--- /dev/null
+(**************************************************************************)
+(* ___ *)
+(* ||M|| *)
+(* ||A|| A project by Andrea Asperti *)
+(* ||T|| *)
+(* ||I|| Developers: *)
+(* ||T|| The HELM team. *)
+(* ||A|| http://helm.cs.unibo.it *)
+(* \ / *)
+(* \ / This file is distributed under the terms of the *)
+(* v GNU General Public License Version 2 *)
+(* *)
+(**************************************************************************)
+
+(* ********************************************************************** *)
+(* Progetto FreeScale *)
+(* *)
+(* Sviluppato da: Cosimo Oliboni, oliboni@cs.unibo.it *)
+(* Cosimo Oliboni, oliboni@cs.unibo.it *)
+(* *)
+(* ********************************************************************** *)
+
+include "num/quatern.ma".
+include "num/bool_lemmas.ma".
+
+(* ********** *)
+(* QUATERNARI *)
+(* ********** *)
+
+ndefinition quatern_destruct_aux ≝
+Πn1,n2:quatern.ΠP:Prop.n1 = n2 →
+ match n1 with
+ [ q0 ⇒ match n2 with [ q0 ⇒ P → P | _ ⇒ P ]
+ | q1 ⇒ match n2 with [ q1 ⇒ P → P | _ ⇒ P ]
+ | q2 ⇒ match n2 with [ q2 ⇒ P → P | _ ⇒ P ]
+ | q3 ⇒ match n2 with [ q3 ⇒ P → P | _ ⇒ P ]
+ ].
+
+ndefinition quatern_destruct : quatern_destruct_aux.
+ #n1; #n2; #P;
+ nelim n1;
+ ##[ ##1: nelim n2; nnormalize; #H;
+ ##[ ##1: napply (λx:P.x)
+ ##| ##*: napply False_ind;
+ nchange with (match q0 with [ q0 ⇒ False | _ ⇒ True ]);
+ nrewrite > H; nnormalize; napply I
+ ##]
+ ##| ##2: nelim n2; nnormalize; #H;
+ ##[ ##2: napply (λx:P.x)
+ ##| ##*: napply False_ind;
+ nchange with (match q1 with [ q1 ⇒ False | _ ⇒ True ]);
+ nrewrite > H; nnormalize; napply I
+ ##]
+ ##| ##3: nelim n2; nnormalize; #H;
+ ##[ ##3: napply (λx:P.x)
+ ##| ##*: napply False_ind;
+ nchange with (match q2 with [ q2 ⇒ False | _ ⇒ True ]);
+ nrewrite > H; nnormalize; napply I
+ ##]
+ ##| ##4: nelim n2; nnormalize; #H;
+ ##[ ##4: napply (λx:P.x)
+ ##| ##*: napply False_ind;
+ nchange with (match q3 with [ q3 ⇒ False | _ ⇒ True ]);
+ nrewrite > H; nnormalize; napply I
+ ##]
+ ##]
+nqed.
+
+nlemma symmetric_eqqu : symmetricT quatern bool eq_qu.
+ #n1; #n2;
+ nelim n1;
+ nelim n2;
+ nnormalize;
+ napply refl_eq.
+nqed.
+
+nlemma eqqu_to_eq : ∀n1,n2.eq_qu n1 n2 = true → n1 = n2.
+ #n1; #n2;
+ ncases n1;
+ ncases n2;
+ nnormalize;
+ ##[ ##1,6,11,16: #H; napply refl_eq
+ ##| ##*: #H; napply (bool_destruct … H)
+ ##]
+nqed.
+
+nlemma eq_to_eqqu : ∀n1,n2.n1 = n2 → eq_qu n1 n2 = true.
+ #n1; #n2;
+ ncases n1;
+ ncases n2;
+ nnormalize;
+ ##[ ##1,6,11,16: #H; napply refl_eq
+ ##| ##*: #H; napply (quatern_destruct … H)
+ ##]
+nqed.
+
+nlemma neqqu_to_neq : ∀n1,n2.eq_qu n1 n2 = false → n1 ≠ n2.
+ #n1; #n2;
+ ncases n1;
+ ncases n2;
+ nnormalize;
+ ##[ ##1,6,11,16: #H; napply (bool_destruct … H)
+ ##| ##*: #H; #H1; napply (quatern_destruct … H1)
+ ##]
+nqed.
+
+nlemma neq_to_neqqu : ∀n1,n2.n1 ≠ n2 → eq_qu n1 n2 = false.
+ #n1; #n2;
+ ncases n1;
+ ncases n2;
+ nnormalize;
+ ##[ ##1,6,11,16: #H; napply False_ind; napply (H (refl_eq …))
+ ##| ##*: #H; napply refl_eq
+ ##]
+nqed.