]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/matita/library/nat/plus.ma
New version of the library, a bit more structured.
[helm.git] / helm / matita / library / nat / plus.ma
diff --git a/helm/matita/library/nat/plus.ma b/helm/matita/library/nat/plus.ma
new file mode 100644 (file)
index 0000000..1a43e21
--- /dev/null
@@ -0,0 +1,76 @@
+(**************************************************************************)
+(*       ___                                                               *)
+(*      ||M||                                                             *)
+(*      ||A||       A project by Andrea Asperti                           *)
+(*      ||T||                                                             *)
+(*      ||I||       Developers:                                           *)
+(*      ||T||       A.Asperti, C.Sacerdoti Coen,                          *)
+(*      ||A||       E.Tassi, S.Zacchiroli                                 *)
+(*      \   /                                                             *)
+(*       \ /        This file is distributed under the terms of the       *)
+(*        v         GNU Lesser General Public License Version 2.1         *)
+(*                                                                        *)
+(**************************************************************************)
+
+set "baseuri" "cic:/matita/nat/plus.ma".
+
+include "logic/equality.ma".
+include "nat/nat.ma".
+
+let rec plus n m \def 
+ match n with 
+ [ O \Rightarrow m
+ | (S p) \Rightarrow S (plus p m) ].
+
+theorem plus_n_O: \forall n:nat. eq nat n (plus n O).
+intros.elim n.
+simplify.reflexivity.
+simplify.apply eq_f.assumption.
+qed.
+
+theorem plus_n_Sm : \forall n,m:nat. eq nat (S (plus n  m)) (plus n (S m)).
+intros.elim n.
+simplify.reflexivity.
+simplify.apply eq_f.assumption.
+qed.
+
+(* some problem here: confusion between relations/symmetric 
+and functions/symmetric; functions symmetric is not in 
+functions.moo why?
+theorem symmetric_plus: symmetric nat plus. *)
+
+theorem sym_plus: \forall n,m:nat. eq nat (plus n m) (plus m n).
+intros.elim n.
+simplify.apply plus_n_O.
+simplify.rewrite > H.apply plus_n_Sm.
+qed.
+
+theorem associative_plus : associative nat plus.
+simplify.intros.elim x.
+simplify.reflexivity.
+simplify.apply eq_f.assumption.
+qed.
+
+theorem assoc_plus : \forall n,m,p:nat. eq nat (plus (plus n m) p) (plus n (plus m p))
+\def associative_plus.
+
+theorem injective_plus_r: \forall n:nat.injective nat nat (\lambda m.plus n m).
+intro.simplify.intros 2.elim n.
+exact H.
+apply H.apply inj_S.apply H1.
+qed.
+
+theorem inj_plus_r: \forall p,n,m:nat.eq nat (plus p n) (plus p m) \to (eq nat n m)
+\def injective_plus_r.
+
+theorem injective_plus_l: \forall m:nat.injective nat nat (\lambda n.plus n m).
+intro.simplify.intros.
+(* qui vorrei applicare injective_plus_r *)
+apply inj_plus_r m.
+rewrite < sym_plus.
+rewrite < sym_plus y.
+assumption.
+qed.
+
+theorem inj_plus_l: \forall p,n,m:nat.eq nat (plus n p) (plus m p) \to (eq nat n m)
+\def injective_plus_l.
\ No newline at end of file