equal
deleted
inserted
replaced
24 (*Utilities*) |
24 (*Utilities*) |
25 |
25 |
26 fun mk_numeral n = HOLogic.number_of_const HOLogic.natT $ HOLogic.mk_binum n; |
26 fun mk_numeral n = HOLogic.number_of_const HOLogic.natT $ HOLogic.mk_binum n; |
27 |
27 |
28 (*Decodes a unary or binary numeral to a NATURAL NUMBER*) |
28 (*Decodes a unary or binary numeral to a NATURAL NUMBER*) |
29 fun dest_numeral (Const ("0", _)) = 0 |
29 fun dest_numeral (Const ("HOL.zero", _)) = 0 |
30 | dest_numeral (Const ("Suc", _) $ t) = 1 + dest_numeral t |
30 | dest_numeral (Const ("Suc", _) $ t) = 1 + dest_numeral t |
31 | dest_numeral (Const("Numeral.number_of", _) $ w) = |
31 | dest_numeral (Const("Numeral.number_of", _) $ w) = |
32 (IntInf.max (0, HOLogic.dest_binum w) |
32 (IntInf.max (0, HOLogic.dest_binum w) |
33 handle TERM _ => raise TERM("Nat_Numeral_Simprocs.dest_numeral:1", [w])) |
33 handle TERM _ => raise TERM("Nat_Numeral_Simprocs.dest_numeral:1", [w])) |
34 | dest_numeral t = raise TERM("Nat_Numeral_Simprocs.dest_numeral:2", [t]); |
34 | dest_numeral t = raise TERM("Nat_Numeral_Simprocs.dest_numeral:2", [t]); |