(* *)
(**************************************************************************)
-set "baseuri" "cic:/matita/Q/frac".
-
-include "nat/factorization.ma".
-include "Q/q.ma".
-
-
-definition numeratorQ \def
-\lambda q.match q with
- [OQ \Rightarrow nfa_zero
- |Qpos r \Rightarrow
- match r with
- [one \Rightarrow nfa_one
- |frac x \Rightarrow numerator x
- ]
- |Qneg r \Rightarrow
- match r with
- [one \Rightarrow nfa_one
- |frac x \Rightarrow numerator x
- ]
- ]
-.
-
-definition nat_fact_all_to_Q \def
-\lambda n.
- match n with
- [nfa_zero \Rightarrow OQ
- |nfa_one \Rightarrow Qpos one
- |nfa_proper l \Rightarrow Qpos (frac (nat_fact_to_fraction l))
- ]
-.
-
-theorem numeratorQ_nat_fact_all_to_Q: \forall g.
-numeratorQ (nat_fact_all_to_Q g) = g.
-intro.cases g
- [reflexivity
- |reflexivity
- |apply numerator_nat_fact_to_fraction
- ]
-qed.
-
-definition nat_to_Q \def
-\lambda n. nat_fact_all_to_Q (factorize n).
-
+(*
let rec nat_fact_to_fraction_inv l \def
match l with
[nf_last a \Rightarrow nn a
]
.
-
-(*
definition nat_fact_all_to_Q_inv \def
\lambda n.
match n with
\lambda n. nat_fact_all_to_Q_inv (factorize n).
*)
-definition Qinv \def
-\lambda q.match q with
-[OQ \Rightarrow OQ
-|Qpos r \Rightarrow Qpos (rinv r)
-|Qneg r \Rightarrow Qneg (rinv r)
-].
-
definition frac:nat \to nat \to Q \def
\lambda p,q. Qtimes (nat_to_Q p) (Qinv (nat_to_Q q)).
intro.cases r;reflexivity.
qed.
-definition Qone \def Qpos one.
-
-theorem Qtimes_Qoner: \forall q.Qtimes q Qone = q.
-intro.cases q
- [reflexivity
- |cases r
- [reflexivity
- |reflexivity
- ]
- |cases r
- [reflexivity
- |reflexivity
- ]
- ]
-qed.
-
-theorem Qtimes_Qonel: \forall q.Qtimes Qone q = q.
-intros.cases q
- [reflexivity
- |cases r
- [reflexivity
- |reflexivity
- ]
- |cases r
- [reflexivity
- |reflexivity
- ]
- ]
-qed.
-
let rec times_f h g \def
match h with
[nf_last a \Rightarrow
=rtimes (Z_to_ratio z) (rtimes (frac f1) (frac f2)).
intros 2.elim f1
[elim f2
- [ change with
+ [change with
(rtimes (rtimes (Z_to_ratio z) (Z_to_ratio (pos n))) (Z_to_ratio (pos n1))
=rtimes (Z_to_ratio z) (rtimes (Z_to_ratio (pos n)) (Z_to_ratio (pos n1)))).
rewrite > rtimes_Zplus.rewrite > rtimes_Zplus.
[simplify in ⊢ (? ? % ?).rewrite > Qtimes_OQ.reflexivity
|elim y
[reflexivity
- |simplify.alias id "symmetric_rtimes" = "cic:/matita/Q/times/symmetric_rtimes.con".
-rewrite > symmetric_rtimes.reflexivity
+ |simplify.rewrite > symmetric_rtimes.reflexivity
|simplify.rewrite > symmetric_rtimes.reflexivity
]
|elim y
intro.
cases q;intro
[elim H.reflexivity
- |simplify.alias id "rtimes_rinv" = "cic:/matita/Q/times/rtimes_rinv.con".
-rewrite > rtimes_rinv.reflexivity
+ |simplify.rewrite > rtimes_rinv.reflexivity
|simplify.rewrite > rtimes_rinv.reflexivity
]
qed.
Qinv(Qtimes p q) =
Qtimes (Qinv p) (Qinv q).
intros.
-rewrite < Qtimes_Qonel in ⊢ (? ? ? %).
+rewrite < Qtimes_Qone_q in ⊢ (? ? ? %).
rewrite < (Qtimes_Qinv (Qtimes p q))
[lapply (Qtimes_Qinv ? H).
lapply (Qtimes_Qinv ? H1).
rewrite < symmetric_Qtimes in ⊢ (? ? ? (? ? (? ? (? % ?)))).
rewrite > associative_Qtimes in ⊢ (? ? ? (? ? (? ? %))).
rewrite > Hletin1.
- rewrite > Qtimes_Qoner.
+ rewrite > Qtimes_q_Qone.
rewrite > Hletin.
- rewrite > Qtimes_Qoner.
+ rewrite > Qtimes_q_Qone.
reflexivity
|intro.
elim (eq_Qtimes_OQ_to_eq_OQ ? ? H2)
|generalize in match H.
rewrite > H2.
rewrite > H3.
- rewrite > Qtimes_Qoner.
+ rewrite > Qtimes_q_Qone.
intro.
destruct H1.
assumption
|generalize in match H.
rewrite > H2.
rewrite > H3.
- rewrite > Qtimes_Qoner.
+ rewrite > Qtimes_q_Qone.
intro.
destruct H1.
assumption
|generalize in match H.
rewrite > H2.
rewrite > H3.
- rewrite > Qtimes_Qoner.
+ rewrite > Qtimes_q_Qone.
intro.
destruct H1.
assumption