From: Cosimo Oliboni Date: Sat, 11 Jul 2009 22:48:48 +0000 (+0000) Subject: (no commit message) X-Git-Tag: make_still_working~3696 X-Git-Url: http://matita.cs.unibo.it/gitweb/?p=helm.git;a=commitdiff_plain;h=64bdbee95e40a5be3bb6c5c2866869103730a4d0 --- diff --git a/helm/software/matita/contribs/ng_assembly/depends b/helm/software/matita/contribs/ng_assembly/depends index 98ad886d0..3a30fbcd1 100644 --- a/helm/software/matita/contribs/ng_assembly/depends +++ b/helm/software/matita/contribs/ng_assembly/depends @@ -1,11 +1,18 @@ freescale/theory.ma freescale/pts.ma +freescale/exadecim_lemmas.ma freescale/bool_lemmas.ma freescale/exadecim.ma +freescale/word32_lemmas.ma freescale/word16_lemmas.ma freescale/word32.ma freescale/bool_lemmas.ma freescale/bool.ma freescale/theory.ma freescale/bool.ma freescale/pts.ma +freescale/byte8_lemmas.ma freescale/byte8.ma freescale/exadecim_lemmas.ma freescale/pts.ma freescale/option_lemmas.ma freescale/bool_lemmas.ma freescale/option.ma freescale/prod_lemmas.ma freescale/bool_lemmas.ma freescale/prod.ma freescale/nat.ma freescale/bool.ma freescale/pts.ma +freescale/word32.ma freescale/word16.ma +freescale/word16.ma freescale/byte8.ma +freescale/byte8.ma freescale/exadecim.ma freescale/option.ma freescale/bool.ma freescale/prod.ma freescale/bool.ma +freescale/word16_lemmas.ma freescale/byte8_lemmas.ma freescale/word16.ma freescale/exadecim.ma freescale/bool.ma freescale/nat.ma freescale/prod.ma freescale/nat_lemmas.ma freescale/bool_lemmas.ma freescale/nat.ma diff --git a/helm/software/matita/contribs/ng_assembly/freescale/bool_lemmas.ma b/helm/software/matita/contribs/ng_assembly/freescale/bool_lemmas.ma index 5c08f23f3..5d05eb195 100755 --- a/helm/software/matita/contribs/ng_assembly/freescale/bool_lemmas.ma +++ b/helm/software/matita/contribs/ng_assembly/freescale/bool_lemmas.ma @@ -31,32 +31,32 @@ include "freescale/bool.ma". (* BOOLEANI *) (* ******** *) -ndefinition boolRelation : Type → Type ≝ -λA:Type.A → A → bool. - -ndefinition boolSymmetric: ∀A:Type.∀R:boolRelation A.Prop ≝ -λA.λR.∀x,y:A.R x y = R y x. - -ntheorem bool_destruct_true_false : true ≠ false. - nnormalize; - #H; - nchange with (match true with [ true ⇒ False | false ⇒ True]); - nrewrite > H; - nnormalize; - napply I. -nqed. - -ntheorem bool_destruct_false_true : false ≠ true. +ndefinition bool_destruct : + Πb1,b2:bool.ΠP:Prop.b1 = b2 → + match b1 with + [ true ⇒ match b2 with [ true ⇒ P → P | false ⇒ P ] + | false ⇒ match b2 with [ true ⇒ P | false ⇒ P → P ] + ]. + #b1; #b2; #P; + nelim b1; + nelim b2; nnormalize; #H; - nchange with (match true with [ true ⇒ False | false ⇒ True]); - nrewrite < H; - nnormalize; - napply I. + ##[ ##2: napply (False_ind ??); + nchange with (match true with [ true ⇒ False | false ⇒ True]); + nrewrite > H; + nnormalize; + napply I + ##| ##3: napply (False_ind ??); + nchange with (match true with [ true ⇒ False | false ⇒ True]); + nrewrite < H; + nnormalize; + napply I + ##| ##1,4: napply (λx:P.x) + ##] nqed. -nlemma bsymmetric_eqbool : boolSymmetric bool eq_bool. - nnormalize; +nlemma symmetric_eqbool : symmetricT bool bool eq_bool. #b1; #b2; nelim b1; nelim b2; @@ -64,8 +64,7 @@ nlemma bsymmetric_eqbool : boolSymmetric bool eq_bool. napply (refl_eq ??). nqed. -nlemma bsymmetric_andbool : boolSymmetric bool and_bool. - nnormalize; +nlemma symmetric_andbool : symmetricT bool bool and_bool. #b1; #b2; nelim b1; nelim b2; @@ -73,17 +72,16 @@ nlemma bsymmetric_andbool : boolSymmetric bool and_bool. napply (refl_eq ??). nqed. -nlemma bsymmetric_orbool : boolSymmetric bool or_bool. - nnormalize; - #b1; #b2; +nlemma associative_andbool : ∀b1,b2,b3.((b1 ⊗ b2) ⊗ b3) = (b1 ⊗ (b2 ⊗ b3)). + #b1; #b2; #b3; nelim b1; nelim b2; + nelim b3; nnormalize; napply (refl_eq ??). nqed. -nlemma bsymmetric_xorbool : boolSymmetric bool xor_bool. - nnormalize; +nlemma symmetric_orbool : symmetricT bool bool or_bool. #b1; #b2; nelim b1; nelim b2; @@ -91,63 +89,94 @@ nlemma bsymmetric_xorbool : boolSymmetric bool xor_bool. napply (refl_eq ??). nqed. -nlemma eqbool_to_eq : ∀b1,b2:bool.(eq_bool b1 b2 = true) → (b1 = b2). - #b1; #b2; +nlemma associative_orbool : ∀b1,b2,b3.((b1 ⊕ b2) ⊕ b3) = (b1 ⊕ (b2 ⊕ b3)). + #b1; #b2; #b3; nelim b1; nelim b2; + nelim b3; nnormalize; - #H; - ##[ ##2,3: nelim (bool_destruct_false_true H) ##] napply (refl_eq ??). nqed. -nlemma eq_to_eqbool : ∀b1,b2.b1 = b2 → eq_bool b1 b2 = true. +nlemma symmetric_xorbool : symmetricT bool bool xor_bool. #b1; #b2; nelim b1; nelim b2; nnormalize; - #H; - ##[ ##2: nelim (bool_destruct_true_false H) - ##| ##3: nelim (bool_destruct_false_true H) ##] napply (refl_eq ??). nqed. -nlemma andb_true_true: ∀b1,b2.(b1 ⊗ b2) = true → b1 = true. - #b1; #b2; +nlemma associative_orbool : ∀b1,b2,b3.((b1 ⊙ b2) ⊙ b3) = (b1 ⊙ (b2 ⊙ b3)). + #b1; #b2; #b3; nelim b1; nelim b2; + nelim b3; nnormalize; - #H; - ##[ ##3,4: nelim (bool_destruct_false_true H) ##] napply (refl_eq ??). nqed. +nlemma eqbool_to_eq : ∀b1,b2:bool.(eq_bool b1 b2 = true) → (b1 = b2). + #b1; #b2; #H; + nletin K ≝ (bool_destruct ?? (b1 = b2) H); + nelim b1 in K:(%) ⊢ %; + nelim b2; + nnormalize; + ##[ ##2,3: #H; napply H + ##| ##1,4: #H; napply (refl_eq ??) + ##] +nqed. + +nlemma eq_to_eqbool : ∀b1,b2.b1 = b2 → eq_bool b1 b2 = true. + #b1; #b2; #H; + nletin K ≝ (bool_destruct ?? (eq_bool b1 b2 = true) H); + nelim b1 in K:(%) ⊢ %; + nelim b2; + nnormalize; + ##[ ##2,3: #H; napply H + ##| ##1,4: #H; napply (refl_eq ??) + ##] +nqed. + +nlemma andb_true_true_l: ∀b1,b2.(b1 ⊗ b2) = true → b1 = true. + #b1; #b2; #H; + nletin K ≝ (bool_destruct ?? (b1 = true) H); + nelim b1 in K:(%) ⊢ %; + nelim b2; + nnormalize; + ##[ ##3,4: #H; napply H + ##| ##1,2: #H; napply (refl_eq ??) + ##] +nqed. + nlemma andb_true_true_r: ∀b1,b2.(b1 ⊗ b2) = true → b2 = true. - #b1; #b2; - nelim b1; + #b1; #b2; #H; + nletin K ≝ (bool_destruct ?? (b2 = true) H); + nelim b1 in K:(%) ⊢ %; nelim b2; nnormalize; - #H; - ##[ ##2,3,4: nelim (bool_destruct_false_true H) ##] - napply (refl_eq ??). + ##[ ##2,4: #H; napply H + ##| ##1,3: #H; napply (refl_eq ??) + ##] nqed. -nlemma orb_false_false : ∀b1,b2:bool.(b1 ⊕ b2) = false → b1 = false. - #b1; #b2; - nelim b1; +nlemma orb_false_false_l : ∀b1,b2:bool.(b1 ⊕ b2) = false → b1 = false. + #b1; #b2; #H; + nletin K ≝ (bool_destruct ?? (b1 = false) H); + nelim b1 in K:(%) ⊢ %; nelim b2; nnormalize; - #H; - ##[ ##1,2: nelim (bool_destruct_true_false H) ##] - napply (refl_eq ??). + ##[ ##1,2,3: #H; napply H + ##| ##4: #H; napply (refl_eq ??) + ##] nqed. nlemma orb_false_false_r : ∀b1,b2:bool.(b1 ⊕ b2) = false → b2 = false. - #b1; #b2; - nelim b1; + #b1; #b2; #H; + nletin K ≝ (bool_destruct ?? (b2 = false) H); + nelim b1 in K:(%) ⊢ %; nelim b2; nnormalize; - #H; - ##[ ##1,3: nelim (bool_destruct_true_false H) ##] - napply (refl_eq ??). + ##[ ##1,2,3: #H; napply H + ##| ##4: #H; napply (refl_eq ??) + ##] nqed. diff --git a/helm/software/matita/contribs/ng_assembly/freescale/byte8.ma b/helm/software/matita/contribs/ng_assembly/freescale/byte8.ma new file mode 100755 index 000000000..4dd950268 --- /dev/null +++ b/helm/software/matita/contribs/ng_assembly/freescale/byte8.ma @@ -0,0 +1,328 @@ +(**************************************************************************) +(* ___ *) +(* ||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 *) +(* *) +(* Questo materiale fa parte della tesi: *) +(* "Formalizzazione Interattiva dei Microcontroller a 8bit FreeScale" *) +(* *) +(* data ultima modifica 15/11/2007 *) +(* ********************************************************************** *) + +include "freescale/exadecim.ma". + +(* **** *) +(* BYTE *) +(* **** *) + +nrecord byte8 : Type ≝ + { + b8h: exadecim; + b8l: exadecim + }. + +ndefinition byte8_ind : ΠP:byte8 → Prop.(Πe:exadecim.Πe1:exadecim.P (mk_byte8 e e1)) → Πb:byte8.P b ≝ +λP:byte8 → Prop.λf:Πe:exadecim.Πe1:exadecim.P (mk_byte8 e e1).λb:byte8. + match b with [ mk_byte8 (e:exadecim) (e1:exadecim) ⇒ f e e1 ]. + +ndefinition byte8_rec : ΠP:byte8 → Set.(Πe:exadecim.Πe1:exadecim.P (mk_byte8 e e1)) → Πb:byte8.P b ≝ +λP:byte8 → Set.λf:Πe:exadecim.Πe1:exadecim.P (mk_byte8 e e1).λb:byte8. + match b with [ mk_byte8 (e:exadecim) (e1:exadecim) ⇒ f e e1 ]. + +ndefinition byte8_rect : ΠP:byte8 → Type.(Πe:exadecim.Πe1:exadecim.P (mk_byte8 e e1)) → Πb:byte8.P b ≝ +λP:byte8 → Type.λf:Πe:exadecim.Πe1:exadecim.P (mk_byte8 e e1).λb:byte8. + match b with [ mk_byte8 (e:exadecim) (e1:exadecim) ⇒ f e e1 ]. + +ndefinition b8h ≝ λb:byte8.match b with [ mk_byte8 x _ ⇒ x ]. +ndefinition b8l ≝ λb:byte8.match b with [ mk_byte8 _ x ⇒ x ]. + +(* \langle \rangle *) +notation "〈x,y〉" non associative with precedence 80 + for @{ 'mk_byte8 $x $y }. +interpretation "mk_byte8" 'mk_byte8 x y = (mk_byte8 x y). + +(* operatore = *) +ndefinition eq_b8 ≝ λb1,b2:byte8.(eq_ex (b8h b1) (b8h b2)) ⊗ (eq_ex (b8l b1) (b8l b2)). + +(* operatore < *) +ndefinition lt_b8 ≝ +λb1,b2:byte8.match lt_ex (b8h b1) (b8h b2) with + [ true ⇒ true + | false ⇒ match gt_ex (b8h b1) (b8h b2) with + [ true ⇒ false + | false ⇒ lt_ex (b8l b1) (b8l b2) ]]. + +(* operatore ≤ *) +ndefinition le_b8 ≝ λb1,b2:byte8.(eq_b8 b1 b2) ⊕ (lt_b8 b1 b2). + +(* operatore > *) +ndefinition gt_b8 ≝ λb1,b2:byte8.⊖ (le_b8 b1 b2). + +(* operatore ≥ *) +ndefinition ge_b8 ≝ λb1,b2:byte8.⊖ (lt_b8 b1 b2). + +(* operatore and *) +ndefinition and_b8 ≝ +λb1,b2:byte8.mk_byte8 (and_ex (b8h b1) (b8h b2)) (and_ex (b8l b1) (b8l b2)). + +(* operatore or *) +ndefinition or_b8 ≝ +λb1,b2:byte8.mk_byte8 (or_ex (b8h b1) (b8h b2)) (or_ex (b8l b1) (b8l b2)). + +(* operatore xor *) +ndefinition xor_b8 ≝ +λb1,b2:byte8.mk_byte8 (xor_ex (b8h b1) (b8h b2)) (xor_ex (b8l b1) (b8l b2)). + +(* operatore rotazione destra con carry *) +ndefinition rcr_b8 ≝ +λb:byte8.λc:bool.match rcr_ex (b8h b) c with + [ pair bh' c' ⇒ match rcr_ex (b8l b) c' with + [ pair bl' c'' ⇒ pair ?? (mk_byte8 bh' bl') c'' ]]. + +(* operatore shift destro *) +ndefinition shr_b8 ≝ +λb:byte8.match rcr_ex (b8h b) false with + [ pair bh' c' ⇒ match rcr_ex (b8l b) c' with + [ pair bl' c'' ⇒ pair ?? (mk_byte8 bh' bl') c'' ]]. + +(* operatore rotazione destra *) +ndefinition ror_b8 ≝ +λb:byte8.match rcr_ex (b8h b) false with + [ pair bh' c' ⇒ match rcr_ex (b8l b) c' with + [ pair bl' c'' ⇒ match c'' with + [ true ⇒ mk_byte8 (or_ex x8 bh') bl' + | false ⇒ mk_byte8 bh' bl' ]]]. + +(* operatore rotazione destra n-volte *) +nlet rec ror_b8_n (b:byte8) (n:nat) on n ≝ + match n with + [ O ⇒ b + | S n' ⇒ ror_b8_n (ror_b8 b) n' ]. + +(* operatore rotazione sinistra con carry *) +ndefinition rcl_b8 ≝ +λb:byte8.λc:bool.match rcl_ex (b8l b) c with + [ pair bl' c' ⇒ match rcl_ex (b8h b) c' with + [ pair bh' c'' ⇒ pair ?? (mk_byte8 bh' bl') c'' ]]. + +(* operatore shift sinistro *) +ndefinition shl_b8 ≝ +λb:byte8.match rcl_ex (b8l b) false with + [ pair bl' c' ⇒ match rcl_ex (b8h b) c' with + [ pair bh' c'' ⇒ pair ?? (mk_byte8 bh' bl') c'' ]]. + +(* operatore rotazione sinistra *) +ndefinition rol_b8 ≝ +λb:byte8.match rcl_ex (b8l b) false with + [ pair bl' c' ⇒ match rcl_ex (b8h b) c' with + [ pair bh' c'' ⇒ match c'' with + [ true ⇒ mk_byte8 bh' (or_ex x1 bl') + | false ⇒ mk_byte8 bh' bl' ]]]. + +(* operatore rotazione sinistra n-volte *) +nlet rec rol_b8_n (b:byte8) (n:nat) on n ≝ + match n with + [ O ⇒ b + | S n' ⇒ rol_b8_n (rol_b8 b) n' ]. + +(* operatore not/complemento a 1 *) +ndefinition not_b8 ≝ +λb:byte8.mk_byte8 (not_ex (b8h b)) (not_ex (b8l b)). + +(* operatore somma con data+carry → data+carry *) +ndefinition plus_b8_dc_dc ≝ +λb1,b2:byte8.λc:bool. + match plus_ex_dc_dc (b8l b1) (b8l b2) c with + [ pair l c ⇒ match plus_ex_dc_dc (b8h b1) (b8h b2) c with + [ pair h c' ⇒ pair ?? 〈h,l〉 c' ]]. + +(* operatore somma con data+carry → data *) +ndefinition plus_b8_dc_d ≝ +λb1,b2:byte8.λc:bool. + match plus_ex_dc_dc (b8l b1) (b8l b2) c with + [ pair l c ⇒ 〈plus_ex_dc_d (b8h b1) (b8h b2) c,l〉 ]. + +(* operatore somma con data+carry → c *) +ndefinition plus_b8_dc_c ≝ +λb1,b2:byte8.λc:bool. + plus_ex_dc_c (b8h b1) (b8h b2) (plus_ex_dc_c (b8l b1) (b8l b2) c). + +(* operatore somma con data → data+carry *) +ndefinition plus_b8_d_dc ≝ +λb1,b2:byte8. + match plus_ex_d_dc (b8l b1) (b8l b2) with + [ pair l c ⇒ match plus_ex_dc_dc (b8h b1) (b8h b2) c with + [ pair h c' ⇒ pair ?? 〈h,l〉 c' ]]. + +(* operatore somma con data → data *) +ndefinition plus_b8_d_d ≝ +λb1,b2:byte8. + match plus_ex_d_dc (b8l b1) (b8l b2) with + [ pair l c ⇒ 〈plus_ex_dc_d (b8h b1) (b8h b2) c,l〉 ]. + +(* operatore somma con data → c *) +ndefinition plus_b8_d_c ≝ +λb1,b2:byte8. + plus_ex_dc_c (b8h b1) (b8h b2) (plus_ex_d_c (b8l b1) (b8l b2)). + +(* operatore Most Significant Bit *) +ndefinition MSB_b8 ≝ λb:byte8.eq_ex x8 (and_ex x8 (b8h b)). + +(* byte → naturali *) +ndefinition nat_of_byte8 ≝ λb:byte8.(16*(nat_of_exadecim (b8h b))) + (nat_of_exadecim (b8l b)). + +(* operatore predecessore *) +ndefinition pred_b8 ≝ +λb:byte8.match eq_ex (b8l b) x0 with + [ true ⇒ mk_byte8 (pred_ex (b8h b)) (pred_ex (b8l b)) + | false ⇒ mk_byte8 (b8h b) (pred_ex (b8l b)) ]. + +(* operatore successore *) +ndefinition succ_b8 ≝ +λb:byte8.match eq_ex (b8l b) xF with + [ true ⇒ mk_byte8 (succ_ex (b8h b)) (succ_ex (b8l b)) + | false ⇒ mk_byte8 (b8h b) (succ_ex (b8l b)) ]. + +(* operatore neg/complemento a 2 *) +ndefinition compl_b8 ≝ +λb:byte8.match MSB_b8 b with + [ true ⇒ succ_b8 (not_b8 b) + | false ⇒ not_b8 (pred_b8 b) ]. + +(* operatore moltiplicazione senza segno: e*e=[0x00,0xE1] *) +ndefinition mul_ex ≝ +λe1,e2:exadecim.match e1 with + [ x0 ⇒ match e2 with + [ x0 ⇒ 〈x0,x0〉 | x1 ⇒ 〈x0,x0〉 | x2 ⇒ 〈x0,x0〉 | x3 ⇒ 〈x0,x0〉 + | x4 ⇒ 〈x0,x0〉 | x5 ⇒ 〈x0,x0〉 | x6 ⇒ 〈x0,x0〉 | x7 ⇒ 〈x0,x0〉 + | x8 ⇒ 〈x0,x0〉 | x9 ⇒ 〈x0,x0〉 | xA ⇒ 〈x0,x0〉 | xB ⇒ 〈x0,x0〉 + | xC ⇒ 〈x0,x0〉 | xD ⇒ 〈x0,x0〉 | xE ⇒ 〈x0,x0〉 | xF ⇒ 〈x0,x0〉 ] + | x1 ⇒ match e2 with + [ x0 ⇒ 〈x0,x0〉 | x1 ⇒ 〈x0,x1〉 | x2 ⇒ 〈x0,x2〉 | x3 ⇒ 〈x0,x3〉 + | x4 ⇒ 〈x0,x4〉 | x5 ⇒ 〈x0,x5〉 | x6 ⇒ 〈x0,x6〉 | x7 ⇒ 〈x0,x7〉 + | x8 ⇒ 〈x0,x8〉 | x9 ⇒ 〈x0,x9〉 | xA ⇒ 〈x0,xA〉 | xB ⇒ 〈x0,xB〉 + | xC ⇒ 〈x0,xC〉 | xD ⇒ 〈x0,xD〉 | xE ⇒ 〈x0,xE〉 | xF ⇒ 〈x0,xF〉 ] + | x2 ⇒ match e2 with + [ x0 ⇒ 〈x0,x0〉 | x1 ⇒ 〈x0,x2〉 | x2 ⇒ 〈x0,x4〉 | x3 ⇒ 〈x0,x6〉 + | x4 ⇒ 〈x0,x8〉 | x5 ⇒ 〈x0,xA〉 | x6 ⇒ 〈x0,xC〉 | x7 ⇒ 〈x0,xE〉 + | x8 ⇒ 〈x1,x0〉 | x9 ⇒ 〈x1,x2〉 | xA ⇒ 〈x1,x4〉 | xB ⇒ 〈x1,x6〉 + | xC ⇒ 〈x1,x8〉 | xD ⇒ 〈x1,xA〉 | xE ⇒ 〈x1,xC〉 | xF ⇒ 〈x1,xE〉 ] + | x3 ⇒ match e2 with + [ x0 ⇒ 〈x0,x0〉 | x1 ⇒ 〈x0,x3〉 | x2 ⇒ 〈x0,x6〉 | x3 ⇒ 〈x0,x9〉 + | x4 ⇒ 〈x0,xC〉 | x5 ⇒ 〈x0,xF〉 | x6 ⇒ 〈x1,x2〉 | x7 ⇒ 〈x1,x5〉 + | x8 ⇒ 〈x1,x8〉 | x9 ⇒ 〈x1,xB〉 | xA ⇒ 〈x1,xE〉 | xB ⇒ 〈x2,x1〉 + | xC ⇒ 〈x2,x4〉 | xD ⇒ 〈x2,x7〉 | xE ⇒ 〈x2,xA〉 | xF ⇒ 〈x2,xD〉 ] + | x4 ⇒ match e2 with + [ x0 ⇒ 〈x0,x0〉 | x1 ⇒ 〈x0,x4〉 | x2 ⇒ 〈x0,x8〉 | x3 ⇒ 〈x0,xC〉 + | x4 ⇒ 〈x1,x0〉 | x5 ⇒ 〈x1,x4〉 | x6 ⇒ 〈x1,x8〉 | x7 ⇒ 〈x1,xC〉 + | x8 ⇒ 〈x2,x0〉 | x9 ⇒ 〈x2,x4〉 | xA ⇒ 〈x2,x8〉 | xB ⇒ 〈x2,xC〉 + | xC ⇒ 〈x3,x0〉 | xD ⇒ 〈x3,x4〉 | xE ⇒ 〈x3,x8〉 | xF ⇒ 〈x3,xC〉 ] + | x5 ⇒ match e2 with + [ x0 ⇒ 〈x0,x0〉 | x1 ⇒ 〈x0,x5〉 | x2 ⇒ 〈x0,xA〉 | x3 ⇒ 〈x0,xF〉 + | x4 ⇒ 〈x1,x4〉 | x5 ⇒ 〈x1,x9〉 | x6 ⇒ 〈x1,xE〉 | x7 ⇒ 〈x2,x3〉 + | x8 ⇒ 〈x2,x8〉 | x9 ⇒ 〈x2,xD〉 | xA ⇒ 〈x3,x2〉 | xB ⇒ 〈x3,x7〉 + | xC ⇒ 〈x3,xC〉 | xD ⇒ 〈x4,x1〉 | xE ⇒ 〈x4,x6〉 | xF ⇒ 〈x4,xB〉 ] + | x6 ⇒ match e2 with + [ x0 ⇒ 〈x0,x0〉 | x1 ⇒ 〈x0,x6〉 | x2 ⇒ 〈x0,xC〉 | x3 ⇒ 〈x1,x2〉 + | x4 ⇒ 〈x1,x8〉 | x5 ⇒ 〈x1,xE〉 | x6 ⇒ 〈x2,x4〉 | x7 ⇒ 〈x2,xA〉 + | x8 ⇒ 〈x3,x0〉 | x9 ⇒ 〈x3,x6〉 | xA ⇒ 〈x3,xC〉 | xB ⇒ 〈x4,x2〉 + | xC ⇒ 〈x4,x8〉 | xD ⇒ 〈x4,xE〉 | xE ⇒ 〈x5,x4〉 | xF ⇒ 〈x5,xA〉 ] + | x7 ⇒ match e2 with + [ x0 ⇒ 〈x0,x0〉 | x1 ⇒ 〈x0,x7〉 | x2 ⇒ 〈x0,xE〉 | x3 ⇒ 〈x1,x5〉 + | x4 ⇒ 〈x1,xC〉 | x5 ⇒ 〈x2,x3〉 | x6 ⇒ 〈x2,xA〉 | x7 ⇒ 〈x3,x1〉 + | x8 ⇒ 〈x3,x8〉 | x9 ⇒ 〈x3,xF〉 | xA ⇒ 〈x4,x6〉 | xB ⇒ 〈x4,xD〉 + | xC ⇒ 〈x5,x4〉 | xD ⇒ 〈x5,xB〉 | xE ⇒ 〈x6,x2〉 | xF ⇒ 〈x6,x9〉 ] + | x8 ⇒ match e2 with + [ x0 ⇒ 〈x0,x0〉 | x1 ⇒ 〈x0,x8〉 | x2 ⇒ 〈x1,x0〉 | x3 ⇒ 〈x1,x8〉 + | x4 ⇒ 〈x2,x0〉 | x5 ⇒ 〈x2,x8〉 | x6 ⇒ 〈x3,x0〉 | x7 ⇒ 〈x3,x8〉 + | x8 ⇒ 〈x4,x0〉 | x9 ⇒ 〈x4,x8〉 | xA ⇒ 〈x5,x0〉 | xB ⇒ 〈x5,x8〉 + | xC ⇒ 〈x6,x0〉 | xD ⇒ 〈x6,x8〉 | xE ⇒ 〈x7,x0〉 | xF ⇒ 〈x7,x8〉 ] + | x9 ⇒ match e2 with + [ x0 ⇒ 〈x0,x0〉 | x1 ⇒ 〈x0,x9〉 | x2 ⇒ 〈x1,x2〉 | x3 ⇒ 〈x1,xB〉 + | x4 ⇒ 〈x2,x4〉 | x5 ⇒ 〈x2,xD〉 | x6 ⇒ 〈x3,x6〉 | x7 ⇒ 〈x3,xF〉 + | x8 ⇒ 〈x4,x8〉 | x9 ⇒ 〈x5,x1〉 | xA ⇒ 〈x5,xA〉 | xB ⇒ 〈x6,x3〉 + | xC ⇒ 〈x6,xC〉 | xD ⇒ 〈x7,x5〉 | xE ⇒ 〈x7,xE〉 | xF ⇒ 〈x8,x7〉 ] + | xA ⇒ match e2 with + [ x0 ⇒ 〈x0,x0〉 | x1 ⇒ 〈x0,xA〉 | x2 ⇒ 〈x1,x4〉 | x3 ⇒ 〈x1,xE〉 + | x4 ⇒ 〈x2,x8〉 | x5 ⇒ 〈x3,x2〉 | x6 ⇒ 〈x3,xC〉 | x7 ⇒ 〈x4,x6〉 + | x8 ⇒ 〈x5,x0〉 | x9 ⇒ 〈x5,xA〉 | xA ⇒ 〈x6,x4〉 | xB ⇒ 〈x6,xE〉 + | xC ⇒ 〈x7,x8〉 | xD ⇒ 〈x8,x2〉 | xE ⇒ 〈x8,xC〉 | xF ⇒ 〈x9,x6〉 ] + | xB ⇒ match e2 with + [ x0 ⇒ 〈x0,x0〉 | x1 ⇒ 〈x0,xB〉 | x2 ⇒ 〈x1,x6〉 | x3 ⇒ 〈x2,x1〉 + | x4 ⇒ 〈x2,xC〉 | x5 ⇒ 〈x3,x7〉 | x6 ⇒ 〈x4,x2〉 | x7 ⇒ 〈x4,xD〉 + | x8 ⇒ 〈x5,x8〉 | x9 ⇒ 〈x6,x3〉 | xA ⇒ 〈x6,xE〉 | xB ⇒ 〈x7,x9〉 + | xC ⇒ 〈x8,x4〉 | xD ⇒ 〈x8,xF〉 | xE ⇒ 〈x9,xA〉 | xF ⇒ 〈xA,x5〉 ] + | xC ⇒ match e2 with + [ x0 ⇒ 〈x0,x0〉 | x1 ⇒ 〈x0,xC〉 | x2 ⇒ 〈x1,x8〉 | x3 ⇒ 〈x2,x4〉 + | x4 ⇒ 〈x3,x0〉 | x5 ⇒ 〈x3,xC〉 | x6 ⇒ 〈x4,x8〉 | x7 ⇒ 〈x5,x4〉 + | x8 ⇒ 〈x6,x0〉 | x9 ⇒ 〈x6,xC〉 | xA ⇒ 〈x7,x8〉 | xB ⇒ 〈x8,x4〉 + | xC ⇒ 〈x9,x0〉 | xD ⇒ 〈x9,xC〉 | xE ⇒ 〈xA,x8〉 | xF ⇒ 〈xB,x4〉 ] + | xD ⇒ match e2 with + [ x0 ⇒ 〈x0,x0〉 | x1 ⇒ 〈x0,xD〉 | x2 ⇒ 〈x1,xA〉 | x3 ⇒ 〈x2,x7〉 + | x4 ⇒ 〈x3,x4〉 | x5 ⇒ 〈x4,x1〉 | x6 ⇒ 〈x4,xE〉 | x7 ⇒ 〈x5,xB〉 + | x8 ⇒ 〈x6,x8〉 | x9 ⇒ 〈x7,x5〉 | xA ⇒ 〈x8,x2〉 | xB ⇒ 〈x8,xF〉 + | xC ⇒ 〈x9,xC〉 | xD ⇒ 〈xA,x9〉 | xE ⇒ 〈xB,x6〉 | xF ⇒ 〈xC,x3〉 ] + | xE ⇒ match e2 with + [ x0 ⇒ 〈x0,x0〉 | x1 ⇒ 〈x0,xE〉 | x2 ⇒ 〈x1,xC〉 | x3 ⇒ 〈x2,xA〉 + | x4 ⇒ 〈x3,x8〉 | x5 ⇒ 〈x4,x6〉 | x6 ⇒ 〈x5,x4〉 | x7 ⇒ 〈x6,x2〉 + | x8 ⇒ 〈x7,x0〉 | x9 ⇒ 〈x7,xE〉 | xA ⇒ 〈x8,xC〉 | xB ⇒ 〈x9,xA〉 + | xC ⇒ 〈xA,x8〉 | xD ⇒ 〈xB,x6〉 | xE ⇒ 〈xC,x4〉 | xF ⇒ 〈xD,x2〉 ] + | xF ⇒ match e2 with + [ x0 ⇒ 〈x0,x0〉 | x1 ⇒ 〈x0,xF〉 | x2 ⇒ 〈x1,xE〉 | x3 ⇒ 〈x2,xD〉 + | x4 ⇒ 〈x3,xC〉 | x5 ⇒ 〈x4,xB〉 | x6 ⇒ 〈x5,xA〉 | x7 ⇒ 〈x6,x9〉 + | x8 ⇒ 〈x7,x8〉 | x9 ⇒ 〈x8,x7〉 | xA ⇒ 〈x9,x6〉 | xB ⇒ 〈xA,x5〉 + | xC ⇒ 〈xB,x4〉 | xD ⇒ 〈xC,x3〉 | xE ⇒ 〈xD,x2〉 | xF ⇒ 〈xE,x1〉 ] + ]. + +(* correzione per somma su BCD *) +(* input: halfcarry,carry,X(BCD+BCD) *) +(* output: X',carry' *) +ndefinition daa_b8 ≝ +λh,c:bool.λX:byte8. + match lt_b8 X 〈x9,xA〉 with + (* [X:0x00-0x99] *) + (* c' = c *) + (* X' = [(b16l X):0x0-0x9] X + [h=1 ? 0x06 : 0x00] + [c=1 ? 0x60 : 0x00] + [(b16l X):0xA-0xF] X + 0x06 + [c=1 ? 0x60 : 0x00] *) + [ true ⇒ + let X' ≝ match (lt_ex (b8l X) xA) ⊗ (⊖h) with + [ true ⇒ X + | false ⇒ plus_b8_d_d X 〈x0,x6〉 ] in + let X'' ≝ match c with + [ true ⇒ plus_b8_d_d X' 〈x6,x0〉 + | false ⇒ X' ] in + pair ?? X'' c + (* [X:0x9A-0xFF] *) + (* c' = 1 *) + (* X' = [X:0x9A-0xFF] + [(b16l X):0x0-0x9] X + [h=1 ? 0x06 : 0x00] + 0x60 + [(b16l X):0xA-0xF] X + 0x6 + 0x60 *) + | false ⇒ + let X' ≝ match (lt_ex (b8l X) xA) ⊗ (⊖h) with + [ true ⇒ X + | false ⇒ plus_b8_d_d X 〈x0,x6〉 ] in + let X'' ≝ plus_b8_d_d X' 〈x6,x0〉 in + pair ?? X'' true + ]. + +(* iteratore sui byte *) +ndefinition forall_byte8 ≝ + λP. + forall_exadecim (λbh. + forall_exadecim (λbl. + P (mk_byte8 bh bl))). diff --git a/helm/software/matita/contribs/ng_assembly/freescale/byte8_lemmas.ma b/helm/software/matita/contribs/ng_assembly/freescale/byte8_lemmas.ma new file mode 100755 index 000000000..cf35e6f35 --- /dev/null +++ b/helm/software/matita/contribs/ng_assembly/freescale/byte8_lemmas.ma @@ -0,0 +1,292 @@ +(**************************************************************************) +(* ___ *) +(* ||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 *) +(* *) +(* Questo materiale fa parte della tesi: *) +(* "Formalizzazione Interattiva dei Microcontroller a 8bit FreeScale" *) +(* *) +(* data ultima modifica 15/11/2007 *) +(* ********************************************************************** *) + +include "freescale/exadecim_lemmas.ma". +include "freescale/byte8.ma". + +(* **** *) +(* BYTE *) +(* **** *) + +nlemma byte8_destruct_1 : +∀x1,x2,y1,y2. + mk_byte8 x1 y1 = mk_byte8 x2 y2 → x1 = x2. + #x1; #x2; #y1; #y2; #H; + nchange with (match mk_byte8 x2 y2 with [ mk_byte8 a _ ⇒ x1 = a ]); + nrewrite < H; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma byte8_destruct_2 : +∀x1,x2,y1,y2. + mk_byte8 x1 y1 = mk_byte8 x2 y2 → y1 = y2. + #x1; #x2; #y1; #y2; #H; + nchange with (match mk_byte8 x2 y2 with [ mk_byte8 _ b ⇒ y1 = b ]); + nrewrite < H; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma symmetric_eqb8 : symmetricT byte8 bool eq_b8. + #b1; #b2; + nelim b1; + nelim b2; + #e1; #e2; #e3; #e4; + nchange with (((eq_ex e3 e1)⊗(eq_ex e4 e2)) = ((eq_ex e1 e3)⊗(eq_ex e2 e4))); + nrewrite > (symmetric_eqex e1 e3); + nrewrite > (symmetric_eqex e2 e4); + napply (refl_eq ??). +nqed. + +nlemma symmetric_andb8 : symmetricT byte8 byte8 and_b8. + #b1; #b2; + nelim b1; + nelim b2; + #e1; #e2; #e3; #e4; + nchange with ((mk_byte8 (and_ex e3 e1) (and_ex e4 e2)) = (mk_byte8 (and_ex e1 e3) (and_ex e2 e4))); + nrewrite > (symmetric_andex e1 e3); + nrewrite > (symmetric_andex e2 e4); + napply (refl_eq ??). +nqed. + +nlemma associative_andb8 : ∀b1,b2,b3.(and_b8 (and_b8 b1 b2) b3) = (and_b8 b1 (and_b8 b2 b3)). + #b1; #b2; #b3; + nelim b1; + #e1; #e2; + nelim b2; + #e3; #e4; + nelim b3; + #e5; #e6; + nchange with (mk_byte8 (and_ex (and_ex e1 e3) e5) (and_ex (and_ex e2 e4) e6) = + mk_byte8 (and_ex e1 (and_ex e3 e5)) (and_ex e2 (and_ex e4 e6))); + nrewrite < (associative_andex e1 e3 e5); + nrewrite < (associative_andex e2 e4 e6); + napply (refl_eq ??). +nqed. + +nlemma symmetric_orb8 : symmetricT byte8 byte8 or_b8. + #b1; #b2; + nelim b1; + nelim b2; + #e1; #e2; #e3; #e4; + nchange with ((mk_byte8 (or_ex e3 e1) (or_ex e4 e2)) = (mk_byte8 (or_ex e1 e3) (or_ex e2 e4))); + nrewrite > (symmetric_orex e1 e3); + nrewrite > (symmetric_orex e2 e4); + napply (refl_eq ??). +nqed. + +nlemma associative_orb8 : ∀b1,b2,b3.(or_b8 (or_b8 b1 b2) b3) = (or_b8 b1 (or_b8 b2 b3)). + #b1; #b2; #b3; + nelim b1; + #e1; #e2; + nelim b2; + #e3; #e4; + nelim b3; + #e5; #e6; + nchange with (mk_byte8 (or_ex (or_ex e1 e3) e5) (or_ex (or_ex e2 e4) e6) = + mk_byte8 (or_ex e1 (or_ex e3 e5)) (or_ex e2 (or_ex e4 e6))); + nrewrite < (associative_orex e1 e3 e5); + nrewrite < (associative_orex e2 e4 e6); + napply (refl_eq ??). +nqed. + +nlemma symmetric_xorb8 : symmetricT byte8 byte8 xor_b8. + #b1; #b2; + nelim b1; + nelim b2; + #e1; #e2; #e3; #e4; + nchange with ((mk_byte8 (xor_ex e3 e1) (xor_ex e4 e2)) = (mk_byte8 (xor_ex e1 e3) (xor_ex e2 e4))); + nrewrite > (symmetric_xorex e1 e3); + nrewrite > (symmetric_xorex e2 e4); + napply (refl_eq ??). +nqed. + +nlemma associative_xorb8 : ∀b1,b2,b3.(xor_b8 (xor_b8 b1 b2) b3) = (xor_b8 b1 (xor_b8 b2 b3)). + #b1; #b2; #b3; + nelim b1; + #e1; #e2; + nelim b2; + #e3; #e4; + nelim b3; + #e5; #e6; + nchange with (mk_byte8 (xor_ex (xor_ex e1 e3) e5) (xor_ex (xor_ex e2 e4) e6) = + mk_byte8 (xor_ex e1 (xor_ex e3 e5)) (xor_ex e2 (xor_ex e4 e6))); + nrewrite < (associative_xorex e1 e3 e5); + nrewrite < (associative_xorex e2 e4 e6); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusb8_dc_dc : ∀b1,b2,c.plus_b8_dc_dc b1 b2 c = plus_b8_dc_dc b2 b1 c. + #b1; #b2; #c; + nelim b1; + #e1; #e2; + nelim b2; + #e3; #e4; + nchange with ( + match plus_ex_dc_dc e2 e4 c with + [ pair l c ⇒ match plus_ex_dc_dc e1 e3 c with + [ pair h c' ⇒ pair ?? 〈h,l〉 c' ]] = + match plus_ex_dc_dc e4 e2 c with + [ pair l c ⇒ match plus_ex_dc_dc e3 e1 c with + [ pair h c' ⇒ pair ?? 〈h,l〉 c' ]]); + nrewrite > (symmetric_plusex_dc_dc e4 e2 c); + ncases (plus_ex_dc_dc e2 e4 c); + #e5; #c1; + nchange with ( + match plus_ex_dc_dc e1 e3 c1 with + [ pair h c' ⇒ pair ?? 〈h,e5〉 c' ] = + match plus_ex_dc_dc e3 e1 c1 with + [ pair h c' ⇒ pair ?? 〈h,e5〉 c' ]); + nrewrite > (symmetric_plusex_dc_dc e1 e3 c1); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusb8_dc_d : ∀b1,b2,c.plus_b8_dc_d b1 b2 c = plus_b8_dc_d b2 b1 c. + #b1; #b2; #c; + nelim b1; + #e1; #e2; + nelim b2; + #e3; #e4; + nchange with ( + match plus_ex_dc_dc e2 e4 c with + [ pair l c ⇒ 〈plus_ex_dc_d e1 e3 c,l〉 ] = + match plus_ex_dc_dc e4 e2 c with + [ pair l c ⇒ 〈plus_ex_dc_d e3 e1 c,l〉 ]); + nrewrite > (symmetric_plusex_dc_dc e4 e2 c); + ncases (plus_ex_dc_dc e2 e4 c); + #e5; #c1; + nchange with (〈plus_ex_dc_d e1 e3 c1,e5〉 = 〈plus_ex_dc_d e3 e1 c1,e5〉); + nrewrite > (symmetric_plusex_dc_d e1 e3 c1); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusb8_dc_c : ∀b1,b2,c.plus_b8_dc_c b1 b2 c = plus_b8_dc_c b2 b1 c. + #b1; #b2; #c; + nelim b1; + #e1; #e2; + nelim b2; + #e3; #e4; + nchange with ( + plus_ex_dc_c e1 e3 (plus_ex_dc_c e2 e4 c) = + plus_ex_dc_c e3 e1 (plus_ex_dc_c e4 e2 c)); + nrewrite > (symmetric_plusex_dc_c e4 e2 c); + nrewrite > (symmetric_plusex_dc_c e3 e1 (plus_ex_dc_c e2 e4 c)); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusb8_d_dc : ∀b1,b2.plus_b8_d_dc b1 b2 = plus_b8_d_dc b2 b1. + #b1; #b2; + nelim b1; + #e1; #e2; + nelim b2; + #e3; #e4; + nchange with ( + match plus_ex_d_dc e2 e4 with + [ pair l c ⇒ match plus_ex_dc_dc e1 e3 c with + [ pair h c' ⇒ pair ?? 〈h,l〉 c' ]] = + match plus_ex_d_dc e4 e2 with + [ pair l c ⇒ match plus_ex_dc_dc e3 e1 c with + [ pair h c' ⇒ pair ?? 〈h,l〉 c' ]]); + nrewrite > (symmetric_plusex_d_dc e4 e2); + ncases (plus_ex_d_dc e2 e4); + #e5; #c; + nchange with ( + match plus_ex_dc_dc e1 e3 c with + [ pair h c' ⇒ pair ?? 〈h,e5〉 c' ] = + match plus_ex_dc_dc e3 e1 c with + [ pair h c' ⇒ pair ?? 〈h,e5〉 c' ]); + nrewrite > (symmetric_plusex_dc_dc e1 e3 c); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusb8_d_d : ∀b1,b2.plus_b8_d_d b1 b2 = plus_b8_d_d b2 b1. + #b1; #b2; + nelim b1; + #e1; #e2; + nelim b2; + #e3; #e4; + nchange with ( + match plus_ex_d_dc e2 e4 with + [ pair l c ⇒ 〈plus_ex_dc_d e1 e3 c,l〉 ] = + match plus_ex_d_dc e4 e2 with + [ pair l c ⇒ 〈plus_ex_dc_d e3 e1 c,l〉 ]); + nrewrite > (symmetric_plusex_d_dc e4 e2); + ncases (plus_ex_d_dc e2 e4); + #e5; #c; + nchange with (〈plus_ex_dc_d e1 e3 c,e5〉 = 〈plus_ex_dc_d e3 e1 c,e5〉); + nrewrite > (symmetric_plusex_dc_d e1 e3 c); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusb8_d_c : ∀b1,b2.plus_b8_d_c b1 b2 = plus_b8_d_c b2 b1. + #b1; #b2; + nelim b1; + #e1; #e2; + nelim b2; + #e3; #e4; + nchange with ( + plus_ex_dc_c e1 e3 (plus_ex_d_c e2 e4) = + plus_ex_dc_c e3 e1 (plus_ex_d_c e4 e2)); + nrewrite > (symmetric_plusex_d_c e4 e2); + nrewrite > (symmetric_plusex_dc_c e3 e1 (plus_ex_d_c e2 e4)); + napply (refl_eq ??). +nqed. + +nlemma symmetric_mulex : symmetricT exadecim byte8 mul_ex. + #e1; #e2; + nelim e1; + nelim e2; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma eqb8_to_eq : ∀b1,b2:byte8.(eq_b8 b1 b2 = true) → (b1 = b2). + #b1; #b2; + nelim b1; + nelim b2; + #e1; #e2; #e3; #e4; + nchange in ⊢ (% → ?) with (((eq_ex e3 e1)⊗(eq_ex e4 e2)) = true); + #H; + nrewrite < (eqex_to_eq ?? (andb_true_true_l ?? H)); + nrewrite < (eqex_to_eq ?? (andb_true_true_r ?? H)); + napply (refl_eq ??). +nqed. + +nlemma eq_to_eqb8 : ∀b1,b2.b1 = b2 → eq_b8 b1 b2 = true. + #b1; #b2; + nelim b1; + nelim b2; + #e1; #e2; #e3; #e4; + #H; + nrewrite < (byte8_destruct_1 ???? H); + nrewrite < (byte8_destruct_2 ???? H); + nchange with (((eq_ex e3 e3)⊗(eq_ex e4 e4)) = true); + nrewrite > (eq_to_eqex e3 e3 (refl_eq ??)); + nrewrite > (eq_to_eqex e4 e4 (refl_eq ??)); + nnormalize; + napply (refl_eq ??). +nqed. diff --git a/helm/software/matita/contribs/ng_assembly/freescale/exadecim.ma b/helm/software/matita/contribs/ng_assembly/freescale/exadecim.ma index 16fb11a16..a87cf99d2 100755 --- a/helm/software/matita/contribs/ng_assembly/freescale/exadecim.ma +++ b/helm/software/matita/contribs/ng_assembly/freescale/exadecim.ma @@ -871,601 +871,578 @@ ndefinition not_ex ≝ | x8 ⇒ x7 | x9 ⇒ x6 | xA ⇒ x5 | xB ⇒ x4 | xC ⇒ x3 | xD ⇒ x2 | xE ⇒ x1 | xF ⇒ x0 ]. -(* operatore somma con carry *) -ndefinition plus_ex ≝ +(* operatore somma con data+carry → data+carry *) +ndefinition plus_ex_dc_dc ≝ λe1,e2:exadecim.λc:bool. - match c with - [ true ⇒ - match e1 with - [ x0 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x1 false - | x1 ⇒ pair exadecim bool x2 false - | x2 ⇒ pair exadecim bool x3 false - | x3 ⇒ pair exadecim bool x4 false - | x4 ⇒ pair exadecim bool x5 false - | x5 ⇒ pair exadecim bool x6 false - | x6 ⇒ pair exadecim bool x7 false - | x7 ⇒ pair exadecim bool x8 false - | x8 ⇒ pair exadecim bool x9 false - | x9 ⇒ pair exadecim bool xA false - | xA ⇒ pair exadecim bool xB false - | xB ⇒ pair exadecim bool xC false - | xC ⇒ pair exadecim bool xD false - | xD ⇒ pair exadecim bool xE false - | xE ⇒ pair exadecim bool xF false - | xF ⇒ pair exadecim bool x0 true ] - | x1 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x2 false - | x1 ⇒ pair exadecim bool x3 false - | x2 ⇒ pair exadecim bool x4 false - | x3 ⇒ pair exadecim bool x5 false - | x4 ⇒ pair exadecim bool x6 false - | x5 ⇒ pair exadecim bool x7 false - | x6 ⇒ pair exadecim bool x8 false - | x7 ⇒ pair exadecim bool x9 false - | x8 ⇒ pair exadecim bool xA false - | x9 ⇒ pair exadecim bool xB false - | xA ⇒ pair exadecim bool xC false - | xB ⇒ pair exadecim bool xD false - | xC ⇒ pair exadecim bool xE false - | xD ⇒ pair exadecim bool xF false - | xE ⇒ pair exadecim bool x0 true - | xF ⇒ pair exadecim bool x1 true ] - | x2 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x3 false - | x1 ⇒ pair exadecim bool x4 false - | x2 ⇒ pair exadecim bool x5 false - | x3 ⇒ pair exadecim bool x6 false - | x4 ⇒ pair exadecim bool x7 false - | x5 ⇒ pair exadecim bool x8 false - | x6 ⇒ pair exadecim bool x9 false - | x7 ⇒ pair exadecim bool xA false - | x8 ⇒ pair exadecim bool xB false - | x9 ⇒ pair exadecim bool xC false - | xA ⇒ pair exadecim bool xD false - | xB ⇒ pair exadecim bool xE false - | xC ⇒ pair exadecim bool xF false - | xD ⇒ pair exadecim bool x0 true - | xE ⇒ pair exadecim bool x1 true - | xF ⇒ pair exadecim bool x2 true ] - | x3 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x4 false - | x1 ⇒ pair exadecim bool x5 false - | x2 ⇒ pair exadecim bool x6 false - | x3 ⇒ pair exadecim bool x7 false - | x4 ⇒ pair exadecim bool x8 false - | x5 ⇒ pair exadecim bool x9 false - | x6 ⇒ pair exadecim bool xA false - | x7 ⇒ pair exadecim bool xB false - | x8 ⇒ pair exadecim bool xC false - | x9 ⇒ pair exadecim bool xD false - | xA ⇒ pair exadecim bool xE false - | xB ⇒ pair exadecim bool xF false - | xC ⇒ pair exadecim bool x0 true - | xD ⇒ pair exadecim bool x1 true - | xE ⇒ pair exadecim bool x2 true - | xF ⇒ pair exadecim bool x3 true ] - | x4 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x5 false - | x1 ⇒ pair exadecim bool x6 false - | x2 ⇒ pair exadecim bool x7 false - | x3 ⇒ pair exadecim bool x8 false - | x4 ⇒ pair exadecim bool x9 false - | x5 ⇒ pair exadecim bool xA false - | x6 ⇒ pair exadecim bool xB false - | x7 ⇒ pair exadecim bool xC false - | x8 ⇒ pair exadecim bool xD false - | x9 ⇒ pair exadecim bool xE false - | xA ⇒ pair exadecim bool xF false - | xB ⇒ pair exadecim bool x0 true - | xC ⇒ pair exadecim bool x1 true - | xD ⇒ pair exadecim bool x2 true - | xE ⇒ pair exadecim bool x3 true - | xF ⇒ pair exadecim bool x4 true ] - | x5 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x6 false - | x1 ⇒ pair exadecim bool x7 false - | x2 ⇒ pair exadecim bool x8 false - | x3 ⇒ pair exadecim bool x9 false - | x4 ⇒ pair exadecim bool xA false - | x5 ⇒ pair exadecim bool xB false - | x6 ⇒ pair exadecim bool xC false - | x7 ⇒ pair exadecim bool xD false - | x8 ⇒ pair exadecim bool xE false - | x9 ⇒ pair exadecim bool xF false - | xA ⇒ pair exadecim bool x0 true - | xB ⇒ pair exadecim bool x1 true - | xC ⇒ pair exadecim bool x2 true - | xD ⇒ pair exadecim bool x3 true - | xE ⇒ pair exadecim bool x4 true - | xF ⇒ pair exadecim bool x5 true ] - | x6 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x7 false - | x1 ⇒ pair exadecim bool x8 false - | x2 ⇒ pair exadecim bool x9 false - | x3 ⇒ pair exadecim bool xA false - | x4 ⇒ pair exadecim bool xB false - | x5 ⇒ pair exadecim bool xC false - | x6 ⇒ pair exadecim bool xD false - | x7 ⇒ pair exadecim bool xE false - | x8 ⇒ pair exadecim bool xF false - | x9 ⇒ pair exadecim bool x0 true - | xA ⇒ pair exadecim bool x1 true - | xB ⇒ pair exadecim bool x2 true - | xC ⇒ pair exadecim bool x3 true - | xD ⇒ pair exadecim bool x4 true - | xE ⇒ pair exadecim bool x5 true - | xF ⇒ pair exadecim bool x6 true ] - | x7 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x8 false - | x1 ⇒ pair exadecim bool x9 false - | x2 ⇒ pair exadecim bool xA false - | x3 ⇒ pair exadecim bool xB false - | x4 ⇒ pair exadecim bool xC false - | x5 ⇒ pair exadecim bool xD false - | x6 ⇒ pair exadecim bool xE false - | x7 ⇒ pair exadecim bool xF false - | x8 ⇒ pair exadecim bool x0 true - | x9 ⇒ pair exadecim bool x1 true - | xA ⇒ pair exadecim bool x2 true - | xB ⇒ pair exadecim bool x3 true - | xC ⇒ pair exadecim bool x4 true - | xD ⇒ pair exadecim bool x5 true - | xE ⇒ pair exadecim bool x6 true - | xF ⇒ pair exadecim bool x7 true ] - | x8 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x9 false - | x1 ⇒ pair exadecim bool xA false - | x2 ⇒ pair exadecim bool xB false - | x3 ⇒ pair exadecim bool xC false - | x4 ⇒ pair exadecim bool xD false - | x5 ⇒ pair exadecim bool xE false - | x6 ⇒ pair exadecim bool xF false - | x7 ⇒ pair exadecim bool x0 true - | x8 ⇒ pair exadecim bool x1 true - | x9 ⇒ pair exadecim bool x2 true - | xA ⇒ pair exadecim bool x3 true - | xB ⇒ pair exadecim bool x4 true - | xC ⇒ pair exadecim bool x5 true - | xD ⇒ pair exadecim bool x6 true - | xE ⇒ pair exadecim bool x7 true - | xF ⇒ pair exadecim bool x8 true ] - | x9 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool xA false - | x1 ⇒ pair exadecim bool xB false - | x2 ⇒ pair exadecim bool xC false - | x3 ⇒ pair exadecim bool xD false - | x4 ⇒ pair exadecim bool xE false - | x5 ⇒ pair exadecim bool xF false - | x6 ⇒ pair exadecim bool x0 true - | x7 ⇒ pair exadecim bool x1 true - | x8 ⇒ pair exadecim bool x2 true - | x9 ⇒ pair exadecim bool x3 true - | xA ⇒ pair exadecim bool x4 true - | xB ⇒ pair exadecim bool x5 true - | xC ⇒ pair exadecim bool x6 true - | xD ⇒ pair exadecim bool x7 true - | xE ⇒ pair exadecim bool x8 true - | xF ⇒ pair exadecim bool x9 true ] - | xA ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool xB false - | x1 ⇒ pair exadecim bool xC false - | x2 ⇒ pair exadecim bool xD false - | x3 ⇒ pair exadecim bool xE false - | x4 ⇒ pair exadecim bool xF false - | x5 ⇒ pair exadecim bool x0 true - | x6 ⇒ pair exadecim bool x1 true - | x7 ⇒ pair exadecim bool x2 true - | x8 ⇒ pair exadecim bool x3 true - | x9 ⇒ pair exadecim bool x4 true - | xA ⇒ pair exadecim bool x5 true - | xB ⇒ pair exadecim bool x6 true - | xC ⇒ pair exadecim bool x7 true - | xD ⇒ pair exadecim bool x8 true - | xE ⇒ pair exadecim bool x9 true - | xF ⇒ pair exadecim bool xA true ] - | xB ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool xC false - | x1 ⇒ pair exadecim bool xD false - | x2 ⇒ pair exadecim bool xE false - | x3 ⇒ pair exadecim bool xF false - | x4 ⇒ pair exadecim bool x0 true - | x5 ⇒ pair exadecim bool x1 true - | x6 ⇒ pair exadecim bool x2 true - | x7 ⇒ pair exadecim bool x3 true - | x8 ⇒ pair exadecim bool x4 true - | x9 ⇒ pair exadecim bool x5 true - | xA ⇒ pair exadecim bool x6 true - | xB ⇒ pair exadecim bool x7 true - | xC ⇒ pair exadecim bool x8 true - | xD ⇒ pair exadecim bool x9 true - | xE ⇒ pair exadecim bool xA true - | xF ⇒ pair exadecim bool xB true ] - | xC ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool xD false - | x1 ⇒ pair exadecim bool xE false - | x2 ⇒ pair exadecim bool xF false - | x3 ⇒ pair exadecim bool x0 true - | x4 ⇒ pair exadecim bool x1 true - | x5 ⇒ pair exadecim bool x2 true - | x6 ⇒ pair exadecim bool x3 true - | x7 ⇒ pair exadecim bool x4 true - | x8 ⇒ pair exadecim bool x5 true - | x9 ⇒ pair exadecim bool x6 true - | xA ⇒ pair exadecim bool x7 true - | xB ⇒ pair exadecim bool x8 true - | xC ⇒ pair exadecim bool x9 true - | xD ⇒ pair exadecim bool xA true - | xE ⇒ pair exadecim bool xB true - | xF ⇒ pair exadecim bool xC true ] - | xD ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool xE false - | x1 ⇒ pair exadecim bool xF false - | x2 ⇒ pair exadecim bool x0 true - | x3 ⇒ pair exadecim bool x1 true - | x4 ⇒ pair exadecim bool x2 true - | x5 ⇒ pair exadecim bool x3 true - | x6 ⇒ pair exadecim bool x4 true - | x7 ⇒ pair exadecim bool x5 true - | x8 ⇒ pair exadecim bool x6 true - | x9 ⇒ pair exadecim bool x7 true - | xA ⇒ pair exadecim bool x8 true - | xB ⇒ pair exadecim bool x9 true - | xC ⇒ pair exadecim bool xA true - | xD ⇒ pair exadecim bool xB true - | xE ⇒ pair exadecim bool xC true - | xF ⇒ pair exadecim bool xD true ] - | xE ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool xF false - | x1 ⇒ pair exadecim bool x0 true - | x2 ⇒ pair exadecim bool x1 true - | x3 ⇒ pair exadecim bool x2 true - | x4 ⇒ pair exadecim bool x3 true - | x5 ⇒ pair exadecim bool x4 true - | x6 ⇒ pair exadecim bool x5 true - | x7 ⇒ pair exadecim bool x6 true - | x8 ⇒ pair exadecim bool x7 true - | x9 ⇒ pair exadecim bool x8 true - | xA ⇒ pair exadecim bool x9 true - | xB ⇒ pair exadecim bool xA true - | xC ⇒ pair exadecim bool xB true - | xD ⇒ pair exadecim bool xC true - | xE ⇒ pair exadecim bool xD true - | xF ⇒ pair exadecim bool xE true ] - | xF ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x0 true - | x1 ⇒ pair exadecim bool x1 true - | x2 ⇒ pair exadecim bool x2 true - | x3 ⇒ pair exadecim bool x3 true - | x4 ⇒ pair exadecim bool x4 true - | x5 ⇒ pair exadecim bool x5 true - | x6 ⇒ pair exadecim bool x6 true - | x7 ⇒ pair exadecim bool x7 true - | x8 ⇒ pair exadecim bool x8 true - | x9 ⇒ pair exadecim bool x9 true - | xA ⇒ pair exadecim bool xA true - | xB ⇒ pair exadecim bool xB true - | xC ⇒ pair exadecim bool xC true - | xD ⇒ pair exadecim bool xD true - | xE ⇒ pair exadecim bool xE true - | xF ⇒ pair exadecim bool xF true ] - ] - | false ⇒ - match e1 with - [ x0 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x0 false - | x1 ⇒ pair exadecim bool x1 false - | x2 ⇒ pair exadecim bool x2 false - | x3 ⇒ pair exadecim bool x3 false - | x4 ⇒ pair exadecim bool x4 false - | x5 ⇒ pair exadecim bool x5 false - | x6 ⇒ pair exadecim bool x6 false - | x7 ⇒ pair exadecim bool x7 false - | x8 ⇒ pair exadecim bool x8 false - | x9 ⇒ pair exadecim bool x9 false - | xA ⇒ pair exadecim bool xA false - | xB ⇒ pair exadecim bool xB false - | xC ⇒ pair exadecim bool xC false - | xD ⇒ pair exadecim bool xD false - | xE ⇒ pair exadecim bool xE false - | xF ⇒ pair exadecim bool xF false ] - | x1 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x1 false - | x1 ⇒ pair exadecim bool x2 false - | x2 ⇒ pair exadecim bool x3 false - | x3 ⇒ pair exadecim bool x4 false - | x4 ⇒ pair exadecim bool x5 false - | x5 ⇒ pair exadecim bool x6 false - | x6 ⇒ pair exadecim bool x7 false - | x7 ⇒ pair exadecim bool x8 false - | x8 ⇒ pair exadecim bool x9 false - | x9 ⇒ pair exadecim bool xA false - | xA ⇒ pair exadecim bool xB false - | xB ⇒ pair exadecim bool xC false - | xC ⇒ pair exadecim bool xD false - | xD ⇒ pair exadecim bool xE false - | xE ⇒ pair exadecim bool xF false - | xF ⇒ pair exadecim bool x0 true ] - | x2 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x2 false - | x1 ⇒ pair exadecim bool x3 false - | x2 ⇒ pair exadecim bool x4 false - | x3 ⇒ pair exadecim bool x5 false - | x4 ⇒ pair exadecim bool x6 false - | x5 ⇒ pair exadecim bool x7 false - | x6 ⇒ pair exadecim bool x8 false - | x7 ⇒ pair exadecim bool x9 false - | x8 ⇒ pair exadecim bool xA false - | x9 ⇒ pair exadecim bool xB false - | xA ⇒ pair exadecim bool xC false - | xB ⇒ pair exadecim bool xD false - | xC ⇒ pair exadecim bool xE false - | xD ⇒ pair exadecim bool xF false - | xE ⇒ pair exadecim bool x0 true - | xF ⇒ pair exadecim bool x1 true ] - | x3 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x3 false - | x1 ⇒ pair exadecim bool x4 false - | x2 ⇒ pair exadecim bool x5 false - | x3 ⇒ pair exadecim bool x6 false - | x4 ⇒ pair exadecim bool x7 false - | x5 ⇒ pair exadecim bool x8 false - | x6 ⇒ pair exadecim bool x9 false - | x7 ⇒ pair exadecim bool xA false - | x8 ⇒ pair exadecim bool xB false - | x9 ⇒ pair exadecim bool xC false - | xA ⇒ pair exadecim bool xD false - | xB ⇒ pair exadecim bool xE false - | xC ⇒ pair exadecim bool xF false - | xD ⇒ pair exadecim bool x0 true - | xE ⇒ pair exadecim bool x1 true - | xF ⇒ pair exadecim bool x2 true ] - | x4 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x4 false - | x1 ⇒ pair exadecim bool x5 false - | x2 ⇒ pair exadecim bool x6 false - | x3 ⇒ pair exadecim bool x7 false - | x4 ⇒ pair exadecim bool x8 false - | x5 ⇒ pair exadecim bool x9 false - | x6 ⇒ pair exadecim bool xA false - | x7 ⇒ pair exadecim bool xB false - | x8 ⇒ pair exadecim bool xC false - | x9 ⇒ pair exadecim bool xD false - | xA ⇒ pair exadecim bool xE false - | xB ⇒ pair exadecim bool xF false - | xC ⇒ pair exadecim bool x0 true - | xD ⇒ pair exadecim bool x1 true - | xE ⇒ pair exadecim bool x2 true - | xF ⇒ pair exadecim bool x3 true ] - | x5 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x5 false - | x1 ⇒ pair exadecim bool x6 false - | x2 ⇒ pair exadecim bool x7 false - | x3 ⇒ pair exadecim bool x8 false - | x4 ⇒ pair exadecim bool x9 false - | x5 ⇒ pair exadecim bool xA false - | x6 ⇒ pair exadecim bool xB false - | x7 ⇒ pair exadecim bool xC false - | x8 ⇒ pair exadecim bool xD false - | x9 ⇒ pair exadecim bool xE false - | xA ⇒ pair exadecim bool xF false - | xB ⇒ pair exadecim bool x0 true - | xC ⇒ pair exadecim bool x1 true - | xD ⇒ pair exadecim bool x2 true - | xE ⇒ pair exadecim bool x3 true - | xF ⇒ pair exadecim bool x4 true ] - | x6 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x6 false - | x1 ⇒ pair exadecim bool x7 false - | x2 ⇒ pair exadecim bool x8 false - | x3 ⇒ pair exadecim bool x9 false - | x4 ⇒ pair exadecim bool xA false - | x5 ⇒ pair exadecim bool xB false - | x6 ⇒ pair exadecim bool xC false - | x7 ⇒ pair exadecim bool xD false - | x8 ⇒ pair exadecim bool xE false - | x9 ⇒ pair exadecim bool xF false - | xA ⇒ pair exadecim bool x0 true - | xB ⇒ pair exadecim bool x1 true - | xC ⇒ pair exadecim bool x2 true - | xD ⇒ pair exadecim bool x3 true - | xE ⇒ pair exadecim bool x4 true - | xF ⇒ pair exadecim bool x5 true ] - | x7 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x7 false - | x1 ⇒ pair exadecim bool x8 false - | x2 ⇒ pair exadecim bool x9 false - | x3 ⇒ pair exadecim bool xA false - | x4 ⇒ pair exadecim bool xB false - | x5 ⇒ pair exadecim bool xC false - | x6 ⇒ pair exadecim bool xD false - | x7 ⇒ pair exadecim bool xE false - | x8 ⇒ pair exadecim bool xF false - | x9 ⇒ pair exadecim bool x0 true - | xA ⇒ pair exadecim bool x1 true - | xB ⇒ pair exadecim bool x2 true - | xC ⇒ pair exadecim bool x3 true - | xD ⇒ pair exadecim bool x4 true - | xE ⇒ pair exadecim bool x5 true - | xF ⇒ pair exadecim bool x6 true ] - | x8 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x8 false - | x1 ⇒ pair exadecim bool x9 false - | x2 ⇒ pair exadecim bool xA false - | x3 ⇒ pair exadecim bool xB false - | x4 ⇒ pair exadecim bool xC false - | x5 ⇒ pair exadecim bool xD false - | x6 ⇒ pair exadecim bool xE false - | x7 ⇒ pair exadecim bool xF false - | x8 ⇒ pair exadecim bool x0 true - | x9 ⇒ pair exadecim bool x1 true - | xA ⇒ pair exadecim bool x2 true - | xB ⇒ pair exadecim bool x3 true - | xC ⇒ pair exadecim bool x4 true - | xD ⇒ pair exadecim bool x5 true - | xE ⇒ pair exadecim bool x6 true - | xF ⇒ pair exadecim bool x7 true ] - | x9 ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool x9 false - | x1 ⇒ pair exadecim bool xA false - | x2 ⇒ pair exadecim bool xB false - | x3 ⇒ pair exadecim bool xC false - | x4 ⇒ pair exadecim bool xD false - | x5 ⇒ pair exadecim bool xE false - | x6 ⇒ pair exadecim bool xF false - | x7 ⇒ pair exadecim bool x0 true - | x8 ⇒ pair exadecim bool x1 true - | x9 ⇒ pair exadecim bool x2 true - | xA ⇒ pair exadecim bool x3 true - | xB ⇒ pair exadecim bool x4 true - | xC ⇒ pair exadecim bool x5 true - | xD ⇒ pair exadecim bool x6 true - | xE ⇒ pair exadecim bool x7 true - | xF ⇒ pair exadecim bool x8 true ] - | xA ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool xA false - | x1 ⇒ pair exadecim bool xB false - | x2 ⇒ pair exadecim bool xC false - | x3 ⇒ pair exadecim bool xD false - | x4 ⇒ pair exadecim bool xE false - | x5 ⇒ pair exadecim bool xF false - | x6 ⇒ pair exadecim bool x0 true - | x7 ⇒ pair exadecim bool x1 true - | x8 ⇒ pair exadecim bool x2 true - | x9 ⇒ pair exadecim bool x3 true - | xA ⇒ pair exadecim bool x4 true - | xB ⇒ pair exadecim bool x5 true - | xC ⇒ pair exadecim bool x6 true - | xD ⇒ pair exadecim bool x7 true - | xE ⇒ pair exadecim bool x8 true - | xF ⇒ pair exadecim bool x9 true ] - | xB ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool xB false - | x1 ⇒ pair exadecim bool xC false - | x2 ⇒ pair exadecim bool xD false - | x3 ⇒ pair exadecim bool xE false - | x4 ⇒ pair exadecim bool xF false - | x5 ⇒ pair exadecim bool x0 true - | x6 ⇒ pair exadecim bool x1 true - | x7 ⇒ pair exadecim bool x2 true - | x8 ⇒ pair exadecim bool x3 true - | x9 ⇒ pair exadecim bool x4 true - | xA ⇒ pair exadecim bool x5 true - | xB ⇒ pair exadecim bool x6 true - | xC ⇒ pair exadecim bool x7 true - | xD ⇒ pair exadecim bool x8 true - | xE ⇒ pair exadecim bool x9 true - | xF ⇒ pair exadecim bool xA true ] - | xC ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool xC false - | x1 ⇒ pair exadecim bool xD false - | x2 ⇒ pair exadecim bool xE false - | x3 ⇒ pair exadecim bool xF false - | x4 ⇒ pair exadecim bool x0 true - | x5 ⇒ pair exadecim bool x1 true - | x6 ⇒ pair exadecim bool x2 true - | x7 ⇒ pair exadecim bool x3 true - | x8 ⇒ pair exadecim bool x4 true - | x9 ⇒ pair exadecim bool x5 true - | xA ⇒ pair exadecim bool x6 true - | xB ⇒ pair exadecim bool x7 true - | xC ⇒ pair exadecim bool x8 true - | xD ⇒ pair exadecim bool x9 true - | xE ⇒ pair exadecim bool xA true - | xF ⇒ pair exadecim bool xB true ] - | xD ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool xD false - | x1 ⇒ pair exadecim bool xE false - | x2 ⇒ pair exadecim bool xF false - | x3 ⇒ pair exadecim bool x0 true - | x4 ⇒ pair exadecim bool x1 true - | x5 ⇒ pair exadecim bool x2 true - | x6 ⇒ pair exadecim bool x3 true - | x7 ⇒ pair exadecim bool x4 true - | x8 ⇒ pair exadecim bool x5 true - | x9 ⇒ pair exadecim bool x6 true - | xA ⇒ pair exadecim bool x7 true - | xB ⇒ pair exadecim bool x8 true - | xC ⇒ pair exadecim bool x9 true - | xD ⇒ pair exadecim bool xA true - | xE ⇒ pair exadecim bool xB true - | xF ⇒ pair exadecim bool xC true ] - | xE ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool xE false - | x1 ⇒ pair exadecim bool xF false - | x2 ⇒ pair exadecim bool x0 true - | x3 ⇒ pair exadecim bool x1 true - | x4 ⇒ pair exadecim bool x2 true - | x5 ⇒ pair exadecim bool x3 true - | x6 ⇒ pair exadecim bool x4 true - | x7 ⇒ pair exadecim bool x5 true - | x8 ⇒ pair exadecim bool x6 true - | x9 ⇒ pair exadecim bool x7 true - | xA ⇒ pair exadecim bool x8 true - | xB ⇒ pair exadecim bool x9 true - | xC ⇒ pair exadecim bool xA true - | xD ⇒ pair exadecim bool xB true - | xE ⇒ pair exadecim bool xC true - | xF ⇒ pair exadecim bool xD true ] - | xF ⇒ - match e2 with - [ x0 ⇒ pair exadecim bool xF false - | x1 ⇒ pair exadecim bool x0 true - | x2 ⇒ pair exadecim bool x1 true - | x3 ⇒ pair exadecim bool x2 true - | x4 ⇒ pair exadecim bool x3 true - | x5 ⇒ pair exadecim bool x4 true - | x6 ⇒ pair exadecim bool x5 true - | x7 ⇒ pair exadecim bool x6 true - | x8 ⇒ pair exadecim bool x7 true - | x9 ⇒ pair exadecim bool x8 true - | xA ⇒ pair exadecim bool x9 true - | xB ⇒ pair exadecim bool xA true - | xC ⇒ pair exadecim bool xB true - | xD ⇒ pair exadecim bool xC true - | xE ⇒ pair exadecim bool xD true - | xF ⇒ pair exadecim bool xE true ] - ] - ]. + match c with + [ true ⇒ match e1 with + [ x0 ⇒ match e2 with + [ x0 ⇒ pair ?? x1 false | x1 ⇒ pair ?? x2 false | x2 ⇒ pair ?? x3 false | x3 ⇒ pair ?? x4 false + | x4 ⇒ pair ?? x5 false | x5 ⇒ pair ?? x6 false | x6 ⇒ pair ?? x7 false | x7 ⇒ pair ?? x8 false + | x8 ⇒ pair ?? x9 false | x9 ⇒ pair ?? xA false | xA ⇒ pair ?? xB false | xB ⇒ pair ?? xC false + | xC ⇒ pair ?? xD false | xD ⇒ pair ?? xE false | xE ⇒ pair ?? xF false | xF ⇒ pair ?? x0 true ] + | x1 ⇒ match e2 with + [ x0 ⇒ pair ?? x2 false | x1 ⇒ pair ?? x3 false | x2 ⇒ pair ?? x4 false | x3 ⇒ pair ?? x5 false + | x4 ⇒ pair ?? x6 false | x5 ⇒ pair ?? x7 false | x6 ⇒ pair ?? x8 false | x7 ⇒ pair ?? x9 false + | x8 ⇒ pair ?? xA false | x9 ⇒ pair ?? xB false | xA ⇒ pair ?? xC false | xB ⇒ pair ?? xD false + | xC ⇒ pair ?? xE false | xD ⇒ pair ?? xF false | xE ⇒ pair ?? x0 true | xF ⇒ pair ?? x1 true ] + | x2 ⇒ match e2 with + [ x0 ⇒ pair ?? x3 false | x1 ⇒ pair ?? x4 false | x2 ⇒ pair ?? x5 false | x3 ⇒ pair ?? x6 false + | x4 ⇒ pair ?? x7 false | x5 ⇒ pair ?? x8 false | x6 ⇒ pair ?? x9 false | x7 ⇒ pair ?? xA false + | x8 ⇒ pair ?? xB false | x9 ⇒ pair ?? xC false | xA ⇒ pair ?? xD false | xB ⇒ pair ?? xE false + | xC ⇒ pair ?? xF false | xD ⇒ pair ?? x0 true | xE ⇒ pair ?? x1 true | xF ⇒ pair ?? x2 true ] + | x3 ⇒ match e2 with + [ x0 ⇒ pair ?? x4 false | x1 ⇒ pair ?? x5 false | x2 ⇒ pair ?? x6 false | x3 ⇒ pair ?? x7 false + | x4 ⇒ pair ?? x8 false | x5 ⇒ pair ?? x9 false | x6 ⇒ pair ?? xA false | x7 ⇒ pair ?? xB false + | x8 ⇒ pair ?? xC false | x9 ⇒ pair ?? xD false | xA ⇒ pair ?? xE false | xB ⇒ pair ?? xF false + | xC ⇒ pair ?? x0 true | xD ⇒ pair ?? x1 true | xE ⇒ pair ?? x2 true | xF ⇒ pair ?? x3 true ] + | x4 ⇒ match e2 with + [ x0 ⇒ pair ?? x5 false | x1 ⇒ pair ?? x6 false | x2 ⇒ pair ?? x7 false | x3 ⇒ pair ?? x8 false + | x4 ⇒ pair ?? x9 false | x5 ⇒ pair ?? xA false | x6 ⇒ pair ?? xB false | x7 ⇒ pair ?? xC false + | x8 ⇒ pair ?? xD false | x9 ⇒ pair ?? xE false | xA ⇒ pair ?? xF false | xB ⇒ pair ?? x0 true + | xC ⇒ pair ?? x1 true | xD ⇒ pair ?? x2 true | xE ⇒ pair ?? x3 true | xF ⇒ pair ?? x4 true ] + | x5 ⇒ match e2 with + [ x0 ⇒ pair ?? x6 false | x1 ⇒ pair ?? x7 false | x2 ⇒ pair ?? x8 false | x3 ⇒ pair ?? x9 false + | x4 ⇒ pair ?? xA false | x5 ⇒ pair ?? xB false | x6 ⇒ pair ?? xC false | x7 ⇒ pair ?? xD false + | x8 ⇒ pair ?? xE false | x9 ⇒ pair ?? xF false | xA ⇒ pair ?? x0 true | xB ⇒ pair ?? x1 true + | xC ⇒ pair ?? x2 true | xD ⇒ pair ?? x3 true | xE ⇒ pair ?? x4 true | xF ⇒ pair ?? x5 true ] + | x6 ⇒ match e2 with + [ x0 ⇒ pair ?? x7 false | x1 ⇒ pair ?? x8 false | x2 ⇒ pair ?? x9 false | x3 ⇒ pair ?? xA false + | x4 ⇒ pair ?? xB false | x5 ⇒ pair ?? xC false | x6 ⇒ pair ?? xD false | x7 ⇒ pair ?? xE false + | x8 ⇒ pair ?? xF false | x9 ⇒ pair ?? x0 true | xA ⇒ pair ?? x1 true | xB ⇒ pair ?? x2 true + | xC ⇒ pair ?? x3 true | xD ⇒ pair ?? x4 true | xE ⇒ pair ?? x5 true | xF ⇒ pair ?? x6 true ] + | x7 ⇒ match e2 with + [ x0 ⇒ pair ?? x8 false | x1 ⇒ pair ?? x9 false | x2 ⇒ pair ?? xA false | x3 ⇒ pair ?? xB false + | x4 ⇒ pair ?? xC false | x5 ⇒ pair ?? xD false | x6 ⇒ pair ?? xE false | x7 ⇒ pair ?? xF false + | x8 ⇒ pair ?? x0 true | x9 ⇒ pair ?? x1 true | xA ⇒ pair ?? x2 true | xB ⇒ pair ?? x3 true + | xC ⇒ pair ?? x4 true | xD ⇒ pair ?? x5 true | xE ⇒ pair ?? x6 true | xF ⇒ pair ?? x7 true ] + | x8 ⇒ match e2 with + [ x0 ⇒ pair ?? x9 false | x1 ⇒ pair ?? xA false | x2 ⇒ pair ?? xB false | x3 ⇒ pair ?? xC false + | x4 ⇒ pair ?? xD false | x5 ⇒ pair ?? xE false | x6 ⇒ pair ?? xF false | x7 ⇒ pair ?? x0 true + | x8 ⇒ pair ?? x1 true | x9 ⇒ pair ?? x2 true | xA ⇒ pair ?? x3 true | xB ⇒ pair ?? x4 true + | xC ⇒ pair ?? x5 true | xD ⇒ pair ?? x6 true | xE ⇒ pair ?? x7 true | xF ⇒ pair ?? x8 true ] + | x9 ⇒ match e2 with + [ x0 ⇒ pair ?? xA false | x1 ⇒ pair ?? xB false | x2 ⇒ pair ?? xC false | x3 ⇒ pair ?? xD false + | x4 ⇒ pair ?? xE false | x5 ⇒ pair ?? xF false | x6 ⇒ pair ?? x0 true | x7 ⇒ pair ?? x1 true + | x8 ⇒ pair ?? x2 true | x9 ⇒ pair ?? x3 true | xA ⇒ pair ?? x4 true | xB ⇒ pair ?? x5 true + | xC ⇒ pair ?? x6 true | xD ⇒ pair ?? x7 true | xE ⇒ pair ?? x8 true | xF ⇒ pair ?? x9 true ] + | xA ⇒ match e2 with + [ x0 ⇒ pair ?? xB false | x1 ⇒ pair ?? xC false | x2 ⇒ pair ?? xD false | x3 ⇒ pair ?? xE false + | x4 ⇒ pair ?? xF false | x5 ⇒ pair ?? x0 true | x6 ⇒ pair ?? x1 true | x7 ⇒ pair ?? x2 true + | x8 ⇒ pair ?? x3 true | x9 ⇒ pair ?? x4 true | xA ⇒ pair ?? x5 true | xB ⇒ pair ?? x6 true + | xC ⇒ pair ?? x7 true | xD ⇒ pair ?? x8 true | xE ⇒ pair ?? x9 true | xF ⇒ pair ?? xA true ] + | xB ⇒ match e2 with + [ x0 ⇒ pair ?? xC false | x1 ⇒ pair ?? xD false | x2 ⇒ pair ?? xE false | x3 ⇒ pair ?? xF false + | x4 ⇒ pair ?? x0 true | x5 ⇒ pair ?? x1 true | x6 ⇒ pair ?? x2 true | x7 ⇒ pair ?? x3 true + | x8 ⇒ pair ?? x4 true | x9 ⇒ pair ?? x5 true | xA ⇒ pair ?? x6 true | xB ⇒ pair ?? x7 true + | xC ⇒ pair ?? x8 true | xD ⇒ pair ?? x9 true | xE ⇒ pair ?? xA true | xF ⇒ pair ?? xB true ] + | xC ⇒ match e2 with + [ x0 ⇒ pair ?? xD false | x1 ⇒ pair ?? xE false | x2 ⇒ pair ?? xF false | x3 ⇒ pair ?? x0 true + | x4 ⇒ pair ?? x1 true | x5 ⇒ pair ?? x2 true | x6 ⇒ pair ?? x3 true | x7 ⇒ pair ?? x4 true + | x8 ⇒ pair ?? x5 true | x9 ⇒ pair ?? x6 true | xA ⇒ pair ?? x7 true | xB ⇒ pair ?? x8 true + | xC ⇒ pair ?? x9 true | xD ⇒ pair ?? xA true | xE ⇒ pair ?? xB true | xF ⇒ pair ?? xC true ] + | xD ⇒ match e2 with + [ x0 ⇒ pair ?? xE false | x1 ⇒ pair ?? xF false | x2 ⇒ pair ?? x0 true | x3 ⇒ pair ?? x1 true + | x4 ⇒ pair ?? x2 true | x5 ⇒ pair ?? x3 true | x6 ⇒ pair ?? x4 true | x7 ⇒ pair ?? x5 true + | x8 ⇒ pair ?? x6 true | x9 ⇒ pair ?? x7 true | xA ⇒ pair ?? x8 true | xB ⇒ pair ?? x9 true + | xC ⇒ pair ?? xA true | xD ⇒ pair ?? xB true | xE ⇒ pair ?? xC true | xF ⇒ pair ?? xD true ] + | xE ⇒ match e2 with + [ x0 ⇒ pair ?? xF false | x1 ⇒ pair ?? x0 true | x2 ⇒ pair ?? x1 true | x3 ⇒ pair ?? x2 true + | x4 ⇒ pair ?? x3 true | x5 ⇒ pair ?? x4 true | x6 ⇒ pair ?? x5 true | x7 ⇒ pair ?? x6 true + | x8 ⇒ pair ?? x7 true | x9 ⇒ pair ?? x8 true | xA ⇒ pair ?? x9 true | xB ⇒ pair ?? xA true + | xC ⇒ pair ?? xB true | xD ⇒ pair ?? xC true | xE ⇒ pair ?? xD true | xF ⇒ pair ?? xE true ] + | xF ⇒ match e2 with + [ x0 ⇒ pair ?? x0 true | x1 ⇒ pair ?? x1 true | x2 ⇒ pair ?? x2 true | x3 ⇒ pair ?? x3 true + | x4 ⇒ pair ?? x4 true | x5 ⇒ pair ?? x5 true | x6 ⇒ pair ?? x6 true | x7 ⇒ pair ?? x7 true + | x8 ⇒ pair ?? x8 true | x9 ⇒ pair ?? x9 true | xA ⇒ pair ?? xA true | xB ⇒ pair ?? xB true + | xC ⇒ pair ?? xC true | xD ⇒ pair ?? xD true | xE ⇒ pair ?? xE true | xF ⇒ pair ?? xF true ] + ] + | false ⇒ match e1 with + [ x0 ⇒ match e2 with + [ x0 ⇒ pair ?? x0 false | x1 ⇒ pair ?? x1 false | x2 ⇒ pair ?? x2 false | x3 ⇒ pair ?? x3 false + | x4 ⇒ pair ?? x4 false | x5 ⇒ pair ?? x5 false | x6 ⇒ pair ?? x6 false | x7 ⇒ pair ?? x7 false + | x8 ⇒ pair ?? x8 false | x9 ⇒ pair ?? x9 false | xA ⇒ pair ?? xA false | xB ⇒ pair ?? xB false + | xC ⇒ pair ?? xC false | xD ⇒ pair ?? xD false | xE ⇒ pair ?? xE false | xF ⇒ pair ?? xF false ] + | x1 ⇒ match e2 with + [ x0 ⇒ pair ?? x1 false | x1 ⇒ pair ?? x2 false | x2 ⇒ pair ?? x3 false | x3 ⇒ pair ?? x4 false + | x4 ⇒ pair ?? x5 false | x5 ⇒ pair ?? x6 false | x6 ⇒ pair ?? x7 false | x7 ⇒ pair ?? x8 false + | x8 ⇒ pair ?? x9 false | x9 ⇒ pair ?? xA false | xA ⇒ pair ?? xB false | xB ⇒ pair ?? xC false + | xC ⇒ pair ?? xD false | xD ⇒ pair ?? xE false | xE ⇒ pair ?? xF false | xF ⇒ pair ?? x0 true ] + | x2 ⇒ match e2 with + [ x0 ⇒ pair ?? x2 false | x1 ⇒ pair ?? x3 false | x2 ⇒ pair ?? x4 false | x3 ⇒ pair ?? x5 false + | x4 ⇒ pair ?? x6 false | x5 ⇒ pair ?? x7 false | x6 ⇒ pair ?? x8 false | x7 ⇒ pair ?? x9 false + | x8 ⇒ pair ?? xA false | x9 ⇒ pair ?? xB false | xA ⇒ pair ?? xC false | xB ⇒ pair ?? xD false + | xC ⇒ pair ?? xE false | xD ⇒ pair ?? xF false | xE ⇒ pair ?? x0 true | xF ⇒ pair ?? x1 true ] + | x3 ⇒ match e2 with + [ x0 ⇒ pair ?? x3 false | x1 ⇒ pair ?? x4 false | x2 ⇒ pair ?? x5 false | x3 ⇒ pair ?? x6 false + | x4 ⇒ pair ?? x7 false | x5 ⇒ pair ?? x8 false | x6 ⇒ pair ?? x9 false | x7 ⇒ pair ?? xA false + | x8 ⇒ pair ?? xB false | x9 ⇒ pair ?? xC false | xA ⇒ pair ?? xD false | xB ⇒ pair ?? xE false + | xC ⇒ pair ?? xF false | xD ⇒ pair ?? x0 true | xE ⇒ pair ?? x1 true | xF ⇒ pair ?? x2 true ] + | x4 ⇒ match e2 with + [ x0 ⇒ pair ?? x4 false | x1 ⇒ pair ?? x5 false | x2 ⇒ pair ?? x6 false | x3 ⇒ pair ?? x7 false + | x4 ⇒ pair ?? x8 false | x5 ⇒ pair ?? x9 false | x6 ⇒ pair ?? xA false | x7 ⇒ pair ?? xB false + | x8 ⇒ pair ?? xC false | x9 ⇒ pair ?? xD false | xA ⇒ pair ?? xE false | xB ⇒ pair ?? xF false + | xC ⇒ pair ?? x0 true | xD ⇒ pair ?? x1 true | xE ⇒ pair ?? x2 true | xF ⇒ pair ?? x3 true ] + | x5 ⇒ match e2 with + [ x0 ⇒ pair ?? x5 false | x1 ⇒ pair ?? x6 false | x2 ⇒ pair ?? x7 false | x3 ⇒ pair ?? x8 false + | x4 ⇒ pair ?? x9 false | x5 ⇒ pair ?? xA false | x6 ⇒ pair ?? xB false | x7 ⇒ pair ?? xC false + | x8 ⇒ pair ?? xD false | x9 ⇒ pair ?? xE false | xA ⇒ pair ?? xF false | xB ⇒ pair ?? x0 true + | xC ⇒ pair ?? x1 true | xD ⇒ pair ?? x2 true | xE ⇒ pair ?? x3 true | xF ⇒ pair ?? x4 true ] + | x6 ⇒ match e2 with + [ x0 ⇒ pair ?? x6 false | x1 ⇒ pair ?? x7 false | x2 ⇒ pair ?? x8 false | x3 ⇒ pair ?? x9 false + | x4 ⇒ pair ?? xA false | x5 ⇒ pair ?? xB false | x6 ⇒ pair ?? xC false | x7 ⇒ pair ?? xD false + | x8 ⇒ pair ?? xE false | x9 ⇒ pair ?? xF false | xA ⇒ pair ?? x0 true | xB ⇒ pair ?? x1 true + | xC ⇒ pair ?? x2 true | xD ⇒ pair ?? x3 true | xE ⇒ pair ?? x4 true | xF ⇒ pair ?? x5 true ] + | x7 ⇒ match e2 with + [ x0 ⇒ pair ?? x7 false | x1 ⇒ pair ?? x8 false | x2 ⇒ pair ?? x9 false | x3 ⇒ pair ?? xA false + | x4 ⇒ pair ?? xB false | x5 ⇒ pair ?? xC false | x6 ⇒ pair ?? xD false | x7 ⇒ pair ?? xE false + | x8 ⇒ pair ?? xF false | x9 ⇒ pair ?? x0 true | xA ⇒ pair ?? x1 true | xB ⇒ pair ?? x2 true + | xC ⇒ pair ?? x3 true | xD ⇒ pair ?? x4 true | xE ⇒ pair ?? x5 true | xF ⇒ pair ?? x6 true ] + | x8 ⇒ match e2 with + [ x0 ⇒ pair ?? x8 false | x1 ⇒ pair ?? x9 false | x2 ⇒ pair ?? xA false | x3 ⇒ pair ?? xB false + | x4 ⇒ pair ?? xC false | x5 ⇒ pair ?? xD false | x6 ⇒ pair ?? xE false | x7 ⇒ pair ?? xF false + | x8 ⇒ pair ?? x0 true | x9 ⇒ pair ?? x1 true | xA ⇒ pair ?? x2 true | xB ⇒ pair ?? x3 true + | xC ⇒ pair ?? x4 true | xD ⇒ pair ?? x5 true | xE ⇒ pair ?? x6 true | xF ⇒ pair ?? x7 true ] + | x9 ⇒ match e2 with + [ x0 ⇒ pair ?? x9 false | x1 ⇒ pair ?? xA false | x2 ⇒ pair ?? xB false | x3 ⇒ pair ?? xC false + | x4 ⇒ pair ?? xD false | x5 ⇒ pair ?? xE false | x6 ⇒ pair ?? xF false | x7 ⇒ pair ?? x0 true + | x8 ⇒ pair ?? x1 true | x9 ⇒ pair ?? x2 true | xA ⇒ pair ?? x3 true | xB ⇒ pair ?? x4 true + | xC ⇒ pair ?? x5 true | xD ⇒ pair ?? x6 true | xE ⇒ pair ?? x7 true | xF ⇒ pair ?? x8 true ] + | xA ⇒ match e2 with + [ x0 ⇒ pair ?? xA false | x1 ⇒ pair ?? xB false | x2 ⇒ pair ?? xC false | x3 ⇒ pair ?? xD false + | x4 ⇒ pair ?? xE false | x5 ⇒ pair ?? xF false | x6 ⇒ pair ?? x0 true | x7 ⇒ pair ?? x1 true + | x8 ⇒ pair ?? x2 true | x9 ⇒ pair ?? x3 true | xA ⇒ pair ?? x4 true | xB ⇒ pair ?? x5 true + | xC ⇒ pair ?? x6 true | xD ⇒ pair ?? x7 true | xE ⇒ pair ?? x8 true | xF ⇒ pair ?? x9 true ] + | xB ⇒ match e2 with + [ x0 ⇒ pair ?? xB false | x1 ⇒ pair ?? xC false | x2 ⇒ pair ?? xD false | x3 ⇒ pair ?? xE false + | x4 ⇒ pair ?? xF false | x5 ⇒ pair ?? x0 true | x6 ⇒ pair ?? x1 true | x7 ⇒ pair ?? x2 true + | x8 ⇒ pair ?? x3 true | x9 ⇒ pair ?? x4 true | xA ⇒ pair ?? x5 true | xB ⇒ pair ?? x6 true + | xC ⇒ pair ?? x7 true | xD ⇒ pair ?? x8 true | xE ⇒ pair ?? x9 true | xF ⇒ pair ?? xA true ] + | xC ⇒ match e2 with + [ x0 ⇒ pair ?? xC false | x1 ⇒ pair ?? xD false | x2 ⇒ pair ?? xE false | x3 ⇒ pair ?? xF false + | x4 ⇒ pair ?? x0 true | x5 ⇒ pair ?? x1 true | x6 ⇒ pair ?? x2 true | x7 ⇒ pair ?? x3 true + | x8 ⇒ pair ?? x4 true | x9 ⇒ pair ?? x5 true | xA ⇒ pair ?? x6 true | xB ⇒ pair ?? x7 true + | xC ⇒ pair ?? x8 true | xD ⇒ pair ?? x9 true | xE ⇒ pair ?? xA true | xF ⇒ pair ?? xB true ] + | xD ⇒ match e2 with + [ x0 ⇒ pair ?? xD false | x1 ⇒ pair ?? xE false | x2 ⇒ pair ?? xF false | x3 ⇒ pair ?? x0 true + | x4 ⇒ pair ?? x1 true | x5 ⇒ pair ?? x2 true | x6 ⇒ pair ?? x3 true | x7 ⇒ pair ?? x4 true + | x8 ⇒ pair ?? x5 true | x9 ⇒ pair ?? x6 true | xA ⇒ pair ?? x7 true | xB ⇒ pair ?? x8 true + | xC ⇒ pair ?? x9 true | xD ⇒ pair ?? xA true | xE ⇒ pair ?? xB true | xF ⇒ pair ?? xC true ] + | xE ⇒ match e2 with + [ x0 ⇒ pair ?? xE false | x1 ⇒ pair ?? xF false | x2 ⇒ pair ?? x0 true | x3 ⇒ pair ?? x1 true + | x4 ⇒ pair ?? x2 true | x5 ⇒ pair ?? x3 true | x6 ⇒ pair ?? x4 true | x7 ⇒ pair ?? x5 true + | x8 ⇒ pair ?? x6 true | x9 ⇒ pair ?? x7 true | xA ⇒ pair ?? x8 true | xB ⇒ pair ?? x9 true + | xC ⇒ pair ?? xA true | xD ⇒ pair ?? xB true | xE ⇒ pair ?? xC true | xF ⇒ pair ?? xD true ] + | xF ⇒ match e2 with + [ x0 ⇒ pair ?? xF false | x1 ⇒ pair ?? x0 true | x2 ⇒ pair ?? x1 true | x3 ⇒ pair ?? x2 true + | x4 ⇒ pair ?? x3 true | x5 ⇒ pair ?? x4 true | x6 ⇒ pair ?? x5 true | x7 ⇒ pair ?? x6 true + | x8 ⇒ pair ?? x7 true | x9 ⇒ pair ?? x8 true | xA ⇒ pair ?? x9 true | xB ⇒ pair ?? xA true + | xC ⇒ pair ?? xB true | xD ⇒ pair ?? xC true | xE ⇒ pair ?? xD true | xF ⇒ pair ?? xE true ] + ]]. -(* operatore somma senza carry *) -ndefinition plus_exnc ≝ -λe1,e2:exadecim.fst ?? (plus_ex e1 e2 false). +(* operatore somma con data → data+carry *) +ndefinition plus_ex_d_dc ≝ +λe1,e2:exadecim. + match e1 with + [ x0 ⇒ match e2 with + [ x0 ⇒ pair ?? x0 false | x1 ⇒ pair ?? x1 false | x2 ⇒ pair ?? x2 false | x3 ⇒ pair ?? x3 false + | x4 ⇒ pair ?? x4 false | x5 ⇒ pair ?? x5 false | x6 ⇒ pair ?? x6 false | x7 ⇒ pair ?? x7 false + | x8 ⇒ pair ?? x8 false | x9 ⇒ pair ?? x9 false | xA ⇒ pair ?? xA false | xB ⇒ pair ?? xB false + | xC ⇒ pair ?? xC false | xD ⇒ pair ?? xD false | xE ⇒ pair ?? xE false | xF ⇒ pair ?? xF false ] + | x1 ⇒ match e2 with + [ x0 ⇒ pair ?? x1 false | x1 ⇒ pair ?? x2 false | x2 ⇒ pair ?? x3 false | x3 ⇒ pair ?? x4 false + | x4 ⇒ pair ?? x5 false | x5 ⇒ pair ?? x6 false | x6 ⇒ pair ?? x7 false | x7 ⇒ pair ?? x8 false + | x8 ⇒ pair ?? x9 false | x9 ⇒ pair ?? xA false | xA ⇒ pair ?? xB false | xB ⇒ pair ?? xC false + | xC ⇒ pair ?? xD false | xD ⇒ pair ?? xE false | xE ⇒ pair ?? xF false | xF ⇒ pair ?? x0 true ] + | x2 ⇒ match e2 with + [ x0 ⇒ pair ?? x2 false | x1 ⇒ pair ?? x3 false | x2 ⇒ pair ?? x4 false | x3 ⇒ pair ?? x5 false + | x4 ⇒ pair ?? x6 false | x5 ⇒ pair ?? x7 false | x6 ⇒ pair ?? x8 false | x7 ⇒ pair ?? x9 false + | x8 ⇒ pair ?? xA false | x9 ⇒ pair ?? xB false | xA ⇒ pair ?? xC false | xB ⇒ pair ?? xD false + | xC ⇒ pair ?? xE false | xD ⇒ pair ?? xF false | xE ⇒ pair ?? x0 true | xF ⇒ pair ?? x1 true ] + | x3 ⇒ match e2 with + [ x0 ⇒ pair ?? x3 false | x1 ⇒ pair ?? x4 false | x2 ⇒ pair ?? x5 false | x3 ⇒ pair ?? x6 false + | x4 ⇒ pair ?? x7 false | x5 ⇒ pair ?? x8 false | x6 ⇒ pair ?? x9 false | x7 ⇒ pair ?? xA false + | x8 ⇒ pair ?? xB false | x9 ⇒ pair ?? xC false | xA ⇒ pair ?? xD false | xB ⇒ pair ?? xE false + | xC ⇒ pair ?? xF false | xD ⇒ pair ?? x0 true | xE ⇒ pair ?? x1 true | xF ⇒ pair ?? x2 true ] + | x4 ⇒ match e2 with + [ x0 ⇒ pair ?? x4 false | x1 ⇒ pair ?? x5 false | x2 ⇒ pair ?? x6 false | x3 ⇒ pair ?? x7 false + | x4 ⇒ pair ?? x8 false | x5 ⇒ pair ?? x9 false | x6 ⇒ pair ?? xA false | x7 ⇒ pair ?? xB false + | x8 ⇒ pair ?? xC false | x9 ⇒ pair ?? xD false | xA ⇒ pair ?? xE false | xB ⇒ pair ?? xF false + | xC ⇒ pair ?? x0 true | xD ⇒ pair ?? x1 true | xE ⇒ pair ?? x2 true | xF ⇒ pair ?? x3 true ] + | x5 ⇒ match e2 with + [ x0 ⇒ pair ?? x5 false | x1 ⇒ pair ?? x6 false | x2 ⇒ pair ?? x7 false | x3 ⇒ pair ?? x8 false + | x4 ⇒ pair ?? x9 false | x5 ⇒ pair ?? xA false | x6 ⇒ pair ?? xB false | x7 ⇒ pair ?? xC false + | x8 ⇒ pair ?? xD false | x9 ⇒ pair ?? xE false | xA ⇒ pair ?? xF false | xB ⇒ pair ?? x0 true + | xC ⇒ pair ?? x1 true | xD ⇒ pair ?? x2 true | xE ⇒ pair ?? x3 true | xF ⇒ pair ?? x4 true ] + | x6 ⇒ match e2 with + [ x0 ⇒ pair ?? x6 false | x1 ⇒ pair ?? x7 false | x2 ⇒ pair ?? x8 false | x3 ⇒ pair ?? x9 false + | x4 ⇒ pair ?? xA false | x5 ⇒ pair ?? xB false | x6 ⇒ pair ?? xC false | x7 ⇒ pair ?? xD false + | x8 ⇒ pair ?? xE false | x9 ⇒ pair ?? xF false | xA ⇒ pair ?? x0 true | xB ⇒ pair ?? x1 true + | xC ⇒ pair ?? x2 true | xD ⇒ pair ?? x3 true | xE ⇒ pair ?? x4 true | xF ⇒ pair ?? x5 true ] + | x7 ⇒ match e2 with + [ x0 ⇒ pair ?? x7 false | x1 ⇒ pair ?? x8 false | x2 ⇒ pair ?? x9 false | x3 ⇒ pair ?? xA false + | x4 ⇒ pair ?? xB false | x5 ⇒ pair ?? xC false | x6 ⇒ pair ?? xD false | x7 ⇒ pair ?? xE false + | x8 ⇒ pair ?? xF false | x9 ⇒ pair ?? x0 true | xA ⇒ pair ?? x1 true | xB ⇒ pair ?? x2 true + | xC ⇒ pair ?? x3 true | xD ⇒ pair ?? x4 true | xE ⇒ pair ?? x5 true | xF ⇒ pair ?? x6 true ] + | x8 ⇒ match e2 with + [ x0 ⇒ pair ?? x8 false | x1 ⇒ pair ?? x9 false | x2 ⇒ pair ?? xA false | x3 ⇒ pair ?? xB false + | x4 ⇒ pair ?? xC false | x5 ⇒ pair ?? xD false | x6 ⇒ pair ?? xE false | x7 ⇒ pair ?? xF false + | x8 ⇒ pair ?? x0 true | x9 ⇒ pair ?? x1 true | xA ⇒ pair ?? x2 true | xB ⇒ pair ?? x3 true + | xC ⇒ pair ?? x4 true | xD ⇒ pair ?? x5 true | xE ⇒ pair ?? x6 true | xF ⇒ pair ?? x7 true ] + | x9 ⇒ match e2 with + [ x0 ⇒ pair ?? x9 false | x1 ⇒ pair ?? xA false | x2 ⇒ pair ?? xB false | x3 ⇒ pair ?? xC false + | x4 ⇒ pair ?? xD false | x5 ⇒ pair ?? xE false | x6 ⇒ pair ?? xF false | x7 ⇒ pair ?? x0 true + | x8 ⇒ pair ?? x1 true | x9 ⇒ pair ?? x2 true | xA ⇒ pair ?? x3 true | xB ⇒ pair ?? x4 true + | xC ⇒ pair ?? x5 true | xD ⇒ pair ?? x6 true | xE ⇒ pair ?? x7 true | xF ⇒ pair ?? x8 true ] + | xA ⇒ match e2 with + [ x0 ⇒ pair ?? xA false | x1 ⇒ pair ?? xB false | x2 ⇒ pair ?? xC false | x3 ⇒ pair ?? xD false + | x4 ⇒ pair ?? xE false | x5 ⇒ pair ?? xF false | x6 ⇒ pair ?? x0 true | x7 ⇒ pair ?? x1 true + | x8 ⇒ pair ?? x2 true | x9 ⇒ pair ?? x3 true | xA ⇒ pair ?? x4 true | xB ⇒ pair ?? x5 true + | xC ⇒ pair ?? x6 true | xD ⇒ pair ?? x7 true | xE ⇒ pair ?? x8 true | xF ⇒ pair ?? x9 true ] + | xB ⇒ match e2 with + [ x0 ⇒ pair ?? xB false | x1 ⇒ pair ?? xC false | x2 ⇒ pair ?? xD false | x3 ⇒ pair ?? xE false + | x4 ⇒ pair ?? xF false | x5 ⇒ pair ?? x0 true | x6 ⇒ pair ?? x1 true | x7 ⇒ pair ?? x2 true + | x8 ⇒ pair ?? x3 true | x9 ⇒ pair ?? x4 true | xA ⇒ pair ?? x5 true | xB ⇒ pair ?? x6 true + | xC ⇒ pair ?? x7 true | xD ⇒ pair ?? x8 true | xE ⇒ pair ?? x9 true | xF ⇒ pair ?? xA true ] + | xC ⇒ match e2 with + [ x0 ⇒ pair ?? xC false | x1 ⇒ pair ?? xD false | x2 ⇒ pair ?? xE false | x3 ⇒ pair ?? xF false + | x4 ⇒ pair ?? x0 true | x5 ⇒ pair ?? x1 true | x6 ⇒ pair ?? x2 true | x7 ⇒ pair ?? x3 true + | x8 ⇒ pair ?? x4 true | x9 ⇒ pair ?? x5 true | xA ⇒ pair ?? x6 true | xB ⇒ pair ?? x7 true + | xC ⇒ pair ?? x8 true | xD ⇒ pair ?? x9 true | xE ⇒ pair ?? xA true | xF ⇒ pair ?? xB true ] + | xD ⇒ match e2 with + [ x0 ⇒ pair ?? xD false | x1 ⇒ pair ?? xE false | x2 ⇒ pair ?? xF false | x3 ⇒ pair ?? x0 true + | x4 ⇒ pair ?? x1 true | x5 ⇒ pair ?? x2 true | x6 ⇒ pair ?? x3 true | x7 ⇒ pair ?? x4 true + | x8 ⇒ pair ?? x5 true | x9 ⇒ pair ?? x6 true | xA ⇒ pair ?? x7 true | xB ⇒ pair ?? x8 true + | xC ⇒ pair ?? x9 true | xD ⇒ pair ?? xA true | xE ⇒ pair ?? xB true | xF ⇒ pair ?? xC true ] + | xE ⇒ match e2 with + [ x0 ⇒ pair ?? xE false | x1 ⇒ pair ?? xF false | x2 ⇒ pair ?? x0 true | x3 ⇒ pair ?? x1 true + | x4 ⇒ pair ?? x2 true | x5 ⇒ pair ?? x3 true | x6 ⇒ pair ?? x4 true | x7 ⇒ pair ?? x5 true + | x8 ⇒ pair ?? x6 true | x9 ⇒ pair ?? x7 true | xA ⇒ pair ?? x8 true | xB ⇒ pair ?? x9 true + | xC ⇒ pair ?? xA true | xD ⇒ pair ?? xB true | xE ⇒ pair ?? xC true | xF ⇒ pair ?? xD true ] + | xF ⇒ match e2 with + [ x0 ⇒ pair ?? xF false | x1 ⇒ pair ?? x0 true | x2 ⇒ pair ?? x1 true | x3 ⇒ pair ?? x2 true + | x4 ⇒ pair ?? x3 true | x5 ⇒ pair ?? x4 true | x6 ⇒ pair ?? x5 true | x7 ⇒ pair ?? x6 true + | x8 ⇒ pair ?? x7 true | x9 ⇒ pair ?? x8 true | xA ⇒ pair ?? x9 true | xB ⇒ pair ?? xA true + | xC ⇒ pair ?? xB true | xD ⇒ pair ?? xC true | xE ⇒ pair ?? xD true | xF ⇒ pair ?? xE true ] + ]. + +(* operatore somma con data+carry → data *) +ndefinition plus_ex_dc_d ≝ +λe1,e2:exadecim.λc:bool. + match c with + [ true ⇒ match e1 with + [ x0 ⇒ match e2 with + [ x0 ⇒ x1 | x1 ⇒ x2 | x2 ⇒ x3 | x3 ⇒ x4 | x4 ⇒ x5 | x5 ⇒ x6 | x6 ⇒ x7 | x7 ⇒ x8 + | x8 ⇒ x9 | x9 ⇒ xA | xA ⇒ xB | xB ⇒ xC | xC ⇒ xD | xD ⇒ xE | xE ⇒ xF | xF ⇒ x0 ] + | x1 ⇒ match e2 with + [ x0 ⇒ x2 | x1 ⇒ x3 | x2 ⇒ x4 | x3 ⇒ x5 | x4 ⇒ x6 | x5 ⇒ x7 | x6 ⇒ x8 | x7 ⇒ x9 + | x8 ⇒ xA | x9 ⇒ xB | xA ⇒ xC | xB ⇒ xD | xC ⇒ xE | xD ⇒ xF | xE ⇒ x0 | xF ⇒ x1 ] + | x2 ⇒ match e2 with + [ x0 ⇒ x3 | x1 ⇒ x4 | x2 ⇒ x5 | x3 ⇒ x6 | x4 ⇒ x7 | x5 ⇒ x8 | x6 ⇒ x9 | x7 ⇒ xA + | x8 ⇒ xB | x9 ⇒ xC | xA ⇒ xD | xB ⇒ xE | xC ⇒ xF | xD ⇒ x0 | xE ⇒ x1 | xF ⇒ x2 ] + | x3 ⇒ match e2 with + [ x0 ⇒ x4 | x1 ⇒ x5 | x2 ⇒ x6 | x3 ⇒ x7 | x4 ⇒ x8 | x5 ⇒ x9 | x6 ⇒ xA | x7 ⇒ xB + | x8 ⇒ xC | x9 ⇒ xD | xA ⇒ xE | xB ⇒ xF | xC ⇒ x0 | xD ⇒ x1 | xE ⇒ x2 | xF ⇒ x3 ] + | x4 ⇒ match e2 with + [ x0 ⇒ x5 | x1 ⇒ x6 | x2 ⇒ x7 | x3 ⇒ x8 | x4 ⇒ x9 | x5 ⇒ xA | x6 ⇒ xB | x7 ⇒ xC + | x8 ⇒ xD | x9 ⇒ xE | xA ⇒ xF | xB ⇒ x0 | xC ⇒ x1 | xD ⇒ x2 | xE ⇒ x3 | xF ⇒ x4 ] + | x5 ⇒ match e2 with + [ x0 ⇒ x6 | x1 ⇒ x7 | x2 ⇒ x8 | x3 ⇒ x9 | x4 ⇒ xA | x5 ⇒ xB | x6 ⇒ xC | x7 ⇒ xD + | x8 ⇒ xE | x9 ⇒ xF | xA ⇒ x0 | xB ⇒ x1 | xC ⇒ x2 | xD ⇒ x3 | xE ⇒ x4 | xF ⇒ x5 ] + | x6 ⇒ match e2 with + [ x0 ⇒ x7 | x1 ⇒ x8 | x2 ⇒ x9 | x3 ⇒ xA | x4 ⇒ xB | x5 ⇒ xC | x6 ⇒ xD | x7 ⇒ xE + | x8 ⇒ xF | x9 ⇒ x0 | xA ⇒ x1 | xB ⇒ x2 | xC ⇒ x3 | xD ⇒ x4 | xE ⇒ x5 | xF ⇒ x6 ] + | x7 ⇒ match e2 with + [ x0 ⇒ x8 | x1 ⇒ x9 | x2 ⇒ xA | x3 ⇒ xB | x4 ⇒ xC | x5 ⇒ xD | x6 ⇒ xE | x7 ⇒ xF + | x8 ⇒ x0 | x9 ⇒ x1 | xA ⇒ x2 | xB ⇒ x3 | xC ⇒ x4 | xD ⇒ x5 | xE ⇒ x6 | xF ⇒ x7 ] + | x8 ⇒ match e2 with + [ x0 ⇒ x9 | x1 ⇒ xA | x2 ⇒ xB | x3 ⇒ xC | x4 ⇒ xD | x5 ⇒ xE | x6 ⇒ xF | x7 ⇒ x0 + | x8 ⇒ x1 | x9 ⇒ x2 | xA ⇒ x3 | xB ⇒ x4 | xC ⇒ x5 | xD ⇒ x6 | xE ⇒ x7 | xF ⇒ x8 ] + | x9 ⇒ match e2 with + [ x0 ⇒ xA | x1 ⇒ xB | x2 ⇒ xC | x3 ⇒ xD | x4 ⇒ xE | x5 ⇒ xF | x6 ⇒ x0 | x7 ⇒ x1 + | x8 ⇒ x2 | x9 ⇒ x3 | xA ⇒ x4 | xB ⇒ x5 | xC ⇒ x6 | xD ⇒ x7 | xE ⇒ x8 | xF ⇒ x9 ] + | xA ⇒ match e2 with + [ x0 ⇒ xB | x1 ⇒ xC | x2 ⇒ xD | x3 ⇒ xE | x4 ⇒ xF | x5 ⇒ x0 | x6 ⇒ x1 | x7 ⇒ x2 + | x8 ⇒ x3 | x9 ⇒ x4 | xA ⇒ x5 | xB ⇒ x6 | xC ⇒ x7 | xD ⇒ x8 | xE ⇒ x9 | xF ⇒ xA ] + | xB ⇒ match e2 with + [ x0 ⇒ xC | x1 ⇒ xD | x2 ⇒ xE | x3 ⇒ xF | x4 ⇒ x0 | x5 ⇒ x1 | x6 ⇒ x2 | x7 ⇒ x3 + | x8 ⇒ x4 | x9 ⇒ x5 | xA ⇒ x6 | xB ⇒ x7 | xC ⇒ x8 | xD ⇒ x9 | xE ⇒ xA | xF ⇒ xB ] + | xC ⇒ match e2 with + [ x0 ⇒ xD | x1 ⇒ xE | x2 ⇒ xF | x3 ⇒ x0 | x4 ⇒ x1 | x5 ⇒ x2 | x6 ⇒ x3 | x7 ⇒ x4 + | x8 ⇒ x5 | x9 ⇒ x6 | xA ⇒ x7 | xB ⇒ x8 | xC ⇒ x9 | xD ⇒ xA | xE ⇒ xB | xF ⇒ xC ] + | xD ⇒ match e2 with + [ x0 ⇒ xE | x1 ⇒ xF | x2 ⇒ x0 | x3 ⇒ x1 | x4 ⇒ x2 | x5 ⇒ x3 | x6 ⇒ x4 | x7 ⇒ x5 + | x8 ⇒ x6 | x9 ⇒ x7 | xA ⇒ x8 | xB ⇒ x9 | xC ⇒ xA | xD ⇒ xB | xE ⇒ xC | xF ⇒ xD ] + | xE ⇒ match e2 with + [ x0 ⇒ xF | x1 ⇒ x0 | x2 ⇒ x1 | x3 ⇒ x2 | x4 ⇒ x3 | x5 ⇒ x4 | x6 ⇒ x5 | x7 ⇒ x6 + | x8 ⇒ x7 | x9 ⇒ x8 | xA ⇒ x9 | xB ⇒ xA | xC ⇒ xB | xD ⇒ xC | xE ⇒ xD | xF ⇒ xE ] + | xF ⇒ match e2 with + [ x0 ⇒ x0 | x1 ⇒ x1 | x2 ⇒ x2 | x3 ⇒ x3 | x4 ⇒ x4 | x5 ⇒ x5 | x6 ⇒ x6 | x7 ⇒ x7 + | x8 ⇒ x8 | x9 ⇒ x9 | xA ⇒ xA | xB ⇒ xB | xC ⇒ xC | xD ⇒ xD | xE ⇒ xE | xF ⇒ xF ] + ] + | false ⇒ match e1 with + [ x0 ⇒ match e2 with + [ x0 ⇒ x0 | x1 ⇒ x1 | x2 ⇒ x2 | x3 ⇒ x3 | x4 ⇒ x4 | x5 ⇒ x5 | x6 ⇒ x6 | x7 ⇒ x7 + | x8 ⇒ x8 | x9 ⇒ x9 | xA ⇒ xA | xB ⇒ xB | xC ⇒ xC | xD ⇒ xD | xE ⇒ xE | xF ⇒ xF ] + | x1 ⇒ match e2 with + [ x0 ⇒ x1 | x1 ⇒ x2 | x2 ⇒ x3 | x3 ⇒ x4 | x4 ⇒ x5 | x5 ⇒ x6 | x6 ⇒ x7 | x7 ⇒ x8 + | x8 ⇒ x9 | x9 ⇒ xA | xA ⇒ xB | xB ⇒ xC | xC ⇒ xD | xD ⇒ xE | xE ⇒ xF | xF ⇒ x0 ] + | x2 ⇒ match e2 with + [ x0 ⇒ x2 | x1 ⇒ x3 | x2 ⇒ x4 | x3 ⇒ x5 | x4 ⇒ x6 | x5 ⇒ x7 | x6 ⇒ x8 | x7 ⇒ x9 + | x8 ⇒ xA | x9 ⇒ xB | xA ⇒ xC | xB ⇒ xD | xC ⇒ xE | xD ⇒ xF | xE ⇒ x0 | xF ⇒ x1 ] + | x3 ⇒ match e2 with + [ x0 ⇒ x3 | x1 ⇒ x4 | x2 ⇒ x5 | x3 ⇒ x6 | x4 ⇒ x7 | x5 ⇒ x8 | x6 ⇒ x9 | x7 ⇒ xA + | x8 ⇒ xB | x9 ⇒ xC | xA ⇒ xD | xB ⇒ xE | xC ⇒ xF | xD ⇒ x0 | xE ⇒ x1 | xF ⇒ x2 ] + | x4 ⇒ match e2 with + [ x0 ⇒ x4 | x1 ⇒ x5 | x2 ⇒ x6 | x3 ⇒ x7 | x4 ⇒ x8 | x5 ⇒ x9 | x6 ⇒ xA | x7 ⇒ xB + | x8 ⇒ xC | x9 ⇒ xD | xA ⇒ xE | xB ⇒ xF | xC ⇒ x0 | xD ⇒ x1 | xE ⇒ x2 | xF ⇒ x3 ] + | x5 ⇒ match e2 with + [ x0 ⇒ x5 | x1 ⇒ x6 | x2 ⇒ x7 | x3 ⇒ x8 | x4 ⇒ x9 | x5 ⇒ xA | x6 ⇒ xB | x7 ⇒ xC + | x8 ⇒ xD | x9 ⇒ xE | xA ⇒ xF | xB ⇒ x0 | xC ⇒ x1 | xD ⇒ x2 | xE ⇒ x3 | xF ⇒ x4 ] + | x6 ⇒ match e2 with + [ x0 ⇒ x6 | x1 ⇒ x7 | x2 ⇒ x8 | x3 ⇒ x9 | x4 ⇒ xA | x5 ⇒ xB | x6 ⇒ xC | x7 ⇒ xD + | x8 ⇒ xE | x9 ⇒ xF | xA ⇒ x0 | xB ⇒ x1 | xC ⇒ x2 | xD ⇒ x3 | xE ⇒ x4 | xF ⇒ x5 ] + | x7 ⇒ match e2 with + [ x0 ⇒ x7 | x1 ⇒ x8 | x2 ⇒ x9 | x3 ⇒ xA | x4 ⇒ xB | x5 ⇒ xC | x6 ⇒ xD | x7 ⇒ xE + | x8 ⇒ xF | x9 ⇒ x0 | xA ⇒ x1 | xB ⇒ x2 | xC ⇒ x3 | xD ⇒ x4 | xE ⇒ x5 | xF ⇒ x6 ] + | x8 ⇒ match e2 with + [ x0 ⇒ x8 | x1 ⇒ x9 | x2 ⇒ xA | x3 ⇒ xB | x4 ⇒ xC | x5 ⇒ xD | x6 ⇒ xE | x7 ⇒ xF + | x8 ⇒ x0 | x9 ⇒ x1 | xA ⇒ x2 | xB ⇒ x3 | xC ⇒ x4 | xD ⇒ x5 | xE ⇒ x6 | xF ⇒ x7 ] + | x9 ⇒ match e2 with + [ x0 ⇒ x9 | x1 ⇒ xA | x2 ⇒ xB | x3 ⇒ xC | x4 ⇒ xD | x5 ⇒ xE | x6 ⇒ xF | x7 ⇒ x0 + | x8 ⇒ x1 | x9 ⇒ x2 | xA ⇒ x3 | xB ⇒ x4 | xC ⇒ x5 | xD ⇒ x6 | xE ⇒ x7 | xF ⇒ x8 ] + | xA ⇒ match e2 with + [ x0 ⇒ xA | x1 ⇒ xB | x2 ⇒ xC | x3 ⇒ xD | x4 ⇒ xE | x5 ⇒ xF | x6 ⇒ x0 | x7 ⇒ x1 + | x8 ⇒ x2 | x9 ⇒ x3 | xA ⇒ x4 | xB ⇒ x5 | xC ⇒ x6 | xD ⇒ x7 | xE ⇒ x8 | xF ⇒ x9 ] + | xB ⇒ match e2 with + [ x0 ⇒ xB | x1 ⇒ xC | x2 ⇒ xD | x3 ⇒ xE | x4 ⇒ xF | x5 ⇒ x0 | x6 ⇒ x1 | x7 ⇒ x2 + | x8 ⇒ x3 | x9 ⇒ x4 | xA ⇒ x5 | xB ⇒ x6 | xC ⇒ x7 | xD ⇒ x8 | xE ⇒ x9 | xF ⇒ xA ] + | xC ⇒ match e2 with + [ x0 ⇒ xC | x1 ⇒ xD | x2 ⇒ xE | x3 ⇒ xF | x4 ⇒ x0 | x5 ⇒ x1 | x6 ⇒ x2 | x7 ⇒ x3 + | x8 ⇒ x4 | x9 ⇒ x5 | xA ⇒ x6 | xB ⇒ x7 | xC ⇒ x8 | xD ⇒ x9 | xE ⇒ xA | xF ⇒ xB ] + | xD ⇒ match e2 with + [ x0 ⇒ xD | x1 ⇒ xE | x2 ⇒ xF | x3 ⇒ x0 | x4 ⇒ x1 | x5 ⇒ x2 | x6 ⇒ x3 | x7 ⇒ x4 + | x8 ⇒ x5 | x9 ⇒ x6 | xA ⇒ x7 | xB ⇒ x8 | xC ⇒ x9 | xD ⇒ xA | xE ⇒ xB | xF ⇒ xC ] + | xE ⇒ match e2 with + [ x0 ⇒ xE | x1 ⇒ xF | x2 ⇒ x0 | x3 ⇒ x1 | x4 ⇒ x2 | x5 ⇒ x3 | x6 ⇒ x4 | x7 ⇒ x5 + | x8 ⇒ x6 | x9 ⇒ x7 | xA ⇒ x8 | xB ⇒ x9 | xC ⇒ xA | xD ⇒ xB | xE ⇒ xC | xF ⇒ xD ] + | xF ⇒ match e2 with + [ x0 ⇒ xF | x1 ⇒ x0 | x2 ⇒ x1 | x3 ⇒ x2 | x4 ⇒ x3 | x5 ⇒ x4 | x6 ⇒ x5 | x7 ⇒ x6 + | x8 ⇒ x7 | x9 ⇒ x8 | xA ⇒ x9 | xB ⇒ xA | xC ⇒ xB | xD ⇒ xC | xE ⇒ xD | xF ⇒ xE ] + ]]. + +(* operatore somma con data → data *) +ndefinition plus_ex_d_d ≝ +λe1,e2:exadecim. + match e1 with + [ x0 ⇒ match e2 with + [ x0 ⇒ x0 | x1 ⇒ x1 | x2 ⇒ x2 | x3 ⇒ x3 | x4 ⇒ x4 | x5 ⇒ x5 | x6 ⇒ x6 | x7 ⇒ x7 + | x8 ⇒ x8 | x9 ⇒ x9 | xA ⇒ xA | xB ⇒ xB | xC ⇒ xC | xD ⇒ xD | xE ⇒ xE | xF ⇒ xF ] + | x1 ⇒ match e2 with + [ x0 ⇒ x1 | x1 ⇒ x2 | x2 ⇒ x3 | x3 ⇒ x4 | x4 ⇒ x5 | x5 ⇒ x6 | x6 ⇒ x7 | x7 ⇒ x8 + | x8 ⇒ x9 | x9 ⇒ xA | xA ⇒ xB | xB ⇒ xC | xC ⇒ xD | xD ⇒ xE | xE ⇒ xF | xF ⇒ x0 ] + | x2 ⇒ match e2 with + [ x0 ⇒ x2 | x1 ⇒ x3 | x2 ⇒ x4 | x3 ⇒ x5 | x4 ⇒ x6 | x5 ⇒ x7 | x6 ⇒ x8 | x7 ⇒ x9 + | x8 ⇒ xA | x9 ⇒ xB | xA ⇒ xC | xB ⇒ xD | xC ⇒ xE | xD ⇒ xF | xE ⇒ x0 | xF ⇒ x1 ] + | x3 ⇒ match e2 with + [ x0 ⇒ x3 | x1 ⇒ x4 | x2 ⇒ x5 | x3 ⇒ x6 | x4 ⇒ x7 | x5 ⇒ x8 | x6 ⇒ x9 | x7 ⇒ xA + | x8 ⇒ xB | x9 ⇒ xC | xA ⇒ xD | xB ⇒ xE | xC ⇒ xF | xD ⇒ x0 | xE ⇒ x1 | xF ⇒ x2 ] + | x4 ⇒ match e2 with + [ x0 ⇒ x4 | x1 ⇒ x5 | x2 ⇒ x6 | x3 ⇒ x7 | x4 ⇒ x8 | x5 ⇒ x9 | x6 ⇒ xA | x7 ⇒ xB + | x8 ⇒ xC | x9 ⇒ xD | xA ⇒ xE | xB ⇒ xF | xC ⇒ x0 | xD ⇒ x1 | xE ⇒ x2 | xF ⇒ x3 ] + | x5 ⇒ match e2 with + [ x0 ⇒ x5 | x1 ⇒ x6 | x2 ⇒ x7 | x3 ⇒ x8 | x4 ⇒ x9 | x5 ⇒ xA | x6 ⇒ xB | x7 ⇒ xC + | x8 ⇒ xD | x9 ⇒ xE | xA ⇒ xF | xB ⇒ x0 | xC ⇒ x1 | xD ⇒ x2 | xE ⇒ x3 | xF ⇒ x4 ] + | x6 ⇒ match e2 with + [ x0 ⇒ x6 | x1 ⇒ x7 | x2 ⇒ x8 | x3 ⇒ x9 | x4 ⇒ xA | x5 ⇒ xB | x6 ⇒ xC | x7 ⇒ xD + | x8 ⇒ xE | x9 ⇒ xF | xA ⇒ x0 | xB ⇒ x1 | xC ⇒ x2 | xD ⇒ x3 | xE ⇒ x4 | xF ⇒ x5 ] + | x7 ⇒ match e2 with + [ x0 ⇒ x7 | x1 ⇒ x8 | x2 ⇒ x9 | x3 ⇒ xA | x4 ⇒ xB | x5 ⇒ xC | x6 ⇒ xD | x7 ⇒ xE + | x8 ⇒ xF | x9 ⇒ x0 | xA ⇒ x1 | xB ⇒ x2 | xC ⇒ x3 | xD ⇒ x4 | xE ⇒ x5 | xF ⇒ x6 ] + | x8 ⇒ match e2 with + [ x0 ⇒ x8 | x1 ⇒ x9 | x2 ⇒ xA | x3 ⇒ xB | x4 ⇒ xC | x5 ⇒ xD | x6 ⇒ xE | x7 ⇒ xF + | x8 ⇒ x0 | x9 ⇒ x1 | xA ⇒ x2 | xB ⇒ x3 | xC ⇒ x4 | xD ⇒ x5 | xE ⇒ x6 | xF ⇒ x7 ] + | x9 ⇒ match e2 with + [ x0 ⇒ x9 | x1 ⇒ xA | x2 ⇒ xB | x3 ⇒ xC | x4 ⇒ xD | x5 ⇒ xE | x6 ⇒ xF | x7 ⇒ x0 + | x8 ⇒ x1 | x9 ⇒ x2 | xA ⇒ x3 | xB ⇒ x4 | xC ⇒ x5 | xD ⇒ x6 | xE ⇒ x7 | xF ⇒ x8 ] + | xA ⇒ match e2 with + [ x0 ⇒ xA | x1 ⇒ xB | x2 ⇒ xC | x3 ⇒ xD | x4 ⇒ xE | x5 ⇒ xF | x6 ⇒ x0 | x7 ⇒ x1 + | x8 ⇒ x2 | x9 ⇒ x3 | xA ⇒ x4 | xB ⇒ x5 | xC ⇒ x6 | xD ⇒ x7 | xE ⇒ x8 | xF ⇒ x9 ] + | xB ⇒ match e2 with + [ x0 ⇒ xB | x1 ⇒ xC | x2 ⇒ xD | x3 ⇒ xE | x4 ⇒ xF | x5 ⇒ x0 | x6 ⇒ x1 | x7 ⇒ x2 + | x8 ⇒ x3 | x9 ⇒ x4 | xA ⇒ x5 | xB ⇒ x6 | xC ⇒ x7 | xD ⇒ x8 | xE ⇒ x9 | xF ⇒ xA ] + | xC ⇒ match e2 with + [ x0 ⇒ xC | x1 ⇒ xD | x2 ⇒ xE | x3 ⇒ xF | x4 ⇒ x0 | x5 ⇒ x1 | x6 ⇒ x2 | x7 ⇒ x3 + | x8 ⇒ x4 | x9 ⇒ x5 | xA ⇒ x6 | xB ⇒ x7 | xC ⇒ x8 | xD ⇒ x9 | xE ⇒ xA | xF ⇒ xB ] + | xD ⇒ match e2 with + [ x0 ⇒ xD | x1 ⇒ xE | x2 ⇒ xF | x3 ⇒ x0 | x4 ⇒ x1 | x5 ⇒ x2 | x6 ⇒ x3 | x7 ⇒ x4 + | x8 ⇒ x5 | x9 ⇒ x6 | xA ⇒ x7 | xB ⇒ x8 | xC ⇒ x9 | xD ⇒ xA | xE ⇒ xB | xF ⇒ xC ] + | xE ⇒ match e2 with + [ x0 ⇒ xE | x1 ⇒ xF | x2 ⇒ x0 | x3 ⇒ x1 | x4 ⇒ x2 | x5 ⇒ x3 | x6 ⇒ x4 | x7 ⇒ x5 + | x8 ⇒ x6 | x9 ⇒ x7 | xA ⇒ x8 | xB ⇒ x9 | xC ⇒ xA | xD ⇒ xB | xE ⇒ xC | xF ⇒ xD ] + | xF ⇒ match e2 with + [ x0 ⇒ xF | x1 ⇒ x0 | x2 ⇒ x1 | x3 ⇒ x2 | x4 ⇒ x3 | x5 ⇒ x4 | x6 ⇒ x5 | x7 ⇒ x6 + | x8 ⇒ x7 | x9 ⇒ x8 | xA ⇒ x9 | xB ⇒ xA | xC ⇒ xB | xD ⇒ xC | xE ⇒ xD | xF ⇒ xE ] + ]. + +(* operatore somma con data+carry → carry *) +ndefinition plus_ex_dc_c ≝ +λe1,e2:exadecim.λc:bool. + match c with + [ true ⇒ match e1 with + [ x0 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ false | xB ⇒ false | xC ⇒ false | xD ⇒ false | xE ⇒ false | xF ⇒ true ] + | x1 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ false | xB ⇒ false | xC ⇒ false | xD ⇒ false | xE ⇒ true | xF ⇒ true ] + | x2 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ false | xB ⇒ false | xC ⇒ false | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x3 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ false | xB ⇒ false | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x4 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ false | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x5 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x6 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x7 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x8 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x9 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xA ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ true | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xB ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ true | x5 ⇒ true | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xC ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ true | x4 ⇒ true | x5 ⇒ true | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xD ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ true | x3 ⇒ true | x4 ⇒ true | x5 ⇒ true | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xE ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ true | x2 ⇒ true | x3 ⇒ true | x4 ⇒ true | x5 ⇒ true | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xF ⇒ match e2 with + [ x0 ⇒ true | x1 ⇒ true | x2 ⇒ true | x3 ⇒ true | x4 ⇒ true | x5 ⇒ true | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + ] + | false ⇒ match e1 with + [ x0 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ false | xB ⇒ false | xC ⇒ false | xD ⇒ false | xE ⇒ false | xF ⇒ false ] + | x1 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ false | xB ⇒ false | xC ⇒ false | xD ⇒ false | xE ⇒ false | xF ⇒ true ] + | x2 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ false | xB ⇒ false | xC ⇒ false | xD ⇒ false | xE ⇒ true | xF ⇒ true ] + | x3 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ false | xB ⇒ false | xC ⇒ false | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x4 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ false | xB ⇒ false | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x5 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ false | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x6 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x7 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x8 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x9 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xA ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xB ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ true | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xC ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ true | x5 ⇒ true | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xD ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ true | x4 ⇒ true | x5 ⇒ true | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xE ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ true | x3 ⇒ true | x4 ⇒ true | x5 ⇒ true | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xF ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ true | x2 ⇒ true | x3 ⇒ true | x4 ⇒ true | x5 ⇒ true | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + ]]. -(* operatore carry della somma *) -ndefinition plus_exc ≝ -λe1,e2:exadecim.snd ?? (plus_ex e1 e2 false). +(* operatore somma con data → carry *) +ndefinition plus_ex_d_c ≝ +λe1,e2:exadecim. + match e1 with + [ x0 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ false | xB ⇒ false | xC ⇒ false | xD ⇒ false | xE ⇒ false | xF ⇒ false ] + | x1 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ false | xB ⇒ false | xC ⇒ false | xD ⇒ false | xE ⇒ false | xF ⇒ true ] + | x2 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ false | xB ⇒ false | xC ⇒ false | xD ⇒ false | xE ⇒ true | xF ⇒ true ] + | x3 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ false | xB ⇒ false | xC ⇒ false | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x4 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ false | xB ⇒ false | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x5 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ false | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x6 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ false | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x7 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ false | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x8 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ false + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | x9 ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ false | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xA ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ false | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xB ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ false | x5 ⇒ true | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xC ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ false | x4 ⇒ true | x5 ⇒ true | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xD ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ false | x3 ⇒ true | x4 ⇒ true | x5 ⇒ true | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xE ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ false | x2 ⇒ true | x3 ⇒ true | x4 ⇒ true | x5 ⇒ true | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + | xF ⇒ match e2 with + [ x0 ⇒ false | x1 ⇒ true | x2 ⇒ true | x3 ⇒ true | x4 ⇒ true | x5 ⇒ true | x6 ⇒ true | x7 ⇒ true + | x8 ⇒ true | x9 ⇒ true | xA ⇒ true | xB ⇒ true | xC ⇒ true | xD ⇒ true | xE ⇒ true | xF ⇒ true ] + ]. (* operatore Most Significant Bit *) ndefinition MSB_ex ≝ diff --git a/helm/software/matita/contribs/ng_assembly/freescale/exadecim_lemmas.ma b/helm/software/matita/contribs/ng_assembly/freescale/exadecim_lemmas.ma new file mode 100755 index 000000000..19f9dc960 --- /dev/null +++ b/helm/software/matita/contribs/ng_assembly/freescale/exadecim_lemmas.ma @@ -0,0 +1,404 @@ +(**************************************************************************) +(* ___ *) +(* ||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 *) +(* *) +(* Questo materiale fa parte della tesi: *) +(* "Formalizzazione Interattiva dei Microcontroller a 8bit FreeScale" *) +(* *) +(* data ultima modifica 15/11/2007 *) +(* ********************************************************************** *) + +include "freescale/bool_lemmas.ma". +include "freescale/exadecim.ma". + +(* *********** *) +(* ESADECIMALI *) +(* *********** *) + +ndefinition exadecim_destruct : + Πe1,e2:exadecim.ΠP:Prop.e1 = e2 → + match e1 with + [ x0 ⇒ match e2 with [ x0 ⇒ P → P | _ ⇒ P ] + | x1 ⇒ match e2 with [ x1 ⇒ P → P | _ ⇒ P ] + | x2 ⇒ match e2 with [ x2 ⇒ P → P | _ ⇒ P ] + | x3 ⇒ match e2 with [ x3 ⇒ P → P | _ ⇒ P ] + | x4 ⇒ match e2 with [ x4 ⇒ P → P | _ ⇒ P ] + | x5 ⇒ match e2 with [ x5 ⇒ P → P | _ ⇒ P ] + | x6 ⇒ match e2 with [ x6 ⇒ P → P | _ ⇒ P ] + | x7 ⇒ match e2 with [ x7 ⇒ P → P | _ ⇒ P ] + | x8 ⇒ match e2 with [ x8 ⇒ P → P | _ ⇒ P ] + | x9 ⇒ match e2 with [ x9 ⇒ P → P | _ ⇒ P ] + | xA ⇒ match e2 with [ xA ⇒ P → P | _ ⇒ P ] + | xB ⇒ match e2 with [ xB ⇒ P → P | _ ⇒ P ] + | xC ⇒ match e2 with [ xC ⇒ P → P | _ ⇒ P ] + | xD ⇒ match e2 with [ xD ⇒ P → P | _ ⇒ P ] + | xE ⇒ match e2 with [ xE ⇒ P → P | _ ⇒ P ] + | xF ⇒ match e2 with [ xF ⇒ P → P | _ ⇒ P ] + ]. + #e1; #e2; #P; + nelim e1; + ##[ ##1: nelim e2; nnormalize; #H; + ##[ ##1: napply (λx:P.x) + ##| ##*: napply (False_ind ??); + nchange with (match x0 with [ x0 ⇒ False | _ ⇒ True ]); + nrewrite > H; nnormalize; napply I + ##] + ##| ##2: nelim e2; nnormalize; #H; + ##[ ##2: napply (λx:P.x) + ##| ##*: napply (False_ind ??); + nchange with (match x1 with [ x1 ⇒ False | _ ⇒ True ]); + nrewrite > H; nnormalize; napply I + ##] + ##| ##3: nelim e2; nnormalize; #H; + ##[ ##3: napply (λx:P.x) + ##| ##*: napply (False_ind ??); + nchange with (match x2 with [ x2 ⇒ False | _ ⇒ True ]); + nrewrite > H; nnormalize; napply I + ##] + ##| ##4: nelim e2; nnormalize; #H; + ##[ ##4: napply (λx:P.x) + ##| ##*: napply (False_ind ??); + nchange with (match x3 with [ x3 ⇒ False | _ ⇒ True ]); + nrewrite > H; nnormalize; napply I + ##] + ##| ##5: nelim e2; nnormalize; #H; + ##[ ##5: napply (λx:P.x) + ##| ##*: napply (False_ind ??); + nchange with (match x4 with [ x4 ⇒ False | _ ⇒ True ]); + nrewrite > H; nnormalize; napply I + ##] + ##| ##6: nelim e2; nnormalize; #H; + ##[ ##6: napply (λx:P.x) + ##| ##*: napply (False_ind ??); + nchange with (match x5 with [ x5 ⇒ False | _ ⇒ True ]); + nrewrite > H; nnormalize; napply I + ##] + ##| ##7: nelim e2; nnormalize; #H; + ##[ ##7: napply (λx:P.x) + ##| ##*: napply (False_ind ??); + nchange with (match x6 with [ x6 ⇒ False | _ ⇒ True ]); + nrewrite > H; nnormalize; napply I + ##] + ##| ##8: nelim e2; nnormalize; #H; + ##[ ##8: napply (λx:P.x) + ##| ##*: napply (False_ind ??); + nchange with (match x7 with [ x7 ⇒ False | _ ⇒ True ]); + nrewrite > H; nnormalize; napply I + ##] + ##| ##9: nelim e2; nnormalize; #H; + ##[ ##9: napply (λx:P.x) + ##| ##*: napply (False_ind ??); + nchange with (match x8 with [ x8 ⇒ False | _ ⇒ True ]); + nrewrite > H; nnormalize; napply I + ##] + ##| ##10: nelim e2; nnormalize; #H; + ##[ ##10: napply (λx:P.x) + ##| ##*: napply (False_ind ??); + nchange with (match x9 with [ x9 ⇒ False | _ ⇒ True ]); + nrewrite > H; nnormalize; napply I + ##] + ##| ##11: nelim e2; nnormalize; #H; + ##[ ##11: napply (λx:P.x) + ##| ##*: napply (False_ind ??); + nchange with (match xA with [ xA ⇒ False | _ ⇒ True ]); + nrewrite > H; nnormalize; napply I + ##] + ##| ##12: nelim e2; nnormalize; #H; + ##[ ##12: napply (λx:P.x) + ##| ##*: napply (False_ind ??); + nchange with (match xB with [ xB ⇒ False | _ ⇒ True ]); + nrewrite > H; nnormalize; napply I + ##] + ##| ##13: nelim e2; nnormalize; #H; + ##[ ##13: napply (λx:P.x) + ##| ##*: napply (False_ind ??); + nchange with (match xC with [ xC ⇒ False | _ ⇒ True ]); + nrewrite > H; nnormalize; napply I + ##] + ##| ##14: nelim e2; nnormalize; #H; + ##[ ##14: napply (λx:P.x) + ##| ##*: napply (False_ind ??); + nchange with (match xD with [ xD ⇒ False | _ ⇒ True ]); + nrewrite > H; nnormalize; napply I + ##] + ##| ##15: nelim e2; nnormalize; #H; + ##[ ##15: napply (λx:P.x) + ##| ##*: napply (False_ind ??); + nchange with (match xE with [ xE ⇒ False | _ ⇒ True ]); + nrewrite > H; nnormalize; napply I + ##] + ##| ##16: nelim e2; nnormalize; #H; + ##[ ##16: napply (λx:P.x) + ##| ##*: napply (False_ind ??); + nchange with (match xF with [ xF ⇒ False | _ ⇒ True ]); + nrewrite > H; nnormalize; napply I + ##] + ##] +nqed. + +nlemma symmetric_eqex : symmetricT exadecim bool eq_ex. + #e1; #e2; + nelim e1; + nelim e2; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma symmetric_andex : symmetricT exadecim exadecim and_ex. + #e1; #e2; + nelim e1; + nelim e2; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma associative_andex : ∀e1,e2,e3.(and_ex (and_ex e1 e2) e3) = (and_ex e1 (and_ex e2 e3)). + #e1; #e2; #e3; + nelim e1; + ##[ ##1: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##2: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##3: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##4: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##5: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##6: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##7: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##8: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##9: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##10: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##11: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##12: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##13: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##14: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##15: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##16: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##] +nqed. + +nlemma symmetric_orex : symmetricT exadecim exadecim or_ex. + #e1; #e2; + nelim e1; + nelim e2; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma associative_orex : ∀e1,e2,e3.(or_ex (or_ex e1 e2) e3) = (or_ex e1 (or_ex e2 e3)). + #e1; #e2; #e3; + nelim e1; + ##[ ##1: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##2: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##3: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##4: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##5: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##6: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##7: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##8: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##9: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##10: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##11: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##12: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##13: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##14: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##15: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##16: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##] +nqed. + +nlemma symmetric_xorex : symmetricT exadecim exadecim xor_ex. + #e1; #e2; + nelim e1; + nelim e2; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma associative_xorex : ∀e1,e2,e3.(xor_ex (xor_ex e1 e2) e3) = (xor_ex e1 (xor_ex e2 e3)). + #e1; #e2; #e3; + nelim e1; + ##[ ##1: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##2: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##3: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##4: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##5: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##6: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##7: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##8: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##9: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##10: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##11: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##12: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##13: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##14: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##15: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##16: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##] +nqed. + +nlemma symmetric_plusex_dc_dc : ∀e1,e2,c.plus_ex_dc_dc e1 e2 c = plus_ex_dc_dc e2 e1 c. + #e1; #e2; #c; + nelim e1; + nelim e2; + nelim c; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma plusex_dc_dc_to_dc_d : ∀e1,e2,c.fst ?? (plus_ex_dc_dc e1 e2 c) = plus_ex_dc_d e1 e2 c. + #e1; #e2; #c; + nelim e1; + nelim e2; + nelim c; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma plusex_dc_dc_to_dc_c : ∀e1,e2,c.snd ?? (plus_ex_dc_dc e1 e2 c) = plus_ex_dc_c e1 e2 c. + #e1; #e2; #c; + nelim e1; + nelim e2; + nelim c; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma plusex_dc_dc_to_d_dc : ∀e1,e2.plus_ex_dc_dc e1 e2 false = plus_ex_d_dc e1 e2. + #e1; #e2; + nelim e1; + nelim e2; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma plusex_dc_dc_to_d_d : ∀e1,e2.fst ?? (plus_ex_dc_dc e1 e2 false) = plus_ex_d_d e1 e2. + #e1; #e2; + nelim e1; + nelim e2; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma plusex_dc_dc_to_d_c : ∀e1,e2.snd ?? (plus_ex_dc_dc e1 e2 false) = plus_ex_d_c e1 e2. + #e1; #e2; + nelim e1; + nelim e2; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusex_dc_d : ∀e1,e2,c.plus_ex_dc_d e1 e2 c = plus_ex_dc_d e2 e1 c. + #e1; #e2; #c; + nelim e1; + nelim e2; + nelim c; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusex_dc_c : ∀e1,e2,c.plus_ex_dc_c e1 e2 c = plus_ex_dc_c e2 e1 c. + #e1; #e2; #c; + nelim e1; + nelim e2; + nelim c; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusex_d_dc : ∀e1,e2.plus_ex_d_dc e1 e2 = plus_ex_d_dc e2 e1. + #e1; #e2; + nelim e1; + nelim e2; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma plusex_d_dc_to_d_d : ∀e1,e2.fst ?? (plus_ex_d_dc e1 e2) = plus_ex_d_d e1 e2. + #e1; #e2; + nelim e1; + nelim e2; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma plusex_d_dc_to_d_c : ∀e1,e2.snd ?? (plus_ex_d_dc e1 e2) = plus_ex_d_c e1 e2. + #e1; #e2; + nelim e1; + nelim e2; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusex_d_d : ∀e1,e2.plus_ex_d_d e1 e2 = plus_ex_d_d e2 e1. + #e1; #e2; + nelim e1; + nelim e2; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma associative_plusex_d_d : ∀e1,e2,e3.(plus_ex_d_d (plus_ex_d_d e1 e2) e3) = (plus_ex_d_d e1 (plus_ex_d_d e2 e3)). + #e1; #e2; #e3; + nelim e1; + ##[ ##1: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##2: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##3: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##4: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##5: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##6: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##7: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##8: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##9: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##10: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##11: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##12: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##13: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##14: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##15: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##| ##16: nelim e2; nelim e3; nnormalize; napply (refl_eq ??) + ##] +nqed. + +nlemma symmetric_plusex_d_c : ∀e1,e2.plus_ex_d_c e1 e2 = plus_ex_d_c e2 e1. + #e1; #e2; + nelim e1; + nelim e2; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma eqex_to_eq : ∀e1,e2:exadecim.(eq_ex e1 e2 = true) → (e1 = e2). + #e1; #e2; #H; + nletin K ≝ (bool_destruct ?? (e1 = e2) H); + nelim e1 in K:(%) ⊢ %; + nelim e2; + nnormalize; + ##[ ##1,18,35,52,69,86,103,120,137,154,171,188,205,222,239,256: #H; napply (refl_eq ??) + ##| ##*: #H; napply H + ##] +nqed. + +nlemma eq_to_eqex : ∀e1,e2.e1 = e2 → eq_ex e1 e2 = true. + #e1; #e2; #H; + nletin K ≝ (exadecim_destruct ?? (eq_ex e1 e2 = true) H); + nelim e1 in K:(%) ⊢ %; + nelim e2; + nnormalize; + ##[ ##1,18,35,52,69,86,103,120,137,154,171,188,205,222,239,256: #H; napply (refl_eq ??) + ##| ##*: #H; napply H + ##] +nqed. diff --git a/helm/software/matita/contribs/ng_assembly/freescale/nat_lemmas.ma b/helm/software/matita/contribs/ng_assembly/freescale/nat_lemmas.ma index fde0972e4..9e6b6e8a5 100644 --- a/helm/software/matita/contribs/ng_assembly/freescale/nat_lemmas.ma +++ b/helm/software/matita/contribs/ng_assembly/freescale/nat_lemmas.ma @@ -55,7 +55,7 @@ nlemma nat_destruct_S_0 : ∀n:nat.S n = O → False. napply I. nqed. -nlemma bsymmetric_eqnat : boolSymmetric nat eq_nat. +nlemma symmetric_eqnat : symmetricT nat bool eq_nat. nnormalize; #n1; nelim n1; @@ -73,7 +73,7 @@ nlemma bsymmetric_eqnat : boolSymmetric nat eq_nat. ##| ##2: #n4; napply (H n4) ##] ##] -nqed. +nqed. nlemma eq_to_eqnat : ∀n1,n2:nat.n1 = n2 → eq_nat n1 n2 = true. #n1; @@ -101,12 +101,12 @@ nlemma eqnat_to_eq : ∀n1,n2:nat.(eq_nat n1 n2 = true → n1 = n2). nelim n2; nnormalize; ##[ ##1: #H; napply (refl_eq ??) - ##| ##2: #n3; #H; #H1; nelim (bool_destruct_false_true H1) + ##| ##2: #n3; #H; #H1; napply (bool_destruct ?? (O = S n3) H1) ##] ##| ##2: #n2; #H; #n3; #H1; ncases n3 in H1:(%) ⊢ %; nnormalize; - ##[ ##1: #H1; nelim (bool_destruct_false_true H1) + ##[ ##1: #H1; napply (bool_destruct ?? (S n2 = O) H1) ##| ##2: #n4; #H1; nrewrite > (H n4 H1); napply (refl_eq ??) diff --git a/helm/software/matita/contribs/ng_assembly/freescale/option_lemmas.ma b/helm/software/matita/contribs/ng_assembly/freescale/option_lemmas.ma index 071d884f4..30df5ac07 100644 --- a/helm/software/matita/contribs/ng_assembly/freescale/option_lemmas.ma +++ b/helm/software/matita/contribs/ng_assembly/freescale/option_lemmas.ma @@ -57,7 +57,7 @@ nqed. nlemma bsymmetric_eqoption : ∀T:Type.∀o1,o2:option T.∀f:T → T → bool. - (boolSymmetric T f) → + (symmetricT T bool f) → (eq_option T o1 o2 f = eq_option T o2 o1 f). #T; #o1; #o2; #f; #H; ncases o1; @@ -95,7 +95,7 @@ nlemma eqoption_to_eq : ncases o1; ncases o2; ##[ ##1: nnormalize; #H1; napply (refl_eq ??) - ##| ##2,3: #H1; #H2; nnormalize in H2:(%); nelim (bool_destruct_false_true H2) + ##| ##2,3: #H1; #H2; nnormalize in H2:(%); napply (bool_destruct ??? H2) ##| ##4: #x1; #x2; #H1; nnormalize in H1:(%); nrewrite > (H ?? H1); diff --git a/helm/software/matita/contribs/ng_assembly/freescale/prod_lemmas.ma b/helm/software/matita/contribs/ng_assembly/freescale/prod_lemmas.ma index d95af89a6..96bc15172 100644 --- a/helm/software/matita/contribs/ng_assembly/freescale/prod_lemmas.ma +++ b/helm/software/matita/contribs/ng_assembly/freescale/prod_lemmas.ma @@ -54,8 +54,8 @@ nqed. nlemma bsymmetric_eqpair : ∀T1,T2:Type.∀p1,p2:ProdT T1 T2. ∀f1:T1 → T1 → bool.∀f2:T2 → T2 → bool. - (boolSymmetric T1 f1) → - (boolSymmetric T2 f2) → + (symmetricT T1 bool f1) → + (symmetricT T2 bool f2) → (eq_pair T1 T2 p1 p2 f1 f2 = eq_pair T1 T2 p2 p1 f1 f2). #T1; #T2; #p1; #p2; #f1; #f2; #H; #H1; ncases p1; @@ -102,7 +102,7 @@ nlemma eqpair_to_eq : ncases (f1 x1 x2) in H:(%) K:(%); nnormalize; #H3; - ##[ ##2: nelim (bool_destruct_false_true H3) ##] + ##[ ##2: napply (bool_destruct ??? H3) ##] #H4; nrewrite > (H4 (refl_eq ??)); nrewrite > (H2 y1 y2 H3); @@ -142,9 +142,9 @@ nqed. nlemma bsymmetric_eqtriple : ∀T1,T2,T3:Type.∀p1,p2:Prod3T T1 T2 T3. ∀f1:T1 → T1 → bool.∀f2:T2 → T2 → bool.∀f3:T3 → T3 → bool. - (boolSymmetric T1 f1) → - (boolSymmetric T2 f2) → - (boolSymmetric T3 f3) → + (symmetricT T1 bool f1) → + (symmetricT T2 bool f2) → + (symmetricT T3 bool f3) → (eq_triple T1 T2 T3 p1 p2 f1 f2 f3 = eq_triple T1 T2 T3 p2 p1 f1 f2 f3). #T1; #T2; #T3; #p1; #p2; #f1; #f2; #f3; #H; #H1; #H2; ncases p1; @@ -199,11 +199,11 @@ nlemma eqtriple_to_eq : nletin K ≝ (H1 x1 x2); ncases (f1 x1 x2) in H:(%) K:(%); nnormalize; - ##[ ##2: #H4; nelim (bool_destruct_false_true H4) ##] + ##[ ##2: #H4; napply (bool_destruct ??? H4) ##] nletin K1 ≝ (H2 y1 y2); ncases (f2 y1 y2) in K1:(%) ⊢ %; nnormalize; - ##[ ##2: #H4; #H5; nelim (bool_destruct_false_true H5) ##] + ##[ ##2: #H4; #H5; napply (bool_destruct ??? H5) ##] #H4; #H5; #H6; nrewrite > (H4 (refl_eq ??)); nrewrite > (H6 (refl_eq ??)); @@ -254,10 +254,10 @@ nqed. nlemma bsymmetric_eqquadruple : ∀T1,T2,T3,T4:Type.∀p1,p2:Prod4T T1 T2 T3 T4. ∀f1:T1 → T1 → bool.∀f2:T2 → T2 → bool.∀f3:T3 → T3 → bool.∀f4:T4 → T4 → bool. - (boolSymmetric T1 f1) → - (boolSymmetric T2 f2) → - (boolSymmetric T3 f3) → - (boolSymmetric T4 f4) → + (symmetricT T1 bool f1) → + (symmetricT T2 bool f2) → + (symmetricT T3 bool f3) → + (symmetricT T4 bool f4) → (eq_quadruple T1 T2 T3 T4 p1 p2 f1 f2 f3 f4 = eq_quadruple T1 T2 T3 T4 p2 p1 f1 f2 f3 f4). #T1; #T2; #T3; #T4; #p1; #p2; #f1; #f2; #f3; #f4; #H; #H1; #H2; #H3; ncases p1; @@ -321,15 +321,15 @@ nlemma eqquadruple_to_eq : nletin K ≝ (H1 x1 x2); ncases (f1 x1 x2) in H:(%) K:(%); nnormalize; - ##[ ##2: #H5; nelim (bool_destruct_false_true H5) ##] + ##[ ##2: #H5; napply (bool_destruct ??? H5) ##] nletin K1 ≝ (H2 y1 y2); ncases (f2 y1 y2) in K1:(%) ⊢ %; nnormalize; - ##[ ##2: #H5; #H6; nelim (bool_destruct_false_true H6) ##] + ##[ ##2: #H5; #H6; napply (bool_destruct ??? H6) ##] nletin K2 ≝ (H3 z1 z2); ncases (f3 z1 z2) in K2:(%) ⊢ %; nnormalize; - ##[ ##2: #H5; #H6; #H7; nelim (bool_destruct_false_true H7) ##] + ##[ ##2: #H5; #H6; #H7; napply (bool_destruct ??? H7) ##] #H5; #H6; #H7; #H8; nrewrite > (H5 (refl_eq ??)); nrewrite > (H6 (refl_eq ??)); @@ -391,11 +391,11 @@ nqed. nlemma bsymmetric_eqquintuple : ∀T1,T2,T3,T4,T5:Type.∀p1,p2:Prod5T T1 T2 T3 T4 T5. ∀f1:T1 → T1 → bool.∀f2:T2 → T2 → bool.∀f3:T3 → T3 → bool.∀f4:T4 → T4 → bool.∀f5:T5 → T5 → bool. - (boolSymmetric T1 f1) → - (boolSymmetric T2 f2) → - (boolSymmetric T3 f3) → - (boolSymmetric T4 f4) → - (boolSymmetric T5 f5) → + (symmetricT T1 bool f1) → + (symmetricT T2 bool f2) → + (symmetricT T3 bool f3) → + (symmetricT T4 bool f4) → + (symmetricT T5 bool f5) → (eq_quintuple T1 T2 T3 T4 T5 p1 p2 f1 f2 f3 f4 f5 = eq_quintuple T1 T2 T3 T4 T5 p2 p1 f1 f2 f3 f4 f5). #T1; #T2; #T3; #T4; #T5; #p1; #p2; #f1; #f2; #f3; #f4; #f5; #H; #H1; #H2; #H3; #H4; ncases p1; @@ -468,19 +468,19 @@ nlemma eqquintuple_to_eq : nletin K ≝ (H1 x1 x2); ncases (f1 x1 x2) in H:(%) K:(%); nnormalize; - ##[ ##2: #H6; nelim (bool_destruct_false_true H6) ##] + ##[ ##2: #H6; napply (bool_destruct ??? H6) ##] nletin K1 ≝ (H2 y1 y2); ncases (f2 y1 y2) in K1:(%) ⊢ %; nnormalize; - ##[ ##2: #H6; #H7; nelim (bool_destruct_false_true H7) ##] + ##[ ##2: #H6; #H7; napply (bool_destruct ??? H7) ##] nletin K2 ≝ (H3 z1 z2); ncases (f3 z1 z2) in K2:(%) ⊢ %; nnormalize; - ##[ ##2: #H6; #H7; #H8; nelim (bool_destruct_false_true H8) ##] + ##[ ##2: #H6; #H7; #H8; napply (bool_destruct ??? H8) ##] nletin K3 ≝ (H4 v1 v2); ncases (f4 v1 v2) in K3:(%) ⊢ %; nnormalize; - ##[ ##2: #H6; #H7; #H8; #H9; nelim (bool_destruct_false_true H9) ##] + ##[ ##2: #H6; #H7; #H8; #H9; napply (bool_destruct ??? H9) ##] #H6; #H7; #H8; #H9; #H10; nrewrite > (H6 (refl_eq ??)); nrewrite > (H7 (refl_eq ??)); diff --git a/helm/software/matita/contribs/ng_assembly/freescale/theory.ma b/helm/software/matita/contribs/ng_assembly/freescale/theory.ma index ceda6dcca..65800d2e5 100644 --- a/helm/software/matita/contribs/ng_assembly/freescale/theory.ma +++ b/helm/software/matita/contribs/ng_assembly/freescale/theory.ma @@ -64,14 +64,14 @@ ndefinition Not: Prop → Prop ≝ interpretation "logical not" 'not x = (Not x). -ntheorem absurd : ∀A,C:Prop.A → ¬A → C. +nlemma absurd : ∀A,C:Prop.A → ¬A → C. #A; #C; #H; nnormalize; #H1; nelim (H1 H). nqed. -ntheorem not_to_not : ∀A,B:Prop. (A → B) → ¬B →¬A. +nlemma not_to_not : ∀A,B:Prop. (A → B) → ¬B →¬A. #A; #B; #H; nnormalize; #H1; #H2; @@ -95,14 +95,14 @@ ndefinition And_rect : ΠA,B:Prop.ΠP:Type.(A → B → P) → And A B → P ≝ interpretation "logical and" 'and x y = (And x y). -ntheorem proj1: ∀A,B:Prop.A ∧ B → A. +nlemma proj1: ∀A,B:Prop.A ∧ B → A. #A; #B; #H; napply (And_ind A B ?? H); #H1; #H2; napply H1. nqed. -ntheorem proj2: ∀A,B:Prop.A ∧ B → B. +nlemma proj2: ∀A,B:Prop.A ∧ B → B. #A; #B; #H; napply (And_ind A B ?? H); #H1; #H2; @@ -183,7 +183,7 @@ interpretation "leibnitz's equality" 'eq t x y = (eq t x y). interpretation "leibnitz's non-equality" 'neq t x y = (Not (eq t x y)). -ntheorem symmetric_eq: ∀A:Type. symmetric A (eq A). +nlemma symmetric_eq: ∀A:Type. symmetric A (eq A). #A; nnormalize; #x; #y; #H; @@ -191,9 +191,15 @@ ntheorem symmetric_eq: ∀A:Type. symmetric A (eq A). napply (refl_eq ??). nqed. -ntheorem eq_elim_r: ∀A:Type.∀x:A.∀P:A → Prop.P x → ∀y:A.y=x → P y. +nlemma eq_elim_r: ∀A:Type.∀x:A.∀P:A → Prop.P x → ∀y:A.y=x → P y. #A; #x; #P; #H; #y; #H1; napply (eq_ind ? x ? H y ?); nrewrite < H1; napply (refl_eq ??). nqed. + +ndefinition relationT : Type → Type → Type ≝ +λA,T:Type.A → A → T. + +ndefinition symmetricT: ∀A,T:Type.∀R:relationT A T.Prop ≝ +λA,T.λR.∀x,y:A.R x y = R y x. diff --git a/helm/software/matita/contribs/ng_assembly/freescale/word16.ma b/helm/software/matita/contribs/ng_assembly/freescale/word16.ma new file mode 100755 index 000000000..a9bead0c4 --- /dev/null +++ b/helm/software/matita/contribs/ng_assembly/freescale/word16.ma @@ -0,0 +1,260 @@ +(**************************************************************************) +(* ___ *) +(* ||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 *) +(* *) +(* Questo materiale fa parte della tesi: *) +(* "Formalizzazione Interattiva dei Microcontroller a 8bit FreeScale" *) +(* *) +(* data ultima modifica 15/11/2007 *) +(* ********************************************************************** *) + +include "freescale/byte8.ma". + +(* **** *) +(* WORD *) +(* **** *) + +nrecord word16 : Type ≝ + { + w16h: byte8; + w16l: byte8 + }. + +ndefinition word16_ind : ΠP:word16 → Prop.(Πb:byte8.Πb1:byte8.P (mk_word16 b b1)) → Πw:word16.P w ≝ +λP:word16 → Prop.λf:Πb:byte8.Πb1:byte8.P (mk_word16 b b1).λw:word16. + match w with [ mk_word16 (b:byte8) (b1:byte8) ⇒ f b b1 ]. + +ndefinition word16_rec : ΠP:word16 → Set.(Πb:byte8.Πb1:byte8.P (mk_word16 b b1)) → Πw:word16.P w ≝ +λP:word16 → Set.λf:Πb:byte8.Πb1:byte8.P (mk_word16 b b1).λw:word16. + match w with [ mk_word16 (b:byte8) (b1:byte8) ⇒ f b b1 ]. + +ndefinition word16_rect : ΠP:word16 → Type.(Πb:byte8.Πb1:byte8.P (mk_word16 b b1)) → Πw:word16.P w ≝ +λP:word16 → Type.λf:Πb:byte8.Πb1:byte8.P (mk_word16 b b1).λw:word16. + match w with [ mk_word16 (b:byte8) (b1:byte8) ⇒ f b b1 ]. + +ndefinition w16h ≝ λw:word16.match w with [ mk_word16 x _ ⇒ x ]. +ndefinition w16l ≝ λw:word16.match w with [ mk_word16 _ x ⇒ x ]. + +(* \langle \rangle *) +notation "〈x:y〉" non associative with precedence 80 + for @{ 'mk_word16 $x $y }. +interpretation "mk_word16" 'mk_word16 x y = (mk_word16 x y). + +(* operatore = *) +ndefinition eq_w16 ≝ λw1,w2.(eq_b8 (w16h w1) (w16h w2)) ⊗ (eq_b8 (w16l w1) (w16l w2)). + +(* operatore < *) +ndefinition lt_w16 ≝ +λw1,w2:word16.match lt_b8 (w16h w1) (w16h w2) with + [ true ⇒ true + | false ⇒ match gt_b8 (w16h w1) (w16h w2) with + [ true ⇒ false + | false ⇒ lt_b8 (w16l w1) (w16l w2) ]]. + +(* operatore ≤ *) +ndefinition le_w16 ≝ λw1,w2:word16.(eq_w16 w1 w2) ⊕ (lt_w16 w1 w2). + +(* operatore > *) +ndefinition gt_w16 ≝ λw1,w2:word16.⊖ (le_w16 w1 w2). + +(* operatore ≥ *) +ndefinition ge_w16 ≝ λw1,w2:word16.⊖ (lt_w16 w1 w2). + +(* operatore and *) +ndefinition and_w16 ≝ +λw1,w2:word16.mk_word16 (and_b8 (w16h w1) (w16h w2)) (and_b8 (w16l w1) (w16l w2)). + +(* operatore or *) +ndefinition or_w16 ≝ +λw1,w2:word16.mk_word16 (or_b8 (w16h w1) (w16h w2)) (or_b8 (w16l w1) (w16l w2)). + +(* operatore xor *) +ndefinition xor_w16 ≝ +λw1,w2:word16.mk_word16 (xor_b8 (w16h w1) (w16h w2)) (xor_b8 (w16l w1) (w16l w2)). + +(* operatore rotazione destra con carry *) +ndefinition rcr_w16 ≝ +λw:word16.λc:bool.match rcr_b8 (w16h w) c with + [ pair wh' c' ⇒ match rcr_b8 (w16l w) c' with + [ pair wl' c'' ⇒ pair ?? (mk_word16 wh' wl') c'' ]]. + +(* operatore shift destro *) +ndefinition shr_w16 ≝ +λw:word16.match rcr_b8 (w16h w) false with + [ pair wh' c' ⇒ match rcr_b8 (w16l w) c' with + [ pair wl' c'' ⇒ pair ?? (mk_word16 wh' wl') c'' ]]. + +(* operatore rotazione destra *) +ndefinition ror_w16 ≝ +λw:word16.match rcr_b8 (w16h w) false with + [ pair wh' c' ⇒ match rcr_b8 (w16l w) c' with + [ pair wl' c'' ⇒ match c'' with + [ true ⇒ mk_word16 (or_b8 (mk_byte8 x8 x0) wh') wl' + | false ⇒ mk_word16 wh' wl' ]]]. + +(* operatore rotazione destra n-volte *) +nlet rec ror_w16_n (w:word16) (n:nat) on n ≝ + match n with + [ O ⇒ w + | S n' ⇒ ror_w16_n (ror_w16 w) n' ]. + +(* operatore rotazione sinistra con carry *) +ndefinition rcl_w16 ≝ +λw:word16.λc:bool.match rcl_b8 (w16l w) c with + [ pair wl' c' ⇒ match rcl_b8 (w16h w) c' with + [ pair wh' c'' ⇒ pair ?? (mk_word16 wh' wl') c'' ]]. + +(* operatore shift sinistro *) +ndefinition shl_w16 ≝ +λw:word16.match rcl_b8 (w16l w) false with + [ pair wl' c' ⇒ match rcl_b8 (w16h w) c' with + [ pair wh' c'' ⇒ pair ?? (mk_word16 wh' wl') c'' ]]. + +(* operatore rotazione sinistra *) +ndefinition rol_w16 ≝ +λw:word16.match rcl_b8 (w16l w) false with + [ pair wl' c' ⇒ match rcl_b8 (w16h w) c' with + [ pair wh' c'' ⇒ match c'' with + [ true ⇒ mk_word16 wh' (or_b8 (mk_byte8 x0 x1) wl') + | false ⇒ mk_word16 wh' wl' ]]]. + +(* operatore rotazione sinistra n-volte *) +nlet rec rol_w16_n (w:word16) (n:nat) on n ≝ + match n with + [ O ⇒ w + | S n' ⇒ rol_w16_n (rol_w16 w) n' ]. + +(* operatore not/complemento a 1 *) +ndefinition not_w16 ≝ +λw:word16.mk_word16 (not_b8 (w16h w)) (not_b8 (w16l w)). + +(* operatore somma con data+carry → data+carry *) +ndefinition plus_w16_dc_dc ≝ +λw1,w2:word16.λc:bool. + match plus_b8_dc_dc (w16l w1) (w16l w2) c with + [ pair l c ⇒ match plus_b8_dc_dc (w16h w1) (w16h w2) c with + [ pair h c' ⇒ pair ?? 〈h:l〉 c' ]]. + +(* operatore somma con data+carry → data *) +ndefinition plus_w16_dc_d ≝ +λw1,w2:word16.λc:bool. + match plus_b8_dc_dc (w16l w1) (w16l w2) c with + [ pair l c ⇒ 〈plus_b8_dc_d (w16h w1) (w16h w2) c:l〉 ]. + +(* operatore somma con data+carry → c *) +ndefinition plus_w16_dc_c ≝ +λw1,w2:word16.λc:bool. + plus_b8_dc_c (w16h w1) (w16h w2) (plus_b8_dc_c (w16l w1) (w16l w2) c). + +(* operatore somma con data → data+carry *) +ndefinition plus_w16_d_dc ≝ +λw1,w2:word16. + match plus_b8_d_dc (w16l w1) (w16l w2) with + [ pair l c ⇒ match plus_b8_dc_dc (w16h w1) (w16h w2) c with + [ pair h c' ⇒ pair ?? 〈h:l〉 c' ]]. + +(* operatore somma con data → data *) +ndefinition plus_w16_d_d ≝ +λw1,w2:word16. + match plus_b8_d_dc (w16l w1) (w16l w2) with + [ pair l c ⇒ 〈plus_b8_dc_d (w16h w1) (w16h w2) c:l〉 ]. + +(* operatore somma con data → c *) +ndefinition plus_w16_d_c ≝ +λw1,w2:word16. + plus_b8_dc_c (w16h w1) (w16h w2) (plus_b8_d_c (w16l w1) (w16l w2)). + +(* operatore Most Significant Bit *) +ndefinition MSB_w16 ≝ λw:word16.eq_ex x8 (and_ex x8 (b8h (w16h w))). + +(* word → naturali *) +ndefinition nat_of_word16 ≝ λw:word16. 256 * (nat_of_byte8 (w16h w)) + (nat_of_byte8 (w16l w)). + +(* operatore predecessore *) +ndefinition pred_w16 ≝ +λw:word16.match eq_b8 (w16l w) (mk_byte8 x0 x0) with + [ true ⇒ mk_word16 (pred_b8 (w16h w)) (pred_b8 (w16l w)) + | false ⇒ mk_word16 (w16h w) (pred_b8 (w16l w)) ]. + +(* operatore successore *) +ndefinition succ_w16 ≝ +λw:word16.match eq_b8 (w16l w) (mk_byte8 xF xF) with + [ true ⇒ mk_word16 (succ_b8 (w16h w)) (succ_b8 (w16l w)) + | false ⇒ mk_word16 (w16h w) (succ_b8 (w16l w)) ]. + +(* operatore neg/complemento a 2 *) +ndefinition compl_w16 ≝ +λw:word16.match MSB_w16 w with + [ true ⇒ succ_w16 (not_w16 w) + | false ⇒ not_w16 (pred_w16 w) ]. + +(* + operatore moltiplicazione senza segno: b*b=[0x0000,0xFE01] + ... in pratica (〈a,b〉*〈c,d〉) = (a*c)<<8+(a*d)<<4+(b*c)<<4+(b*d) +*) +ndefinition mul_b8 ≝ +λb1,b2:byte8.match b1 with +[ mk_byte8 b1h b1l ⇒ match b2 with +[ mk_byte8 b2h b2l ⇒ match mul_ex b1l b2l with +[ mk_byte8 t1_h t1_l ⇒ match mul_ex b1h b2l with +[ mk_byte8 t2_h t2_l ⇒ match mul_ex b2h b1l with +[ mk_byte8 t3_h t3_l ⇒ match mul_ex b1h b2h with +[ mk_byte8 t4_h t4_l ⇒ + plus_w16_d_d + (plus_w16_d_d + (plus_w16_d_d 〈〈x0,t3_h〉:〈t3_l,x0〉〉 〈〈x0,t2_h〉:〈t2_l,x0〉〉) 〈〈t4_h,t4_l〉:〈x0,x0〉〉)〈〈x0,x0〉:〈t1_h,t1_l〉〉 +]]]]]]. + +(* divisione senza segno (secondo la logica delle ALU): (quoziente resto) overflow *) +nlet rec div_b8_aux (divd:word16) (divs:word16) (molt:byte8) (q:byte8) (c:nat) on c ≝ + let w' ≝ plus_w16_d_d divd (compl_w16 divs) in + match c with + [ O ⇒ match le_w16 divs divd with + [ true ⇒ triple ??? (or_b8 molt q) (w16l w') (⊖ (eq_b8 (w16h w') 〈x0,x0〉)) + | false ⇒ triple ??? q (w16l divd) (⊖ (eq_b8 (w16h divd) 〈x0,x0〉)) ] + | S c' ⇒ match le_w16 divs divd with + [ true ⇒ div_b8_aux w' (ror_w16 divs) (ror_b8 molt) (or_b8 molt q) c' + | false ⇒ div_b8_aux divd (ror_w16 divs) (ror_b8 molt) q c' ]]. + +ndefinition div_b8 ≝ +λw:word16.λb:byte8.match eq_b8 b 〈x0,x0〉 with +(* + la combinazione n/0 e' illegale, segnala solo overflow senza dare risultato +*) + [ true ⇒ triple ??? 〈xF,xF〉 (w16l w) true + | false ⇒ match eq_w16 w 〈〈x0,x0〉:〈x0,x0〉〉 with +(* 0 diviso qualsiasi cosa diverso da 0 da' q=0 r=0 o=false *) + [ true ⇒ triple ??? 〈x0,x0〉 〈x0,x0〉 false +(* 1) e' una divisione sensata che produrra' overflow/risultato *) +(* 2) parametri: dividendo, divisore, moltiplicatore, quoziente, contatore *) +(* 3) ad ogni ciclo il divisore e il moltiplicatore vengono scalati di 1 a dx *) +(* 4) il moltiplicatore e' la quantita' aggiunta al quoziente se il divisore *) +(* puo' essere sottratto al dividendo *) + | false ⇒ div_b8_aux w (rol_w16_n 〈〈x0,x0〉:b〉 7) 〈x8,x0〉 〈x0,x0〉 7 ]]. + +(* operatore x in [inf,sup] *) +ndefinition in_range ≝ +λx,inf,sup:word16.(le_w16 inf sup) ⊗ (ge_w16 x inf) ⊗ (le_w16 x sup). + +(* iteratore sulle word *) +ndefinition forall_word16 ≝ + λP. + forall_byte8 (λbh. + forall_byte8 (λbl. + P (mk_word16 bh bl ))). diff --git a/helm/software/matita/contribs/ng_assembly/freescale/word16_lemmas.ma b/helm/software/matita/contribs/ng_assembly/freescale/word16_lemmas.ma new file mode 100755 index 000000000..bdf42ee94 --- /dev/null +++ b/helm/software/matita/contribs/ng_assembly/freescale/word16_lemmas.ma @@ -0,0 +1,331 @@ +(**************************************************************************) +(* ___ *) +(* ||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 *) +(* *) +(* Questo materiale fa parte della tesi: *) +(* "Formalizzazione Interattiva dei Microcontroller a 8bit FreeScale" *) +(* *) +(* data ultima modifica 15/11/2007 *) +(* ********************************************************************** *) + +include "freescale/byte8_lemmas.ma". +include "freescale/word16.ma". + +(* **** *) +(* WORD *) +(* **** *) + +nlemma word16_destruct_1 : +∀x1,x2,y1,y2. + mk_word16 x1 y1 = mk_word16 x2 y2 → x1 = x2. + #x1; #x2; #y1; #y2; #H; + nchange with (match mk_word16 x2 y2 with [ mk_word16 a _ ⇒ x1 = a ]); + nrewrite < H; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma word16_destruct_2 : +∀x1,x2,y1,y2. + mk_word16 x1 y1 = mk_word16 x2 y2 → y1 = y2. + #x1; #x2; #y1; #y2; #H; + nchange with (match mk_word16 x2 y2 with [ mk_word16 _ b ⇒ y1 = b ]); + nrewrite < H; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma symmetric_eqw16 : symmetricT word16 bool eq_w16. + #w1; #w2; + nelim w1; + nelim w2; + #b1; #b2; #b3; #b4; + nchange with (((eq_b8 b3 b1)⊗(eq_b8 b4 b2)) = ((eq_b8 b1 b3)⊗(eq_b8 b2 b4))); + nrewrite > (symmetric_eqb8 b1 b3); + nrewrite > (symmetric_eqb8 b2 b4); + napply (refl_eq ??). +nqed. + +nlemma symmetric_andw16 : symmetricT word16 word16 and_w16. + #w1; #w2; + nelim w1; + nelim w2; + #b1; #b2; #b3; #b4; + nchange with ((mk_word16 (and_b8 b3 b1) (and_b8 b4 b2)) = (mk_word16 (and_b8 b1 b3) (and_b8 b2 b4))); + nrewrite > (symmetric_andb8 b1 b3); + nrewrite > (symmetric_andb8 b2 b4); + napply (refl_eq ??). +nqed. + +nlemma associative_andw16 : ∀w1,w2,w3.(and_w16 (and_w16 w1 w2) w3) = (and_w16 w1 (and_w16 w2 w3)). + #w1; #w2; #w3; + nelim w1; + #b1; #b2; + nelim w2; + #b3; #b4; + nelim w3; + #b5; #b6; + nchange with (mk_word16 (and_b8 (and_b8 b1 b3) b5) (and_b8 (and_b8 b2 b4) b6) = + mk_word16 (and_b8 b1 (and_b8 b3 b5)) (and_b8 b2 (and_b8 b4 b6))); + nrewrite < (associative_andb8 b1 b3 b5); + nrewrite < (associative_andb8 b2 b4 b6); + napply (refl_eq ??). +nqed. + +nlemma symmetric_orw16 : symmetricT word16 word16 or_w16. + #w1; #w2; + nelim w1; + nelim w2; + #b1; #b2; #b3; #b4; + nchange with ((mk_word16 (or_b8 b3 b1) (or_b8 b4 b2)) = (mk_word16 (or_b8 b1 b3) (or_b8 b2 b4))); + nrewrite > (symmetric_orb8 b1 b3); + nrewrite > (symmetric_orb8 b2 b4); + napply (refl_eq ??). +nqed. + +nlemma associative_orw16 : ∀w1,w2,w3.(or_w16 (or_w16 w1 w2) w3) = (or_w16 w1 (or_w16 w2 w3)). + #w1; #w2; #w3; + nelim w1; + #b1; #b2; + nelim w2; + #b3; #b4; + nelim w3; + #b5; #b6; + nchange with (mk_word16 (or_b8 (or_b8 b1 b3) b5) (or_b8 (or_b8 b2 b4) b6) = + mk_word16 (or_b8 b1 (or_b8 b3 b5)) (or_b8 b2 (or_b8 b4 b6))); + nrewrite < (associative_orb8 b1 b3 b5); + nrewrite < (associative_orb8 b2 b4 b6); + napply (refl_eq ??). +nqed. + +nlemma symmetric_xorw16 : symmetricT word16 word16 xor_w16. + #w1; #w2; + nelim w1; + nelim w2; + #b1; #b2; #b3; #b4; + nchange with ((mk_word16 (xor_b8 b3 b1) (xor_b8 b4 b2)) = (mk_word16 (xor_b8 b1 b3) (xor_b8 b2 b4))); + nrewrite > (symmetric_xorb8 b1 b3); + nrewrite > (symmetric_xorb8 b2 b4); + napply (refl_eq ??). +nqed. + +nlemma associative_xorw16 : ∀w1,w2,w3.(xor_w16 (xor_w16 w1 w2) w3) = (xor_w16 w1 (xor_w16 w2 w3)). + #w1; #w2; #w3; + nelim w1; + #b1; #b2; + nelim w2; + #b3; #b4; + nelim w3; + #b5; #b6; + nchange with (mk_word16 (xor_b8 (xor_b8 b1 b3) b5) (xor_b8 (xor_b8 b2 b4) b6) = + mk_word16 (xor_b8 b1 (xor_b8 b3 b5)) (xor_b8 b2 (xor_b8 b4 b6))); + nrewrite < (associative_xorb8 b1 b3 b5); + nrewrite < (associative_xorb8 b2 b4 b6); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusw16_dc_dc : ∀w1,w2,c.plus_w16_dc_dc w1 w2 c = plus_w16_dc_dc w2 w1 c. + #w1; #w2; #c; + nelim w1; + #b1; #b2; + nelim w2; + #b3; #b4; + nchange with ( + match plus_b8_dc_dc b2 b4 c with + [ pair l c ⇒ match plus_b8_dc_dc b1 b3 c with + [ pair h c' ⇒ pair ?? 〈h:l〉 c' ]] = + match plus_b8_dc_dc b4 b2 c with + [ pair l c ⇒ match plus_b8_dc_dc b3 b1 c with + [ pair h c' ⇒ pair ?? 〈h:l〉 c' ]]); + nrewrite > (symmetric_plusb8_dc_dc b4 b2 c); + ncases (plus_b8_dc_dc b2 b4 c); + #b5; #c1; + nchange with ( + match plus_b8_dc_dc b1 b3 c1 with + [ pair h c' ⇒ pair ?? 〈h:b5〉 c' ] = + match plus_b8_dc_dc b3 b1 c1 with + [ pair h c' ⇒ pair ?? 〈h:b5〉 c' ]); + nrewrite > (symmetric_plusb8_dc_dc b1 b3 c1); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusw16_dc_d : ∀w1,w2,c.plus_w16_dc_d w1 w2 c = plus_w16_dc_d w2 w1 c. + #w1; #w2; #c; + nelim w1; + #b1; #b2; + nelim w2; + #b3; #b4; + nchange with ( + match plus_b8_dc_dc b2 b4 c with + [ pair l c ⇒ 〈plus_b8_dc_d b1 b3 c:l〉 ] = + match plus_b8_dc_dc b4 b2 c with + [ pair l c ⇒ 〈plus_b8_dc_d b3 b1 c:l〉 ]); + nrewrite > (symmetric_plusb8_dc_dc b4 b2 c); + ncases (plus_b8_dc_dc b2 b4 c); + #b5; #c1; + nchange with (〈plus_b8_dc_d b1 b3 c1:b5〉 = 〈plus_b8_dc_d b3 b1 c1:b5〉); + nrewrite > (symmetric_plusb8_dc_d b1 b3 c1); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusw16_dc_c : ∀w1,w2,c.plus_w16_dc_c w1 w2 c = plus_w16_dc_c w2 w1 c. + #w1; #w2; #c; + nelim w1; + #b1; #b2; + nelim w2; + #b3; #b4; + nchange with ( + plus_b8_dc_c b1 b3 (plus_b8_dc_c b2 b4 c) = + plus_b8_dc_c b3 b1 (plus_b8_dc_c b4 b2 c)); + nrewrite > (symmetric_plusb8_dc_c b4 b2 c); + nrewrite > (symmetric_plusb8_dc_c b3 b1 (plus_b8_dc_c b2 b4 c)); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusw16_d_dc : ∀w1,w2.plus_w16_d_dc w1 w2 = plus_w16_d_dc w2 w1. + #w1; #w2; + nelim w1; + #b1; #b2; + nelim w2; + #b3; #b4; + nchange with ( + match plus_b8_d_dc b2 b4 with + [ pair l c ⇒ match plus_b8_dc_dc b1 b3 c with + [ pair h c' ⇒ pair ?? 〈h:l〉 c' ]] = + match plus_b8_d_dc b4 b2 with + [ pair l c ⇒ match plus_b8_dc_dc b3 b1 c with + [ pair h c' ⇒ pair ?? 〈h:l〉 c' ]]); + nrewrite > (symmetric_plusb8_d_dc b4 b2); + ncases (plus_b8_d_dc b2 b4); + #b5; #c; + nchange with ( + match plus_b8_dc_dc b1 b3 c with + [ pair h c' ⇒ pair ?? 〈h:b5〉 c' ] = + match plus_b8_dc_dc b3 b1 c with + [ pair h c' ⇒ pair ?? 〈h:b5〉 c' ]); + nrewrite > (symmetric_plusb8_dc_dc b1 b3 c); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusw16_d_d : ∀w1,w2.plus_w16_d_d w1 w2 = plus_w16_d_d w2 w1. + #w1; #w2; + nelim w1; + #b1; #b2; + nelim w2; + #b3; #b4; + nchange with ( + match plus_b8_d_dc b2 b4 with + [ pair l c ⇒ 〈plus_b8_dc_d b1 b3 c:l〉 ] = + match plus_b8_d_dc b4 b2 with + [ pair l c ⇒ 〈plus_b8_dc_d b3 b1 c:l〉 ]); + nrewrite > (symmetric_plusb8_d_dc b4 b2); + ncases (plus_b8_d_dc b2 b4); + #b5; #c; + nchange with (〈plus_b8_dc_d b1 b3 c:b5〉 = 〈plus_b8_dc_d b3 b1 c:b5〉); + nrewrite > (symmetric_plusb8_dc_d b1 b3 c); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusw16_d_c : ∀w1,w2.plus_w16_d_c w1 w2 = plus_w16_d_c w2 w1. + #w1; #w2; + nelim w1; + #b1; #b2; + nelim w2; + #b3; #b4; + nchange with ( + plus_b8_dc_c b1 b3 (plus_b8_d_c b2 b4) = + plus_b8_dc_c b3 b1 (plus_b8_d_c b4 b2)); + nrewrite > (symmetric_plusb8_d_c b4 b2); + nrewrite > (symmetric_plusb8_dc_c b3 b1 (plus_b8_d_c b2 b4)); + napply (refl_eq ??). +nqed. + +nlemma symmetric_mulb8 : symmetricT byte8 word16 mul_b8. + #b1; #b2; + nelim b1; + #e1; #e2; + nelim b2; + #e3; #e4; + nchange with (match mul_ex e2 e4 with + [ mk_byte8 t1_h t1_l ⇒ match mul_ex e1 e4 with + [ mk_byte8 t2_h t2_l ⇒ match mul_ex e3 e2 with + [ mk_byte8 t3_h t3_l ⇒ match mul_ex e1 e3 with + [ mk_byte8 t4_h t4_l ⇒ plus_w16_d_d (plus_w16_d_d (plus_w16_d_d 〈〈x0,t3_h〉:〈t3_l,x0〉〉 〈〈x0,t2_h〉:〈t2_l,x0〉〉) 〈〈t4_h,t4_l〉:〈x0,x0〉〉)〈〈x0,x0〉:〈t1_h,t1_l〉〉 + ]]]] = match mul_ex e4 e2 with + [ mk_byte8 t1_h t1_l ⇒ match mul_ex e3 e2 with + [ mk_byte8 t2_h t2_l ⇒ match mul_ex e1 e4 with + [ mk_byte8 t3_h t3_l ⇒ match mul_ex e3 e1 with + [ mk_byte8 t4_h t4_l ⇒ plus_w16_d_d (plus_w16_d_d (plus_w16_d_d 〈〈x0,t3_h〉:〈t3_l,x0〉〉 〈〈x0,t2_h〉:〈t2_l,x0〉〉) 〈〈t4_h,t4_l〉:〈x0,x0〉〉)〈〈x0,x0〉:〈t1_h,t1_l〉〉 + ]]]]); + nrewrite < (symmetric_mulex e2 e4); + ncases (mul_ex e2 e4); + #e5; #e6; + nchange with (match mul_ex e1 e4 with + [ mk_byte8 t2_h t2_l ⇒ match mul_ex e3 e2 with + [ mk_byte8 t3_h t3_l ⇒ match mul_ex e1 e3 with + [ mk_byte8 t4_h t4_l ⇒ plus_w16_d_d (plus_w16_d_d (plus_w16_d_d 〈〈x0,t3_h〉:〈t3_l,x0〉〉 〈〈x0,t2_h〉:〈t2_l,x0〉〉) 〈〈t4_h,t4_l〉:〈x0,x0〉〉)〈〈x0,x0〉:〈e5,e6〉〉 + ]]] = match mul_ex e3 e2 with + [ mk_byte8 t2_h t2_l ⇒ match mul_ex e1 e4 with + [ mk_byte8 t3_h t3_l ⇒ match mul_ex e3 e1 with + [ mk_byte8 t4_h t4_l ⇒ plus_w16_d_d (plus_w16_d_d (plus_w16_d_d 〈〈x0,t3_h〉:〈t3_l,x0〉〉 〈〈x0,t2_h〉:〈t2_l,x0〉〉) 〈〈t4_h,t4_l〉:〈x0,x0〉〉)〈〈x0,x0〉:〈e5,e6〉〉 + ]]]); + ncases (mul_ex e3 e2); + #e7; #e8; + ncases (mul_ex e1 e4); + #e9; #e10; + nchange with (match mul_ex e1 e3 with + [ mk_byte8 t4_h t4_l ⇒ plus_w16_d_d (plus_w16_d_d (plus_w16_d_d 〈〈x0,e7〉:〈e8,x0〉〉 〈〈x0,e9〉:〈e10,x0〉〉) 〈〈t4_h,t4_l〉:〈x0,x0〉〉)〈〈x0,x0〉:〈e5,e6〉〉 + ] = match mul_ex e3 e1 with + [ mk_byte8 t4_h t4_l ⇒ plus_w16_d_d (plus_w16_d_d (plus_w16_d_d 〈〈x0,e9〉:〈e10,x0〉〉 〈〈x0,e7〉:〈e8,x0〉〉) 〈〈t4_h,t4_l〉:〈x0,x0〉〉)〈〈x0,x0〉:〈e5,e6〉〉 + ]); + nrewrite < (symmetric_mulex e1 e3); + ncases (mul_ex e1 e3); + #e11; #e12; + nchange with ((plus_w16_d_d (plus_w16_d_d (plus_w16_d_d 〈〈x0,e7〉:〈e8,x0〉〉 〈〈x0,e9〉:〈e10,x0〉〉) 〈〈e11,e12〉:〈x0,x0〉〉)〈〈x0,x0〉:〈e5,e6〉〉) = + (plus_w16_d_d (plus_w16_d_d (plus_w16_d_d 〈〈x0,e9〉:〈e10,x0〉〉 〈〈x0,e7〉:〈e8,x0〉〉) 〈〈e11,e12〉:〈x0,x0〉〉)〈〈x0,x0〉:〈e5,e6〉〉)); + nrewrite > (symmetric_plusw16_d_d 〈〈x0,e7〉:〈e8,x0〉〉 〈〈x0,e9〉:〈e10,x0〉〉); + napply (refl_eq ??). +nqed. + +nlemma eqw16_to_eq : ∀w1,w2:word16.(eq_w16 w1 w2 = true) → (w1 = w2). + #w1; #w2; + nelim w1; + nelim w2; + #b1; #b2; #b3; #b4; + nchange in ⊢ (% → ?) with (((eq_b8 b3 b1)⊗(eq_b8 b4 b2)) = true); + #H; + nrewrite < (eqb8_to_eq ?? (andb_true_true_l ?? H)); + nrewrite < (eqb8_to_eq ?? (andb_true_true_r ?? H)); + napply (refl_eq ??). +nqed. + +nlemma eq_to_eqw16 : ∀w1,w2.w1 = w2 → eq_w16 w1 w2 = true. + #w1; #w2; + nelim w1; + nelim w2; + #b1; #b2; #b3; #b4; + #H; + nrewrite < (word16_destruct_1 ???? H); + nrewrite < (word16_destruct_2 ???? H); + nchange with (((eq_b8 b3 b3)⊗(eq_b8 b4 b4)) = true); + nrewrite > (eq_to_eqb8 b3 b3 (refl_eq ??)); + nrewrite > (eq_to_eqb8 b4 b4 (refl_eq ??)); + nnormalize; + napply (refl_eq ??). +nqed. diff --git a/helm/software/matita/contribs/ng_assembly/freescale/word32.ma b/helm/software/matita/contribs/ng_assembly/freescale/word32.ma new file mode 100755 index 000000000..e9ede8556 --- /dev/null +++ b/helm/software/matita/contribs/ng_assembly/freescale/word32.ma @@ -0,0 +1,255 @@ +(**************************************************************************) +(* ___ *) +(* ||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 *) +(* *) +(**************************************************************************) + +(* ********************************************************************** *) +(* *) +(* Sviluppato da: *) +(* Cosimo Oliboni, oliboni@cs.unibo.it *) +(* *) +(* ********************************************************************** *) + +include "freescale/word16.ma". + +(* ***** *) +(* DWORD *) +(* ***** *) + +nrecord word32 : Type ≝ + { + w32h: word16; + w32l: word16 + }. + +ndefinition word32_ind : ΠP:word32 → Prop.(Πw:word16.Πw1:word16.P (mk_word32 w w1)) → Πdw:word32.P dw ≝ +λP:word32 → Prop.λf:Πw:word16.Πw1:word16.P (mk_word32 w w1).λdw:word32. + match dw with [ mk_word32 (w:word16) (w1:word16) ⇒ f w w1 ]. + +ndefinition word32_rec : ΠP:word32 → Set.(Πw:word16.Πw1:word16.P (mk_word32 w w1)) → Πdw:word32.P dw ≝ +λP:word32 → Set.λf:Πw:word16.Πw1:word16.P (mk_word32 w w1).λdw:word32. + match dw with [ mk_word32 (w:word16) (w1:word16) ⇒ f w w1 ]. + +ndefinition word32_rect : ΠP:word32 → Type.(Πw:word16.Πw1:word16.P (mk_word32 w w1)) → Πdw:word32.P dw ≝ +λP:word32 → Type.λf:Πw:word16.Πw1:word16.P (mk_word32 w w1).λdw:word32. + match dw with [ mk_word32 (w:word16) (w1:word16) ⇒ f w w1 ]. + +ndefinition w32h ≝ λdw:word32.match dw with [ mk_word32 x _ ⇒ x ]. +ndefinition w32l ≝ λdw:word32.match dw with [ mk_word32 _ x ⇒ x ]. + +(* \langle \rangle *) +notation "〈x.y〉" non associative with precedence 80 + for @{ 'mk_word32 $x $y }. +interpretation "mk_word32" 'mk_word32 x y = (mk_word32 x y). + +(* operatore = *) +ndefinition eq_w32 ≝ λdw1,dw2.(eq_w16 (w32h dw1) (w32h dw2)) ⊗ (eq_w16 (w32l dw1) (w32l dw2)). + +(* operatore < *) +ndefinition lt_w32 ≝ +λdw1,dw2:word32.match lt_w16 (w32h dw1) (w32h dw2) with + [ true ⇒ true + | false ⇒ match gt_w16 (w32h dw1) (w32h dw2) with + [ true ⇒ false + | false ⇒ lt_w16 (w32l dw1) (w32l dw2) ]]. + +(* operatore ≤ *) +ndefinition le_w32 ≝ λdw1,dw2:word32.(eq_w32 dw1 dw2) ⊕ (lt_w32 dw1 dw2). + +(* operatore > *) +ndefinition gt_w32 ≝ λdw1,dw2:word32.⊖ (le_w32 dw1 dw2). + +(* operatore ≥ *) +ndefinition ge_w32 ≝ λdw1,dw2:word32.⊖ (lt_w32 dw1 dw2). + +(* operatore and *) +ndefinition and_w32 ≝ +λdw1,dw2:word32.mk_word32 (and_w16 (w32h dw1) (w32h dw2)) (and_w16 (w32l dw1) (w32l dw2)). + +(* operatore or *) +ndefinition or_w32 ≝ +λdw1,dw2:word32.mk_word32 (or_w16 (w32h dw1) (w32h dw2)) (or_w16 (w32l dw1) (w32l dw2)). + +(* operatore xor *) +ndefinition xor_w32 ≝ +λdw1,dw2:word32.mk_word32 (xor_w16 (w32h dw1) (w32h dw2)) (xor_w16 (w32l dw1) (w32l dw2)). + +(* operatore rotazione destra con carry *) +ndefinition rcr_w32 ≝ +λdw:word32.λc:bool.match rcr_w16 (w32h dw) c with + [ pair wh' c' ⇒ match rcr_w16 (w32l dw) c' with + [ pair wl' c'' ⇒ pair ?? (mk_word32 wh' wl') c'' ]]. + +(* operatore shift destro *) +ndefinition shr_w32 ≝ +λdw:word32.match rcr_w16 (w32h dw) false with + [ pair wh' c' ⇒ match rcr_w16 (w32l dw) c' with + [ pair wl' c'' ⇒ pair ?? (mk_word32 wh' wl') c'' ]]. + +(* operatore rotazione destra *) +ndefinition ror_w32 ≝ +λdw:word32.match rcr_w16 (w32h dw) false with + [ pair wh' c' ⇒ match rcr_w16 (w32l dw) c' with + [ pair wl' c'' ⇒ match c'' with + [ true ⇒ mk_word32 (or_w16 (mk_word16 (mk_byte8 x8 x0) (mk_byte8 x0 x0)) wh') wl' + | false ⇒ mk_word32 wh' wl' ]]]. + +(* operatore rotazione destra n-volte *) +nlet rec ror_w32_n (dw:word32) (n:nat) on n ≝ + match n with + [ O ⇒ dw + | S n' ⇒ ror_w32_n (ror_w32 dw) n' ]. + +(* operatore rotazione sinistra con carry *) +ndefinition rcl_w32 ≝ +λdw:word32.λc:bool.match rcl_w16 (w32l dw) c with + [ pair wl' c' ⇒ match rcl_w16 (w32h dw) c' with + [ pair wh' c'' ⇒ pair ?? (mk_word32 wh' wl') c'' ]]. + +(* operatore shift sinistro *) +ndefinition shl_w32 ≝ +λdw:word32.match rcl_w16 (w32l dw) false with + [ pair wl' c' ⇒ match rcl_w16 (w32h dw) c' with + [ pair wh' c'' ⇒ pair ?? (mk_word32 wh' wl') c'' ]]. + +(* operatore rotazione sinistra *) +ndefinition rol_w32 ≝ +λdw:word32.match rcl_w16 (w32l dw) false with + [ pair wl' c' ⇒ match rcl_w16 (w32h dw) c' with + [ pair wh' c'' ⇒ match c'' with + [ true ⇒ mk_word32 wh' (or_w16 (mk_word16 (mk_byte8 x0 x0) (mk_byte8 x0 x1)) wl') + | false ⇒ mk_word32 wh' wl' ]]]. + +(* operatore rotazione sinistra n-volte *) +nlet rec rol_w32_n (dw:word32) (n:nat) on n ≝ + match n with + [ O ⇒ dw + | S n' ⇒ rol_w32_n (rol_w32 dw) n' ]. + +(* operatore not/complemento a 1 *) +ndefinition not_w32 ≝ +λdw:word32.mk_word32 (not_w16 (w32h dw)) (not_w16 (w32l dw)). + +(* operatore somma con data+carry → data+carry *) +ndefinition plus_w32_dc_dc ≝ +λdw1,dw2:word32.λc:bool. + match plus_w16_dc_dc (w32l dw1) (w32l dw2) c with + [ pair l c ⇒ match plus_w16_dc_dc (w32h dw1) (w32h dw2) c with + [ pair h c' ⇒ pair ?? 〈h.l〉 c' ]]. + +(* operatore somma con data+carry → data *) +ndefinition plus_w32_dc_d ≝ +λdw1,dw2:word32.λc:bool. + match plus_w16_dc_dc (w32l dw1) (w32l dw2) c with + [ pair l c ⇒ 〈plus_w16_dc_d (w32h dw1) (w32h dw2) c.l〉 ]. + +(* operatore somma con data+carry → c *) +ndefinition plus_w32_dc_c ≝ +λdw1,dw2:word32.λc:bool. + plus_w16_dc_c (w32h dw1) (w32h dw2) (plus_w16_dc_c (w32l dw1) (w32l dw2) c). + +(* operatore somma con data → data+carry *) +ndefinition plus_w32_d_dc ≝ +λdw1,dw2:word32. + match plus_w16_d_dc (w32l dw1) (w32l dw2) with + [ pair l c ⇒ match plus_w16_dc_dc (w32h dw1) (w32h dw2) c with + [ pair h c' ⇒ pair ?? 〈h.l〉 c' ]]. + +(* operatore somma con data → data *) +ndefinition plus_w32_d_d ≝ +λdw1,dw2:word32. + match plus_w16_d_dc (w32l dw1) (w32l dw2) with + [ pair l c ⇒ 〈plus_w16_dc_d (w32h dw1) (w32h dw2) c.l〉 ]. + +(* operatore somma con data → c *) +ndefinition plus_w32_d_c ≝ +λdw1,dw2:word32. + plus_w16_dc_c (w32h dw1) (w32h dw2) (plus_w16_d_c (w32l dw1) (w32l dw2)). + +(* operatore Most Significant Bit *) +ndefinition MSB_w32 ≝ λdw:word32.eq_ex x8 (and_ex x8 (b8h (w16h (w32h dw)))). + +(* word → naturali *) +ndefinition nat_of_word32 ≝ λdw:word32. (256 * 256 * (nat_of_word16 (w32h dw))) + (nat_of_word16 (w32l dw)). + +(* operatore predecessore *) +ndefinition pred_w32 ≝ +λdw:word32.match eq_w16 (w32l dw) (mk_word16 (mk_byte8 x0 x0) (mk_byte8 x0 x0)) with + [ true ⇒ mk_word32 (pred_w16 (w32h dw)) (pred_w16 (w32l dw)) + | false ⇒ mk_word32 (w32h dw) (pred_w16 (w32l dw)) ]. + +(* operatore successore *) +ndefinition succ_w32 ≝ +λdw:word32.match eq_w16 (w32l dw) (mk_word16 (mk_byte8 xF xF) (mk_byte8 xF xF)) with + [ true ⇒ mk_word32 (succ_w16 (w32h dw)) (succ_w16 (w32l dw)) + | false ⇒ mk_word32 (w32h dw) (succ_w16 (w32l dw)) ]. + +(* operatore neg/complemento a 2 *) +ndefinition compl_w32 ≝ +λdw:word32.match MSB_w32 dw with + [ true ⇒ succ_w32 (not_w32 dw) + | false ⇒ not_w32 (pred_w32 dw) ]. + +(* + operatore moltiplicazione senza segno: b*b=[0x00000000,0xFFFE0001] + ... in pratica (〈a:b〉*〈c:d〉) = (a*c)<<16+(a*d)<<8+(b*c)<<8+(b*d) +*) +ndefinition mul_w16 ≝ +λw1,w2:word16.match w1 with +[ mk_word16 b1h b1l ⇒ match w2 with +[ mk_word16 b2h b2l ⇒ match mul_b8 b1l b2l with +[ mk_word16 t1_h t1_l ⇒ match mul_b8 b1h b2l with +[ mk_word16 t2_h t2_l ⇒ match mul_b8 b2h b1l with +[ mk_word16 t3_h t3_l ⇒ match mul_b8 b1h b2h with +[ mk_word16 t4_h t4_l ⇒ + plus_w32_d_d + (plus_w32_d_d + (plus_w32_d_d 〈〈〈x0,x0〉:t3_h〉.〈t3_l:〈x0,x0〉〉〉 〈〈〈x0,x0〉:t2_h〉.〈t2_l:〈x0,x0〉〉〉) 〈〈t4_h:t4_l〉.〈〈x0,x0〉:〈x0,x0〉〉〉)〈〈〈x0,x0〉:〈x0,x0〉〉.〈t1_h:t1_l〉〉 +]]]]]]. + +(* divisione senza segno (secondo la logica delle ALU): (quoziente resto) overflow *) +nlet rec div_w16_aux (divd:word32) (divs:word32) (molt:word16) (q:word16) (c:nat) on c ≝ + let w' ≝ plus_w32_d_d divd (compl_w32 divs) in + match c with + [ O ⇒ match le_w32 divs divd with + [ true ⇒ triple ??? (or_w16 molt q) (w32l w') (⊖ (eq_w16 (w32h w') 〈〈x0,x0〉:〈x0,x0〉〉)) + | false ⇒ triple ??? q (w32l divd) (⊖ (eq_w16 (w32h divd) 〈〈x0,x0〉:〈x0,x0〉〉)) ] + | S c' ⇒ match le_w32 divs divd with + [ true ⇒ div_w16_aux w' (ror_w32 divs) (ror_w16 molt) (or_w16 molt q) c' + | false ⇒ div_w16_aux divd (ror_w32 divs) (ror_w16 molt) q c' ]]. + +ndefinition div_w16 ≝ +λw:word32.λb:word16.match eq_w16 b 〈〈x0,x0〉:〈x0,x0〉〉 with +(* + la combinazione n/0 e' illegale, segnala solo overflow senza dare risultato +*) + [ true ⇒ triple ??? 〈〈xF,xF〉:〈xF,xF〉〉 (w32l w) true + | false ⇒ match eq_w32 w 〈〈〈x0,x0〉:〈x0,x0〉〉.〈〈x0,x0〉:〈x0,x0〉〉〉 with +(* 0 diviso qualsiasi cosa diverso da 0 da' q=0 r=0 o=false *) + [ true ⇒ triple ??? 〈〈x0,x0〉:〈x0,x0〉〉 〈〈x0,x0〉:〈x0,x0〉〉 false +(* 1) e' una divisione sensata che produrra' overflow/risultato *) +(* 2) parametri: dividendo, divisore, moltiplicatore, quoziente, contatore *) +(* 3) ad ogni ciclo il divisore e il moltiplicatore vengono scalati di 1 a dx *) +(* 4) il moltiplicatore e' la quantita' aggiunta al quoziente se il divisore *) +(* puo' essere sottratto al dividendo *) + | false ⇒ div_w16_aux w (rol_w32_n 〈〈〈x0,x0〉:〈x0,x0〉〉.b〉 15) 〈〈x8,x0〉:〈x0,x0〉〉 〈〈x0,x0〉:〈x0,x0〉〉 15 ]]. + +(* operatore x in [inf,sup] *) +ndefinition in_range ≝ +λx,inf,sup:word32.(le_w32 inf sup) ⊗ (ge_w32 x inf) ⊗ (le_w32 x sup). + +(* iteratore sulle word *) +ndefinition forall_word32 ≝ + λP. + forall_word16 (λbh. + forall_word16 (λbl. + P (mk_word32 bh bl ))). diff --git a/helm/software/matita/contribs/ng_assembly/freescale/word32_lemmas.ma b/helm/software/matita/contribs/ng_assembly/freescale/word32_lemmas.ma new file mode 100755 index 000000000..a6d3d832a --- /dev/null +++ b/helm/software/matita/contribs/ng_assembly/freescale/word32_lemmas.ma @@ -0,0 +1,331 @@ +(**************************************************************************) +(* ___ *) +(* ||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 *) +(* *) +(* Questo materiale fa parte della tesi: *) +(* "Formalizzazione Interattiva dei Microcontroller a 8bit FreeScale" *) +(* *) +(* data ultima modifica 15/11/2007 *) +(* ********************************************************************** *) + +include "freescale/word16_lemmas.ma". +include "freescale/word32.ma". + +(* ***** *) +(* DWORD *) +(* ***** *) + +nlemma word32_destruct_1 : +∀x1,x2,y1,y2. + mk_word32 x1 y1 = mk_word32 x2 y2 → x1 = x2. + #x1; #x2; #y1; #y2; #H; + nchange with (match mk_word32 x2 y2 with [ mk_word32 a _ ⇒ x1 = a ]); + nrewrite < H; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma word32_destruct_2 : +∀x1,x2,y1,y2. + mk_word32 x1 y1 = mk_word32 x2 y2 → y1 = y2. + #x1; #x2; #y1; #y2; #H; + nchange with (match mk_word32 x2 y2 with [ mk_word32 _ b ⇒ y1 = b ]); + nrewrite < H; + nnormalize; + napply (refl_eq ??). +nqed. + +nlemma symmetric_eqw32 : symmetricT word32 bool eq_w32. + #dw1; #dw2; + nelim dw1; + nelim dw2; + #w1; #w2; #w3; #w4; + nchange with (((eq_w16 w3 w1)⊗(eq_w16 w4 w2)) = ((eq_w16 w1 w3)⊗(eq_w16 w2 w4))); + nrewrite > (symmetric_eqw16 w1 w3); + nrewrite > (symmetric_eqw16 w2 w4); + napply (refl_eq ??). +nqed. + +nlemma symmetric_andw32 : symmetricT word32 word32 and_w32. + #dw1; #dw2; + nelim dw1; + nelim dw2; + #w1; #w2; #w3; #w4; + nchange with ((mk_word32 (and_w16 w3 w1) (and_w16 w4 w2)) = (mk_word32 (and_w16 w1 w3) (and_w16 w2 w4))); + nrewrite > (symmetric_andw16 w1 w3); + nrewrite > (symmetric_andw16 w2 w4); + napply (refl_eq ??). +nqed. + +nlemma associative_andw32 : ∀dw1,dw2,dw3.(and_w32 (and_w32 dw1 dw2) dw3) = (and_w32 dw1 (and_w32 dw2 dw3)). + #dw1; #dw2; #dw3; + nelim dw1; + #w1; #w2; + nelim dw2; + #w3; #w4; + nelim dw3; + #w5; #w6; + nchange with (mk_word32 (and_w16 (and_w16 w1 w3) w5) (and_w16 (and_w16 w2 w4) w6) = + mk_word32 (and_w16 w1 (and_w16 w3 w5)) (and_w16 w2 (and_w16 w4 w6))); + nrewrite < (associative_andw16 w1 w3 w5); + nrewrite < (associative_andw16 w2 w4 w6); + napply (refl_eq ??). +nqed. + +nlemma symmetric_orw32 : symmetricT word32 word32 or_w32. + #dw1; #dw2; + nelim dw1; + nelim dw2; + #w1; #w2; #w3; #w4; + nchange with ((mk_word32 (or_w16 w3 w1) (or_w16 w4 w2)) = (mk_word32 (or_w16 w1 w3) (or_w16 w2 w4))); + nrewrite > (symmetric_orw16 w1 w3); + nrewrite > (symmetric_orw16 w2 w4); + napply (refl_eq ??). +nqed. + +nlemma associative_orw32 : ∀dw1,dw2,dw3.(or_w32 (or_w32 dw1 dw2) dw3) = (or_w32 dw1 (or_w32 dw2 dw3)). + #dw1; #dw2; #dw3; + nelim dw1; + #w1; #w2; + nelim dw2; + #w3; #w4; + nelim dw3; + #w5; #w6; + nchange with (mk_word32 (or_w16 (or_w16 w1 w3) w5) (or_w16 (or_w16 w2 w4) w6) = + mk_word32 (or_w16 w1 (or_w16 w3 w5)) (or_w16 w2 (or_w16 w4 w6))); + nrewrite < (associative_orw16 w1 w3 w5); + nrewrite < (associative_orw16 w2 w4 w6); + napply (refl_eq ??). +nqed. + +nlemma symmetric_xorw32 : symmetricT word32 word32 xor_w32. + #dw1; #dw2; + nelim dw1; + nelim dw2; + #w1; #w2; #w3; #w4; + nchange with ((mk_word32 (xor_w16 w3 w1) (xor_w16 w4 w2)) = (mk_word32 (xor_w16 w1 w3) (xor_w16 w2 w4))); + nrewrite > (symmetric_xorw16 w1 w3); + nrewrite > (symmetric_xorw16 w2 w4); + napply (refl_eq ??). +nqed. + +nlemma associative_xorw32 : ∀dw1,dw2,dw3.(xor_w32 (xor_w32 dw1 dw2) dw3) = (xor_w32 dw1 (xor_w32 dw2 dw3)). + #dw1; #dw2; #dw3; + nelim dw1; + #w1; #w2; + nelim dw2; + #w3; #w4; + nelim dw3; + #w5; #w6; + nchange with (mk_word32 (xor_w16 (xor_w16 w1 w3) w5) (xor_w16 (xor_w16 w2 w4) w6) = + mk_word32 (xor_w16 w1 (xor_w16 w3 w5)) (xor_w16 w2 (xor_w16 w4 w6))); + nrewrite < (associative_xorw16 w1 w3 w5); + nrewrite < (associative_xorw16 w2 w4 w6); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusw32_dc_dc : ∀dw1,dw2,c.plus_w32_dc_dc dw1 dw2 c = plus_w32_dc_dc dw2 dw1 c. + #dw1; #dw2; #c; + nelim dw1; + #w1; #w2; + nelim dw2; + #w3; #w4; + nchange with ( + match plus_w16_dc_dc w2 w4 c with + [ pair l c ⇒ match plus_w16_dc_dc w1 w3 c with + [ pair h c' ⇒ pair ?? 〈h.l〉 c' ]] = + match plus_w16_dc_dc w4 w2 c with + [ pair l c ⇒ match plus_w16_dc_dc w3 w1 c with + [ pair h c' ⇒ pair ?? 〈h.l〉 c' ]]); + nrewrite > (symmetric_plusw16_dc_dc w4 w2 c); + ncases (plus_w16_dc_dc w2 w4 c); + #w5; #c1; + nchange with ( + match plus_w16_dc_dc w1 w3 c1 with + [ pair h c' ⇒ pair ?? 〈h.w5〉 c' ] = + match plus_w16_dc_dc w3 w1 c1 with + [ pair h c' ⇒ pair ?? 〈h.w5〉 c' ]); + nrewrite > (symmetric_plusw16_dc_dc w1 w3 c1); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusw32_dc_d : ∀dw1,dw2,c.plus_w32_dc_d dw1 dw2 c = plus_w32_dc_d dw2 dw1 c. + #dw1; #dw2; #c; + nelim dw1; + #w1; #w2; + nelim dw2; + #w3; #w4; + nchange with ( + match plus_w16_dc_dc w2 w4 c with + [ pair l c ⇒ 〈plus_w16_dc_d w1 w3 c.l〉 ] = + match plus_w16_dc_dc w4 w2 c with + [ pair l c ⇒ 〈plus_w16_dc_d w3 w1 c.l〉 ]); + nrewrite > (symmetric_plusw16_dc_dc w4 w2 c); + ncases (plus_w16_dc_dc w2 w4 c); + #w5; #c1; + nchange with (〈plus_w16_dc_d w1 w3 c1.w5〉 = 〈plus_w16_dc_d w3 w1 c1.w5〉); + nrewrite > (symmetric_plusw16_dc_d w1 w3 c1); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusw32_dc_c : ∀dw1,dw2,c.plus_w32_dc_c dw1 dw2 c = plus_w32_dc_c dw2 dw1 c. + #dw1; #dw2; #c; + nelim dw1; + #w1; #w2; + nelim dw2; + #w3; #w4; + nchange with ( + plus_w16_dc_c w1 w3 (plus_w16_dc_c w2 w4 c) = + plus_w16_dc_c w3 w1 (plus_w16_dc_c w4 w2 c)); + nrewrite > (symmetric_plusw16_dc_c w4 w2 c); + nrewrite > (symmetric_plusw16_dc_c w3 w1 (plus_w16_dc_c w2 w4 c)); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusw32_d_dc : ∀dw1,dw2.plus_w32_d_dc dw1 dw2 = plus_w32_d_dc dw2 dw1. + #dw1; #dw2; + nelim dw1; + #w1; #w2; + nelim dw2; + #w3; #w4; + nchange with ( + match plus_w16_d_dc w2 w4 with + [ pair l c ⇒ match plus_w16_dc_dc w1 w3 c with + [ pair h c' ⇒ pair ?? 〈h.l〉 c' ]] = + match plus_w16_d_dc w4 w2 with + [ pair l c ⇒ match plus_w16_dc_dc w3 w1 c with + [ pair h c' ⇒ pair ?? 〈h.l〉 c' ]]); + nrewrite > (symmetric_plusw16_d_dc w4 w2); + ncases (plus_w16_d_dc w2 w4); + #w5; #c; + nchange with ( + match plus_w16_dc_dc w1 w3 c with + [ pair h c' ⇒ pair ?? 〈h.w5〉 c' ] = + match plus_w16_dc_dc w3 w1 c with + [ pair h c' ⇒ pair ?? 〈h.w5〉 c' ]); + nrewrite > (symmetric_plusw16_dc_dc w1 w3 c); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusw32_d_d : ∀dw1,dw2.plus_w32_d_d dw1 dw2 = plus_w32_d_d dw2 dw1. + #dw1; #dw2; + nelim dw1; + #w1; #w2; + nelim dw2; + #w3; #w4; + nchange with ( + match plus_w16_d_dc w2 w4 with + [ pair l c ⇒ 〈plus_w16_dc_d w1 w3 c.l〉 ] = + match plus_w16_d_dc w4 w2 with + [ pair l c ⇒ 〈plus_w16_dc_d w3 w1 c.l〉 ]); + nrewrite > (symmetric_plusw16_d_dc w4 w2); + ncases (plus_w16_d_dc w2 w4); + #w5; #c; + nchange with (〈plus_w16_dc_d w1 w3 c.w5〉 = 〈plus_w16_dc_d w3 w1 c.w5〉); + nrewrite > (symmetric_plusw16_dc_d w1 w3 c); + napply (refl_eq ??). +nqed. + +nlemma symmetric_plusw32_d_c : ∀dw1,dw2.plus_w32_d_c dw1 dw2 = plus_w32_d_c dw2 dw1. + #dw1; #dw2; + nelim dw1; + #w1; #w2; + nelim dw2; + #w3; #w4; + nchange with ( + plus_w16_dc_c w1 w3 (plus_w16_d_c w2 w4) = + plus_w16_dc_c w3 w1 (plus_w16_d_c w4 w2)); + nrewrite > (symmetric_plusw16_d_c w4 w2); + nrewrite > (symmetric_plusw16_dc_c w3 w1 (plus_w16_d_c w2 w4)); + napply (refl_eq ??). +nqed. + +nlemma symmetric_mulw16 : symmetricT word16 word32 mul_w16. + #w1; #w2; + nelim w1; + #b1; #b2; + nelim w2; + #b3; #b4; + nchange with (match mul_b8 b2 b4 with + [ mk_word16 t1_h t1_l ⇒ match mul_b8 b1 b4 with + [ mk_word16 t2_h t2_l ⇒ match mul_b8 b3 b2 with + [ mk_word16 t3_h t3_l ⇒ match mul_b8 b1 b3 with + [ mk_word16 t4_h t4_l ⇒ plus_w32_d_d (plus_w32_d_d (plus_w32_d_d 〈〈〈x0,x0〉:t3_h〉.〈t3_l:〈x0,x0〉〉〉 〈〈〈x0,x0〉:t2_h〉.〈t2_l:〈x0,x0〉〉〉) 〈〈t4_h:t4_l〉.〈〈x0,x0〉:〈x0,x0〉〉〉)〈〈〈x0,x0〉:〈x0,x0〉〉.〈t1_h:t1_l〉〉 + ]]]] = match mul_b8 b4 b2 with + [ mk_word16 t1_h t1_l ⇒ match mul_b8 b3 b2 with + [ mk_word16 t2_h t2_l ⇒ match mul_b8 b1 b4 with + [ mk_word16 t3_h t3_l ⇒ match mul_b8 b3 b1 with + [ mk_word16 t4_h t4_l ⇒ plus_w32_d_d (plus_w32_d_d (plus_w32_d_d 〈〈〈x0,x0〉:t3_h〉.〈t3_l:〈x0,x0〉〉〉 〈〈〈x0,x0〉:t2_h〉.〈t2_l:〈x0,x0〉〉〉) 〈〈t4_h:t4_l〉.〈〈x0,x0〉:〈x0,x0〉〉〉)〈〈〈x0,x0〉:〈x0,x0〉〉.〈t1_h:t1_l〉〉 + ]]]]); + nrewrite < (symmetric_mulb8 b2 b4); + ncases (mul_b8 b2 b4); + #b5; #b6; + nchange with (match mul_b8 b1 b4 with + [ mk_word16 t2_h t2_l ⇒ match mul_b8 b3 b2 with + [ mk_word16 t3_h t3_l ⇒ match mul_b8 b1 b3 with + [ mk_word16 t4_h t4_l ⇒ plus_w32_d_d (plus_w32_d_d (plus_w32_d_d 〈〈〈x0,x0〉:t3_h〉.〈t3_l:〈x0,x0〉〉〉 〈〈〈x0,x0〉:t2_h〉.〈t2_l:〈x0,x0〉〉〉) 〈〈t4_h:t4_l〉.〈〈x0,x0〉:〈x0,x0〉〉〉)〈〈〈x0,x0〉:〈x0,x0〉〉.〈b5:b6〉〉 + ]]] = match mul_b8 b3 b2 with + [ mk_word16 t2_h t2_l ⇒ match mul_b8 b1 b4 with + [ mk_word16 t3_h t3_l ⇒ match mul_b8 b3 b1 with + [ mk_word16 t4_h t4_l ⇒ plus_w32_d_d (plus_w32_d_d (plus_w32_d_d 〈〈〈x0,x0〉:t3_h〉.〈t3_l:〈x0,x0〉〉〉 〈〈〈x0,x0〉:t2_h〉.〈t2_l:〈x0,x0〉〉〉) 〈〈t4_h:t4_l〉.〈〈x0,x0〉:〈x0,x0〉〉〉)〈〈〈x0,x0〉:〈x0,x0〉〉.〈b5:b6〉〉 + ]]]); + ncases (mul_b8 b3 b2); + #b7; #b8; + ncases (mul_b8 b1 b4); + #b9; #b10; + nchange with (match mul_b8 b1 b3 with + [ mk_word16 t4_h t4_l ⇒ plus_w32_d_d (plus_w32_d_d (plus_w32_d_d 〈〈〈x0,x0〉:b7〉.〈b8:〈x0,x0〉〉〉 〈〈〈x0,x0〉:b9〉.〈b10:〈x0,x0〉〉〉) 〈〈t4_h:t4_l〉.〈〈x0,x0〉:〈x0,x0〉〉〉)〈〈〈x0,x0〉:〈x0,x0〉〉.〈b5:b6〉〉 + ] = match mul_b8 b3 b1 with + [ mk_word16 t4_h t4_l ⇒ plus_w32_d_d (plus_w32_d_d (plus_w32_d_d 〈〈〈x0,x0〉:b9〉.〈b10:〈x0,x0〉〉〉 〈〈〈x0,x0〉:b7〉.〈b8:〈x0,x0〉〉〉) 〈〈t4_h:t4_l〉.〈〈x0,x0〉:〈x0,x0〉〉〉)〈〈〈x0,x0〉:〈x0,x0〉〉.〈b5:b6〉〉 + ]); + nrewrite < (symmetric_mulb8 b1 b3); + ncases (mul_b8 b1 b3); + #b11; #b12; + nchange with ((plus_w32_d_d (plus_w32_d_d (plus_w32_d_d 〈〈〈x0,x0〉:b7〉.〈b8:〈x0,x0〉〉〉 〈〈〈x0,x0〉:b9〉.〈b10:〈x0,x0〉〉〉) 〈〈b11:b12〉.〈〈x0,x0〉:〈x0,x0〉〉〉)〈〈〈x0,x0〉:〈x0,x0〉〉.〈b5:b6〉〉) = + (plus_w32_d_d (plus_w32_d_d (plus_w32_d_d 〈〈〈x0,x0〉:b9〉.〈b10:〈x0,x0〉〉〉 〈〈〈x0,x0〉:b7〉.〈b8:〈x0,x0〉〉〉) 〈〈b11:b12〉.〈〈x0,x0〉:〈x0,x0〉〉〉)〈〈〈x0,x0〉:〈x0,x0〉〉.〈b5:b6〉〉)); + nrewrite > (symmetric_plusw32_d_d 〈〈〈x0,x0〉:b7〉.〈b8:〈x0,x0〉〉〉 〈〈〈x0,x0〉:b9〉.〈b10:〈x0,x0〉〉〉); + napply (refl_eq ??). +nqed. + +nlemma eqw32_to_eq : ∀dw1,dw2:word32.(eq_w32 dw1 dw2 = true) → (dw1 = dw2). + #dw1; #dw2; + nelim dw1; + nelim dw2; + #w1; #w2; #w3; #w4; + nchange in ⊢ (% → ?) with (((eq_w16 w3 w1)⊗(eq_w16 w4 w2)) = true); + #H; + nrewrite < (eqw16_to_eq ?? (andb_true_true_l ?? H)); + nrewrite < (eqw16_to_eq ?? (andb_true_true_r ?? H)); + napply (refl_eq ??). +nqed. + +nlemma eq_to_eqw32 : ∀dw1,dw2.dw1 = dw2 → eq_w32 dw1 dw2 = true. + #dw1; #dw2; + nelim dw1; + nelim dw2; + #w1; #w2; #w3; #w4; + #H; + nrewrite < (word32_destruct_1 ???? H); + nrewrite < (word32_destruct_2 ???? H); + nchange with (((eq_w16 w3 w3)⊗(eq_w16 w4 w4)) = true); + nrewrite > (eq_to_eqw16 w3 w3 (refl_eq ??)); + nrewrite > (eq_to_eqw16 w4 w4 (refl_eq ??)); + nnormalize; + napply (refl_eq ??). +nqed.