]> matita.cs.unibo.it Git - helm.git/blob - matita/library/nat/times.ma
experimental branch with no set baseuri command and no developments
[helm.git] / matita / library / nat / times.ma
1 (**************************************************************************)
2 (*       __                                                               *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||       A.Asperti, C.Sacerdoti Coen,                          *)
8 (*      ||A||       E.Tassi, S.Zacchiroli                                 *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU Lesser General Public License Version 2.1         *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15
16
17 include "nat/plus.ma".
18
19 let rec times n m \def 
20  match n with 
21  [ O \Rightarrow O
22  | (S p) \Rightarrow m+(times p m) ].
23
24 (*CSC: the URI must disappear: there is a bug now *)
25 interpretation "natural times" 'times x y = (cic:/matita/nat/times/times.con x y).
26
27 theorem times_n_O: \forall n:nat. O = n*O.
28 intros.elim n.
29 simplify.reflexivity.
30 simplify.assumption.
31 qed.
32
33 theorem times_n_Sm : 
34 \forall n,m:nat. n+(n*m) = n*(S m).
35 intros.elim n.
36 simplify.reflexivity.
37 simplify.apply eq_f.rewrite < H.
38 transitivity ((n1+m)+n1*m).symmetry.apply assoc_plus.
39 transitivity ((m+n1)+n1*m).
40 apply eq_f2.
41 apply sym_plus.
42 reflexivity.
43 apply assoc_plus.
44 qed.
45
46 theorem times_O_to_O: \forall n,m:nat.n*m = O \to n = O \lor m= O.
47 apply nat_elim2;intros
48   [left.reflexivity
49   |right.reflexivity
50   |apply False_ind.
51    simplify in H1.
52    apply (not_eq_O_S ? (sym_eq  ? ? ? H1))
53   ]
54 qed.
55
56 theorem times_n_SO : \forall n:nat. n = n * S O.
57 intros.
58 rewrite < times_n_Sm.
59 rewrite < times_n_O.
60 rewrite < plus_n_O.
61 reflexivity.
62 qed.
63
64 theorem times_SSO_n : \forall n:nat. n + n = S (S O) * n.
65 intros.
66 simplify.
67 rewrite < plus_n_O.
68 reflexivity.
69 qed.
70
71 theorem symmetric_times : symmetric nat times. 
72 unfold symmetric.
73 intros.elim x.
74 simplify.apply times_n_O.
75 simplify.rewrite > H.apply times_n_Sm.
76 qed.
77
78 variant sym_times : \forall n,m:nat. n*m = m*n \def
79 symmetric_times.
80
81 theorem distributive_times_plus : distributive nat times plus.
82 unfold distributive.
83 intros.elim x.
84 simplify.reflexivity.
85 simplify.rewrite > H. rewrite > assoc_plus.rewrite > assoc_plus.
86 apply eq_f.rewrite < assoc_plus. rewrite < (sym_plus ? z).
87 rewrite > assoc_plus.reflexivity.
88 qed.
89
90 variant distr_times_plus: \forall n,m,p:nat. n*(m+p) = n*m + n*p
91 \def distributive_times_plus.
92
93 theorem associative_times: associative nat times.
94 unfold associative.intros.
95 elim x.simplify.apply refl_eq.
96 simplify.rewrite < sym_times.
97 rewrite > distr_times_plus.
98 rewrite < sym_times.
99 rewrite < (sym_times (times n y) z).
100 rewrite < H.apply refl_eq.
101 qed.
102
103 variant assoc_times: \forall n,m,p:nat. (n*m)*p = n*(m*p) \def
104 associative_times.