neuper@42394
|
1 |
(* Title: Test for rational equations
|
neuper@42394
|
2 |
Author: Richard Lang 2009
|
neuper@42394
|
3 |
(c) copyright due to lincense terms.
|
neuper@42394
|
4 |
*)
|
neuper@37906
|
5 |
|
neuper@42394
|
6 |
"-----------------------------------------------------------------";
|
neuper@42394
|
7 |
"table of contents -----------------------------------------------";
|
neuper@42394
|
8 |
"-----------------------------------------------------------------";
|
walther@59835
|
9 |
"----------- pbl: rational, univariate, equation ----------------";
|
walther@59835
|
10 |
"----------- solve (1/x = 5, x) by me ---------------------------";
|
walther@59835
|
11 |
"----------- S.68, Bsp.: 40, ((x)/(x - 8) + (x - 8)/(x) = 26/5)--";
|
walther@59835
|
12 |
"----------- x / (x ^ 2 - 6 * x + 9) - 1 / (x ^ 2 - 3 * x) = 1 /x";
|
walther@59835
|
13 |
"----------- ((5*x)/(x - 2) - x/(x+2)=(4::real)), incl. refine ---------------------------------";
|
neuper@42394
|
14 |
"-----------------------------------------------------------------";
|
neuper@42394
|
15 |
"-----------------------------------------------------------------";
|
neuper@37906
|
16 |
|
neuper@42394
|
17 |
val thy = @{theory "RatEq"};
|
neuper@48761
|
18 |
val ctxt = Proof_Context.init_global thy;
|
neuper@37906
|
19 |
|
neuper@42394
|
20 |
"------------ pbl: rational, univariate, equation ----------------";
|
neuper@42394
|
21 |
"------------ pbl: rational, univariate, equation ----------------";
|
neuper@42394
|
22 |
"------------ pbl: rational, univariate, equation ----------------";
|
wneuper@59188
|
23 |
val t = (Thm.term_of o the o (parse thy)) "(1/b+1/x=1) is_ratequation_in x";
|
neuper@42394
|
24 |
val SOME (t_, _) = rewrite_set_ thy false RatEq_prls t;
|
walther@59868
|
25 |
val result = UnparseC.term t_;
|
neuper@42394
|
26 |
if result <> "True" then error "rateq.sml: new behaviour 1:" else ();
|
neuper@41943
|
27 |
|
wneuper@59188
|
28 |
val t = (Thm.term_of o the o (parse thy)) "(sqrt(x)=1) is_ratequation_in x";
|
neuper@42394
|
29 |
val SOME (t_, _) = rewrite_set_ thy false RatEq_prls t;
|
walther@59868
|
30 |
val result = UnparseC.term t_;
|
neuper@42394
|
31 |
if result <> "False" then error "rateq.sml: new behaviour 2:" else ();
|
neuper@37906
|
32 |
|
wneuper@59188
|
33 |
val t = (Thm.term_of o the o (parse thy)) "(x=-1) is_ratequation_in x";
|
neuper@42394
|
34 |
val SOME (t_,_) = rewrite_set_ thy false RatEq_prls t;
|
walther@59868
|
35 |
val result = UnparseC.term t_;
|
neuper@42394
|
36 |
if result <> "False" then error "rateq.sml: new behaviour 3:" else ();
|
neuper@37906
|
37 |
|
wneuper@59188
|
38 |
val t = (Thm.term_of o the o (parse thy)) "(3 + x^^^2 + 1/(x^^^2+3)=1) is_ratequation_in x";
|
neuper@42394
|
39 |
val SOME (t_,_) = rewrite_set_ thy false RatEq_prls t;
|
walther@59868
|
40 |
val result = UnparseC.term t_;
|
neuper@42394
|
41 |
if result <> "True" then error "rateq.sml: new behaviour 4:" else ();
|
neuper@37906
|
42 |
|
walther@59984
|
43 |
val result = M_Match.match_pbl ["equality (x=(1::real))","solveFor x","solutions L"]
|
walther@59970
|
44 |
(Problem.from_store ["rational","univariate","equation"]);
|
walther@59984
|
45 |
case result of M_Match.NoMatch' _ => () | _ => error "rateq.sml: new behaviour: 5";
|
neuper@37906
|
46 |
|
walther@59984
|
47 |
val result = M_Match.match_pbl ["equality (3 + x^^^2 + 1/(x^^^2+3)=1)","solveFor x","solutions L"]
|
walther@59970
|
48 |
(Problem.from_store ["rational","univariate","equation"]);
|
walther@59984
|
49 |
case result of M_Match.Matches' _ => () | _ => error "rateq.sml: new behaviour: 6";
|
neuper@37906
|
50 |
|
neuper@42394
|
51 |
"------------ solve (1/x = 5, x) by me ---------------------------";
|
neuper@42394
|
52 |
"------------ solve (1/x = 5, x) by me ---------------------------";
|
neuper@42394
|
53 |
"------------ solve (1/x = 5, x) by me ---------------------------";
|
neuper@42394
|
54 |
val fmz = ["equality (1/x=(5::real))","solveFor x","solutions L"];
|
neuper@37991
|
55 |
val (dI',pI',mI') = ("RatEq",["univariate","equation"],["no_met"]);
|
neuper@37906
|
56 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
|
neuper@42394
|
57 |
(* val (p,_,f,nxt,_,pt) = me nxt p [1] pt;------------- now Refine_Tacitly*)
|
neuper@37906
|
58 |
(* nxt = ("Model_Problem",Model_Problem ["rational","univariate","equation"]) *)
|
neuper@37906
|
59 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
60 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
61 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
62 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@42394
|
63 |
|
wneuper@59253
|
64 |
case nxt of ("Rewrite_Set", Rewrite_Set "RatEq_eliminate") => () | _ => ((*not checked before*));
|
neuper@37906
|
65 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@42394
|
66 |
(*
|
walther@59767
|
67 |
WN120317.TODO dropped rateq: here "x ~= 0 should at_location to ctxt, but it does not:
|
neuper@42394
|
68 |
--- repair NO asms from rls RatEq_eliminate --- shows why.
|
neuper@42394
|
69 |
so it needs more effort to find out, how Check_elementwise worked in 2002, see below.
|
neuper@42394
|
70 |
*)
|
neuper@42394
|
71 |
|
neuper@42394
|
72 |
(* val nxt = (_,Subproblem ("RatEq",["univariate","equation"] ======= *)
|
neuper@37906
|
73 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@42394
|
74 |
(* val (p,_,f,nxt,_,pt) = me nxt p [1] pt;------------- now Refine_Tacitly*)
|
wneuper@59367
|
75 |
(*val nxt = ("Model_Problem", Model_Problem ["normalise","polynomial","univariate","equation"])*)
|
neuper@37906
|
76 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
77 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
78 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
79 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
wneuper@59370
|
80 |
(*val nxt = Apply_Method ["PolyEq", "normalise_poly"])*)
|
neuper@37906
|
81 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
82 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@42394
|
83 |
(* val nxt = (_,Subproblem ("PolyEq",["polynomial","univariate","equation"]=======*)
|
neuper@37906
|
84 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
85 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
86 |
(* ("Model_Problem", Model_Problem ["degree_1","polynomial","univariate","equation"])*)
|
neuper@37906
|
87 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
88 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
89 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
90 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
91 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
92 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@42394
|
93 |
val (p''',_,f,nxt''',_,pt''') = me nxt p [1] pt;
|
neuper@42394
|
94 |
f2str f = "[x = 1 / 5]";
|
wneuper@59253
|
95 |
case nxt of ("Check_elementwise", Check_elementwise "Assumptions") => () | _ => ((*not checked before*));
|
walther@59749
|
96 |
"~~~~~ fun me, args:"; val (tac, (p:pos'), _, (pt:ctree)) = (nxt, p, c, pt);
|
walther@59804
|
97 |
val (pt, p) = case Step.by_tactic tac (pt,p) of
|
walther@59804
|
98 |
("ok", (_, _, ptp)) => ptp | _ => error "--- solve (1/x = 5.. Step.by_tactic";
|
walther@59765
|
99 |
"~~~~~ fun Step.do_next, args:"; val (ip as (_,p_), (ptp as (pt,p), tacis)) = (p, ((pt, e_pos'), []))
|
neuper@42394
|
100 |
val pIopt = get_pblID (pt,ip); (*= SOME ["rational", "univariate", "equation"]
|
neuper@42394
|
101 |
1-1 associated to metID ["RatEq", "solve_rat_equation"]*)
|
neuper@42394
|
102 |
tacis; (*= []*)
|
walther@59914
|
103 |
Library.member op = [Pbl,Met] p_; (*= false*)
|
walther@59760
|
104 |
"~~~~~ fun do_next, args:"; val (ptp as (pt, pos as (p, p_))) = (pt, ip);
|
neuper@42394
|
105 |
val thy' = get_obj g_domID pt (par_pblobj pt p);
|
walther@59831
|
106 |
val (is, sc) = resume_prog thy' (p,p_) pt; (*is: which ctxt?*)
|
walther@59772
|
107 |
"~~~~~ fun find_next_step, args:"; val () = ();
|
walther@59679
|
108 |
(*----- outcommented during cleanup of args in lucas-interpreter.sml ------------------------\\* )
|
walther@59769
|
109 |
"~~~~~ fun go_scan_up, args:"; val (thy, ptp, (Prog sc), E, l, ay, a, v) =
|
walther@59784
|
110 |
(thy, ptp, sc, E, l, true, a, v);
|
neuper@42394
|
111 |
1 < length l; (*true*)
|
neuper@42394
|
112 |
val up = drop_last l;
|
walther@59767
|
113 |
at_location up sc; (* = Const ("HOL.Let", *)
|
walther@59769
|
114 |
"~~~~~ fun scan_up, args:"; val (thy, ptp, (scr as (Prog sc)), E, l, ay,
|
walther@59767
|
115 |
(t as Const ("HOL.Let",_) $ _), a, v) = (thy, ptp, (Prog sc), E, up, ay, (at_location up sc), a, v);
|
neuper@42394
|
116 |
ay = Napp_; (*false*)
|
neuper@42394
|
117 |
val up = drop_last l;
|
walther@59767
|
118 |
val (Const ("HOL.Let",_) $ e $ (Abs (i,T,body))) = at_location up sc; (*Const ("Prog_Tac.SubProblem",..*)
|
neuper@42394
|
119 |
val i = mk_Free (i, T);
|
walther@59697
|
120 |
val E = Env.update E (i, v);
|
walther@59769
|
121 |
"~~~~~ fun scan_dn, args:"; val ((thy as (th,sr)), (pt, p), E, l, t, a, v) =
|
neuper@42394
|
122 |
(thy, ptp, E, (up@[R,D]), body, a, v);
|
walther@59772
|
123 |
"~~~~~ fun check_leaf, args:"; val (call, thy, srls, (E, (a, v)), t) = ("next ", th, sr, (E, (a, v)), t);
|
walther@59718
|
124 |
"~~~~~ fun eval_leaf, args:"; val (E, a, v,
|
wneuper@59601
|
125 |
(t as (Const ("Prog_Tac.Check'_elementwise",_) $ _ $ _ ))) = (E, a, v, t);
|
walther@59717
|
126 |
val Program.Tac tm = Program.Tac (subst_atomic E t);
|
walther@59868
|
127 |
UnparseC.term tm = "Check_elementwise [x = 1 / 5] {v_v. Assumptions}";
|
neuper@42394
|
128 |
(* ------ ^^^ ----- ? "x" ?*)
|
walther@59772
|
129 |
"~~~~~ to check_leaf return val:"; val ((Program.Tac stac, a')) = ((Program.Tac (subst_atomic E t), NONE));
|
walther@59881
|
130 |
val stac' = eval_prog_expr (ThyC.get_theory thy) srls (subst_atomic (upd_env_opt E (a,v)) stac);
|
walther@59868
|
131 |
UnparseC.term stac' = "Check_elementwise [x = 1 / 5] {v_v. Assumptions}";
|
walther@59769
|
132 |
"~~~~~ to scan_dn return val:"; val ((a', Program.Tac stac)) = ((a', Program.Tac stac'));
|
walther@59881
|
133 |
val m = LItool.tac_from_prog pt (ThyC.get_theory th) stac;
|
wneuper@59253
|
134 |
case m of Check_elementwise "Assumptions" => () | _ => (); (*m' = Empty_Tac_ ???!??? *);
|
neuper@42394
|
135 |
val (p''''', pt''''', m''''') = (p, pt, m);
|
walther@59922
|
136 |
"~~~~~ fun check , args:"; val ((p,p_), pt, (m as Check_elementwise pred)) = (p, pt, m);
|
walther@59914
|
137 |
Library.member op = [Pbl,Met] p_; (* = false*)
|
neuper@42394
|
138 |
val pp = par_pblobj pt p;
|
neuper@42394
|
139 |
val thy' = (get_obj g_domID pt pp):theory';
|
walther@59881
|
140 |
val thy = ThyC.get_theory thy'
|
neuper@42394
|
141 |
val metID = (get_obj g_metID pt pp)
|
walther@59970
|
142 |
val {crls,...} = Method.from_store metID
|
neuper@42394
|
143 |
val (f,asm) = case p_ of Frm => (get_obj g_form pt p , [])
|
neuper@42394
|
144 |
| Res => get_obj g_result pt p;
|
walther@59868
|
145 |
UnparseC.term f = "[x = 1 / 5]"; (*the current formula*)
|
walther@59879
|
146 |
val vp = (ThyC.to_ctxt thy, pred) |-> parseNEW |> the |> mk_set thy pt p f;
|
neuper@42394
|
147 |
val (bdv, asms) = vp;
|
neuper@42394
|
148 |
|
walther@59868
|
149 |
UnparseC.term bdv = "x";
|
walther@59868
|
150 |
UnparseC.terms asms = (* asms from rewriting are missing : vvv *)
|
wneuper@59357
|
151 |
("[\"<not> matches (?a = 0) (1 = 5 * x) | ~ lhs (1 = 5 * x) is_poly_in x\",\"x = 1 / 5\"," ^
|
neuper@42394
|
152 |
"\"lhs (1 + -5 * x = 0) is_poly_in x\",\"lhs (1 + -5 * x = 0) has_degree_in x = 1\"," ^
|
neuper@42394
|
153 |
"\"1 / x = 5 is_ratequation_in x\"]");
|
neuper@42394
|
154 |
(*
|
neuper@42394
|
155 |
WN120317.TODO dropped rateq: ctxt should contain "x ~= 0 here, but it does not, see above.
|
neuper@42394
|
156 |
*)
|
neuper@42394
|
157 |
|
walther@59922
|
158 |
val Applicable.Yes (Check_elementwise' (curr_form, pred, (res, asms))) = check p''''' pt''''' m''''';
|
walther@59868
|
159 |
UnparseC.term curr_form = "[x = 1 / 5]";
|
neuper@42394
|
160 |
pred = "Assumptions";
|
neuper@42394
|
161 |
res = str2term "[]::bool list";
|
neuper@42394
|
162 |
asms = [];
|
neuper@42394
|
163 |
|
neuper@42394
|
164 |
val (p,_,f,nxt,_,pt) = me nxt''' p''' [] pt'''; (*<<<----- this caused the error*)
|
neuper@42394
|
165 |
f2str f = "[]";
|
neuper@37906
|
166 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@42394
|
167 |
|
wneuper@59581
|
168 |
if p = ([], Res) andalso f2str f = "[x = 1 / 5]"
|
wneuper@59253
|
169 |
then case nxt of ("End_Proof'", End_Proof') => ()
|
wneuper@59253
|
170 |
| _ => error "rateq.sml: new behaviour: [x = 1 / 5] 1"
|
walther@59617
|
171 |
else error "rateq.sml: new behaviour: [x = 1 / 5] 2";
|
walther@59679
|
172 |
( *----- outcommented during cleanup of args in lucas-interpreter.sml ------------------------//*)
|
neuper@37906
|
173 |
|
neuper@42394
|
174 |
"------------ S.68, Bsp.: 40, ((x)/(x - 8) + (x - 8)/(x) = 26/5)--";
|
neuper@42394
|
175 |
"------------ S.68, Bsp.: 40, ((x)/(x - 8) + (x - 8)/(x) = 26/5)--";
|
neuper@42394
|
176 |
"------------ S.68, Bsp.: 40, ((x)/(x - 8) + (x - 8)/(x) = 26/5)--";
|
neuper@37906
|
177 |
(*EP Schalk_II_p68_n40*)
|
neuper@42394
|
178 |
val fmz = ["equality ((x)/(x - 8) + (x - 8)/(x) = 26/(5::real))","solveFor x","solutions L"];
|
neuper@37991
|
179 |
val (dI',pI',mI') = ("RatEq",["univariate","equation"],["no_met"]);
|
neuper@37906
|
180 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
|
neuper@37906
|
181 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
182 |
(* nxt = ("Model_Problem",Model_Problem ["rational","univariate","equation"])*)
|
neuper@37906
|
183 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
184 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
185 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
186 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
187 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
188 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37991
|
189 |
(* nxt = ("Subproblem",Subproblem ("RatEq",["univariate","equation"]))*)
|
neuper@37906
|
190 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
wneuper@59367
|
191 |
(* nxt = ("Model_Problem", Model_Problem ["normalise","polynomial","univariate","equation"])*)
|
neuper@37906
|
192 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
193 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
194 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
195 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
196 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
walther@59627
|
197 |
|
walther@59627
|
198 |
if p = ([4, 3], Pbl) then ()
|
walther@59627
|
199 |
else
|
walther@59627
|
200 |
(case nxt of
|
walther@59627
|
201 |
("Add_Given", Add_Given "solveFor x") =>
|
walther@59627
|
202 |
(case f of
|
walther@59959
|
203 |
Test_Out.PpcKF (Problem [], {Given = [Incompl "solveFor", Correct "equality (320 + 128 * x + -16 * x ^^^ 2 = 0)"], ...}) => ()
|
walther@59627
|
204 |
| _ => error ("S.68, Bsp.: 40 PblObj changed"))
|
walther@59846
|
205 |
| _ => error ("S.68, Bsp.: 40 changed nxt =" ^ Tactic.input_to_string (snd nxt)));
|
walther@59627
|
206 |
|
neuper@37906
|
207 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37991
|
208 |
(* ("Subproblem", Subproblem ("PolyEq",["polynomial","univariate","equation"])) *)
|
neuper@37906
|
209 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
210 |
(* nxt = ("Model_Problem", Model_Problem
|
neuper@37906
|
211 |
["abcFormula","degree_2","polynomial","univariate","equation"])*)
|
neuper@37906
|
212 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
213 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
214 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
215 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
216 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
217 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@37906
|
218 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
walther@59627
|
219 |
if p = ([], Res) andalso f2str f = "[]" then ()
|
neuper@42394
|
220 |
else error "rateq.sml: new behaviour: [x = -2, x = 10]";
|
neuper@37906
|
221 |
|
walther@59842
|
222 |
"----------- remove x = 0 from [x = 0, x = 6 / 5] ----------------------------------------------";
|
walther@59842
|
223 |
"----------- remove x = 0 from [x = 0, x = 6 / 5] ----------------------------------------------";
|
walther@59842
|
224 |
"----------- remove x = 0 from [x = 0, x = 6 / 5] ----------------------------------------------";
|
neuper@42394
|
225 |
(*ER-7*) (*Schalk I s.87 Bsp 55b*)
|
neuper@42394
|
226 |
val fmz = ["equality (x/(x^^^2 - 6*x+9) - 1/(x^^^2 - 3*x) =1/x)",
|
neuper@42394
|
227 |
"solveFor x","solutions L"];
|
walther@59842
|
228 |
val spec = ("RatEq",["univariate","equation"],["no_met"]);
|
walther@59842
|
229 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, spec)]; (* 0. specify-phase *)
|
walther@59842
|
230 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
231 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
232 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
233 |
|
walther@59842
|
234 |
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
235 |
(*+*)case nxt of Apply_Method ["RatEq", "solve_rat_equation"] => ()
|
walther@59842
|
236 |
(*+*)| _ => error "55b root specification broken";
|
walther@59842
|
237 |
|
walther@59842
|
238 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; (* 0. solve-phase*)
|
walther@59842
|
239 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
240 |
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
|
241 |
|
walther@59868
|
242 |
(*+*)if eq_set op = (Ctree.get_assumptions pt p |> map UnparseC.term,
|
walther@59842
|
243 |
(*+*) ["x \<noteq> 0",
|
walther@59842
|
244 |
(*+*) "9 * x + -6 * x ^^^ 2 + x ^^^ 3 \<noteq> 0",
|
walther@59842
|
245 |
(*+*) "x / (x ^^^ 2 - 6 * x + 9) - 1 / (x ^^^ 2 - 3 * x) =\n1 / x is_ratequation_in x"])
|
walther@59842
|
246 |
(*+*)then () else error "assumptions before 1. Subproblem CHANGED";
|
walther@59842
|
247 |
(*+*)if p = ([3], Res) andalso f2str f = "(3 + -1 * x + x ^^^ 2) * x = 1 * (9 * x + -6 * x ^^^ 2 + x ^^^ 3)"
|
walther@59842
|
248 |
(*+*)then
|
walther@59842
|
249 |
(*+*) ((case nxt of Subproblem ("PolyEq", ["normalise", "polynomial", "univariate", "equation"]) => ()
|
walther@59846
|
250 |
(*+*) | _ => error ("S.68, Bsp.: 40 nxt =" ^ Tactic.input_to_string nxt)))
|
walther@59842
|
251 |
(*+*)else error "1. Subproblem -- call changed";
|
walther@59842
|
252 |
|
walther@59842
|
253 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; (* 1. specify-phase *)
|
walther@59842
|
254 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
255 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
256 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
257 |
|
walther@59842
|
258 |
(*[4], Met*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
259 |
case nxt of Apply_Method ["PolyEq", "normalise_poly"] => ()
|
walther@59617
|
260 |
| _ => error "55b normalise_poly specification broken 1";
|
walther@59842
|
261 |
|
walther@59842
|
262 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; (* 1. solve-phase *)
|
walther@59842
|
263 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
264 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; f2str f = "-6 * x + 5 * x ^^^ 2 = 0";
|
walther@59842
|
265 |
|
walther@59627
|
266 |
if p = ([4, 3], Res) andalso f2str f = "-6 * x + 5 * x ^^^ 2 = 0"
|
walther@59627
|
267 |
then
|
walther@59842
|
268 |
((case nxt of Subproblem ("PolyEq", ["bdv_only", "degree_2", "polynomial", "univariate", "equation"]) => ()
|
walther@59846
|
269 |
| _ => error ("S.68, Bsp.: 40 nxt =" ^ Tactic.input_to_string nxt)))
|
walther@59628
|
270 |
else error "xxx";
|
walther@59842
|
271 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; (* 2. specify-phase *)
|
walther@59842
|
272 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
273 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
274 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59842
|
275 |
|
walther@59842
|
276 |
(*[4, 4], Met*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*\<rightarrow>*)
|
walther@59842
|
277 |
case nxt of Apply_Method ["PolyEq", "solve_d2_polyeq_bdvonly_equation"] => ()
|
walther@59617
|
278 |
| _ => error "55b normalise_poly specification broken 2";
|
neuper@41943
|
279 |
|
walther@59842
|
280 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*f = "-6 * x + 5 * x ^^^ 2 = 0"*) (* 2. solve-phase *)
|
walther@59842
|
281 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@42394
|
282 |
|
walther@59842
|
283 |
(*[4, 4, 3], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*\<rightarrow>Or_to_List*)
|
walther@59842
|
284 |
(*[4, 4, 4], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; f2str f = "[x = 0, x = 6 / 5]";
|
walther@59842
|
285 |
(*[4, 4, 5], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*\<rightarrow>2. Check_Postcond ["bdv_only", "degree_2", "polynomial", "univariate", "equation"]*)
|
neuper@42394
|
286 |
|
walther@59868
|
287 |
(* *)if eq_set op = ((Ctree.get_assumptions pt p |> map UnparseC.term), [
|
walther@59842
|
288 |
(*0.pre*) "x / (x ^^^ 2 - 6 * x + 9) - 1 / (x ^^^ 2 - 3 * x) =\n1 / x is_ratequation_in x",
|
walther@59842
|
289 |
(*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
|
290 |
(*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
|
291 |
(*2.pre*) "lhs (-6 * x + 5 * x ^^^ 2 = 0) is_poly_in x",
|
walther@59842
|
292 |
(*2.pre*) "lhs (-6 * x + 5 * x ^^^ 2 = 0) has_degree_in x = 2",
|
walther@59842
|
293 |
(*0.asm*) "x \<noteq> 0",
|
walther@59842
|
294 |
(*0.asm*) "9 * x + -6 * x ^^^ 2 + x ^^^ 3 \<noteq> 0"
|
walther@59842
|
295 |
(* *)])
|
walther@59842
|
296 |
(* *)then () else error "assumptions at end 2. Subproblem CHANGED";
|
neuper@42394
|
297 |
|
walther@59842
|
298 |
(*[4, 4], Res*)val (p''''',_,f,nxt''''',_,pt''''') = me nxt p [] pt;(*\<rightarrow>1. Check_Postcond ["normalise", "polynomial", "univariate", "equation"]*)
|
neuper@42394
|
299 |
|
walther@59842
|
300 |
(*/--------- step into 2. Check_Postcond SEE .. ----------------------------------------------\*)
|
walther@59842
|
301 |
"----------- rat-equ: remove x = 0 from [x = 0, x = 6 / 5] due to contexts ---------------------";
|
walther@59842
|
302 |
(*\--------- step into 2. Check_Postcond -----------------------------------------------------/*)
|
neuper@42394
|
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@59868
|
308 |
if f2str f = "[x = 6 / 5]" andalso eq_set op = (map UnparseC.term (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";
|
neuper@42394
|
315 |
|
walther@59835
|
316 |
|
walther@59835
|
317 |
"----------- ((5*x)/(x - 2) - x/(x+2)=(4::real)), incl. refine ---------------------------------";
|
walther@59835
|
318 |
"----------- ((5*x)/(x - 2) - x/(x+2)=(4::real)), incl. refine ---------------------------------";
|
walther@59835
|
319 |
"----------- ((5*x)/(x - 2) - x/(x+2)=(4::real)), incl. refine ---------------------------------";
|
walther@59835
|
320 |
(*was in test/../usecases.sml*)
|
walther@59835
|
321 |
val fmz = ["equality ((5*x)/(x - 2) - x/(x+2)=(4::real))", "solveFor x","solutions L"];
|
walther@59835
|
322 |
val (dI',pI',mI') = ("RatEq", ["univariate","equation"], ["no_met"]);
|
walther@59835
|
323 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
|
walther@59835
|
324 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [1] pt; val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
walther@59835
|
325 |
(**)val (p,_,f,nxt,_,pt) = me nxt p [1] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;(**)
|
walther@59835
|
326 |
(**)val (p,_,f,nxt,_,pt) = me nxt p [1] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;(**)
|
walther@59835
|
327 |
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p [1] pt;(*Apply_Method ["RatEq", "solve_rat_equation"]*)
|
walther@59835
|
328 |
(*[1], Frm*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*Rewrite_Set "RatEq_simplify":*)
|
walther@59835
|
329 |
|
walther@59844
|
330 |
(*+*)if (get_istate_LI pt p |> Istate.string_of) (* still specify-phase: found_accept = false ---------------------------------> vvvvv*)
|
walther@59852
|
331 |
(*+*) = "Pstate ([\"\n(e_e, 5 * x / (x - 2) - x / (x + 2) = 4)\",\"\n(v_v, x)\"], [], Rule_Set.empty, NONE, \n??.empty, ORundef, false, true)"
|
walther@59835
|
332 |
(*+*)then () else error "rat-eq + subpbl: istate in specify-phase";
|
walther@59835
|
333 |
|
walther@59835
|
334 |
(*[1], Res*)val (p,_,f,nxt,_,pt) = me nxt p [1] pt;(*Rewrite_Set "norm_Rational"*)
|
walther@59835
|
335 |
|
walther@59844
|
336 |
(*+*)if (get_istate_LI pt p |> Istate.string_of) (* solve-phase: found_accept = true -----------------------------------------------------------------------------------------------> vvvvv*)
|
walther@59852
|
337 |
(*+*) = "Pstate ([\"\n(e_e, 5 * x / (x - 2) - x / (x + 2) = 4)\",\"\n(v_v, x)\"], [R,L,R,L,L,R,R,R], Rule_Set.empty, SOME e_e, \n5 * x / (x + -1 * 2) + -1 * x / (x + 2) = 4, ORundef, true, true)"
|
walther@59835
|
338 |
(*+*)then () else error "rat-eq + subpbl: istate after found_accept";
|
walther@59835
|
339 |
|
walther@59835
|
340 |
(*[2], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*Rewrite_Set "RatEq_eliminate"*)
|
walther@59835
|
341 |
(*^^^ 2*05*)
|
walther@59835
|
342 |
\<close> ML \<open>
|
walther@59835
|
343 |
(*[3], Res*)val (p,_,f,nxt,_,pt) = me nxt p [1] pt;(*Subproblem ("PolyEq", ["normalise", "polynomial", "univariate", "equation"])*)
|
walther@59835
|
344 |
(*[4], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*Model_Problem*)
|
walther@59835
|
345 |
|
walther@59835
|
346 |
(**)val (p,_,f,nxt,_,pt) = me nxt p [1] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;(**)
|
walther@59835
|
347 |
(**)val (p,_,f,nxt,_,pt) = me nxt p [1] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;(**)
|
walther@59835
|
348 |
(**)val (p,_,f,nxt,_,pt) = me nxt p [1] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;(**)
|
walther@59835
|
349 |
(**)val (p,_,f,nxt,_,pt) = me nxt p [1] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;(**)
|
walther@59835
|
350 |
(*^^^ 2*10*)
|
walther@59835
|
351 |
(**)val (p,_,f,nxt,_,pt) = me nxt p [1] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;(**)
|
walther@59835
|
352 |
(**)val (p,_,f,nxt,_,pt) = me nxt p [1] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;(**)
|
walther@59835
|
353 |
(**)val (p,_,f,nxt,_,pt) = me nxt p [1] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;(**)
|
walther@59835
|
354 |
(**)val (p,_,f,nxt,_,pt) = me nxt p [1] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;(**)
|
walther@59835
|
355 |
|
walther@59835
|
356 |
(*[4,3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [1] pt;(*Specify_Method ["PolyEq", "solve_d1_polyeq_equation"]*)
|
walther@59835
|
357 |
(*[4,3], Met*)val (p,_,f,nxt,_,pt) = me nxt p [1] pt;(*Apply_Method ["PolyEq", "solve_d1_polyeq_equation"]*)
|
walther@59835
|
358 |
(*^^^ 2*15*)
|
walther@59835
|
359 |
(*[4,3,1], Frm*)val (p,_,f,nxt,_,pt) = me nxt p [1] pt;(*Rewrite_Set_Inst (["(''bdv'', x)"], "d1_polyeq_simplify")*)
|
walther@59835
|
360 |
(*[4,3,1], Res*)val (p,_,f,nxt,_,pt) = me nxt p [1] pt;(*Rewrite_Set "polyeq_simplify"*)
|
walther@59835
|
361 |
(*[4,3,2], Res*)val (p,_,f,nxt,_,pt) = me nxt p [1] pt;(*Or_to_List*)
|
walther@59835
|
362 |
(*[4,3,3], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*Check_elementwise "Assumptions"*)
|
walther@59959
|
363 |
(* f = Test_Out.FormKF "[x = -4 / 3]" *)
|
walther@59835
|
364 |
(*[4, 3, 4], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*Check_Postcond ["degree_1", "polynomial", "univariate", "equation"]*)
|
walther@59835
|
365 |
(*[4, 3], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*Check_Postcond ["normalise", "polynomial", "univariate", "equation"]*)
|
walther@59835
|
366 |
(*[4], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*Check_elementwise "Assumptions"*)
|
walther@59835
|
367 |
(*[5], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*Check_Postcond ["rational", "univariate", "equation"]*)
|
walther@59835
|
368 |
(*[], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*End_Proof'*)
|
walther@59835
|
369 |
|
walther@59835
|
370 |
if p = ([], Res) andalso f2str f = "[x = -4 / 3]"
|
walther@59835
|
371 |
then case nxt of End_Proof' => () | _ => error "rat-eq + subpbl: end CHANGED 1"
|
walther@59835
|
372 |
else error "rat-eq + subpbl: end CHANGED 2";
|
walther@59835
|
373 |
|