wneuper@59577
|
1 |
(* Title: "ProgLang/contextC.sml"
|
wneuper@59577
|
2 |
Author: Walther Neuper
|
wneuper@59577
|
3 |
(c) due to copyright terms
|
wneuper@59577
|
4 |
*)
|
wneuper@59577
|
5 |
|
wneuper@59577
|
6 |
"-----------------------------------------------------------------------------------------------";
|
wneuper@59577
|
7 |
"table of contents -----------------------------------------------------------------------------";
|
wneuper@59577
|
8 |
"-----------------------------------------------------------------------------------------------";
|
wneuper@59582
|
9 |
"----------- SEE ADDTESTS/All_Ctxt.thy ---------------------------------------------------------";
|
wneuper@59582
|
10 |
"-----------------------------------------------------------------------------------------------";
|
wneuper@59582
|
11 |
"----------- fun initialise --------------------------------------------------------------------";
|
wneuper@59582
|
12 |
"----------- build fun initialise'--------------------------------------------------------------";
|
walther@59842
|
13 |
"----------- fun get_assumptions, fun insert_assumptions----------------------------------------";
|
wneuper@59582
|
14 |
"----------- fun transfer_asms_from_to ---------------------------------------------------------";
|
walther@59842
|
15 |
"----------- fun avoid_contradict --------------------------------------------------------------";
|
walther@59842
|
16 |
"----------- fun subpbl_to_caller --------------------------------------------------------------";
|
wneuper@59582
|
17 |
"----------- rat-equ: remove x = 0 from [x = 0, x = 6 / 5] due to contexts ---------------------";
|
wneuper@59577
|
18 |
"-----------------------------------------------------------------------------------------------";
|
wneuper@59577
|
19 |
"-----------------------------------------------------------------------------------------------";
|
wneuper@59577
|
20 |
"-----------------------------------------------------------------------------------------------";
|
wneuper@59577
|
21 |
|
wneuper@59577
|
22 |
|
wneuper@59582
|
23 |
"----------- fun initialise --------------------------------------------------------------------";
|
wneuper@59582
|
24 |
"----------- fun initialise --------------------------------------------------------------------";
|
wneuper@59582
|
25 |
"----------- fun initialise --------------------------------------------------------------------";
|
wneuper@59582
|
26 |
val t = @{term "a * b + -123 * c :: real"};
|
wneuper@59582
|
27 |
val ctxt = initialise "Rational" (vars t)
|
wneuper@59582
|
28 |
|
wneuper@59582
|
29 |
(*----- now parsing infers the type *)
|
wneuper@59582
|
30 |
val SOME t = parseNEW ctxt "x";
|
wneuper@59582
|
31 |
if type_of t = HOLogic.realT then error "type inference failed 1" else ();
|
wneuper@59582
|
32 |
|
wneuper@59582
|
33 |
val SOME t = parseNEW ctxt "a";
|
wneuper@59582
|
34 |
if type_of t = HOLogic.realT then () else error "type inference failed 2";
|
wneuper@59582
|
35 |
|
wneuper@59582
|
36 |
"----------- build fun initialise'--------------------------------------------------------------";
|
wneuper@59582
|
37 |
"----------- build fun initialise'--------------------------------------------------------------";
|
wneuper@59582
|
38 |
"----------- build fun initialise'--------------------------------------------------------------";
|
wneuper@59582
|
39 |
val fmz = ["Traegerlaenge L","Streckenlast q_0","Biegelinie y",
|
wneuper@59582
|
40 |
"Randbedingungen [y 0 = (0::real), y L = 0, M_b 0 = 0, M_b L = 0]",
|
wneuper@59582
|
41 |
"FunktionsVariable x", "GleichungsVariablen [c, c_2, c_3, c_4]",
|
wneuper@59582
|
42 |
"AbleitungBiegelinie dy"];
|
wneuper@59582
|
43 |
val (thy, fmz) = (@{theory Biegelinie}, fmz);
|
wneuper@59582
|
44 |
|
wneuper@59582
|
45 |
initialise' thy fmz;
|
wneuper@59582
|
46 |
|
wneuper@59582
|
47 |
val ctxt = thy |> Proof_Context.init_global
|
wneuper@59582
|
48 |
val ts = (map (TermC.parseNEW' ctxt) fmz) |> map TermC.vars |> flat |> distinct
|
wneuper@59582
|
49 |
val _ = TermC.raise_type_conflicts ts;
|
wneuper@59582
|
50 |
|
walther@59842
|
51 |
"----------- fun get_assumptions, fun insert_assumptions----------------------------------------";
|
walther@59842
|
52 |
"----------- fun get_assumptions, fun insert_assumptions----------------------------------------";
|
walther@59842
|
53 |
"----------- fun get_assumptions, fun insert_assumptions----------------------------------------";
|
walther@59728
|
54 |
val ctxt = ContextC.insert_assumptions [@{term "x * v"}, @{term "2 * u"}, @{term "2 * u"}] ctxt;
|
walther@59728
|
55 |
val ctxt = ContextC.insert_assumptions [@{term "x * v"}, @{term "2 * u"}] ctxt;
|
walther@59842
|
56 |
val asms = ContextC.get_assumptions ctxt;
|
wneuper@59582
|
57 |
if asms = [@{term "x * v"}, @{term "2 * u"}]
|
wneuper@59582
|
58 |
then () else error "mstools.sml insert_/get_assumptions changed 1.";
|
wneuper@59582
|
59 |
|
wneuper@59582
|
60 |
"----------- fun transfer_asms_from_to ---------------------------------------------------------";
|
wneuper@59582
|
61 |
"----------- fun transfer_asms_from_to ---------------------------------------------------------";
|
wneuper@59582
|
62 |
"----------- fun transfer_asms_from_to ---------------------------------------------------------";
|
wneuper@59592
|
63 |
val ctxt = Proof_Context.init_global @{theory "Isac_Knowledge"}
|
walther@59728
|
64 |
val from_ctxt = ContextC.insert_assumptions
|
wneuper@59582
|
65 |
[str2term "a < (fro::int)", str2term "b < (fro::int)"] ctxt
|
walther@59728
|
66 |
val to_ctxt = ContextC.insert_assumptions
|
wneuper@59582
|
67 |
[str2term "b < (to::int)", str2term "c < (to::int)"] ctxt
|
wneuper@59582
|
68 |
val new_ctxt = transfer_asms_from_to from_ctxt to_ctxt;
|
wneuper@59582
|
69 |
if terms2strs (get_assumptions new_ctxt) = ["b < fro", "b < to", "c < to"]
|
wneuper@59582
|
70 |
then () else error "fun transfer_asms_from_to changed"
|
wneuper@59582
|
71 |
|
walther@59842
|
72 |
|
walther@59842
|
73 |
"----------- fun avoid_contradict --------------------------------------------------------------";
|
walther@59842
|
74 |
"----------- fun avoid_contradict --------------------------------------------------------------";
|
walther@59842
|
75 |
"----------- fun avoid_contradict --------------------------------------------------------------";
|
walther@59842
|
76 |
val preds = [
|
walther@59842
|
77 |
(*0.pre*)str2term "x / (x ^^^ 2 - 6 * x + 9) - 1 / (x ^^^ 2 - 3 * x) =\n1 / x is_ratequation_in x",
|
walther@59842
|
78 |
(*1.pre*)str2term ("\<not> matches (?a = 0)\n ((3 + -1 * x + x ^^^ 2) * x =\n 1 * (9 * x + -6 * x ^^^ 2 + x ^^^ 3)) \<or>\n"
|
walther@59842
|
79 |
(*1.pre*) ^ "\<not> lhs ((3 + -1 * x + x ^^^ 2) * x =\n 1 * (9 * x + -6 * x ^^^ 2 + x ^^^ 3)) is_poly_in x"),
|
walther@59842
|
80 |
(*0.asm*)str2term "x \<noteq> 0", (* <-------------- "x \<noteq> 0" would contradict "x = 0" ---\*)
|
walther@59842
|
81 |
(*0.asm*)str2term "9 * x + -6 * x ^^^ 2 + x ^^^ 3 \<noteq> 0"
|
walther@59842
|
82 |
];
|
walther@59842
|
83 |
|
walther@59842
|
84 |
val t = str2term "[x = 0, x = 6 / 5]";
|
walther@59842
|
85 |
val (t', for_asm) = avoid_contradict t preds;
|
walther@59842
|
86 |
if term2str t' = "[x = 6 / 5]" andalso map term2str for_asm = ["x = 6 / 5"]
|
walther@59842
|
87 |
then () else error "avoid_contradict [x = 0, x = 6 / 5] CHANGED";
|
walther@59842
|
88 |
|
walther@59842
|
89 |
val t = str2term "x = 0";
|
walther@59842
|
90 |
val (t', for_asm) = avoid_contradict t preds;
|
walther@59842
|
91 |
if term2str t' = "bool_undef" andalso map term2str for_asm = []
|
walther@59842
|
92 |
then () else error "avoid_contradict x = 0 CHANGED"; (* "x \<noteq> 0" in preds *)
|
walther@59842
|
93 |
|
walther@59842
|
94 |
val t = str2term "x = 1";
|
walther@59842
|
95 |
val (t', for_asm) = avoid_contradict t preds;
|
walther@59842
|
96 |
if term2str t' = "x = 1" andalso map term2str for_asm = ["x = 1"]
|
walther@59842
|
97 |
then () else error "avoid_contradict x = 1 CHANGED"; (* "x \<noteq> 1" NOT in preds *)
|
walther@59842
|
98 |
|
walther@59842
|
99 |
val t = str2term "a + b";
|
walther@59842
|
100 |
val (t', for_asm) = avoid_contradict t preds;
|
walther@59842
|
101 |
if term2str t' = "a + b" andalso map term2str for_asm = []
|
walther@59842
|
102 |
then () else error "avoid_contradict a + b CHANGED"; (* NOT a predicate *)
|
walther@59842
|
103 |
|
walther@59842
|
104 |
val t = str2term "[a + b]";
|
walther@59842
|
105 |
val (t', for_asm) = avoid_contradict t preds;
|
walther@59842
|
106 |
if term2str t' = "[a + b]" andalso map term2str for_asm = []
|
walther@59842
|
107 |
then () else error "avoid_contradict [a + b] CHANGED"; (* NOT a predicate *)
|
walther@59842
|
108 |
|
walther@59842
|
109 |
|
walther@59842
|
110 |
"----------- fun subpbl_to_caller --------------------------------------------------------------";
|
walther@59842
|
111 |
"----------- fun subpbl_to_caller --------------------------------------------------------------";
|
walther@59842
|
112 |
"----------- fun subpbl_to_caller --------------------------------------------------------------";
|
wneuper@59592
|
113 |
val ctxt = Proof_Context.init_global @{theory "Isac_Knowledge"}
|
walther@59842
|
114 |
|
walther@59728
|
115 |
val sub_ctxt = ContextC.insert_assumptions
|
wneuper@59582
|
116 |
[str2term "a < (fro::int)", str2term "b < (fro::int)"] ctxt
|
walther@59842
|
117 |
val prog_res = str2term "[x_1 = 1, x_2 = (2::int), x_3 = 3]";
|
walther@59842
|
118 |
|
walther@59842
|
119 |
(* NO contradiction ..*)
|
walther@59728
|
120 |
val caller_ctxt = ContextC.insert_assumptions
|
wneuper@59582
|
121 |
[str2term "b < (to::int)", str2term "c < (to::int)"] ctxt
|
walther@59842
|
122 |
val (t, new_ctxt) = subpbl_to_caller sub_ctxt prog_res caller_ctxt;
|
wneuper@59582
|
123 |
|
walther@59842
|
124 |
if term2str t = "[x_1 = 1, x_2 = 2, x_3 = 3]" andalso map term2str (get_assumptions new_ctxt) =
|
walther@59842
|
125 |
["b < fro", "x_1 = 1", "x_2 = 2", "x_3 = 3", "b < to", "c < to"]
|
walther@59842
|
126 |
then () else error "fun subpbl_to_caller changed 1";
|
walther@59842
|
127 |
|
walther@59842
|
128 |
(* a contradiction ..*)
|
walther@59842
|
129 |
val caller_ctxt = ContextC.insert_assumptions
|
walther@59842
|
130 |
[str2term "b < (to::int)", str2term "x_2 \<noteq> (2::int)"] ctxt
|
walther@59842
|
131 |
val (t, new_ctxt) = subpbl_to_caller sub_ctxt prog_res caller_ctxt;
|
walther@59842
|
132 |
|
walther@59842
|
133 |
if term2str t = "[x_1 = 1, x_3 = 3]" andalso map term2str (get_assumptions new_ctxt) =
|
walther@59842
|
134 |
["b < fro", "x_1 = 1", "x_3 = 3", "b < to", "x_2 \<noteq> 2"]
|
walther@59842
|
135 |
then () else error "fun subpbl_to_caller changed 2";
|
wneuper@59582
|
136 |
|
wneuper@59582
|
137 |
|
wneuper@59582
|
138 |
"----------- rat-equ: remove x = 0 from [x = 0, x = 6 / 5] due to contexts ---------------------";
|
wneuper@59582
|
139 |
"----------- rat-equ: remove x = 0 from [x = 0, x = 6 / 5] due to contexts ---------------------";
|
wneuper@59582
|
140 |
"----------- rat-equ: remove x = 0 from [x = 0, x = 6 / 5] due to contexts ---------------------";
|
walther@59842
|
141 |
(*ER-7*) (*Schalk I s.87 Bsp 55b*)
|
walther@59842
|
142 |
val fmz = ["equality (x/(x^^^2 - 6*x+9) - 1/(x^^^2 - 3*x) =1/x)",
|
walther@59842
|
143 |
"solveFor x","solutions L"];
|
walther@59842
|
144 |
val spec = ("RatEq",["univariate","equation"],["no_met"]);
|
walther@59842
|
145 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, spec)]; (* 0. specify-phase *)
|
walther@59842
|
146 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
147 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
148 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
149 |
|
walther@59842
|
150 |
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
151 |
(*+*)case nxt of Apply_Method ["RatEq", "solve_rat_equation"] => ()
|
walther@59842
|
152 |
(*+*)| _ => error "55b root specification broken";
|
walther@59842
|
153 |
|
walther@59842
|
154 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; (* 0. solve-phase*)
|
walther@59842
|
155 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
156 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; f2str f = "(3 + -1 * x + x ^^^ 2) * x = 1 * (9 * x + -6 * x ^^^ 2 + x ^^^ 3)";
|
walther@59842
|
157 |
|
walther@59844
|
158 |
(*+*)if (Ctree.get_assumptions pt p |> map term2str) =
|
walther@59842
|
159 |
(*+*) ["x \<noteq> 0",
|
walther@59842
|
160 |
(*+*) "9 * x + -6 * x ^^^ 2 + x ^^^ 3 \<noteq> 0",
|
walther@59842
|
161 |
(*+*) "x / (x ^^^ 2 - 6 * x + 9) - 1 / (x ^^^ 2 - 3 * x) =\n1 / x is_ratequation_in x"]
|
walther@59842
|
162 |
(*+*)then () else error "assumptions before 1. Subproblem CHANGED";
|
walther@59842
|
163 |
(*+*)if p = ([3], Res) andalso f2str f = "(3 + -1 * x + x ^^^ 2) * x = 1 * (9 * x + -6 * x ^^^ 2 + x ^^^ 3)"
|
walther@59842
|
164 |
(*+*)then
|
walther@59842
|
165 |
(*+*) ((case nxt of Subproblem ("PolyEq", ["normalise", "polynomial", "univariate", "equation"]) => ()
|
walther@59842
|
166 |
(*+*) | _ => error ("S.68, Bsp.: 40 nxt =" ^ tac2str nxt)))
|
walther@59842
|
167 |
(*+*)else error "1. Subproblem -- call changed";
|
walther@59842
|
168 |
|
walther@59842
|
169 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; (* 1. specify-phase *)
|
walther@59842
|
170 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
171 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
172 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
173 |
|
walther@59842
|
174 |
(*[4], Met*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
175 |
case nxt of Apply_Method ["PolyEq", "normalise_poly"] => ()
|
walther@59842
|
176 |
| _ => error "55b normalise_poly specification broken 1";
|
walther@59842
|
177 |
|
walther@59842
|
178 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; (* 1. solve-phase *)
|
walther@59842
|
179 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
180 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; f2str f = "-6 * x + 5 * x ^^^ 2 = 0";
|
walther@59842
|
181 |
|
walther@59842
|
182 |
if p = ([4, 3], Res) andalso f2str f = "-6 * x + 5 * x ^^^ 2 = 0"
|
walther@59842
|
183 |
then
|
walther@59842
|
184 |
((case nxt of Subproblem ("PolyEq", ["bdv_only", "degree_2", "polynomial", "univariate", "equation"]) => ()
|
walther@59842
|
185 |
| _ => error ("S.68, Bsp.: 40 nxt =" ^ tac2str nxt)))
|
walther@59842
|
186 |
else error "xxx";
|
walther@59842
|
187 |
|
walther@59842
|
188 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; (* 2. specify-phase *)
|
walther@59842
|
189 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
190 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
191 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
192 |
|
walther@59842
|
193 |
(*[4, 4], Met*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*\<rightarrow>*)
|
walther@59842
|
194 |
case nxt of Apply_Method ["PolyEq", "solve_d2_polyeq_bdvonly_equation"] => ()
|
walther@59842
|
195 |
| _ => error "55b normalise_poly specification broken 2";
|
walther@59842
|
196 |
|
walther@59842
|
197 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*f = "-6 * x + 5 * x ^^^ 2 = 0"*) (* 2. solve-phase *)
|
walther@59842
|
198 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
199 |
|
walther@59842
|
200 |
(*[4, 4, 3], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*\<rightarrow>Or_to_List*)
|
walther@59842
|
201 |
(*[4, 4, 4], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; f2str f = "[x = 0, x = 6 / 5]";
|
walther@59842
|
202 |
(*[4, 4, 5], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*\<rightarrow>2. Check_Postcond ["bdv_only", "degree_2", "polynomial", "univariate", "equation"]*)
|
walther@59842
|
203 |
|
walther@59844
|
204 |
(* *)if eq_set op = ((Ctree.get_assumptions pt p |> map term2str), [
|
walther@59842
|
205 |
(*0.pre*) "x / (x ^^^ 2 - 6 * x + 9) - 1 / (x ^^^ 2 - 3 * x) =\n1 / x is_ratequation_in x",
|
walther@59842
|
206 |
(*1.pre*) "\<not> matches (?a = 0)\n ((3 + -1 * x + x ^^^ 2) * x =\n 1 * (9 * x + -6 * x ^^^ 2 + x ^^^ 3)) \<or>\n"
|
walther@59842
|
207 |
(*1.pre*) ^ "\<not> lhs ((3 + -1 * x + x ^^^ 2) * x =\n 1 * (9 * x + -6 * x ^^^ 2 + x ^^^ 3)) is_poly_in x",
|
walther@59842
|
208 |
(*2.pre*) "lhs (-6 * x + 5 * x ^^^ 2 = 0) is_poly_in x",
|
walther@59842
|
209 |
(*2.pre*) "lhs (-6 * x + 5 * x ^^^ 2 = 0) has_degree_in x = 2",
|
walther@59842
|
210 |
(*0.asm*) "x \<noteq> 0",
|
walther@59842
|
211 |
(*0.asm*) "9 * x + -6 * x ^^^ 2 + x ^^^ 3 \<noteq> 0"
|
walther@59842
|
212 |
(* *)])
|
walther@59842
|
213 |
(* *)then () else error "assumptions at end 2. Subproblem CHANGED";
|
walther@59842
|
214 |
(*[4, 4], Res*)val (p''''',_,f,nxt''''',_,pt''''') = me nxt p [] pt;(*\<rightarrow>1. Check_Postcond ["normalise", "polynomial", "univariate", "equation"]*)
|
walther@59842
|
215 |
|
walther@59842
|
216 |
(*/--------- step into 2. Check_Postcond -----------------------------------------------------\*)
|
walther@59842
|
217 |
"~~~~~ fun me , args:"; val (tac, p, _(*NEW remove*), pt) = (nxt, p, [], pt);
|
walther@59842
|
218 |
|
walther@59842
|
219 |
val ("ok", (([(Check_Postcond ["bdv_only", "degree_2", "polynomial", "univariate", "equation"], _, _)]), _, _)) = (*case*)
|
walther@59842
|
220 |
Step.by_tactic tac (pt, p) (*of*);
|
walther@59842
|
221 |
"~~~~~ fun by_tactic , args:"; val (m, (ptp as (pt, p))) = (tac, (pt, p));
|
walther@59842
|
222 |
val Applicable.Appl m = (*case*) Applicable.applicable_in p pt m (*of*);
|
walther@59842
|
223 |
(*if*) Tactic.for_specify' m (*else*);
|
walther@59842
|
224 |
|
walther@59842
|
225 |
val ("ok", (([(Check_Postcond ["bdv_only", "degree_2", "polynomial", "univariate", "equation"], _, _)]), _, _)) =
|
walther@59842
|
226 |
Step_Solve.by_tactic m ptp;
|
walther@59842
|
227 |
"~~~~~ fun by_tactic , args:"; val ((tac as Tactic.Check_Postcond' _), (ptp as (pt, p))) = (m, ptp);
|
walther@59842
|
228 |
|
walther@59842
|
229 |
LI.by_tactic tac (get_istate_LI pt p, get_ctxt_LI pt p) ptp;
|
walther@59843
|
230 |
"~~~~~ fun by_tactic , args:"; val ((Tactic.Check_Postcond' (pI, res)), (sub_ist, sub_ctxt), (pt, pos as (p, _)))
|
walther@59842
|
231 |
= (tac, (get_istate_LI pt p, get_ctxt_LI pt p), ptp);
|
walther@59842
|
232 |
val parent_pos = par_pblobj pt p
|
walther@59842
|
233 |
val {scr, ...} = Specify.get_met (get_obj g_metID pt parent_pos);
|
walther@59842
|
234 |
val prog_res =
|
walther@59842
|
235 |
case LI.find_next_step scr (pt, pos) sub_ist sub_ctxt of
|
walther@59842
|
236 |
(*OLD*) Next_Step (_, _, Tactic.Check_elementwise' (_, _, (prog_res, _))) => prog_res
|
walther@59843
|
237 |
|(*OLD*) End_Program (_, Tactic.Check_Postcond' (_, prog_res)) => prog_res
|
walther@59842
|
238 |
(*OLD*) | _ => raise ERROR ("Step_Solve.by_tactic Check_Postcond " ^ strs2str' pI)
|
walther@59842
|
239 |
(*OLD* ) vvv--- handled by ctxt \<rightarrow> drop ( *OLD*)
|
walther@59842
|
240 |
(*OLD*)val asm = (*?!? Rfun,Rrls rm case*)(case get_obj g_tac pt p of
|
walther@59842
|
241 |
(*OLD*) Tactic.Check_elementwise _ => (snd o (get_obj g_result pt)) p
|
walther@59844
|
242 |
(*OLD*) | _ => Ctree.get_assumptions pt pos);
|
walther@59842
|
243 |
(*OLD* )val tac = Tactic.Check_Postcond' (pI, (prog_res, asm))
|
walther@59842
|
244 |
( *OLD*)
|
walther@59842
|
245 |
(*if*) parent_pos = [] (*else*);
|
walther@59842
|
246 |
(*NEW*) val (ist_parent, ctxt_parent) = case get_loc pt (parent_pos, Frm) of
|
walther@59842
|
247 |
(*NEW*) (Pstate i, c) => (i, c)
|
walther@59842
|
248 |
(*NEW*) | _ => error "LI.by_tactic Check_Postcond': uncovered case get_loc";
|
walther@59842
|
249 |
|
walther@59842
|
250 |
(* *)if eq_set op = (map term2str (get_assumptions ctxt_parent), [
|
walther@59842
|
251 |
(*0.pre*) "x / (x ^^^ 2 - 6 * x + 9) - 1 / (x ^^^ 2 - 3 * x) =\n1 / x is_ratequation_in x",
|
walther@59842
|
252 |
(*1.pre*) "\<not> matches (?a = 0)\n ((3 + -1 * x + x ^^^ 2) * x =\n 1 * (9 * x + -6 * x ^^^ 2 + x ^^^ 3)) \<or>\n"
|
walther@59842
|
253 |
(*1.pre*) ^ "\<not> lhs ((3 + -1 * x + x ^^^ 2) * x =\n 1 * (9 * x + -6 * x ^^^ 2 + x ^^^ 3)) is_poly_in x",
|
walther@59842
|
254 |
(*0.asm*) "x \<noteq> 0",
|
walther@59842
|
255 |
(*0.asm*) "9 * x + -6 * x ^^^ 2 + x ^^^ 3 \<noteq> 0"
|
walther@59842
|
256 |
(* *)])
|
walther@59842
|
257 |
(* *)then () else error "assumptions at xxx CHANGED";
|
walther@59842
|
258 |
|
walther@59842
|
259 |
val (prog_res', ctxt') =
|
walther@59842
|
260 |
ContextC.subpbl_to_caller sub_ctxt prog_res ctxt_parent;
|
walther@59842
|
261 |
(* *)if eq_set op = (map term2str (get_assumptions ctxt'), [
|
walther@59842
|
262 |
(*0.pre*) "x / (x ^^^ 2 - 6 * x + 9) - 1 / (x ^^^ 2 - 3 * x) =\n1 / x is_ratequation_in x",
|
walther@59842
|
263 |
(*1.pre*) "\<not> matches (?a = 0)\n ((3 + -1 * x + x ^^^ 2) * x =\n 1 * (9 * x + -6 * x ^^^ 2 + x ^^^ 3)) \<or>\n"
|
walther@59842
|
264 |
(*1.pre*) ^ "\<not> lhs ((3 + -1 * x + x ^^^ 2) * x =\n 1 * (9 * x + -6 * x ^^^ 2 + x ^^^ 3)) is_poly_in x",
|
walther@59842
|
265 |
(*0.asm*) "9 * x + -6 * x ^^^ 2 + x ^^^ 3 \<noteq> 0",
|
walther@59842
|
266 |
(*0.asm*) "x \<noteq> 0", (* <----------------------- "x \<noteq> 0" contradiction resoved ---\*)
|
walther@59842
|
267 |
(*2.pre*) "lhs (-6 * x + 5 * x ^^^ 2 = 0) is_poly_in x",
|
walther@59842
|
268 |
(*2.pre*) "lhs (-6 * x + 5 * x ^^^ 2 = 0) has_degree_in x = 2",
|
walther@59842
|
269 |
(*2.res*) (*"x \<noteq> 0",*) "x = 6 / 5" (* <---------------- "x \<noteq> 0" would contradict "x = 0" ---/*)
|
walther@59842
|
270 |
(* *)])
|
walther@59842
|
271 |
(* *)then () else error "assumptions at xxx CHANGED";
|
walther@59842
|
272 |
|
walther@59842
|
273 |
"~~~~~ fun subpbl_to_caller , args:"; val (sub_ctxt, prog_res, caller_ctxt)
|
walther@59842
|
274 |
= (sub_ctxt, prog_res, ctxt_parent);
|
walther@59842
|
275 |
val xxxxx = caller_ctxt
|
walther@59842
|
276 |
|> get_assumptions
|
walther@59842
|
277 |
|> avoid_contradict prog_res
|
walther@59842
|
278 |
|> apsnd (insert_assumptions_cao caller_ctxt)
|
walther@59842
|
279 |
|> apsnd (transfer_asms_from_to sub_ctxt);
|
walther@59842
|
280 |
|
walther@59842
|
281 |
xxxxx (*return from xxx*);
|
walther@59842
|
282 |
"~~~~~ from fun subpbl_to_caller \<longrightarrow>fun by_tactic , return:"; val (prog_res', ctxt')
|
walther@59842
|
283 |
= (xxxxx);
|
walther@59843
|
284 |
(*NEW*) val tac = Tactic.Check_Postcond' (pI, prog_res')
|
walther@59842
|
285 |
(*NEW*) val ist' = Pstate (ist_parent |> set_act prog_res |> set_found)
|
walther@59842
|
286 |
(*NEW*) val ((p, p_), ps, _, pt) = Generate.generate1 tac (ist', ctxt') (pt, (parent_pos, Res));
|
walther@59842
|
287 |
|
walther@59842
|
288 |
(*NEW*) ("ok", ([(Tactic.input_from_T tac, tac, ((parent_pos, Res), (ist', ctxt')))], ps, (pt, (p, p_))))
|
walther@59842
|
289 |
(*return from xxx*);
|
walther@59842
|
290 |
"~~~~~ from fun LI.by_tactic \<longrightarrow>fun Step_Solve.by_tactic \<longrightarrow>fun Step.by_tactic \<longrightarrow>fun me, return:"; val (("ok", (_, _, (pt, p))))
|
walther@59842
|
291 |
= ("ok", ([(Tactic.input_from_T tac, tac, ((parent_pos, Res), (ist', ctxt')))], ps, (pt, (p, p_))));
|
walther@59842
|
292 |
val ("ok", (ts as (_, _, _) :: _, _, _)) =
|
walther@59842
|
293 |
(*case*) Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
|
walther@59842
|
294 |
val tac =
|
walther@59842
|
295 |
case ts of
|
walther@59842
|
296 |
tacis as (_::_) => let val (tac, _, _) = last_elem tacis in tac end
|
walther@59842
|
297 |
| _ => if p = ([], Pos.Res) then Tactic.End_Proof' else Tactic.Empty_Tac;
|
walther@59842
|
298 |
|
walther@59842
|
299 |
"~~~~~ from fun me \<longrightarrow>toplevel , return:"; val (p''''',_,f,nxt''''',_,pt''''')
|
walther@59842
|
300 |
= (p, [] : NEW, TESTg_form (pt, p) (* form output comes from Step.by_tactic *),
|
walther@59842
|
301 |
tac, Telem.Sundef, pt);
|
walther@59842
|
302 |
(*\--------- step into 2. Check_Postcond -----------------------------------------------------/*)
|
walther@59842
|
303 |
|
walther@59842
|
304 |
(*[4], Res*)val (p,_,f,nxt,_,pt) = me nxt''''' p''''' [] pt''''';(*\<rightarrow>IDLE LEGACY: Check_elementwise "Assumptions"*)
|
walther@59842
|
305 |
(*[], Res*)val (p,_,f,nxt,_,pt) = me nxt''''' p''''' [] pt''''';(*\<rightarrow>End_Proof'*)
|
walther@59842
|
306 |
|
walther@59842
|
307 |
(*/-------- final test -----------------------------------------------------------------------\*)
|
walther@59844
|
308 |
if f2str f = "[x = 6 / 5]" andalso map term2str (Ctree.get_assumptions pt p) =
|
walther@59842
|
309 |
["x = 6 / 5", "lhs (-6 * x + 5 * x ^^^ 2 = 0) is_poly_in x",
|
walther@59842
|
310 |
"lhs (-6 * x + 5 * x ^^^ 2 = 0) has_degree_in x = 2",
|
walther@59842
|
311 |
"\<not> matches (?a = 0)\n ((3 + -1 * x + x ^^^ 2) * x =\n 1 * (9 * x + -6 * x ^^^ 2 + x ^^^ 3)) \<or>\n\<not> lhs ((3 + -1 * x + x ^^^ 2) * x =\n 1 * (9 * x + -6 * x ^^^ 2 + x ^^^ 3)) is_poly_in x",
|
walther@59842
|
312 |
"x \<noteq> 0", "9 * x + -6 * x ^^^ 2 + x ^^^ 3 \<noteq> 0",
|
walther@59842
|
313 |
"x / (x ^^^ 2 - 6 * x + 9) - 1 / (x ^^^ 2 - 3 * x) =\n1 / x is_ratequation_in x"]
|
walther@59842
|
314 |
then () else error "test CHANGED";
|