X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fmatita%2Fcontribs%2Fng_assembly2%2Femulator%2Fopcodes%2Fpseudo.ma;h=c881965acfe40cb51c417fab52149c33abbee73d;hb=cacd19eb7ce2395301b31ed3932b4cd7c23ca90e;hp=10b82528d13d6aa903eb81bad50e287d353764bc;hpb=e1efca300fbaeb8c69a691a428a084d89a2c058f;p=helm.git diff --git a/helm/software/matita/contribs/ng_assembly2/emulator/opcodes/pseudo.ma b/helm/software/matita/contribs/ng_assembly2/emulator/opcodes/pseudo.ma index 10b82528d..c881965ac 100755 --- a/helm/software/matita/contribs/ng_assembly2/emulator/opcodes/pseudo.ma +++ b/helm/software/matita/contribs/ng_assembly2/emulator/opcodes/pseudo.ma @@ -58,6 +58,40 @@ ndefinition aux_pseudo_type ≝ | IP2022 ⇒ IP2022_pseudo ]. +ndefinition pseudo_is_comparable: mcu_type → comparable. + #mcu; @ (aux_pseudo_type mcu) + ##[ nelim mcu; + ##[ ##1,2,3,4: napply (zeroc Freescalepseudo_is_comparable) + ##| ##5: napply (zeroc IP2022pseudo_is_comparable) ##] + ##| nelim mcu; + ##[ ##1,2,3,4: napply (forallc Freescalepseudo_is_comparable) + ##| ##5: napply (forallc IP2022pseudo_is_comparable) ##] + ##| nelim mcu; + ##[ ##1,2,3,4: napply (eqc Freescalepseudo_is_comparable) + ##| ##5: napply (eqc IP2022pseudo_is_comparable) ##] + ##| nelim mcu; + ##[ ##1,2,3,4: napply (eqc_to_eq Freescalepseudo_is_comparable) + ##| ##5: napply (eqc_to_eq IP2022pseudo_is_comparable) ##] + ##| nelim mcu; + ##[ ##1,2,3,4: napply (eq_to_eqc Freescalepseudo_is_comparable) + ##| ##5: napply (eq_to_eqc IP2022pseudo_is_comparable) ##] + ##| nelim mcu; + ##[ ##1,2,3,4: napply (neqc_to_neq Freescalepseudo_is_comparable) + ##| ##5: napply (neqc_to_neq IP2022pseudo_is_comparable) ##] + ##| nelim mcu; + ##[ ##1,2,3,4: napply (neq_to_neqc Freescalepseudo_is_comparable) + ##| ##5: napply (neq_to_neqc IP2022pseudo_is_comparable) ##] + ##| nelim mcu; + ##[ ##1,2,3,4: napply (decidable_c Freescalepseudo_is_comparable) + ##| ##5: napply (decidable_c IP2022pseudo_is_comparable) ##] + ##| nelim mcu; + ##[ ##1,2,3,4: napply (symmetric_eqc Freescalepseudo_is_comparable) + ##| ##5: napply (symmetric_eqc IP2022pseudo_is_comparable) ##] + ##] +nqed. + +unification hint 0 ≔ M:mcu_type ⊢ carr (pseudo_is_comparable M) ≡ aux_pseudo_type M. + ndefinition aux_im_type ≝ λmcu:mcu_type.match mcu with [ HC05 ⇒ Freescale_instr_mode @@ -67,23 +101,71 @@ ndefinition aux_im_type ≝ | IP2022 ⇒ IP2022_instr_mode ]. +ndefinition im_is_comparable: mcu_type → comparable. + #mcu; @ (aux_im_type mcu) + ##[ nelim mcu; + ##[ ##1,2,3,4: napply (zeroc Freescaleim_is_comparable) + ##| ##5: napply (zeroc IP2022im_is_comparable) ##] + ##| nelim mcu; + ##[ ##1,2,3,4: napply (forallc Freescaleim_is_comparable) + ##| ##5: napply (forallc IP2022im_is_comparable) ##] + ##| nelim mcu; + ##[ ##1,2,3,4: napply (eqc Freescaleim_is_comparable) + ##| ##5: napply (eqc IP2022im_is_comparable) ##] + ##| nelim mcu; + ##[ ##1,2,3,4: napply (eqc_to_eq Freescaleim_is_comparable) + ##| ##5: napply (eqc_to_eq IP2022im_is_comparable) ##] + ##| nelim mcu; + ##[ ##1,2,3,4: napply (eq_to_eqc Freescaleim_is_comparable) + ##| ##5: napply (eq_to_eqc IP2022im_is_comparable) ##] + ##| nelim mcu; + ##[ ##1,2,3,4: napply (neqc_to_neq Freescaleim_is_comparable) + ##| ##5: napply (neqc_to_neq IP2022im_is_comparable) ##] + ##| nelim mcu; + ##[ ##1,2,3,4: napply (neq_to_neqc Freescaleim_is_comparable) + ##| ##5: napply (neq_to_neqc IP2022im_is_comparable) ##] + ##| nelim mcu; + ##[ ##1,2,3,4: napply (decidable_c Freescaleim_is_comparable) + ##| ##5: napply (decidable_c IP2022im_is_comparable) ##] + ##| nelim mcu; + ##[ ##1,2,3,4: napply (symmetric_eqc Freescaleim_is_comparable) + ##| ##5: napply (symmetric_eqc IP2022im_is_comparable) ##] + ##] +nqed. + +unification hint 0 ≔ M:mcu_type ⊢ carr (im_is_comparable M) ≡ aux_im_type M. + (* ********************************************* *) (* STRUMENTI PER LE DIMOSTRAZIONI DI CORRETTEZZA *) (* ********************************************* *) ndefinition aux_table_type ≝ λmcu:mcu_type.Prod4T (aux_pseudo_type mcu) (aux_im_type mcu) byte8_or_word16 byte8. -ndefinition pseudo_is_comparable ≝ -λmcu:mcu_type.match mcu with - [ HC05 ⇒ Freescalepseudo_is_comparable - | HC08 ⇒ Freescalepseudo_is_comparable - | HCS08 ⇒ Freescalepseudo_is_comparable - | RS08 ⇒ Freescalepseudo_is_comparable - | IP2022 ⇒ IP2022pseudo_is_comparable - ]. +(* su tutta la lista quante volte compare il byte *) +nlet rec get_byte_count (m:mcu_type) (b:byte8) (c:word16) (l:list (aux_table_type m)) on l ≝ + match l with + [ nil ⇒ c + | cons hd tl ⇒ match thd4T … hd with + [ Byte b' ⇒ match eqc ? b b' with + [ true ⇒ get_byte_count m b (succc ? c) tl + | false ⇒ get_byte_count m b c tl + ] + | Word _ ⇒ get_byte_count m b c tl + ] + ]. -(* come suggerire di unificare? - carr (pseudo_is_comparable M) = aux_pseudo_type M *) +(* su tutta la lista quante volte compare la word *) +nlet rec get_word_count (m:mcu_type) (w:word16) (c:word16) (l:list (aux_table_type m)) on l ≝ + match l with + [ nil ⇒ c + | cons hd tl ⇒ match thd4T … hd with + [ Byte _ ⇒ get_word_count m w c tl + | Word w' ⇒ match eqc ? w w' with + [ true ⇒ get_word_count m w (succc ? c) tl + | false ⇒ get_word_count m w c tl + ] + ] + ]. (* su tutta la lista quante volte compare lo pseudocodice *) nlet rec get_pseudo_count (m:mcu_type) (o:aux_pseudo_type m) (c:word16) (l:list (aux_table_type m)) on l ≝ @@ -94,3 +176,55 @@ nlet rec get_pseudo_count (m:mcu_type) (o:aux_pseudo_type m) (c:word16) (l:list | false ⇒ get_pseudo_count m o c tl ] ]. + +(* su tutta la lista quante volte compare la modalita' *) +nlet rec get_mode_count (m:mcu_type) (i:aux_im_type m) (c:word16) (l:list (aux_table_type m)) on l ≝ + match l with + [ nil ⇒ c + | cons hd tl ⇒ match eqc ? i (snd4T … hd) with + [ true ⇒ get_mode_count m i (succc ? c) tl + | false ⇒ get_mode_count m i c tl + ] + ]. + +(* b e' non implementato? *) +nlet rec test_not_impl_byte (b:byte8) (l:list byte8) on l ≝ + match l with + [ nil ⇒ false + | cons hd tl ⇒ match eqc ? b hd with + [ true ⇒ true + | false ⇒ test_not_impl_byte b tl + ] + ]. + +(* su tutta la lista quante volte compare la coppia pseudo,instr_mode *) +nlet rec get_PsIm_count (m:mcu_type) (o:aux_pseudo_type m) (i:aux_im_type m) (c:word16) (l:list (aux_table_type m)) on l ≝ + match l with + [ nil ⇒ c + | cons hd tl ⇒ + match (eqc ? o (fst4T … hd)) ⊗ + (eqc ? i (snd4T … hd)) with + [ true ⇒ get_PsIm_count m o i (succc ? c) tl + | false ⇒ get_PsIm_count m o i c tl + ] + ]. + +(* o e' non implementato? *) +nlet rec test_not_impl_pseudo (m:mcu_type) (o:aux_pseudo_type m) (l:list (aux_pseudo_type m)) on l ≝ + match l with + [ nil ⇒ false + | cons hd tl ⇒ match eqc ? o hd with + [ true ⇒ true + | false ⇒ test_not_impl_pseudo m o tl + ] + ]. + +(* i e' non implementato? *) +nlet rec test_not_impl_mode (m:mcu_type) (i:aux_im_type m) (l:list (aux_im_type m)) on l ≝ + match l with + [ nil ⇒ false + | cons hd tl ⇒ match eqc ? i hd with + [ true ⇒ true + | false ⇒ test_not_impl_mode m i tl + ] + ].