neuper@37906
|
1 |
(* theory collecting all knowledge
|
neuper@37906
|
2 |
(predicates 'is_rootEq_in', 'is_sqrt_in', 'is_ratEq_in')
|
neuper@37906
|
3 |
for PolynomialEquations.
|
wneuper@59592
|
4 |
alternative dependencies see @{theory "Isac_Knowledge"}
|
neuper@37906
|
5 |
created by: rlang
|
neuper@37906
|
6 |
date: 02.07
|
neuper@37906
|
7 |
changed by: rlang
|
neuper@37906
|
8 |
last change by: rlang
|
neuper@37906
|
9 |
date: 03.06.03
|
neuper@37954
|
10 |
(c) by Richard Lang, 2003
|
neuper@37906
|
11 |
*)
|
neuper@37906
|
12 |
|
neuper@37954
|
13 |
theory PolyEq imports LinEq RootRatEq begin
|
neuper@37906
|
14 |
|
neuper@37906
|
15 |
(*-------------------- rules -------------------------------------------------*)
|
walther@60242
|
16 |
(* type real enforced by op " \<up> " *)
|
neuper@52148
|
17 |
axiomatization where
|
walther@60242
|
18 |
cancel_leading_coeff1: "Not (c =!= 0) ==> (a + b*bdv + c*bdv \<up> 2 = 0) =
|
walther@60242
|
19 |
(a/c + b/c*bdv + bdv \<up> 2 = 0)" and
|
walther@60242
|
20 |
cancel_leading_coeff2: "Not (c =!= 0) ==> (a - b*bdv + c*bdv \<up> 2 = 0) =
|
walther@60242
|
21 |
(a/c - b/c*bdv + bdv \<up> 2 = 0)" and
|
walther@60242
|
22 |
cancel_leading_coeff3: "Not (c =!= 0) ==> (a + b*bdv - c*bdv \<up> 2 = 0) =
|
walther@60242
|
23 |
(a/c + b/c*bdv - bdv \<up> 2 = 0)" and
|
neuper@37906
|
24 |
|
walther@60242
|
25 |
cancel_leading_coeff4: "Not (c =!= 0) ==> (a + bdv + c*bdv \<up> 2 = 0) =
|
walther@60242
|
26 |
(a/c + 1/c*bdv + bdv \<up> 2 = 0)" and
|
walther@60242
|
27 |
cancel_leading_coeff5: "Not (c =!= 0) ==> (a - bdv + c*bdv \<up> 2 = 0) =
|
walther@60242
|
28 |
(a/c - 1/c*bdv + bdv \<up> 2 = 0)" and
|
walther@60242
|
29 |
cancel_leading_coeff6: "Not (c =!= 0) ==> (a + bdv - c*bdv \<up> 2 = 0) =
|
walther@60242
|
30 |
(a/c + 1/c*bdv - bdv \<up> 2 = 0)" and
|
neuper@37906
|
31 |
|
walther@60242
|
32 |
cancel_leading_coeff7: "Not (c =!= 0) ==> ( b*bdv + c*bdv \<up> 2 = 0) =
|
walther@60242
|
33 |
( b/c*bdv + bdv \<up> 2 = 0)" and
|
walther@60242
|
34 |
cancel_leading_coeff8: "Not (c =!= 0) ==> ( b*bdv - c*bdv \<up> 2 = 0) =
|
walther@60242
|
35 |
( b/c*bdv - bdv \<up> 2 = 0)" and
|
neuper@37906
|
36 |
|
walther@60242
|
37 |
cancel_leading_coeff9: "Not (c =!= 0) ==> ( bdv + c*bdv \<up> 2 = 0) =
|
walther@60242
|
38 |
( 1/c*bdv + bdv \<up> 2 = 0)" and
|
walther@60242
|
39 |
cancel_leading_coeff10:"Not (c =!= 0) ==> ( bdv - c*bdv \<up> 2 = 0) =
|
walther@60242
|
40 |
( 1/c*bdv - bdv \<up> 2 = 0)" and
|
neuper@37906
|
41 |
|
walther@60242
|
42 |
cancel_leading_coeff11:"Not (c =!= 0) ==> (a + b*bdv \<up> 2 = 0) =
|
walther@60242
|
43 |
(a/b + bdv \<up> 2 = 0)" and
|
walther@60242
|
44 |
cancel_leading_coeff12:"Not (c =!= 0) ==> (a - b*bdv \<up> 2 = 0) =
|
walther@60242
|
45 |
(a/b - bdv \<up> 2 = 0)" and
|
walther@60242
|
46 |
cancel_leading_coeff13:"Not (c =!= 0) ==> ( b*bdv \<up> 2 = 0) =
|
walther@60242
|
47 |
( bdv \<up> 2 = 0/b)" and
|
neuper@37906
|
48 |
|
walther@60242
|
49 |
complete_square1: "(q + p*bdv + bdv \<up> 2 = 0) =
|
walther@60242
|
50 |
(q + (p/2 + bdv) \<up> 2 = (p/2) \<up> 2)" and
|
walther@60242
|
51 |
complete_square2: "( p*bdv + bdv \<up> 2 = 0) =
|
walther@60242
|
52 |
( (p/2 + bdv) \<up> 2 = (p/2) \<up> 2)" and
|
walther@60242
|
53 |
complete_square3: "( bdv + bdv \<up> 2 = 0) =
|
walther@60242
|
54 |
( (1/2 + bdv) \<up> 2 = (1/2) \<up> 2)" and
|
neuper@37906
|
55 |
|
walther@60242
|
56 |
complete_square4: "(q - p*bdv + bdv \<up> 2 = 0) =
|
walther@60242
|
57 |
(q + (p/2 - bdv) \<up> 2 = (p/2) \<up> 2)" and
|
walther@60242
|
58 |
complete_square5: "(q + p*bdv - bdv \<up> 2 = 0) =
|
walther@60242
|
59 |
(q + (p/2 - bdv) \<up> 2 = (p/2) \<up> 2)" and
|
neuper@37906
|
60 |
|
walther@60242
|
61 |
square_explicit1: "(a + b \<up> 2 = c) = ( b \<up> 2 = c - a)" and
|
walther@60242
|
62 |
square_explicit2: "(a - b \<up> 2 = c) = (-(b \<up> 2) = c - a)" and
|
neuper@37906
|
63 |
|
walther@60242
|
64 |
(*bdv_explicit* required type constrain to real in --- (-8 - 2*x + x \<up> 2 = 0), by rewriting ---*)
|
neuper@52148
|
65 |
bdv_explicit1: "(a + bdv = b) = (bdv = - a + (b::real))" and
|
neuper@52148
|
66 |
bdv_explicit2: "(a - bdv = b) = ((-1)*bdv = - a + (b::real))" and
|
neuper@52148
|
67 |
bdv_explicit3: "((-1)*bdv = b) = (bdv = (-1)*(b::real))" and
|
neuper@37906
|
68 |
|
neuper@52148
|
69 |
plus_leq: "(0 <= a + b) = ((-1)*b <= a)"(*Isa?*) and
|
neuper@52148
|
70 |
minus_leq: "(0 <= a - b) = ( b <= a)"(*Isa?*) and
|
neuper@37906
|
71 |
|
wneuper@59370
|
72 |
(*-- normalise --*)
|
neuper@37906
|
73 |
(*WN0509 compare LinEq.all_left "[|Not(b=!=0)|] ==> (a=b) = (a+(-1)*b=0)"*)
|
neuper@52148
|
74 |
all_left: "[|Not(b=!=0)|] ==> (a = b) = (a - b = 0)" and
|
walther@60242
|
75 |
makex1_x: "a\<up>1 = a" and
|
neuper@52148
|
76 |
real_assoc_1: "a+(b+c) = a+b+c" and
|
neuper@52148
|
77 |
real_assoc_2: "a*(b*c) = a*b*c" and
|
neuper@37906
|
78 |
|
neuper@37906
|
79 |
(* ---- degree 0 ----*)
|
neuper@52148
|
80 |
d0_true: "(0=0) = True" and
|
neuper@52148
|
81 |
d0_false: "[|Not(bdv occurs_in a);Not(a=0)|] ==> (a=0) = False" and
|
neuper@37906
|
82 |
(* ---- degree 1 ----*)
|
neuper@37983
|
83 |
d1_isolate_add1:
|
neuper@52148
|
84 |
"[|Not(bdv occurs_in a)|] ==> (a + b*bdv = 0) = (b*bdv = (-1)*a)" and
|
neuper@37983
|
85 |
d1_isolate_add2:
|
neuper@52148
|
86 |
"[|Not(bdv occurs_in a)|] ==> (a + bdv = 0) = ( bdv = (-1)*a)" and
|
neuper@37983
|
87 |
d1_isolate_div:
|
neuper@52148
|
88 |
"[|Not(b=0);Not(bdv occurs_in c)|] ==> (b*bdv = c) = (bdv = c/b)" and
|
neuper@37906
|
89 |
(* ---- degree 2 ----*)
|
neuper@37983
|
90 |
d2_isolate_add1:
|
walther@60242
|
91 |
"[|Not(bdv occurs_in a)|] ==> (a + b*bdv \<up> 2=0) = (b*bdv \<up> 2= (-1)*a)" and
|
neuper@37983
|
92 |
d2_isolate_add2:
|
walther@60242
|
93 |
"[|Not(bdv occurs_in a)|] ==> (a + bdv \<up> 2=0) = ( bdv \<up> 2= (-1)*a)" and
|
neuper@37983
|
94 |
d2_isolate_div:
|
walther@60242
|
95 |
"[|Not(b=0);Not(bdv occurs_in c)|] ==> (b*bdv \<up> 2=c) = (bdv \<up> 2=c/b)" and
|
neuper@42394
|
96 |
|
walther@60242
|
97 |
d2_prescind1: "(a*bdv + b*bdv \<up> 2 = 0) = (bdv*(a +b*bdv)=0)" and
|
walther@60242
|
98 |
d2_prescind2: "(a*bdv + bdv \<up> 2 = 0) = (bdv*(a + bdv)=0)" and
|
walther@60242
|
99 |
d2_prescind3: "( bdv + b*bdv \<up> 2 = 0) = (bdv*(1+b*bdv)=0)" and
|
walther@60242
|
100 |
d2_prescind4: "( bdv + bdv \<up> 2 = 0) = (bdv*(1+ bdv)=0)" and
|
neuper@37906
|
101 |
(* eliminate degree 2 *)
|
neuper@37906
|
102 |
(* thm for neg arguments in sqroot have postfix _neg *)
|
neuper@37983
|
103 |
d2_sqrt_equation1: "[|(0<=c);Not(bdv occurs_in c)|] ==>
|
walther@60242
|
104 |
(bdv \<up> 2=c) = ((bdv=sqrt c) | (bdv=(-1)*sqrt c ))" and
|
t@42197
|
105 |
d2_sqrt_equation1_neg:
|
walther@60242
|
106 |
"[|(c<0);Not(bdv occurs_in c)|] ==> (bdv \<up> 2=c) = False" and
|
walther@60242
|
107 |
d2_sqrt_equation2: "(bdv \<up> 2=0) = (bdv=0)" and
|
walther@60242
|
108 |
d2_sqrt_equation3: "(b*bdv \<up> 2=0) = (bdv=0)"
|
neuper@52148
|
109 |
axiomatization where (*AK..if replaced by "and" we get errors:
|
t@42203
|
110 |
exception PTREE "nth _ []" raised
|
t@42203
|
111 |
(line 783 of "/usr/local/isabisac/src/Tools/isac/Interpret/ctree.sml"):
|
t@42203
|
112 |
'fun nth _ [] = raise PTREE "nth _ []"'
|
t@42203
|
113 |
and
|
t@42203
|
114 |
exception Bind raised
|
t@42203
|
115 |
(line 1097 of "/usr/local/isabisac/test/Tools/isac/Frontend/interface.sml"):
|
t@42203
|
116 |
'val (Form f, tac, asms) = pt_extract (pt, p);' *)
|
walther@60242
|
117 |
(* WN120315 these 2 thms need "::real", because no " \<up> " constrains type as
|
neuper@42394
|
118 |
required in test --- rls d2_polyeq_bdv_only_simplify --- *)
|
neuper@52148
|
119 |
d2_reduce_equation1: "(bdv*(a +b*bdv)=0) = ((bdv=0)|(a+b*bdv=(0::real)))" and
|
neuper@42394
|
120 |
d2_reduce_equation2: "(bdv*(a + bdv)=0) = ((bdv=0)|(a+ bdv=(0::real)))"
|
neuper@52148
|
121 |
|
neuper@52148
|
122 |
axiomatization where (*..if replaced by "and" we get errors:
|
t@42203
|
123 |
exception PTREE "nth _ []" raised
|
t@42203
|
124 |
(line 783 of "/usr/local/isabisac/src/Tools/isac/Interpret/ctree.sml"):
|
t@42203
|
125 |
'fun nth _ [] = raise PTREE "nth _ []"'
|
t@42203
|
126 |
and
|
t@42203
|
127 |
exception Bind raised
|
t@42203
|
128 |
(line 1097 of "/usr/local/isabisac/test/Tools/isac/Frontend/interface.sml"):
|
t@42203
|
129 |
'val (Form f, tac, asms) = pt_extract (pt, p);' *)
|
walther@60242
|
130 |
d2_pqformula1: "[|0<=p \<up> 2 - 4*q|] ==> (q+p*bdv+ bdv \<up> 2=0) =
|
walther@60242
|
131 |
((bdv= (-1)*(p/2) + sqrt(p \<up> 2 - 4*q)/2)
|
walther@60242
|
132 |
| (bdv= (-1)*(p/2) - sqrt(p \<up> 2 - 4*q)/2))" and
|
walther@60242
|
133 |
d2_pqformula1_neg: "[|p \<up> 2 - 4*q<0|] ==> (q+p*bdv+ bdv \<up> 2=0) = False" and
|
walther@60242
|
134 |
d2_pqformula2: "[|0<=p \<up> 2 - 4*q|] ==> (q+p*bdv+1*bdv \<up> 2=0) =
|
walther@60242
|
135 |
((bdv= (-1)*(p/2) + sqrt(p \<up> 2 - 4*q)/2)
|
walther@60242
|
136 |
| (bdv= (-1)*(p/2) - sqrt(p \<up> 2 - 4*q)/2))" and
|
walther@60242
|
137 |
d2_pqformula2_neg: "[|p \<up> 2 - 4*q<0|] ==> (q+p*bdv+1*bdv \<up> 2=0) = False" and
|
walther@60242
|
138 |
d2_pqformula3: "[|0<=1 - 4*q|] ==> (q+ bdv+ bdv \<up> 2=0) =
|
neuper@37954
|
139 |
((bdv= (-1)*(1/2) + sqrt(1 - 4*q)/2)
|
neuper@52148
|
140 |
| (bdv= (-1)*(1/2) - sqrt(1 - 4*q)/2))" and
|
walther@60242
|
141 |
d2_pqformula3_neg: "[|1 - 4*q<0|] ==> (q+ bdv+ bdv \<up> 2=0) = False" and
|
walther@60242
|
142 |
d2_pqformula4: "[|0<=1 - 4*q|] ==> (q+ bdv+1*bdv \<up> 2=0) =
|
neuper@37954
|
143 |
((bdv= (-1)*(1/2) + sqrt(1 - 4*q)/2)
|
neuper@52148
|
144 |
| (bdv= (-1)*(1/2) - sqrt(1 - 4*q)/2))" and
|
walther@60242
|
145 |
d2_pqformula4_neg: "[|1 - 4*q<0|] ==> (q+ bdv+1*bdv \<up> 2=0) = False" and
|
walther@60242
|
146 |
d2_pqformula5: "[|0<=p \<up> 2 - 0|] ==> ( p*bdv+ bdv \<up> 2=0) =
|
walther@60242
|
147 |
((bdv= (-1)*(p/2) + sqrt(p \<up> 2 - 0)/2)
|
walther@60242
|
148 |
| (bdv= (-1)*(p/2) - sqrt(p \<up> 2 - 0)/2))" and
|
t@42203
|
149 |
(* d2_pqformula5_neg not need p^2 never less zero in R *)
|
walther@60242
|
150 |
d2_pqformula6: "[|0<=p \<up> 2 - 0|] ==> ( p*bdv+1*bdv \<up> 2=0) =
|
walther@60242
|
151 |
((bdv= (-1)*(p/2) + sqrt(p \<up> 2 - 0)/2)
|
walther@60242
|
152 |
| (bdv= (-1)*(p/2) - sqrt(p \<up> 2 - 0)/2))" and
|
neuper@37906
|
153 |
(* d2_pqformula6_neg not need p^2 never less zero in R *)
|
walther@60242
|
154 |
d2_pqformula7: "[|0<=1 - 0|] ==> ( bdv+ bdv \<up> 2=0) =
|
neuper@37954
|
155 |
((bdv= (-1)*(1/2) + sqrt(1 - 0)/2)
|
neuper@52148
|
156 |
| (bdv= (-1)*(1/2) - sqrt(1 - 0)/2))" and
|
neuper@37906
|
157 |
(* d2_pqformula7_neg not need, because 1<0 ==> False*)
|
walther@60242
|
158 |
d2_pqformula8: "[|0<=1 - 0|] ==> ( bdv+1*bdv \<up> 2=0) =
|
neuper@37954
|
159 |
((bdv= (-1)*(1/2) + sqrt(1 - 0)/2)
|
neuper@52148
|
160 |
| (bdv= (-1)*(1/2) - sqrt(1 - 0)/2))" and
|
neuper@37906
|
161 |
(* d2_pqformula8_neg not need, because 1<0 ==> False*)
|
neuper@37983
|
162 |
d2_pqformula9: "[|Not(bdv occurs_in q); 0<= (-1)*4*q|] ==>
|
walther@60242
|
163 |
(q+ 1*bdv \<up> 2=0) = ((bdv= 0 + sqrt(0 - 4*q)/2)
|
neuper@52148
|
164 |
| (bdv= 0 - sqrt(0 - 4*q)/2))" and
|
neuper@37983
|
165 |
d2_pqformula9_neg:
|
walther@60242
|
166 |
"[|Not(bdv occurs_in q); (-1)*4*q<0|] ==> (q+ 1*bdv \<up> 2=0) = False" and
|
neuper@37983
|
167 |
d2_pqformula10:
|
walther@60242
|
168 |
"[|Not(bdv occurs_in q); 0<= (-1)*4*q|] ==> (q+ bdv \<up> 2=0) =
|
neuper@37906
|
169 |
((bdv= 0 + sqrt(0 - 4*q)/2)
|
neuper@52148
|
170 |
| (bdv= 0 - sqrt(0 - 4*q)/2))" and
|
neuper@37983
|
171 |
d2_pqformula10_neg:
|
walther@60242
|
172 |
"[|Not(bdv occurs_in q); (-1)*4*q<0|] ==> (q+ bdv \<up> 2=0) = False" and
|
neuper@37983
|
173 |
d2_abcformula1:
|
walther@60242
|
174 |
"[|0<=b \<up> 2 - 4*a*c|] ==> (c + b*bdv+a*bdv \<up> 2=0) =
|
walther@60242
|
175 |
((bdv=( -b + sqrt(b \<up> 2 - 4*a*c))/(2*a))
|
walther@60242
|
176 |
| (bdv=( -b - sqrt(b \<up> 2 - 4*a*c))/(2*a)))" and
|
neuper@37983
|
177 |
d2_abcformula1_neg:
|
walther@60242
|
178 |
"[|b \<up> 2 - 4*a*c<0|] ==> (c + b*bdv+a*bdv \<up> 2=0) = False" and
|
neuper@37983
|
179 |
d2_abcformula2:
|
walther@60242
|
180 |
"[|0<=1 - 4*a*c|] ==> (c+ bdv+a*bdv \<up> 2=0) =
|
neuper@37906
|
181 |
((bdv=( -1 + sqrt(1 - 4*a*c))/(2*a))
|
neuper@52148
|
182 |
| (bdv=( -1 - sqrt(1 - 4*a*c))/(2*a)))" and
|
neuper@37983
|
183 |
d2_abcformula2_neg:
|
walther@60242
|
184 |
"[|1 - 4*a*c<0|] ==> (c+ bdv+a*bdv \<up> 2=0) = False" and
|
neuper@37983
|
185 |
d2_abcformula3:
|
walther@60242
|
186 |
"[|0<=b \<up> 2 - 4*1*c|] ==> (c + b*bdv+ bdv \<up> 2=0) =
|
walther@60242
|
187 |
((bdv=( -b + sqrt(b \<up> 2 - 4*1*c))/(2*1))
|
walther@60242
|
188 |
| (bdv=( -b - sqrt(b \<up> 2 - 4*1*c))/(2*1)))" and
|
neuper@37983
|
189 |
d2_abcformula3_neg:
|
walther@60242
|
190 |
"[|b \<up> 2 - 4*1*c<0|] ==> (c + b*bdv+ bdv \<up> 2=0) = False" and
|
neuper@37983
|
191 |
d2_abcformula4:
|
walther@60242
|
192 |
"[|0<=1 - 4*1*c|] ==> (c + bdv+ bdv \<up> 2=0) =
|
neuper@37906
|
193 |
((bdv=( -1 + sqrt(1 - 4*1*c))/(2*1))
|
neuper@52148
|
194 |
| (bdv=( -1 - sqrt(1 - 4*1*c))/(2*1)))" and
|
neuper@37983
|
195 |
d2_abcformula4_neg:
|
walther@60242
|
196 |
"[|1 - 4*1*c<0|] ==> (c + bdv+ bdv \<up> 2=0) = False" and
|
neuper@37983
|
197 |
d2_abcformula5:
|
walther@60242
|
198 |
"[|Not(bdv occurs_in c); 0<=0 - 4*a*c|] ==> (c + a*bdv \<up> 2=0) =
|
neuper@37906
|
199 |
((bdv=( 0 + sqrt(0 - 4*a*c))/(2*a))
|
neuper@52148
|
200 |
| (bdv=( 0 - sqrt(0 - 4*a*c))/(2*a)))" and
|
neuper@37983
|
201 |
d2_abcformula5_neg:
|
walther@60242
|
202 |
"[|Not(bdv occurs_in c); 0 - 4*a*c<0|] ==> (c + a*bdv \<up> 2=0) = False" and
|
neuper@37983
|
203 |
d2_abcformula6:
|
walther@60242
|
204 |
"[|Not(bdv occurs_in c); 0<=0 - 4*1*c|] ==> (c+ bdv \<up> 2=0) =
|
neuper@37906
|
205 |
((bdv=( 0 + sqrt(0 - 4*1*c))/(2*1))
|
neuper@52148
|
206 |
| (bdv=( 0 - sqrt(0 - 4*1*c))/(2*1)))" and
|
neuper@37983
|
207 |
d2_abcformula6_neg:
|
walther@60242
|
208 |
"[|Not(bdv occurs_in c); 0 - 4*1*c<0|] ==> (c+ bdv \<up> 2=0) = False" and
|
neuper@37983
|
209 |
d2_abcformula7:
|
walther@60242
|
210 |
"[|0<=b \<up> 2 - 0|] ==> ( b*bdv+a*bdv \<up> 2=0) =
|
walther@60242
|
211 |
((bdv=( -b + sqrt(b \<up> 2 - 0))/(2*a))
|
walther@60242
|
212 |
| (bdv=( -b - sqrt(b \<up> 2 - 0))/(2*a)))" and
|
neuper@37906
|
213 |
(* d2_abcformula7_neg not need b^2 never less zero in R *)
|
neuper@37983
|
214 |
d2_abcformula8:
|
walther@60242
|
215 |
"[|0<=b \<up> 2 - 0|] ==> ( b*bdv+ bdv \<up> 2=0) =
|
walther@60242
|
216 |
((bdv=( -b + sqrt(b \<up> 2 - 0))/(2*1))
|
walther@60242
|
217 |
| (bdv=( -b - sqrt(b \<up> 2 - 0))/(2*1)))" and
|
neuper@37906
|
218 |
(* d2_abcformula8_neg not need b^2 never less zero in R *)
|
neuper@37983
|
219 |
d2_abcformula9:
|
walther@60242
|
220 |
"[|0<=1 - 0|] ==> ( bdv+a*bdv \<up> 2=0) =
|
neuper@37906
|
221 |
((bdv=( -1 + sqrt(1 - 0))/(2*a))
|
neuper@52148
|
222 |
| (bdv=( -1 - sqrt(1 - 0))/(2*a)))" and
|
neuper@37906
|
223 |
(* d2_abcformula9_neg not need, because 1<0 ==> False*)
|
neuper@37983
|
224 |
d2_abcformula10:
|
walther@60242
|
225 |
"[|0<=1 - 0|] ==> ( bdv+ bdv \<up> 2=0) =
|
neuper@37906
|
226 |
((bdv=( -1 + sqrt(1 - 0))/(2*1))
|
neuper@52148
|
227 |
| (bdv=( -1 - sqrt(1 - 0))/(2*1)))" and
|
neuper@37906
|
228 |
(* d2_abcformula10_neg not need, because 1<0 ==> False*)
|
neuper@37906
|
229 |
|
t@42203
|
230 |
|
neuper@37906
|
231 |
(* ---- degree 3 ----*)
|
neuper@37983
|
232 |
d3_reduce_equation1:
|
walther@60242
|
233 |
"(a*bdv + b*bdv \<up> 2 + c*bdv \<up> 3=0) = (bdv=0 | (a + b*bdv + c*bdv \<up> 2=0))" and
|
neuper@37983
|
234 |
d3_reduce_equation2:
|
walther@60242
|
235 |
"( bdv + b*bdv \<up> 2 + c*bdv \<up> 3=0) = (bdv=0 | (1 + b*bdv + c*bdv \<up> 2=0))" and
|
neuper@37983
|
236 |
d3_reduce_equation3:
|
walther@60242
|
237 |
"(a*bdv + bdv \<up> 2 + c*bdv \<up> 3=0) = (bdv=0 | (a + bdv + c*bdv \<up> 2=0))" and
|
neuper@37983
|
238 |
d3_reduce_equation4:
|
walther@60242
|
239 |
"( bdv + bdv \<up> 2 + c*bdv \<up> 3=0) = (bdv=0 | (1 + bdv + c*bdv \<up> 2=0))" and
|
neuper@37983
|
240 |
d3_reduce_equation5:
|
walther@60242
|
241 |
"(a*bdv + b*bdv \<up> 2 + bdv \<up> 3=0) = (bdv=0 | (a + b*bdv + bdv \<up> 2=0))" and
|
neuper@37983
|
242 |
d3_reduce_equation6:
|
walther@60242
|
243 |
"( bdv + b*bdv \<up> 2 + bdv \<up> 3=0) = (bdv=0 | (1 + b*bdv + bdv \<up> 2=0))" and
|
neuper@37983
|
244 |
d3_reduce_equation7:
|
walther@60242
|
245 |
"(a*bdv + bdv \<up> 2 + bdv \<up> 3=0) = (bdv=0 | (1 + bdv + bdv \<up> 2=0))" and
|
neuper@37983
|
246 |
d3_reduce_equation8:
|
walther@60242
|
247 |
"( bdv + bdv \<up> 2 + bdv \<up> 3=0) = (bdv=0 | (1 + bdv + bdv \<up> 2=0))" and
|
neuper@37983
|
248 |
d3_reduce_equation9:
|
walther@60242
|
249 |
"(a*bdv + c*bdv \<up> 3=0) = (bdv=0 | (a + c*bdv \<up> 2=0))" and
|
neuper@37983
|
250 |
d3_reduce_equation10:
|
walther@60242
|
251 |
"( bdv + c*bdv \<up> 3=0) = (bdv=0 | (1 + c*bdv \<up> 2=0))" and
|
neuper@37983
|
252 |
d3_reduce_equation11:
|
walther@60242
|
253 |
"(a*bdv + bdv \<up> 3=0) = (bdv=0 | (a + bdv \<up> 2=0))" and
|
neuper@37983
|
254 |
d3_reduce_equation12:
|
walther@60242
|
255 |
"( bdv + bdv \<up> 3=0) = (bdv=0 | (1 + bdv \<up> 2=0))" and
|
neuper@37983
|
256 |
d3_reduce_equation13:
|
walther@60242
|
257 |
"( b*bdv \<up> 2 + c*bdv \<up> 3=0) = (bdv=0 | ( b*bdv + c*bdv \<up> 2=0))" and
|
neuper@37983
|
258 |
d3_reduce_equation14:
|
walther@60242
|
259 |
"( bdv \<up> 2 + c*bdv \<up> 3=0) = (bdv=0 | ( bdv + c*bdv \<up> 2=0))" and
|
neuper@37983
|
260 |
d3_reduce_equation15:
|
walther@60242
|
261 |
"( b*bdv \<up> 2 + bdv \<up> 3=0) = (bdv=0 | ( b*bdv + bdv \<up> 2=0))" and
|
neuper@37983
|
262 |
d3_reduce_equation16:
|
walther@60242
|
263 |
"( bdv \<up> 2 + bdv \<up> 3=0) = (bdv=0 | ( bdv + bdv \<up> 2=0))" and
|
neuper@37983
|
264 |
d3_isolate_add1:
|
walther@60242
|
265 |
"[|Not(bdv occurs_in a)|] ==> (a + b*bdv \<up> 3=0) = (b*bdv \<up> 3= (-1)*a)" and
|
neuper@37983
|
266 |
d3_isolate_add2:
|
walther@60242
|
267 |
"[|Not(bdv occurs_in a)|] ==> (a + bdv \<up> 3=0) = ( bdv \<up> 3= (-1)*a)" and
|
neuper@37983
|
268 |
d3_isolate_div:
|
walther@60242
|
269 |
"[|Not(b=0);Not(bdv occurs_in a)|] ==> (b*bdv \<up> 3=c) = (bdv \<up> 3=c/b)" and
|
neuper@37983
|
270 |
d3_root_equation2:
|
walther@60242
|
271 |
"(bdv \<up> 3=0) = (bdv=0)" and
|
neuper@37983
|
272 |
d3_root_equation1:
|
walther@60242
|
273 |
"(bdv \<up> 3=c) = (bdv = nroot 3 c)" and
|
neuper@37906
|
274 |
|
neuper@37906
|
275 |
(* ---- degree 4 ----*)
|
neuper@37906
|
276 |
(* RL03.FIXME es wir nicht getestet ob u>0 *)
|
neuper@37989
|
277 |
d4_sub_u1:
|
walther@60242
|
278 |
"(c+b*bdv \<up> 2+a*bdv \<up> 4=0) =
|
walther@60242
|
279 |
((a*u \<up> 2+b*u+c=0) & (bdv \<up> 2=u))" and
|
neuper@37906
|
280 |
|
neuper@37906
|
281 |
(* ---- 7.3.02 von Termorder ---- *)
|
neuper@37906
|
282 |
|
neuper@52148
|
283 |
bdv_collect_1: "l * bdv + m * bdv = (l + m) * bdv" and
|
neuper@52148
|
284 |
bdv_collect_2: "bdv + m * bdv = (1 + m) * bdv" and
|
neuper@52148
|
285 |
bdv_collect_3: "l * bdv + bdv = (l + 1) * bdv" and
|
neuper@37906
|
286 |
|
neuper@37906
|
287 |
(* bdv_collect_assoc0_1 "l * bdv + m * bdv + k = (l + m) * bdv + k"
|
neuper@37906
|
288 |
bdv_collect_assoc0_2 "bdv + m * bdv + k = (1 + m) * bdv + k"
|
neuper@37906
|
289 |
bdv_collect_assoc0_3 "l * bdv + bdv + k = (l + 1) * bdv + k"
|
neuper@37906
|
290 |
*)
|
neuper@52148
|
291 |
bdv_collect_assoc1_1: "l * bdv + (m * bdv + k) = (l + m) * bdv + k" and
|
neuper@52148
|
292 |
bdv_collect_assoc1_2: "bdv + (m * bdv + k) = (1 + m) * bdv + k" and
|
neuper@52148
|
293 |
bdv_collect_assoc1_3: "l * bdv + (bdv + k) = (l + 1) * bdv + k" and
|
neuper@38030
|
294 |
|
neuper@52148
|
295 |
bdv_collect_assoc2_1: "k + l * bdv + m * bdv = k + (l + m) * bdv" and
|
neuper@52148
|
296 |
bdv_collect_assoc2_2: "k + bdv + m * bdv = k + (1 + m) * bdv" and
|
neuper@52148
|
297 |
bdv_collect_assoc2_3: "k + l * bdv + bdv = k + (l + 1) * bdv" and
|
neuper@37906
|
298 |
|
neuper@37906
|
299 |
|
walther@60242
|
300 |
bdv_n_collect_1: "l * bdv \<up> n + m * bdv \<up> n = (l + m) * bdv \<up> n" and
|
walther@60242
|
301 |
bdv_n_collect_2: " bdv \<up> n + m * bdv \<up> n = (1 + m) * bdv \<up> n" and
|
walther@60242
|
302 |
bdv_n_collect_3: "l * bdv \<up> n + bdv \<up> n = (l + 1) * bdv \<up> n" (*order!*) and
|
neuper@37906
|
303 |
|
neuper@38030
|
304 |
bdv_n_collect_assoc1_1:
|
walther@60242
|
305 |
"l * bdv \<up> n + (m * bdv \<up> n + k) = (l + m) * bdv \<up> n + k" and
|
walther@60242
|
306 |
bdv_n_collect_assoc1_2: "bdv \<up> n + (m * bdv \<up> n + k) = (1 + m) * bdv \<up> n + k" and
|
walther@60242
|
307 |
bdv_n_collect_assoc1_3: "l * bdv \<up> n + (bdv \<up> n + k) = (l + 1) * bdv \<up> n + k" and
|
neuper@37906
|
308 |
|
walther@60242
|
309 |
bdv_n_collect_assoc2_1: "k + l * bdv \<up> n + m * bdv \<up> n = k +(l + m) * bdv \<up> n" and
|
walther@60242
|
310 |
bdv_n_collect_assoc2_2: "k + bdv \<up> n + m * bdv \<up> n = k + (1 + m) * bdv \<up> n" and
|
walther@60242
|
311 |
bdv_n_collect_assoc2_3: "k + l * bdv \<up> n + bdv \<up> n = k + (l + 1) * bdv \<up> n" and
|
neuper@37906
|
312 |
|
neuper@37906
|
313 |
(*WN.14.3.03*)
|
neuper@52148
|
314 |
real_minus_div: "- (a / b) = (-1 * a) / b" and
|
neuper@38030
|
315 |
|
neuper@52148
|
316 |
separate_bdv: "(a * bdv) / b = (a / b) * (bdv::real)" and
|
walther@60242
|
317 |
separate_bdv_n: "(a * bdv \<up> n) / b = (a / b) * bdv \<up> n" and
|
neuper@52148
|
318 |
separate_1_bdv: "bdv / b = (1 / b) * (bdv::real)" and
|
walther@60242
|
319 |
separate_1_bdv_n: "bdv \<up> n / b = (1 / b) * bdv \<up> n"
|
neuper@37906
|
320 |
|
wneuper@59472
|
321 |
ML \<open>
|
neuper@37972
|
322 |
val thy = @{theory};
|
neuper@37972
|
323 |
|
neuper@37954
|
324 |
(*-------------------------rulse-------------------------*)
|
neuper@37954
|
325 |
val PolyEq_prls = (*3.10.02:just the following order due to subterm evaluation*)
|
walther@59852
|
326 |
Rule_Set.append_rules "PolyEq_prls" Rule_Set.empty
|
walther@59878
|
327 |
[Rule.Eval ("Prog_Expr.ident", Prog_Expr.eval_ident "#ident_"),
|
walther@59878
|
328 |
Rule.Eval ("Prog_Expr.matches", Prog_Expr.eval_matches ""),
|
walther@59878
|
329 |
Rule.Eval ("Prog_Expr.lhs", Prog_Expr.eval_lhs ""),
|
walther@59878
|
330 |
Rule.Eval ("Prog_Expr.rhs", Prog_Expr.eval_rhs ""),
|
walther@59878
|
331 |
Rule.Eval ("Poly.is'_expanded'_in", eval_is_expanded_in ""),
|
walther@59878
|
332 |
Rule.Eval ("Poly.is'_poly'_in", eval_is_poly_in ""),
|
walther@59878
|
333 |
Rule.Eval ("Poly.has'_degree'_in", eval_has_degree_in ""),
|
walther@59878
|
334 |
Rule.Eval ("Poly.is'_polyrat'_in", eval_is_polyrat_in ""),
|
walther@59878
|
335 |
(*Rule.Eval ("Prog_Expr.occurs'_in", Prog_Expr.eval_occurs_in ""), *)
|
walther@59878
|
336 |
(*Rule.Eval ("Prog_Expr.is'_const", Prog_Expr.eval_const "#is_const_"),*)
|
walther@59878
|
337 |
Rule.Eval ("HOL.eq", Prog_Expr.eval_equal "#equal_"),
|
walther@59878
|
338 |
Rule.Eval ("RootEq.is'_rootTerm'_in", eval_is_rootTerm_in ""),
|
walther@59878
|
339 |
Rule.Eval ("RatEq.is'_ratequation'_in", eval_is_ratequation_in ""),
|
walther@59871
|
340 |
Rule.Thm ("not_true",ThmC.numerals_to_Free @{thm not_true}),
|
walther@59871
|
341 |
Rule.Thm ("not_false",ThmC.numerals_to_Free @{thm not_false}),
|
walther@59871
|
342 |
Rule.Thm ("and_true",ThmC.numerals_to_Free @{thm and_true}),
|
walther@59871
|
343 |
Rule.Thm ("and_false",ThmC.numerals_to_Free @{thm and_false}),
|
walther@59871
|
344 |
Rule.Thm ("or_true",ThmC.numerals_to_Free @{thm or_true}),
|
walther@59871
|
345 |
Rule.Thm ("or_false",ThmC.numerals_to_Free @{thm or_false})
|
neuper@37954
|
346 |
];
|
neuper@37954
|
347 |
|
neuper@37954
|
348 |
val PolyEq_erls =
|
walther@59852
|
349 |
Rule_Set.merge "PolyEq_erls" LinEq_erls
|
walther@59852
|
350 |
(Rule_Set.append_rules "ops_preds" calculate_Rational
|
walther@59878
|
351 |
[Rule.Eval ("HOL.eq", Prog_Expr.eval_equal "#equal_"),
|
walther@59871
|
352 |
Rule.Thm ("plus_leq", ThmC.numerals_to_Free @{thm plus_leq}),
|
walther@59871
|
353 |
Rule.Thm ("minus_leq", ThmC.numerals_to_Free @{thm minus_leq}),
|
walther@59871
|
354 |
Rule.Thm ("rat_leq1", ThmC.numerals_to_Free @{thm rat_leq1}),
|
walther@59871
|
355 |
Rule.Thm ("rat_leq2", ThmC.numerals_to_Free @{thm rat_leq2}),
|
walther@59871
|
356 |
Rule.Thm ("rat_leq3", ThmC.numerals_to_Free @{thm rat_leq3})
|
neuper@37954
|
357 |
]);
|
neuper@37954
|
358 |
|
neuper@37954
|
359 |
val PolyEq_crls =
|
walther@59852
|
360 |
Rule_Set.merge "PolyEq_crls" LinEq_crls
|
walther@59852
|
361 |
(Rule_Set.append_rules "ops_preds" calculate_Rational
|
walther@59878
|
362 |
[Rule.Eval ("HOL.eq", Prog_Expr.eval_equal "#equal_"),
|
walther@59871
|
363 |
Rule.Thm ("plus_leq", ThmC.numerals_to_Free @{thm plus_leq}),
|
walther@59871
|
364 |
Rule.Thm ("minus_leq", ThmC.numerals_to_Free @{thm minus_leq}),
|
walther@59871
|
365 |
Rule.Thm ("rat_leq1", ThmC.numerals_to_Free @{thm rat_leq1}),
|
walther@59871
|
366 |
Rule.Thm ("rat_leq2", ThmC.numerals_to_Free @{thm rat_leq2}),
|
walther@59871
|
367 |
Rule.Thm ("rat_leq3", ThmC.numerals_to_Free @{thm rat_leq3})
|
neuper@37954
|
368 |
]);
|
neuper@37954
|
369 |
|
s1210629013@55444
|
370 |
val cancel_leading_coeff = prep_rls'(
|
walther@59851
|
371 |
Rule_Def.Repeat {id = "cancel_leading_coeff", preconds = [],
|
walther@59857
|
372 |
rew_ord = ("e_rew_ord",Rewrite_Ord.e_rew_ord),
|
walther@59851
|
373 |
erls = PolyEq_erls, srls = Rule_Set.Empty, calc = [], errpatts = [],
|
neuper@37989
|
374 |
rules =
|
walther@59871
|
375 |
[Rule.Thm ("cancel_leading_coeff1",ThmC.numerals_to_Free @{thm cancel_leading_coeff1}),
|
walther@59871
|
376 |
Rule.Thm ("cancel_leading_coeff2",ThmC.numerals_to_Free @{thm cancel_leading_coeff2}),
|
walther@59871
|
377 |
Rule.Thm ("cancel_leading_coeff3",ThmC.numerals_to_Free @{thm cancel_leading_coeff3}),
|
walther@59871
|
378 |
Rule.Thm ("cancel_leading_coeff4",ThmC.numerals_to_Free @{thm cancel_leading_coeff4}),
|
walther@59871
|
379 |
Rule.Thm ("cancel_leading_coeff5",ThmC.numerals_to_Free @{thm cancel_leading_coeff5}),
|
walther@59871
|
380 |
Rule.Thm ("cancel_leading_coeff6",ThmC.numerals_to_Free @{thm cancel_leading_coeff6}),
|
walther@59871
|
381 |
Rule.Thm ("cancel_leading_coeff7",ThmC.numerals_to_Free @{thm cancel_leading_coeff7}),
|
walther@59871
|
382 |
Rule.Thm ("cancel_leading_coeff8",ThmC.numerals_to_Free @{thm cancel_leading_coeff8}),
|
walther@59871
|
383 |
Rule.Thm ("cancel_leading_coeff9",ThmC.numerals_to_Free @{thm cancel_leading_coeff9}),
|
walther@59871
|
384 |
Rule.Thm ("cancel_leading_coeff10",ThmC.numerals_to_Free @{thm cancel_leading_coeff10}),
|
walther@59871
|
385 |
Rule.Thm ("cancel_leading_coeff11",ThmC.numerals_to_Free @{thm cancel_leading_coeff11}),
|
walther@59871
|
386 |
Rule.Thm ("cancel_leading_coeff12",ThmC.numerals_to_Free @{thm cancel_leading_coeff12}),
|
walther@59871
|
387 |
Rule.Thm ("cancel_leading_coeff13",ThmC.numerals_to_Free @{thm cancel_leading_coeff13})
|
walther@59878
|
388 |
],scr = Rule.Empty_Prog});
|
s1210629013@55444
|
389 |
|
walther@59618
|
390 |
val prep_rls' = Auto_Prog.prep_rls @{theory};
|
wneuper@59472
|
391 |
\<close>
|
wneuper@59472
|
392 |
ML\<open>
|
s1210629013@55444
|
393 |
val complete_square = prep_rls'(
|
walther@59851
|
394 |
Rule_Def.Repeat {id = "complete_square", preconds = [],
|
walther@59857
|
395 |
rew_ord = ("e_rew_ord",Rewrite_Ord.e_rew_ord),
|
walther@59851
|
396 |
erls = PolyEq_erls, srls = Rule_Set.Empty, calc = [], errpatts = [],
|
walther@59871
|
397 |
rules = [Rule.Thm ("complete_square1",ThmC.numerals_to_Free @{thm complete_square1}),
|
walther@59871
|
398 |
Rule.Thm ("complete_square2",ThmC.numerals_to_Free @{thm complete_square2}),
|
walther@59871
|
399 |
Rule.Thm ("complete_square3",ThmC.numerals_to_Free @{thm complete_square3}),
|
walther@59871
|
400 |
Rule.Thm ("complete_square4",ThmC.numerals_to_Free @{thm complete_square4}),
|
walther@59871
|
401 |
Rule.Thm ("complete_square5",ThmC.numerals_to_Free @{thm complete_square5})
|
neuper@37954
|
402 |
],
|
walther@59878
|
403 |
scr = Rule.Empty_Prog
|
wneuper@59406
|
404 |
});
|
neuper@37954
|
405 |
|
s1210629013@55444
|
406 |
val polyeq_simplify = prep_rls'(
|
walther@59851
|
407 |
Rule_Def.Repeat {id = "polyeq_simplify", preconds = [],
|
neuper@37954
|
408 |
rew_ord = ("termlessI",termlessI),
|
neuper@37954
|
409 |
erls = PolyEq_erls,
|
walther@59851
|
410 |
srls = Rule_Set.Empty,
|
neuper@42451
|
411 |
calc = [], errpatts = [],
|
walther@59871
|
412 |
rules = [Rule.Thm ("real_assoc_1",ThmC.numerals_to_Free @{thm real_assoc_1}),
|
walther@59871
|
413 |
Rule.Thm ("real_assoc_2",ThmC.numerals_to_Free @{thm real_assoc_2}),
|
walther@59871
|
414 |
Rule.Thm ("real_diff_minus",ThmC.numerals_to_Free @{thm real_diff_minus}),
|
walther@59871
|
415 |
Rule.Thm ("real_unari_minus",ThmC.numerals_to_Free @{thm real_unari_minus}),
|
walther@59871
|
416 |
Rule.Thm ("realpow_multI",ThmC.numerals_to_Free @{thm realpow_multI}),
|
walther@59878
|
417 |
Rule.Eval ("Groups.plus_class.plus", (**)eval_binop "#add_"),
|
walther@59878
|
418 |
Rule.Eval ("Groups.minus_class.minus", (**)eval_binop "#sub_"),
|
walther@59878
|
419 |
Rule.Eval ("Groups.times_class.times", (**)eval_binop "#mult_"),
|
walther@59878
|
420 |
Rule.Eval ("Rings.divide_class.divide", Prog_Expr.eval_cancel "#divide_e"),
|
walther@59878
|
421 |
Rule.Eval ("NthRoot.sqrt", eval_sqrt "#sqrt_"),
|
walther@59878
|
422 |
Rule.Eval ("Prog_Expr.pow" , (**)eval_binop "#power_"),
|
wneuper@59416
|
423 |
Rule.Rls_ reduce_012
|
neuper@37954
|
424 |
],
|
walther@59878
|
425 |
scr = Rule.Empty_Prog
|
wneuper@59406
|
426 |
});
|
wneuper@59472
|
427 |
\<close>
|
wneuper@59472
|
428 |
setup \<open>KEStore_Elems.add_rlss
|
neuper@52125
|
429 |
[("cancel_leading_coeff", (Context.theory_name @{theory}, cancel_leading_coeff)),
|
neuper@52125
|
430 |
("complete_square", (Context.theory_name @{theory}, complete_square)),
|
neuper@52125
|
431 |
("PolyEq_erls", (Context.theory_name @{theory}, PolyEq_erls)),
|
wneuper@59472
|
432 |
("polyeq_simplify", (Context.theory_name @{theory}, polyeq_simplify))]\<close>
|
wneuper@59472
|
433 |
ML\<open>
|
neuper@37954
|
434 |
|
neuper@37954
|
435 |
(* ------------- polySolve ------------------ *)
|
neuper@37954
|
436 |
(* -- d0 -- *)
|
neuper@37954
|
437 |
(*isolate the bound variable in an d0 equation; 'bdv' is a meta-constant*)
|
s1210629013@55444
|
438 |
val d0_polyeq_simplify = prep_rls'(
|
walther@59851
|
439 |
Rule_Def.Repeat {id = "d0_polyeq_simplify", preconds = [],
|
walther@59857
|
440 |
rew_ord = ("e_rew_ord",Rewrite_Ord.e_rew_ord),
|
neuper@37954
|
441 |
erls = PolyEq_erls,
|
walther@59851
|
442 |
srls = Rule_Set.Empty,
|
neuper@42451
|
443 |
calc = [], errpatts = [],
|
walther@59871
|
444 |
rules = [Rule.Thm("d0_true",ThmC.numerals_to_Free @{thm d0_true}),
|
walther@59871
|
445 |
Rule.Thm("d0_false",ThmC.numerals_to_Free @{thm d0_false})
|
neuper@37954
|
446 |
],
|
walther@59878
|
447 |
scr = Rule.Empty_Prog
|
wneuper@59406
|
448 |
});
|
neuper@37954
|
449 |
|
neuper@37954
|
450 |
(* -- d1 -- *)
|
neuper@37954
|
451 |
(*isolate the bound variable in an d1 equation; 'bdv' is a meta-constant*)
|
s1210629013@55444
|
452 |
val d1_polyeq_simplify = prep_rls'(
|
walther@59851
|
453 |
Rule_Def.Repeat {id = "d1_polyeq_simplify", preconds = [],
|
walther@59857
|
454 |
rew_ord = ("e_rew_ord",Rewrite_Ord.e_rew_ord),
|
neuper@37954
|
455 |
erls = PolyEq_erls,
|
walther@59851
|
456 |
srls = Rule_Set.Empty,
|
neuper@42451
|
457 |
calc = [], errpatts = [],
|
neuper@37954
|
458 |
rules = [
|
walther@59871
|
459 |
Rule.Thm("d1_isolate_add1",ThmC.numerals_to_Free @{thm d1_isolate_add1}),
|
neuper@37954
|
460 |
(* a+bx=0 -> bx=-a *)
|
walther@59871
|
461 |
Rule.Thm("d1_isolate_add2",ThmC.numerals_to_Free @{thm d1_isolate_add2}),
|
neuper@37954
|
462 |
(* a+ x=0 -> x=-a *)
|
walther@59871
|
463 |
Rule.Thm("d1_isolate_div",ThmC.numerals_to_Free @{thm d1_isolate_div})
|
neuper@37954
|
464 |
(* bx=c -> x=c/b *)
|
neuper@37954
|
465 |
],
|
walther@59878
|
466 |
scr = Rule.Empty_Prog
|
wneuper@59406
|
467 |
});
|
neuper@37954
|
468 |
|
wneuper@59472
|
469 |
\<close>
|
wneuper@59472
|
470 |
subsection \<open>degree 2\<close>
|
wneuper@59472
|
471 |
ML\<open>
|
neuper@42394
|
472 |
(* isolate the bound variable in an d2 equation with bdv only;
|
neuper@42394
|
473 |
"bdv" is a meta-constant substituted for the "x" below by isac's rewriter. *)
|
s1210629013@55444
|
474 |
val d2_polyeq_bdv_only_simplify = prep_rls'(
|
walther@59857
|
475 |
Rule_Def.Repeat {id = "d2_polyeq_bdv_only_simplify", preconds = [], rew_ord = ("e_rew_ord",Rewrite_Ord.e_rew_ord),
|
walther@59851
|
476 |
erls = PolyEq_erls, srls = Rule_Set.Empty, calc = [], errpatts = [],
|
neuper@42394
|
477 |
rules =
|
walther@59871
|
478 |
[Rule.Thm ("d2_prescind1", ThmC.numerals_to_Free @{thm d2_prescind1}), (* ax+bx^2=0 -> x(a+bx)=0 *)
|
walther@59871
|
479 |
Rule.Thm ("d2_prescind2", ThmC.numerals_to_Free @{thm d2_prescind2}), (* ax+ x^2=0 -> x(a+ x)=0 *)
|
walther@59871
|
480 |
Rule.Thm ("d2_prescind3", ThmC.numerals_to_Free @{thm d2_prescind3}), (* x+bx^2=0 -> x(1+bx)=0 *)
|
walther@59871
|
481 |
Rule.Thm ("d2_prescind4", ThmC.numerals_to_Free @{thm d2_prescind4}), (* x+ x^2=0 -> x(1+ x)=0 *)
|
walther@59871
|
482 |
Rule.Thm ("d2_sqrt_equation1", ThmC.numerals_to_Free @{thm d2_sqrt_equation1}), (* x^2=c -> x=+-sqrt(c) *)
|
walther@59871
|
483 |
Rule.Thm ("d2_sqrt_equation1_neg", ThmC.numerals_to_Free @{thm d2_sqrt_equation1_neg}), (* [0<c] x^2=c -> []*)
|
walther@59871
|
484 |
Rule.Thm ("d2_sqrt_equation2", ThmC.numerals_to_Free @{thm d2_sqrt_equation2}), (* x^2=0 -> x=0 *)
|
walther@59871
|
485 |
Rule.Thm ("d2_reduce_equation1", ThmC.numerals_to_Free @{thm d2_reduce_equation1}),(* x(a+bx)=0 -> x=0 |a+bx=0*)
|
walther@59871
|
486 |
Rule.Thm ("d2_reduce_equation2", ThmC.numerals_to_Free @{thm d2_reduce_equation2}),(* x(a+ x)=0 -> x=0 |a+ x=0*)
|
walther@59871
|
487 |
Rule.Thm ("d2_isolate_div", ThmC.numerals_to_Free @{thm d2_isolate_div}) (* bx^2=c -> x^2=c/b *)
|
neuper@42394
|
488 |
],
|
walther@59878
|
489 |
scr = Rule.Empty_Prog
|
wneuper@59406
|
490 |
});
|
wneuper@59472
|
491 |
\<close>
|
wneuper@59472
|
492 |
ML\<open>
|
neuper@37954
|
493 |
(* isolate the bound variable in an d2 equation with sqrt only;
|
neuper@37954
|
494 |
'bdv' is a meta-constant*)
|
s1210629013@55444
|
495 |
val d2_polyeq_sq_only_simplify = prep_rls'(
|
walther@59851
|
496 |
Rule_Def.Repeat {id = "d2_polyeq_sq_only_simplify", preconds = [],
|
walther@59857
|
497 |
rew_ord = ("e_rew_ord",Rewrite_Ord.e_rew_ord),
|
neuper@37954
|
498 |
erls = PolyEq_erls,
|
walther@59851
|
499 |
srls = Rule_Set.Empty,
|
neuper@42451
|
500 |
calc = [], errpatts = [],
|
walther@59997
|
501 |
(*asm_thm = [("d2_sqrt_equation1", ""),("d2_sqrt_equation1_neg", ""),
|
walther@59997
|
502 |
("d2_isolate_div", "")],*)
|
walther@59871
|
503 |
rules = [Rule.Thm("d2_isolate_add1",ThmC.numerals_to_Free @{thm d2_isolate_add1}),
|
neuper@37954
|
504 |
(* a+ bx^2=0 -> bx^2=(-1)a*)
|
walther@59871
|
505 |
Rule.Thm("d2_isolate_add2",ThmC.numerals_to_Free @{thm d2_isolate_add2}),
|
neuper@37954
|
506 |
(* a+ x^2=0 -> x^2=(-1)a*)
|
walther@59871
|
507 |
Rule.Thm("d2_sqrt_equation2",ThmC.numerals_to_Free @{thm d2_sqrt_equation2}),
|
neuper@37954
|
508 |
(* x^2=0 -> x=0 *)
|
walther@59871
|
509 |
Rule.Thm("d2_sqrt_equation1",ThmC.numerals_to_Free @{thm d2_sqrt_equation1}),
|
neuper@37954
|
510 |
(* x^2=c -> x=+-sqrt(c)*)
|
walther@59871
|
511 |
Rule.Thm("d2_sqrt_equation1_neg",ThmC.numerals_to_Free @{thm d2_sqrt_equation1_neg}),
|
neuper@37954
|
512 |
(* [c<0] x^2=c -> x=[] *)
|
walther@59871
|
513 |
Rule.Thm("d2_isolate_div",ThmC.numerals_to_Free @{thm d2_isolate_div})
|
neuper@37954
|
514 |
(* bx^2=c -> x^2=c/b*)
|
neuper@37954
|
515 |
],
|
walther@59878
|
516 |
scr = Rule.Empty_Prog
|
wneuper@59406
|
517 |
});
|
wneuper@59472
|
518 |
\<close>
|
wneuper@59472
|
519 |
ML\<open>
|
neuper@37954
|
520 |
(* isolate the bound variable in an d2 equation with pqFormula;
|
neuper@37954
|
521 |
'bdv' is a meta-constant*)
|
s1210629013@55444
|
522 |
val d2_polyeq_pqFormula_simplify = prep_rls'(
|
walther@59851
|
523 |
Rule_Def.Repeat {id = "d2_polyeq_pqFormula_simplify", preconds = [],
|
walther@59857
|
524 |
rew_ord = ("e_rew_ord",Rewrite_Ord.e_rew_ord), erls = PolyEq_erls,
|
walther@59851
|
525 |
srls = Rule_Set.Empty, calc = [], errpatts = [],
|
walther@59871
|
526 |
rules = [Rule.Thm("d2_pqformula1",ThmC.numerals_to_Free @{thm d2_pqformula1}),
|
neuper@37954
|
527 |
(* q+px+ x^2=0 *)
|
walther@59871
|
528 |
Rule.Thm("d2_pqformula1_neg",ThmC.numerals_to_Free @{thm d2_pqformula1_neg}),
|
neuper@37954
|
529 |
(* q+px+ x^2=0 *)
|
walther@59871
|
530 |
Rule.Thm("d2_pqformula2",ThmC.numerals_to_Free @{thm d2_pqformula2}),
|
neuper@37954
|
531 |
(* q+px+1x^2=0 *)
|
walther@59871
|
532 |
Rule.Thm("d2_pqformula2_neg",ThmC.numerals_to_Free @{thm d2_pqformula2_neg}),
|
neuper@37954
|
533 |
(* q+px+1x^2=0 *)
|
walther@59871
|
534 |
Rule.Thm("d2_pqformula3",ThmC.numerals_to_Free @{thm d2_pqformula3}),
|
neuper@37954
|
535 |
(* q+ x+ x^2=0 *)
|
walther@59871
|
536 |
Rule.Thm("d2_pqformula3_neg",ThmC.numerals_to_Free @{thm d2_pqformula3_neg}),
|
neuper@37954
|
537 |
(* q+ x+ x^2=0 *)
|
walther@59871
|
538 |
Rule.Thm("d2_pqformula4",ThmC.numerals_to_Free @{thm d2_pqformula4}),
|
neuper@37954
|
539 |
(* q+ x+1x^2=0 *)
|
walther@59871
|
540 |
Rule.Thm("d2_pqformula4_neg",ThmC.numerals_to_Free @{thm d2_pqformula4_neg}),
|
neuper@37954
|
541 |
(* q+ x+1x^2=0 *)
|
walther@59871
|
542 |
Rule.Thm("d2_pqformula5",ThmC.numerals_to_Free @{thm d2_pqformula5}),
|
neuper@37954
|
543 |
(* qx+ x^2=0 *)
|
walther@59871
|
544 |
Rule.Thm("d2_pqformula6",ThmC.numerals_to_Free @{thm d2_pqformula6}),
|
neuper@37954
|
545 |
(* qx+1x^2=0 *)
|
walther@59871
|
546 |
Rule.Thm("d2_pqformula7",ThmC.numerals_to_Free @{thm d2_pqformula7}),
|
neuper@37954
|
547 |
(* x+ x^2=0 *)
|
walther@59871
|
548 |
Rule.Thm("d2_pqformula8",ThmC.numerals_to_Free @{thm d2_pqformula8}),
|
neuper@37954
|
549 |
(* x+1x^2=0 *)
|
walther@59871
|
550 |
Rule.Thm("d2_pqformula9",ThmC.numerals_to_Free @{thm d2_pqformula9}),
|
neuper@37954
|
551 |
(* q +1x^2=0 *)
|
walther@59871
|
552 |
Rule.Thm("d2_pqformula9_neg",ThmC.numerals_to_Free @{thm d2_pqformula9_neg}),
|
neuper@37954
|
553 |
(* q +1x^2=0 *)
|
walther@59871
|
554 |
Rule.Thm("d2_pqformula10",ThmC.numerals_to_Free @{thm d2_pqformula10}),
|
neuper@37954
|
555 |
(* q + x^2=0 *)
|
walther@59871
|
556 |
Rule.Thm("d2_pqformula10_neg",ThmC.numerals_to_Free @{thm d2_pqformula10_neg}),
|
neuper@37954
|
557 |
(* q + x^2=0 *)
|
walther@59871
|
558 |
Rule.Thm("d2_sqrt_equation2",ThmC.numerals_to_Free @{thm d2_sqrt_equation2}),
|
neuper@37954
|
559 |
(* x^2=0 *)
|
walther@59871
|
560 |
Rule.Thm("d2_sqrt_equation3",ThmC.numerals_to_Free @{thm d2_sqrt_equation3})
|
neuper@37954
|
561 |
(* 1x^2=0 *)
|
walther@59878
|
562 |
],scr = Rule.Empty_Prog
|
wneuper@59406
|
563 |
});
|
wneuper@59472
|
564 |
\<close>
|
wneuper@59472
|
565 |
ML\<open>
|
neuper@37954
|
566 |
(* isolate the bound variable in an d2 equation with abcFormula;
|
neuper@37954
|
567 |
'bdv' is a meta-constant*)
|
s1210629013@55444
|
568 |
val d2_polyeq_abcFormula_simplify = prep_rls'(
|
walther@59851
|
569 |
Rule_Def.Repeat {id = "d2_polyeq_abcFormula_simplify", preconds = [],
|
walther@59857
|
570 |
rew_ord = ("e_rew_ord",Rewrite_Ord.e_rew_ord), erls = PolyEq_erls,
|
walther@59851
|
571 |
srls = Rule_Set.Empty, calc = [], errpatts = [],
|
walther@59871
|
572 |
rules = [Rule.Thm("d2_abcformula1",ThmC.numerals_to_Free @{thm d2_abcformula1}),
|
neuper@37954
|
573 |
(*c+bx+cx^2=0 *)
|
walther@59871
|
574 |
Rule.Thm("d2_abcformula1_neg",ThmC.numerals_to_Free @{thm d2_abcformula1_neg}),
|
neuper@37954
|
575 |
(*c+bx+cx^2=0 *)
|
walther@59871
|
576 |
Rule.Thm("d2_abcformula2",ThmC.numerals_to_Free @{thm d2_abcformula2}),
|
neuper@37954
|
577 |
(*c+ x+cx^2=0 *)
|
walther@59871
|
578 |
Rule.Thm("d2_abcformula2_neg",ThmC.numerals_to_Free @{thm d2_abcformula2_neg}),
|
neuper@37954
|
579 |
(*c+ x+cx^2=0 *)
|
walther@59871
|
580 |
Rule.Thm("d2_abcformula3",ThmC.numerals_to_Free @{thm d2_abcformula3}),
|
neuper@37954
|
581 |
(*c+bx+ x^2=0 *)
|
walther@59871
|
582 |
Rule.Thm("d2_abcformula3_neg",ThmC.numerals_to_Free @{thm d2_abcformula3_neg}),
|
neuper@37954
|
583 |
(*c+bx+ x^2=0 *)
|
walther@59871
|
584 |
Rule.Thm("d2_abcformula4",ThmC.numerals_to_Free @{thm d2_abcformula4}),
|
neuper@37954
|
585 |
(*c+ x+ x^2=0 *)
|
walther@59871
|
586 |
Rule.Thm("d2_abcformula4_neg",ThmC.numerals_to_Free @{thm d2_abcformula4_neg}),
|
neuper@37954
|
587 |
(*c+ x+ x^2=0 *)
|
walther@59871
|
588 |
Rule.Thm("d2_abcformula5",ThmC.numerals_to_Free @{thm d2_abcformula5}),
|
neuper@37954
|
589 |
(*c+ cx^2=0 *)
|
walther@59871
|
590 |
Rule.Thm("d2_abcformula5_neg",ThmC.numerals_to_Free @{thm d2_abcformula5_neg}),
|
neuper@37954
|
591 |
(*c+ cx^2=0 *)
|
walther@59871
|
592 |
Rule.Thm("d2_abcformula6",ThmC.numerals_to_Free @{thm d2_abcformula6}),
|
neuper@37954
|
593 |
(*c+ x^2=0 *)
|
walther@59871
|
594 |
Rule.Thm("d2_abcformula6_neg",ThmC.numerals_to_Free @{thm d2_abcformula6_neg}),
|
neuper@37954
|
595 |
(*c+ x^2=0 *)
|
walther@59871
|
596 |
Rule.Thm("d2_abcformula7",ThmC.numerals_to_Free @{thm d2_abcformula7}),
|
neuper@37954
|
597 |
(* bx+ax^2=0 *)
|
walther@59871
|
598 |
Rule.Thm("d2_abcformula8",ThmC.numerals_to_Free @{thm d2_abcformula8}),
|
neuper@37954
|
599 |
(* bx+ x^2=0 *)
|
walther@59871
|
600 |
Rule.Thm("d2_abcformula9",ThmC.numerals_to_Free @{thm d2_abcformula9}),
|
neuper@37954
|
601 |
(* x+ax^2=0 *)
|
walther@59871
|
602 |
Rule.Thm("d2_abcformula10",ThmC.numerals_to_Free @{thm d2_abcformula10}),
|
neuper@37954
|
603 |
(* x+ x^2=0 *)
|
walther@59871
|
604 |
Rule.Thm("d2_sqrt_equation2",ThmC.numerals_to_Free @{thm d2_sqrt_equation2}),
|
neuper@37954
|
605 |
(* x^2=0 *)
|
walther@59871
|
606 |
Rule.Thm("d2_sqrt_equation3",ThmC.numerals_to_Free @{thm d2_sqrt_equation3})
|
neuper@37954
|
607 |
(* bx^2=0 *)
|
neuper@37954
|
608 |
],
|
walther@59878
|
609 |
scr = Rule.Empty_Prog
|
wneuper@59406
|
610 |
});
|
wneuper@59472
|
611 |
\<close>
|
wneuper@59472
|
612 |
ML\<open>
|
neuper@37954
|
613 |
|
neuper@37954
|
614 |
(* isolate the bound variable in an d2 equation;
|
neuper@37954
|
615 |
'bdv' is a meta-constant*)
|
s1210629013@55444
|
616 |
val d2_polyeq_simplify = prep_rls'(
|
walther@59851
|
617 |
Rule_Def.Repeat {id = "d2_polyeq_simplify", preconds = [],
|
walther@59857
|
618 |
rew_ord = ("e_rew_ord",Rewrite_Ord.e_rew_ord), erls = PolyEq_erls,
|
walther@59851
|
619 |
srls = Rule_Set.Empty, calc = [], errpatts = [],
|
walther@59871
|
620 |
rules = [Rule.Thm("d2_pqformula1",ThmC.numerals_to_Free @{thm d2_pqformula1}),
|
neuper@37954
|
621 |
(* p+qx+ x^2=0 *)
|
walther@59871
|
622 |
Rule.Thm("d2_pqformula1_neg",ThmC.numerals_to_Free @{thm d2_pqformula1_neg}),
|
neuper@37954
|
623 |
(* p+qx+ x^2=0 *)
|
walther@59871
|
624 |
Rule.Thm("d2_pqformula2",ThmC.numerals_to_Free @{thm d2_pqformula2}),
|
neuper@37954
|
625 |
(* p+qx+1x^2=0 *)
|
walther@59871
|
626 |
Rule.Thm("d2_pqformula2_neg",ThmC.numerals_to_Free @{thm d2_pqformula2_neg}),
|
neuper@37954
|
627 |
(* p+qx+1x^2=0 *)
|
walther@59871
|
628 |
Rule.Thm("d2_pqformula3",ThmC.numerals_to_Free @{thm d2_pqformula3}),
|
neuper@37954
|
629 |
(* p+ x+ x^2=0 *)
|
walther@59871
|
630 |
Rule.Thm("d2_pqformula3_neg",ThmC.numerals_to_Free @{thm d2_pqformula3_neg}),
|
neuper@37954
|
631 |
(* p+ x+ x^2=0 *)
|
walther@59871
|
632 |
Rule.Thm("d2_pqformula4",ThmC.numerals_to_Free @{thm d2_pqformula4}),
|
neuper@37954
|
633 |
(* p+ x+1x^2=0 *)
|
walther@59871
|
634 |
Rule.Thm("d2_pqformula4_neg",ThmC.numerals_to_Free @{thm d2_pqformula4_neg}),
|
neuper@37954
|
635 |
(* p+ x+1x^2=0 *)
|
walther@59871
|
636 |
Rule.Thm("d2_abcformula1",ThmC.numerals_to_Free @{thm d2_abcformula1}),
|
neuper@37954
|
637 |
(* c+bx+cx^2=0 *)
|
walther@59871
|
638 |
Rule.Thm("d2_abcformula1_neg",ThmC.numerals_to_Free @{thm d2_abcformula1_neg}),
|
neuper@37954
|
639 |
(* c+bx+cx^2=0 *)
|
walther@59871
|
640 |
Rule.Thm("d2_abcformula2",ThmC.numerals_to_Free @{thm d2_abcformula2}),
|
neuper@37954
|
641 |
(* c+ x+cx^2=0 *)
|
walther@59871
|
642 |
Rule.Thm("d2_abcformula2_neg",ThmC.numerals_to_Free @{thm d2_abcformula2_neg}),
|
neuper@37954
|
643 |
(* c+ x+cx^2=0 *)
|
walther@59871
|
644 |
Rule.Thm("d2_prescind1",ThmC.numerals_to_Free @{thm d2_prescind1}),
|
neuper@37954
|
645 |
(* ax+bx^2=0 -> x(a+bx)=0 *)
|
walther@59871
|
646 |
Rule.Thm("d2_prescind2",ThmC.numerals_to_Free @{thm d2_prescind2}),
|
neuper@37954
|
647 |
(* ax+ x^2=0 -> x(a+ x)=0 *)
|
walther@59871
|
648 |
Rule.Thm("d2_prescind3",ThmC.numerals_to_Free @{thm d2_prescind3}),
|
neuper@37954
|
649 |
(* x+bx^2=0 -> x(1+bx)=0 *)
|
walther@59871
|
650 |
Rule.Thm("d2_prescind4",ThmC.numerals_to_Free @{thm d2_prescind4}),
|
neuper@37954
|
651 |
(* x+ x^2=0 -> x(1+ x)=0 *)
|
walther@59871
|
652 |
Rule.Thm("d2_isolate_add1",ThmC.numerals_to_Free @{thm d2_isolate_add1}),
|
neuper@37954
|
653 |
(* a+ bx^2=0 -> bx^2=(-1)a*)
|
walther@59871
|
654 |
Rule.Thm("d2_isolate_add2",ThmC.numerals_to_Free @{thm d2_isolate_add2}),
|
neuper@37954
|
655 |
(* a+ x^2=0 -> x^2=(-1)a*)
|
walther@59871
|
656 |
Rule.Thm("d2_sqrt_equation1",ThmC.numerals_to_Free @{thm d2_sqrt_equation1}),
|
neuper@37954
|
657 |
(* x^2=c -> x=+-sqrt(c)*)
|
walther@59871
|
658 |
Rule.Thm("d2_sqrt_equation1_neg",ThmC.numerals_to_Free @{thm d2_sqrt_equation1_neg}),
|
neuper@37954
|
659 |
(* [c<0] x^2=c -> x=[]*)
|
walther@59871
|
660 |
Rule.Thm("d2_sqrt_equation2",ThmC.numerals_to_Free @{thm d2_sqrt_equation2}),
|
neuper@37954
|
661 |
(* x^2=0 -> x=0 *)
|
walther@59871
|
662 |
Rule.Thm("d2_reduce_equation1",ThmC.numerals_to_Free @{thm d2_reduce_equation1}),
|
neuper@37954
|
663 |
(* x(a+bx)=0 -> x=0 | a+bx=0*)
|
walther@59871
|
664 |
Rule.Thm("d2_reduce_equation2",ThmC.numerals_to_Free @{thm d2_reduce_equation2}),
|
neuper@37954
|
665 |
(* x(a+ x)=0 -> x=0 | a+ x=0*)
|
walther@59871
|
666 |
Rule.Thm("d2_isolate_div",ThmC.numerals_to_Free @{thm d2_isolate_div})
|
neuper@37954
|
667 |
(* bx^2=c -> x^2=c/b*)
|
neuper@37954
|
668 |
],
|
walther@59878
|
669 |
scr = Rule.Empty_Prog
|
wneuper@59406
|
670 |
});
|
wneuper@59472
|
671 |
\<close>
|
wneuper@59472
|
672 |
ML\<open>
|
neuper@37954
|
673 |
|
neuper@37954
|
674 |
(* -- d3 -- *)
|
neuper@37954
|
675 |
(* isolate the bound variable in an d3 equation; 'bdv' is a meta-constant *)
|
s1210629013@55444
|
676 |
val d3_polyeq_simplify = prep_rls'(
|
walther@59851
|
677 |
Rule_Def.Repeat {id = "d3_polyeq_simplify", preconds = [],
|
walther@59857
|
678 |
rew_ord = ("e_rew_ord",Rewrite_Ord.e_rew_ord), erls = PolyEq_erls,
|
walther@59851
|
679 |
srls = Rule_Set.Empty, calc = [], errpatts = [],
|
neuper@37954
|
680 |
rules =
|
walther@59871
|
681 |
[Rule.Thm("d3_reduce_equation1",ThmC.numerals_to_Free @{thm d3_reduce_equation1}),
|
walther@60242
|
682 |
(*a*bdv + b*bdv \<up> 2 + c*bdv \<up> 3=0) =
|
walther@60242
|
683 |
(bdv=0 | (a + b*bdv + c*bdv \<up> 2=0)*)
|
walther@59871
|
684 |
Rule.Thm("d3_reduce_equation2",ThmC.numerals_to_Free @{thm d3_reduce_equation2}),
|
walther@60242
|
685 |
(* bdv + b*bdv \<up> 2 + c*bdv \<up> 3=0) =
|
walther@60242
|
686 |
(bdv=0 | (1 + b*bdv + c*bdv \<up> 2=0)*)
|
walther@59871
|
687 |
Rule.Thm("d3_reduce_equation3",ThmC.numerals_to_Free @{thm d3_reduce_equation3}),
|
walther@60242
|
688 |
(*a*bdv + bdv \<up> 2 + c*bdv \<up> 3=0) =
|
walther@60242
|
689 |
(bdv=0 | (a + bdv + c*bdv \<up> 2=0)*)
|
walther@59871
|
690 |
Rule.Thm("d3_reduce_equation4",ThmC.numerals_to_Free @{thm d3_reduce_equation4}),
|
walther@60242
|
691 |
(* bdv + bdv \<up> 2 + c*bdv \<up> 3=0) =
|
walther@60242
|
692 |
(bdv=0 | (1 + bdv + c*bdv \<up> 2=0)*)
|
walther@59871
|
693 |
Rule.Thm("d3_reduce_equation5",ThmC.numerals_to_Free @{thm d3_reduce_equation5}),
|
walther@60242
|
694 |
(*a*bdv + b*bdv \<up> 2 + bdv \<up> 3=0) =
|
walther@60242
|
695 |
(bdv=0 | (a + b*bdv + bdv \<up> 2=0)*)
|
walther@59871
|
696 |
Rule.Thm("d3_reduce_equation6",ThmC.numerals_to_Free @{thm d3_reduce_equation6}),
|
walther@60242
|
697 |
(* bdv + b*bdv \<up> 2 + bdv \<up> 3=0) =
|
walther@60242
|
698 |
(bdv=0 | (1 + b*bdv + bdv \<up> 2=0)*)
|
walther@59871
|
699 |
Rule.Thm("d3_reduce_equation7",ThmC.numerals_to_Free @{thm d3_reduce_equation7}),
|
walther@60242
|
700 |
(*a*bdv + bdv \<up> 2 + bdv \<up> 3=0) =
|
walther@60242
|
701 |
(bdv=0 | (1 + bdv + bdv \<up> 2=0)*)
|
walther@59871
|
702 |
Rule.Thm("d3_reduce_equation8",ThmC.numerals_to_Free @{thm d3_reduce_equation8}),
|
walther@60242
|
703 |
(* bdv + bdv \<up> 2 + bdv \<up> 3=0) =
|
walther@60242
|
704 |
(bdv=0 | (1 + bdv + bdv \<up> 2=0)*)
|
walther@59871
|
705 |
Rule.Thm("d3_reduce_equation9",ThmC.numerals_to_Free @{thm d3_reduce_equation9}),
|
walther@60242
|
706 |
(*a*bdv + c*bdv \<up> 3=0) =
|
walther@60242
|
707 |
(bdv=0 | (a + c*bdv \<up> 2=0)*)
|
walther@59871
|
708 |
Rule.Thm("d3_reduce_equation10",ThmC.numerals_to_Free @{thm d3_reduce_equation10}),
|
walther@60242
|
709 |
(* bdv + c*bdv \<up> 3=0) =
|
walther@60242
|
710 |
(bdv=0 | (1 + c*bdv \<up> 2=0)*)
|
walther@59871
|
711 |
Rule.Thm("d3_reduce_equation11",ThmC.numerals_to_Free @{thm d3_reduce_equation11}),
|
walther@60242
|
712 |
(*a*bdv + bdv \<up> 3=0) =
|
walther@60242
|
713 |
(bdv=0 | (a + bdv \<up> 2=0)*)
|
walther@59871
|
714 |
Rule.Thm("d3_reduce_equation12",ThmC.numerals_to_Free @{thm d3_reduce_equation12}),
|
walther@60242
|
715 |
(* bdv + bdv \<up> 3=0) =
|
walther@60242
|
716 |
(bdv=0 | (1 + bdv \<up> 2=0)*)
|
walther@59871
|
717 |
Rule.Thm("d3_reduce_equation13",ThmC.numerals_to_Free @{thm d3_reduce_equation13}),
|
walther@60242
|
718 |
(* b*bdv \<up> 2 + c*bdv \<up> 3=0) =
|
walther@60242
|
719 |
(bdv=0 | ( b*bdv + c*bdv \<up> 2=0)*)
|
walther@59871
|
720 |
Rule.Thm("d3_reduce_equation14",ThmC.numerals_to_Free @{thm d3_reduce_equation14}),
|
walther@60242
|
721 |
(* bdv \<up> 2 + c*bdv \<up> 3=0) =
|
walther@60242
|
722 |
(bdv=0 | ( bdv + c*bdv \<up> 2=0)*)
|
walther@59871
|
723 |
Rule.Thm("d3_reduce_equation15",ThmC.numerals_to_Free @{thm d3_reduce_equation15}),
|
walther@60242
|
724 |
(* b*bdv \<up> 2 + bdv \<up> 3=0) =
|
walther@60242
|
725 |
(bdv=0 | ( b*bdv + bdv \<up> 2=0)*)
|
walther@59871
|
726 |
Rule.Thm("d3_reduce_equation16",ThmC.numerals_to_Free @{thm d3_reduce_equation16}),
|
walther@60242
|
727 |
(* bdv \<up> 2 + bdv \<up> 3=0) =
|
walther@60242
|
728 |
(bdv=0 | ( bdv + bdv \<up> 2=0)*)
|
walther@59871
|
729 |
Rule.Thm("d3_isolate_add1",ThmC.numerals_to_Free @{thm d3_isolate_add1}),
|
walther@60242
|
730 |
(*[|Not(bdv occurs_in a)|] ==> (a + b*bdv \<up> 3=0) =
|
walther@60242
|
731 |
(bdv=0 | (b*bdv \<up> 3=a)*)
|
walther@59871
|
732 |
Rule.Thm("d3_isolate_add2",ThmC.numerals_to_Free @{thm d3_isolate_add2}),
|
walther@60242
|
733 |
(*[|Not(bdv occurs_in a)|] ==> (a + bdv \<up> 3=0) =
|
walther@60242
|
734 |
(bdv=0 | ( bdv \<up> 3=a)*)
|
walther@59871
|
735 |
Rule.Thm("d3_isolate_div",ThmC.numerals_to_Free @{thm d3_isolate_div}),
|
walther@60242
|
736 |
(*[|Not(b=0)|] ==> (b*bdv \<up> 3=c) = (bdv \<up> 3=c/b*)
|
walther@59871
|
737 |
Rule.Thm("d3_root_equation2",ThmC.numerals_to_Free @{thm d3_root_equation2}),
|
walther@60242
|
738 |
(*(bdv \<up> 3=0) = (bdv=0) *)
|
walther@59871
|
739 |
Rule.Thm("d3_root_equation1",ThmC.numerals_to_Free @{thm d3_root_equation1})
|
walther@60242
|
740 |
(*bdv \<up> 3=c) = (bdv = nroot 3 c*)
|
neuper@37954
|
741 |
],
|
walther@59878
|
742 |
scr = Rule.Empty_Prog
|
wneuper@59406
|
743 |
});
|
wneuper@59472
|
744 |
\<close>
|
wneuper@59472
|
745 |
ML\<open>
|
neuper@37954
|
746 |
|
neuper@37954
|
747 |
(* -- d4 -- *)
|
neuper@37954
|
748 |
(*isolate the bound variable in an d4 equation; 'bdv' is a meta-constant*)
|
s1210629013@55444
|
749 |
val d4_polyeq_simplify = prep_rls'(
|
walther@59851
|
750 |
Rule_Def.Repeat {id = "d4_polyeq_simplify", preconds = [],
|
walther@59857
|
751 |
rew_ord = ("e_rew_ord",Rewrite_Ord.e_rew_ord), erls = PolyEq_erls,
|
walther@59851
|
752 |
srls = Rule_Set.Empty, calc = [], errpatts = [],
|
neuper@37954
|
753 |
rules =
|
walther@59871
|
754 |
[Rule.Thm("d4_sub_u1",ThmC.numerals_to_Free @{thm d4_sub_u1})
|
neuper@37954
|
755 |
(* ax^4+bx^2+c=0 -> x=+-sqrt(ax^2+bx^+c) *)
|
neuper@37954
|
756 |
],
|
walther@59878
|
757 |
scr = Rule.Empty_Prog
|
wneuper@59406
|
758 |
});
|
wneuper@59472
|
759 |
\<close>
|
wneuper@59472
|
760 |
setup \<open>KEStore_Elems.add_rlss
|
neuper@52125
|
761 |
[("d0_polyeq_simplify", (Context.theory_name @{theory}, d0_polyeq_simplify)),
|
neuper@52125
|
762 |
("d1_polyeq_simplify", (Context.theory_name @{theory}, d1_polyeq_simplify)),
|
neuper@52125
|
763 |
("d2_polyeq_simplify", (Context.theory_name @{theory}, d2_polyeq_simplify)),
|
neuper@52125
|
764 |
("d2_polyeq_bdv_only_simplify", (Context.theory_name @{theory}, d2_polyeq_bdv_only_simplify)),
|
neuper@52125
|
765 |
("d2_polyeq_sq_only_simplify", (Context.theory_name @{theory}, d2_polyeq_sq_only_simplify)),
|
neuper@52125
|
766 |
|
neuper@52125
|
767 |
("d2_polyeq_pqFormula_simplify",
|
neuper@52125
|
768 |
(Context.theory_name @{theory}, d2_polyeq_pqFormula_simplify)),
|
neuper@52125
|
769 |
("d2_polyeq_abcFormula_simplify",
|
neuper@52125
|
770 |
(Context.theory_name @{theory}, d2_polyeq_abcFormula_simplify)),
|
neuper@52125
|
771 |
("d3_polyeq_simplify", (Context.theory_name @{theory}, d3_polyeq_simplify)),
|
wneuper@59472
|
772 |
("d4_polyeq_simplify", (Context.theory_name @{theory}, d4_polyeq_simplify))]\<close>
|
walther@60258
|
773 |
|
wneuper@59472
|
774 |
setup \<open>KEStore_Elems.add_pbts
|
walther@59973
|
775 |
[(Problem.prep_input thy "pbl_equ_univ_poly" [] Problem.id_empty
|
walther@59997
|
776 |
(["polynomial", "univariate", "equation"],
|
walther@59997
|
777 |
[("#Given" ,["equality e_e", "solveFor v_v"]),
|
s1210629013@55339
|
778 |
("#Where" ,["~((e_e::bool) is_ratequation_in (v_v::real))",
|
s1210629013@55339
|
779 |
"~((lhs e_e) is_rootTerm_in (v_v::real))",
|
s1210629013@55339
|
780 |
"~((rhs e_e) is_rootTerm_in (v_v::real))"]),
|
s1210629013@55339
|
781 |
("#Find" ,["solutions v_v'i'"])],
|
s1210629013@55339
|
782 |
PolyEq_prls, SOME "solve (e_e::bool, v_v)", [])),
|
s1210629013@55339
|
783 |
(*--- d0 ---*)
|
walther@59973
|
784 |
(Problem.prep_input thy "pbl_equ_univ_poly_deg0" [] Problem.id_empty
|
walther@59997
|
785 |
(["degree_0", "polynomial", "univariate", "equation"],
|
walther@59997
|
786 |
[("#Given" ,["equality e_e", "solveFor v_v"]),
|
s1210629013@55339
|
787 |
("#Where" ,["matches (?a = 0) e_e",
|
s1210629013@55339
|
788 |
"(lhs e_e) is_poly_in v_v",
|
s1210629013@55339
|
789 |
"((lhs e_e) has_degree_in v_v ) = 0"]),
|
s1210629013@55339
|
790 |
("#Find" ,["solutions v_v'i'"])],
|
walther@59997
|
791 |
PolyEq_prls, SOME "solve (e_e::bool, v_v)", [["PolyEq", "solve_d0_polyeq_equation"]])),
|
s1210629013@55339
|
792 |
(*--- d1 ---*)
|
walther@59973
|
793 |
(Problem.prep_input thy "pbl_equ_univ_poly_deg1" [] Problem.id_empty
|
walther@59997
|
794 |
(["degree_1", "polynomial", "univariate", "equation"],
|
walther@59997
|
795 |
[("#Given" ,["equality e_e", "solveFor v_v"]),
|
s1210629013@55339
|
796 |
("#Where" ,["matches (?a = 0) e_e",
|
s1210629013@55339
|
797 |
"(lhs e_e) is_poly_in v_v",
|
s1210629013@55339
|
798 |
"((lhs e_e) has_degree_in v_v ) = 1"]),
|
s1210629013@55339
|
799 |
("#Find" ,["solutions v_v'i'"])],
|
walther@59997
|
800 |
PolyEq_prls, SOME "solve (e_e::bool, v_v)", [["PolyEq", "solve_d1_polyeq_equation"]])),
|
s1210629013@55339
|
801 |
(*--- d2 ---*)
|
walther@59973
|
802 |
(Problem.prep_input thy "pbl_equ_univ_poly_deg2" [] Problem.id_empty
|
walther@59997
|
803 |
(["degree_2", "polynomial", "univariate", "equation"],
|
walther@59997
|
804 |
[("#Given" ,["equality e_e", "solveFor v_v"]),
|
s1210629013@55339
|
805 |
("#Where" ,["matches (?a = 0) e_e",
|
s1210629013@55339
|
806 |
"(lhs e_e) is_poly_in v_v ",
|
s1210629013@55339
|
807 |
"((lhs e_e) has_degree_in v_v ) = 2"]),
|
s1210629013@55339
|
808 |
("#Find" ,["solutions v_v'i'"])],
|
walther@59997
|
809 |
PolyEq_prls, SOME "solve (e_e::bool, v_v)", [["PolyEq", "solve_d2_polyeq_equation"]])),
|
walther@59973
|
810 |
(Problem.prep_input thy "pbl_equ_univ_poly_deg2_sqonly" [] Problem.id_empty
|
walther@59997
|
811 |
(["sq_only", "degree_2", "polynomial", "univariate", "equation"],
|
walther@59997
|
812 |
[("#Given" ,["equality e_e", "solveFor v_v"]),
|
walther@60242
|
813 |
("#Where" ,["matches ( ?a + ?v_ \<up> 2 = 0) e_e | " ^
|
walther@60242
|
814 |
"matches ( ?a + ?b*?v_ \<up> 2 = 0) e_e | " ^
|
walther@60242
|
815 |
"matches ( ?v_ \<up> 2 = 0) e_e | " ^
|
walther@60242
|
816 |
"matches ( ?b*?v_ \<up> 2 = 0) e_e" ,
|
walther@60242
|
817 |
"Not (matches (?a + ?v_ + ?v_ \<up> 2 = 0) e_e) &" ^
|
walther@60242
|
818 |
"Not (matches (?a + ?b*?v_ + ?v_ \<up> 2 = 0) e_e) &" ^
|
walther@60242
|
819 |
"Not (matches (?a + ?v_ + ?c*?v_ \<up> 2 = 0) e_e) &" ^
|
walther@60242
|
820 |
"Not (matches (?a + ?b*?v_ + ?c*?v_ \<up> 2 = 0) e_e) &" ^
|
walther@60242
|
821 |
"Not (matches ( ?v_ + ?v_ \<up> 2 = 0) e_e) &" ^
|
walther@60242
|
822 |
"Not (matches ( ?b*?v_ + ?v_ \<up> 2 = 0) e_e) &" ^
|
walther@60242
|
823 |
"Not (matches ( ?v_ + ?c*?v_ \<up> 2 = 0) e_e) &" ^
|
walther@60242
|
824 |
"Not (matches ( ?b*?v_ + ?c*?v_ \<up> 2 = 0) e_e)"]),
|
s1210629013@55339
|
825 |
("#Find" ,["solutions v_v'i'"])],
|
s1210629013@55339
|
826 |
PolyEq_prls, SOME "solve (e_e::bool, v_v)",
|
walther@59997
|
827 |
[["PolyEq", "solve_d2_polyeq_sqonly_equation"]])),
|
walther@59973
|
828 |
(Problem.prep_input thy "pbl_equ_univ_poly_deg2_bdvonly" [] Problem.id_empty
|
walther@59997
|
829 |
(["bdv_only", "degree_2", "polynomial", "univariate", "equation"],
|
walther@59997
|
830 |
[("#Given", ["equality e_e", "solveFor v_v"]),
|
walther@60242
|
831 |
("#Where", ["matches (?a*?v_ + ?v_ \<up> 2 = 0) e_e | " ^
|
walther@60242
|
832 |
"matches ( ?v_ + ?v_ \<up> 2 = 0) e_e | " ^
|
walther@60242
|
833 |
"matches ( ?v_ + ?b*?v_ \<up> 2 = 0) e_e | " ^
|
walther@60242
|
834 |
"matches (?a*?v_ + ?b*?v_ \<up> 2 = 0) e_e | " ^
|
walther@60242
|
835 |
"matches ( ?v_ \<up> 2 = 0) e_e | " ^
|
walther@60242
|
836 |
"matches ( ?b*?v_ \<up> 2 = 0) e_e "]),
|
s1210629013@55339
|
837 |
("#Find", ["solutions v_v'i'"])],
|
s1210629013@55339
|
838 |
PolyEq_prls, SOME "solve (e_e::bool, v_v)",
|
walther@59997
|
839 |
[["PolyEq", "solve_d2_polyeq_bdvonly_equation"]])),
|
walther@59973
|
840 |
(Problem.prep_input thy "pbl_equ_univ_poly_deg2_pq" [] Problem.id_empty
|
walther@59997
|
841 |
(["pqFormula", "degree_2", "polynomial", "univariate", "equation"],
|
walther@59997
|
842 |
[("#Given", ["equality e_e", "solveFor v_v"]),
|
walther@60242
|
843 |
("#Where", ["matches (?a + 1*?v_ \<up> 2 = 0) e_e | " ^
|
walther@60242
|
844 |
"matches (?a + ?v_ \<up> 2 = 0) e_e"]),
|
s1210629013@55339
|
845 |
("#Find", ["solutions v_v'i'"])],
|
walther@59997
|
846 |
PolyEq_prls, SOME "solve (e_e::bool, v_v)", [["PolyEq", "solve_d2_polyeq_pq_equation"]])),
|
walther@59973
|
847 |
(Problem.prep_input thy "pbl_equ_univ_poly_deg2_abc" [] Problem.id_empty
|
walther@59997
|
848 |
(["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
|
walther@59997
|
849 |
[("#Given", ["equality e_e", "solveFor v_v"]),
|
walther@60242
|
850 |
("#Where", ["matches (?a + ?v_ \<up> 2 = 0) e_e | " ^
|
walther@60242
|
851 |
"matches (?a + ?b*?v_ \<up> 2 = 0) e_e"]),
|
s1210629013@55339
|
852 |
("#Find", ["solutions v_v'i'"])],
|
walther@59997
|
853 |
PolyEq_prls, SOME "solve (e_e::bool, v_v)", [["PolyEq", "solve_d2_polyeq_abc_equation"]])),
|
s1210629013@55339
|
854 |
(*--- d3 ---*)
|
walther@59973
|
855 |
(Problem.prep_input thy "pbl_equ_univ_poly_deg3" [] Problem.id_empty
|
walther@59997
|
856 |
(["degree_3", "polynomial", "univariate", "equation"],
|
walther@59997
|
857 |
[("#Given", ["equality e_e", "solveFor v_v"]),
|
s1210629013@55339
|
858 |
("#Where", ["matches (?a = 0) e_e",
|
s1210629013@55339
|
859 |
"(lhs e_e) is_poly_in v_v ",
|
s1210629013@55339
|
860 |
"((lhs e_e) has_degree_in v_v) = 3"]),
|
s1210629013@55339
|
861 |
("#Find", ["solutions v_v'i'"])],
|
walther@59997
|
862 |
PolyEq_prls, SOME "solve (e_e::bool, v_v)", [["PolyEq", "solve_d3_polyeq_equation"]])),
|
s1210629013@55339
|
863 |
(*--- d4 ---*)
|
walther@59973
|
864 |
(Problem.prep_input thy "pbl_equ_univ_poly_deg4" [] Problem.id_empty
|
walther@59997
|
865 |
(["degree_4", "polynomial", "univariate", "equation"],
|
walther@59997
|
866 |
[("#Given", ["equality e_e", "solveFor v_v"]),
|
s1210629013@55339
|
867 |
("#Where", ["matches (?a = 0) e_e",
|
s1210629013@55339
|
868 |
"(lhs e_e) is_poly_in v_v ",
|
s1210629013@55339
|
869 |
"((lhs e_e) has_degree_in v_v) = 4"]),
|
s1210629013@55339
|
870 |
("#Find", ["solutions v_v'i'"])],
|
walther@59997
|
871 |
PolyEq_prls, SOME "solve (e_e::bool, v_v)", [(*["PolyEq", "solve_d4_polyeq_equation"]*)])),
|
wneuper@59370
|
872 |
(*--- normalise ---*)
|
walther@59973
|
873 |
(Problem.prep_input thy "pbl_equ_univ_poly_norm" [] Problem.id_empty
|
walther@59997
|
874 |
(["normalise", "polynomial", "univariate", "equation"],
|
walther@59997
|
875 |
[("#Given", ["equality e_e", "solveFor v_v"]),
|
s1210629013@55339
|
876 |
("#Where", ["(Not((matches (?a = 0 ) e_e ))) |" ^
|
s1210629013@55339
|
877 |
"(Not(((lhs e_e) is_poly_in v_v)))"]),
|
s1210629013@55339
|
878 |
("#Find", ["solutions v_v'i'"])],
|
walther@59842
|
879 |
PolyEq_prls, SOME "solve (e_e::bool, v_v)", [["PolyEq", "normalise_poly"]])),
|
s1210629013@55339
|
880 |
(*-------------------------expanded-----------------------*)
|
walther@59973
|
881 |
(Problem.prep_input thy "pbl_equ_univ_expand" [] Problem.id_empty
|
walther@59997
|
882 |
(["expanded", "univariate", "equation"],
|
walther@59997
|
883 |
[("#Given", ["equality e_e", "solveFor v_v"]),
|
s1210629013@55339
|
884 |
("#Where", ["matches (?a = 0) e_e",
|
s1210629013@55339
|
885 |
"(lhs e_e) is_expanded_in v_v "]),
|
s1210629013@55339
|
886 |
("#Find", ["solutions v_v'i'"])],
|
s1210629013@55339
|
887 |
PolyEq_prls, SOME "solve (e_e::bool, v_v)", [])),
|
s1210629013@55339
|
888 |
(*--- d2 ---*)
|
walther@59973
|
889 |
(Problem.prep_input thy "pbl_equ_univ_expand_deg2" [] Problem.id_empty
|
walther@59997
|
890 |
(["degree_2", "expanded", "univariate", "equation"],
|
walther@59997
|
891 |
[("#Given", ["equality e_e", "solveFor v_v"]),
|
s1210629013@55339
|
892 |
("#Where", ["((lhs e_e) has_degree_in v_v) = 2"]),
|
s1210629013@55339
|
893 |
("#Find", ["solutions v_v'i'"])],
|
walther@59997
|
894 |
PolyEq_prls, SOME "solve (e_e::bool, v_v)", [["PolyEq", "complete_square"]]))]\<close>
|
neuper@37954
|
895 |
|
wneuper@59472
|
896 |
text \<open>"-------------------------methods-----------------------"\<close>
|
wneuper@59472
|
897 |
setup \<open>KEStore_Elems.add_mets
|
walther@60154
|
898 |
[MethodC.prep_input thy "met_polyeq" [] MethodC.id_empty
|
s1210629013@55373
|
899 |
(["PolyEq"], [],
|
walther@59852
|
900 |
{rew_ord'="tless_true",rls'=Atools_erls,calc = [], srls = Rule_Set.empty, prls=Rule_Set.empty,
|
s1210629013@55373
|
901 |
crls=PolyEq_crls, errpats = [], nrls = norm_Rational},
|
wneuper@59545
|
902 |
@{thm refl})]
|
wneuper@59473
|
903 |
\<close>
|
wneuper@59545
|
904 |
|
wneuper@59504
|
905 |
partial_function (tailrec) normalize_poly_eq :: "bool \<Rightarrow> real \<Rightarrow> bool"
|
wneuper@59504
|
906 |
where
|
walther@59635
|
907 |
"normalize_poly_eq e_e v_v = (
|
walther@59635
|
908 |
let
|
walther@59635
|
909 |
e_e = (
|
walther@59637
|
910 |
(Try (Rewrite ''all_left'')) #>
|
walther@59637
|
911 |
(Try (Repeat (Rewrite ''makex1_x''))) #>
|
walther@59637
|
912 |
(Try (Repeat (Rewrite_Set ''expand_binoms''))) #>
|
walther@59637
|
913 |
(Try (Repeat (Rewrite_Set_Inst [(''bdv'', v_v)] ''make_ratpoly_in''))) #>
|
walther@59635
|
914 |
(Try (Repeat (Rewrite_Set ''polyeq_simplify''))) ) e_e
|
walther@59635
|
915 |
in
|
walther@59635
|
916 |
SubProblem (''PolyEq'', [''polynomial'', ''univariate'', ''equation''], [''no_met''])
|
wneuper@59504
|
917 |
[BOOL e_e, REAL v_v])"
|
wneuper@59473
|
918 |
setup \<open>KEStore_Elems.add_mets
|
walther@60154
|
919 |
[MethodC.prep_input thy "met_polyeq_norm" [] MethodC.id_empty
|
walther@59842
|
920 |
(["PolyEq", "normalise_poly"],
|
walther@59997
|
921 |
[("#Given" ,["equality e_e", "solveFor v_v"]),
|
walther@59842
|
922 |
("#Where" ,["(Not((matches (?a = 0 ) e_e ))) | (Not(((lhs e_e) is_poly_in v_v)))"]),
|
s1210629013@55373
|
923 |
("#Find" ,["solutions v_v'i'"])],
|
walther@59852
|
924 |
{rew_ord'="termlessI", rls'=PolyEq_erls, srls=Rule_Set.empty, prls=PolyEq_prls, calc=[],
|
s1210629013@55373
|
925 |
crls=PolyEq_crls, errpats = [], nrls = norm_Rational},
|
wneuper@59551
|
926 |
@{thm normalize_poly_eq.simps})]
|
wneuper@59473
|
927 |
\<close>
|
wneuper@59545
|
928 |
|
wneuper@59504
|
929 |
partial_function (tailrec) solve_poly_equ :: "bool \<Rightarrow> real \<Rightarrow> bool list"
|
wneuper@59504
|
930 |
where
|
walther@59635
|
931 |
"solve_poly_equ e_e v_v = (
|
walther@59635
|
932 |
let
|
walther@59635
|
933 |
e_e = (Try (Rewrite_Set_Inst [(''bdv'', v_v)] ''d0_polyeq_simplify'')) e_e
|
walther@59635
|
934 |
in
|
walther@59635
|
935 |
Or_to_List e_e)"
|
wneuper@59473
|
936 |
setup \<open>KEStore_Elems.add_mets
|
walther@60154
|
937 |
[MethodC.prep_input thy "met_polyeq_d0" [] MethodC.id_empty
|
walther@59997
|
938 |
(["PolyEq", "solve_d0_polyeq_equation"],
|
walther@59997
|
939 |
[("#Given" ,["equality e_e", "solveFor v_v"]),
|
s1210629013@55373
|
940 |
("#Where" ,["(lhs e_e) is_poly_in v_v ", "((lhs e_e) has_degree_in v_v) = 0"]),
|
s1210629013@55373
|
941 |
("#Find" ,["solutions v_v'i'"])],
|
walther@59852
|
942 |
{rew_ord'="termlessI", rls'=PolyEq_erls, srls=Rule_Set.empty, prls=PolyEq_prls,
|
s1210629013@55373
|
943 |
calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))], crls=PolyEq_crls, errpats = [],
|
s1210629013@55373
|
944 |
nrls = norm_Rational},
|
wneuper@59551
|
945 |
@{thm solve_poly_equ.simps})]
|
wneuper@59473
|
946 |
\<close>
|
wneuper@59545
|
947 |
|
wneuper@59504
|
948 |
partial_function (tailrec) solve_poly_eq1 :: "bool \<Rightarrow> real \<Rightarrow> bool list"
|
walther@59635
|
949 |
where
|
walther@59635
|
950 |
"solve_poly_eq1 e_e v_v = (
|
walther@59635
|
951 |
let
|
walther@59635
|
952 |
e_e = (
|
walther@59637
|
953 |
(Try (Rewrite_Set_Inst [(''bdv'', v_v)] ''d1_polyeq_simplify'')) #>
|
walther@59637
|
954 |
(Try (Rewrite_Set ''polyeq_simplify'')) #>
|
walther@59635
|
955 |
(Try (Rewrite_Set ''norm_Rational_parenthesized'')) ) e_e;
|
walther@59635
|
956 |
L_L = Or_to_List e_e
|
walther@59635
|
957 |
in
|
walther@59635
|
958 |
Check_elementwise L_L {(v_v::real). Assumptions})"
|
wneuper@59473
|
959 |
setup \<open>KEStore_Elems.add_mets
|
walther@60154
|
960 |
[MethodC.prep_input thy "met_polyeq_d1" [] MethodC.id_empty
|
walther@59997
|
961 |
(["PolyEq", "solve_d1_polyeq_equation"],
|
walther@59997
|
962 |
[("#Given" ,["equality e_e", "solveFor v_v"]),
|
s1210629013@55373
|
963 |
("#Where" ,["(lhs e_e) is_poly_in v_v ", "((lhs e_e) has_degree_in v_v) = 1"]),
|
s1210629013@55373
|
964 |
("#Find" ,["solutions v_v'i'"])],
|
walther@59852
|
965 |
{rew_ord'="termlessI", rls'=PolyEq_erls, srls=Rule_Set.empty, prls=PolyEq_prls,
|
s1210629013@55373
|
966 |
calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))], crls=PolyEq_crls, errpats = [],
|
s1210629013@55373
|
967 |
nrls = norm_Rational},
|
wneuper@59551
|
968 |
@{thm solve_poly_eq1.simps})]
|
wneuper@59473
|
969 |
\<close>
|
wneuper@59545
|
970 |
|
wneuper@59504
|
971 |
partial_function (tailrec) solve_poly_equ2 :: "bool \<Rightarrow> real \<Rightarrow> bool list"
|
wneuper@59504
|
972 |
where
|
walther@59635
|
973 |
"solve_poly_equ2 e_e v_v = (
|
walther@59635
|
974 |
let
|
walther@59635
|
975 |
e_e = (
|
walther@59637
|
976 |
(Try (Rewrite_Set_Inst [(''bdv'', v_v)] ''d2_polyeq_simplify'')) #>
|
walther@59637
|
977 |
(Try (Rewrite_Set ''polyeq_simplify'')) #>
|
walther@59637
|
978 |
(Try (Rewrite_Set_Inst [(''bdv'', v_v)] ''d1_polyeq_simplify'')) #>
|
walther@59637
|
979 |
(Try (Rewrite_Set ''polyeq_simplify'')) #>
|
walther@59635
|
980 |
(Try (Rewrite_Set ''norm_Rational_parenthesized'')) ) e_e;
|
walther@59635
|
981 |
L_L = Or_to_List e_e
|
walther@59635
|
982 |
in
|
walther@59635
|
983 |
Check_elementwise L_L {(v_v::real). Assumptions})"
|
wneuper@59473
|
984 |
setup \<open>KEStore_Elems.add_mets
|
walther@60154
|
985 |
[MethodC.prep_input thy "met_polyeq_d22" [] MethodC.id_empty
|
walther@59997
|
986 |
(["PolyEq", "solve_d2_polyeq_equation"],
|
walther@59997
|
987 |
[("#Given" ,["equality e_e", "solveFor v_v"]),
|
s1210629013@55373
|
988 |
("#Where" ,["(lhs e_e) is_poly_in v_v ", "((lhs e_e) has_degree_in v_v) = 2"]),
|
s1210629013@55373
|
989 |
("#Find" ,["solutions v_v'i'"])],
|
walther@59852
|
990 |
{rew_ord'="termlessI", rls'=PolyEq_erls, srls=Rule_Set.empty, prls=PolyEq_prls,
|
s1210629013@55373
|
991 |
calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))], crls=PolyEq_crls, errpats = [],
|
s1210629013@55373
|
992 |
nrls = norm_Rational},
|
wneuper@59551
|
993 |
@{thm solve_poly_equ2.simps})]
|
wneuper@59473
|
994 |
\<close>
|
wneuper@59545
|
995 |
|
wneuper@59504
|
996 |
partial_function (tailrec) solve_poly_equ0 :: "bool \<Rightarrow> real \<Rightarrow> bool list"
|
walther@59635
|
997 |
where
|
walther@59635
|
998 |
"solve_poly_equ0 e_e v_v = (
|
walther@59635
|
999 |
let
|
walther@59635
|
1000 |
e_e = (
|
walther@59637
|
1001 |
(Try (Rewrite_Set_Inst [(''bdv'', v_v)] ''d2_polyeq_bdv_only_simplify'')) #>
|
walther@59637
|
1002 |
(Try (Rewrite_Set ''polyeq_simplify'')) #>
|
walther@59637
|
1003 |
(Try (Rewrite_Set_Inst [(''bdv'',v_v::real)] ''d1_polyeq_simplify'')) #>
|
walther@59637
|
1004 |
(Try (Rewrite_Set ''polyeq_simplify'')) #>
|
walther@59635
|
1005 |
(Try (Rewrite_Set ''norm_Rational_parenthesized'')) ) e_e;
|
wneuper@59504
|
1006 |
L_L = Or_to_List e_e
|
walther@59635
|
1007 |
in
|
walther@59635
|
1008 |
Check_elementwise L_L {(v_v::real). Assumptions})"
|
wneuper@59473
|
1009 |
setup \<open>KEStore_Elems.add_mets
|
walther@60154
|
1010 |
[MethodC.prep_input thy "met_polyeq_d2_bdvonly" [] MethodC.id_empty
|
walther@59997
|
1011 |
(["PolyEq", "solve_d2_polyeq_bdvonly_equation"],
|
walther@59997
|
1012 |
[("#Given" ,["equality e_e", "solveFor v_v"]),
|
s1210629013@55373
|
1013 |
("#Where" ,["(lhs e_e) is_poly_in v_v ", "((lhs e_e) has_degree_in v_v) = 2"]),
|
s1210629013@55373
|
1014 |
("#Find" ,["solutions v_v'i'"])],
|
walther@59852
|
1015 |
{rew_ord'="termlessI", rls'=PolyEq_erls, srls=Rule_Set.empty, prls=PolyEq_prls,
|
s1210629013@55373
|
1016 |
calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))], crls=PolyEq_crls, errpats = [],
|
s1210629013@55373
|
1017 |
nrls = norm_Rational},
|
wneuper@59551
|
1018 |
@{thm solve_poly_equ0.simps})]
|
wneuper@59473
|
1019 |
\<close>
|
wneuper@59545
|
1020 |
|
wneuper@59504
|
1021 |
partial_function (tailrec) solve_poly_equ_sqrt :: "bool \<Rightarrow> real \<Rightarrow> bool list"
|
wneuper@59504
|
1022 |
where
|
walther@59635
|
1023 |
"solve_poly_equ_sqrt e_e v_v = (
|
walther@59635
|
1024 |
let
|
walther@59635
|
1025 |
e_e = (
|
walther@59637
|
1026 |
(Try (Rewrite_Set_Inst [(''bdv'', v_v)] ''d2_polyeq_sq_only_simplify'')) #>
|
walther@59637
|
1027 |
(Try (Rewrite_Set ''polyeq_simplify'')) #>
|
walther@59635
|
1028 |
(Try (Rewrite_Set ''norm_Rational_parenthesized'')) ) e_e;
|
wneuper@59504
|
1029 |
L_L = Or_to_List e_e
|
walther@59635
|
1030 |
in
|
walther@59635
|
1031 |
Check_elementwise L_L {(v_v::real). Assumptions})"
|
wneuper@59473
|
1032 |
setup \<open>KEStore_Elems.add_mets
|
walther@60154
|
1033 |
[MethodC.prep_input thy "met_polyeq_d2_sqonly" [] MethodC.id_empty
|
walther@59997
|
1034 |
(["PolyEq", "solve_d2_polyeq_sqonly_equation"],
|
walther@59997
|
1035 |
[("#Given" ,["equality e_e", "solveFor v_v"]),
|
s1210629013@55373
|
1036 |
("#Where" ,["(lhs e_e) is_poly_in v_v ", "((lhs e_e) has_degree_in v_v) = 2"]),
|
s1210629013@55373
|
1037 |
("#Find" ,["solutions v_v'i'"])],
|
walther@59852
|
1038 |
{rew_ord'="termlessI", rls'=PolyEq_erls, srls=Rule_Set.empty, prls=PolyEq_prls,
|
s1210629013@55373
|
1039 |
calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))], crls=PolyEq_crls, errpats = [],
|
s1210629013@55373
|
1040 |
nrls = norm_Rational},
|
wneuper@59551
|
1041 |
@{thm solve_poly_equ_sqrt.simps})]
|
wneuper@59473
|
1042 |
\<close>
|
wneuper@59545
|
1043 |
|
wneuper@59504
|
1044 |
partial_function (tailrec) solve_poly_equ_pq :: "bool \<Rightarrow> real \<Rightarrow> bool list"
|
walther@59635
|
1045 |
where
|
walther@59635
|
1046 |
"solve_poly_equ_pq e_e v_v = (
|
walther@59635
|
1047 |
let
|
walther@59635
|
1048 |
e_e = (
|
walther@59637
|
1049 |
(Try (Rewrite_Set_Inst [(''bdv'', v_v)] ''d2_polyeq_pqFormula_simplify'')) #>
|
walther@59637
|
1050 |
(Try (Rewrite_Set ''polyeq_simplify'')) #>
|
walther@59635
|
1051 |
(Try (Rewrite_Set ''norm_Rational_parenthesized'')) ) e_e;
|
walther@59635
|
1052 |
L_L = Or_to_List e_e
|
walther@59635
|
1053 |
in
|
walther@59635
|
1054 |
Check_elementwise L_L {(v_v::real). Assumptions})"
|
wneuper@59473
|
1055 |
setup \<open>KEStore_Elems.add_mets
|
walther@60154
|
1056 |
[MethodC.prep_input thy "met_polyeq_d2_pq" [] MethodC.id_empty
|
walther@59997
|
1057 |
(["PolyEq", "solve_d2_polyeq_pq_equation"],
|
walther@59997
|
1058 |
[("#Given" ,["equality e_e", "solveFor v_v"]),
|
s1210629013@55373
|
1059 |
("#Where" ,["(lhs e_e) is_poly_in v_v ", "((lhs e_e) has_degree_in v_v) = 2"]),
|
s1210629013@55373
|
1060 |
("#Find" ,["solutions v_v'i'"])],
|
walther@59852
|
1061 |
{rew_ord'="termlessI", rls'=PolyEq_erls, srls=Rule_Set.empty, prls=PolyEq_prls,
|
s1210629013@55373
|
1062 |
calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))], crls=PolyEq_crls, errpats = [],
|
s1210629013@55373
|
1063 |
nrls = norm_Rational},
|
wneuper@59551
|
1064 |
@{thm solve_poly_equ_pq.simps})]
|
wneuper@59473
|
1065 |
\<close>
|
wneuper@59545
|
1066 |
|
wneuper@59504
|
1067 |
partial_function (tailrec) solve_poly_equ_abc :: "bool \<Rightarrow> real \<Rightarrow> bool list"
|
wneuper@59504
|
1068 |
where
|
walther@59635
|
1069 |
"solve_poly_equ_abc e_e v_v = (
|
walther@59635
|
1070 |
let
|
walther@59635
|
1071 |
e_e = (
|
walther@59637
|
1072 |
(Try (Rewrite_Set_Inst [(''bdv'', v_v)] ''d2_polyeq_abcFormula_simplify'')) #>
|
walther@59637
|
1073 |
(Try (Rewrite_Set ''polyeq_simplify'')) #>
|
walther@59635
|
1074 |
(Try (Rewrite_Set ''norm_Rational_parenthesized'')) ) e_e;
|
walther@59635
|
1075 |
L_L = Or_to_List e_e
|
wneuper@59504
|
1076 |
in Check_elementwise L_L {(v_v::real). Assumptions})"
|
wneuper@59473
|
1077 |
setup \<open>KEStore_Elems.add_mets
|
walther@60154
|
1078 |
[MethodC.prep_input thy "met_polyeq_d2_abc" [] MethodC.id_empty
|
walther@59997
|
1079 |
(["PolyEq", "solve_d2_polyeq_abc_equation"],
|
walther@59997
|
1080 |
[("#Given" ,["equality e_e", "solveFor v_v"]),
|
s1210629013@55373
|
1081 |
("#Where" ,["(lhs e_e) is_poly_in v_v ", "((lhs e_e) has_degree_in v_v) = 2"]),
|
s1210629013@55373
|
1082 |
("#Find" ,["solutions v_v'i'"])],
|
walther@59852
|
1083 |
{rew_ord'="termlessI", rls'=PolyEq_erls,srls=Rule_Set.empty, prls=PolyEq_prls,
|
s1210629013@55373
|
1084 |
calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))], crls=PolyEq_crls, errpats = [],
|
s1210629013@55373
|
1085 |
nrls = norm_Rational},
|
wneuper@59551
|
1086 |
@{thm solve_poly_equ_abc.simps})]
|
wneuper@59473
|
1087 |
\<close>
|
wneuper@59545
|
1088 |
|
wneuper@59504
|
1089 |
partial_function (tailrec) solve_poly_equ3 :: "bool \<Rightarrow> real \<Rightarrow> bool list"
|
walther@59635
|
1090 |
where
|
walther@59635
|
1091 |
"solve_poly_equ3 e_e v_v = (
|
walther@59635
|
1092 |
let
|
walther@59635
|
1093 |
e_e = (
|
walther@59637
|
1094 |
(Try (Rewrite_Set_Inst [(''bdv'', v_v)] ''d3_polyeq_simplify'')) #>
|
walther@59637
|
1095 |
(Try (Rewrite_Set ''polyeq_simplify'')) #>
|
walther@59637
|
1096 |
(Try (Rewrite_Set_Inst [(''bdv'', v_v)] ''d2_polyeq_simplify'')) #>
|
walther@59637
|
1097 |
(Try (Rewrite_Set ''polyeq_simplify'')) #>
|
walther@59637
|
1098 |
(Try (Rewrite_Set_Inst [(''bdv'',v_v)] ''d1_polyeq_simplify'')) #>
|
walther@59637
|
1099 |
(Try (Rewrite_Set ''polyeq_simplify'')) #>
|
walther@59635
|
1100 |
(Try (Rewrite_Set ''norm_Rational_parenthesized''))) e_e;
|
walther@59635
|
1101 |
L_L = Or_to_List e_e
|
walther@59635
|
1102 |
in
|
walther@59635
|
1103 |
Check_elementwise L_L {(v_v::real). Assumptions})"
|
wneuper@59473
|
1104 |
setup \<open>KEStore_Elems.add_mets
|
walther@60154
|
1105 |
[MethodC.prep_input thy "met_polyeq_d3" [] MethodC.id_empty
|
walther@59997
|
1106 |
(["PolyEq", "solve_d3_polyeq_equation"],
|
walther@59997
|
1107 |
[("#Given" ,["equality e_e", "solveFor v_v"]),
|
s1210629013@55373
|
1108 |
("#Where" ,["(lhs e_e) is_poly_in v_v ", "((lhs e_e) has_degree_in v_v) = 3"]),
|
s1210629013@55373
|
1109 |
("#Find" ,["solutions v_v'i'"])],
|
walther@59852
|
1110 |
{rew_ord'="termlessI", rls'=PolyEq_erls, srls=Rule_Set.empty, prls=PolyEq_prls,
|
s1210629013@55373
|
1111 |
calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))], crls=PolyEq_crls, errpats = [],
|
s1210629013@55373
|
1112 |
nrls = norm_Rational},
|
wneuper@59551
|
1113 |
@{thm solve_poly_equ3.simps})]
|
wneuper@59473
|
1114 |
\<close>
|
wneuper@59370
|
1115 |
(*.solves all expanded (ie. normalised) terms of degree 2.*)
|
s1210629013@55373
|
1116 |
(*Oct.02 restriction: 'eval_true 0 =< discriminant' ony for integer values
|
s1210629013@55373
|
1117 |
by 'PolyEq_erls'; restricted until Float.thy is implemented*)
|
wneuper@59504
|
1118 |
partial_function (tailrec) solve_by_completing_square :: "bool \<Rightarrow> real \<Rightarrow> bool list"
|
wneuper@59504
|
1119 |
where
|
walther@59635
|
1120 |
"solve_by_completing_square e_e v_v = (
|
walther@59635
|
1121 |
let e_e = (
|
walther@59637
|
1122 |
(Try (Rewrite_Set_Inst [(''bdv'', v_v)] ''cancel_leading_coeff'')) #>
|
walther@59637
|
1123 |
(Try (Rewrite_Set_Inst [(''bdv'', v_v)] ''complete_square'')) #>
|
walther@59637
|
1124 |
(Try (Rewrite ''square_explicit1'')) #>
|
walther@59637
|
1125 |
(Try (Rewrite ''square_explicit2'')) #>
|
walther@59637
|
1126 |
(Rewrite ''root_plus_minus'') #>
|
walther@59637
|
1127 |
(Try (Repeat (Rewrite_Inst [(''bdv'', v_v)] ''bdv_explicit1''))) #>
|
walther@59637
|
1128 |
(Try (Repeat (Rewrite_Inst [(''bdv'', v_v)] ''bdv_explicit2''))) #>
|
walther@59637
|
1129 |
(Try (Repeat (Rewrite_Inst [(''bdv'', v_v)] ''bdv_explicit3''))) #>
|
walther@59637
|
1130 |
(Try (Rewrite_Set ''calculate_RootRat'')) #>
|
walther@59635
|
1131 |
(Try (Repeat (Calculate ''SQRT'')))) e_e
|
walther@59635
|
1132 |
in
|
walther@59635
|
1133 |
Or_to_List e_e)"
|
wneuper@59473
|
1134 |
setup \<open>KEStore_Elems.add_mets
|
walther@60154
|
1135 |
[MethodC.prep_input thy "met_polyeq_complsq" [] MethodC.id_empty
|
walther@59997
|
1136 |
(["PolyEq", "complete_square"],
|
walther@59997
|
1137 |
[("#Given" ,["equality e_e", "solveFor v_v"]),
|
s1210629013@55373
|
1138 |
("#Where" ,["matches (?a = 0) e_e", "((lhs e_e) has_degree_in v_v) = 2"]),
|
s1210629013@55373
|
1139 |
("#Find" ,["solutions v_v'i'"])],
|
walther@59852
|
1140 |
{rew_ord'="termlessI",rls'=PolyEq_erls,srls=Rule_Set.empty,prls=PolyEq_prls,
|
s1210629013@55373
|
1141 |
calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))], crls=PolyEq_crls, errpats = [],
|
s1210629013@55373
|
1142 |
nrls = norm_Rational},
|
wneuper@59551
|
1143 |
@{thm solve_by_completing_square.simps})]
|
wneuper@59472
|
1144 |
\<close>
|
s1210629013@55373
|
1145 |
|
wneuper@59472
|
1146 |
ML\<open>
|
neuper@37954
|
1147 |
|
neuper@37954
|
1148 |
(* termorder hacked by MG *)
|
neuper@37954
|
1149 |
local (*. for make_polynomial_in .*)
|
neuper@37954
|
1150 |
|
neuper@37954
|
1151 |
open Term; (* for type order = EQUAL | LESS | GREATER *)
|
neuper@37954
|
1152 |
|
neuper@37954
|
1153 |
fun pr_ord EQUAL = "EQUAL"
|
neuper@37954
|
1154 |
| pr_ord LESS = "LESS"
|
neuper@37954
|
1155 |
| pr_ord GREATER = "GREATER";
|
neuper@37954
|
1156 |
|
walther@60263
|
1157 |
fun dest_hd' _ (Const (a, T)) = (((a, 0), T), 0)
|
neuper@37954
|
1158 |
| dest_hd' x (t as Free (a, T)) =
|
neuper@37954
|
1159 |
if x = t then ((("|||||||||||||", 0), T), 0) (*WN*)
|
neuper@37954
|
1160 |
else (((a, 0), T), 1)
|
walther@60263
|
1161 |
| dest_hd' _ (Var v) = (v, 2)
|
walther@60263
|
1162 |
| dest_hd' _ (Bound i) = ((("", i), dummyT), 3)
|
walther@60263
|
1163 |
| dest_hd' _ (Abs (_, T, _)) = ((("", 0), T), 4)
|
walther@60263
|
1164 |
| dest_hd' _ _ = raise ERROR "dest_hd': uncovered case in fun.def.";
|
neuper@37954
|
1165 |
|
walther@59603
|
1166 |
fun size_of_term' x (Const ("Prog_Expr.pow",_) $ Free (var,_) $ Free (pot,_)) =
|
neuper@37954
|
1167 |
(case x of (*WN*)
|
neuper@37954
|
1168 |
(Free (xstr,_)) =>
|
walther@59875
|
1169 |
(if xstr = var then 1000*(the (TermC.int_opt_of_string pot)) else 3)
|
walther@59962
|
1170 |
| _ => raise ERROR ("size_of_term' called with subst = "^
|
walther@59868
|
1171 |
(UnparseC.term x)))
|
neuper@37954
|
1172 |
| size_of_term' x (Free (subst,_)) =
|
neuper@37954
|
1173 |
(case x of
|
neuper@37954
|
1174 |
(Free (xstr,_)) => (if xstr = subst then 1000 else 1)
|
walther@59962
|
1175 |
| _ => raise ERROR ("size_of_term' called with subst = "^
|
walther@59868
|
1176 |
(UnparseC.term x)))
|
neuper@37954
|
1177 |
| size_of_term' x (Abs (_,_,body)) = 1 + size_of_term' x body
|
neuper@37954
|
1178 |
| size_of_term' x (f$t) = size_of_term' x f + size_of_term' x t
|
walther@60263
|
1179 |
| size_of_term' _ _ = 1;
|
neuper@37954
|
1180 |
|
neuper@37989
|
1181 |
fun term_ord' x pr thy (Abs (_, T, t), Abs(_, U, u)) = (* ~ term.ML *)
|
neuper@52070
|
1182 |
(case term_ord' x pr thy (t, u) of EQUAL => Term_Ord.typ_ord (T, U) | ord => ord)
|
neuper@37989
|
1183 |
| term_ord' x pr thy (t, u) =
|
neuper@52070
|
1184 |
(if pr
|
neuper@52070
|
1185 |
then
|
neuper@52070
|
1186 |
let
|
neuper@52070
|
1187 |
val (f, ts) = strip_comb t and (g, us) = strip_comb u;
|
walther@59870
|
1188 |
val _ = tracing ("t= f@ts= \"" ^ UnparseC.term_in_thy thy f ^ "\" @ \"[" ^
|
walther@59870
|
1189 |
commas (map (UnparseC.term_in_thy thy) ts) ^ "]\"");
|
walther@59870
|
1190 |
val _ = tracing ("u= g@us= \"" ^ UnparseC.term_in_thy thy g ^ "\" @ \"[" ^
|
walther@59870
|
1191 |
commas(map (UnparseC.term_in_thy thy) us) ^ "]\"");
|
neuper@52070
|
1192 |
val _ = tracing ("size_of_term(t,u)= (" ^ string_of_int (size_of_term' x t) ^ ", " ^
|
neuper@52070
|
1193 |
string_of_int (size_of_term' x u) ^ ")");
|
neuper@52070
|
1194 |
val _ = tracing ("hd_ord(f,g) = " ^ (pr_ord o (hd_ord x)) (f,g));
|
neuper@52070
|
1195 |
val _ = tracing ("terms_ord(ts,us) = " ^ (pr_ord o (terms_ord x) str false) (ts, us));
|
neuper@52070
|
1196 |
val _ = tracing ("-------");
|
neuper@52070
|
1197 |
in () end
|
neuper@52070
|
1198 |
else ();
|
neuper@52070
|
1199 |
case int_ord (size_of_term' x t, size_of_term' x u) of
|
neuper@52070
|
1200 |
EQUAL =>
|
neuper@52070
|
1201 |
let val (f, ts) = strip_comb t and (g, us) = strip_comb u
|
neuper@52070
|
1202 |
in
|
neuper@52070
|
1203 |
(case hd_ord x (f, g) of
|
neuper@52070
|
1204 |
EQUAL => (terms_ord x str pr) (ts, us)
|
neuper@52070
|
1205 |
| ord => ord)
|
neuper@52070
|
1206 |
end
|
neuper@37954
|
1207 |
| ord => ord)
|
neuper@37954
|
1208 |
and hd_ord x (f, g) = (* ~ term.ML *)
|
neuper@37989
|
1209 |
prod_ord (prod_ord Term_Ord.indexname_ord Term_Ord.typ_ord)
|
neuper@37989
|
1210 |
int_ord (dest_hd' x f, dest_hd' x g)
|
walther@60263
|
1211 |
and terms_ord x _ pr (ts, us) =
|
walther@59881
|
1212 |
list_ord (term_ord' x pr (ThyC.get_theory "Isac_Knowledge"))(ts, us);
|
neuper@52070
|
1213 |
|
neuper@37954
|
1214 |
in
|
neuper@37954
|
1215 |
|
walther@60263
|
1216 |
fun ord_make_polynomial_in (pr:bool) thy subst tu =
|
walther@60263
|
1217 |
((**)tracing ("*** subs variable is: " ^ (Env.subst2str subst)); (**)
|
neuper@37954
|
1218 |
case subst of
|
walther@60263
|
1219 |
(_, x) :: _ => (term_ord' x pr thy tu = LESS)
|
walther@60263
|
1220 |
| _ => raise ERROR ("ord_make_polynomial_in called with subst = " ^ Env.subst2str subst))
|
walther@60263
|
1221 |
|
neuper@37989
|
1222 |
end;(*local*)
|
neuper@37954
|
1223 |
|
wneuper@59472
|
1224 |
\<close>
|
wneuper@59472
|
1225 |
ML\<open>
|
s1210629013@55444
|
1226 |
val order_add_mult_in = prep_rls'(
|
walther@59851
|
1227 |
Rule_Def.Repeat{id = "order_add_mult_in", preconds = [],
|
neuper@37954
|
1228 |
rew_ord = ("ord_make_polynomial_in",
|
neuper@52139
|
1229 |
ord_make_polynomial_in false @{theory "Poly"}),
|
walther@59852
|
1230 |
erls = Rule_Set.empty,srls = Rule_Set.Empty,
|
neuper@42451
|
1231 |
calc = [], errpatts = [],
|
walther@59877
|
1232 |
rules = [Rule.Thm ("mult.commute",ThmC.numerals_to_Free @{thm mult.commute}),
|
neuper@37954
|
1233 |
(* z * w = w * z *)
|
walther@59871
|
1234 |
Rule.Thm ("real_mult_left_commute",ThmC.numerals_to_Free @{thm real_mult_left_commute}),
|
neuper@37954
|
1235 |
(*z1.0 * (z2.0 * z3.0) = z2.0 * (z1.0 * z3.0)*)
|
walther@59877
|
1236 |
Rule.Thm ("mult.assoc",ThmC.numerals_to_Free @{thm mult.assoc}),
|
neuper@37954
|
1237 |
(*z1.0 * z2.0 * z3.0 = z1.0 * (z2.0 * z3.0)*)
|
walther@59877
|
1238 |
Rule.Thm ("add.commute",ThmC.numerals_to_Free @{thm add.commute}),
|
neuper@37954
|
1239 |
(*z + w = w + z*)
|
walther@59877
|
1240 |
Rule.Thm ("add.left_commute",ThmC.numerals_to_Free @{thm add.left_commute}),
|
neuper@37954
|
1241 |
(*x + (y + z) = y + (x + z)*)
|
walther@59877
|
1242 |
Rule.Thm ("add.assoc",ThmC.numerals_to_Free @{thm add.assoc})
|
neuper@37954
|
1243 |
(*z1.0 + z2.0 + z3.0 = z1.0 + (z2.0 + z3.0)*)
|
walther@59878
|
1244 |
], scr = Rule.Empty_Prog});
|
neuper@37954
|
1245 |
|
wneuper@59472
|
1246 |
\<close>
|
wneuper@59472
|
1247 |
ML\<open>
|
s1210629013@55444
|
1248 |
val collect_bdv = prep_rls'(
|
walther@59851
|
1249 |
Rule_Def.Repeat{id = "collect_bdv", preconds = [],
|
walther@59857
|
1250 |
rew_ord = ("dummy_ord", Rewrite_Ord.dummy_ord),
|
walther@59852
|
1251 |
erls = Rule_Set.empty,srls = Rule_Set.Empty,
|
neuper@42451
|
1252 |
calc = [], errpatts = [],
|
walther@59871
|
1253 |
rules = [Rule.Thm ("bdv_collect_1",ThmC.numerals_to_Free @{thm bdv_collect_1}),
|
walther@59871
|
1254 |
Rule.Thm ("bdv_collect_2",ThmC.numerals_to_Free @{thm bdv_collect_2}),
|
walther@59871
|
1255 |
Rule.Thm ("bdv_collect_3",ThmC.numerals_to_Free @{thm bdv_collect_3}),
|
neuper@37954
|
1256 |
|
walther@59871
|
1257 |
Rule.Thm ("bdv_collect_assoc1_1",ThmC.numerals_to_Free @{thm bdv_collect_assoc1_1}),
|
walther@59871
|
1258 |
Rule.Thm ("bdv_collect_assoc1_2",ThmC.numerals_to_Free @{thm bdv_collect_assoc1_2}),
|
walther@59871
|
1259 |
Rule.Thm ("bdv_collect_assoc1_3",ThmC.numerals_to_Free @{thm bdv_collect_assoc1_3}),
|
neuper@37954
|
1260 |
|
walther@59871
|
1261 |
Rule.Thm ("bdv_collect_assoc2_1",ThmC.numerals_to_Free @{thm bdv_collect_assoc2_1}),
|
walther@59871
|
1262 |
Rule.Thm ("bdv_collect_assoc2_2",ThmC.numerals_to_Free @{thm bdv_collect_assoc2_2}),
|
walther@59871
|
1263 |
Rule.Thm ("bdv_collect_assoc2_3",ThmC.numerals_to_Free @{thm bdv_collect_assoc2_3}),
|
neuper@37954
|
1264 |
|
neuper@37954
|
1265 |
|
walther@59871
|
1266 |
Rule.Thm ("bdv_n_collect_1",ThmC.numerals_to_Free @{thm bdv_n_collect_1}),
|
walther@59871
|
1267 |
Rule.Thm ("bdv_n_collect_2",ThmC.numerals_to_Free @{thm bdv_n_collect_2}),
|
walther@59871
|
1268 |
Rule.Thm ("bdv_n_collect_3",ThmC.numerals_to_Free @{thm bdv_n_collect_3}),
|
neuper@37954
|
1269 |
|
walther@59871
|
1270 |
Rule.Thm ("bdv_n_collect_assoc1_1",ThmC.numerals_to_Free @{thm bdv_n_collect_assoc1_1}),
|
walther@59871
|
1271 |
Rule.Thm ("bdv_n_collect_assoc1_2",ThmC.numerals_to_Free @{thm bdv_n_collect_assoc1_2}),
|
walther@59871
|
1272 |
Rule.Thm ("bdv_n_collect_assoc1_3",ThmC.numerals_to_Free @{thm bdv_n_collect_assoc1_3}),
|
neuper@37954
|
1273 |
|
walther@59871
|
1274 |
Rule.Thm ("bdv_n_collect_assoc2_1",ThmC.numerals_to_Free @{thm bdv_n_collect_assoc2_1}),
|
walther@59871
|
1275 |
Rule.Thm ("bdv_n_collect_assoc2_2",ThmC.numerals_to_Free @{thm bdv_n_collect_assoc2_2}),
|
walther@59871
|
1276 |
Rule.Thm ("bdv_n_collect_assoc2_3",ThmC.numerals_to_Free @{thm bdv_n_collect_assoc2_3})
|
walther@59878
|
1277 |
], scr = Rule.Empty_Prog});
|
neuper@37954
|
1278 |
|
wneuper@59472
|
1279 |
\<close>
|
wneuper@59472
|
1280 |
ML\<open>
|
neuper@37954
|
1281 |
(*.transforms an arbitrary term without roots to a polynomial [4]
|
neuper@37954
|
1282 |
according to knowledge/Poly.sml.*)
|
s1210629013@55444
|
1283 |
val make_polynomial_in = prep_rls'(
|
walther@59878
|
1284 |
Rule_Set.Sequence {id = "make_polynomial_in", preconds = []:term list,
|
walther@59857
|
1285 |
rew_ord = ("dummy_ord", Rewrite_Ord.dummy_ord),
|
walther@59851
|
1286 |
erls = Atools_erls, srls = Rule_Set.Empty,
|
neuper@42451
|
1287 |
calc = [], errpatts = [],
|
wneuper@59416
|
1288 |
rules = [Rule.Rls_ expand_poly,
|
wneuper@59416
|
1289 |
Rule.Rls_ order_add_mult_in,
|
wneuper@59416
|
1290 |
Rule.Rls_ simplify_power,
|
wneuper@59416
|
1291 |
Rule.Rls_ collect_numerals,
|
wneuper@59416
|
1292 |
Rule.Rls_ reduce_012,
|
walther@59871
|
1293 |
Rule.Thm ("realpow_oneI",ThmC.numerals_to_Free @{thm realpow_oneI}),
|
wneuper@59416
|
1294 |
Rule.Rls_ discard_parentheses,
|
wneuper@59416
|
1295 |
Rule.Rls_ collect_bdv
|
neuper@37954
|
1296 |
],
|
walther@59878
|
1297 |
scr = Rule.Empty_Prog
|
wneuper@59406
|
1298 |
});
|
neuper@37954
|
1299 |
|
wneuper@59472
|
1300 |
\<close>
|
wneuper@59472
|
1301 |
ML\<open>
|
neuper@37954
|
1302 |
val separate_bdvs =
|
walther@59852
|
1303 |
Rule_Set.append_rules "separate_bdvs"
|
neuper@37954
|
1304 |
collect_bdv
|
walther@59871
|
1305 |
[Rule.Thm ("separate_bdv", ThmC.numerals_to_Free @{thm separate_bdv}),
|
neuper@37954
|
1306 |
(*"?a * ?bdv / ?b = ?a / ?b * ?bdv"*)
|
walther@59871
|
1307 |
Rule.Thm ("separate_bdv_n", ThmC.numerals_to_Free @{thm separate_bdv_n}),
|
walther@59871
|
1308 |
Rule.Thm ("separate_1_bdv", ThmC.numerals_to_Free @{thm separate_1_bdv}),
|
neuper@37954
|
1309 |
(*"?bdv / ?b = (1 / ?b) * ?bdv"*)
|
walther@59871
|
1310 |
Rule.Thm ("separate_1_bdv_n", ThmC.numerals_to_Free @{thm separate_1_bdv_n}),
|
walther@60242
|
1311 |
(*"?bdv \<up> ?n / ?b = 1 / ?b * ?bdv \<up> ?n"*)
|
wneuper@59416
|
1312 |
Rule.Thm ("add_divide_distrib",
|
walther@59871
|
1313 |
ThmC.numerals_to_Free @{thm add_divide_distrib})
|
neuper@37954
|
1314 |
(*"(?x + ?y) / ?z = ?x / ?z + ?y / ?z"
|
neuper@37954
|
1315 |
WN051031 DOES NOT BELONG TO HERE*)
|
neuper@37954
|
1316 |
];
|
wneuper@59472
|
1317 |
\<close>
|
wneuper@59472
|
1318 |
ML\<open>
|
s1210629013@55444
|
1319 |
val make_ratpoly_in = prep_rls'(
|
walther@59878
|
1320 |
Rule_Set.Sequence {id = "make_ratpoly_in", preconds = []:term list,
|
walther@59857
|
1321 |
rew_ord = ("dummy_ord", Rewrite_Ord.dummy_ord),
|
walther@59851
|
1322 |
erls = Atools_erls, srls = Rule_Set.Empty,
|
neuper@42451
|
1323 |
calc = [], errpatts = [],
|
wneuper@59416
|
1324 |
rules = [Rule.Rls_ norm_Rational,
|
wneuper@59416
|
1325 |
Rule.Rls_ order_add_mult_in,
|
wneuper@59416
|
1326 |
Rule.Rls_ discard_parentheses,
|
wneuper@59416
|
1327 |
Rule.Rls_ separate_bdvs,
|
wneuper@59416
|
1328 |
(* Rule.Rls_ rearrange_assoc, WN060916 why does cancel_p not work?*)
|
wneuper@59416
|
1329 |
Rule.Rls_ cancel_p
|
walther@59878
|
1330 |
(*Rule.Eval ("Rings.divide_class.divide" , eval_cancel "#divide_e") too weak!*)
|
neuper@37954
|
1331 |
],
|
walther@59878
|
1332 |
scr = Rule.Empty_Prog});
|
wneuper@59472
|
1333 |
\<close>
|
wneuper@59472
|
1334 |
setup \<open>KEStore_Elems.add_rlss
|
neuper@52130
|
1335 |
[("order_add_mult_in", (Context.theory_name @{theory}, order_add_mult_in)),
|
neuper@52130
|
1336 |
("collect_bdv", (Context.theory_name @{theory}, collect_bdv)),
|
neuper@52130
|
1337 |
("make_polynomial_in", (Context.theory_name @{theory}, make_polynomial_in)),
|
neuper@52130
|
1338 |
("make_ratpoly_in", (Context.theory_name @{theory}, make_ratpoly_in)),
|
wneuper@59472
|
1339 |
("separate_bdvs", (Context.theory_name @{theory}, separate_bdvs))]\<close>
|
neuper@37954
|
1340 |
|
neuper@37906
|
1341 |
end
|
neuper@37906
|
1342 |
|
neuper@37906
|
1343 |
|
neuper@37906
|
1344 |
|
neuper@37906
|
1345 |
|
neuper@37906
|
1346 |
|
neuper@37906
|
1347 |
|