]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/library/nat/plus.ma
Added a new contrib div_and_mod and few modifs here and there.
[helm.git] / helm / 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 theorem plus_n_O: \forall n:nat. eq nat n (plus n O).
25 intros.elim n.
26 simplify.reflexivity.
27 simplify.apply eq_f.assumption.
28 qed.
29
30 theorem plus_n_Sm : \forall n,m:nat. eq nat (S (plus n  m)) (plus n (S m)).
31 intros.elim n.
32 simplify.reflexivity.
33 simplify.apply eq_f.assumption.
34 qed.
35
36 (* some problem here: confusion between relations/symmetric 
37 and functions/symmetric; functions symmetric is not in 
38 functions.moo why?
39 theorem symmetric_plus: symmetric nat plus. *)
40
41 theorem sym_plus: \forall n,m:nat. eq nat (plus n m) (plus m n).
42 intros.elim n.
43 simplify.apply plus_n_O.
44 simplify.rewrite > H.apply plus_n_Sm.
45 qed.
46
47 theorem associative_plus : associative nat plus.
48 simplify.intros.elim x.
49 simplify.reflexivity.
50 simplify.apply eq_f.assumption.
51 qed.
52
53 theorem assoc_plus : \forall n,m,p:nat. eq nat (plus (plus n m) p) (plus n (plus m p))
54 \def associative_plus.
55
56 theorem injective_plus_r: \forall n:nat.injective nat nat (\lambda m.plus n m).
57 intro.simplify.intros 2.elim n.
58 exact H.
59 apply H.apply inj_S.apply H1.
60 qed.
61
62 theorem inj_plus_r: \forall p,n,m:nat.eq nat (plus p n) (plus p m) \to (eq nat n m)
63 \def injective_plus_r.
64
65 theorem injective_plus_l: \forall m:nat.injective nat nat (\lambda n.plus n m).
66 intro.simplify.intros.
67 (* qui vorrei applicare injective_plus_r *)
68 apply inj_plus_r m.
69 rewrite < sym_plus.
70 rewrite < sym_plus y.
71 assumption.
72 qed.
73
74 theorem inj_plus_l: \forall p,n,m:nat.eq nat (plus n p) (plus m p) \to (eq nat n m)
75 \def injective_plus_l.