]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/ng_assembly/num/quatern_lemmas.ma
Release 0.5.9.
[helm.git] / helm / software / matita / contribs / ng_assembly / num / quatern_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: Ing. Cosimo Oliboni, oliboni@cs.unibo.it              *)
19 (*   Ultima modifica: 05/08/2009                                          *)
20 (*                                                                        *)
21 (* ********************************************************************** *)
22
23 include "num/quatern.ma".
24 include "num/bool_lemmas.ma".
25
26 (* ********** *)
27 (* QUATERNARI *)
28 (* ********** *)
29
30 ndefinition quatern_destruct_aux ≝
31 Πn1,n2:quatern.ΠP:Prop.n1 = n2 →
32  match eq_qu n1 n2 with [ true ⇒ P → P | false ⇒ P ].
33
34 ndefinition quatern_destruct : quatern_destruct_aux.
35  #n1; #n2; #P; #H;
36  nrewrite < H;
37  nelim n1;
38  nnormalize;
39  napply (λx.x).
40 nqed.
41
42 nlemma eq_to_eqqu : ∀n1,n2.n1 = n2 → eq_qu n1 n2 = true.
43  #n1; #n2; #H;
44  nrewrite > H;
45  nelim n2;
46  nnormalize;
47  napply refl_eq.
48 nqed.
49
50 nlemma neqqu_to_neq : ∀n1,n2.eq_qu n1 n2 = false → n1 ≠ n2.
51  #n1; #n2; #H;
52  napply (not_to_not (n1 = n2) (eq_qu n1 n2 = true) …);
53  ##[ ##1: napply (eq_to_eqqu n1 n2)
54  ##| ##2: napply (eqfalse_to_neqtrue … H)
55  ##]
56 nqed.
57
58 nlemma eqqu_to_eq : ∀n1,n2.eq_qu n1 n2 = true → n1 = n2.
59  #n1; #n2;
60  ncases n1;
61  ncases n2;
62  nnormalize;
63  ##[ ##1,6,11,16: #H; napply refl_eq
64  ##| ##*: #H; napply (bool_destruct … H)
65  ##]
66 nqed.
67
68 nlemma neq_to_neqqu : ∀n1,n2.n1 ≠ n2 → eq_qu n1 n2 = false.
69  #n1; #n2; #H;
70  napply (neqtrue_to_eqfalse (eq_qu n1 n2));
71  napply (not_to_not (eq_qu n1 n2 = true) (n1 = n2) ? H);
72  napply (eqqu_to_eq n1 n2).
73 nqed.
74
75 nlemma decidable_qu : ∀x,y:quatern.decidable (x = y).
76  #x; #y; nnormalize;
77  napply (or2_elim (eq_qu x y = true) (eq_qu x y = false) ? (decidable_bexpr ?));
78  ##[ ##1: #H; napply (or2_intro1 (x = y) (x ≠ y) (eqqu_to_eq … H))
79  ##| ##2: #H; napply (or2_intro2 (x = y) (x ≠ y) (neqqu_to_neq … H))
80  ##]
81 nqed.
82
83 nlemma symmetric_eqqu : symmetricT quatern bool eq_qu.
84  #n1; #n2;
85  napply (or2_elim (n1 = n2) (n1 ≠ n2) ? (decidable_qu n1 n2));
86  ##[ ##1: #H; nrewrite > H; napply refl_eq
87  ##| ##2: #H; nrewrite > (neq_to_neqqu n1 n2 H);
88           napply (symmetric_eq ? (eq_qu n2 n1) false);
89           napply (neq_to_neqqu n2 n1 (symmetric_neq ? n1 n2 H))
90  ##]
91 nqed.