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 "nat/plus.ma".
17 let rec times n m \def
20 | (S p) \Rightarrow m+(times p m) ].
22 interpretation "natural times" 'times x y = (cic:/matita/nat/times/times.con x y).
25 \forall n,m:nat. m+n*m = S n*m.
29 theorem times_n_O: \forall n:nat. O = n*O.
36 \forall n,m:nat. n+(n*m) = n*(S m).
39 simplify.apply eq_f.rewrite < H.
40 transitivity ((n1+m)+n1*m).symmetry.apply assoc_plus.
41 transitivity ((m+n1)+n1*m).
48 theorem times_O_to_O: \forall n,m:nat.n*m = O \to n = O \lor m= O.
49 apply nat_elim2;intros
54 apply (not_eq_O_S ? (sym_eq ? ? ? H1))
58 theorem times_n_SO : \forall n:nat. n = n * S O.
66 theorem times_SSO_n : \forall n:nat. n + n = S (S O) * n.
73 alias num (instance 0) = "natural number".
74 lemma times_SSO: \forall n.2*(S n) = S(S(2*n)).
75 intro.simplify.rewrite < plus_n_Sm.reflexivity.
78 theorem or_eq_eq_S: \forall n.\exists m.
79 n = (S(S O))*m \lor n = S ((S(S O))*m).
81 [apply (ex_intro ? ? O).
84 [apply (ex_intro ? ? a).
85 right.apply eq_f.assumption
86 |apply (ex_intro ? ? (S a)).
94 theorem symmetric_times : symmetric nat times.
97 simplify.apply times_n_O.
98 (* applyS times_n_Sm. *)
99 simplify.rewrite > H.apply times_n_Sm.
102 variant sym_times : \forall n,m:nat. n*m = m*n \def
105 theorem distributive_times_plus : distributive nat times plus.
108 simplify.reflexivity.
109 simplify.rewrite > H. rewrite > assoc_plus.rewrite > assoc_plus.
110 apply eq_f.rewrite < assoc_plus. rewrite < (sym_plus ? z).
111 rewrite > assoc_plus.reflexivity.
114 variant distr_times_plus: \forall n,m,p:nat. n*(m+p) = n*m + n*p
115 \def distributive_times_plus.
117 theorem associative_times: associative nat times.
120 elim x. simplify.apply refl_eq.
121 simplify.rewrite < sym_times.
122 rewrite > distr_times_plus.
124 rewrite < (sym_times (times n y) z).
125 rewrite < H.apply refl_eq.
128 variant assoc_times: \forall n,m,p:nat. (n*m)*p = n*(m*p) \def
131 lemma times_times: ∀x,y,z. x*(y*z) = y*(x*z).
132 intros.autobatch paramodulation.