]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/ng_assembly2/common/ascii.ma
arithmetics for λδ
[helm.git] / matita / matita / contribs / ng_assembly2 / common / ascii.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: Ing. Cosimo Oliboni, oliboni@cs.unibo.it              *)
19 (*   Sviluppo: 2008-2010                                                  *)
20 (*                                                                        *)
21 (* ********************************************************************** *)
22
23 include "common/ascii_base.ma".
24 include "common/comp.ma".
25 include "num/bool_lemmas.ma".
26
27 (* ************************** *)
28 (* DEFINIZIONE ASCII MINIMALE *)
29 (* ************************** *)
30
31 ndefinition ascii_destruct_aux ≝
32 Πc1,c2.ΠP:Prop.c1 = c2 →
33  match eq_ascii c1 c2 with [ true ⇒ P → P | false ⇒ P ].
34
35 nlemma ascii_destruct : ascii_destruct_aux.
36  #c1; #c2; #P; #H;
37  nrewrite < H;
38  nelim c1;
39  nnormalize;
40  napply (λx.x).
41 nqed.
42
43 nlemma eq_to_eqascii : ∀n1,n2.n1 = n2 → eq_ascii n1 n2 = true.
44  #n1; #n2; #H;
45  nrewrite > H;
46  nelim n2;
47  nnormalize;
48  napply refl_eq.
49 nqed.
50
51 nlemma neqascii_to_neq : ∀n1,n2.eq_ascii n1 n2 = false → n1 ≠ n2.
52  #n1; #n2; #H;
53  napply (not_to_not (n1 = n2) (eq_ascii n1 n2 = true) …);
54  ##[ ##1: napply (eq_to_eqascii n1 n2)
55  ##| ##2: napply (eqfalse_to_neqtrue … H)
56  ##]
57 nqed.
58
59 (* !!! per brevita... *)
60 naxiom eqascii_to_eq : ∀c1,c2.eq_ascii c1 c2 = true → c1 = c2.
61
62 nlemma neq_to_neqascii : ∀n1,n2.n1 ≠ n2 → eq_ascii n1 n2 = false.
63  #n1; #n2; #H;
64  napply (neqtrue_to_eqfalse (eq_ascii n1 n2));
65  napply (not_to_not (eq_ascii n1 n2 = true) (n1 = n2) ? H);
66  napply (eqascii_to_eq n1 n2).
67 nqed.
68
69 nlemma decidable_ascii : ∀x,y:ascii.decidable (x = y).
70  #x; #y; nnormalize;
71  napply (or2_elim (eq_ascii x y = true) (eq_ascii x y = false) ? (decidable_bexpr ?));
72  ##[ ##1: #H; napply (or2_intro1 (x = y) (x ≠ y) (eqascii_to_eq … H))
73  ##| ##2: #H; napply (or2_intro2 (x = y) (x ≠ y) (neqascii_to_neq … H))
74  ##]
75 nqed.
76
77 nlemma symmetric_eqascii : symmetricT ascii bool eq_ascii.
78  #n1; #n2;
79  napply (or2_elim (n1 = n2) (n1 ≠ n2) ? (decidable_ascii n1 n2));
80  ##[ ##1: #H; nrewrite > H; napply refl_eq
81  ##| ##2: #H; nrewrite > (neq_to_neqascii n1 n2 H);
82           napply (symmetric_eq ? (eq_ascii n2 n1) false);
83           napply (neq_to_neqascii n2 n1 (symmetric_neq ? n1 n2 H))
84  ##]
85 nqed.
86
87 nlemma ascii_is_comparable : comparable.
88  @ ascii
89   ##[ napply ch_0
90   ##| napply forall_ascii
91   ##| napply eq_ascii
92   ##| napply eqascii_to_eq
93   ##| napply eq_to_eqascii
94   ##| napply neqascii_to_neq
95   ##| napply neq_to_neqascii
96   ##| napply decidable_ascii
97   ##| napply symmetric_eqascii
98   ##]
99 nqed.
100
101 unification hint 0 ≔ ⊢ carr ascii_is_comparable ≡ ascii.