1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| A.Asperti, C.Sacerdoti Coen, *)
8 (* ||A|| E.Tassi, S.Zacchiroli *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU Lesser General Public License Version 2.1 *)
13 (**************************************************************************)
15 include "Q/ratio/ratio.ma".
16 include "Q/fraction/numerator_denominator.ma".
18 (* a rational number is either O or a ratio with a sign *)
19 inductive Q : Set \def
24 interpretation "Rationals" 'Q = Q.
26 definition Qone ≝ Qpos one.
36 definition nat_fact_all_to_Q \def
39 [nfa_zero \Rightarrow OQ
40 |nfa_one \Rightarrow Qpos one
41 |nfa_proper l \Rightarrow Qpos (frac (nat_fact_to_fraction l))
44 definition nat_to_Q ≝ λn.nat_fact_all_to_Q (factorize n).
50 | pos n ⇒ nat_to_Q (S n)
51 | neg n ⇒ Qopp (nat_to_Q (S n))
54 definition numeratorQ \def
55 \lambda q.match q with
56 [OQ \Rightarrow nfa_zero
59 [one \Rightarrow nfa_one
60 |frac x \Rightarrow numerator x
64 [one \Rightarrow nfa_one
65 |frac x \Rightarrow numerator x
69 theorem numeratorQ_nat_fact_all_to_Q: \forall g.
70 numeratorQ (nat_fact_all_to_Q g) = g.
74 |apply numerator_nat_fact_to_fraction