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 include "higher_order_defs/functions.ma".
17 inductive nat : Set \def
21 definition pred: nat \to nat \def
22 \lambda n:nat. match n with
24 | (S p) \Rightarrow p ].
26 theorem pred_Sn : \forall n:nat.n=(pred (S n)).
27 intros. simplify. reflexivity.
30 theorem injective_S : injective nat nat S.
34 rewrite > (pred_Sn y).
35 apply eq_f. assumption.
38 theorem inj_S : \forall n,m:nat.(S n)=(S m) \to n=m \def
41 theorem not_eq_S : \forall n,m:nat.
42 \lnot n=m \to S n \neq S m.
43 intros. unfold Not. intros.
44 apply H. apply injective_S. assumption.
47 definition not_zero : nat \to Prop \def
51 | (S p) \Rightarrow True ].
53 theorem not_eq_O_S : \forall n:nat. O \neq S n.
54 intros. unfold Not. intros.
60 theorem not_eq_n_Sn : \forall n:nat. n \neq S n.
63 apply not_eq_S.assumption.
67 \forall n:nat.\forall P:nat \to Prop.
68 P O \to (\forall m:nat. P (S m)) \to P n.
75 \forall n:nat.\forall P:nat \to Prop.
76 (n=O \to P O) \to (\forall m:nat. (n=(S m) \to P (S m))) \to P n.
79 | apply H2;reflexivity ]
83 \forall R:nat \to nat \to Prop.
84 (\forall n:nat. R O n)
85 \to (\forall n:nat. R (S n) O)
86 \to (\forall n,m:nat. R n m \to R (S n) (S m))
87 \to \forall n,m:nat. R n m.
92 | intro; apply H2; apply H3 ] ]
95 theorem decidable_eq_nat : \forall n,m:nat.decidable (n=m).
96 intros.unfold decidable.
97 apply (nat_elim2 (\lambda n,m.(Or (n=m) ((n=m) \to False))))
100 | right; apply not_eq_O_S ]
101 | intro; right; intro; apply (not_eq_O_S n1); apply sym_eq; assumption
103 [ left; apply eq_f; assumption
104 | right; intro; apply H1; apply inj_S; assumption ] ]