]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/ng_assembly/utility/string_lemmas.ma
freescale porting, work in progress
[helm.git] / helm / software / matita / contribs / ng_assembly / utility / string_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: Cosimo Oliboni, oliboni@cs.unibo.it                   *)
19 (*     Cosimo Oliboni, oliboni@cs.unibo.it                                *)
20 (*                                                                        *)
21 (* ********************************************************************** *)
22
23 include "utility/string.ma".
24 include "utility/ascii_lemmas2.ma".
25 include "utility/utility_lemmas.ma".
26
27 (* ************************ *)
28 (* MANIPOLAZIONE DI STRINGA *)
29 (* ************************ *)
30
31 nlemma symmetric_eqstr : symmetricT (list ascii) bool eq_str.
32  #s1; #s2;
33  napply (symmetric_bfoldrightlist2 ascii eq_ascii s1 s2 symmetric_eqascii).
34 nqed.
35
36 nlemma eqstr_to_eq : ∀s,s'.eq_str s s' = true → s = s'.
37  #s1; #s2;
38  napply (bfoldrightlist2_to_eq ascii eq_ascii s1 s2 eqascii_to_eq).
39 nqed.
40
41 nlemma eq_to_eqstr : ∀s,s'.s = s' → eq_str s s' = true.
42  #s1; #s2;
43  napply (eq_to_bfoldrightlist2 ascii eq_ascii s1 s2 eq_to_eqascii).
44 nqed.
45
46 (* ************ *)
47 (* STRINGA + ID *)
48 (* ************ *)
49
50 nlemma strid_destruct_1 : ∀x1,x2,y1,y2.mk_strId x1 y1 = mk_strId x2 y2 → x1 = x2.
51  #x1; #x2; #y1; #y2; #H;
52  nchange with (match mk_strId x2 y2 with [ mk_strId a _ ⇒ x1 = a ]);
53  nrewrite < H;
54  nnormalize;
55  napply refl_eq.
56 nqed.
57
58 nlemma strid_destruct_2 : ∀x1,x2,y1,y2.mk_strId x1 y1 = mk_strId x2 y2 → y1 = y2.
59  #x1; #x2; #y1; #y2; #H;
60  nchange with (match mk_strId x2 y2 with [ mk_strId _ b ⇒ y1 = b ]);
61  nrewrite < H;
62  nnormalize;
63  napply refl_eq.
64 nqed.
65
66 nlemma symmetric_eqstrid : symmetricT strId bool eq_strId.
67  #si1; #si2;
68  nchange with (
69   ((eq_str (str_elem si1) (str_elem si2))⊗(eq_nat (id_elem si1) (id_elem si2))) =
70   ((eq_str (str_elem si2) (str_elem si1))⊗(eq_nat (id_elem si2) (id_elem si1))));
71  nrewrite > (symmetric_eqstr (str_elem si1) (str_elem si2));
72  nrewrite > (symmetric_eqnat (id_elem si1) (id_elem si2));
73  napply refl_eq.
74 nqed. 
75
76 nlemma eqstrid_to_eq : ∀s,s'.eq_strId s s' = true → s = s'.
77  #si1; #si2;
78  nelim si1;
79  #l1; #n1;
80  nelim si2;
81  #l2; #n2; #H;
82  nchange in H:(%) with (((eq_str l1 l2)⊗(eq_nat n1 n2)) = true);
83  nrewrite > (eqstr_to_eq l1 l2 (andb_true_true_l … H));
84  nrewrite > (eqnat_to_eq n1 n2 (andb_true_true_r … H));
85  napply refl_eq.
86 nqed.
87
88 nlemma eq_to_eqstrid : ∀s,s'.s = s' → eq_strId s s' = true.
89  #si1; #si2;
90  nelim si1;
91  #l1; #n1;
92  nelim si2;
93  #l2; #n2; #H;
94  nchange with (((eq_str l1 l2)⊗(eq_nat n1 n2)) = true);
95  nrewrite > (strid_destruct_1 … H);
96  nrewrite > (strid_destruct_2 … H);
97  nrewrite > (eq_to_eqstr l2 l2 (refl_eq …));
98  nrewrite > (eq_to_eqnat n2 n2 (refl_eq …));
99  nnormalize;
100  napply refl_eq.
101 nqed.