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 definition Qone ≝ Qpos one.
34 definition nat_fact_all_to_Q \def
37 [nfa_zero \Rightarrow OQ
38 |nfa_one \Rightarrow Qpos one
39 |nfa_proper l \Rightarrow Qpos (frac (nat_fact_to_fraction l))
42 definition nat_to_Q ≝ λn.nat_fact_all_to_Q (factorize n).
48 | pos n ⇒ nat_to_Q (S n)
49 | neg n ⇒ Qopp (nat_to_Q (S n))
52 definition numeratorQ \def
53 \lambda q.match q with
54 [OQ \Rightarrow nfa_zero
57 [one \Rightarrow nfa_one
58 |frac x \Rightarrow numerator x
62 [one \Rightarrow nfa_one
63 |frac x \Rightarrow numerator x
67 theorem numeratorQ_nat_fact_all_to_Q: \forall g.
68 numeratorQ (nat_fact_all_to_Q g) = g.
72 |apply numerator_nat_fact_to_fraction