40 in Numeral_Syntax.dest_binary (bin_of tm) end; |
40 in Numeral_Syntax.dest_binary (bin_of tm) end; |
41 |
41 |
42 |
42 |
43 (*Utilities*) |
43 (*Utilities*) |
44 |
44 |
45 fun mk_numeral i = \<^const>\<open>integ_of\<close> $ mk_bin i; |
45 fun mk_numeral i = \<^Const>\<open>integ_of\<close> $ mk_bin i; |
46 |
46 |
47 fun dest_numeral \<^Const_>\<open>integ_of for w\<close> = dest_bin w |
47 fun dest_numeral \<^Const_>\<open>integ_of for w\<close> = dest_bin w |
48 | dest_numeral t = raise TERM ("dest_numeral", [t]); |
48 | dest_numeral t = raise TERM ("dest_numeral", [t]); |
49 |
49 |
50 fun find_first_numeral past (t::terms) = |
50 fun find_first_numeral past (t::terms) = |
68 fun dest_summing (pos, \<^Const_>\<open>zadd for t u\<close>, ts) = |
68 fun dest_summing (pos, \<^Const_>\<open>zadd for t u\<close>, ts) = |
69 dest_summing (pos, t, dest_summing (pos, u, ts)) |
69 dest_summing (pos, t, dest_summing (pos, u, ts)) |
70 | dest_summing (pos, \<^Const_>\<open>zdiff for t u\<close>, ts) = |
70 | dest_summing (pos, \<^Const_>\<open>zdiff for t u\<close>, ts) = |
71 dest_summing (pos, t, dest_summing (not pos, u, ts)) |
71 dest_summing (pos, t, dest_summing (not pos, u, ts)) |
72 | dest_summing (pos, t, ts) = |
72 | dest_summing (pos, t, ts) = |
73 if pos then t::ts else \<^const>\<open>zminus\<close> $ t :: ts; |
73 if pos then t::ts else \<^Const>\<open>zminus for t\<close> :: ts; |
74 |
74 |
75 fun dest_sum t = dest_summing (true, t, []); |
75 fun dest_sum t = dest_summing (true, t, []); |
76 |
76 |
77 val one = mk_numeral 1; |
77 val one = mk_numeral 1; |
78 val mk_times = FOLogic.mk_binop \<^const_name>\<open>zmult\<close>; |
78 val mk_times = FOLogic.mk_binop \<^const_name>\<open>zmult\<close>; |