]> matita.cs.unibo.it Git - helm.git/blob - matita/library/nat/plus.ma
More documentation committed.
[helm.git] / matita / library / nat / plus.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 set "baseuri" "cic:/matita/nat/plus".
16
17 include "nat/nat.ma".
18
19 let rec plus n m \def 
20  match n with 
21  [ O \Rightarrow m
22  | (S p) \Rightarrow S (plus p m) ].
23
24 (*CSC: the URI must disappear: there is a bug now *)
25 interpretation "natural plus" 'plus x y = (cic:/matita/nat/plus/plus.con x y).
26
27 theorem plus_n_O: \forall n:nat. n = n+O.
28 intros.elim n.
29 simplify.reflexivity.
30 simplify.apply eq_f.assumption.
31 qed.
32
33 theorem plus_n_Sm : \forall n,m:nat. S (n+m) = n+(S m).
34 intros.elim n.
35 simplify.reflexivity.
36 simplify.apply eq_f.assumption.
37 qed.
38
39 theorem sym_plus: \forall n,m:nat. n+m = m+n.
40 intros.elim n.
41 simplify.apply plus_n_O.
42 simplify.rewrite > H.apply plus_n_Sm.
43 qed.
44
45 theorem associative_plus : associative nat plus.
46 unfold associative.intros.elim x.
47 simplify.reflexivity.
48 simplify.apply eq_f.assumption.
49 qed.
50
51 theorem assoc_plus : \forall n,m,p:nat. (n+m)+p = n+(m+p)
52 \def associative_plus.
53
54 theorem injective_plus_r: \forall n:nat.injective nat nat (\lambda m.n+m).
55 intro.simplify.intros 2.elim n.
56 exact H.
57 apply H.apply inj_S.apply H1.
58 qed.
59
60 theorem inj_plus_r: \forall p,n,m:nat. p+n = p+m \to n=m
61 \def injective_plus_r.
62
63 theorem injective_plus_l: \forall m:nat.injective nat nat (\lambda n.n+m).
64 intro.simplify.intros.
65 apply (injective_plus_r m).
66 rewrite < sym_plus.
67 rewrite < (sym_plus y).
68 assumption.
69 qed.
70
71 theorem inj_plus_l: \forall p,n,m:nat. n+p = m+p \to n=m
72 \def injective_plus_l.