]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/library/nat/compare.ma
Bug fixed: the generated elimination principles used to have Anonymous
[helm.git] / helm / matita / library / nat / compare.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/compare".
16
17 include "nat/orders.ma".
18 include "datatypes/bool.ma".
19
20 let rec leb n m \def 
21 match n with 
22     [ O \Rightarrow true
23     | (S p) \Rightarrow
24         match m with 
25         [ O \Rightarrow false
26         | (S q) \Rightarrow leb p q]].
27         
28 theorem leb_to_Prop: \forall n,m:nat. 
29 match (leb n m) with
30 [ true  \Rightarrow (le n m) 
31 | false \Rightarrow (Not (le n m))].
32 intros.
33 apply nat_elim2
34 (\lambda n,m:nat.match (leb n m) with
35 [ true  \Rightarrow (le n m) 
36 | false \Rightarrow (Not (le n m))]).
37 simplify.exact le_O_n.
38 simplify.exact not_le_Sn_O.
39 intros 2.simplify.elim (leb n1 m1).
40 simplify.apply le_S_S.apply H.
41 simplify.intros.apply H.apply le_S_S_to_le.assumption.
42 qed.
43
44 theorem le_elim: \forall n,m:nat. \forall P:bool \to Prop. 
45 ((le n m) \to (P true)) \to ((Not (le n m)) \to (P false)) \to
46 P (leb n m).
47 intros.
48 cut 
49 match (leb n m) with
50 [ true  \Rightarrow (le n m) 
51 | false \Rightarrow (Not (le n m))] \to (P (leb n m)).
52 apply Hcut.apply leb_to_Prop.
53 elim leb n m.
54 apply (H H2).
55 apply (H1 H2).
56 qed.
57
58
59