]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/library/Q/q/q.ma
First snapshot at trying to clean up the Q library.
[helm.git] / helm / software / matita / library / Q / q / q.ma
1 (**************************************************************************)
2 (*       ___                                                                *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||       A.Asperti, C.Sacerdoti Coen,                          *)
8 (*      ||A||       E.Tassi, S.Zacchiroli                                 *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU Lesser General Public License Version 2.1         *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "Q/ratio/ratio.ma".
16
17 (* a rational number is either O or a ratio with a sign *)
18 inductive Q : Set \def 
19     OQ : Q
20   | Qpos : ratio  \to Q
21   | Qneg : ratio  \to Q.
22
23 definition Q_of_nat ≝
24  λn.
25   match factorize n with
26    [ nfa_zero ⇒ OQ
27    | nfa_one ⇒ Qpos one
28    | nfa_proper l ⇒ Qpos (frac (nat_fact_to_fraction l))
29    ].