author | paulson |
Mon, 21 May 2001 14:52:27 +0200 | |
changeset 11321 | 01cbbf33779b |
parent 10716 | 01aec27d4c45 |
child 12089 | 34e7693271a9 |
permissions | -rw-r--r-- |
9570 | 1 |
(* Title: ZF/Integ/int_arith.ML |
2 |
ID: $Id$ |
|
3 |
Author: Larry Paulson |
|
4 |
Copyright 2000 University of Cambridge |
|
5 |
||
6 |
Simprocs for linear arithmetic. |
|
7 |
*) |
|
8 |
||
11321 | 9 |
|
10 |
(** To simplify inequalities involving integer negation and literals, |
|
11 |
such as -x = #3 |
|
12 |
**) |
|
13 |
||
14 |
Addsimps [inst "y" "integ_of(?w)" zminus_equation, |
|
15 |
inst "x" "integ_of(?w)" equation_zminus]; |
|
16 |
||
17 |
AddIffs [inst "y" "integ_of(?w)" zminus_zless, |
|
18 |
inst "x" "integ_of(?w)" zless_zminus]; |
|
19 |
||
20 |
AddIffs [inst "y" "integ_of(?w)" zminus_zle, |
|
21 |
inst "x" "integ_of(?w)" zle_zminus]; |
|
22 |
||
23 |
Addsimps [inst "s" "integ_of(?w)" Let_def]; |
|
24 |
||
9570 | 25 |
(*** Simprocs for numeric literals ***) |
26 |
||
27 |
(** Combining of literal coefficients in sums of products **) |
|
28 |
||
29 |
Goal "(x $< y) <-> (x$-y $< #0)"; |
|
30 |
by (simp_tac (simpset() addsimps zcompare_rls) 1); |
|
31 |
qed "zless_iff_zdiff_zless_0"; |
|
32 |
||
33 |
Goal "[| x: int; y: int |] ==> (x = y) <-> (x$-y = #0)"; |
|
34 |
by (asm_simp_tac (simpset() addsimps zcompare_rls) 1); |
|
35 |
qed "eq_iff_zdiff_eq_0"; |
|
36 |
||
37 |
Goal "(x $<= y) <-> (x$-y $<= #0)"; |
|
38 |
by (asm_simp_tac (simpset() addsimps zcompare_rls) 1); |
|
39 |
qed "zle_iff_zdiff_zle_0"; |
|
40 |
||
41 |
||
42 |
(** For combine_numerals **) |
|
43 |
||
44 |
Goal "i$*u $+ (j$*u $+ k) = (i$+j)$*u $+ k"; |
|
45 |
by (simp_tac (simpset() addsimps [zadd_zmult_distrib]@zadd_ac) 1); |
|
46 |
qed "left_zadd_zmult_distrib"; |
|
47 |
||
48 |
||
49 |
(** For cancel_numerals **) |
|
50 |
||
51 |
val rel_iff_rel_0_rls = map (inst "y" "?u$+?v") |
|
52 |
[zless_iff_zdiff_zless_0, eq_iff_zdiff_eq_0, |
|
53 |
zle_iff_zdiff_zle_0] @ |
|
54 |
map (inst "y" "n") |
|
55 |
[zless_iff_zdiff_zless_0, eq_iff_zdiff_eq_0, |
|
56 |
zle_iff_zdiff_zle_0]; |
|
57 |
||
58 |
Goal "(i$*u $+ m = j$*u $+ n) <-> ((i$-j)$*u $+ m = intify(n))"; |
|
59 |
by (simp_tac (simpset() addsimps [zdiff_def, zadd_zmult_distrib]) 1); |
|
60 |
by (simp_tac (simpset() addsimps zcompare_rls) 1); |
|
61 |
by (simp_tac (simpset() addsimps zadd_ac) 1); |
|
62 |
qed "eq_add_iff1"; |
|
63 |
||
64 |
Goal "(i$*u $+ m = j$*u $+ n) <-> (intify(m) = (j$-i)$*u $+ n)"; |
|
65 |
by (simp_tac (simpset() addsimps [zdiff_def, zadd_zmult_distrib]) 1); |
|
66 |
by (simp_tac (simpset() addsimps zcompare_rls) 1); |
|
67 |
by (simp_tac (simpset() addsimps zadd_ac) 1); |
|
68 |
qed "eq_add_iff2"; |
|
69 |
||
70 |
Goal "(i$*u $+ m $< j$*u $+ n) <-> ((i$-j)$*u $+ m $< n)"; |
|
71 |
by (asm_simp_tac (simpset() addsimps [zdiff_def, zadd_zmult_distrib]@ |
|
72 |
zadd_ac@rel_iff_rel_0_rls) 1); |
|
73 |
qed "less_add_iff1"; |
|
74 |
||
75 |
Goal "(i$*u $+ m $< j$*u $+ n) <-> (m $< (j$-i)$*u $+ n)"; |
|
76 |
by (asm_simp_tac (simpset() addsimps [zdiff_def, zadd_zmult_distrib]@ |
|
77 |
zadd_ac@rel_iff_rel_0_rls) 1); |
|
78 |
qed "less_add_iff2"; |
|
79 |
||
80 |
Goal "(i$*u $+ m $<= j$*u $+ n) <-> ((i$-j)$*u $+ m $<= intify(n))"; |
|
81 |
by (simp_tac (simpset() addsimps [zdiff_def, zadd_zmult_distrib]) 1); |
|
82 |
by (simp_tac (simpset() addsimps zcompare_rls) 1); |
|
83 |
by (simp_tac (simpset() addsimps zadd_ac) 1); |
|
84 |
qed "le_add_iff1"; |
|
85 |
||
86 |
Goal "(i$*u $+ m $<= j$*u $+ n) <-> (intify(m) $<= (j$-i)$*u $+ n)"; |
|
87 |
by (simp_tac (simpset() addsimps [zdiff_def, zadd_zmult_distrib]) 1); |
|
88 |
by (simp_tac (simpset() addsimps zcompare_rls) 1); |
|
89 |
by (simp_tac (simpset() addsimps zadd_ac) 1); |
|
90 |
qed "le_add_iff2"; |
|
91 |
||
92 |
||
93 |
structure Int_Numeral_Simprocs = |
|
94 |
struct |
|
95 |
||
96 |
(*Utilities*) |
|
97 |
||
98 |
val integ_of_const = Const ("Bin.integ_of", iT --> iT); |
|
99 |
||
100 |
fun mk_numeral n = integ_of_const $ NumeralSyntax.mk_bin n; |
|
101 |
||
102 |
(*Decodes a binary INTEGER*) |
|
103 |
fun dest_numeral (Const("Bin.integ_of", _) $ w) = |
|
104 |
(NumeralSyntax.dest_bin w |
|
105 |
handle Match => raise TERM("Int_Numeral_Simprocs.dest_numeral:1", [w])) |
|
106 |
| dest_numeral t = raise TERM("Int_Numeral_Simprocs.dest_numeral:2", [t]); |
|
107 |
||
108 |
fun find_first_numeral past (t::terms) = |
|
109 |
((dest_numeral t, rev past @ terms) |
|
110 |
handle TERM _ => find_first_numeral (t::past) terms) |
|
111 |
| find_first_numeral past [] = raise TERM("find_first_numeral", []); |
|
112 |
||
113 |
val zero = mk_numeral 0; |
|
114 |
val mk_plus = FOLogic.mk_binop "Int.zadd"; |
|
115 |
||
116 |
val iT = Ind_Syntax.iT; |
|
117 |
||
118 |
val zminus_const = Const ("Int.zminus", iT --> iT); |
|
119 |
||
120 |
(*Thus mk_sum[t] yields t+#0; longer sums don't have a trailing zero*) |
|
121 |
fun mk_sum [] = zero |
|
122 |
| mk_sum [t,u] = mk_plus (t, u) |
|
123 |
| mk_sum (t :: ts) = mk_plus (t, mk_sum ts); |
|
124 |
||
125 |
(*this version ALWAYS includes a trailing zero*) |
|
126 |
fun long_mk_sum [] = zero |
|
127 |
| long_mk_sum (t :: ts) = mk_plus (t, mk_sum ts); |
|
128 |
||
129 |
val dest_plus = FOLogic.dest_bin "Int.zadd" iT; |
|
130 |
||
131 |
(*decompose additions AND subtractions as a sum*) |
|
132 |
fun dest_summing (pos, Const ("Int.zadd", _) $ t $ u, ts) = |
|
133 |
dest_summing (pos, t, dest_summing (pos, u, ts)) |
|
134 |
| dest_summing (pos, Const ("Int.zdiff", _) $ t $ u, ts) = |
|
135 |
dest_summing (pos, t, dest_summing (not pos, u, ts)) |
|
136 |
| dest_summing (pos, t, ts) = |
|
137 |
if pos then t::ts else zminus_const$t :: ts; |
|
138 |
||
139 |
fun dest_sum t = dest_summing (true, t, []); |
|
140 |
||
141 |
val mk_diff = FOLogic.mk_binop "Int.zdiff"; |
|
142 |
val dest_diff = FOLogic.dest_bin "Int.zdiff" iT; |
|
143 |
||
144 |
val one = mk_numeral 1; |
|
145 |
val mk_times = FOLogic.mk_binop "Int.zmult"; |
|
146 |
||
147 |
fun mk_prod [] = one |
|
148 |
| mk_prod [t] = t |
|
149 |
| mk_prod (t :: ts) = if t = one then mk_prod ts |
|
150 |
else mk_times (t, mk_prod ts); |
|
151 |
||
152 |
val dest_times = FOLogic.dest_bin "Int.zmult" iT; |
|
153 |
||
154 |
fun dest_prod t = |
|
155 |
let val (t,u) = dest_times t |
|
156 |
in dest_prod t @ dest_prod u end |
|
157 |
handle TERM _ => [t]; |
|
158 |
||
159 |
(*DON'T do the obvious simplifications; that would create special cases*) |
|
160 |
fun mk_coeff (k, t) = mk_times (mk_numeral k, t); |
|
161 |
||
162 |
(*Express t as a product of (possibly) a numeral with other sorted terms*) |
|
163 |
fun dest_coeff sign (Const ("Int.zminus", _) $ t) = dest_coeff (~sign) t |
|
164 |
| dest_coeff sign t = |
|
165 |
let val ts = sort Term.term_ord (dest_prod t) |
|
166 |
val (n, ts') = find_first_numeral [] ts |
|
167 |
handle TERM _ => (1, ts) |
|
168 |
in (sign*n, mk_prod ts') end; |
|
169 |
||
170 |
(*Find first coefficient-term THAT MATCHES u*) |
|
171 |
fun find_first_coeff past u [] = raise TERM("find_first_coeff", []) |
|
172 |
| find_first_coeff past u (t::terms) = |
|
173 |
let val (n,u') = dest_coeff 1 t |
|
174 |
in if u aconv u' then (n, rev past @ terms) |
|
175 |
else find_first_coeff (t::past) u terms |
|
176 |
end |
|
177 |
handle TERM _ => find_first_coeff (t::past) u terms; |
|
178 |
||
179 |
||
180 |
(*Simplify #1*n and n*#1 to n*) |
|
181 |
val add_0s = [zadd_0_intify, zadd_0_right_intify]; |
|
182 |
||
183 |
val mult_1s = [zmult_1_intify, zmult_1_right_intify, |
|
184 |
zmult_minus1, zmult_minus1_right]; |
|
185 |
||
186 |
val tc_rules = [integ_of_type, intify_in_int, |
|
9648
35d761c7d934
better rules for cancellation of common factors across comparisons
paulson
parents:
9576
diff
changeset
|
187 |
int_of_type, zadd_type, zdiff_type, zmult_type] @ bin.intrs; |
9570 | 188 |
val intifys = [intify_ident, zadd_intify1, zadd_intify2, |
189 |
zdiff_intify1, zdiff_intify2, zmult_intify1, zmult_intify2, |
|
190 |
zless_intify1, zless_intify2, zle_intify1, zle_intify2]; |
|
191 |
||
192 |
(*To perform binary arithmetic*) |
|
193 |
val bin_simps = [add_integ_of_left] @ bin_arith_simps @ bin_rel_simps; |
|
194 |
||
195 |
(*To evaluate binary negations of coefficients*) |
|
196 |
val zminus_simps = NCons_simps @ |
|
197 |
[integ_of_minus RS sym, |
|
198 |
bin_minus_1, bin_minus_0, bin_minus_Pls, bin_minus_Min, |
|
199 |
bin_pred_1, bin_pred_0, bin_pred_Pls, bin_pred_Min]; |
|
200 |
||
201 |
(*To let us treat subtraction as addition*) |
|
202 |
val diff_simps = [zdiff_def, zminus_zadd_distrib, zminus_zminus]; |
|
203 |
||
10716 | 204 |
(*push the unary minus down: - x * y = x * - y *) |
205 |
val int_minus_mult_eq_1_to_2 = |
|
206 |
[zmult_zminus, zmult_zminus_right RS sym] MRS trans |> standard; |
|
207 |
||
208 |
(*to extract again any uncancelled minuses*) |
|
209 |
val int_minus_from_mult_simps = |
|
210 |
[zminus_zminus, zmult_zminus, zmult_zminus_right]; |
|
211 |
||
212 |
(*combine unary minus with numeric literals, however nested within a product*) |
|
213 |
val int_mult_minus_simps = |
|
214 |
[zmult_assoc, zmult_zminus RS sym, int_minus_mult_eq_1_to_2]; |
|
215 |
||
9570 | 216 |
fun prep_simproc (name, pats, proc) = Simplifier.mk_simproc name pats proc; |
217 |
fun prep_pat s = Thm.read_cterm (Theory.sign_of (the_context ())) |
|
218 |
(s, TypeInfer.anyT ["logic"]); |
|
219 |
val prep_pats = map prep_pat; |
|
220 |
||
221 |
structure CancelNumeralsCommon = |
|
222 |
struct |
|
223 |
val mk_sum = mk_sum |
|
224 |
val dest_sum = dest_sum |
|
225 |
val mk_coeff = mk_coeff |
|
226 |
val dest_coeff = dest_coeff 1 |
|
227 |
val find_first_coeff = find_first_coeff [] |
|
228 |
val trans_tac = ArithData.gen_trans_tac iff_trans |
|
229 |
val norm_tac_ss1 = ZF_ss addsimps add_0s@mult_1s@diff_simps@ |
|
230 |
zminus_simps@zadd_ac |
|
10716 | 231 |
val norm_tac_ss2 = ZF_ss addsimps bin_simps@int_mult_minus_simps@intifys |
232 |
val norm_tac_ss3 = ZF_ss addsimps int_minus_from_mult_simps@ |
|
233 |
zadd_ac@zmult_ac@tc_rules@intifys |
|
9570 | 234 |
val norm_tac = ALLGOALS (asm_simp_tac norm_tac_ss1) |
235 |
THEN ALLGOALS (asm_simp_tac norm_tac_ss2) |
|
10716 | 236 |
THEN ALLGOALS (asm_simp_tac norm_tac_ss3) |
9648
35d761c7d934
better rules for cancellation of common factors across comparisons
paulson
parents:
9576
diff
changeset
|
237 |
val numeral_simp_tac = |
35d761c7d934
better rules for cancellation of common factors across comparisons
paulson
parents:
9576
diff
changeset
|
238 |
ALLGOALS (simp_tac (ZF_ss addsimps add_0s@bin_simps@tc_rules@intifys)) |
9570 | 239 |
val simplify_meta_eq = ArithData.simplify_meta_eq (add_0s@mult_1s) |
240 |
end; |
|
241 |
||
242 |
||
243 |
structure EqCancelNumerals = CancelNumeralsFun |
|
244 |
(open CancelNumeralsCommon |
|
245 |
val prove_conv = ArithData.prove_conv "inteq_cancel_numerals" |
|
246 |
val mk_bal = FOLogic.mk_eq |
|
9648
35d761c7d934
better rules for cancellation of common factors across comparisons
paulson
parents:
9576
diff
changeset
|
247 |
val dest_bal = FOLogic.dest_eq |
9570 | 248 |
val bal_add1 = eq_add_iff1 RS iff_trans |
249 |
val bal_add2 = eq_add_iff2 RS iff_trans |
|
250 |
); |
|
251 |
||
252 |
structure LessCancelNumerals = CancelNumeralsFun |
|
253 |
(open CancelNumeralsCommon |
|
254 |
val prove_conv = ArithData.prove_conv "intless_cancel_numerals" |
|
255 |
val mk_bal = FOLogic.mk_binrel "Int.zless" |
|
256 |
val dest_bal = FOLogic.dest_bin "Int.zless" iT |
|
257 |
val bal_add1 = less_add_iff1 RS iff_trans |
|
258 |
val bal_add2 = less_add_iff2 RS iff_trans |
|
259 |
); |
|
260 |
||
261 |
structure LeCancelNumerals = CancelNumeralsFun |
|
262 |
(open CancelNumeralsCommon |
|
263 |
val prove_conv = ArithData.prove_conv "intle_cancel_numerals" |
|
264 |
val mk_bal = FOLogic.mk_binrel "Int.zle" |
|
265 |
val dest_bal = FOLogic.dest_bin "Int.zle" iT |
|
266 |
val bal_add1 = le_add_iff1 RS iff_trans |
|
267 |
val bal_add2 = le_add_iff2 RS iff_trans |
|
268 |
); |
|
269 |
||
270 |
val cancel_numerals = |
|
271 |
map prep_simproc |
|
272 |
[("inteq_cancel_numerals", |
|
273 |
prep_pats ["l $+ m = n", "l = m $+ n", |
|
274 |
"l $- m = n", "l = m $- n", |
|
275 |
"l $* m = n", "l = m $* n"], |
|
276 |
EqCancelNumerals.proc), |
|
277 |
("intless_cancel_numerals", |
|
278 |
prep_pats ["l $+ m $< n", "l $< m $+ n", |
|
279 |
"l $- m $< n", "l $< m $- n", |
|
280 |
"l $* m $< n", "l $< m $* n"], |
|
281 |
LessCancelNumerals.proc), |
|
282 |
("intle_cancel_numerals", |
|
283 |
prep_pats ["l $+ m $<= n", "l $<= m $+ n", |
|
284 |
"l $- m $<= n", "l $<= m $- n", |
|
285 |
"l $* m $<= n", "l $<= m $* n"], |
|
286 |
LeCancelNumerals.proc)]; |
|
287 |
||
288 |
||
289 |
(*version without the hyps argument*) |
|
290 |
fun prove_conv_nohyps name tacs sg = ArithData.prove_conv name tacs sg []; |
|
291 |
||
292 |
structure CombineNumeralsData = |
|
293 |
struct |
|
294 |
val add = op + : int*int -> int |
|
295 |
val mk_sum = long_mk_sum (*to work for e.g. #2*x $+ #3*x *) |
|
296 |
val dest_sum = dest_sum |
|
297 |
val mk_coeff = mk_coeff |
|
298 |
val dest_coeff = dest_coeff 1 |
|
299 |
val left_distrib = left_zadd_zmult_distrib RS trans |
|
300 |
val prove_conv = prove_conv_nohyps "int_combine_numerals" |
|
301 |
val trans_tac = ArithData.gen_trans_tac trans |
|
302 |
val norm_tac_ss1 = ZF_ss addsimps add_0s@mult_1s@diff_simps@ |
|
303 |
zminus_simps@zadd_ac |
|
10716 | 304 |
val norm_tac_ss2 = ZF_ss addsimps bin_simps@int_mult_minus_simps@intifys |
305 |
val norm_tac_ss3 = ZF_ss addsimps int_minus_from_mult_simps@ |
|
306 |
zadd_ac@zmult_ac@tc_rules@intifys |
|
9570 | 307 |
val norm_tac = ALLGOALS (asm_simp_tac norm_tac_ss1) |
308 |
THEN ALLGOALS (asm_simp_tac norm_tac_ss2) |
|
10716 | 309 |
THEN ALLGOALS (asm_simp_tac norm_tac_ss3) |
9648
35d761c7d934
better rules for cancellation of common factors across comparisons
paulson
parents:
9576
diff
changeset
|
310 |
val numeral_simp_tac = |
35d761c7d934
better rules for cancellation of common factors across comparisons
paulson
parents:
9576
diff
changeset
|
311 |
ALLGOALS (simp_tac (ZF_ss addsimps add_0s@bin_simps@tc_rules@intifys)) |
9570 | 312 |
val simplify_meta_eq = ArithData.simplify_meta_eq (add_0s@mult_1s) |
313 |
end; |
|
314 |
||
315 |
structure CombineNumerals = CombineNumeralsFun(CombineNumeralsData); |
|
316 |
||
317 |
val combine_numerals = |
|
318 |
prep_simproc ("int_combine_numerals", |
|
319 |
prep_pats ["i $+ j", "i $- j"], |
|
320 |
CombineNumerals.proc); |
|
321 |
||
322 |
||
323 |
||
324 |
(** Constant folding for integer multiplication **) |
|
325 |
||
326 |
(*The trick is to regard products as sums, e.g. #3 $* x $* #4 as |
|
327 |
the "sum" of #3, x, #4; the literals are then multiplied*) |
|
9648
35d761c7d934
better rules for cancellation of common factors across comparisons
paulson
parents:
9576
diff
changeset
|
328 |
|
35d761c7d934
better rules for cancellation of common factors across comparisons
paulson
parents:
9576
diff
changeset
|
329 |
|
9570 | 330 |
structure CombineNumeralsProdData = |
331 |
struct |
|
332 |
val add = op * : int*int -> int |
|
333 |
val mk_sum = mk_prod |
|
334 |
val dest_sum = dest_prod |
|
9648
35d761c7d934
better rules for cancellation of common factors across comparisons
paulson
parents:
9576
diff
changeset
|
335 |
fun mk_coeff(k,t) = if t=one then mk_numeral k |
35d761c7d934
better rules for cancellation of common factors across comparisons
paulson
parents:
9576
diff
changeset
|
336 |
else raise TERM("mk_coeff", []) |
35d761c7d934
better rules for cancellation of common factors across comparisons
paulson
parents:
9576
diff
changeset
|
337 |
fun dest_coeff t = (dest_numeral t, one) (*We ONLY want pure numerals.*) |
9570 | 338 |
val left_distrib = zmult_assoc RS sym RS trans |
339 |
val prove_conv = prove_conv_nohyps "int_combine_numerals_prod" |
|
340 |
val trans_tac = ArithData.gen_trans_tac trans |
|
341 |
val norm_tac_ss1 = ZF_ss addsimps mult_1s@diff_simps@zminus_simps |
|
342 |
val norm_tac_ss2 = ZF_ss addsimps [zmult_zminus_right RS sym]@ |
|
343 |
bin_simps@zmult_ac@tc_rules@intifys |
|
344 |
val norm_tac = ALLGOALS (asm_simp_tac norm_tac_ss1) |
|
345 |
THEN ALLGOALS (asm_simp_tac norm_tac_ss2) |
|
9648
35d761c7d934
better rules for cancellation of common factors across comparisons
paulson
parents:
9576
diff
changeset
|
346 |
val numeral_simp_tac = |
35d761c7d934
better rules for cancellation of common factors across comparisons
paulson
parents:
9576
diff
changeset
|
347 |
ALLGOALS (simp_tac (ZF_ss addsimps bin_simps@tc_rules@intifys)) |
9570 | 348 |
val simplify_meta_eq = ArithData.simplify_meta_eq (mult_1s) |
349 |
end; |
|
350 |
||
351 |
||
352 |
structure CombineNumeralsProd = CombineNumeralsFun(CombineNumeralsProdData); |
|
353 |
||
354 |
val combine_numerals_prod = |
|
355 |
prep_simproc ("int_combine_numerals_prod", |
|
9576
3df14e0a3a51
interim working version: more improvements to the integers
paulson
parents:
9570
diff
changeset
|
356 |
prep_pats ["i $* j"], |
9570 | 357 |
CombineNumeralsProd.proc); |
358 |
||
359 |
end; |
|
360 |
||
361 |
||
362 |
Addsimprocs Int_Numeral_Simprocs.cancel_numerals; |
|
363 |
Addsimprocs [Int_Numeral_Simprocs.combine_numerals, |
|
364 |
Int_Numeral_Simprocs.combine_numerals_prod]; |
|
365 |
||
366 |
||
367 |
(*examples:*) |
|
368 |
(* |
|
369 |
print_depth 22; |
|
370 |
set timing; |
|
371 |
set trace_simp; |
|
372 |
fun test s = (Goal s; by (Asm_simp_tac 1)); |
|
373 |
val sg = #sign (rep_thm (topthm())); |
|
374 |
val t = FOLogic.dest_Trueprop (Logic.strip_assums_concl(getgoal 1)); |
|
375 |
val (t,_) = FOLogic.dest_eq t; |
|
376 |
||
377 |
(*combine_numerals_prod (products of separate literals) *) |
|
378 |
test "#5 $* x $* #3 = y"; |
|
379 |
||
380 |
test "y2 $+ ?x42 = y $+ y2"; |
|
381 |
||
382 |
test "oo : int ==> l $+ (l $+ #2) $+ oo = oo"; |
|
383 |
||
384 |
test "#9$*x $+ y = x$*#23 $+ z"; |
|
385 |
test "y $+ x = x $+ z"; |
|
386 |
||
387 |
test "x : int ==> x $+ y $+ z = x $+ z"; |
|
388 |
test "x : int ==> y $+ (z $+ x) = z $+ x"; |
|
389 |
test "z : int ==> x $+ y $+ z = (z $+ y) $+ (x $+ w)"; |
|
390 |
test "z : int ==> x$*y $+ z = (z $+ y) $+ (y$*x $+ w)"; |
|
391 |
||
392 |
test "#-3 $* x $+ y $<= x $* #2 $+ z"; |
|
393 |
test "y $+ x $<= x $+ z"; |
|
394 |
test "x $+ y $+ z $<= x $+ z"; |
|
395 |
||
396 |
test "y $+ (z $+ x) $< z $+ x"; |
|
397 |
test "x $+ y $+ z $< (z $+ y) $+ (x $+ w)"; |
|
398 |
test "x$*y $+ z $< (z $+ y) $+ (y$*x $+ w)"; |
|
399 |
||
400 |
test "l $+ #2 $+ #2 $+ #2 $+ (l $+ #2) $+ (oo $+ #2) = uu"; |
|
401 |
test "u : int ==> #2 $* u = u"; |
|
402 |
test "(i $+ j $+ #12 $+ k) $- #15 = y"; |
|
403 |
test "(i $+ j $+ #12 $+ k) $- #5 = y"; |
|
404 |
||
405 |
test "y $- b $< b"; |
|
406 |
test "y $- (#3 $* b $+ c) $< b $- #2 $* c"; |
|
407 |
||
408 |
test "(#2 $* x $- (u $* v) $+ y) $- v $* #3 $* u = w"; |
|
409 |
test "(#2 $* x $* u $* v $+ (u $* v) $* #4 $+ y) $- v $* u $* #4 = w"; |
|
410 |
test "(#2 $* x $* u $* v $+ (u $* v) $* #4 $+ y) $- v $* u = w"; |
|
411 |
test "u $* v $- (x $* u $* v $+ (u $* v) $* #4 $+ y) = w"; |
|
412 |
||
413 |
test "(i $+ j $+ #12 $+ k) = u $+ #15 $+ y"; |
|
414 |
test "(i $+ j $* #2 $+ #12 $+ k) = j $+ #5 $+ y"; |
|
415 |
||
416 |
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"; |
|
417 |
||
418 |
test "a $+ $-(b$+c) $+ b = d"; |
|
419 |
test "a $+ $-(b$+c) $- b = d"; |
|
420 |
||
421 |
(*negative numerals*) |
|
422 |
test "(i $+ j $+ #-2 $+ k) $- (u $+ #5 $+ y) = zz"; |
|
423 |
test "(i $+ j $+ #-3 $+ k) $< u $+ #5 $+ y"; |
|
424 |
test "(i $+ j $+ #3 $+ k) $< u $+ #-6 $+ y"; |
|
425 |
test "(i $+ j $+ #-12 $+ k) $- #15 = y"; |
|
426 |
test "(i $+ j $+ #12 $+ k) $- #-15 = y"; |
|
427 |
test "(i $+ j $+ #-12 $+ k) $- #-15 = y"; |
|
9648
35d761c7d934
better rules for cancellation of common factors across comparisons
paulson
parents:
9576
diff
changeset
|
428 |
|
35d761c7d934
better rules for cancellation of common factors across comparisons
paulson
parents:
9576
diff
changeset
|
429 |
(*Multiplying separated numerals*) |
35d761c7d934
better rules for cancellation of common factors across comparisons
paulson
parents:
9576
diff
changeset
|
430 |
Goal "#6 $* ($# x $* #2) = uu"; |
35d761c7d934
better rules for cancellation of common factors across comparisons
paulson
parents:
9576
diff
changeset
|
431 |
Goal "#4 $* ($# x $* $# x) $* (#2 $* $# x) = uu"; |
9570 | 432 |
*) |
433 |