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