]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/ng_assembly/freescale/nat_lemmas.ma
freescale porting to ng, work in progress
[helm.git] / helm / software / matita / contribs / ng_assembly / freescale / nat_lemmas.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 (* ********************************************************************** *)
16 (*                           Progetto FreeScale                           *)
17 (*                                                                        *)
18 (* Sviluppato da:                                                         *)
19 (*   Cosimo Oliboni, oliboni@cs.unibo.it                                  *)
20 (*                                                                        *)
21 (* Questo materiale fa parte della tesi:                                  *)
22 (*   "Formalizzazione Interattiva dei Microcontroller a 8bit FreeScale"   *)
23 (*                                                                        *)
24 (*                    data ultima modifica 15/11/2007                     *)
25 (* ********************************************************************** *)
26
27 include "freescale/bool_lemmas.ma".
28 include "freescale/nat.ma".
29
30 (* ******** *)
31 (* NATURALI *)
32 (* ******** *)
33
34 nlemma nat_destruct_S_S : ∀n1,n2:nat.S n1 = S n2 → n1 = n2.
35  #n1; #n2; #H;
36  nchange with (match S n2 with [ O ⇒ False | S a ⇒ n1 = a ]);
37  nrewrite < H;
38  nnormalize;
39  napply (refl_eq ??).
40 nqed.
41
42 nlemma nat_destruct_0_S : ∀n:nat.O = S n → False.
43  #n; #H;
44  nchange with (match S n with [ O ⇒ True | S a ⇒ False ]);
45  nrewrite < H;
46  nnormalize;
47  napply I.
48 nqed.
49
50 nlemma nat_destruct_S_0 : ∀n:nat.S n = O → False.
51  #n; #H;
52  nchange with (match S n with [ O ⇒ True | S a ⇒ False ]);
53  nrewrite > H;
54  nnormalize;
55  napply I.
56 nqed.
57
58 nlemma symmetric_eqnat : symmetricT nat bool eq_nat.
59  nnormalize;
60  #n1;
61  nelim n1;
62  ##[ ##1: #n2;
63           nelim n2;
64           nnormalize;
65           ##[ ##1: napply (refl_eq ??)
66           ##| ##2: #n3; #H; napply (refl_eq ??)
67           ##]
68  ##| ##2: #n2; #H; #n3;
69           nnormalize;
70           ncases n3;
71           nnormalize;
72           ##[ ##1: napply (refl_eq ??)
73           ##| ##2: #n4; napply (H n4)
74           ##]
75  ##]
76 nqed.
77
78 nlemma eq_to_eqnat : ∀n1,n2:nat.n1 = n2 → eq_nat n1 n2 = true.
79  #n1;
80  nelim n1;
81  ##[ ##1: #n2;
82           nelim n2;
83           nnormalize;
84           ##[ ##1: #H; napply (refl_eq ??)
85           ##| ##2: #n3; #H; #H1; nelim (nat_destruct_0_S ? H1)
86           ##]
87  ##| ##2: #n2; #H; #n3; #H1;
88           ncases n3 in H1:(%) ⊢ %;
89           nnormalize;
90           ##[ ##1: #H1; nelim (nat_destruct_S_0 ? H1)
91           ##| ##2: #n4; #H1;
92                    napply (H n4 (nat_destruct_S_S ?? H1))
93           ##]
94  ##]
95 nqed. 
96
97 nlemma eqnat_to_eq : ∀n1,n2:nat.(eq_nat n1 n2 = true → n1 = n2).
98  #n1;
99  nelim n1;
100  ##[ ##1: #n2;
101           nelim n2;
102           nnormalize;
103           ##[ ##1: #H; napply (refl_eq ??)
104           ##| ##2: #n3; #H; #H1; napply (bool_destruct ?? (O = S n3) H1) 
105           ##]
106  ##| ##2: #n2; #H; #n3; #H1;
107           ncases n3 in H1:(%) ⊢ %;
108           nnormalize;
109           ##[ ##1: #H1; napply (bool_destruct ?? (S n2 = O) H1)
110           ##| ##2: #n4; #H1;
111                    nrewrite > (H n4 H1);
112                    napply (refl_eq ??)
113           ##]
114  ##]
115 nqed.