2 (**************************************************************************)
5 (* ||A|| A project by Andrea Asperti *)
7 (* ||I|| Developers: *)
8 (* ||T|| A.Asperti, C.Sacerdoti Coen, *)
9 (* ||A|| E.Tassi, S.Zacchiroli *)
11 (* \ / This file is distributed under the terms of the *)
12 (* v GNU Lesser General Public License Version 2.1 *)
14 (**************************************************************************)
16 include "nat/plus.ma".
18 let rec times n m \def
21 | (S p) \Rightarrow m+(times p m) ].
23 interpretation "natural times" 'times x y = (times x y).
26 \forall n,m:nat. m+n*m = S n*m.
30 theorem times_n_O: \forall n:nat. O = n*O.
37 \forall n,m:nat. n+(n*m) = n*(S m).
43 apply eq_f.rewrite < H.
44 transitivity ((n1+m)+n1*m).symmetry.apply assoc_plus.
45 transitivity ((m+n1)+n1*m).
53 theorem times_O_to_O: \forall n,m:nat.n*m = O \to n = O \lor m= O.
54 apply nat_elim2;intros
59 apply (not_eq_O_S ? (sym_eq ? ? ? H1))
63 theorem times_n_SO : \forall n:nat. n = n * S O.
64 intros. demodulate. reflexivity. (*
71 theorem times_SSO_n : \forall n:nat. n + n = S (S O) * n.
78 alias num (instance 0) = "natural number".
79 lemma times_SSO: \forall n.2*(S n) = S(S(2*n)).
80 intro.simplify.rewrite < plus_n_Sm.reflexivity.
83 theorem or_eq_eq_S: \forall n.\exists m.
84 n = (S(S O))*m \lor n = S ((S(S O))*m).
86 [apply (ex_intro ? ? O).
89 [apply (ex_intro ? ? a).
90 right.apply eq_f.assumption
91 |apply (ex_intro ? ? (S a)).
99 theorem symmetric_times : symmetric nat times.
102 [ simplify. apply times_n_O.
103 | demodulate. reflexivity. (*
104 (* applyS times_n_Sm. *)
105 simplify.rewrite > H.apply times_n_Sm.*)]
108 variant sym_times : \forall n,m:nat. n*m = m*n \def
111 theorem distributive_times_plus : distributive nat times plus.
114 simplify.reflexivity.
118 rewrite > H. rewrite > assoc_plus.rewrite > assoc_plus.
119 apply eq_f.rewrite < assoc_plus. rewrite < (sym_plus ? z).
120 rewrite > assoc_plus.reflexivity. *)
123 variant distr_times_plus: \forall n,m,p:nat. n*(m+p) = n*m + n*p
124 \def distributive_times_plus.
126 theorem associative_times: associative nat times.
129 elim x. simplify.apply refl_eq.
134 rewrite > distr_times_plus.
136 rewrite < (sym_times (times n y) z).
137 rewrite < H.apply refl_eq.
141 variant assoc_times: \forall n,m,p:nat. (n*m)*p = n*(m*p) \def
144 lemma times_times: ∀x,y,z. x*(y*z) = y*(x*z).
146 demodulate. reflexivity.
147 (* autobatch paramodulation. *)