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 = (times 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).
40 demodulate all steps=3.
42 apply eq_f.rewrite < H.
43 transitivity ((n1+m)+n1*m).symmetry.apply assoc_plus.
44 transitivity ((m+n1)+n1*m).
52 theorem times_O_to_O: \forall n,m:nat.n*m = O \to n = O \lor m= O.
53 apply nat_elim2;intros
58 apply (not_eq_O_S ? (sym_eq ? ? ? H1))
62 theorem times_n_SO : \forall n:nat. n = n * S O.
63 intros. demodulate. reflexivity. (*
70 theorem times_SSO_n : \forall n:nat. n + n = S (S O) * n.
77 alias num (instance 0) = "natural number".
78 lemma times_SSO: \forall n.2*(S n) = S(S(2*n)).
79 intro.simplify.rewrite < plus_n_Sm.reflexivity.
82 theorem or_eq_eq_S: \forall n.\exists m.
83 n = (S(S O))*m \lor n = S ((S(S O))*m).
85 [apply (ex_intro ? ? O).
88 [apply (ex_intro ? ? a).
89 right.apply eq_f.assumption
90 |apply (ex_intro ? ? (S a)).
98 theorem symmetric_times : symmetric nat times.
101 [ simplify. apply times_n_O.
102 | demodulate. reflexivity. (*
103 (* applyS times_n_Sm. *)
104 simplify.rewrite > H.apply times_n_Sm.*)]
107 variant sym_times : \forall n,m:nat. n*m = m*n \def
110 theorem distributive_times_plus : distributive nat times plus.
113 simplify.reflexivity.
115 demodulate all steps=16.
117 rewrite > H. rewrite > assoc_plus.rewrite > assoc_plus.
118 apply eq_f.rewrite < assoc_plus. rewrite < (sym_plus ? z).
119 rewrite > assoc_plus.reflexivity. *)
122 variant distr_times_plus: \forall n,m,p:nat. n*(m+p) = n*m + n*p
123 \def distributive_times_plus.
125 theorem associative_times: associative nat times.
128 elim x. simplify.apply refl_eq.
130 demodulate all steps=4.
133 rewrite > distr_times_plus.
135 rewrite < (sym_times (times n y) z).
136 rewrite < H.apply refl_eq.
140 variant assoc_times: \forall n,m,p:nat. (n*m)*p = n*(m*p) \def
143 lemma times_times: ∀x,y,z. x*(y*z) = y*(x*z).
145 demodulate. reflexivity.
146 (* autobatch paramodulation. *)