neuper@37954
|
1 |
(* some tests are based on specficially simple scripts etc.
|
neuper@37954
|
2 |
Author: Walther Neuper 2003
|
neuper@37954
|
3 |
(c) due to copyright terms
|
neuper@37954
|
4 |
*)
|
neuper@37906
|
5 |
|
wneuper@59424
|
6 |
theory Test imports Base_Tools Poly Rational Root Diff begin
|
neuper@37906
|
7 |
|
neuper@37906
|
8 |
consts
|
neuper@37906
|
9 |
|
neuper@37906
|
10 |
(*"cancel":: [real, real] => real (infixl "'/'/'/" 70) ...divide 2002*)
|
neuper@37906
|
11 |
|
neuper@37906
|
12 |
Expand'_binomtest
|
neuper@37954
|
13 |
:: "['y,
|
neuper@37954
|
14 |
'y] => 'y"
|
wneuper@59334
|
15 |
("((Script Expand'_binomtest (_ =))// (_))" 9)
|
neuper@37906
|
16 |
|
neuper@37906
|
17 |
Solve'_univar'_err
|
neuper@37954
|
18 |
:: "[bool,real,bool,
|
neuper@37954
|
19 |
bool list] => bool list"
|
wneuper@59334
|
20 |
("((Script Solve'_univar'_err (_ _ _ =))// (_))" 9)
|
neuper@37906
|
21 |
|
neuper@37906
|
22 |
Solve'_linear
|
neuper@37954
|
23 |
:: "[bool,real,
|
neuper@37954
|
24 |
bool list] => bool list"
|
wneuper@59334
|
25 |
("((Script Solve'_linear (_ _ =))// (_))" 9)
|
neuper@37906
|
26 |
|
neuper@37906
|
27 |
(*17.9.02 aus SqRoot.thy------------------------------vvv---*)
|
neuper@37906
|
28 |
|
neuper@42008
|
29 |
"is'_root'_free" :: "'a => bool" ("is'_root'_free _" 10)
|
neuper@42008
|
30 |
"contains'_root" :: "'a => bool" ("contains'_root _" 10)
|
neuper@42008
|
31 |
|
neuper@42008
|
32 |
"precond'_rootmet" :: "'a => bool" ("precond'_rootmet _" 10)
|
neuper@42008
|
33 |
"precond'_rootpbl" :: "'a => bool" ("precond'_rootpbl _" 10)
|
neuper@42008
|
34 |
"precond'_submet" :: "'a => bool" ("precond'_submet _" 10)
|
neuper@42008
|
35 |
"precond'_subpbl" :: "'a => bool" ("precond'_subpbl _" 10)
|
neuper@37906
|
36 |
|
neuper@37906
|
37 |
Solve'_root'_equation
|
neuper@37954
|
38 |
:: "[bool,real,
|
neuper@37954
|
39 |
bool list] => bool list"
|
wneuper@59334
|
40 |
("((Script Solve'_root'_equation (_ _ =))// (_))" 9)
|
neuper@37906
|
41 |
|
neuper@37906
|
42 |
Solve'_plain'_square
|
neuper@37954
|
43 |
:: "[bool,real,
|
neuper@37954
|
44 |
bool list] => bool list"
|
wneuper@59334
|
45 |
("((Script Solve'_plain'_square (_ _ =))// (_))" 9)
|
neuper@37906
|
46 |
|
neuper@37906
|
47 |
Norm'_univar'_equation
|
neuper@37954
|
48 |
:: "[bool,real,
|
neuper@37954
|
49 |
bool] => bool"
|
wneuper@59334
|
50 |
("((Script Norm'_univar'_equation (_ _ =))// (_))" 9)
|
neuper@37906
|
51 |
|
neuper@37906
|
52 |
STest'_simplify
|
neuper@37954
|
53 |
:: "['z,
|
neuper@37954
|
54 |
'z] => 'z"
|
wneuper@59334
|
55 |
("((Script STest'_simplify (_ =))// (_))" 9)
|
neuper@37906
|
56 |
|
neuper@37906
|
57 |
(*17.9.02 aus SqRoot.thy------------------------------^^^---*)
|
neuper@37906
|
58 |
|
neuper@52148
|
59 |
axiomatization where (*TODO: prove as theorems*)
|
neuper@37906
|
60 |
|
neuper@52148
|
61 |
radd_mult_distrib2: "(k::real) * (m + n) = k * m + k * n" and
|
neuper@52148
|
62 |
rdistr_right_assoc: "(k::real) + l * n + m * n = k + (l + m) * n" and
|
neuper@52148
|
63 |
rdistr_right_assoc_p: "l * n + (m * n + (k::real)) = (l + m) * n + k" and
|
neuper@52148
|
64 |
rdistr_div_right: "((k::real) + l) / n = k / n + l / n" and
|
neuper@37983
|
65 |
rcollect_right:
|
neuper@52148
|
66 |
"[| l is_const; m is_const |] ==> (l::real)*n + m*n = (l + m) * n" and
|
neuper@37983
|
67 |
rcollect_one_left:
|
neuper@52148
|
68 |
"m is_const ==> (n::real) + m * n = (1 + m) * n" and
|
neuper@37983
|
69 |
rcollect_one_left_assoc:
|
neuper@52148
|
70 |
"m is_const ==> (k::real) + n + m * n = k + (1 + m) * n" and
|
neuper@37983
|
71 |
rcollect_one_left_assoc_p:
|
neuper@52148
|
72 |
"m is_const ==> n + (m * n + (k::real)) = (1 + m) * n + k" and
|
neuper@37906
|
73 |
|
neuper@52148
|
74 |
rtwo_of_the_same: "a + a = 2 * a" and
|
neuper@52148
|
75 |
rtwo_of_the_same_assoc: "(x + a) + a = x + 2 * a" and
|
neuper@52148
|
76 |
rtwo_of_the_same_assoc_p:"a + (a + x) = 2 * a + x" and
|
neuper@37906
|
77 |
|
neuper@52148
|
78 |
rcancel_den: "not(a=0) ==> a * (b / a) = b" and
|
neuper@52148
|
79 |
rcancel_const: "[| a is_const; b is_const |] ==> a*(x/b) = a/b*x" and
|
neuper@52148
|
80 |
rshift_nominator: "(a::real) * b / c = a / c * b" and
|
neuper@37906
|
81 |
|
neuper@52148
|
82 |
exp_pow: "(a ^^^ b) ^^^ c = a ^^^ (b * c)" and
|
neuper@52148
|
83 |
rsqare: "(a::real) * a = a ^^^ 2" and
|
neuper@52148
|
84 |
power_1: "(a::real) ^^^ 1 = a" and
|
neuper@52148
|
85 |
rbinom_power_2: "((a::real) + b)^^^ 2 = a^^^ 2 + 2*a*b + b^^^ 2" and
|
neuper@37906
|
86 |
|
neuper@52148
|
87 |
rmult_1: "1 * k = (k::real)" and
|
neuper@52148
|
88 |
rmult_1_right: "k * 1 = (k::real)" and
|
neuper@52148
|
89 |
rmult_0: "0 * k = (0::real)" and
|
neuper@52148
|
90 |
rmult_0_right: "k * 0 = (0::real)" and
|
neuper@52148
|
91 |
radd_0: "0 + k = (k::real)" and
|
neuper@52148
|
92 |
radd_0_right: "k + 0 = (k::real)" and
|
neuper@37906
|
93 |
|
neuper@37983
|
94 |
radd_real_const_eq:
|
neuper@52148
|
95 |
"[| a is_const; c is_const; d is_const |] ==> a/d + c/d = (a+c)/(d::real)" and
|
neuper@37983
|
96 |
radd_real_const:
|
neuper@37906
|
97 |
"[| a is_const; b is_const; c is_const; d is_const |] ==> a/b + c/d = (a*d + b*c)/(b*(d::real))"
|
neuper@52148
|
98 |
and
|
neuper@37906
|
99 |
(*for AC-operators*)
|
neuper@52148
|
100 |
radd_commute: "(m::real) + (n::real) = n + m" and
|
neuper@52148
|
101 |
radd_left_commute: "(x::real) + (y + z) = y + (x + z)" and
|
neuper@52148
|
102 |
radd_assoc: "(m::real) + n + k = m + (n + k)" and
|
neuper@52148
|
103 |
rmult_commute: "(m::real) * n = n * m" and
|
neuper@52148
|
104 |
rmult_left_commute: "(x::real) * (y * z) = y * (x * z)" and
|
neuper@52148
|
105 |
rmult_assoc: "(m::real) * n * k = m * (n * k)" and
|
neuper@37906
|
106 |
|
neuper@37906
|
107 |
(*for equations: 'bdv' is a meta-constant*)
|
neuper@52148
|
108 |
risolate_bdv_add: "((k::real) + bdv = m) = (bdv = m + (-1)*k)" and
|
neuper@52148
|
109 |
risolate_bdv_mult_add: "((k::real) + n*bdv = m) = (n*bdv = m + (-1)*k)" and
|
neuper@52148
|
110 |
risolate_bdv_mult: "((n::real) * bdv = m) = (bdv = m / n)" and
|
neuper@37906
|
111 |
|
neuper@37983
|
112 |
rnorm_equation_add:
|
neuper@52148
|
113 |
"~(b =!= 0) ==> (a = b) = (a + (-1)*b = 0)" and
|
neuper@37906
|
114 |
|
neuper@37906
|
115 |
(*17.9.02 aus SqRoot.thy------------------------------vvv---*)
|
neuper@52148
|
116 |
root_ge0: "0 <= a ==> 0 <= sqrt a" and
|
neuper@37906
|
117 |
(*should be dropped with better simplification in eval_rls ...*)
|
neuper@37983
|
118 |
root_add_ge0:
|
neuper@52148
|
119 |
"[| 0 <= a; 0 <= b |] ==> (0 <= sqrt a + sqrt b) = True" and
|
neuper@37983
|
120 |
root_ge0_1:
|
neuper@52148
|
121 |
"[| 0<=a; 0<=b; 0<=c |] ==> (0 <= a * sqrt b + sqrt c) = True" and
|
neuper@37983
|
122 |
root_ge0_2:
|
neuper@52148
|
123 |
"[| 0<=a; 0<=b; 0<=c |] ==> (0 <= sqrt a + b * sqrt c) = True" and
|
neuper@37906
|
124 |
|
neuper@37906
|
125 |
|
neuper@52148
|
126 |
rroot_square_inv: "(sqrt a)^^^ 2 = a" and
|
neuper@52148
|
127 |
rroot_times_root: "sqrt a * sqrt b = sqrt(a*b)" and
|
neuper@52148
|
128 |
rroot_times_root_assoc: "(a * sqrt b) * sqrt c = a * sqrt(b*c)" and
|
neuper@52148
|
129 |
rroot_times_root_assoc_p: "sqrt b * (sqrt c * a)= sqrt(b*c) * a" and
|
neuper@37906
|
130 |
|
neuper@37906
|
131 |
|
neuper@37906
|
132 |
(*for root-equations*)
|
neuper@37983
|
133 |
square_equation_left:
|
neuper@52148
|
134 |
"[| 0 <= a; 0 <= b |] ==> (((sqrt a)=b)=(a=(b^^^ 2)))" and
|
neuper@37983
|
135 |
square_equation_right:
|
neuper@52148
|
136 |
"[| 0 <= a; 0 <= b |] ==> ((a=(sqrt b))=((a^^^ 2)=b))" and
|
neuper@37906
|
137 |
(*causes frequently non-termination:*)
|
neuper@37983
|
138 |
square_equation:
|
neuper@52148
|
139 |
"[| 0 <= a; 0 <= b |] ==> ((a=b)=((a^^^ 2)=b^^^ 2))" and
|
neuper@37906
|
140 |
|
neuper@52148
|
141 |
risolate_root_add: "(a+ sqrt c = d) = ( sqrt c = d + (-1)*a)" and
|
neuper@52148
|
142 |
risolate_root_mult: "(a+b*sqrt c = d) = (b*sqrt c = d + (-1)*a)" and
|
neuper@52148
|
143 |
risolate_root_div: "(a * sqrt c = d) = ( sqrt c = d / a)" and
|
neuper@37906
|
144 |
|
neuper@37906
|
145 |
(*for polynomial equations of degree 2; linear case in RatArith*)
|
neuper@52148
|
146 |
mult_square: "(a*bdv^^^2 = b) = (bdv^^^2 = b / a)" and
|
neuper@52148
|
147 |
constant_square: "(a + bdv^^^2 = b) = (bdv^^^2 = b + -1*a)" and
|
neuper@52148
|
148 |
constant_mult_square: "(a + b*bdv^^^2 = c) = (b*bdv^^^2 = c + -1*a)" and
|
neuper@37906
|
149 |
|
neuper@37983
|
150 |
square_equality:
|
neuper@52148
|
151 |
"0 <= a ==> (x^^^2 = a) = ((x=sqrt a) | (x=-1*sqrt a))" and
|
neuper@37983
|
152 |
square_equality_0:
|
neuper@52148
|
153 |
"(x^^^2 = 0) = (x = 0)" and
|
neuper@37906
|
154 |
|
neuper@37906
|
155 |
(*isolate root on the LEFT hand side of the equation
|
neuper@37906
|
156 |
otherwise shuffling from left to right would not terminate*)
|
neuper@37906
|
157 |
|
neuper@37983
|
158 |
rroot_to_lhs:
|
neuper@52148
|
159 |
"is_root_free a ==> (a = sqrt b) = (a + (-1)*sqrt b = 0)" and
|
neuper@37983
|
160 |
rroot_to_lhs_mult:
|
neuper@52148
|
161 |
"is_root_free a ==> (a = c*sqrt b) = (a + (-1)*c*sqrt b = 0)" and
|
neuper@37983
|
162 |
rroot_to_lhs_add_mult:
|
neuper@37906
|
163 |
"is_root_free a ==> (a = d+c*sqrt b) = (a + (-1)*c*sqrt b = d)"
|
neuper@37906
|
164 |
(*17.9.02 aus SqRoot.thy------------------------------^^^---*)
|
neuper@37906
|
165 |
|
neuper@37954
|
166 |
ML {*
|
neuper@37972
|
167 |
val thy = @{theory};
|
neuper@37972
|
168 |
|
neuper@37954
|
169 |
(** evaluation of numerals and predicates **)
|
neuper@37954
|
170 |
|
neuper@37954
|
171 |
(*does a term contain a root ?*)
|
neuper@37954
|
172 |
fun eval_contains_root (thmid:string) _
|
neuper@37954
|
173 |
(t as (Const("Test.contains'_root",t0) $ arg)) thy =
|
neuper@38053
|
174 |
if member op = (ids_of arg) "sqrt"
|
wneuper@59416
|
175 |
then SOME (TermC.mk_thmid thmid (Rule.term_to_string''' thy arg)"",
|
wneuper@59390
|
176 |
HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
|
wneuper@59416
|
177 |
else SOME (TermC.mk_thmid thmid (Rule.term_to_string''' thy arg)"",
|
wneuper@59390
|
178 |
HOLogic.Trueprop $ (TermC.mk_equality (t, @{term False})))
|
neuper@38053
|
179 |
| eval_contains_root _ _ _ _ = NONE;
|
neuper@42008
|
180 |
|
neuper@42008
|
181 |
(*dummy precondition for root-met of x+1=2*)
|
neuper@42008
|
182 |
fun eval_precond_rootmet (thmid:string) _ (t as (Const ("Test.precond'_rootmet", _) $ arg)) thy =
|
wneuper@59416
|
183 |
SOME (TermC.mk_thmid thmid (Rule.term_to_string''' thy arg)"",
|
wneuper@59390
|
184 |
HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
|
neuper@52070
|
185 |
| eval_precond_rootmet _ _ _ _ = NONE;
|
neuper@42008
|
186 |
|
neuper@42008
|
187 |
(*dummy precondition for root-pbl of x+1=2*)
|
neuper@42008
|
188 |
fun eval_precond_rootpbl (thmid:string) _ (t as (Const ("Test.precond'_rootpbl", _) $ arg)) thy =
|
wneuper@59416
|
189 |
SOME (TermC.mk_thmid thmid (Rule.term_to_string''' thy arg) "",
|
wneuper@59390
|
190 |
HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
|
s1210629013@52159
|
191 |
| eval_precond_rootpbl _ _ _ _ = NONE;
|
s1210629013@52145
|
192 |
*}
|
s1210629013@52145
|
193 |
setup {* KEStore_Elems.add_calcs
|
wneuper@59403
|
194 |
[("contains_root", ("Test.contains'_root", eval_contains_root"#contains_root_")),
|
s1210629013@52145
|
195 |
("Test.precond'_rootmet", ("Test.precond'_rootmet", eval_precond_rootmet"#Test.precond_rootmet_")),
|
s1210629013@52145
|
196 |
("Test.precond'_rootpbl", ("Test.precond'_rootpbl",
|
s1210629013@52145
|
197 |
eval_precond_rootpbl"#Test.precond_rootpbl_"))] *}
|
s1210629013@52145
|
198 |
ML {*
|
neuper@37954
|
199 |
(** term order **)
|
wneuper@59416
|
200 |
fun term_order (_: Rule.subst) tu = (term_ordI [] tu = LESS);
|
s1210629013@52145
|
201 |
|
neuper@38001
|
202 |
(** rule sets **)
|
neuper@37954
|
203 |
|
neuper@37954
|
204 |
val testerls =
|
wneuper@59416
|
205 |
Rule.Rls {id = "testerls", preconds = [], rew_ord = ("termlessI",termlessI),
|
wneuper@59416
|
206 |
erls = Rule.e_rls, srls = Rule.Erls,
|
neuper@42451
|
207 |
calc = [], errpatts = [],
|
wneuper@59416
|
208 |
rules = [Rule.Thm ("refl",TermC.num_str @{thm refl}),
|
wneuper@59416
|
209 |
Rule.Thm ("order_refl",TermC.num_str @{thm order_refl}),
|
wneuper@59416
|
210 |
Rule.Thm ("radd_left_cancel_le",TermC.num_str @{thm radd_left_cancel_le}),
|
wneuper@59416
|
211 |
Rule.Thm ("not_true",TermC.num_str @{thm not_true}),
|
wneuper@59416
|
212 |
Rule.Thm ("not_false",TermC.num_str @{thm not_false}),
|
wneuper@59416
|
213 |
Rule.Thm ("and_true",TermC.num_str @{thm and_true}),
|
wneuper@59416
|
214 |
Rule.Thm ("and_false",TermC.num_str @{thm and_false}),
|
wneuper@59416
|
215 |
Rule.Thm ("or_true",TermC.num_str @{thm or_true}),
|
wneuper@59416
|
216 |
Rule.Thm ("or_false",TermC.num_str @{thm or_false}),
|
wneuper@59416
|
217 |
Rule.Thm ("and_commute",TermC.num_str @{thm and_commute}),
|
wneuper@59416
|
218 |
Rule.Thm ("or_commute",TermC.num_str @{thm or_commute}),
|
neuper@37954
|
219 |
|
wneuper@59416
|
220 |
Rule.Calc ("Atools.is'_const",eval_const "#is_const_"),
|
wneuper@59416
|
221 |
Rule.Calc ("Tools.matches",eval_matches ""),
|
neuper@37954
|
222 |
|
wneuper@59416
|
223 |
Rule.Calc ("Groups.plus_class.plus",eval_binop "#add_"),
|
wneuper@59416
|
224 |
Rule.Calc ("Groups.times_class.times",eval_binop "#mult_"),
|
wneuper@59416
|
225 |
Rule.Calc ("Atools.pow" ,eval_binop "#power_"),
|
neuper@37954
|
226 |
|
wneuper@59416
|
227 |
Rule.Calc ("Orderings.ord_class.less",eval_equ "#less_"),
|
wneuper@59416
|
228 |
Rule.Calc ("Orderings.ord_class.less_eq",eval_equ "#less_equal_"),
|
neuper@37954
|
229 |
|
wneuper@59416
|
230 |
Rule.Calc ("Atools.ident",eval_ident "#ident_")],
|
wneuper@59416
|
231 |
scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
|
wneuper@59406
|
232 |
};
|
neuper@38001
|
233 |
*}
|
neuper@38001
|
234 |
ML {*
|
neuper@37954
|
235 |
(*.for evaluation of conditions in rewrite rules.*)
|
neuper@37954
|
236 |
(*FIXXXXXXME 10.8.02: handle like _simplify*)
|
neuper@37954
|
237 |
val tval_rls =
|
wneuper@59416
|
238 |
Rule.Rls{id = "tval_rls", preconds = [],
|
wneuper@59397
|
239 |
rew_ord = ("sqrt_right",sqrt_right false @{theory "Pure"}),
|
wneuper@59416
|
240 |
erls=testerls,srls = Rule.e_rls,
|
neuper@42451
|
241 |
calc=[], errpatts = [],
|
wneuper@59416
|
242 |
rules = [Rule.Thm ("refl",TermC.num_str @{thm refl}),
|
wneuper@59416
|
243 |
Rule.Thm ("order_refl",TermC.num_str @{thm order_refl}),
|
wneuper@59416
|
244 |
Rule.Thm ("radd_left_cancel_le",TermC.num_str @{thm radd_left_cancel_le}),
|
wneuper@59416
|
245 |
Rule.Thm ("not_true",TermC.num_str @{thm not_true}),
|
wneuper@59416
|
246 |
Rule.Thm ("not_false",TermC.num_str @{thm not_false}),
|
wneuper@59416
|
247 |
Rule.Thm ("and_true",TermC.num_str @{thm and_true}),
|
wneuper@59416
|
248 |
Rule.Thm ("and_false",TermC.num_str @{thm and_false}),
|
wneuper@59416
|
249 |
Rule.Thm ("or_true",TermC.num_str @{thm or_true}),
|
wneuper@59416
|
250 |
Rule.Thm ("or_false",TermC.num_str @{thm or_false}),
|
wneuper@59416
|
251 |
Rule.Thm ("and_commute",TermC.num_str @{thm and_commute}),
|
wneuper@59416
|
252 |
Rule.Thm ("or_commute",TermC.num_str @{thm or_commute}),
|
neuper@37954
|
253 |
|
wneuper@59416
|
254 |
Rule.Thm ("real_diff_minus",TermC.num_str @{thm real_diff_minus}),
|
neuper@37954
|
255 |
|
wneuper@59416
|
256 |
Rule.Thm ("root_ge0",TermC.num_str @{thm root_ge0}),
|
wneuper@59416
|
257 |
Rule.Thm ("root_add_ge0",TermC.num_str @{thm root_add_ge0}),
|
wneuper@59416
|
258 |
Rule.Thm ("root_ge0_1",TermC.num_str @{thm root_ge0_1}),
|
wneuper@59416
|
259 |
Rule.Thm ("root_ge0_2",TermC.num_str @{thm root_ge0_2}),
|
neuper@37954
|
260 |
|
wneuper@59416
|
261 |
Rule.Calc ("Atools.is'_const",eval_const "#is_const_"),
|
wneuper@59416
|
262 |
Rule.Calc ("Test.contains'_root",eval_contains_root "#eval_contains_root"),
|
wneuper@59416
|
263 |
Rule.Calc ("Tools.matches",eval_matches ""),
|
wneuper@59416
|
264 |
Rule.Calc ("Test.contains'_root",
|
neuper@37954
|
265 |
eval_contains_root"#contains_root_"),
|
neuper@37954
|
266 |
|
wneuper@59416
|
267 |
Rule.Calc ("Groups.plus_class.plus",eval_binop "#add_"),
|
wneuper@59416
|
268 |
Rule.Calc ("Groups.times_class.times",eval_binop "#mult_"),
|
wneuper@59416
|
269 |
Rule.Calc ("NthRoot.sqrt",eval_sqrt "#sqrt_"),
|
wneuper@59416
|
270 |
Rule.Calc ("Atools.pow" ,eval_binop "#power_"),
|
neuper@37954
|
271 |
|
wneuper@59416
|
272 |
Rule.Calc ("Orderings.ord_class.less",eval_equ "#less_"),
|
wneuper@59416
|
273 |
Rule.Calc ("Orderings.ord_class.less_eq",eval_equ "#less_equal_"),
|
neuper@37954
|
274 |
|
wneuper@59416
|
275 |
Rule.Calc ("Atools.ident",eval_ident "#ident_")],
|
wneuper@59416
|
276 |
scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
|
wneuper@59406
|
277 |
};
|
neuper@38001
|
278 |
*}
|
s1210629013@55444
|
279 |
setup {* KEStore_Elems.add_rlss [("testerls", (Context.theory_name @{theory}, prep_rls' testerls))] *}
|
neuper@52155
|
280 |
|
neuper@38001
|
281 |
ML {*
|
neuper@37954
|
282 |
(*make () dissappear*)
|
neuper@37954
|
283 |
val rearrange_assoc =
|
wneuper@59416
|
284 |
Rule.Rls{id = "rearrange_assoc", preconds = [],
|
wneuper@59416
|
285 |
rew_ord = ("e_rew_ord",Rule.e_rew_ord),
|
wneuper@59416
|
286 |
erls = Rule.e_rls, srls = Rule.e_rls, calc = [], errpatts = [],
|
neuper@37954
|
287 |
rules =
|
wneuper@59416
|
288 |
[Rule.Thm ("sym_add_assoc",TermC.num_str (@{thm add.assoc} RS @{thm sym})),
|
wneuper@59416
|
289 |
Rule.Thm ("sym_rmult_assoc",TermC.num_str (@{thm rmult_assoc} RS @{thm sym}))],
|
wneuper@59416
|
290 |
scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
|
wneuper@59406
|
291 |
};
|
neuper@37954
|
292 |
|
neuper@37954
|
293 |
val ac_plus_times =
|
wneuper@59416
|
294 |
Rule.Rls{id = "ac_plus_times", preconds = [], rew_ord = ("term_order",term_order),
|
wneuper@59416
|
295 |
erls = Rule.e_rls, srls = Rule.e_rls, calc = [], errpatts = [],
|
neuper@37954
|
296 |
rules =
|
wneuper@59416
|
297 |
[Rule.Thm ("radd_commute",TermC.num_str @{thm radd_commute}),
|
wneuper@59416
|
298 |
Rule.Thm ("radd_left_commute",TermC.num_str @{thm radd_left_commute}),
|
wneuper@59416
|
299 |
Rule.Thm ("add_assoc",TermC.num_str @{thm add.assoc}),
|
wneuper@59416
|
300 |
Rule.Thm ("rmult_commute",TermC.num_str @{thm rmult_commute}),
|
wneuper@59416
|
301 |
Rule.Thm ("rmult_left_commute",TermC.num_str @{thm rmult_left_commute}),
|
wneuper@59416
|
302 |
Rule.Thm ("rmult_assoc",TermC.num_str @{thm rmult_assoc})],
|
wneuper@59416
|
303 |
scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
|
wneuper@59406
|
304 |
};
|
neuper@37954
|
305 |
|
wneuper@59389
|
306 |
(*todo: replace by Rewrite("rnorm_equation_add",TermC.num_str @{thm rnorm_equation_add)*)
|
neuper@37954
|
307 |
val norm_equation =
|
wneuper@59416
|
308 |
Rule.Rls{id = "norm_equation", preconds = [], rew_ord = ("e_rew_ord",Rule.e_rew_ord),
|
wneuper@59416
|
309 |
erls = tval_rls, srls = Rule.e_rls, calc = [], errpatts = [],
|
wneuper@59416
|
310 |
rules = [Rule.Thm ("rnorm_equation_add",TermC.num_str @{thm rnorm_equation_add})
|
neuper@37954
|
311 |
],
|
wneuper@59416
|
312 |
scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
|
wneuper@59406
|
313 |
};
|
neuper@38001
|
314 |
*}
|
neuper@38001
|
315 |
ML {*
|
neuper@37954
|
316 |
(** rule sets **)
|
neuper@37954
|
317 |
|
neuper@37954
|
318 |
val STest_simplify = (* vv--- not changed to real by parse*)
|
neuper@38001
|
319 |
"Script STest_simplify (t_t::'z) = " ^
|
neuper@37954
|
320 |
"(Repeat" ^
|
neuper@37954
|
321 |
" ((Try (Repeat (Rewrite real_diff_minus False))) @@ " ^
|
neuper@37954
|
322 |
" (Try (Repeat (Rewrite radd_mult_distrib2 False))) @@ " ^
|
neuper@37954
|
323 |
" (Try (Repeat (Rewrite rdistr_right_assoc False))) @@ " ^
|
neuper@37954
|
324 |
" (Try (Repeat (Rewrite rdistr_right_assoc_p False))) @@" ^
|
neuper@37954
|
325 |
" (Try (Repeat (Rewrite rdistr_div_right False))) @@ " ^
|
neuper@37954
|
326 |
" (Try (Repeat (Rewrite rbinom_power_2 False))) @@ " ^
|
neuper@37954
|
327 |
|
neuper@37954
|
328 |
" (Try (Repeat (Rewrite radd_commute False))) @@ " ^
|
neuper@37954
|
329 |
" (Try (Repeat (Rewrite radd_left_commute False))) @@ " ^
|
neuper@37974
|
330 |
" (Try (Repeat (Rewrite add_assoc False))) @@ " ^
|
neuper@37954
|
331 |
" (Try (Repeat (Rewrite rmult_commute False))) @@ " ^
|
neuper@37954
|
332 |
" (Try (Repeat (Rewrite rmult_left_commute False))) @@ " ^
|
neuper@37954
|
333 |
" (Try (Repeat (Rewrite rmult_assoc False))) @@ " ^
|
neuper@37954
|
334 |
|
neuper@37954
|
335 |
" (Try (Repeat (Rewrite radd_real_const_eq False))) @@ " ^
|
neuper@37954
|
336 |
" (Try (Repeat (Rewrite radd_real_const False))) @@ " ^
|
neuper@37975
|
337 |
" (Try (Repeat (Calculate PLUS))) @@ " ^
|
neuper@37975
|
338 |
" (Try (Repeat (Calculate TIMES))) @@ " ^
|
neuper@37954
|
339 |
" (Try (Repeat (Calculate divide_))) @@" ^
|
neuper@37975
|
340 |
" (Try (Repeat (Calculate POWER))) @@ " ^
|
neuper@37954
|
341 |
|
neuper@37954
|
342 |
" (Try (Repeat (Rewrite rcollect_right False))) @@ " ^
|
neuper@37954
|
343 |
" (Try (Repeat (Rewrite rcollect_one_left False))) @@ " ^
|
neuper@37954
|
344 |
" (Try (Repeat (Rewrite rcollect_one_left_assoc False))) @@ " ^
|
neuper@37954
|
345 |
" (Try (Repeat (Rewrite rcollect_one_left_assoc_p False))) @@ " ^
|
neuper@37954
|
346 |
|
neuper@37954
|
347 |
" (Try (Repeat (Rewrite rshift_nominator False))) @@ " ^
|
neuper@37954
|
348 |
" (Try (Repeat (Rewrite rcancel_den False))) @@ " ^
|
neuper@37954
|
349 |
" (Try (Repeat (Rewrite rroot_square_inv False))) @@ " ^
|
neuper@37954
|
350 |
" (Try (Repeat (Rewrite rroot_times_root False))) @@ " ^
|
neuper@37954
|
351 |
" (Try (Repeat (Rewrite rroot_times_root_assoc_p False))) @@ " ^
|
neuper@37954
|
352 |
" (Try (Repeat (Rewrite rsqare False))) @@ " ^
|
neuper@37954
|
353 |
" (Try (Repeat (Rewrite power_1 False))) @@ " ^
|
neuper@37954
|
354 |
" (Try (Repeat (Rewrite rtwo_of_the_same False))) @@ " ^
|
neuper@37954
|
355 |
" (Try (Repeat (Rewrite rtwo_of_the_same_assoc_p False))) @@ " ^
|
neuper@37954
|
356 |
|
neuper@37954
|
357 |
" (Try (Repeat (Rewrite rmult_1 False))) @@ " ^
|
neuper@37954
|
358 |
" (Try (Repeat (Rewrite rmult_1_right False))) @@ " ^
|
neuper@37954
|
359 |
" (Try (Repeat (Rewrite rmult_0 False))) @@ " ^
|
neuper@37954
|
360 |
" (Try (Repeat (Rewrite rmult_0_right False))) @@ " ^
|
neuper@37954
|
361 |
" (Try (Repeat (Rewrite radd_0 False))) @@ " ^
|
neuper@37954
|
362 |
" (Try (Repeat (Rewrite radd_0_right False)))) " ^
|
neuper@38001
|
363 |
" t_t)";
|
neuper@37954
|
364 |
|
neuper@38001
|
365 |
*}
|
neuper@38001
|
366 |
ML {*
|
neuper@37954
|
367 |
(* expects * distributed over + *)
|
neuper@37954
|
368 |
val Test_simplify =
|
wneuper@59416
|
369 |
Rule.Rls{id = "Test_simplify", preconds = [],
|
wneuper@59397
|
370 |
rew_ord = ("sqrt_right",sqrt_right false @{theory "Pure"}),
|
wneuper@59416
|
371 |
erls = tval_rls, srls = Rule.e_rls,
|
s1210629013@55444
|
372 |
calc=[(*since 040209 filled by prep_rls'*)], errpatts = [],
|
neuper@37954
|
373 |
rules = [
|
wneuper@59416
|
374 |
Rule.Thm ("real_diff_minus",TermC.num_str @{thm real_diff_minus}),
|
wneuper@59416
|
375 |
Rule.Thm ("radd_mult_distrib2",TermC.num_str @{thm radd_mult_distrib2}),
|
wneuper@59416
|
376 |
Rule.Thm ("rdistr_right_assoc",TermC.num_str @{thm rdistr_right_assoc}),
|
wneuper@59416
|
377 |
Rule.Thm ("rdistr_right_assoc_p",TermC.num_str @{thm rdistr_right_assoc_p}),
|
wneuper@59416
|
378 |
Rule.Thm ("rdistr_div_right",TermC.num_str @{thm rdistr_div_right}),
|
wneuper@59416
|
379 |
Rule.Thm ("rbinom_power_2",TermC.num_str @{thm rbinom_power_2}),
|
neuper@37954
|
380 |
|
wneuper@59416
|
381 |
Rule.Thm ("radd_commute",TermC.num_str @{thm radd_commute}),
|
wneuper@59416
|
382 |
Rule.Thm ("radd_left_commute",TermC.num_str @{thm radd_left_commute}),
|
wneuper@59416
|
383 |
Rule.Thm ("add_assoc",TermC.num_str @{thm add.assoc}),
|
wneuper@59416
|
384 |
Rule.Thm ("rmult_commute",TermC.num_str @{thm rmult_commute}),
|
wneuper@59416
|
385 |
Rule.Thm ("rmult_left_commute",TermC.num_str @{thm rmult_left_commute}),
|
wneuper@59416
|
386 |
Rule.Thm ("rmult_assoc",TermC.num_str @{thm rmult_assoc}),
|
neuper@37954
|
387 |
|
wneuper@59416
|
388 |
Rule.Thm ("radd_real_const_eq",TermC.num_str @{thm radd_real_const_eq}),
|
wneuper@59416
|
389 |
Rule.Thm ("radd_real_const",TermC.num_str @{thm radd_real_const}),
|
neuper@37954
|
390 |
(* these 2 rules are invers to distr_div_right wrt. termination.
|
neuper@37954
|
391 |
thus they MUST be done IMMEDIATELY before calc *)
|
wneuper@59416
|
392 |
Rule.Calc ("Groups.plus_class.plus", eval_binop "#add_"),
|
wneuper@59416
|
393 |
Rule.Calc ("Groups.times_class.times", eval_binop "#mult_"),
|
wneuper@59416
|
394 |
Rule.Calc ("Rings.divide_class.divide", eval_cancel "#divide_e"),
|
wneuper@59416
|
395 |
Rule.Calc ("Atools.pow", eval_binop "#power_"),
|
neuper@37954
|
396 |
|
wneuper@59416
|
397 |
Rule.Thm ("rcollect_right",TermC.num_str @{thm rcollect_right}),
|
wneuper@59416
|
398 |
Rule.Thm ("rcollect_one_left",TermC.num_str @{thm rcollect_one_left}),
|
wneuper@59416
|
399 |
Rule.Thm ("rcollect_one_left_assoc",TermC.num_str @{thm rcollect_one_left_assoc}),
|
wneuper@59416
|
400 |
Rule.Thm ("rcollect_one_left_assoc_p",TermC.num_str @{thm rcollect_one_left_assoc_p}),
|
neuper@37954
|
401 |
|
wneuper@59416
|
402 |
Rule.Thm ("rshift_nominator",TermC.num_str @{thm rshift_nominator}),
|
wneuper@59416
|
403 |
Rule.Thm ("rcancel_den",TermC.num_str @{thm rcancel_den}),
|
wneuper@59416
|
404 |
Rule.Thm ("rroot_square_inv",TermC.num_str @{thm rroot_square_inv}),
|
wneuper@59416
|
405 |
Rule.Thm ("rroot_times_root",TermC.num_str @{thm rroot_times_root}),
|
wneuper@59416
|
406 |
Rule.Thm ("rroot_times_root_assoc_p",TermC.num_str @{thm rroot_times_root_assoc_p}),
|
wneuper@59416
|
407 |
Rule.Thm ("rsqare",TermC.num_str @{thm rsqare}),
|
wneuper@59416
|
408 |
Rule.Thm ("power_1",TermC.num_str @{thm power_1}),
|
wneuper@59416
|
409 |
Rule.Thm ("rtwo_of_the_same",TermC.num_str @{thm rtwo_of_the_same}),
|
wneuper@59416
|
410 |
Rule.Thm ("rtwo_of_the_same_assoc_p",TermC.num_str @{thm rtwo_of_the_same_assoc_p}),
|
neuper@37954
|
411 |
|
wneuper@59416
|
412 |
Rule.Thm ("rmult_1",TermC.num_str @{thm rmult_1}),
|
wneuper@59416
|
413 |
Rule.Thm ("rmult_1_right",TermC.num_str @{thm rmult_1_right}),
|
wneuper@59416
|
414 |
Rule.Thm ("rmult_0",TermC.num_str @{thm rmult_0}),
|
wneuper@59416
|
415 |
Rule.Thm ("rmult_0_right",TermC.num_str @{thm rmult_0_right}),
|
wneuper@59416
|
416 |
Rule.Thm ("radd_0",TermC.num_str @{thm radd_0}),
|
wneuper@59416
|
417 |
Rule.Thm ("radd_0_right",TermC.num_str @{thm radd_0_right})
|
neuper@37954
|
418 |
],
|
wneuper@59416
|
419 |
scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
|
s1210629013@55444
|
420 |
(*since 040209 filled by prep_rls': STest_simplify*)
|
wneuper@59406
|
421 |
};
|
neuper@38001
|
422 |
*}
|
neuper@38001
|
423 |
ML {*
|
neuper@37954
|
424 |
|
neuper@37954
|
425 |
(** rule sets **)
|
neuper@37954
|
426 |
|
neuper@37954
|
427 |
|
neuper@37954
|
428 |
|
neuper@37954
|
429 |
(*isolate the root in a root-equation*)
|
neuper@37954
|
430 |
val isolate_root =
|
wneuper@59416
|
431 |
Rule.Rls{id = "isolate_root", preconds = [], rew_ord = ("e_rew_ord",Rule.e_rew_ord),
|
wneuper@59416
|
432 |
erls=tval_rls,srls = Rule.e_rls, calc=[], errpatts = [],
|
wneuper@59416
|
433 |
rules = [Rule.Thm ("rroot_to_lhs",TermC.num_str @{thm rroot_to_lhs}),
|
wneuper@59416
|
434 |
Rule.Thm ("rroot_to_lhs_mult",TermC.num_str @{thm rroot_to_lhs_mult}),
|
wneuper@59416
|
435 |
Rule.Thm ("rroot_to_lhs_add_mult",TermC.num_str @{thm rroot_to_lhs_add_mult}),
|
wneuper@59416
|
436 |
Rule.Thm ("risolate_root_add",TermC.num_str @{thm risolate_root_add}),
|
wneuper@59416
|
437 |
Rule.Thm ("risolate_root_mult",TermC.num_str @{thm risolate_root_mult}),
|
wneuper@59416
|
438 |
Rule.Thm ("risolate_root_div",TermC.num_str @{thm risolate_root_div}) ],
|
wneuper@59416
|
439 |
scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy))
|
neuper@37954
|
440 |
"empty_script")
|
wneuper@59406
|
441 |
};
|
neuper@37954
|
442 |
|
neuper@37954
|
443 |
(*isolate the bound variable in an equation; 'bdv' is a meta-constant*)
|
neuper@37954
|
444 |
val isolate_bdv =
|
wneuper@59416
|
445 |
Rule.Rls{id = "isolate_bdv", preconds = [], rew_ord = ("e_rew_ord",Rule.e_rew_ord),
|
wneuper@59416
|
446 |
erls=tval_rls,srls = Rule.e_rls, calc= [], errpatts = [],
|
neuper@37954
|
447 |
rules =
|
wneuper@59416
|
448 |
[Rule.Thm ("risolate_bdv_add",TermC.num_str @{thm risolate_bdv_add}),
|
wneuper@59416
|
449 |
Rule.Thm ("risolate_bdv_mult_add",TermC.num_str @{thm risolate_bdv_mult_add}),
|
wneuper@59416
|
450 |
Rule.Thm ("risolate_bdv_mult",TermC.num_str @{thm risolate_bdv_mult}),
|
wneuper@59416
|
451 |
Rule.Thm ("mult_square",TermC.num_str @{thm mult_square}),
|
wneuper@59416
|
452 |
Rule.Thm ("constant_square",TermC.num_str @{thm constant_square}),
|
wneuper@59416
|
453 |
Rule.Thm ("constant_mult_square",TermC.num_str @{thm constant_mult_square})
|
neuper@37954
|
454 |
],
|
wneuper@59416
|
455 |
scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy))
|
neuper@37954
|
456 |
"empty_script")
|
wneuper@59406
|
457 |
};
|
neuper@38001
|
458 |
*}
|
neuper@38001
|
459 |
ML {*
|
neuper@37954
|
460 |
|
neuper@37954
|
461 |
(* association list for calculate_, calculate
|
neuper@38014
|
462 |
"Groups.plus_class.plus" etc. not usable in scripts *)
|
neuper@37954
|
463 |
val calclist =
|
neuper@37954
|
464 |
[
|
neuper@37954
|
465 |
(*as Tools.ML*)
|
neuper@37954
|
466 |
("Vars" ,("Tools.Vars" ,eval_var "#Vars_")),
|
neuper@37954
|
467 |
("matches",("Tools.matches",eval_matches "#matches_")),
|
neuper@37954
|
468 |
("lhs" ,("Tools.lhs" ,eval_lhs "")),
|
neuper@37954
|
469 |
(*aus Atools.ML*)
|
neuper@38014
|
470 |
("PLUS" ,("Groups.plus_class.plus" ,eval_binop "#add_")),
|
neuper@38034
|
471 |
("TIMES" ,("Groups.times_class.times" ,eval_binop "#mult_")),
|
wneuper@59360
|
472 |
("DIVIDE" ,("Rings.divide_class.divide" ,eval_cancel "#divide_e")),
|
neuper@37954
|
473 |
("POWER" ,("Atools.pow" ,eval_binop "#power_")),
|
neuper@37954
|
474 |
("is_const",("Atools.is'_const",eval_const "#is_const_")),
|
neuper@38045
|
475 |
("le" ,("Orderings.ord_class.less" ,eval_equ "#less_")),
|
neuper@38045
|
476 |
("leq" ,("Orderings.ord_class.less_eq" ,eval_equ "#less_equal_")),
|
neuper@37954
|
477 |
("ident" ,("Atools.ident",eval_ident "#ident_")),
|
neuper@37954
|
478 |
(*von hier (ehem.SqRoot*)
|
neuper@37982
|
479 |
("sqrt" ,("NthRoot.sqrt" ,eval_sqrt "#sqrt_")),
|
wneuper@59403
|
480 |
("Test.contains_root",("contains'_root", eval_contains_root "#contains'_root")),
|
neuper@37954
|
481 |
("Test.contains_root",("contains'_root",
|
neuper@37954
|
482 |
eval_contains_root"#contains_root_"))
|
neuper@37954
|
483 |
];
|
neuper@52125
|
484 |
*}
|
wneuper@59374
|
485 |
ML {* val prep_rls' = LTool.prep_rls @{theory}; *}
|
neuper@52125
|
486 |
setup {* KEStore_Elems.add_rlss
|
s1210629013@55444
|
487 |
[("Test_simplify", (Context.theory_name @{theory}, prep_rls' Test_simplify)),
|
s1210629013@55444
|
488 |
("tval_rls", (Context.theory_name @{theory}, prep_rls' tval_rls)),
|
s1210629013@55444
|
489 |
("isolate_root", (Context.theory_name @{theory}, prep_rls' isolate_root)),
|
s1210629013@55444
|
490 |
("isolate_bdv", (Context.theory_name @{theory}, prep_rls' isolate_bdv)),
|
s1210629013@55444
|
491 |
("matches", (Context.theory_name @{theory}, prep_rls'
|
wneuper@59416
|
492 |
(Rule.append_rls "matches" testerls [Rule.Calc ("Tools.matches",eval_matches "#matches_")])))] *}
|
neuper@37954
|
493 |
|
neuper@37954
|
494 |
(** problem types **)
|
s1210629013@55359
|
495 |
setup {* KEStore_Elems.add_pbts
|
wneuper@59416
|
496 |
[(Specify.prep_pbt thy "pbl_test" [] Celem.e_pblID (["test"], [], Rule.e_rls, NONE, [])),
|
wneuper@59406
|
497 |
(Specify.prep_pbt thy "pbl_test_equ" [] Celem.e_pblID
|
s1210629013@55339
|
498 |
(["equation","test"],
|
s1210629013@55339
|
499 |
[("#Given" ,["equality e_e","solveFor v_v"]),
|
s1210629013@55339
|
500 |
("#Where" ,["matches (?a = ?b) e_e"]),
|
s1210629013@55339
|
501 |
("#Find" ,["solutions v_v'i'"])],
|
s1210629013@55339
|
502 |
assoc_rls' @{theory} "matches", SOME "solve (e_e::bool, v_v)", [])),
|
wneuper@59406
|
503 |
(Specify.prep_pbt thy "pbl_test_uni" [] Celem.e_pblID
|
s1210629013@55339
|
504 |
(["univariate","equation","test"],
|
s1210629013@55339
|
505 |
[("#Given" ,["equality e_e","solveFor v_v"]),
|
s1210629013@55339
|
506 |
("#Where" ,["matches (?a = ?b) e_e"]),
|
s1210629013@55339
|
507 |
("#Find" ,["solutions v_v'i'"])],
|
s1210629013@55339
|
508 |
assoc_rls' @{theory} "matches", SOME "solve (e_e::bool, v_v)", [])),
|
wneuper@59406
|
509 |
(Specify.prep_pbt thy "pbl_test_uni_lin" [] Celem.e_pblID
|
s1210629013@55339
|
510 |
(["LINEAR","univariate","equation","test"],
|
s1210629013@55339
|
511 |
[("#Given" ,["equality e_e","solveFor v_v"]),
|
s1210629013@55339
|
512 |
("#Where" ,["(matches ( v_v = 0) e_e) | (matches ( ?b*v_v = 0) e_e) |" ^
|
s1210629013@55339
|
513 |
"(matches (?a+v_v = 0) e_e) | (matches (?a+?b*v_v = 0) e_e) "]),
|
s1210629013@55339
|
514 |
("#Find" ,["solutions v_v'i'"])],
|
s1210629013@55339
|
515 |
assoc_rls' @{theory} "matches",
|
s1210629013@55339
|
516 |
SOME "solve (e_e::bool, v_v)", [["Test","solve_linear"]]))(*,
|
wneuper@59269
|
517 |
(Specify.prep_pbt thy
|
s1210629013@55339
|
518 |
(["thy"],
|
s1210629013@55339
|
519 |
[("#Given" ,"boolTestGiven g_g"),
|
s1210629013@55339
|
520 |
("#Find" ,"boolTestFind f_f")],
|
s1210629013@55339
|
521 |
[])),
|
wneuper@59269
|
522 |
(Specify.prep_pbt thy
|
s1210629013@55339
|
523 |
(["testeq","thy"],
|
s1210629013@55339
|
524 |
[("#Given" ,"boolTestGiven g_g"),
|
s1210629013@55339
|
525 |
("#Find" ,"boolTestFind f_f")],
|
s1210629013@55339
|
526 |
[]))*)] *}
|
wneuper@59352
|
527 |
(*val ttt = (Thm.term_of o the o (parse (Thy_Info_get_theory "Isac"))) "(matches ( v_v = 0) e_e)";
|
s1210629013@55363
|
528 |
|
s1210629013@55363
|
529 |
------ 25.8.01*)
|
s1210629013@55363
|
530 |
|
s1210629013@55373
|
531 |
(** methods **)
|
s1210629013@55373
|
532 |
setup {* KEStore_Elems.add_mets
|
wneuper@59406
|
533 |
[Specify.prep_met @{theory "Diff"} "met_test" [] Celem.e_metID
|
s1210629013@55373
|
534 |
(["Test"], [],
|
wneuper@59416
|
535 |
{rew_ord'="tless_true",rls'=Atools_erls,calc = [], srls = Rule.e_rls, prls=Rule.e_rls,
|
wneuper@59416
|
536 |
crls=Atools_erls, errpats = [], nrls = Rule.e_rls}, "empty_script"),
|
wneuper@59406
|
537 |
Specify.prep_met thy "met_test_solvelin" [] Celem.e_metID
|
wneuper@59406
|
538 |
(["Test","solve_linear"],
|
s1210629013@55373
|
539 |
[("#Given" ,["equality e_e","solveFor v_v"]),
|
s1210629013@55373
|
540 |
("#Where" ,["matches (?a = ?b) e_e"]),
|
s1210629013@55373
|
541 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59416
|
542 |
{rew_ord' = "e_rew_ord", rls' = tval_rls, srls = Rule.e_rls,
|
s1210629013@55373
|
543 |
prls = assoc_rls' @{theory} "matches", calc = [], crls = tval_rls, errpats = [],
|
s1210629013@55373
|
544 |
nrls = Test_simplify},
|
s1210629013@55373
|
545 |
"Script Solve_linear (e_e::bool) (v_v::real)= " ^
|
s1210629013@55373
|
546 |
"(let e_e = " ^
|
s1210629013@55373
|
547 |
" Repeat " ^
|
s1210629013@55373
|
548 |
" (((Rewrite_Set_Inst [(bdv,v_v::real)] isolate_bdv False) @@ " ^
|
s1210629013@55373
|
549 |
" (Rewrite_Set Test_simplify False))) e_e" ^
|
s1210629013@55373
|
550 |
" in [e_e::bool])")(*,
|
wneuper@59269
|
551 |
Specify.prep_met thy (*test for equations*)
|
wneuper@59406
|
552 |
(["Test","testeq"],
|
s1210629013@55373
|
553 |
[("#Given" ,["boolTestGiven g_g"]),
|
s1210629013@55373
|
554 |
("#Find" ,["boolTestFind f_f"])],
|
wneuper@59411
|
555 |
{rew_ord'="e_rew_ord",rls'="tval_rls",asm_rls=[], asm_thm=[("square_equation_left","")]},
|
s1210629013@55373
|
556 |
"Script Testeq (e_q::bool) = " ^
|
s1210629013@55373
|
557 |
"Repeat " ^
|
s1210629013@55373
|
558 |
" (let e_e = Try (Repeat (Rewrite rroot_square_inv False e_q)); " ^
|
s1210629013@55373
|
559 |
" e_e = Try (Repeat (Rewrite square_equation_left True e_e)); " ^
|
s1210629013@55373
|
560 |
" e_e = Try (Repeat (Rewrite rmult_0 False e_e)) " ^
|
s1210629013@55373
|
561 |
" in e_e) Until (is_root_free e_e)" (*deleted*)) ---------27.4.02*)]
|
s1210629013@55373
|
562 |
*}
|
neuper@37954
|
563 |
|
neuper@52125
|
564 |
setup {* KEStore_Elems.add_rlss
|
s1210629013@55444
|
565 |
[("norm_equation", (Context.theory_name @{theory}, prep_rls' norm_equation)),
|
s1210629013@55444
|
566 |
("ac_plus_times", (Context.theory_name @{theory}, prep_rls' ac_plus_times)),
|
s1210629013@55444
|
567 |
("rearrange_assoc", (Context.theory_name @{theory}, prep_rls' rearrange_assoc))] *}
|
neuper@52125
|
568 |
ML {*
|
neuper@37954
|
569 |
|
neuper@37954
|
570 |
|
neuper@37954
|
571 |
fun bin_o (Const (op_,(Type ("fun",
|
neuper@37954
|
572 |
[Type (s2,[]),Type ("fun",
|
neuper@37954
|
573 |
[Type (s4,tl4),Type (s5,tl5)])])))) =
|
neuper@37954
|
574 |
if (s2=s4)andalso(s4=s5)then[op_]else[]
|
neuper@37954
|
575 |
| bin_o _ = [];
|
neuper@37954
|
576 |
|
neuper@37954
|
577 |
fun bin_op (t1 $ t2) = union op = (bin_op t1) (bin_op t2)
|
neuper@37954
|
578 |
| bin_op t = bin_o t;
|
neuper@37954
|
579 |
fun is_bin_op t = ((bin_op t)<>[]);
|
neuper@37954
|
580 |
|
neuper@37954
|
581 |
fun bin_op_arg1 ((Const (op_,(Type ("fun",
|
neuper@37954
|
582 |
[Type (s2,[]),Type ("fun",
|
neuper@37954
|
583 |
[Type (s4,tl4),Type (s5,tl5)])]))))$ arg1 $ arg2) =
|
neuper@37954
|
584 |
arg1;
|
neuper@37954
|
585 |
fun bin_op_arg2 ((Const (op_,(Type ("fun",
|
neuper@37954
|
586 |
[Type (s2,[]),Type ("fun",
|
neuper@37954
|
587 |
[Type (s4,tl4),Type (s5,tl5)])]))))$ arg1 $ arg2) =
|
neuper@37954
|
588 |
arg2;
|
neuper@37954
|
589 |
|
neuper@37954
|
590 |
|
neuper@37954
|
591 |
exception NO_EQUATION_TERM;
|
neuper@41922
|
592 |
fun is_equation ((Const ("HOL.eq",(Type ("fun",
|
neuper@37954
|
593 |
[Type (_,[]),Type ("fun",
|
neuper@37954
|
594 |
[Type (_,[]),Type ("bool",[])])])))) $ _ $ _)
|
neuper@37954
|
595 |
= true
|
neuper@37954
|
596 |
| is_equation _ = false;
|
neuper@41922
|
597 |
fun equ_lhs ((Const ("HOL.eq",(Type ("fun",
|
neuper@37954
|
598 |
[Type (_,[]),Type ("fun",
|
neuper@37954
|
599 |
[Type (_,[]),Type ("bool",[])])])))) $ l $ r)
|
neuper@37954
|
600 |
= l
|
neuper@37954
|
601 |
| equ_lhs _ = raise NO_EQUATION_TERM;
|
neuper@41922
|
602 |
fun equ_rhs ((Const ("HOL.eq",(Type ("fun",
|
neuper@37954
|
603 |
[Type (_,[]),Type ("fun",
|
neuper@37954
|
604 |
[Type (_,[]),Type ("bool",[])])])))) $ l $ r)
|
neuper@37954
|
605 |
= r
|
neuper@37954
|
606 |
| equ_rhs _ = raise NO_EQUATION_TERM;
|
neuper@37954
|
607 |
|
neuper@37954
|
608 |
|
neuper@37954
|
609 |
fun atom (Const (_,Type (_,[]))) = true
|
neuper@37954
|
610 |
| atom (Free (_,Type (_,[]))) = true
|
neuper@37954
|
611 |
| atom (Var (_,Type (_,[]))) = true
|
neuper@37954
|
612 |
(*| atom (_ (_,"?DUMMY" )) = true ..ML-error *)
|
neuper@37954
|
613 |
| atom((Const ("Bin.integ_of_bin",_)) $ _) = true
|
neuper@37954
|
614 |
| atom _ = false;
|
neuper@37954
|
615 |
|
neuper@37954
|
616 |
fun varids (Const (s,Type (_,[]))) = [strip_thy s]
|
wneuper@59390
|
617 |
| varids (Free (s,Type (_,[]))) = if TermC.is_num' s then []
|
neuper@37954
|
618 |
else [strip_thy s]
|
neuper@37954
|
619 |
| varids (Var((s,_),Type (_,[]))) = [strip_thy s]
|
neuper@37954
|
620 |
(*| varids (_ (s,"?DUMMY" )) = ..ML-error *)
|
neuper@37954
|
621 |
| varids((Const ("Bin.integ_of_bin",_)) $ _)= [](*8.01: superfluous?*)
|
neuper@37954
|
622 |
| varids (Abs(a,T,t)) = union op = [a] (varids t)
|
neuper@37954
|
623 |
| varids (t1 $ t2) = union op = (varids t1) (varids t2)
|
neuper@37954
|
624 |
| varids _ = [];
|
wneuper@59186
|
625 |
(*> val t = Thm.term_of (hd (parse Diophant.thy "x"));
|
neuper@37954
|
626 |
val t = Free ("x","?DUMMY") : term
|
neuper@37954
|
627 |
> varids t;
|
neuper@37954
|
628 |
val it = [] : string list [] !!! *)
|
neuper@37954
|
629 |
|
neuper@37954
|
630 |
|
neuper@37954
|
631 |
fun bin_ops_only ((Const op_) $ t1 $ t2) =
|
neuper@37954
|
632 |
if(is_bin_op (Const op_))
|
neuper@37954
|
633 |
then(bin_ops_only t1)andalso(bin_ops_only t2)
|
neuper@37954
|
634 |
else false
|
neuper@37954
|
635 |
| bin_ops_only t =
|
neuper@37954
|
636 |
if atom t then true else bin_ops_only t;
|
neuper@37954
|
637 |
|
neuper@37954
|
638 |
fun polynomial opl t bdVar = (* bdVar TODO *)
|
neuper@37954
|
639 |
subset op = (bin_op t, opl) andalso (bin_ops_only t);
|
neuper@37954
|
640 |
|
neuper@37954
|
641 |
fun poly_equ opl bdVar t = is_equation t (* bdVar TODO *)
|
neuper@37954
|
642 |
andalso polynomial opl (equ_lhs t) bdVar
|
neuper@37954
|
643 |
andalso polynomial opl (equ_rhs t) bdVar
|
neuper@37954
|
644 |
andalso (subset op = (varids bdVar, varids (equ_lhs t)) orelse
|
neuper@37954
|
645 |
subset op = (varids bdVar, varids (equ_lhs t)));
|
neuper@37954
|
646 |
|
neuper@37954
|
647 |
(*fun max is =
|
neuper@37954
|
648 |
let fun max_ m [] = m
|
neuper@37954
|
649 |
| max_ m (i::is) = if m<i then max_ i is else max_ m is;
|
neuper@37954
|
650 |
in max_ (hd is) is end;
|
neuper@37954
|
651 |
> max [1,5,3,7,4,2];
|
neuper@37954
|
652 |
val it = 7 : int *)
|
neuper@37954
|
653 |
|
neuper@37954
|
654 |
fun max (a,b) = if a < b then b else a;
|
neuper@37954
|
655 |
|
neuper@37954
|
656 |
fun degree addl mul bdVar t =
|
neuper@37954
|
657 |
let
|
neuper@37954
|
658 |
fun deg _ _ v (Const (s,Type (_,[]))) = if v=strip_thy s then 1 else 0
|
neuper@37954
|
659 |
| deg _ _ v (Free (s,Type (_,[]))) = if v=strip_thy s then 1 else 0
|
neuper@37954
|
660 |
| deg _ _ v (Var((s,_),Type (_,[]))) = if v=strip_thy s then 1 else 0
|
neuper@37954
|
661 |
(*| deg _ _ v (_ (s,"?DUMMY" )) = ..ML-error *)
|
neuper@37954
|
662 |
| deg _ _ v((Const ("Bin.integ_of_bin",_)) $ _ )= 0
|
neuper@37954
|
663 |
| deg addl mul v (h $ t1 $ t2) =
|
neuper@37954
|
664 |
if subset op = (bin_op h, addl)
|
neuper@37954
|
665 |
then max (deg addl mul v t1 ,deg addl mul v t2)
|
neuper@37954
|
666 |
else (*mul!*)(deg addl mul v t1)+(deg addl mul v t2)
|
neuper@37954
|
667 |
in if polynomial (addl @ [mul]) t bdVar
|
neuper@37954
|
668 |
then SOME (deg addl mul (id_of bdVar) t) else (NONE:int option)
|
neuper@37954
|
669 |
end;
|
neuper@37954
|
670 |
fun degree_ addl mul bdVar t = (* do not export *)
|
neuper@37954
|
671 |
let fun opt (SOME i)= i
|
neuper@37954
|
672 |
| opt NONE = 0
|
neuper@37954
|
673 |
in opt (degree addl mul bdVar t) end;
|
neuper@37954
|
674 |
|
neuper@37954
|
675 |
|
neuper@37954
|
676 |
fun linear addl mul t bdVar = (degree_ addl mul bdVar t)<2;
|
neuper@37954
|
677 |
|
neuper@37954
|
678 |
fun linear_equ addl mul bdVar t =
|
neuper@37954
|
679 |
if is_equation t
|
neuper@37954
|
680 |
then let val degl = degree_ addl mul bdVar (equ_lhs t);
|
neuper@37954
|
681 |
val degr = degree_ addl mul bdVar (equ_rhs t)
|
neuper@37954
|
682 |
in if (degl>0 orelse degr>0)andalso max(degl,degr)<2
|
neuper@37954
|
683 |
then true else false
|
neuper@37954
|
684 |
end
|
neuper@37954
|
685 |
else false;
|
neuper@37954
|
686 |
(* strip_thy op_ before *)
|
neuper@37954
|
687 |
fun is_div_op (dv,(Const (op_,(Type ("fun",
|
neuper@37954
|
688 |
[Type (s2,[]),Type ("fun",
|
neuper@37954
|
689 |
[Type (s4,tl4),Type (s5,tl5)])])))) )= (dv = strip_thy op_)
|
neuper@37954
|
690 |
| is_div_op _ = false;
|
neuper@37954
|
691 |
|
neuper@37954
|
692 |
fun is_denom bdVar div_op t =
|
neuper@37954
|
693 |
let fun is bool[v]dv (Const (s,Type(_,[])))= bool andalso(if v=strip_thy s then true else false)
|
neuper@37954
|
694 |
| is bool[v]dv (Free (s,Type(_,[])))= bool andalso(if v=strip_thy s then true else false)
|
neuper@37954
|
695 |
| is bool[v]dv (Var((s,_),Type(_,[])))= bool andalso(if v=strip_thy s then true else false)
|
neuper@37954
|
696 |
| is bool[v]dv((Const ("Bin.integ_of_bin",_)) $ _) = false
|
neuper@37954
|
697 |
| is bool[v]dv (h$n$d) =
|
neuper@37954
|
698 |
if is_div_op(dv,h)
|
neuper@37954
|
699 |
then (is false[v]dv n)orelse(is true[v]dv d)
|
neuper@37954
|
700 |
else (is bool [v]dv n)orelse(is bool[v]dv d)
|
neuper@37954
|
701 |
in is false (varids bdVar) (strip_thy div_op) t end;
|
neuper@37954
|
702 |
|
neuper@37954
|
703 |
|
neuper@37954
|
704 |
fun rational t div_op bdVar =
|
neuper@37954
|
705 |
is_denom bdVar div_op t andalso bin_ops_only t;
|
neuper@37954
|
706 |
|
neuper@38001
|
707 |
*}
|
neuper@37954
|
708 |
(** problem types **)
|
s1210629013@55363
|
709 |
setup {* KEStore_Elems.add_pbts
|
wneuper@59406
|
710 |
[(Specify.prep_pbt thy "pbl_test_uni_plain2" [] Celem.e_pblID
|
s1210629013@55363
|
711 |
(["plain_square","univariate","equation","test"],
|
s1210629013@55363
|
712 |
[("#Given" ,["equality e_e","solveFor v_v"]),
|
s1210629013@55363
|
713 |
("#Where" ,["(matches (?a + ?b*v_v ^^^2 = 0) e_e) |" ^
|
s1210629013@55363
|
714 |
"(matches ( ?b*v_v ^^^2 = 0) e_e) |" ^
|
s1210629013@55363
|
715 |
"(matches (?a + v_v ^^^2 = 0) e_e) |" ^
|
s1210629013@55363
|
716 |
"(matches ( v_v ^^^2 = 0) e_e)"]),
|
s1210629013@55363
|
717 |
("#Find" ,["solutions v_v'i'"])],
|
s1210629013@55363
|
718 |
assoc_rls' @{theory} "matches",
|
s1210629013@55363
|
719 |
SOME "solve (e_e::bool, v_v)", [["Test","solve_plain_square"]]))] *}
|
neuper@37954
|
720 |
(*
|
wneuper@59186
|
721 |
val e_e = (Thm.term_of o the o (parse thy)) "e_e::bool";
|
wneuper@59186
|
722 |
val ve = (Thm.term_of o the o (parse thy)) "4 + 3*x^^^2 = 0";
|
neuper@37954
|
723 |
val env = [(e_,ve)];
|
neuper@37954
|
724 |
|
wneuper@59186
|
725 |
val pre = (Thm.term_of o the o (parse thy))
|
neuper@38001
|
726 |
"(matches (a + b*v_v ^^^2 = 0, e_e::bool)) |" ^
|
neuper@38001
|
727 |
"(matches ( b*v_v ^^^2 = 0, e_e::bool)) |" ^
|
neuper@37981
|
728 |
"(matches (a + v_v ^^^2 = 0, e_e::bool)) |" ^
|
neuper@37981
|
729 |
"(matches ( v_v ^^^2 = 0, e_e::bool))";
|
neuper@37954
|
730 |
val prei = subst_atomic env pre;
|
wneuper@59184
|
731 |
val cpre = (Thm.global_cterm_of thy) prei;
|
neuper@37954
|
732 |
|
neuper@37954
|
733 |
val SOME (ct,_) = rewrite_set_ thy false tval_rls cpre;
|
neuper@37954
|
734 |
val ct = "True | False | False | False" : cterm
|
neuper@37954
|
735 |
|
neuper@37954
|
736 |
> val SOME (ct,_) = rewrite_ thy sqrt_right tval_rls false or_false ct;
|
neuper@37954
|
737 |
> val SOME (ct,_) = rewrite_ thy sqrt_right tval_rls false or_false ct;
|
neuper@37954
|
738 |
> val SOME (ct,_) = rewrite_ thy sqrt_right tval_rls false or_false ct;
|
neuper@41928
|
739 |
val ct = "HOL.True" : cterm
|
neuper@37954
|
740 |
|
neuper@37954
|
741 |
*)
|
s1210629013@55359
|
742 |
setup {* KEStore_Elems.add_pbts
|
wneuper@59406
|
743 |
[(Specify.prep_pbt thy "pbl_test_uni_poly" [] Celem.e_pblID
|
s1210629013@55339
|
744 |
(["polynomial","univariate","equation","test"],
|
s1210629013@55339
|
745 |
[("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
|
s1210629013@55339
|
746 |
("#Where" ,["HOL.False"]),
|
s1210629013@55339
|
747 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59416
|
748 |
Rule.e_rls, SOME "solve (e_e::bool, v_v)", [])),
|
wneuper@59406
|
749 |
(Specify.prep_pbt thy "pbl_test_uni_poly_deg2" [] Celem.e_pblID
|
s1210629013@55339
|
750 |
(["degree_two","polynomial","univariate","equation","test"],
|
s1210629013@55339
|
751 |
[("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
|
s1210629013@55339
|
752 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59416
|
753 |
Rule.e_rls, SOME "solve (v_v ^^^2 + p_p * v_v + q__q = 0, v_v)", [])),
|
wneuper@59406
|
754 |
(Specify.prep_pbt thy "pbl_test_uni_poly_deg2_pq" [] Celem.e_pblID
|
s1210629013@55339
|
755 |
(["pq_formula","degree_two","polynomial","univariate","equation","test"],
|
s1210629013@55339
|
756 |
[("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
|
s1210629013@55339
|
757 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59416
|
758 |
Rule.e_rls, SOME "solve (v_v ^^^2 + p_p * v_v + q__q = 0, v_v)", [])),
|
wneuper@59406
|
759 |
(Specify.prep_pbt thy "pbl_test_uni_poly_deg2_abc" [] Celem.e_pblID
|
s1210629013@55339
|
760 |
(["abc_formula","degree_two","polynomial","univariate","equation","test"],
|
s1210629013@55339
|
761 |
[("#Given" ,["equality (a_a * x ^^^2 + b_b * x + c_c = 0)","solveFor v_v"]),
|
s1210629013@55339
|
762 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59416
|
763 |
Rule.e_rls, SOME "solve (a_a * x ^^^2 + b_b * x + c_c = 0, v_v)", [])),
|
wneuper@59406
|
764 |
(Specify.prep_pbt thy "pbl_test_uni_root" [] Celem.e_pblID
|
s1210629013@55339
|
765 |
(["squareroot","univariate","equation","test"],
|
s1210629013@55339
|
766 |
[("#Given" ,["equality e_e","solveFor v_v"]),
|
s1210629013@55339
|
767 |
("#Where" ,["precond_rootpbl v_v"]),
|
s1210629013@55339
|
768 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59416
|
769 |
Rule.append_rls "contains_root" Rule.e_rls [Rule.Calc ("Test.contains'_root",
|
s1210629013@55339
|
770 |
eval_contains_root "#contains_root_")],
|
s1210629013@55339
|
771 |
SOME "solve (e_e::bool, v_v)", [["Test","square_equation"]])),
|
wneuper@59406
|
772 |
(Specify.prep_pbt thy "pbl_test_uni_norm" [] Celem.e_pblID
|
wneuper@59367
|
773 |
(["normalise","univariate","equation","test"],
|
s1210629013@55339
|
774 |
[("#Given" ,["equality e_e","solveFor v_v"]),
|
s1210629013@55339
|
775 |
("#Where" ,[]),
|
s1210629013@55339
|
776 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59416
|
777 |
Rule.e_rls, SOME "solve (e_e::bool, v_v)", [["Test","norm_univar_equation"]])),
|
wneuper@59406
|
778 |
(Specify.prep_pbt thy "pbl_test_uni_roottest" [] Celem.e_pblID
|
s1210629013@55339
|
779 |
(["sqroot-test","univariate","equation","test"],
|
s1210629013@55339
|
780 |
[("#Given" ,["equality e_e","solveFor v_v"]),
|
s1210629013@55339
|
781 |
("#Where" ,["precond_rootpbl v_v"]),
|
s1210629013@55339
|
782 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59416
|
783 |
Rule.e_rls, SOME "solve (e_e::bool, v_v)", [])),
|
wneuper@59406
|
784 |
(Specify.prep_pbt thy "pbl_test_intsimp" [] Celem.e_pblID
|
s1210629013@55339
|
785 |
(["inttype","test"],
|
s1210629013@55339
|
786 |
[("#Given" ,["intTestGiven t_t"]),
|
s1210629013@55339
|
787 |
("#Where" ,[]),
|
s1210629013@55339
|
788 |
("#Find" ,["intTestFind s_s"])],
|
wneuper@59416
|
789 |
Rule.e_rls, NONE, [["Test","intsimp"]]))] *}
|
s1210629013@55363
|
790 |
(*
|
s1210629013@55363
|
791 |
show_ptyps();
|
s1210629013@55363
|
792 |
get_pbt ["inttype","test"];
|
s1210629013@55363
|
793 |
*)
|
neuper@41934
|
794 |
|
s1210629013@55373
|
795 |
setup {* KEStore_Elems.add_mets
|
wneuper@59406
|
796 |
[Specify.prep_met thy "met_test_sqrt" [] Celem.e_metID
|
s1210629013@55373
|
797 |
(*root-equation, version for tests before 8.01.01*)
|
wneuper@59406
|
798 |
(["Test","sqrt-equ-test"],
|
s1210629013@55373
|
799 |
[("#Given" ,["equality e_e","solveFor v_v"]),
|
s1210629013@55373
|
800 |
("#Where" ,["contains_root (e_e::bool)"]),
|
s1210629013@55373
|
801 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59411
|
802 |
{rew_ord'="e_rew_ord",rls'=tval_rls,
|
wneuper@59416
|
803 |
srls = Rule.append_rls "srls_contains_root" Rule.e_rls
|
wneuper@59416
|
804 |
[Rule.Calc ("Test.contains'_root",eval_contains_root "")],
|
wneuper@59416
|
805 |
prls = Rule.append_rls "prls_contains_root" Rule.e_rls
|
wneuper@59416
|
806 |
[Rule.Calc ("Test.contains'_root",eval_contains_root "")],
|
wneuper@59416
|
807 |
calc=[], crls=tval_rls, errpats = [], nrls = Rule.e_rls (*,asm_rls=[],
|
s1210629013@55373
|
808 |
asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
|
s1210629013@55373
|
809 |
"Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
|
s1210629013@55373
|
810 |
"(let e_e = " ^
|
s1210629013@55373
|
811 |
" ((While (contains_root e_e) Do" ^
|
s1210629013@55373
|
812 |
" ((Rewrite square_equation_left True) @@" ^
|
s1210629013@55373
|
813 |
" (Try (Rewrite_Set Test_simplify False)) @@" ^
|
s1210629013@55373
|
814 |
" (Try (Rewrite_Set rearrange_assoc False)) @@" ^
|
s1210629013@55373
|
815 |
" (Try (Rewrite_Set isolate_root False)) @@" ^
|
s1210629013@55373
|
816 |
" (Try (Rewrite_Set Test_simplify False)))) @@" ^
|
s1210629013@55373
|
817 |
" (Try (Rewrite_Set norm_equation False)) @@" ^
|
s1210629013@55373
|
818 |
" (Try (Rewrite_Set Test_simplify False)) @@" ^
|
s1210629013@55373
|
819 |
" (Rewrite_Set_Inst [(bdv,v_v::real)] isolate_bdv False) @@" ^
|
s1210629013@55373
|
820 |
" (Try (Rewrite_Set Test_simplify False)))" ^
|
s1210629013@55373
|
821 |
" e_e" ^
|
s1210629013@55373
|
822 |
" in [e_e::bool])"),
|
wneuper@59406
|
823 |
Specify.prep_met thy "met_test_sqrt2" [] Celem.e_metID
|
s1210629013@55373
|
824 |
(*root-equation ... for test-*.sml until 8.01*)
|
wneuper@59406
|
825 |
(["Test","squ-equ-test2"],
|
s1210629013@55373
|
826 |
[("#Given" ,["equality e_e","solveFor v_v"]),
|
s1210629013@55373
|
827 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59411
|
828 |
{rew_ord'="e_rew_ord",rls'=tval_rls,
|
wneuper@59416
|
829 |
srls = Rule.append_rls "srls_contains_root" Rule.e_rls
|
wneuper@59416
|
830 |
[Rule.Calc ("Test.contains'_root",eval_contains_root"")],
|
wneuper@59416
|
831 |
prls=Rule.e_rls,calc=[], crls=tval_rls, errpats = [], nrls = Rule.e_rls(*,asm_rls=[],
|
s1210629013@55373
|
832 |
asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
|
s1210629013@55373
|
833 |
"Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
|
s1210629013@55373
|
834 |
"(let e_e = " ^
|
s1210629013@55373
|
835 |
" ((While (contains_root e_e) Do" ^
|
s1210629013@55373
|
836 |
" ((Rewrite square_equation_left True) @@" ^
|
s1210629013@55373
|
837 |
" (Try (Rewrite_Set Test_simplify False)) @@" ^
|
s1210629013@55373
|
838 |
" (Try (Rewrite_Set rearrange_assoc False)) @@" ^
|
s1210629013@55373
|
839 |
" (Try (Rewrite_Set isolate_root False)) @@" ^
|
s1210629013@55373
|
840 |
" (Try (Rewrite_Set Test_simplify False)))) @@" ^
|
s1210629013@55373
|
841 |
" (Try (Rewrite_Set norm_equation False)) @@" ^
|
s1210629013@55373
|
842 |
" (Try (Rewrite_Set Test_simplify False)) @@" ^
|
s1210629013@55373
|
843 |
" (Rewrite_Set_Inst [(bdv,v_v::real)] isolate_bdv False) @@" ^
|
s1210629013@55373
|
844 |
" (Try (Rewrite_Set Test_simplify False)))" ^
|
s1210629013@55373
|
845 |
" e_e;" ^
|
s1210629013@55373
|
846 |
" (L_L::bool list) = Tac subproblem_equation_dummy; " ^
|
s1210629013@55373
|
847 |
" L_L = Tac solve_equation_dummy " ^
|
s1210629013@55373
|
848 |
" in Check_elementwise L_L {(v_v::real). Assumptions})"),
|
wneuper@59406
|
849 |
Specify.prep_met thy "met_test_squ_sub" [] Celem.e_metID
|
s1210629013@55373
|
850 |
(*tests subproblem fixed linear*)
|
wneuper@59406
|
851 |
(["Test","squ-equ-test-subpbl1"],
|
s1210629013@55373
|
852 |
[("#Given" ,["equality e_e","solveFor v_v"]),
|
s1210629013@55373
|
853 |
("#Where" ,["precond_rootmet v_v"]),
|
s1210629013@55373
|
854 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59416
|
855 |
{rew_ord' = "e_rew_ord", rls' = tval_rls, srls = Rule.e_rls,
|
wneuper@59416
|
856 |
prls = Rule.append_rls "prls_met_test_squ_sub" Rule.e_rls
|
wneuper@59416
|
857 |
[Rule.Calc ("Test.precond'_rootmet", eval_precond_rootmet "")],
|
s1210629013@55373
|
858 |
calc=[], crls=tval_rls, errpats = [], nrls = Test_simplify},
|
s1210629013@55373
|
859 |
"Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
|
s1210629013@55373
|
860 |
" (let e_e = ((Try (Rewrite_Set norm_equation False)) @@ " ^
|
s1210629013@55373
|
861 |
" (Try (Rewrite_Set Test_simplify False))) e_e; " ^
|
s1210629013@55373
|
862 |
" (L_L::bool list) = " ^
|
s1210629013@55373
|
863 |
" (SubProblem (Test', " ^
|
s1210629013@55373
|
864 |
" [LINEAR,univariate,equation,test]," ^
|
s1210629013@55373
|
865 |
" [Test,solve_linear]) " ^
|
s1210629013@55373
|
866 |
" [BOOL e_e, REAL v_v]) " ^
|
s1210629013@55373
|
867 |
" in Check_elementwise L_L {(v_v::real). Assumptions}) "),
|
wneuper@59406
|
868 |
Specify.prep_met thy "met_test_squ_sub2" [] Celem.e_metID
|
s1210629013@55373
|
869 |
(*tests subproblem fixed degree 2*)
|
wneuper@59406
|
870 |
(["Test","squ-equ-test-subpbl2"],
|
s1210629013@55373
|
871 |
[("#Given" ,["equality e_e","solveFor v_v"]),
|
s1210629013@55373
|
872 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59416
|
873 |
{rew_ord'="e_rew_ord",rls'=tval_rls,srls=Rule.e_rls,prls=Rule.e_rls,calc=[], crls=tval_rls,
|
wneuper@59416
|
874 |
errpats = [], nrls = Rule.e_rls (*, asm_rls=[],asm_thm=[("square_equation_left",""),
|
s1210629013@55373
|
875 |
("square_equation_right","")]*)},
|
s1210629013@55373
|
876 |
"Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
|
s1210629013@55373
|
877 |
" (let e_e = Try (Rewrite_Set norm_equation False) e_e; " ^
|
s1210629013@55373
|
878 |
"(L_L::bool list) = (SubProblem (Test',[LINEAR,univariate,equation,test]," ^
|
s1210629013@55373
|
879 |
" [Test,solve_by_pq_formula]) [BOOL e_e, REAL v_v])" ^
|
s1210629013@55373
|
880 |
"in Check_elementwise L_L {(v_v::real). Assumptions})"),
|
wneuper@59406
|
881 |
Specify.prep_met thy "met_test_squ_nonterm" [] Celem.e_metID
|
s1210629013@55373
|
882 |
(*root-equation: see foils..., but notTerminating*)
|
wneuper@59406
|
883 |
(["Test","square_equation...notTerminating"],
|
s1210629013@55373
|
884 |
[("#Given" ,["equality e_e","solveFor v_v"]),
|
s1210629013@55373
|
885 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59411
|
886 |
{rew_ord'="e_rew_ord",rls'=tval_rls,
|
wneuper@59416
|
887 |
srls = Rule.append_rls "srls_contains_root" Rule.e_rls
|
wneuper@59416
|
888 |
[Rule.Calc ("Test.contains'_root",eval_contains_root"")],
|
wneuper@59416
|
889 |
prls=Rule.e_rls,calc=[], crls=tval_rls, errpats = [], nrls = Rule.e_rls(*,asm_rls=[],
|
s1210629013@55373
|
890 |
asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
|
s1210629013@55373
|
891 |
"Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
|
s1210629013@55373
|
892 |
"(let e_e = " ^
|
s1210629013@55373
|
893 |
" ((While (contains_root e_e) Do" ^
|
s1210629013@55373
|
894 |
" ((Rewrite square_equation_left True) @@" ^
|
s1210629013@55373
|
895 |
" (Try (Rewrite_Set Test_simplify False)) @@" ^
|
s1210629013@55373
|
896 |
" (Try (Rewrite_Set rearrange_assoc False)) @@" ^
|
s1210629013@55373
|
897 |
" (Try (Rewrite_Set isolate_root False)) @@" ^
|
s1210629013@55373
|
898 |
" (Try (Rewrite_Set Test_simplify False)))) @@" ^
|
s1210629013@55373
|
899 |
" (Try (Rewrite_Set norm_equation False)) @@" ^
|
s1210629013@55373
|
900 |
" (Try (Rewrite_Set Test_simplify False)))" ^
|
s1210629013@55373
|
901 |
" e_e;" ^
|
s1210629013@55373
|
902 |
" (L_L::bool list) = " ^
|
s1210629013@55373
|
903 |
" (SubProblem (Test',[LINEAR,univariate,equation,test]," ^
|
s1210629013@55373
|
904 |
" [Test,solve_linear]) [BOOL e_e, REAL v_v])" ^
|
s1210629013@55373
|
905 |
"in Check_elementwise L_L {(v_v::real). Assumptions})"),
|
wneuper@59406
|
906 |
Specify.prep_met thy "met_test_eq1" [] Celem.e_metID
|
s1210629013@55373
|
907 |
(*root-equation1:*)
|
wneuper@59406
|
908 |
(["Test","square_equation1"],
|
s1210629013@55373
|
909 |
[("#Given" ,["equality e_e","solveFor v_v"]),
|
s1210629013@55373
|
910 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59411
|
911 |
{rew_ord'="e_rew_ord",rls'=tval_rls,
|
wneuper@59416
|
912 |
srls = Rule.append_rls "srls_contains_root" Rule.e_rls
|
wneuper@59416
|
913 |
[Rule.Calc ("Test.contains'_root",eval_contains_root"")], prls=Rule.e_rls, calc=[], crls=tval_rls,
|
wneuper@59416
|
914 |
errpats = [], nrls = Rule.e_rls(*,asm_rls=[], asm_thm=[("square_equation_left",""),
|
s1210629013@55373
|
915 |
("square_equation_right","")]*)},
|
s1210629013@55373
|
916 |
"Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
|
s1210629013@55373
|
917 |
"(let e_e = " ^
|
s1210629013@55373
|
918 |
" ((While (contains_root e_e) Do" ^
|
s1210629013@55373
|
919 |
" ((Rewrite square_equation_left True) @@" ^
|
s1210629013@55373
|
920 |
" (Try (Rewrite_Set Test_simplify False)) @@" ^
|
s1210629013@55373
|
921 |
" (Try (Rewrite_Set rearrange_assoc False)) @@" ^
|
s1210629013@55373
|
922 |
" (Try (Rewrite_Set isolate_root False)) @@" ^
|
s1210629013@55373
|
923 |
" (Try (Rewrite_Set Test_simplify False)))) @@" ^
|
s1210629013@55373
|
924 |
" (Try (Rewrite_Set norm_equation False)) @@" ^
|
s1210629013@55373
|
925 |
" (Try (Rewrite_Set Test_simplify False)))" ^
|
s1210629013@55373
|
926 |
" e_e;" ^
|
s1210629013@55373
|
927 |
" (L_L::bool list) = (SubProblem (Test',[LINEAR,univariate,equation,test]," ^
|
s1210629013@55373
|
928 |
" [Test,solve_linear]) [BOOL e_e, REAL v_v])" ^
|
s1210629013@55373
|
929 |
" in Check_elementwise L_L {(v_v::real). Assumptions})"),
|
wneuper@59406
|
930 |
Specify.prep_met thy "met_test_squ2" [] Celem.e_metID
|
s1210629013@55373
|
931 |
(*root-equation2*)
|
wneuper@59406
|
932 |
(["Test","square_equation2"],
|
s1210629013@55373
|
933 |
[("#Given" ,["equality e_e","solveFor v_v"]),
|
s1210629013@55373
|
934 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59411
|
935 |
{rew_ord'="e_rew_ord",rls'=tval_rls,
|
wneuper@59416
|
936 |
srls = Rule.append_rls "srls_contains_root" Rule.e_rls
|
wneuper@59416
|
937 |
[Rule.Calc ("Test.contains'_root",eval_contains_root"")],
|
wneuper@59416
|
938 |
prls=Rule.e_rls,calc=[], crls=tval_rls, errpats = [], nrls = Rule.e_rls(*,asm_rls=[],
|
s1210629013@55373
|
939 |
asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
|
s1210629013@55373
|
940 |
"Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
|
s1210629013@55373
|
941 |
"(let e_e = " ^
|
s1210629013@55373
|
942 |
" ((While (contains_root e_e) Do" ^
|
s1210629013@55373
|
943 |
" (((Rewrite square_equation_left True) Or " ^
|
s1210629013@55373
|
944 |
" (Rewrite square_equation_right True)) @@" ^
|
s1210629013@55373
|
945 |
" (Try (Rewrite_Set Test_simplify False)) @@" ^
|
s1210629013@55373
|
946 |
" (Try (Rewrite_Set rearrange_assoc False)) @@" ^
|
s1210629013@55373
|
947 |
" (Try (Rewrite_Set isolate_root False)) @@" ^
|
s1210629013@55373
|
948 |
" (Try (Rewrite_Set Test_simplify False)))) @@" ^
|
s1210629013@55373
|
949 |
" (Try (Rewrite_Set norm_equation False)) @@" ^
|
s1210629013@55373
|
950 |
" (Try (Rewrite_Set Test_simplify False)))" ^
|
s1210629013@55373
|
951 |
" e_e;" ^
|
s1210629013@55373
|
952 |
" (L_L::bool list) = (SubProblem (Test',[plain_square,univariate,equation,test]," ^
|
s1210629013@55373
|
953 |
" [Test,solve_plain_square]) [BOOL e_e, REAL v_v])" ^
|
s1210629013@55373
|
954 |
" in Check_elementwise L_L {(v_v::real). Assumptions})"),
|
wneuper@59406
|
955 |
Specify.prep_met thy "met_test_squeq" [] Celem.e_metID
|
s1210629013@55373
|
956 |
(*root-equation*)
|
wneuper@59406
|
957 |
(["Test","square_equation"],
|
s1210629013@55373
|
958 |
[("#Given" ,["equality e_e","solveFor v_v"]),
|
s1210629013@55373
|
959 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59411
|
960 |
{rew_ord'="e_rew_ord",rls'=tval_rls,
|
wneuper@59416
|
961 |
srls = Rule.append_rls "srls_contains_root" Rule.e_rls
|
wneuper@59416
|
962 |
[Rule.Calc ("Test.contains'_root",eval_contains_root"")],
|
wneuper@59416
|
963 |
prls=Rule.e_rls,calc=[], crls=tval_rls, errpats = [], nrls = Rule.e_rls (*,asm_rls=[],
|
s1210629013@55373
|
964 |
asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
|
s1210629013@55373
|
965 |
"Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
|
s1210629013@55373
|
966 |
"(let e_e = " ^
|
s1210629013@55373
|
967 |
" ((While (contains_root e_e) Do" ^
|
s1210629013@55373
|
968 |
" (((Rewrite square_equation_left True) Or" ^
|
s1210629013@55373
|
969 |
" (Rewrite square_equation_right True)) @@" ^
|
s1210629013@55373
|
970 |
" (Try (Rewrite_Set Test_simplify False)) @@" ^
|
s1210629013@55373
|
971 |
" (Try (Rewrite_Set rearrange_assoc False)) @@" ^
|
s1210629013@55373
|
972 |
" (Try (Rewrite_Set isolate_root False)) @@" ^
|
s1210629013@55373
|
973 |
" (Try (Rewrite_Set Test_simplify False)))) @@" ^
|
s1210629013@55373
|
974 |
" (Try (Rewrite_Set norm_equation False)) @@" ^
|
s1210629013@55373
|
975 |
" (Try (Rewrite_Set Test_simplify False)))" ^
|
s1210629013@55373
|
976 |
" e_e;" ^
|
s1210629013@55373
|
977 |
" (L_L::bool list) = (SubProblem (Test',[univariate,equation,test]," ^
|
s1210629013@55373
|
978 |
" [no_met]) [BOOL e_e, REAL v_v])" ^
|
s1210629013@55373
|
979 |
" in Check_elementwise L_L {(v_v::real). Assumptions})"),
|
wneuper@59406
|
980 |
Specify.prep_met thy "met_test_eq_plain" [] Celem.e_metID
|
s1210629013@55373
|
981 |
(*solve_plain_square*)
|
wneuper@59406
|
982 |
(["Test","solve_plain_square"],
|
s1210629013@55373
|
983 |
[("#Given",["equality e_e","solveFor v_v"]),
|
s1210629013@55373
|
984 |
("#Where" ,["(matches (?a + ?b*v_v ^^^2 = 0) e_e) |" ^
|
s1210629013@55373
|
985 |
"(matches ( ?b*v_v ^^^2 = 0) e_e) |" ^
|
s1210629013@55373
|
986 |
"(matches (?a + v_v ^^^2 = 0) e_e) |" ^
|
s1210629013@55373
|
987 |
"(matches ( v_v ^^^2 = 0) e_e)"]),
|
s1210629013@55373
|
988 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59416
|
989 |
{rew_ord'="e_rew_ord",rls'=tval_rls,calc=[],srls=Rule.e_rls,
|
wneuper@59416
|
990 |
prls = assoc_rls' @{theory} "matches", crls=tval_rls, errpats = [], nrls = Rule.e_rls(*,
|
s1210629013@55373
|
991 |
asm_rls=[],asm_thm=[]*)},
|
s1210629013@55373
|
992 |
"Script Solve_plain_square (e_e::bool) (v_v::real) = " ^
|
s1210629013@55373
|
993 |
" (let e_e = ((Try (Rewrite_Set isolate_bdv False)) @@ " ^
|
s1210629013@55373
|
994 |
" (Try (Rewrite_Set Test_simplify False)) @@ " ^
|
s1210629013@55373
|
995 |
" ((Rewrite square_equality_0 False) Or " ^
|
s1210629013@55373
|
996 |
" (Rewrite square_equality True)) @@ " ^
|
s1210629013@55373
|
997 |
" (Try (Rewrite_Set tval_rls False))) e_e " ^
|
s1210629013@55373
|
998 |
" in ((Or_to_List e_e)::bool list))"),
|
wneuper@59406
|
999 |
Specify.prep_met thy "met_test_norm_univ" [] Celem.e_metID
|
wneuper@59406
|
1000 |
(["Test","norm_univar_equation"],
|
s1210629013@55373
|
1001 |
[("#Given",["equality e_e","solveFor v_v"]),
|
s1210629013@55373
|
1002 |
("#Where" ,[]),
|
s1210629013@55373
|
1003 |
("#Find" ,["solutions v_v'i'"])],
|
wneuper@59416
|
1004 |
{rew_ord'="e_rew_ord",rls'=tval_rls,srls = Rule.e_rls,prls=Rule.e_rls, calc=[], crls=tval_rls,
|
wneuper@59416
|
1005 |
errpats = [], nrls = Rule.e_rls},
|
s1210629013@55373
|
1006 |
"Script Norm_univar_equation (e_e::bool) (v_v::real) = " ^
|
s1210629013@55373
|
1007 |
" (let e_e = ((Try (Rewrite rnorm_equation_add False)) @@ " ^
|
s1210629013@55373
|
1008 |
" (Try (Rewrite_Set Test_simplify False))) e_e " ^
|
s1210629013@55373
|
1009 |
" in (SubProblem (Test',[univariate,equation,test], " ^
|
s1210629013@55373
|
1010 |
" [no_met]) [BOOL e_e, REAL v_v]))"),
|
s1210629013@55373
|
1011 |
(*17.9.02 aus SqRoot.ML------------------------------^^^---*)
|
wneuper@59406
|
1012 |
Specify.prep_met thy "met_test_intsimp" [] Celem.e_metID
|
wneuper@59406
|
1013 |
(["Test","intsimp"],
|
s1210629013@55373
|
1014 |
[("#Given" ,["intTestGiven t_t"]),
|
s1210629013@55373
|
1015 |
("#Where" ,[]),
|
s1210629013@55373
|
1016 |
("#Find" ,["intTestFind s_s"])],
|
wneuper@59416
|
1017 |
{rew_ord' = "e_rew_ord", rls' = tval_rls, srls = Rule.e_rls, prls = Rule.e_rls, calc = [],
|
s1210629013@55373
|
1018 |
crls = tval_rls, errpats = [], nrls = Test_simplify},
|
s1210629013@55373
|
1019 |
"Script STest_simplify (t_t::int) = " ^
|
s1210629013@55373
|
1020 |
"(Repeat " ^
|
s1210629013@55373
|
1021 |
" ((Try (Calculate PLUS)) @@ " ^
|
s1210629013@55373
|
1022 |
" (Try (Calculate TIMES))) t_t::int)")]
|
s1210629013@55373
|
1023 |
*}
|
neuper@41934
|
1024 |
|
neuper@38001
|
1025 |
ML {*
|
neuper@37954
|
1026 |
(*8.4.03 aus Poly.ML--------------------------------vvv---
|
neuper@37954
|
1027 |
make_polynomial ---> make_poly
|
neuper@37954
|
1028 |
^-- for user ^-- for systest _ONLY_*)
|
neuper@37954
|
1029 |
|
neuper@37954
|
1030 |
local (*. for make_polytest .*)
|
neuper@37954
|
1031 |
|
neuper@37954
|
1032 |
open Term; (* for type order = EQUAL | LESS | GREATER *)
|
neuper@37954
|
1033 |
|
neuper@37954
|
1034 |
fun pr_ord EQUAL = "EQUAL"
|
neuper@37954
|
1035 |
| pr_ord LESS = "LESS"
|
neuper@37954
|
1036 |
| pr_ord GREATER = "GREATER";
|
neuper@37954
|
1037 |
|
neuper@37954
|
1038 |
fun dest_hd' (Const (a, T)) = (* ~ term.ML *)
|
neuper@37954
|
1039 |
(case a of
|
neuper@37954
|
1040 |
"Atools.pow" => ((("|||||||||||||", 0), T), 0) (*WN greatest *)
|
neuper@37954
|
1041 |
| _ => (((a, 0), T), 0))
|
neuper@37954
|
1042 |
| dest_hd' (Free (a, T)) = (((a, 0), T), 1)
|
neuper@37954
|
1043 |
| dest_hd' (Var v) = (v, 2)
|
neuper@37954
|
1044 |
| dest_hd' (Bound i) = ((("", i), dummyT), 3)
|
neuper@37954
|
1045 |
| dest_hd' (Abs (_, T, _)) = ((("", 0), T), 4);
|
neuper@37954
|
1046 |
(* RL *)
|
neuper@37954
|
1047 |
fun get_order_pow (t $ (Free(order,_))) =
|
wneuper@59390
|
1048 |
(case TermC.int_of_str_opt (order) of
|
neuper@37954
|
1049 |
SOME d => d
|
neuper@37954
|
1050 |
| NONE => 0)
|
neuper@37954
|
1051 |
| get_order_pow _ = 0;
|
neuper@37954
|
1052 |
|
neuper@37954
|
1053 |
fun size_of_term' (Const(str,_) $ t) =
|
neuper@37954
|
1054 |
if "Atools.pow"=str then 1000 + size_of_term' t else 1 + size_of_term' t(*WN*)
|
neuper@37954
|
1055 |
| size_of_term' (Abs (_,_,body)) = 1 + size_of_term' body
|
neuper@37954
|
1056 |
| size_of_term' (f$t) = size_of_term' f + size_of_term' t
|
neuper@37954
|
1057 |
| size_of_term' _ = 1;
|
neuper@38001
|
1058 |
fun term_ord' pr thy (Abs (_, T, t), Abs(_, U, u)) = (* ~ term.ML *)
|
neuper@38053
|
1059 |
(case term_ord' pr thy (t, u) of EQUAL => Term_Ord.typ_ord (T, U)
|
neuper@38053
|
1060 |
| ord => ord)
|
neuper@38001
|
1061 |
| term_ord' pr thy (t, u) =
|
neuper@38053
|
1062 |
(if pr then
|
neuper@38053
|
1063 |
let val (f, ts) = strip_comb t and (g, us) = strip_comb u;
|
wneuper@59416
|
1064 |
val _ = tracing ("t= f@ts= \"" ^ Rule.term2str f ^ "\" @ \"[" ^
|
wneuper@59416
|
1065 |
commas(map Rule.term2str ts) ^ "]\"")
|
wneuper@59416
|
1066 |
val _ = tracing ("u= g@us= \"" ^ Rule.term2str g ^"\" @ \"[" ^
|
wneuper@59416
|
1067 |
commas(map Rule.term2str us) ^"]\"")
|
neuper@38053
|
1068 |
val _ = tracing ("size_of_term(t,u)= (" ^
|
neuper@38053
|
1069 |
string_of_int (size_of_term' t) ^ ", " ^
|
neuper@38053
|
1070 |
string_of_int (size_of_term' u) ^ ")")
|
neuper@38053
|
1071 |
val _ = tracing ("hd_ord(f,g) = " ^ (pr_ord o hd_ord) (f,g))
|
neuper@38053
|
1072 |
val _ = tracing ("terms_ord(ts,us) = " ^
|
neuper@38053
|
1073 |
(pr_ord o terms_ord str false) (ts,us));
|
neuper@38053
|
1074 |
val _ = tracing "-------"
|
neuper@37954
|
1075 |
in () end
|
neuper@37954
|
1076 |
else ();
|
neuper@37954
|
1077 |
case int_ord (size_of_term' t, size_of_term' u) of
|
neuper@37954
|
1078 |
EQUAL =>
|
neuper@37954
|
1079 |
let val (f, ts) = strip_comb t and (g, us) = strip_comb u in
|
neuper@37954
|
1080 |
(case hd_ord (f, g) of EQUAL => (terms_ord str pr) (ts, us)
|
neuper@37954
|
1081 |
| ord => ord)
|
neuper@37954
|
1082 |
end
|
neuper@37954
|
1083 |
| ord => ord)
|
neuper@37954
|
1084 |
and hd_ord (f, g) = (* ~ term.ML *)
|
neuper@37991
|
1085 |
prod_ord (prod_ord Term_Ord.indexname_ord Term_Ord.typ_ord) int_ord (dest_hd' f, dest_hd' g)
|
neuper@37954
|
1086 |
and terms_ord str pr (ts, us) =
|
wneuper@59406
|
1087 |
list_ord (term_ord' pr (Celem.assoc_thy "Isac"))(ts, us);
|
neuper@37954
|
1088 |
in
|
neuper@37954
|
1089 |
|
wneuper@59416
|
1090 |
fun ord_make_polytest (pr:bool) thy (_: Rule.subst) tu =
|
neuper@37954
|
1091 |
(term_ord' pr thy(***) tu = LESS );
|
neuper@37954
|
1092 |
|
neuper@37954
|
1093 |
end;(*local*)
|
neuper@38001
|
1094 |
*}
|
neuper@38001
|
1095 |
ML {*
|
neuper@37954
|
1096 |
|
wneuper@59416
|
1097 |
Rule.rew_ord' := overwritel (! Rule.rew_ord',
|
neuper@37954
|
1098 |
[("termlessI", termlessI),
|
neuper@37954
|
1099 |
("ord_make_polytest", ord_make_polytest false thy)
|
neuper@37954
|
1100 |
]);
|
neuper@37954
|
1101 |
|
s1210629013@55444
|
1102 |
(*WN060510 this was a preparation for prep_rls' ...
|
neuper@37954
|
1103 |
val scr_make_polytest =
|
neuper@38001
|
1104 |
"Script Expand_binomtest t_t =" ^
|
neuper@37954
|
1105 |
"(Repeat " ^
|
neuper@37954
|
1106 |
"((Try (Repeat (Rewrite real_diff_minus False))) @@ " ^
|
neuper@37954
|
1107 |
|
neuper@52062
|
1108 |
" (Try (Repeat (Rewrite distrib_right False))) @@ " ^
|
neuper@52062
|
1109 |
" (Try (Repeat (Rewrite distrib_left False))) @@ " ^
|
neuper@37971
|
1110 |
" (Try (Repeat (Rewrite left_diff_distrib False))) @@ " ^
|
neuper@37971
|
1111 |
" (Try (Repeat (Rewrite right_diff_distrib False))) @@ " ^
|
neuper@37954
|
1112 |
|
neuper@37971
|
1113 |
" (Try (Repeat (Rewrite mult_1_left False))) @@ " ^
|
neuper@37971
|
1114 |
" (Try (Repeat (Rewrite mult_zero_left False))) @@ " ^
|
neuper@37971
|
1115 |
" (Try (Repeat (Rewrite add_0_left False))) @@ " ^
|
neuper@37954
|
1116 |
|
neuper@48763
|
1117 |
" (Try (Repeat (Rewrite mult_commute False))) @@ " ^
|
neuper@37954
|
1118 |
" (Try (Repeat (Rewrite real_mult_left_commute False))) @@ " ^
|
neuper@48763
|
1119 |
" (Try (Repeat (Rewrite mult_assoc False))) @@ " ^
|
neuper@37971
|
1120 |
" (Try (Repeat (Rewrite add_commute False))) @@ " ^
|
neuper@37971
|
1121 |
" (Try (Repeat (Rewrite add_left_commute False))) @@ " ^
|
neuper@37971
|
1122 |
" (Try (Repeat (Rewrite add_assoc False))) @@ " ^
|
neuper@37954
|
1123 |
|
neuper@37954
|
1124 |
" (Try (Repeat (Rewrite sym_realpow_twoI False))) @@ " ^
|
neuper@37954
|
1125 |
" (Try (Repeat (Rewrite realpow_plus_1 False))) @@ " ^
|
neuper@37954
|
1126 |
" (Try (Repeat (Rewrite sym_real_mult_2 False))) @@ " ^
|
neuper@37954
|
1127 |
" (Try (Repeat (Rewrite real_mult_2_assoc False))) @@ " ^
|
neuper@37954
|
1128 |
|
neuper@37954
|
1129 |
" (Try (Repeat (Rewrite real_num_collect False))) @@ " ^
|
neuper@37954
|
1130 |
" (Try (Repeat (Rewrite real_num_collect_assoc False))) @@ " ^
|
neuper@37954
|
1131 |
|
neuper@37954
|
1132 |
" (Try (Repeat (Rewrite real_one_collect False))) @@ " ^
|
neuper@37954
|
1133 |
" (Try (Repeat (Rewrite real_one_collect_assoc False))) @@ " ^
|
neuper@37954
|
1134 |
|
neuper@37975
|
1135 |
" (Try (Repeat (Calculate PLUS ))) @@ " ^
|
neuper@37975
|
1136 |
" (Try (Repeat (Calculate TIMES ))) @@ " ^
|
neuper@37975
|
1137 |
" (Try (Repeat (Calculate POWER)))) " ^
|
neuper@38001
|
1138 |
" t_t)";
|
neuper@37954
|
1139 |
-----------------------------------------------------*)
|
neuper@37954
|
1140 |
|
neuper@37954
|
1141 |
val make_polytest =
|
wneuper@59416
|
1142 |
Rule.Rls{id = "make_polytest", preconds = []:term list,
|
neuper@52105
|
1143 |
rew_ord = ("ord_make_polytest", ord_make_polytest false @{theory "Poly"}),
|
wneuper@59416
|
1144 |
erls = testerls, srls = Rule.Erls,
|
neuper@38014
|
1145 |
calc = [("PLUS" , ("Groups.plus_class.plus", eval_binop "#add_")),
|
neuper@38034
|
1146 |
("TIMES" , ("Groups.times_class.times", eval_binop "#mult_")),
|
neuper@37954
|
1147 |
("POWER", ("Atools.pow", eval_binop "#power_"))
|
neuper@42451
|
1148 |
], errpatts = [],
|
wneuper@59416
|
1149 |
rules = [Rule.Thm ("real_diff_minus",TermC.num_str @{thm real_diff_minus}),
|
neuper@37954
|
1150 |
(*"a - b = a + (-1) * b"*)
|
wneuper@59416
|
1151 |
Rule.Thm ("distrib_right" ,TermC.num_str @{thm distrib_right}),
|
neuper@37954
|
1152 |
(*"(z1.0 + z2.0) * w = z1.0 * w + z2.0 * w"*)
|
wneuper@59416
|
1153 |
Rule.Thm ("distrib_left",TermC.num_str @{thm distrib_left}),
|
neuper@37954
|
1154 |
(*"w * (z1.0 + z2.0) = w * z1.0 + w * z2.0"*)
|
wneuper@59416
|
1155 |
Rule.Thm ("left_diff_distrib" ,TermC.num_str @{thm left_diff_distrib}),
|
neuper@37954
|
1156 |
(*"(z1.0 - z2.0) * w = z1.0 * w - z2.0 * w"*)
|
wneuper@59416
|
1157 |
Rule.Thm ("right_diff_distrib",TermC.num_str @{thm right_diff_distrib}),
|
neuper@37954
|
1158 |
(*"w * (z1.0 - z2.0) = w * z1.0 - w * z2.0"*)
|
wneuper@59416
|
1159 |
Rule.Thm ("mult_1_left",TermC.num_str @{thm mult_1_left}),
|
neuper@37954
|
1160 |
(*"1 * z = z"*)
|
wneuper@59416
|
1161 |
Rule.Thm ("mult_zero_left",TermC.num_str @{thm mult_zero_left}),
|
neuper@37954
|
1162 |
(*"0 * z = 0"*)
|
wneuper@59416
|
1163 |
Rule.Thm ("add_0_left",TermC.num_str @{thm add_0_left}),
|
neuper@37954
|
1164 |
(*"0 + z = z"*)
|
neuper@37954
|
1165 |
|
neuper@37954
|
1166 |
(*AC-rewriting*)
|
wneuper@59416
|
1167 |
Rule.Thm ("mult_commute",TermC.num_str @{thm mult.commute}),
|
neuper@37954
|
1168 |
(* z * w = w * z *)
|
wneuper@59416
|
1169 |
Rule.Thm ("real_mult_left_commute",TermC.num_str @{thm real_mult_left_commute}),
|
neuper@37954
|
1170 |
(*z1.0 * (z2.0 * z3.0) = z2.0 * (z1.0 * z3.0)*)
|
wneuper@59416
|
1171 |
Rule.Thm ("mult_assoc",TermC.num_str @{thm mult.assoc}),
|
neuper@37954
|
1172 |
(*z1.0 * z2.0 * z3.0 = z1.0 * (z2.0 * z3.0)*)
|
wneuper@59416
|
1173 |
Rule.Thm ("add_commute",TermC.num_str @{thm add.commute}),
|
neuper@37954
|
1174 |
(*z + w = w + z*)
|
wneuper@59416
|
1175 |
Rule.Thm ("add_left_commute",TermC.num_str @{thm add.left_commute}),
|
neuper@37954
|
1176 |
(*x + (y + z) = y + (x + z)*)
|
wneuper@59416
|
1177 |
Rule.Thm ("add_assoc",TermC.num_str @{thm add.assoc}),
|
neuper@37954
|
1178 |
(*z1.0 + z2.0 + z3.0 = z1.0 + (z2.0 + z3.0)*)
|
neuper@37954
|
1179 |
|
wneuper@59416
|
1180 |
Rule.Thm ("sym_realpow_twoI",
|
wneuper@59389
|
1181 |
TermC.num_str (@{thm realpow_twoI} RS @{thm sym})),
|
neuper@37954
|
1182 |
(*"r1 * r1 = r1 ^^^ 2"*)
|
wneuper@59416
|
1183 |
Rule.Thm ("realpow_plus_1",TermC.num_str @{thm realpow_plus_1}),
|
neuper@37954
|
1184 |
(*"r * r ^^^ n = r ^^^ (n + 1)"*)
|
wneuper@59416
|
1185 |
Rule.Thm ("sym_real_mult_2",
|
wneuper@59389
|
1186 |
TermC.num_str (@{thm real_mult_2} RS @{thm sym})),
|
neuper@37954
|
1187 |
(*"z1 + z1 = 2 * z1"*)
|
wneuper@59416
|
1188 |
Rule.Thm ("real_mult_2_assoc",TermC.num_str @{thm real_mult_2_assoc}),
|
neuper@37954
|
1189 |
(*"z1 + (z1 + k) = 2 * z1 + k"*)
|
neuper@37954
|
1190 |
|
wneuper@59416
|
1191 |
Rule.Thm ("real_num_collect",TermC.num_str @{thm real_num_collect}),
|
neuper@37954
|
1192 |
(*"[| l is_const; m is_const |]==>l * n + m * n = (l + m) * n"*)
|
wneuper@59416
|
1193 |
Rule.Thm ("real_num_collect_assoc",TermC.num_str @{thm real_num_collect_assoc}),
|
neuper@37954
|
1194 |
(*"[| l is_const; m is_const |] ==>
|
neuper@37954
|
1195 |
l * n + (m * n + k) = (l + m) * n + k"*)
|
wneuper@59416
|
1196 |
Rule.Thm ("real_one_collect",TermC.num_str @{thm real_one_collect}),
|
neuper@37954
|
1197 |
(*"m is_const ==> n + m * n = (1 + m) * n"*)
|
wneuper@59416
|
1198 |
Rule.Thm ("real_one_collect_assoc",TermC.num_str @{thm real_one_collect_assoc}),
|
neuper@37954
|
1199 |
(*"m is_const ==> k + (n + m * n) = k + (1 + m) * n"*)
|
neuper@37954
|
1200 |
|
wneuper@59416
|
1201 |
Rule.Calc ("Groups.plus_class.plus", eval_binop "#add_"),
|
wneuper@59416
|
1202 |
Rule.Calc ("Groups.times_class.times", eval_binop "#mult_"),
|
wneuper@59416
|
1203 |
Rule.Calc ("Atools.pow", eval_binop "#power_")
|
neuper@37954
|
1204 |
],
|
wneuper@59416
|
1205 |
scr = Rule.EmptyScr(*Rule.Prog ((Thm.term_of o the o (parse thy))
|
neuper@37954
|
1206 |
scr_make_polytest)*)
|
wneuper@59406
|
1207 |
};
|
neuper@38001
|
1208 |
*}
|
neuper@38001
|
1209 |
ML {*
|
s1210629013@55444
|
1210 |
(*WN060510 this was done before 'fun prep_rls ...------------------------
|
neuper@37954
|
1211 |
val scr_expand_binomtest =
|
neuper@38001
|
1212 |
"Script Expand_binomtest t_t =" ^
|
neuper@37954
|
1213 |
"(Repeat " ^
|
neuper@37954
|
1214 |
"((Try (Repeat (Rewrite real_plus_binom_pow2 False))) @@ " ^
|
neuper@37954
|
1215 |
" (Try (Repeat (Rewrite real_plus_binom_times False))) @@ " ^
|
neuper@37954
|
1216 |
" (Try (Repeat (Rewrite real_minus_binom_pow2 False))) @@ " ^
|
neuper@37954
|
1217 |
" (Try (Repeat (Rewrite real_minus_binom_times False))) @@ " ^
|
neuper@37954
|
1218 |
" (Try (Repeat (Rewrite real_plus_minus_binom1 False))) @@ " ^
|
neuper@37954
|
1219 |
" (Try (Repeat (Rewrite real_plus_minus_binom2 False))) @@ " ^
|
neuper@37954
|
1220 |
|
neuper@37971
|
1221 |
" (Try (Repeat (Rewrite mult_1_left False))) @@ " ^
|
neuper@37971
|
1222 |
" (Try (Repeat (Rewrite mult_zero_left False))) @@ " ^
|
neuper@37971
|
1223 |
" (Try (Repeat (Rewrite add_0_left False))) @@ " ^
|
neuper@37954
|
1224 |
|
neuper@37975
|
1225 |
" (Try (Repeat (Calculate PLUS ))) @@ " ^
|
neuper@37975
|
1226 |
" (Try (Repeat (Calculate TIMES ))) @@ " ^
|
neuper@37975
|
1227 |
" (Try (Repeat (Calculate POWER))) @@ " ^
|
neuper@37954
|
1228 |
|
neuper@37954
|
1229 |
" (Try (Repeat (Rewrite sym_realpow_twoI False))) @@ " ^
|
neuper@37954
|
1230 |
" (Try (Repeat (Rewrite realpow_plus_1 False))) @@ " ^
|
neuper@37954
|
1231 |
" (Try (Repeat (Rewrite sym_real_mult_2 False))) @@ " ^
|
neuper@37954
|
1232 |
" (Try (Repeat (Rewrite real_mult_2_assoc False))) @@ " ^
|
neuper@37954
|
1233 |
|
neuper@37954
|
1234 |
" (Try (Repeat (Rewrite real_num_collect False))) @@ " ^
|
neuper@37954
|
1235 |
" (Try (Repeat (Rewrite real_num_collect_assoc False))) @@ " ^
|
neuper@37954
|
1236 |
|
neuper@37954
|
1237 |
" (Try (Repeat (Rewrite real_one_collect False))) @@ " ^
|
neuper@37954
|
1238 |
" (Try (Repeat (Rewrite real_one_collect_assoc False))) @@ " ^
|
neuper@37954
|
1239 |
|
neuper@37975
|
1240 |
" (Try (Repeat (Calculate PLUS ))) @@ " ^
|
neuper@37975
|
1241 |
" (Try (Repeat (Calculate TIMES ))) @@ " ^
|
neuper@37975
|
1242 |
" (Try (Repeat (Calculate POWER)))) " ^
|
neuper@38001
|
1243 |
" t_t)";
|
neuper@38001
|
1244 |
--------------------------------------------------------------------------*)
|
neuper@37954
|
1245 |
|
neuper@37954
|
1246 |
val expand_binomtest =
|
wneuper@59416
|
1247 |
Rule.Rls{id = "expand_binomtest", preconds = [],
|
neuper@37954
|
1248 |
rew_ord = ("termlessI",termlessI),
|
wneuper@59416
|
1249 |
erls = testerls, srls = Rule.Erls,
|
neuper@38014
|
1250 |
calc = [("PLUS" , ("Groups.plus_class.plus", eval_binop "#add_")),
|
neuper@38034
|
1251 |
("TIMES" , ("Groups.times_class.times", eval_binop "#mult_")),
|
neuper@37954
|
1252 |
("POWER", ("Atools.pow", eval_binop "#power_"))
|
neuper@42451
|
1253 |
], errpatts = [],
|
neuper@38001
|
1254 |
rules =
|
wneuper@59416
|
1255 |
[Rule.Thm ("real_plus_binom_pow2" ,TermC.num_str @{thm real_plus_binom_pow2}),
|
neuper@37954
|
1256 |
(*"(a + b) ^^^ 2 = a ^^^ 2 + 2 * a * b + b ^^^ 2"*)
|
wneuper@59416
|
1257 |
Rule.Thm ("real_plus_binom_times" ,TermC.num_str @{thm real_plus_binom_times}),
|
neuper@37954
|
1258 |
(*"(a + b)*(a + b) = ...*)
|
wneuper@59416
|
1259 |
Rule.Thm ("real_minus_binom_pow2" ,TermC.num_str @{thm real_minus_binom_pow2}),
|
neuper@38001
|
1260 |
(*"(a - b) ^^^ 2 = a ^^^ 2 - 2 * a * b + b ^^^ 2"*)
|
wneuper@59416
|
1261 |
Rule.Thm ("real_minus_binom_times",TermC.num_str @{thm real_minus_binom_times}),
|
neuper@38001
|
1262 |
(*"(a - b)*(a - b) = ...*)
|
wneuper@59416
|
1263 |
Rule.Thm ("real_plus_minus_binom1",TermC.num_str @{thm real_plus_minus_binom1}),
|
neuper@38001
|
1264 |
(*"(a + b) * (a - b) = a ^^^ 2 - b ^^^ 2"*)
|
wneuper@59416
|
1265 |
Rule.Thm ("real_plus_minus_binom2",TermC.num_str @{thm real_plus_minus_binom2}),
|
neuper@38001
|
1266 |
(*"(a - b) * (a + b) = a ^^^ 2 - b ^^^ 2"*)
|
neuper@38001
|
1267 |
(*RL 020915*)
|
wneuper@59416
|
1268 |
Rule.Thm ("real_pp_binom_times",TermC.num_str @{thm real_pp_binom_times}),
|
neuper@38001
|
1269 |
(*(a + b)*(c + d) = a*c + a*d + b*c + b*d*)
|
wneuper@59416
|
1270 |
Rule.Thm ("real_pm_binom_times",TermC.num_str @{thm real_pm_binom_times}),
|
neuper@38001
|
1271 |
(*(a + b)*(c - d) = a*c - a*d + b*c - b*d*)
|
wneuper@59416
|
1272 |
Rule.Thm ("real_mp_binom_times",TermC.num_str @{thm real_mp_binom_times}),
|
neuper@38001
|
1273 |
(*(a - b)*(c p d) = a*c + a*d - b*c - b*d*)
|
wneuper@59416
|
1274 |
Rule.Thm ("real_mm_binom_times",TermC.num_str @{thm real_mm_binom_times}),
|
neuper@38001
|
1275 |
(*(a - b)*(c p d) = a*c - a*d - b*c + b*d*)
|
wneuper@59416
|
1276 |
Rule.Thm ("realpow_multI",TermC.num_str @{thm realpow_multI}),
|
neuper@38001
|
1277 |
(*(a*b)^^^n = a^^^n * b^^^n*)
|
wneuper@59416
|
1278 |
Rule.Thm ("real_plus_binom_pow3",TermC.num_str @{thm real_plus_binom_pow3}),
|
neuper@38001
|
1279 |
(* (a + b)^^^3 = a^^^3 + 3*a^^^2*b + 3*a*b^^^2 + b^^^3 *)
|
wneuper@59416
|
1280 |
Rule.Thm ("real_minus_binom_pow3",TermC.num_str @{thm real_minus_binom_pow3}),
|
neuper@38001
|
1281 |
(* (a - b)^^^3 = a^^^3 - 3*a^^^2*b + 3*a*b^^^2 - b^^^3 *)
|
neuper@37954
|
1282 |
|
neuper@37954
|
1283 |
|
wneuper@59416
|
1284 |
(* Rule.Thm ("distrib_right" ,TermC.num_str @{thm distrib_right}),
|
neuper@38001
|
1285 |
(*"(z1.0 + z2.0) * w = z1.0 * w + z2.0 * w"*)
|
wneuper@59416
|
1286 |
Rule.Thm ("distrib_left",TermC.num_str @{thm distrib_left}),
|
neuper@38001
|
1287 |
(*"w * (z1.0 + z2.0) = w * z1.0 + w * z2.0"*)
|
wneuper@59416
|
1288 |
Rule.Thm ("left_diff_distrib" ,TermC.num_str @{thm left_diff_distrib}),
|
neuper@38001
|
1289 |
(*"(z1.0 - z2.0) * w = z1.0 * w - z2.0 * w"*)
|
wneuper@59416
|
1290 |
Rule.Thm ("right_diff_distrib",TermC.num_str @{thm right_diff_distrib}),
|
neuper@38001
|
1291 |
(*"w * (z1.0 - z2.0) = w * z1.0 - w * z2.0"*)
|
neuper@38001
|
1292 |
*)
|
neuper@38001
|
1293 |
|
wneuper@59416
|
1294 |
Rule.Thm ("mult_1_left",TermC.num_str @{thm mult_1_left}),
|
neuper@38001
|
1295 |
(*"1 * z = z"*)
|
wneuper@59416
|
1296 |
Rule.Thm ("mult_zero_left",TermC.num_str @{thm mult_zero_left}),
|
neuper@38001
|
1297 |
(*"0 * z = 0"*)
|
wneuper@59416
|
1298 |
Rule.Thm ("add_0_left",TermC.num_str @{thm add_0_left}),
|
neuper@38001
|
1299 |
(*"0 + z = z"*)
|
neuper@37954
|
1300 |
|
wneuper@59416
|
1301 |
Rule.Calc ("Groups.plus_class.plus", eval_binop "#add_"),
|
wneuper@59416
|
1302 |
Rule.Calc ("Groups.times_class.times", eval_binop "#mult_"),
|
wneuper@59416
|
1303 |
Rule.Calc ("Atools.pow", eval_binop "#power_"),
|
neuper@38001
|
1304 |
(*
|
wneuper@59416
|
1305 |
Rule.Thm ("mult_commute",TermC.num_str @{thm mult_commute}),
|
neuper@38001
|
1306 |
(*AC-rewriting*)
|
wneuper@59416
|
1307 |
Rule.Thm ("real_mult_left_commute",TermC.num_str @{thm real_mult_left_commute}),
|
wneuper@59416
|
1308 |
Rule.Thm ("mult_assoc",TermC.num_str @{thm mult.assoc}),
|
wneuper@59416
|
1309 |
Rule.Thm ("add_commute",TermC.num_str @{thm add_commute}),
|
wneuper@59416
|
1310 |
Rule.Thm ("add_left_commute",TermC.num_str @{thm add_left_commute}),
|
wneuper@59416
|
1311 |
Rule.Thm ("add_assoc",TermC.num_str @{thm add_assoc}),
|
neuper@38001
|
1312 |
*)
|
neuper@38001
|
1313 |
|
wneuper@59416
|
1314 |
Rule.Thm ("sym_realpow_twoI",
|
wneuper@59389
|
1315 |
TermC.num_str (@{thm realpow_twoI} RS @{thm sym})),
|
neuper@38001
|
1316 |
(*"r1 * r1 = r1 ^^^ 2"*)
|
wneuper@59416
|
1317 |
Rule.Thm ("realpow_plus_1",TermC.num_str @{thm realpow_plus_1}),
|
neuper@38001
|
1318 |
(*"r * r ^^^ n = r ^^^ (n + 1)"*)
|
wneuper@59416
|
1319 |
(*Rule.Thm ("sym_real_mult_2",
|
wneuper@59389
|
1320 |
TermC.num_str (@{thm real_mult_2} RS @{thm sym})),
|
neuper@38001
|
1321 |
(*"z1 + z1 = 2 * z1"*)*)
|
wneuper@59416
|
1322 |
Rule.Thm ("real_mult_2_assoc",TermC.num_str @{thm real_mult_2_assoc}),
|
neuper@38001
|
1323 |
(*"z1 + (z1 + k) = 2 * z1 + k"*)
|
neuper@37954
|
1324 |
|
wneuper@59416
|
1325 |
Rule.Thm ("real_num_collect",TermC.num_str @{thm real_num_collect}),
|
neuper@38001
|
1326 |
(*"[| l is_const; m is_const |] ==> l * n + m * n = (l + m) * n"*)
|
wneuper@59416
|
1327 |
Rule.Thm ("real_num_collect_assoc",TermC.num_str @{thm real_num_collect_assoc}),
|
neuper@38001
|
1328 |
(*"[| l is_const; m is_const |] ==> l * n + (m * n + k) = (l + m) * n + k"*)
|
wneuper@59416
|
1329 |
Rule.Thm ("real_one_collect",TermC.num_str @{thm real_one_collect}),
|
neuper@38001
|
1330 |
(*"m is_const ==> n + m * n = (1 + m) * n"*)
|
wneuper@59416
|
1331 |
Rule.Thm ("real_one_collect_assoc",TermC.num_str @{thm real_one_collect_assoc}),
|
neuper@38001
|
1332 |
(*"m is_const ==> k + (n + m * n) = k + (1 + m) * n"*)
|
neuper@37954
|
1333 |
|
wneuper@59416
|
1334 |
Rule.Calc ("Groups.plus_class.plus", eval_binop "#add_"),
|
wneuper@59416
|
1335 |
Rule.Calc ("Groups.times_class.times", eval_binop "#mult_"),
|
wneuper@59416
|
1336 |
Rule.Calc ("Atools.pow", eval_binop "#power_")
|
neuper@38001
|
1337 |
],
|
wneuper@59416
|
1338 |
scr = Rule.EmptyScr
|
wneuper@59186
|
1339 |
(*Script ((Thm.term_of o the o (parse thy)) scr_expand_binomtest)*)
|
wneuper@59406
|
1340 |
};
|
neuper@37954
|
1341 |
*}
|
neuper@52125
|
1342 |
setup {* KEStore_Elems.add_rlss
|
s1210629013@55444
|
1343 |
[("make_polytest", (Context.theory_name @{theory}, prep_rls' make_polytest)),
|
s1210629013@55444
|
1344 |
("expand_binomtest", (Context.theory_name @{theory}, prep_rls' expand_binomtest))] *}
|
neuper@37906
|
1345 |
|
neuper@37906
|
1346 |
end
|