Theory Lem_word
chapter ‹Generated by Lem from ‹word.lem›.›
theory "Lem_word"
imports
Main
"Lem_bool"
"Lem_maybe"
"Lem_num"
"Lem_basic_classes"
"Lem_list"
"HOL-Library.Word"
begin
datatype bitSequence = BitSeq "
nat option " "
bool " " bool
list "
fun boolListFrombitSeqAux :: " nat ⇒ 'a ⇒ 'a list ⇒ 'a list " where
" boolListFrombitSeqAux n s bl = (
if n =( 0 :: nat) then [] else
(case bl of
[] => List.replicate n s
| b # bl' => b # (boolListFrombitSeqAux (n-( 1 :: nat)) s bl')
))"
fun boolListFrombitSeq :: " nat ⇒ bitSequence ⇒(bool)list " where
" boolListFrombitSeq n (BitSeq _ s bl) = ( boolListFrombitSeqAux n s bl )"
definition bitSeqFromBoolList :: "(bool)list ⇒(bitSequence)option " where
" bitSeqFromBoolList bl = (
(case dest_init bl of
None => None
| Some (bl', s) => Some (BitSeq (Some (List.length bl)) s bl')
))"
fun cleanBitSeq :: " bitSequence ⇒ bitSequence " where
" cleanBitSeq (BitSeq len s bl) = ( (case len of
None => (BitSeq len s (List.rev (dropWhile ((⟷) s) (List.rev bl))))
| Some n => (BitSeq len s (List.rev (dropWhile ((⟷) s) (List.rev (List.take (n-( 1 :: nat)) bl)))))
))"
fun bitSeqTestBit :: " bitSequence ⇒ nat ⇒(bool)option " where
" bitSeqTestBit (BitSeq None s bl) pos = ( if pos < List.length bl then index bl pos else Some s )"
|" bitSeqTestBit (BitSeq(Some l) s bl) pos = ( if (pos ≥ l) then None else
if ((pos = (l -( 1 :: nat))) ∨ (pos ≥ List.length bl)) then Some s else
index bl pos )"
fun bitSeqSetBit :: " bitSequence ⇒ nat ⇒ bool ⇒ bitSequence " where
" bitSeqSetBit (BitSeq len s bl) pos v = (
(let bl' = (if (pos < List.length bl) then bl else bl @ List.replicate pos s) in
(let bl'' = (List.list_update bl' pos v) in
(let bs' = (BitSeq len s bl'') in
cleanBitSeq bs'))))"
definition resizeBitSeq :: "(nat)option ⇒ bitSequence ⇒ bitSequence " where
" resizeBitSeq new_len bs = (
(case cleanBitSeq bs of
(BitSeq len s bl) =>
(let shorten_opt = ((case (new_len, len) of
(None, _) => None
| (Some l1, None) => Some l1
| (Some l1, Some l2) =>
if (l1 < l2) then Some l1 else None
)) in
(case shorten_opt of
None => BitSeq new_len s bl
| Some l1 => (
(let bl' = (List.take l1 (bl @ [s])) in
(case dest_init bl' of
None => (BitSeq len s bl)
| Some (bl'', s') => cleanBitSeq (BitSeq new_len s' bl'')
)))
))
) )"
fun bitSeqNot :: " bitSequence ⇒ bitSequence " where
" bitSeqNot (BitSeq len s bl) = ( BitSeq len (¬ s) (List.map (λ x. ¬ x) bl))"
fun bitSeqBinopAux :: "(bool ⇒ bool ⇒ bool)⇒ bool ⇒(bool)list ⇒ bool ⇒(bool)list ⇒(bool)list " where
" bitSeqBinopAux binop s1 ([]) s2 ([]) = ( [])"
|" bitSeqBinopAux binop s1 (b1 # bl1') s2 ([]) = ( (binop b1 s2) # bitSeqBinopAux binop s1 bl1' s2 [])"
|" bitSeqBinopAux binop s1 ([]) s2 (b2 # bl2') = ( (binop s1 b2) # bitSeqBinopAux binop s1 [] s2 bl2' )"
|" bitSeqBinopAux binop s1 (b1 # bl1') s2 (b2 # bl2') = ( (binop b1 b2) # bitSeqBinopAux binop s1 bl1' s2 bl2' )"
definition bitSeqBinop :: "(bool ⇒ bool ⇒ bool)⇒ bitSequence ⇒ bitSequence ⇒ bitSequence " where
" bitSeqBinop binop bs1 bs2 = ( (
(case cleanBitSeq bs1 of
(BitSeq len1 s1 bl1) =>
(case cleanBitSeq bs2 of
(BitSeq len2 s2 bl2) =>
(let len = ((case (len1, len2) of
(Some l1, Some l2) => Some (max l1 l2)
| _ => None
)) in
(let s = (binop s1 s2) in
(let bl = (bitSeqBinopAux binop s1 bl1 s2 bl2) in
cleanBitSeq (BitSeq len s bl))))
)
)
))"
definition bitSeqAnd :: " bitSequence ⇒ bitSequence ⇒ bitSequence " where
" bitSeqAnd = ( bitSeqBinop (∧))"
definition bitSeqOr :: " bitSequence ⇒ bitSequence ⇒ bitSequence " where
" bitSeqOr = ( bitSeqBinop (∨))"
definition bitSeqXor :: " bitSequence ⇒ bitSequence ⇒ bitSequence " where
" bitSeqXor = ( bitSeqBinop (λ b1 b2. ¬ (b1 ⟷ b2)))"
fun bitSeqShiftLeft :: " bitSequence ⇒ nat ⇒ bitSequence " where
" bitSeqShiftLeft (BitSeq len s bl) n = ( cleanBitSeq (BitSeq len s (List.replicate n False @ bl)))"
definition bitSeqArithmeticShiftRight :: " bitSequence ⇒ nat ⇒ bitSequence " where
" bitSeqArithmeticShiftRight bs n = (
(case cleanBitSeq bs of
(BitSeq len s bl) =>
cleanBitSeq (BitSeq len s (List.drop n bl))
) )"
definition bitSeqLogicalShiftRight :: " bitSequence ⇒ nat ⇒ bitSequence " where
" bitSeqLogicalShiftRight bs n = (
if (n =( 0 :: nat)) then cleanBitSeq bs else
(case cleanBitSeq bs of
(BitSeq len s bl) =>
(case len of
None => cleanBitSeq (BitSeq len s (List.drop n bl))
| Some l => cleanBitSeq
(BitSeq len False ((List.drop n bl) @ List.replicate l s))
)
) )"
fun integerFromBoolListAux :: " int ⇒(bool)list ⇒ int " where
" integerFromBoolListAux (acc1 :: int) (([]) :: bool list) = ( acc1 )"
|" integerFromBoolListAux (acc1 :: int) ((True # bl') :: bool list) = ( integerFromBoolListAux ((acc1 *( 2 :: int)) +( 1 :: int)) bl' )"
|" integerFromBoolListAux (acc1 :: int) ((False # bl') :: bool list) = ( integerFromBoolListAux (acc1 *( 2 :: int)) bl' )"
fun integerFromBoolList :: " bool*(bool)list ⇒ int " where
" integerFromBoolList (sign, bl) = (
if sign then
- (integerFromBoolListAux(( 0 :: int)) (List.rev (List.map (λ x. ¬ x) bl)) +( 1 :: int))
else integerFromBoolListAux(( 0 :: int)) (List.rev bl))"
fun boolListFromNatural :: "(bool)list ⇒ nat ⇒(bool)list " where
" boolListFromNatural acc1 (remainder :: nat) = (
if (remainder >( 0 :: nat)) then
(boolListFromNatural (((remainder mod( 2 :: nat)) =( 1 :: nat)) # acc1)
(remainder div( 2 :: nat)))
else
List.rev acc1 )"
definition boolListFromInteger :: " int ⇒ bool*(bool)list " where
" boolListFromInteger (i :: int) = (
if (i <( 0 :: int)) then
(True, List.map (λ x. ¬ x) (boolListFromNatural [] (nat (abs (- (i +( 1 :: int)))))))
else
(False, boolListFromNatural [] (nat (abs i))))"
definition bitSeqFromInteger :: "(nat)option ⇒ int ⇒ bitSequence " where
" bitSeqFromInteger len_opt i = (
(let (s, bl) = (boolListFromInteger i) in
resizeBitSeq len_opt (BitSeq None s bl)))"
definition integerFromBitSeq :: " bitSequence ⇒ int " where
" integerFromBitSeq bs = (
(case cleanBitSeq bs of (BitSeq len s bl) => integerFromBoolList (s, bl) ) )"
definition bitSeqArithUnaryOp :: "(int ⇒ int)⇒ bitSequence ⇒ bitSequence " where
" bitSeqArithUnaryOp uop bs = (
(case bs of
(BitSeq len _ _) =>
bitSeqFromInteger len (uop (integerFromBitSeq bs))
) )"
definition bitSeqArithBinOp :: "(int ⇒ int ⇒ int)⇒ bitSequence ⇒ bitSequence ⇒ bitSequence " where
" bitSeqArithBinOp binop bs1 bs2 = (
(case bs1 of
(BitSeq len1 _ _) =>
(case bs2 of
(BitSeq len2 _ _) =>
(let len = ((case (len1, len2) of
(Some l1, Some l2) => Some (max l1 l2)
| _ => None
)) in
bitSeqFromInteger len
(binop (integerFromBitSeq bs1) (integerFromBitSeq bs2)))
)
) )"
definition bitSeqArithBinTest :: "(int ⇒ int ⇒ 'a)⇒ bitSequence ⇒ bitSequence ⇒ 'a " where
" bitSeqArithBinTest binop bs1 bs2 = ( binop (integerFromBitSeq bs1) (integerFromBitSeq bs2))"
definition bitSeqLess :: " bitSequence ⇒ bitSequence ⇒ bool " where
" bitSeqLess bs1 bs2 = ( bitSeqArithBinTest (<) bs1 bs2 )"
definition bitSeqLessEqual :: " bitSequence ⇒ bitSequence ⇒ bool " where
" bitSeqLessEqual bs1 bs2 = ( bitSeqArithBinTest (≤) bs1 bs2 )"
definition bitSeqGreater :: " bitSequence ⇒ bitSequence ⇒ bool " where
" bitSeqGreater bs1 bs2 = ( bitSeqArithBinTest (>) bs1 bs2 )"
definition bitSeqGreaterEqual :: " bitSequence ⇒ bitSequence ⇒ bool " where
" bitSeqGreaterEqual bs1 bs2 = ( bitSeqArithBinTest (≥) bs1 bs2 )"
definition bitSeqCompare :: " bitSequence ⇒ bitSequence ⇒ ordering " where
" bitSeqCompare bs1 bs2 = ( bitSeqArithBinTest (genericCompare (<) (=)) bs1 bs2 )"
definition instance_Basic_classes_Ord_Word_bitSequence_dict :: "(bitSequence)Ord_class " where
" instance_Basic_classes_Ord_Word_bitSequence_dict = ((|
compare_method = bitSeqCompare,
isLess_method = bitSeqLess,
isLessEqual_method = bitSeqLessEqual,
isGreater_method = bitSeqGreater,
isGreaterEqual_method = bitSeqGreaterEqual |) )"
definition bitSeqNegate :: " bitSequence ⇒ bitSequence " where
" bitSeqNegate bs = ( bitSeqArithUnaryOp (λ i. - i) bs )"
definition instance_Num_NumNegate_Word_bitSequence_dict :: "(bitSequence)NumNegate_class " where
" instance_Num_NumNegate_Word_bitSequence_dict = ((|
numNegate_method = bitSeqNegate |) )"
definition bitSeqAdd :: " bitSequence ⇒ bitSequence ⇒ bitSequence " where
" bitSeqAdd bs1 bs2 = ( bitSeqArithBinOp (+) bs1 bs2 )"
definition instance_Num_NumAdd_Word_bitSequence_dict :: "(bitSequence)NumAdd_class " where
" instance_Num_NumAdd_Word_bitSequence_dict = ((|
numAdd_method = bitSeqAdd |) )"
definition bitSeqMinus :: " bitSequence ⇒ bitSequence ⇒ bitSequence " where
" bitSeqMinus bs1 bs2 = ( bitSeqArithBinOp (-) bs1 bs2 )"
definition instance_Num_NumMinus_Word_bitSequence_dict :: "(bitSequence)NumMinus_class " where
" instance_Num_NumMinus_Word_bitSequence_dict = ((|
numMinus_method = bitSeqMinus |) )"
definition bitSeqSucc :: " bitSequence ⇒ bitSequence " where
" bitSeqSucc bs = ( bitSeqArithUnaryOp (λ n. n +( 1 :: int)) bs )"
definition instance_Num_NumSucc_Word_bitSequence_dict :: "(bitSequence)NumSucc_class " where
" instance_Num_NumSucc_Word_bitSequence_dict = ((|
succ_method = bitSeqSucc |) )"
definition bitSeqPred :: " bitSequence ⇒ bitSequence " where
" bitSeqPred bs = ( bitSeqArithUnaryOp (λ n. n -( 1 :: int)) bs )"
definition instance_Num_NumPred_Word_bitSequence_dict :: "(bitSequence)NumPred_class " where
" instance_Num_NumPred_Word_bitSequence_dict = ((|
pred_method = bitSeqPred |) )"
definition bitSeqMult :: " bitSequence ⇒ bitSequence ⇒ bitSequence " where
" bitSeqMult bs1 bs2 = ( bitSeqArithBinOp (*) bs1 bs2 )"
definition instance_Num_NumMult_Word_bitSequence_dict :: "(bitSequence)NumMult_class " where
" instance_Num_NumMult_Word_bitSequence_dict = ((|
numMult_method = bitSeqMult |) )"
definition bitSeqPow :: " bitSequence ⇒ nat ⇒ bitSequence " where
" bitSeqPow bs n = ( bitSeqArithUnaryOp (λ i . i ^ n) bs )"
definition instance_Num_NumPow_Word_bitSequence_dict :: "(bitSequence)NumPow_class " where
" instance_Num_NumPow_Word_bitSequence_dict = ((|
numPow_method = bitSeqPow |) )"
definition bitSeqDiv :: " bitSequence ⇒ bitSequence ⇒ bitSequence " where
" bitSeqDiv bs1 bs2 = ( bitSeqArithBinOp (div) bs1 bs2 )"
definition instance_Num_NumIntegerDivision_Word_bitSequence_dict :: "(bitSequence)NumIntegerDivision_class " where
" instance_Num_NumIntegerDivision_Word_bitSequence_dict = ((|
div_method = bitSeqDiv |) )"
definition instance_Num_NumDivision_Word_bitSequence_dict :: "(bitSequence)NumDivision_class " where
" instance_Num_NumDivision_Word_bitSequence_dict = ((|
numDivision_method = bitSeqDiv |) )"
definition bitSeqMod :: " bitSequence ⇒ bitSequence ⇒ bitSequence " where
" bitSeqMod bs1 bs2 = ( bitSeqArithBinOp (mod) bs1 bs2 )"
definition instance_Num_NumRemainder_Word_bitSequence_dict :: "(bitSequence)NumRemainder_class " where
" instance_Num_NumRemainder_Word_bitSequence_dict = ((|
mod_method = bitSeqMod |) )"
definition bitSeqMin :: " bitSequence ⇒ bitSequence ⇒ bitSequence " where
" bitSeqMin bs1 bs2 = ( bitSeqArithBinOp min bs1 bs2 )"
definition bitSeqMax :: " bitSequence ⇒ bitSequence ⇒ bitSequence " where
" bitSeqMax bs1 bs2 = ( bitSeqArithBinOp max bs1 bs2 )"
definition instance_Basic_classes_OrdMaxMin_Word_bitSequence_dict :: "(bitSequence)OrdMaxMin_class " where
" instance_Basic_classes_OrdMaxMin_Word_bitSequence_dict = ((|
max_method = bitSeqMax,
min_method = bitSeqMin |) )"
record 'a WordNot_class=
lnot_method ::" 'a ⇒ 'a "
record 'a WordAnd_class=
land_method ::" 'a ⇒ 'a ⇒ 'a "
record 'a WordOr_class=
lor_method ::" 'a ⇒ 'a ⇒ 'a "
record 'a WordXor_class=
lxor_method ::" 'a ⇒ 'a ⇒ 'a "
record 'a WordLsl_class=
lsl_method ::" 'a ⇒ nat ⇒ 'a "
record 'a WordLsr_class=
lsr_method ::" 'a ⇒ nat ⇒ 'a "
record 'a WordAsr_class=
asr_method ::" 'a ⇒ nat ⇒ 'a "
definition instance_Word_WordNot_Word_bitSequence_dict :: "(bitSequence)WordNot_class " where
" instance_Word_WordNot_Word_bitSequence_dict = ((|
lnot_method = bitSeqNot |) )"
definition instance_Word_WordAnd_Word_bitSequence_dict :: "(bitSequence)WordAnd_class " where
" instance_Word_WordAnd_Word_bitSequence_dict = ((|
land_method = bitSeqAnd |) )"
definition instance_Word_WordOr_Word_bitSequence_dict :: "(bitSequence)WordOr_class " where
" instance_Word_WordOr_Word_bitSequence_dict = ((|
lor_method = bitSeqOr |) )"
definition instance_Word_WordXor_Word_bitSequence_dict :: "(bitSequence)WordXor_class " where
" instance_Word_WordXor_Word_bitSequence_dict = ((|
lxor_method = bitSeqXor |) )"
definition instance_Word_WordLsl_Word_bitSequence_dict :: "(bitSequence)WordLsl_class " where
" instance_Word_WordLsl_Word_bitSequence_dict = ((|
lsl_method = bitSeqShiftLeft |) )"
definition instance_Word_WordLsr_Word_bitSequence_dict :: "(bitSequence)WordLsr_class " where
" instance_Word_WordLsr_Word_bitSequence_dict = ((|
lsr_method = bitSeqLogicalShiftRight |) )"
definition instance_Word_WordAsr_Word_bitSequence_dict :: "(bitSequence)WordAsr_class " where
" instance_Word_WordAsr_Word_bitSequence_dict = ((|
asr_method = bitSeqArithmeticShiftRight |) )"
definition instance_Word_WordNot_Num_int32_dict :: "( 32 word)WordNot_class " where
" instance_Word_WordNot_Num_int32_dict = ((|
lnot_method = (λ w. (NOT w))|) )"
definition instance_Word_WordOr_Num_int32_dict :: "( 32 word)WordOr_class " where
" instance_Word_WordOr_Num_int32_dict = ((|
lor_method = (OR)|) )"
definition instance_Word_WordXor_Num_int32_dict :: "( 32 word)WordXor_class " where
" instance_Word_WordXor_Num_int32_dict = ((|
lxor_method = (XOR)|) )"
definition instance_Word_WordAnd_Num_int32_dict :: "( 32 word)WordAnd_class " where
" instance_Word_WordAnd_Num_int32_dict = ((|
land_method = (AND)|) )"
definition instance_Word_WordLsl_Num_int32_dict :: "( 32 word)WordLsl_class " where
" instance_Word_WordLsl_Num_int32_dict = ((|
lsl_method = (<<)|) )"
definition instance_Word_WordLsr_Num_int32_dict :: "( 32 word)WordLsr_class " where
" instance_Word_WordLsr_Num_int32_dict = ((|
lsr_method = (>>)|) )"
definition instance_Word_WordAsr_Num_int32_dict :: "( 32 word)WordAsr_class " where
" instance_Word_WordAsr_Num_int32_dict = ((|
asr_method = (>>>)|) )"
definition instance_Word_WordNot_Num_int64_dict :: "( 64 word)WordNot_class " where
" instance_Word_WordNot_Num_int64_dict = ((|
lnot_method = (λ w. (NOT w))|) )"
definition instance_Word_WordOr_Num_int64_dict :: "( 64 word)WordOr_class " where
" instance_Word_WordOr_Num_int64_dict = ((|
lor_method = (OR)|) )"
definition instance_Word_WordXor_Num_int64_dict :: "( 64 word)WordXor_class " where
" instance_Word_WordXor_Num_int64_dict = ((|
lxor_method = (XOR)|) )"
definition instance_Word_WordAnd_Num_int64_dict :: "( 64 word)WordAnd_class " where
" instance_Word_WordAnd_Num_int64_dict = ((|
land_method = (AND)|) )"
definition instance_Word_WordLsl_Num_int64_dict :: "( 64 word)WordLsl_class " where
" instance_Word_WordLsl_Num_int64_dict = ((|
lsl_method = (<<)|) )"
definition instance_Word_WordLsr_Num_int64_dict :: "( 64 word)WordLsr_class " where
" instance_Word_WordLsr_Num_int64_dict = ((|
lsr_method = (>>)|) )"
definition instance_Word_WordAsr_Num_int64_dict :: "( 64 word)WordAsr_class " where
" instance_Word_WordAsr_Num_int64_dict = ((|
asr_method = (>>>)|) )"
definition defaultLnot :: "(bitSequence ⇒ 'a)⇒('a ⇒ bitSequence)⇒ 'a ⇒ 'a " where
" defaultLnot fromBitSeq toBitSeq x = ( fromBitSeq (bitSeqNegate (toBitSeq x)))"
definition defaultLand :: "(bitSequence ⇒ 'a)⇒('a ⇒ bitSequence)⇒ 'a ⇒ 'a ⇒ 'a " where
" defaultLand fromBitSeq toBitSeq x1 x2 = ( fromBitSeq (bitSeqAnd (toBitSeq x1) (toBitSeq x2)))"
definition defaultLor :: "(bitSequence ⇒ 'a)⇒('a ⇒ bitSequence)⇒ 'a ⇒ 'a ⇒ 'a " where
" defaultLor fromBitSeq toBitSeq x1 x2 = ( fromBitSeq (bitSeqOr (toBitSeq x1) (toBitSeq x2)))"
definition defaultLxor :: "(bitSequence ⇒ 'a)⇒('a ⇒ bitSequence)⇒ 'a ⇒ 'a ⇒ 'a " where
" defaultLxor fromBitSeq toBitSeq x1 x2 = ( fromBitSeq (bitSeqXor (toBitSeq x1) (toBitSeq x2)))"
definition defaultLsl :: "(bitSequence ⇒ 'a)⇒('a ⇒ bitSequence)⇒ 'a ⇒ nat ⇒ 'a " where
" defaultLsl fromBitSeq toBitSeq x n = ( fromBitSeq (bitSeqShiftLeft (toBitSeq x) n))"
definition defaultLsr :: "(bitSequence ⇒ 'a)⇒('a ⇒ bitSequence)⇒ 'a ⇒ nat ⇒ 'a " where
" defaultLsr fromBitSeq toBitSeq x n = ( fromBitSeq (bitSeqLogicalShiftRight (toBitSeq x) n))"
definition defaultAsr :: "(bitSequence ⇒ 'a)⇒('a ⇒ bitSequence)⇒ 'a ⇒ nat ⇒ 'a " where
" defaultAsr fromBitSeq toBitSeq x n = ( fromBitSeq (bitSeqArithmeticShiftRight (toBitSeq x) n))"
definition integerLnot :: " int ⇒ int " where
" integerLnot i = ( - (i +( 1 :: int)))"
definition instance_Word_WordNot_Num_integer_dict :: "(int)WordNot_class " where
" instance_Word_WordNot_Num_integer_dict = ((|
lnot_method = integerLnot |) )"
definition integerLor :: " int ⇒ int ⇒ int " where
" integerLor i1 i2 = ( defaultLor integerFromBitSeq (bitSeqFromInteger None) i1 i2 )"
definition instance_Word_WordOr_Num_integer_dict :: "(int)WordOr_class " where
" instance_Word_WordOr_Num_integer_dict = ((|
lor_method = integerLor |) )"
definition integerLxor :: " int ⇒ int ⇒ int " where
" integerLxor i1 i2 = ( defaultLxor integerFromBitSeq (bitSeqFromInteger None) i1 i2 )"
definition instance_Word_WordXor_Num_integer_dict :: "(int)WordXor_class " where
" instance_Word_WordXor_Num_integer_dict = ((|
lxor_method = integerLxor |) )"
definition integerLand :: " int ⇒ int ⇒ int " where
" integerLand i1 i2 = ( defaultLand integerFromBitSeq (bitSeqFromInteger None) i1 i2 )"
definition instance_Word_WordAnd_Num_integer_dict :: "(int)WordAnd_class " where
" instance_Word_WordAnd_Num_integer_dict = ((|
land_method = integerLand |) )"
definition integerLsl :: " int ⇒ nat ⇒ int " where
" integerLsl i n = ( defaultLsl integerFromBitSeq (bitSeqFromInteger None) i n )"
definition instance_Word_WordLsl_Num_integer_dict :: "(int)WordLsl_class " where
" instance_Word_WordLsl_Num_integer_dict = ((|
lsl_method = integerLsl |) )"
definition integerAsr :: " int ⇒ nat ⇒ int " where
" integerAsr i n = ( defaultAsr integerFromBitSeq (bitSeqFromInteger None) i n )"
definition instance_Word_WordLsr_Num_integer_dict :: "(int)WordLsr_class " where
" instance_Word_WordLsr_Num_integer_dict = ((|
lsr_method = integerAsr |) )"
definition instance_Word_WordAsr_Num_integer_dict :: "(int)WordAsr_class " where
" instance_Word_WordAsr_Num_integer_dict = ((|
asr_method = integerAsr |) )"
definition intFromBitSeq :: " bitSequence ⇒ int " where
" intFromBitSeq bs = ( (integerFromBitSeq (resizeBitSeq (Some(( 31 :: nat))) bs)))"
definition bitSeqFromInt :: " int ⇒ bitSequence " where
" bitSeqFromInt i = ( bitSeqFromInteger (Some(( 31 :: nat))) ( i))"
definition intLnot :: " int ⇒ int " where
" intLnot i = ( - (i +( 1 :: int)))"
definition instance_Word_WordNot_Num_int_dict :: "(int)WordNot_class " where
" instance_Word_WordNot_Num_int_dict = ((|
lnot_method = intLnot |) )"
definition intLor :: " int ⇒ int ⇒ int " where
" intLor i1 i2 = ( defaultLor intFromBitSeq bitSeqFromInt i1 i2 )"
definition instance_Word_WordOr_Num_int_dict :: "(int)WordOr_class " where
" instance_Word_WordOr_Num_int_dict = ((|
lor_method = intLor |) )"
definition intLxor :: " int ⇒ int ⇒ int " where
" intLxor i1 i2 = ( defaultLxor intFromBitSeq bitSeqFromInt i1 i2 )"
definition instance_Word_WordXor_Num_int_dict :: "(int)WordXor_class " where
" instance_Word_WordXor_Num_int_dict = ((|
lxor_method = intLxor |) )"
definition intLand :: " int ⇒ int ⇒ int " where
" intLand i1 i2 = ( defaultLand intFromBitSeq bitSeqFromInt i1 i2 )"
definition instance_Word_WordAnd_Num_int_dict :: "(int)WordAnd_class " where
" instance_Word_WordAnd_Num_int_dict = ((|
land_method = intLand |) )"
definition intLsl :: " int ⇒ nat ⇒ int " where
" intLsl i n = ( defaultLsl intFromBitSeq bitSeqFromInt i n )"
definition instance_Word_WordLsl_Num_int_dict :: "(int)WordLsl_class " where
" instance_Word_WordLsl_Num_int_dict = ((|
lsl_method = intLsl |) )"
definition intAsr :: " int ⇒ nat ⇒ int " where
" intAsr i n = ( defaultAsr intFromBitSeq bitSeqFromInt i n )"
definition instance_Word_WordAsr_Num_int_dict :: "(int)WordAsr_class " where
" instance_Word_WordAsr_Num_int_dict = ((|
asr_method = intAsr |) )"
definition naturalFromBitSeq :: " bitSequence ⇒ nat " where
" naturalFromBitSeq bs = ( nat (abs (integerFromBitSeq bs)))"
definition bitSeqFromNatural :: "(nat)option ⇒ nat ⇒ bitSequence " where
" bitSeqFromNatural len n = ( bitSeqFromInteger len (int n))"
definition naturalLor :: " nat ⇒ nat ⇒ nat " where
" naturalLor i1 i2 = ( defaultLor naturalFromBitSeq (bitSeqFromNatural None) i1 i2 )"
definition instance_Word_WordOr_Num_natural_dict :: "(nat)WordOr_class " where
" instance_Word_WordOr_Num_natural_dict = ((|
lor_method = naturalLor |) )"
definition naturalLxor :: " nat ⇒ nat ⇒ nat " where
" naturalLxor i1 i2 = ( defaultLxor naturalFromBitSeq (bitSeqFromNatural None) i1 i2 )"
definition instance_Word_WordXor_Num_natural_dict :: "(nat)WordXor_class " where
" instance_Word_WordXor_Num_natural_dict = ((|
lxor_method = naturalLxor |) )"
definition naturalLand :: " nat ⇒ nat ⇒ nat " where
" naturalLand i1 i2 = ( defaultLand naturalFromBitSeq (bitSeqFromNatural None) i1 i2 )"
definition instance_Word_WordAnd_Num_natural_dict :: "(nat)WordAnd_class " where
" instance_Word_WordAnd_Num_natural_dict = ((|
land_method = naturalLand |) )"
definition naturalLsl :: " nat ⇒ nat ⇒ nat " where
" naturalLsl i n = ( defaultLsl naturalFromBitSeq (bitSeqFromNatural None) i n )"
definition instance_Word_WordLsl_Num_natural_dict :: "(nat)WordLsl_class " where
" instance_Word_WordLsl_Num_natural_dict = ((|
lsl_method = naturalLsl |) )"
definition naturalAsr :: " nat ⇒ nat ⇒ nat " where
" naturalAsr i n = ( defaultAsr naturalFromBitSeq (bitSeqFromNatural None) i n )"
definition instance_Word_WordLsr_Num_natural_dict :: "(nat)WordLsr_class " where
" instance_Word_WordLsr_Num_natural_dict = ((|
lsr_method = naturalAsr |) )"
definition instance_Word_WordAsr_Num_natural_dict :: "(nat)WordAsr_class " where
" instance_Word_WordAsr_Num_natural_dict = ((|
asr_method = naturalAsr |) )"
definition natFromBitSeq :: " bitSequence ⇒ nat " where
" natFromBitSeq bs = ( (naturalFromBitSeq (resizeBitSeq (Some(( 31 :: nat))) bs)))"
definition bitSeqFromNat :: " nat ⇒ bitSequence " where
" bitSeqFromNat i = ( bitSeqFromNatural (Some(( 31 :: nat))) ( i))"
definition natLor :: " nat ⇒ nat ⇒ nat " where
" natLor i1 i2 = ( defaultLor natFromBitSeq bitSeqFromNat i1 i2 )"
definition instance_Word_WordOr_nat_dict :: "(nat)WordOr_class " where
" instance_Word_WordOr_nat_dict = ((|
lor_method = natLor |) )"
definition natLxor :: " nat ⇒ nat ⇒ nat " where
" natLxor i1 i2 = ( defaultLxor natFromBitSeq bitSeqFromNat i1 i2 )"
definition instance_Word_WordXor_nat_dict :: "(nat)WordXor_class " where
" instance_Word_WordXor_nat_dict = ((|
lxor_method = natLxor |) )"
definition natLand :: " nat ⇒ nat ⇒ nat " where
" natLand i1 i2 = ( defaultLand natFromBitSeq bitSeqFromNat i1 i2 )"
definition instance_Word_WordAnd_nat_dict :: "(nat)WordAnd_class " where
" instance_Word_WordAnd_nat_dict = ((|
land_method = natLand |) )"
definition natLsl :: " nat ⇒ nat ⇒ nat " where
" natLsl i n = ( defaultLsl natFromBitSeq bitSeqFromNat i n )"
definition instance_Word_WordLsl_nat_dict :: "(nat)WordLsl_class " where
" instance_Word_WordLsl_nat_dict = ((|
lsl_method = natLsl |) )"
definition natAsr :: " nat ⇒ nat ⇒ nat " where
" natAsr i n = ( defaultAsr natFromBitSeq bitSeqFromNat i n )"
definition instance_Word_WordAsr_nat_dict :: "(nat)WordAsr_class " where
" instance_Word_WordAsr_nat_dict = ((|
asr_method = natAsr |) )"
end