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 "higher_order_defs/functions.ma".
19 theorem esempio: \forall A,B,C:Prop.(A \to B \to C) \to (A \to B)
24 inductive nat : Set \def
28 definition pred: nat \to nat \def
29 \lambda n:nat. match n with
31 | (S p) \Rightarrow p ].
33 theorem pred_Sn : \forall n:nat.n=(pred (S n)).
34 intros. simplify. reflexivity.
37 theorem injective_S : injective nat nat S.
41 rewrite > (pred_Sn y).
42 apply eq_f. assumption.
45 theorem inj_S : \forall n,m:nat.(S n)=(S m) \to n=m \def
48 theorem not_eq_S : \forall n,m:nat.
49 \lnot n=m \to S n \neq S m.
50 intros. unfold Not. intros.
51 apply H. apply injective_S. assumption.
54 definition not_zero : nat \to Prop \def
58 | (S p) \Rightarrow True ].
60 theorem not_eq_O_S : \forall n:nat. O \neq S n.
61 intros. unfold Not. intros.
67 theorem not_eq_n_Sn : \forall n:nat. n \neq S n.
70 apply not_eq_S.assumption.
74 \forall n:nat.\forall P:nat \to Prop.
75 P O \to (\forall m:nat. P (S m)) \to P n.
82 \forall n:nat.\forall P:nat \to Prop.
83 (n=O \to P O) \to (\forall m:nat. (n=(S m) \to P (S m))) \to P n.
86 | apply H2;reflexivity ]
90 \forall R:nat \to nat \to Prop.
91 (\forall n:nat. R O n)
92 \to (\forall n:nat. R (S n) O)
93 \to (\forall n,m:nat. R n m \to R (S n) (S m))
94 \to \forall n,m:nat. R n m.
99 | intro; apply H2; apply H3 ] ]
102 theorem decidable_eq_nat : \forall n,m:nat.decidable (n=m).
103 intros.unfold decidable.
104 apply (nat_elim2 (\lambda n,m.(Or (n=m) ((n=m) \to False))))
107 | right; apply not_eq_O_S ]
108 | intro; right; intro; apply (not_eq_O_S n1); apply sym_eq; assumption
110 [ left; apply eq_f; assumption
111 | right; intro; apply H1; apply inj_S; assumption ] ]