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 set "baseuri" "cic:/matita/Q/Qplus".
17 include "nat/factorization.ma".
20 (* transformation from nat_fact to fracion *)
21 let rec nat_fact_to_fraction l \def
23 [nf_last a \Rightarrow pp a
24 |nf_cons a p \Rightarrow
25 cons (Z_of_nat a) (nat_fact_to_fraction p)
29 (* returns the numerator of a fraction in the form of a nat_fact_all *)
30 let rec numerator f \def
32 [pp a \Rightarrow nfa_proper (nf_last a)
33 |nn a \Rightarrow nfa_one
35 let n \def numerator l in
37 [nfa_zero \Rightarrow (* this case is vacuous *) nfa_zero
40 [OZ \Rightarrow nfa_one
41 |pos x \Rightarrow nfa_proper (nf_last x)
42 |neg x \Rightarrow nfa_one
44 |nfa_proper g \Rightarrow
46 [OZ \Rightarrow nfa_proper (nf_cons O g)
47 |pos x \Rightarrow nfa_proper (nf_cons (S x) g)
48 |neg x \Rightarrow nfa_proper (nf_cons O g)
54 theorem numerator_nat_fact_to_fraction: \forall g:nat_fact.
55 numerator (nat_fact_to_fraction g) = nfa_proper g.
58 [simplify.reflexivity.
59 |simplify.rewrite > H.simplify.
64 definition numeratorQ \def
65 \lambda q.match q with
66 [OQ \Rightarrow nfa_zero
69 [one \Rightarrow nfa_one
70 |frac x \Rightarrow numerator x
74 [one \Rightarrow nfa_one
75 |frac x \Rightarrow numerator x
80 definition nat_fact_all_to_Q \def
83 [nfa_zero \Rightarrow OQ
84 |nfa_one \Rightarrow Qpos one
85 |nfa_proper l \Rightarrow Qpos (frac (nat_fact_to_fraction l))
89 theorem numeratorQ_nat_fact_all_to_Q: \forall g.
90 numeratorQ (nat_fact_all_to_Q g) = g.
94 |apply numerator_nat_fact_to_fraction
98 definition nat_to_Q \def
99 \lambda n. nat_fact_all_to_Q (factorize n).
101 let rec nat_fact_to_fraction_inv l \def
103 [nf_last a \Rightarrow nn a
104 |nf_cons a p \Rightarrow
105 cons (neg_Z_of_nat a) (nat_fact_to_fraction_inv p)
110 definition nat_fact_all_to_Q_inv \def
113 [nfa_zero \Rightarrow OQ
114 |nfa_one \Rightarrow Qpos one
115 |nfa_proper l \Rightarrow Qpos (frac (nat_fact_to_fraction_inv l))
119 definition nat_to_Q_inv \def
120 \lambda n. nat_fact_all_to_Q_inv (factorize n).
124 \lambda q.match q with
126 |Qpos r \Rightarrow Qpos (rinv r)
127 |Qneg r \Rightarrow Qneg (rinv r)
130 definition frac:nat \to nat \to Q \def
131 \lambda p,q. Qtimes (nat_to_Q p) (Qinv (nat_to_Q q)).
133 theorem rtimes_oner: \forall r.rtimes r one = r.
134 intro.cases r;reflexivity.
137 theorem rtimes_onel: \forall r.rtimes one r = r.
138 intro.cases r;reflexivity.
141 definition Qone \def Qpos one.
143 theorem Qtimes_Qoner: \forall q.Qtimes q Qone = q.
157 theorem Qtimes_Qonel: \forall q.Qtimes Qone q = q.
171 let rec times_f h g \def
173 [nf_last a \Rightarrow
175 [nf_last b \Rightarrow nf_last (S (a+b))
176 |nf_cons b g1 \Rightarrow nf_cons (S (a+b)) g1
178 |nf_cons a h1 \Rightarrow
180 [nf_last b \Rightarrow nf_cons (S (a+b)) h1
181 |nf_cons b g1 \Rightarrow nf_cons (a+b) (times_f h1 g1)
186 definition times_fa \def
189 [nfa_zero \Rightarrow nfa_zero
190 |nfa_one \Rightarrow g
191 |nfa_proper f1 \Rightarrow match g with
192 [nfa_zero \Rightarrow nfa_zero
193 |nfa_one \Rightarrow nfa_proper f1
194 |nfa_proper g1 \Rightarrow nfa_proper (times_f f1 g1)
199 theorem eq_times_f_times1:\forall g,h,m. defactorize_aux (times_f g h) m
200 =defactorize_aux g m*defactorize_aux h m.
202 [elim h;simplify;autobatch
205 |simplify.rewrite > (H n3 (S m)).autobatch
210 theorem eq_times_fa_times: \forall f,g.
211 defactorize (times_fa f g) = defactorize f*defactorize g.
215 |simplify.apply plus_n_O
219 |apply eq_times_f_times1
224 theorem eq_times_times_fa: \forall n,m.
225 factorize (n*m) = times_fa (factorize n) (factorize m).
227 rewrite <(factorize_defactorize (times_fa (factorize n) (factorize m))).
228 rewrite > eq_times_fa_times.
229 rewrite > defactorize_factorize.
230 rewrite > defactorize_factorize.
235 theorem eq_plus_Zplus: \forall n,m:nat. Z_of_nat (n+m) =
236 Z_of_nat n + Z_of_nat m.
240 [simplify.rewrite < plus_n_O.reflexivity
241 |simplify.reflexivity.
246 definition unfrac \def \lambda f.
248 [one \Rightarrow pp O
249 |frac f \Rightarrow f
253 lemma injective_frac: injective fraction ratio frac.
255 change with ((unfrac (frac x)) = (unfrac (frac y))).
256 rewrite < H.reflexivity.
259 theorem times_f_ftimes: \forall n,m.
260 frac (nat_fact_to_fraction (times_f n m))
261 = ftimes (nat_fact_to_fraction n) (nat_fact_to_fraction m).
266 rewrite < plus_n_Sm.reflexivity
268 [simplify.rewrite < plus_n_O.reflexivity
269 |simplify.reflexivity.
274 [simplify.reflexivity
275 |simplify.rewrite < plus_n_Sm.reflexivity
278 cut (\exist h.ftimes (nat_fact_to_fraction n2) (nat_fact_to_fraction n4) = frac h)
284 |apply injective_frac.
288 |generalize in match n4.
290 [cases n6;simplify;autobatch
304 theorem times_fa_Qtimes: \forall f,g. nat_fact_all_to_Q (times_fa f g) =
305 Qtimes (nat_fact_all_to_Q f) (nat_fact_all_to_Q g).
313 |rewrite > times_f_ftimes.reflexivity
318 theorem times_Qtimes: \forall p,q.
319 (nat_to_Q (p*q)) = Qtimes (nat_to_Q p) (nat_to_Q q).
320 intros.unfold nat_to_Q.
321 rewrite < times_fa_Qtimes.
322 rewrite < eq_times_times_fa.
326 theorem rtimes_Zplus: \forall x,y.
327 rtimes (Z_to_ratio x) (Z_to_ratio y) =
337 theorem rtimes_Zplus1: \forall x,y,f.
338 rtimes (Z_to_ratio x) (frac (cons y f)) =
339 frac (cons ((x + y)) f).
348 theorem rtimes_Zplus2: \forall x,y,f.
349 rtimes (frac (cons y f)) (Z_to_ratio x) =
350 frac (cons ((y + x)) f).
359 theorem or_one_frac: \forall f,g.
360 rtimes (frac f) (frac g) = one \lor
361 \exists h.rtimes (frac f) (frac g) = frac h.
363 elim (rtimes (frac f) (frac g))
365 |right.apply (ex_intro ? ? f1).reflexivity
369 theorem one_to_rtimes_Zplus3: \forall x,y:Z.\forall f,g:fraction.
370 rtimes (frac f) (frac g) = one \to
371 rtimes (frac (cons x f)) (frac (cons y g)) = Z_to_ratio (x + y).
372 intros.simplify.simplify in H.rewrite > H.simplify.
376 theorem frac_to_rtimes_Zplus3: \forall x,y:Z.\forall f,g:fraction.
377 \forall h.rtimes (frac f) (frac g) = frac h \to
378 rtimes (frac (cons x f)) (frac (cons y g)) = frac (cons (x + y) h).
379 intros.simplify.simplify in H.rewrite > H.simplify.
383 theorem rtimes_Zplus3: \forall x,y:Z.\forall f,g:fraction.
384 (rtimes (frac f) (frac g) = one \land
385 rtimes (frac (cons x f)) (frac (cons y g)) = Z_to_ratio (x + y))
386 \lor (\exists h.rtimes (frac f) (frac g) = frac h \land
387 rtimes (frac (cons x f)) (frac (cons y g)) =
388 frac (cons (x + y) h)).
391 elim (rtimes (frac f) (frac g));simplify
392 [left.split;reflexivity
394 apply (ex_intro ? ? f1).
399 theorem Z_to_ratio_frac_frac: \forall z,f1,f2.
400 rtimes (rtimes (Z_to_ratio z) (frac f1)) (frac f2)
401 =rtimes (Z_to_ratio z) (rtimes (frac f1) (frac f2)).
405 (rtimes (rtimes (Z_to_ratio z) (Z_to_ratio (pos n))) (Z_to_ratio (pos n1))
406 =rtimes (Z_to_ratio z) (rtimes (Z_to_ratio (pos n)) (Z_to_ratio (pos n1)))).
407 rewrite > rtimes_Zplus.rewrite > rtimes_Zplus.
408 rewrite > rtimes_Zplus.rewrite > rtimes_Zplus.
409 rewrite > assoc_Zplus.reflexivity
411 (rtimes (rtimes (Z_to_ratio z) (Z_to_ratio (pos n))) (Z_to_ratio (neg n1))
412 =rtimes (Z_to_ratio z) (rtimes (Z_to_ratio (pos n)) (Z_to_ratio (neg n1)))).
413 rewrite > rtimes_Zplus.rewrite > rtimes_Zplus.
414 rewrite > rtimes_Zplus.rewrite > rtimes_Zplus.
415 rewrite > assoc_Zplus.reflexivity
417 (rtimes (rtimes (Z_to_ratio z) (Z_to_ratio (pos n))) (frac (cons z1 f))
418 = rtimes (Z_to_ratio z) (rtimes (Z_to_ratio (pos n)) (frac (cons z1 f)))).
419 rewrite > rtimes_Zplus.rewrite > rtimes_Zplus1.
420 rewrite > rtimes_Zplus1.rewrite > rtimes_Zplus1.
421 rewrite > assoc_Zplus.reflexivity
425 (rtimes (rtimes (Z_to_ratio z) (Z_to_ratio (neg n))) (Z_to_ratio (pos n1))
426 =rtimes (Z_to_ratio z) (rtimes (Z_to_ratio (neg n)) (Z_to_ratio (pos n1)))).
427 rewrite > rtimes_Zplus.rewrite > rtimes_Zplus.
428 rewrite > rtimes_Zplus.rewrite > rtimes_Zplus.
429 rewrite > assoc_Zplus.reflexivity
431 (rtimes (rtimes (Z_to_ratio z) (Z_to_ratio (neg n))) (Z_to_ratio (neg n1))
432 =rtimes (Z_to_ratio z) (rtimes (Z_to_ratio (neg n)) (Z_to_ratio (neg n1)))).
433 rewrite > rtimes_Zplus.rewrite > rtimes_Zplus.
434 rewrite > rtimes_Zplus.rewrite > rtimes_Zplus.
435 rewrite > assoc_Zplus.reflexivity
437 (rtimes (rtimes (Z_to_ratio z) (Z_to_ratio (neg n))) (frac (cons z1 f))
438 = rtimes (Z_to_ratio z) (rtimes (Z_to_ratio (neg n)) (frac (cons z1 f)))).
439 rewrite > rtimes_Zplus.rewrite > rtimes_Zplus1.
440 rewrite > rtimes_Zplus1.rewrite > rtimes_Zplus1.
441 rewrite > assoc_Zplus.reflexivity
445 (rtimes (rtimes (Z_to_ratio z) (frac (cons z1 f))) (Z_to_ratio (pos n))
446 =rtimes (Z_to_ratio z) (rtimes (frac (cons z1 f)) (Z_to_ratio (pos n)))).
447 rewrite > rtimes_Zplus1.rewrite > rtimes_Zplus2.
448 rewrite > rtimes_Zplus2.rewrite > rtimes_Zplus1.
449 rewrite > assoc_Zplus.reflexivity
451 (rtimes (rtimes (Z_to_ratio z) (frac (cons z1 f))) (Z_to_ratio (neg n))
452 =rtimes (Z_to_ratio z) (rtimes (frac (cons z1 f)) (Z_to_ratio (neg n)))).
453 rewrite > rtimes_Zplus1.rewrite > rtimes_Zplus2.
454 rewrite > rtimes_Zplus2.rewrite > rtimes_Zplus1.
455 rewrite > assoc_Zplus.reflexivity
456 |elim (or_one_frac f f3)
457 [rewrite > rtimes_Zplus1.
458 rewrite > (one_to_rtimes_Zplus3 ? ? ? ? H2).
459 rewrite > (one_to_rtimes_Zplus3 ? ? ? ? H2).
460 rewrite > rtimes_Zplus.
461 rewrite > assoc_Zplus.reflexivity
463 rewrite > rtimes_Zplus1.
464 rewrite > (frac_to_rtimes_Zplus3 ? ? ? ? a H3).
465 rewrite > (frac_to_rtimes_Zplus3 ? ? ? ? a H3).
466 rewrite > rtimes_Zplus1.
467 rewrite > assoc_Zplus.reflexivity
473 theorem cons_frac_frac: \forall f1,z,f,f2.
474 rtimes (rtimes (frac (cons z f)) (frac f1)) (frac f2)
475 =rtimes (frac (cons z f)) (rtimes (frac f1) (frac f2)).
479 (rtimes (rtimes (frac (cons z f)) (Z_to_ratio (pos n))) (Z_to_ratio (pos n1))
480 =rtimes (frac (cons z f)) (rtimes (Z_to_ratio (pos n)) (Z_to_ratio (pos n1)))).
481 rewrite > rtimes_Zplus2.rewrite > rtimes_Zplus2.
482 rewrite > rtimes_Zplus.rewrite > rtimes_Zplus2.
483 rewrite > assoc_Zplus.reflexivity
485 (rtimes (rtimes (frac (cons z f)) (Z_to_ratio (pos n))) (Z_to_ratio (neg n1))
486 =rtimes (frac (cons z f)) (rtimes (Z_to_ratio (pos n)) (Z_to_ratio (neg n1)))).
487 rewrite > rtimes_Zplus2.rewrite > rtimes_Zplus2.
488 rewrite > rtimes_Zplus.rewrite > rtimes_Zplus2.
489 rewrite > assoc_Zplus.reflexivity
491 (rtimes (rtimes (frac (cons z f)) (Z_to_ratio (pos n))) (frac (cons z1 f3))
492 = rtimes (frac (cons z f)) (rtimes (Z_to_ratio (pos n)) (frac (cons z1 f3)))).
493 rewrite > rtimes_Zplus2.rewrite > rtimes_Zplus1.
494 elim (or_one_frac f f3)
495 [rewrite > (one_to_rtimes_Zplus3 ? ? ? ? H1).
496 rewrite > (one_to_rtimes_Zplus3 ? ? ? ? H1).
497 rewrite > assoc_Zplus.reflexivity
499 rewrite > (frac_to_rtimes_Zplus3 ? ? ? ? a H2).
500 rewrite > (frac_to_rtimes_Zplus3 ? ? ? ? a H2).
501 rewrite > assoc_Zplus.reflexivity
506 (rtimes (rtimes (frac (cons z f)) (Z_to_ratio (neg n))) (Z_to_ratio (pos n1))
507 =rtimes (frac (cons z f)) (rtimes (Z_to_ratio (neg n)) (Z_to_ratio (pos n1)))).
508 rewrite > rtimes_Zplus2.rewrite > rtimes_Zplus2.
509 rewrite > rtimes_Zplus.rewrite > rtimes_Zplus2.
510 rewrite > assoc_Zplus.reflexivity
512 (rtimes (rtimes (frac (cons z f)) (Z_to_ratio (neg n))) (Z_to_ratio (neg n1))
513 =rtimes (frac (cons z f)) (rtimes (Z_to_ratio (neg n)) (Z_to_ratio (neg n1)))).
514 rewrite > rtimes_Zplus2.rewrite > rtimes_Zplus2.
515 rewrite > rtimes_Zplus.rewrite > rtimes_Zplus2.
516 rewrite > assoc_Zplus.reflexivity
518 (rtimes (rtimes (frac (cons z f)) (Z_to_ratio (neg n))) (frac (cons z1 f3))
519 = rtimes (frac (cons z f)) (rtimes (Z_to_ratio (neg n)) (frac (cons z1 f3)))).
520 rewrite > rtimes_Zplus2.rewrite > rtimes_Zplus1.
521 elim (or_one_frac f f3)
522 [rewrite > (one_to_rtimes_Zplus3 ? ? ? ? H1).
523 rewrite > (one_to_rtimes_Zplus3 ? ? ? ? H1).
524 rewrite > assoc_Zplus.reflexivity
526 rewrite > (frac_to_rtimes_Zplus3 ? ? ? ? a H2).
527 rewrite > (frac_to_rtimes_Zplus3 ? ? ? ? a H2).
528 rewrite > assoc_Zplus.reflexivity
533 (rtimes (rtimes (frac (cons z1 f2)) (frac (cons z f))) (Z_to_ratio (pos n))
534 =rtimes (frac (cons z1 f2)) (rtimes (frac (cons z f)) (Z_to_ratio (pos n)))).
535 rewrite > rtimes_Zplus2.
536 elim (or_one_frac f2 f)
537 [rewrite > (one_to_rtimes_Zplus3 ? ? ? ? H1).
538 rewrite > (one_to_rtimes_Zplus3 ? ? ? ? H1).
539 rewrite > rtimes_Zplus.
540 rewrite > assoc_Zplus.reflexivity
542 rewrite > (frac_to_rtimes_Zplus3 ? ? ? ? a H2).
543 rewrite > (frac_to_rtimes_Zplus3 ? ? ? ? a H2).
544 rewrite > rtimes_Zplus2.
545 rewrite > assoc_Zplus.reflexivity
548 (rtimes (rtimes (frac (cons z1 f2)) (frac (cons z f))) (Z_to_ratio (neg n))
549 =rtimes (frac (cons z1 f2)) (rtimes (frac (cons z f)) (Z_to_ratio (neg n)))).
550 rewrite > rtimes_Zplus2.
551 elim (or_one_frac f2 f)
552 [rewrite > (one_to_rtimes_Zplus3 ? ? ? ? H1).
553 rewrite > (one_to_rtimes_Zplus3 ? ? ? ? H1).
554 rewrite > rtimes_Zplus.
555 rewrite > assoc_Zplus.reflexivity
557 rewrite > (frac_to_rtimes_Zplus3 ? ? ? ? a H2).
558 rewrite > (frac_to_rtimes_Zplus3 ? ? ? ? a H2).
559 rewrite > rtimes_Zplus2.
560 rewrite > assoc_Zplus.reflexivity
562 |elim (or_one_frac f2 f)
563 [rewrite > (one_to_rtimes_Zplus3 ? ? ? ? H2).
564 rewrite > rtimes_Zplus1.
565 elim (or_one_frac f f4)
566 [rewrite > (one_to_rtimes_Zplus3 ? ? ? ? H3).
567 rewrite > rtimes_Zplus2.
570 rewrite > assoc_Zplus.reflexivity
571 |apply injective_frac.
572 rewrite < rtimes_onel.
574 (* problema inaspettato: mi serve l'unicita' dell'inversa,
575 che richiede (?) l'associativita. Per fortuna basta
576 l'ipotesi induttiva. *)
579 (rtimes (rtimes (Z_to_ratio (pos n)) (frac f)) (frac f4)=Z_to_ratio (pos n)).
580 rewrite > Z_to_ratio_frac_frac.
582 rewrite > rtimes_oner.
585 (rtimes (rtimes (Z_to_ratio (neg n)) (frac f)) (frac f4)=Z_to_ratio (neg n)).
586 rewrite > Z_to_ratio_frac_frac.
588 rewrite > rtimes_oner.
592 rewrite > rtimes_oner.
597 rewrite > (frac_to_rtimes_Zplus3 ? ? ? ? a H4).
598 cut (rtimes (frac f2) (frac a) = frac f4)
599 [rewrite > (frac_to_rtimes_Zplus3 ? ? ? ? f4 Hcut).
600 rewrite > assoc_Zplus.reflexivity
602 generalize in match H2.
605 (rtimes (Z_to_ratio (pos n)) (rtimes (frac f)(frac f4)) =frac f4).
606 rewrite < Z_to_ratio_frac_frac.
608 rewrite > rtimes_onel.
611 (rtimes (Z_to_ratio (neg n)) (rtimes (frac f)(frac f4)) =frac f4).
612 rewrite < Z_to_ratio_frac_frac.
614 rewrite > rtimes_onel.
618 rewrite > rtimes_onel.
624 rewrite > (frac_to_rtimes_Zplus3 ? ? ? ? a H3).
625 elim (or_one_frac f f4)
626 [rewrite > (one_to_rtimes_Zplus3 ? ? ? ? H2).
627 rewrite > rtimes_Zplus2.
628 cut (rtimes (frac a) (frac f4) = frac f2)
629 [rewrite > (frac_to_rtimes_Zplus3 ? ? ? ? f2 Hcut).
630 rewrite > assoc_Zplus.reflexivity
632 generalize in match H2.
635 (rtimes (rtimes (Z_to_ratio (pos n)) (frac f)) (frac f4)=Z_to_ratio (pos n)).
636 rewrite > Z_to_ratio_frac_frac.
638 rewrite > rtimes_oner.
641 (rtimes (rtimes (Z_to_ratio (neg n)) (frac f)) (frac f4)=Z_to_ratio (neg n)).
642 rewrite > Z_to_ratio_frac_frac.
644 rewrite > rtimes_oner.
648 rewrite > rtimes_oner.
653 rewrite > (frac_to_rtimes_Zplus3 ? ? ? ? a1 H4).
654 elim (or_one_frac a f4)
655 [rewrite > (one_to_rtimes_Zplus3 ? ? ? ? H2).
656 cut (rtimes (frac f2) (frac a1) = one)
657 [rewrite > (one_to_rtimes_Zplus3 ? ? ? ? Hcut).
658 rewrite > assoc_Zplus.reflexivity
660 generalize in match H3.
663 (rtimes (Z_to_ratio (pos n)) (rtimes (frac f)(frac f4)) = one).
664 rewrite < Z_to_ratio_frac_frac.
668 (rtimes (Z_to_ratio (neg n)) (rtimes (frac f)(frac f4)) = one).
669 rewrite < Z_to_ratio_frac_frac.
678 rewrite > (frac_to_rtimes_Zplus3 ? ? ? ? a2 H5).
679 cut (rtimes (frac f2) (frac a1) = frac a2)
680 [rewrite > (frac_to_rtimes_Zplus3 ? ? ? ? a2 Hcut).
681 rewrite > assoc_Zplus.reflexivity
683 generalize in match H3.
686 (rtimes (Z_to_ratio (pos n)) (rtimes (frac f)(frac f4)) = frac a2).
687 rewrite < Z_to_ratio_frac_frac.
691 (rtimes (Z_to_ratio (neg n)) (rtimes (frac f)(frac f4)) = frac a2).
692 rewrite < Z_to_ratio_frac_frac.
707 theorem frac_frac_fracaux: \forall f,f1,f2.
708 rtimes (rtimes (frac f) (frac f1)) (frac f2)
709 =rtimes (frac f) (rtimes (frac f1) (frac f2)).
713 (rtimes (rtimes (Z_to_ratio (pos n)) (frac f1)) (frac f2)
714 =rtimes (Z_to_ratio (pos n)) (rtimes (frac f1) (frac f2))).
715 apply Z_to_ratio_frac_frac
717 (rtimes (rtimes (Z_to_ratio (neg n)) (frac f1)) (frac f2)
718 =rtimes (Z_to_ratio (neg n)) (rtimes (frac f1) (frac f2))).
719 apply Z_to_ratio_frac_frac
720 |apply cons_frac_frac
724 theorem associative_rtimes:associative ? rtimes.
731 [rewrite > rtimes_oner.rewrite > rtimes_oner.reflexivity
732 |apply frac_frac_fracaux
738 theorem associative_Qtimes:associative ? Qtimes.
742 (* non posso scrivere 2,3: ... ?? *)
747 |simplify.rewrite > associative_rtimes.
749 |simplify.rewrite > associative_rtimes.
754 |simplify.rewrite > associative_rtimes.
756 |simplify.rewrite > associative_rtimes.
764 |simplify.rewrite > associative_rtimes.
766 |simplify.rewrite > associative_rtimes.
771 |simplify.rewrite > associative_rtimes.
773 |simplify.rewrite > associative_rtimes.
780 theorem Qtimes_OQ: \forall q.Qtimes q OQ = OQ.
781 intro.cases q;reflexivity.
784 theorem symmetric_Qtimes: symmetric ? Qtimes.
787 [simplify in ⊢ (? ? % ?).rewrite > Qtimes_OQ.reflexivity
790 |simplify.rewrite > symmetric_rtimes.reflexivity
791 |simplify.rewrite > symmetric_rtimes.reflexivity
795 |simplify.rewrite > symmetric_rtimes.reflexivity
796 |simplify.rewrite > symmetric_rtimes.reflexivity
801 theorem Qtimes_Qinv: \forall q. q \neq OQ \to Qtimes q (Qinv q) = Qone.
805 |simplify.rewrite > rtimes_rinv.reflexivity
806 |simplify.rewrite > rtimes_rinv.reflexivity
810 theorem eq_Qtimes_OQ_to_eq_OQ: \forall p,q.
811 Qtimes p q = OQ \to p = OQ \lor q = OQ.
814 [intro.left.reflexivity
816 [intro.right.reflexivity
817 |simplify.intro.destruct H
818 |simplify.intro.destruct H
821 [intro.right.reflexivity
822 |simplify.intro.destruct H
823 |simplify.intro.destruct H
828 theorem Qinv_Qtimes: \forall p,q.
829 p \neq OQ \to q \neq OQ \to
831 Qtimes (Qinv p) (Qinv q).
833 rewrite < Qtimes_Qonel in ⊢ (? ? ? %).
834 rewrite < (Qtimes_Qinv (Qtimes p q))
835 [lapply (Qtimes_Qinv ? H).
836 lapply (Qtimes_Qinv ? H1).
837 rewrite > symmetric_Qtimes in ⊢ (? ? ? (? % ?)).
838 rewrite > associative_Qtimes.
839 rewrite > associative_Qtimes.
840 rewrite < associative_Qtimes in ⊢ (? ? ? (? ? (? ? %))).
841 rewrite < symmetric_Qtimes in ⊢ (? ? ? (? ? (? ? (? % ?)))).
842 rewrite > associative_Qtimes in ⊢ (? ? ? (? ? (? ? %))).
844 rewrite > Qtimes_Qoner.
846 rewrite > Qtimes_Qoner.
849 elim (eq_Qtimes_OQ_to_eq_OQ ? ? H2)
850 [apply (H H3)|apply (H1 H3)]
854 (* a stronger version, taking advantage of inv(O) = O *)
855 theorem Qinv_Qtimes': \forall p,q.
857 Qtimes (Qinv p) (Qinv q).
863 |apply Qinv_Qtimes;intro;destruct H
864 |apply Qinv_Qtimes;intro;destruct H
868 |apply Qinv_Qtimes;intro;destruct H
869 |apply Qinv_Qtimes;intro;destruct H
874 theorem Qtimes_frac_frac: \forall p,q,r,s.
875 Qtimes (frac p q) (frac r s) = (frac (p*r) (q*s)).
878 rewrite > associative_Qtimes.
879 rewrite < associative_Qtimes in ⊢ (? ? (? ? %) ?).
880 rewrite > symmetric_Qtimes in ⊢ (? ? (? ? (? % ?)) ?).
881 rewrite > associative_Qtimes in ⊢ (? ? (? ? %) ?).
882 rewrite < associative_Qtimes.
883 rewrite < times_Qtimes.
884 rewrite < Qinv_Qtimes'.
885 rewrite < times_Qtimes.