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 set "baseuri" "cic:/matita/nat/nat".
17 include "datatypes/bool.ma".
18 include "logic/equality.ma".
19 include "logic/connectives.ma".
20 include "higher_order_defs/functions.ma".
22 inductive nat : Set \def
26 definition pred: nat \to nat \def
27 \lambda n:nat. match n with
29 | (S p) \Rightarrow p ].
31 theorem pred_Sn : \forall n:nat.n=(pred (S n)).
35 theorem injective_S : injective nat nat S.
40 apply eq_f. assumption.
43 theorem inj_S : \forall n,m:nat.(S n)=(S m) \to n=m
46 theorem not_eq_S : \forall n,m:nat.
47 \lnot n=m \to \lnot (S n = S m).
48 intros. simplify. intros.
49 apply H. apply injective_S. assumption.
52 definition not_zero : nat \to Prop \def
56 | (S p) \Rightarrow True ].
58 theorem not_eq_O_S : \forall n:nat. \lnot O=S n.
59 intros. simplify. intros.
65 theorem not_eq_n_Sn : \forall n:nat. \lnot n=S n.
68 apply not_eq_S.assumption.
72 \forall n:nat.\forall P:nat \to Prop.
73 P O \to (\forall m:nat. P (S m)) \to P n.
74 intros.elim n.assumption.apply H1.
78 \forall n:nat.\forall P:nat \to Prop.
79 (n=O \to P O) \to (\forall m:nat. (n=(S m) \to P (S m))) \to P n.
86 \forall R:nat \to nat \to Prop.
87 (\forall n:nat. R O n) \to
88 (\forall n:nat. R (S n) O) \to
89 (\forall n,m:nat. R n m \to R (S n) (S m)) \to \forall n,m:nat. R n m.
92 apply nat_case m.apply H1.
93 intros.apply H2. apply H3.
96 theorem decidable_eq_nat : \forall n,m:nat.decidable (n=m).
98 apply nat_elim2 (\lambda n,m.(Or (n=m) ((n=m) \to False))).
101 right.apply not_eq_O_S.
103 apply not_eq_O_S n1 ?.
104 apply sym_eq.assumption.
106 left.apply eq_f. assumption.
107 right.intro.apply H1.apply inj_S.assumption.