src/HOL/ex/Binary.thy
changeset 22997 d4f3b015b50b
parent 22229 8e127313ed55
child 24227 9b226b56e9a9
equal deleted inserted replaced
22996:5f82c5f8478e 22997:d4f3b015b50b
    23 ML {*
    23 ML {*
    24   fun dest_bit (Const ("False", _)) = 0
    24   fun dest_bit (Const ("False", _)) = 0
    25     | dest_bit (Const ("True", _)) = 1
    25     | dest_bit (Const ("True", _)) = 1
    26     | dest_bit t = raise TERM ("dest_bit", [t]);
    26     | dest_bit t = raise TERM ("dest_bit", [t]);
    27 
    27 
    28   fun dest_binary (Const ("HOL.zero", Type ("nat", _))) = 0
    28   fun dest_binary (Const (@{const_name HOL.zero}, Type ("nat", _))) = 0
    29     | dest_binary (Const ("HOL.one", Type ("nat", _))) = 1
    29     | dest_binary (Const (@{const_name HOL.one}, Type ("nat", _))) = 1
    30     | dest_binary (Const ("Binary.bit", _) $ bs $ b) =
    30     | dest_binary (Const ("Binary.bit", _) $ bs $ b) =
    31         2 * dest_binary bs + IntInf.fromInt (dest_bit b)
    31         2 * dest_binary bs + IntInf.fromInt (dest_bit b)
    32     | dest_binary t = raise TERM ("dest_binary", [t]);
    32     | dest_binary t = raise TERM ("dest_binary", [t]);
    33 
    33 
    34   fun mk_bit 0 = @{term False}
    34   fun mk_bit 0 = @{term False}