author | nipkow |
Sun, 09 Apr 2006 14:47:24 +0200 | |
changeset 19378 | 6cc9ac729eb5 |
parent 19298 | 741b8138c2b3 |
child 19481 | a6205c6203ea |
permissions | -rw-r--r-- |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
1 |
(* Title: HOL/nat_simprocs.ML |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
2 |
ID: $Id$ |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
4 |
Copyright 2000 University of Cambridge |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
5 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
6 |
Simprocs for nat numerals. |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
7 |
*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
8 |
|
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14390
diff
changeset
|
9 |
val Let_number_of = thm"Let_number_of"; |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14390
diff
changeset
|
10 |
val Let_0 = thm"Let_0"; |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14390
diff
changeset
|
11 |
val Let_1 = thm"Let_1"; |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14390
diff
changeset
|
12 |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
13 |
structure Nat_Numeral_Simprocs = |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
14 |
struct |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
15 |
|
11868
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents:
11704
diff
changeset
|
16 |
(*Maps n to #n for n = 0, 1, 2*) |
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents:
11704
diff
changeset
|
17 |
val numeral_syms = |
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14369
diff
changeset
|
18 |
[nat_numeral_0_eq_0 RS sym, nat_numeral_1_eq_1 RS sym, numeral_2_eq_2 RS sym]; |
11868
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents:
11704
diff
changeset
|
19 |
val numeral_sym_ss = HOL_ss addsimps numeral_syms; |
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents:
11704
diff
changeset
|
20 |
|
13462 | 21 |
fun rename_numerals th = |
11868
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents:
11704
diff
changeset
|
22 |
simplify numeral_sym_ss (Thm.transfer (the_context ()) th); |
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents:
11704
diff
changeset
|
23 |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
24 |
(*Utilities*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
25 |
|
10693 | 26 |
fun mk_numeral n = HOLogic.number_of_const HOLogic.natT $ HOLogic.mk_bin n; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
27 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
28 |
(*Decodes a unary or binary numeral to a NATURAL NUMBER*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
29 |
fun dest_numeral (Const ("0", _)) = 0 |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
30 |
| dest_numeral (Const ("Suc", _) $ t) = 1 + dest_numeral t |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
31 |
| dest_numeral (Const("Numeral.number_of", _) $ w) = |
15965
f422f8283491
Use of IntInf.int instead of int in most numeric simprocs; avoids
paulson
parents:
15921
diff
changeset
|
32 |
(IntInf.max (0, HOLogic.dest_binum w) |
10890 | 33 |
handle TERM _ => raise TERM("Nat_Numeral_Simprocs.dest_numeral:1", [w])) |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
34 |
| dest_numeral t = raise TERM("Nat_Numeral_Simprocs.dest_numeral:2", [t]); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
35 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
36 |
fun find_first_numeral past (t::terms) = |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
37 |
((dest_numeral t, t, rev past @ terms) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
38 |
handle TERM _ => find_first_numeral (t::past) terms) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
39 |
| find_first_numeral past [] = raise TERM("find_first_numeral", []); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
40 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
41 |
val zero = mk_numeral 0; |
19233
77ca20b0ed77
renamed HOL + - * etc. to HOL.plus HOL.minus HOL.times etc.
haftmann
parents:
18708
diff
changeset
|
42 |
val mk_plus = HOLogic.mk_binop "HOL.plus"; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
43 |
|
11868
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents:
11704
diff
changeset
|
44 |
(*Thus mk_sum[t] yields t+0; longer sums don't have a trailing zero*) |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
45 |
fun mk_sum [] = zero |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
46 |
| mk_sum [t,u] = mk_plus (t, u) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
47 |
| mk_sum (t :: ts) = mk_plus (t, mk_sum ts); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
48 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
49 |
(*this version ALWAYS includes a trailing zero*) |
11868
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents:
11704
diff
changeset
|
50 |
fun long_mk_sum [] = HOLogic.zero |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
51 |
| long_mk_sum (t :: ts) = mk_plus (t, mk_sum ts); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
52 |
|
19233
77ca20b0ed77
renamed HOL + - * etc. to HOL.plus HOL.minus HOL.times etc.
haftmann
parents:
18708
diff
changeset
|
53 |
val dest_plus = HOLogic.dest_bin "HOL.plus" HOLogic.natT; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
54 |
|
11377
0f16ad464c62
Simprocs for type "nat" no longer introduce numerals unless they are already
paulson
parents:
11334
diff
changeset
|
55 |
|
0f16ad464c62
Simprocs for type "nat" no longer introduce numerals unless they are already
paulson
parents:
11334
diff
changeset
|
56 |
(** Other simproc items **) |
0f16ad464c62
Simprocs for type "nat" no longer introduce numerals unless they are already
paulson
parents:
11334
diff
changeset
|
57 |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
58 |
val trans_tac = Int_Numeral_Simprocs.trans_tac; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
59 |
|
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14390
diff
changeset
|
60 |
val bin_simps = |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14390
diff
changeset
|
61 |
[nat_numeral_0_eq_0 RS sym, nat_numeral_1_eq_1 RS sym, |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14390
diff
changeset
|
62 |
add_nat_number_of, nat_number_of_add_left, |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14390
diff
changeset
|
63 |
diff_nat_number_of, le_number_of_eq_not_less, |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14390
diff
changeset
|
64 |
mult_nat_number_of, nat_number_of_mult_left, |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14390
diff
changeset
|
65 |
less_nat_number_of, |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14390
diff
changeset
|
66 |
Let_number_of, nat_number_of] @ |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14390
diff
changeset
|
67 |
bin_arith_simps @ bin_rel_simps; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
68 |
|
13462 | 69 |
fun prep_simproc (name, pats, proc) = |
70 |
Simplifier.simproc (Theory.sign_of (the_context ())) name pats proc; |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
71 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
72 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
73 |
(*** CancelNumerals simprocs ***) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
74 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
75 |
val one = mk_numeral 1; |
19233
77ca20b0ed77
renamed HOL + - * etc. to HOL.plus HOL.minus HOL.times etc.
haftmann
parents:
18708
diff
changeset
|
76 |
val mk_times = HOLogic.mk_binop "HOL.times"; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
77 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
78 |
fun mk_prod [] = one |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
79 |
| mk_prod [t] = t |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
80 |
| mk_prod (t :: ts) = if t = one then mk_prod ts |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
81 |
else mk_times (t, mk_prod ts); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
82 |
|
19233
77ca20b0ed77
renamed HOL + - * etc. to HOL.plus HOL.minus HOL.times etc.
haftmann
parents:
18708
diff
changeset
|
83 |
val dest_times = HOLogic.dest_bin "HOL.times" HOLogic.natT; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
84 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
85 |
fun dest_prod t = |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
86 |
let val (t,u) = dest_times t |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
87 |
in dest_prod t @ dest_prod u end |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
88 |
handle TERM _ => [t]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
89 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
90 |
(*DON'T do the obvious simplifications; that would create special cases*) |
9544
f9202e219a29
added a dummy "thm list" argument to prove_conv for the new interface to
paulson
parents:
9436
diff
changeset
|
91 |
fun mk_coeff (k,t) = mk_times (mk_numeral k, t); |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
92 |
|
9544
f9202e219a29
added a dummy "thm list" argument to prove_conv for the new interface to
paulson
parents:
9436
diff
changeset
|
93 |
(*Express t as a product of (possibly) a numeral with other factors, sorted*) |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
94 |
fun dest_coeff t = |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
95 |
let val ts = sort Term.term_ord (dest_prod t) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
96 |
val (n, _, ts') = find_first_numeral [] ts |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
97 |
handle TERM _ => (1, one, ts) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
98 |
in (n, mk_prod ts') end; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
99 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
100 |
(*Find first coefficient-term THAT MATCHES u*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
101 |
fun find_first_coeff past u [] = raise TERM("find_first_coeff", []) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
102 |
| find_first_coeff past u (t::terms) = |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
103 |
let val (n,u') = dest_coeff t |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
104 |
in if u aconv u' then (n, rev past @ terms) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
105 |
else find_first_coeff (t::past) u terms |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
106 |
end |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
107 |
handle TERM _ => find_first_coeff (t::past) u terms; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
108 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
109 |
|
19298 | 110 |
(*Split up a sum into the list of its constituent terms, on the way removing any |
111 |
Sucs and counting them.*) |
|
112 |
fun dest_Suc_sum (Const ("Suc", _) $ t, (k,ts)) = dest_Suc_sum (t, (k+1,ts)) |
|
113 |
| dest_Suc_sum (t, (k,ts)) = |
|
114 |
let val (t1,t2) = dest_plus t |
|
115 |
in dest_Suc_sum (t1, dest_Suc_sum (t2, (k,ts))) end |
|
116 |
handle TERM _ => (k, t::ts); |
|
117 |
||
118 |
(*Code for testing whether numerals are already used in the goal*) |
|
119 |
fun is_numeral (Const("Numeral.number_of", _) $ w) = true |
|
120 |
| is_numeral _ = false; |
|
121 |
||
122 |
fun prod_has_numeral t = exists is_numeral (dest_prod t); |
|
123 |
||
124 |
(*The Sucs found in the term are converted to a binary numeral. If relaxed is false, |
|
125 |
an exception is raised unless the original expression contains at least one |
|
126 |
numeral in a coefficient position. This prevents nat_combine_numerals from |
|
127 |
introducing numerals to goals.*) |
|
128 |
fun dest_Sucs_sum relaxed t = |
|
129 |
let val (k,ts) = dest_Suc_sum (t,(0,[])) |
|
130 |
in |
|
131 |
if relaxed orelse exists prod_has_numeral ts then |
|
132 |
if k=0 then ts |
|
133 |
else mk_numeral (IntInf.fromInt k) :: ts |
|
134 |
else raise TERM("Nat_Numeral_Simprocs.dest_Sucs_sum", [t]) |
|
135 |
end; |
|
136 |
||
137 |
||
11868
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents:
11704
diff
changeset
|
138 |
(*Simplify 1*n and n*1 to n*) |
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents:
11704
diff
changeset
|
139 |
val add_0s = map rename_numerals [add_0, add_0_right]; |
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
13485
diff
changeset
|
140 |
val mult_1s = map rename_numerals [thm"nat_mult_1", thm"nat_mult_1_right"]; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
141 |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
11377
diff
changeset
|
142 |
(*Final simplification: cancel + and *; replace Numeral0 by 0 and Numeral1 by 1*) |
12949
b94843ffc0d1
Fixed the natxx_cancel_numerals simprocs so that they pull out Sucs and
paulson
parents:
12338
diff
changeset
|
143 |
|
b94843ffc0d1
Fixed the natxx_cancel_numerals simprocs so that they pull out Sucs and
paulson
parents:
12338
diff
changeset
|
144 |
(*And these help the simproc return False when appropriate, which helps |
b94843ffc0d1
Fixed the natxx_cancel_numerals simprocs so that they pull out Sucs and
paulson
parents:
12338
diff
changeset
|
145 |
the arith prover.*) |
13462 | 146 |
val contra_rules = [add_Suc, add_Suc_right, Zero_not_Suc, Suc_not_Zero, |
12949
b94843ffc0d1
Fixed the natxx_cancel_numerals simprocs so that they pull out Sucs and
paulson
parents:
12338
diff
changeset
|
147 |
le_0_eq]; |
b94843ffc0d1
Fixed the natxx_cancel_numerals simprocs so that they pull out Sucs and
paulson
parents:
12338
diff
changeset
|
148 |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
149 |
val simplify_meta_eq = |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
150 |
Int_Numeral_Simprocs.simplify_meta_eq |
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14369
diff
changeset
|
151 |
([nat_numeral_0_eq_0, numeral_1_eq_Suc_0, add_0, add_0_right, |
12949
b94843ffc0d1
Fixed the natxx_cancel_numerals simprocs so that they pull out Sucs and
paulson
parents:
12338
diff
changeset
|
152 |
mult_0, mult_0_right, mult_1, mult_1_right] @ contra_rules); |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
153 |
|
10536 | 154 |
|
14474
00292f6f8d13
New simplification ordering to move numerals together. Fixes a bug in the
paulson
parents:
14430
diff
changeset
|
155 |
(*Like HOL_ss but with an ordering that brings numerals to the front |
00292f6f8d13
New simplification ordering to move numerals together. Fixes a bug in the
paulson
parents:
14430
diff
changeset
|
156 |
under AC-rewriting.*) |
00292f6f8d13
New simplification ordering to move numerals together. Fixes a bug in the
paulson
parents:
14430
diff
changeset
|
157 |
val num_ss = Int_Numeral_Simprocs.num_ss; |
00292f6f8d13
New simplification ordering to move numerals together. Fixes a bug in the
paulson
parents:
14430
diff
changeset
|
158 |
|
10704 | 159 |
(*** Applying CancelNumeralsFun ***) |
10536 | 160 |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
161 |
structure CancelNumeralsCommon = |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
162 |
struct |
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14369
diff
changeset
|
163 |
val mk_sum = (fn T:typ => mk_sum) |
19298 | 164 |
val dest_sum = dest_Sucs_sum true |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
165 |
val mk_coeff = mk_coeff |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
166 |
val dest_coeff = dest_coeff |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
167 |
val find_first_coeff = find_first_coeff [] |
16973 | 168 |
val trans_tac = fn _ => trans_tac |
18328 | 169 |
|
170 |
val norm_ss1 = num_ss addsimps numeral_syms @ add_0s @ mult_1s @ |
|
171 |
[Suc_eq_add_numeral_1_left] @ add_ac |
|
172 |
val norm_ss2 = num_ss addsimps bin_simps @ add_ac @ mult_ac |
|
173 |
fun norm_tac ss = |
|
174 |
ALLGOALS (simp_tac (Simplifier.inherit_context ss norm_ss1)) |
|
175 |
THEN ALLGOALS (simp_tac (Simplifier.inherit_context ss norm_ss2)) |
|
176 |
||
177 |
val numeral_simp_ss = HOL_ss addsimps add_0s @ bin_simps; |
|
178 |
fun numeral_simp_tac ss = ALLGOALS (simp_tac (Simplifier.inherit_context ss numeral_simp_ss)); |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
179 |
val simplify_meta_eq = simplify_meta_eq |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
180 |
end; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
181 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
182 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
183 |
structure EqCancelNumerals = CancelNumeralsFun |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
184 |
(open CancelNumeralsCommon |
13485
acf39e924091
tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents:
13462
diff
changeset
|
185 |
val prove_conv = Bin_Simprocs.prove_conv |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
186 |
val mk_bal = HOLogic.mk_eq |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
187 |
val dest_bal = HOLogic.dest_bin "op =" HOLogic.natT |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
188 |
val bal_add1 = nat_eq_add_iff1 RS trans |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
189 |
val bal_add2 = nat_eq_add_iff2 RS trans |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
190 |
); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
191 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
192 |
structure LessCancelNumerals = CancelNumeralsFun |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
193 |
(open CancelNumeralsCommon |
13485
acf39e924091
tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents:
13462
diff
changeset
|
194 |
val prove_conv = Bin_Simprocs.prove_conv |
19277 | 195 |
val mk_bal = HOLogic.mk_binrel "Orderings.less" |
196 |
val dest_bal = HOLogic.dest_bin "Orderings.less" HOLogic.natT |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
197 |
val bal_add1 = nat_less_add_iff1 RS trans |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
198 |
val bal_add2 = nat_less_add_iff2 RS trans |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
199 |
); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
200 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
201 |
structure LeCancelNumerals = CancelNumeralsFun |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
202 |
(open CancelNumeralsCommon |
13485
acf39e924091
tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents:
13462
diff
changeset
|
203 |
val prove_conv = Bin_Simprocs.prove_conv |
19277 | 204 |
val mk_bal = HOLogic.mk_binrel "Orderings.less_eq" |
205 |
val dest_bal = HOLogic.dest_bin "Orderings.less_eq" HOLogic.natT |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
206 |
val bal_add1 = nat_le_add_iff1 RS trans |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
207 |
val bal_add2 = nat_le_add_iff2 RS trans |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
208 |
); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
209 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
210 |
structure DiffCancelNumerals = CancelNumeralsFun |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
211 |
(open CancelNumeralsCommon |
13485
acf39e924091
tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents:
13462
diff
changeset
|
212 |
val prove_conv = Bin_Simprocs.prove_conv |
19233
77ca20b0ed77
renamed HOL + - * etc. to HOL.plus HOL.minus HOL.times etc.
haftmann
parents:
18708
diff
changeset
|
213 |
val mk_bal = HOLogic.mk_binop "HOL.minus" |
77ca20b0ed77
renamed HOL + - * etc. to HOL.plus HOL.minus HOL.times etc.
haftmann
parents:
18708
diff
changeset
|
214 |
val dest_bal = HOLogic.dest_bin "HOL.minus" HOLogic.natT |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
215 |
val bal_add1 = nat_diff_add_eq1 RS trans |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
216 |
val bal_add2 = nat_diff_add_eq2 RS trans |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
217 |
); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
218 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
219 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
220 |
val cancel_numerals = |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
221 |
map prep_simproc |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
222 |
[("nateq_cancel_numerals", |
13462 | 223 |
["(l::nat) + m = n", "(l::nat) = m + n", |
224 |
"(l::nat) * m = n", "(l::nat) = m * n", |
|
225 |
"Suc m = n", "m = Suc n"], |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
226 |
EqCancelNumerals.proc), |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
227 |
("natless_cancel_numerals", |
13462 | 228 |
["(l::nat) + m < n", "(l::nat) < m + n", |
229 |
"(l::nat) * m < n", "(l::nat) < m * n", |
|
230 |
"Suc m < n", "m < Suc n"], |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
231 |
LessCancelNumerals.proc), |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
232 |
("natle_cancel_numerals", |
13462 | 233 |
["(l::nat) + m <= n", "(l::nat) <= m + n", |
234 |
"(l::nat) * m <= n", "(l::nat) <= m * n", |
|
235 |
"Suc m <= n", "m <= Suc n"], |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
236 |
LeCancelNumerals.proc), |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
237 |
("natdiff_cancel_numerals", |
13462 | 238 |
["((l::nat) + m) - n", "(l::nat) - (m + n)", |
239 |
"(l::nat) * m - n", "(l::nat) - m * n", |
|
240 |
"Suc m - n", "m - Suc n"], |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
241 |
DiffCancelNumerals.proc)]; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
242 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
243 |
|
10704 | 244 |
(*** Applying CombineNumeralsFun ***) |
10536 | 245 |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
246 |
structure CombineNumeralsData = |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
247 |
struct |
15965
f422f8283491
Use of IntInf.int instead of int in most numeric simprocs; avoids
paulson
parents:
15921
diff
changeset
|
248 |
val add = IntInf.+ |
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14369
diff
changeset
|
249 |
val mk_sum = (fn T:typ => long_mk_sum) (*to work for 2*x + 3*x *) |
19298 | 250 |
val dest_sum = dest_Sucs_sum false |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
251 |
val mk_coeff = mk_coeff |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
252 |
val dest_coeff = dest_coeff |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
253 |
val left_distrib = left_add_mult_distrib RS trans |
13485
acf39e924091
tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents:
13462
diff
changeset
|
254 |
val prove_conv = Bin_Simprocs.prove_conv_nohyps |
16973 | 255 |
val trans_tac = fn _ => trans_tac |
18328 | 256 |
|
257 |
val norm_ss1 = num_ss addsimps numeral_syms @ add_0s @ mult_1s @ [Suc_eq_add_numeral_1] @ add_ac |
|
258 |
val norm_ss2 = num_ss addsimps bin_simps @ add_ac @ mult_ac |
|
16973 | 259 |
fun norm_tac ss = |
18328 | 260 |
ALLGOALS (simp_tac (Simplifier.inherit_context ss norm_ss1)) |
261 |
THEN ALLGOALS (simp_tac (Simplifier.inherit_context ss norm_ss2)) |
|
262 |
||
263 |
val numeral_simp_ss = HOL_ss addsimps add_0s @ bin_simps; |
|
264 |
fun numeral_simp_tac ss = ALLGOALS (simp_tac (Simplifier.inherit_context ss numeral_simp_ss)) |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
265 |
val simplify_meta_eq = simplify_meta_eq |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
266 |
end; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
267 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
268 |
structure CombineNumerals = CombineNumeralsFun(CombineNumeralsData); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
269 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
270 |
val combine_numerals = |
13462 | 271 |
prep_simproc ("nat_combine_numerals", ["(i::nat) + j", "Suc (i + j)"], CombineNumerals.proc); |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
272 |
|
10536 | 273 |
|
10704 | 274 |
(*** Applying CancelNumeralFactorFun ***) |
10536 | 275 |
|
276 |
structure CancelNumeralFactorCommon = |
|
277 |
struct |
|
13462 | 278 |
val mk_coeff = mk_coeff |
279 |
val dest_coeff = dest_coeff |
|
16973 | 280 |
val trans_tac = fn _ => trans_tac |
18328 | 281 |
|
282 |
val norm_ss1 = num_ss addsimps |
|
283 |
numeral_syms @ add_0s @ mult_1s @ [Suc_eq_add_numeral_1_left] @ add_ac |
|
284 |
val norm_ss2 = num_ss addsimps bin_simps @ add_ac @ mult_ac |
|
16973 | 285 |
fun norm_tac ss = |
18328 | 286 |
ALLGOALS (simp_tac (Simplifier.inherit_context ss norm_ss1)) |
287 |
THEN ALLGOALS (simp_tac (Simplifier.inherit_context ss norm_ss2)) |
|
288 |
||
289 |
val numeral_simp_ss = HOL_ss addsimps bin_simps |
|
290 |
fun numeral_simp_tac ss = ALLGOALS (simp_tac (Simplifier.inherit_context ss numeral_simp_ss)) |
|
10536 | 291 |
val simplify_meta_eq = simplify_meta_eq |
292 |
end |
|
293 |
||
294 |
structure DivCancelNumeralFactor = CancelNumeralFactorFun |
|
295 |
(open CancelNumeralFactorCommon |
|
13485
acf39e924091
tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents:
13462
diff
changeset
|
296 |
val prove_conv = Bin_Simprocs.prove_conv |
10536 | 297 |
val mk_bal = HOLogic.mk_binop "Divides.op div" |
298 |
val dest_bal = HOLogic.dest_bin "Divides.op div" HOLogic.natT |
|
299 |
val cancel = nat_mult_div_cancel1 RS trans |
|
300 |
val neg_exchanges = false |
|
301 |
) |
|
302 |
||
303 |
structure EqCancelNumeralFactor = CancelNumeralFactorFun |
|
304 |
(open CancelNumeralFactorCommon |
|
13485
acf39e924091
tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents:
13462
diff
changeset
|
305 |
val prove_conv = Bin_Simprocs.prove_conv |
10536 | 306 |
val mk_bal = HOLogic.mk_eq |
307 |
val dest_bal = HOLogic.dest_bin "op =" HOLogic.natT |
|
308 |
val cancel = nat_mult_eq_cancel1 RS trans |
|
309 |
val neg_exchanges = false |
|
310 |
) |
|
311 |
||
312 |
structure LessCancelNumeralFactor = CancelNumeralFactorFun |
|
313 |
(open CancelNumeralFactorCommon |
|
13485
acf39e924091
tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents:
13462
diff
changeset
|
314 |
val prove_conv = Bin_Simprocs.prove_conv |
19277 | 315 |
val mk_bal = HOLogic.mk_binrel "Orderings.less" |
316 |
val dest_bal = HOLogic.dest_bin "Orderings.less" HOLogic.natT |
|
10536 | 317 |
val cancel = nat_mult_less_cancel1 RS trans |
318 |
val neg_exchanges = true |
|
319 |
) |
|
320 |
||
321 |
structure LeCancelNumeralFactor = CancelNumeralFactorFun |
|
322 |
(open CancelNumeralFactorCommon |
|
13485
acf39e924091
tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents:
13462
diff
changeset
|
323 |
val prove_conv = Bin_Simprocs.prove_conv |
19277 | 324 |
val mk_bal = HOLogic.mk_binrel "Orderings.less_eq" |
325 |
val dest_bal = HOLogic.dest_bin "Orderings.less_eq" HOLogic.natT |
|
10536 | 326 |
val cancel = nat_mult_le_cancel1 RS trans |
327 |
val neg_exchanges = true |
|
328 |
) |
|
329 |
||
13462 | 330 |
val cancel_numeral_factors = |
10536 | 331 |
map prep_simproc |
332 |
[("nateq_cancel_numeral_factors", |
|
13462 | 333 |
["(l::nat) * m = n", "(l::nat) = m * n"], |
10536 | 334 |
EqCancelNumeralFactor.proc), |
13462 | 335 |
("natless_cancel_numeral_factors", |
336 |
["(l::nat) * m < n", "(l::nat) < m * n"], |
|
10536 | 337 |
LessCancelNumeralFactor.proc), |
13462 | 338 |
("natle_cancel_numeral_factors", |
339 |
["(l::nat) * m <= n", "(l::nat) <= m * n"], |
|
10536 | 340 |
LeCancelNumeralFactor.proc), |
13462 | 341 |
("natdiv_cancel_numeral_factors", |
342 |
["((l::nat) * m) div n", "(l::nat) div (m * n)"], |
|
10536 | 343 |
DivCancelNumeralFactor.proc)]; |
344 |
||
10704 | 345 |
|
346 |
||
347 |
(*** Applying ExtractCommonTermFun ***) |
|
348 |
||
349 |
(*this version ALWAYS includes a trailing one*) |
|
350 |
fun long_mk_prod [] = one |
|
351 |
| long_mk_prod (t :: ts) = mk_times (t, mk_prod ts); |
|
352 |
||
353 |
(*Find first term that matches u*) |
|
18442 | 354 |
fun find_first_t past u [] = raise TERM("find_first_t", []) |
355 |
| find_first_t past u (t::terms) = |
|
13462 | 356 |
if u aconv t then (rev past @ terms) |
18442 | 357 |
else find_first_t (t::past) u terms |
358 |
handle TERM _ => find_first_t (t::past) u terms; |
|
10704 | 359 |
|
15271
3c32a26510c4
fixed some awkward problems with nat/int simprocs
paulson
parents:
14474
diff
changeset
|
360 |
(** Final simplification for the CancelFactor simprocs **) |
3c32a26510c4
fixed some awkward problems with nat/int simprocs
paulson
parents:
14474
diff
changeset
|
361 |
val simplify_one = |
3c32a26510c4
fixed some awkward problems with nat/int simprocs
paulson
parents:
14474
diff
changeset
|
362 |
Int_Numeral_Simprocs.simplify_meta_eq |
3c32a26510c4
fixed some awkward problems with nat/int simprocs
paulson
parents:
14474
diff
changeset
|
363 |
[mult_1_left, mult_1_right, div_1, numeral_1_eq_Suc_0]; |
3c32a26510c4
fixed some awkward problems with nat/int simprocs
paulson
parents:
14474
diff
changeset
|
364 |
|
16973 | 365 |
fun cancel_simplify_meta_eq cancel_th ss th = |
366 |
simplify_one ss (([th, cancel_th]) MRS trans); |
|
10704 | 367 |
|
368 |
structure CancelFactorCommon = |
|
369 |
struct |
|
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14369
diff
changeset
|
370 |
val mk_sum = (fn T:typ => long_mk_prod) |
13462 | 371 |
val dest_sum = dest_prod |
372 |
val mk_coeff = mk_coeff |
|
373 |
val dest_coeff = dest_coeff |
|
18442 | 374 |
val find_first = find_first_t [] |
16973 | 375 |
val trans_tac = fn _ => trans_tac |
18328 | 376 |
val norm_ss = HOL_ss addsimps mult_1s @ mult_ac |
377 |
fun norm_tac ss = ALLGOALS (simp_tac (Simplifier.inherit_context ss norm_ss)) |
|
10704 | 378 |
end; |
379 |
||
380 |
structure EqCancelFactor = ExtractCommonTermFun |
|
381 |
(open CancelFactorCommon |
|
13485
acf39e924091
tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents:
13462
diff
changeset
|
382 |
val prove_conv = Bin_Simprocs.prove_conv |
10704 | 383 |
val mk_bal = HOLogic.mk_eq |
384 |
val dest_bal = HOLogic.dest_bin "op =" HOLogic.natT |
|
385 |
val simplify_meta_eq = cancel_simplify_meta_eq nat_mult_eq_cancel_disj |
|
386 |
); |
|
387 |
||
388 |
structure LessCancelFactor = ExtractCommonTermFun |
|
389 |
(open CancelFactorCommon |
|
13485
acf39e924091
tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents:
13462
diff
changeset
|
390 |
val prove_conv = Bin_Simprocs.prove_conv |
19277 | 391 |
val mk_bal = HOLogic.mk_binrel "Orderings.less" |
392 |
val dest_bal = HOLogic.dest_bin "Orderings.less" HOLogic.natT |
|
10704 | 393 |
val simplify_meta_eq = cancel_simplify_meta_eq nat_mult_less_cancel_disj |
394 |
); |
|
395 |
||
396 |
structure LeCancelFactor = ExtractCommonTermFun |
|
397 |
(open CancelFactorCommon |
|
13485
acf39e924091
tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents:
13462
diff
changeset
|
398 |
val prove_conv = Bin_Simprocs.prove_conv |
19277 | 399 |
val mk_bal = HOLogic.mk_binrel "Orderings.less_eq" |
400 |
val dest_bal = HOLogic.dest_bin "Orderings.less_eq" HOLogic.natT |
|
10704 | 401 |
val simplify_meta_eq = cancel_simplify_meta_eq nat_mult_le_cancel_disj |
402 |
); |
|
403 |
||
404 |
structure DivideCancelFactor = ExtractCommonTermFun |
|
405 |
(open CancelFactorCommon |
|
13485
acf39e924091
tuned prove_conv (error reporting done within meta_simplifier.ML);
wenzelm
parents:
13462
diff
changeset
|
406 |
val prove_conv = Bin_Simprocs.prove_conv |
10704 | 407 |
val mk_bal = HOLogic.mk_binop "Divides.op div" |
408 |
val dest_bal = HOLogic.dest_bin "Divides.op div" HOLogic.natT |
|
409 |
val simplify_meta_eq = cancel_simplify_meta_eq nat_mult_div_cancel_disj |
|
410 |
); |
|
411 |
||
13462 | 412 |
val cancel_factor = |
10704 | 413 |
map prep_simproc |
414 |
[("nat_eq_cancel_factor", |
|
13462 | 415 |
["(l::nat) * m = n", "(l::nat) = m * n"], |
10704 | 416 |
EqCancelFactor.proc), |
417 |
("nat_less_cancel_factor", |
|
13462 | 418 |
["(l::nat) * m < n", "(l::nat) < m * n"], |
10704 | 419 |
LessCancelFactor.proc), |
420 |
("nat_le_cancel_factor", |
|
13462 | 421 |
["(l::nat) * m <= n", "(l::nat) <= m * n"], |
10704 | 422 |
LeCancelFactor.proc), |
13462 | 423 |
("nat_divide_cancel_factor", |
424 |
["((l::nat) * m) div n", "(l::nat) div (m * n)"], |
|
10704 | 425 |
DivideCancelFactor.proc)]; |
426 |
||
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
427 |
end; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
428 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
429 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
430 |
Addsimprocs Nat_Numeral_Simprocs.cancel_numerals; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
431 |
Addsimprocs [Nat_Numeral_Simprocs.combine_numerals]; |
10536 | 432 |
Addsimprocs Nat_Numeral_Simprocs.cancel_numeral_factors; |
10704 | 433 |
Addsimprocs Nat_Numeral_Simprocs.cancel_factor; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
434 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
435 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
436 |
(*examples: |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
437 |
print_depth 22; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
438 |
set timing; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
439 |
set trace_simp; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
440 |
fun test s = (Goal s; by (Simp_tac 1)); |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
441 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
442 |
(*cancel_numerals*) |
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
443 |
test "l +( 2) + (2) + 2 + (l + 2) + (oo + 2) = (uu::nat)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
444 |
test "(2*length xs < 2*length xs + j)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
445 |
test "(2*length xs < length xs * 2 + j)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
446 |
test "2*u = (u::nat)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
447 |
test "2*u = Suc (u)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
448 |
test "(i + j + 12 + (k::nat)) - 15 = y"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
449 |
test "(i + j + 12 + (k::nat)) - 5 = y"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
450 |
test "Suc u - 2 = y"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
451 |
test "Suc (Suc (Suc u)) - 2 = y"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
452 |
test "(i + j + 2 + (k::nat)) - 1 = y"; |
11868
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents:
11704
diff
changeset
|
453 |
test "(i + j + 1 + (k::nat)) - 2 = y"; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
454 |
|
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
455 |
test "(2*x + (u*v) + y) - v*3*u = (w::nat)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
456 |
test "(2*x*u*v + 5 + (u*v)*4 + y) - v*u*4 = (w::nat)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
457 |
test "(2*x*u*v + (u*v)*4 + y) - v*u = (w::nat)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
458 |
test "Suc (Suc (2*x*u*v + u*4 + y)) - u = w"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
459 |
test "Suc ((u*v)*4) - v*3*u = w"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
460 |
test "Suc (Suc ((u*v)*3)) - v*3*u = w"; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
461 |
|
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
462 |
test "(i + j + 12 + (k::nat)) = u + 15 + y"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
463 |
test "(i + j + 32 + (k::nat)) - (u + 15 + y) = zz"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
464 |
test "(i + j + 12 + (k::nat)) = u + 5 + y"; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
465 |
(*Suc*) |
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
466 |
test "(i + j + 12 + k) = Suc (u + y)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
467 |
test "Suc (Suc (Suc (Suc (Suc (u + y))))) <= ((i + j) + 41 + k)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
468 |
test "(i + j + 5 + k) < Suc (Suc (Suc (Suc (Suc (u + y)))))"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
469 |
test "Suc (Suc (Suc (Suc (Suc (u + y))))) - 5 = v"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
470 |
test "(i + j + 5 + k) = Suc (Suc (Suc (Suc (Suc (Suc (Suc (u + y)))))))"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
471 |
test "2*y + 3*z + 2*u = Suc (u)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
472 |
test "2*y + 3*z + 6*w + 2*y + 3*z + 2*u = Suc (u)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
473 |
test "2*y + 3*z + 6*w + 2*y + 3*z + 2*u = 2*y' + 3*z' + 6*w' + 2*y' + 3*z' + u + (vv::nat)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
474 |
test "6 + 2*y + 3*z + 4*u = Suc (vv + 2*u + z)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
475 |
test "(2*n*m) < (3*(m*n)) + (u::nat)"; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
476 |
|
14474
00292f6f8d13
New simplification ordering to move numerals together. Fixes a bug in the
paulson
parents:
14430
diff
changeset
|
477 |
test "(Suc (Suc (Suc (Suc (Suc (Suc (case length (f c) of 0 => 0 | Suc k => k)))))) <= Suc 0)"; |
00292f6f8d13
New simplification ordering to move numerals together. Fixes a bug in the
paulson
parents:
14430
diff
changeset
|
478 |
|
00292f6f8d13
New simplification ordering to move numerals together. Fixes a bug in the
paulson
parents:
14430
diff
changeset
|
479 |
test "Suc (Suc (Suc (Suc (Suc (Suc (length l1 + length l2)))))) <= length l1"; |
00292f6f8d13
New simplification ordering to move numerals together. Fixes a bug in the
paulson
parents:
14430
diff
changeset
|
480 |
|
00292f6f8d13
New simplification ordering to move numerals together. Fixes a bug in the
paulson
parents:
14430
diff
changeset
|
481 |
test "( (Suc (Suc (Suc (Suc (Suc (length (compT P E A ST mxr e) + length l3)))))) <= length (compT P E A ST mxr e))"; |
00292f6f8d13
New simplification ordering to move numerals together. Fixes a bug in the
paulson
parents:
14430
diff
changeset
|
482 |
|
00292f6f8d13
New simplification ordering to move numerals together. Fixes a bug in the
paulson
parents:
14430
diff
changeset
|
483 |
test "( (Suc (Suc (Suc (Suc (Suc (length (compT P E A ST mxr e) + length (compT P E (A Un \<A> e) ST mxr c))))))) <= length (compT P E A ST mxr e))"; |
00292f6f8d13
New simplification ordering to move numerals together. Fixes a bug in the
paulson
parents:
14430
diff
changeset
|
484 |
|
00292f6f8d13
New simplification ordering to move numerals together. Fixes a bug in the
paulson
parents:
14430
diff
changeset
|
485 |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
486 |
(*negative numerals: FAIL*) |
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
487 |
test "(i + j + -23 + (k::nat)) < u + 15 + y"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
488 |
test "(i + j + 3 + (k::nat)) < u + -15 + y"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
489 |
test "(i + j + -12 + (k::nat)) - 15 = y"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
490 |
test "(i + j + 12 + (k::nat)) - -15 = y"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
491 |
test "(i + j + -12 + (k::nat)) - -15 = y"; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
492 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
493 |
(*combine_numerals*) |
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
494 |
test "k + 3*k = (u::nat)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
495 |
test "Suc (i + 3) = u"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
496 |
test "Suc (i + j + 3 + k) = u"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
497 |
test "k + j + 3*k + j = (u::nat)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
498 |
test "Suc (j*i + i + k + 5 + 3*k + i*j*4) = (u::nat)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
499 |
test "(2*n*m) + (3*(m*n)) = (u::nat)"; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
500 |
(*negative numerals: FAIL*) |
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
501 |
test "Suc (i + j + -3 + k) = u"; |
10536 | 502 |
|
10704 | 503 |
(*cancel_numeral_factors*) |
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
504 |
test "9*x = 12 * (y::nat)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
505 |
test "(9*x) div (12 * (y::nat)) = z"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
506 |
test "9*x < 12 * (y::nat)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
507 |
test "9*x <= 12 * (y::nat)"; |
10704 | 508 |
|
509 |
(*cancel_factor*) |
|
510 |
test "x*k = k*(y::nat)"; |
|
13462 | 511 |
test "k = k*(y::nat)"; |
10704 | 512 |
test "a*(b*c) = (b::nat)"; |
513 |
test "a*(b*c) = d*(b::nat)*(x*a)"; |
|
514 |
||
515 |
test "x*k < k*(y::nat)"; |
|
13462 | 516 |
test "k < k*(y::nat)"; |
10704 | 517 |
test "a*(b*c) < (b::nat)"; |
518 |
test "a*(b*c) < d*(b::nat)*(x*a)"; |
|
519 |
||
520 |
test "x*k <= k*(y::nat)"; |
|
13462 | 521 |
test "k <= k*(y::nat)"; |
10704 | 522 |
test "a*(b*c) <= (b::nat)"; |
523 |
test "a*(b*c) <= d*(b::nat)*(x*a)"; |
|
524 |
||
525 |
test "(x*k) div (k*(y::nat)) = (uu::nat)"; |
|
13462 | 526 |
test "(k) div (k*(y::nat)) = (uu::nat)"; |
10704 | 527 |
test "(a*(b*c)) div ((b::nat)) = (uu::nat)"; |
528 |
test "(a*(b*c)) div (d*(b::nat)*(x*a)) = (uu::nat)"; |
|
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
529 |
*) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
530 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
531 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
532 |
(*** Prepare linear arithmetic for nat numerals ***) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
533 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
534 |
local |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
535 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
536 |
(* reduce contradictory <= to False *) |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
537 |
val add_rules = |
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14390
diff
changeset
|
538 |
[thm "Let_number_of", Let_0, Let_1, nat_0, nat_1, |
11868
56db9f3a6b3e
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents:
11704
diff
changeset
|
539 |
add_nat_number_of, diff_nat_number_of, mult_nat_number_of, |
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14273
diff
changeset
|
540 |
eq_nat_number_of, less_nat_number_of, le_number_of_eq_not_less, |
11296 | 541 |
le_Suc_number_of,le_number_of_Suc, |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
542 |
less_Suc_number_of,less_number_of_Suc, |
11296 | 543 |
Suc_eq_number_of,eq_number_of_Suc, |
14369 | 544 |
mult_Suc, mult_Suc_right, |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
545 |
eq_number_of_0, eq_0_number_of, less_0_number_of, |
14390 | 546 |
of_int_number_of_eq, of_nat_number_of_eq, nat_number_of, if_True, if_False]; |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
547 |
|
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14369
diff
changeset
|
548 |
val simprocs = [Nat_Numeral_Simprocs.combine_numerals]@ |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
549 |
Nat_Numeral_Simprocs.cancel_numerals; |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
550 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
551 |
in |
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
552 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
553 |
val nat_simprocs_setup = |
18708 | 554 |
Fast_Arith.map_data (fn {add_mono_thms, mult_mono_thms, inj_thms, lessD, neqE, simpset} => |
10693 | 555 |
{add_mono_thms = add_mono_thms, mult_mono_thms = mult_mono_thms, |
15921 | 556 |
inj_thms = inj_thms, lessD = lessD, neqE = neqE, |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
557 |
simpset = simpset addsimps add_rules |
18708 | 558 |
addsimprocs simprocs}); |
9436
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
559 |
|
62bb04ab4b01
rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents:
diff
changeset
|
560 |
end; |