1 (* Title: 150-add-given.sml
2 Author: Walther Neuper 1105
3 (c) copyright due to lincense terms.
6 val fmz = ["equality (x+1=(2::real))", "solveFor x","solutions L"];
8 ("Test", ["sqroot-test","univariate","equation","test"],
9 ["Test","squ-equ-test-subpbl1"]);
10 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))]; (*nxt = ("Model_Problem"*)
11 (*for resuming after stepping into code*)
12 val (p''',f''',nxt''',pt''') = (p,f,nxt,pt);
14 "~~~~~ fun me, args:"; val (((_,tac):tac'_), (p:pos'), (_:NEW), (pt:ctree)) = (nxt, p, [], pt);
16 (*ERROR nxt_add: types or dsc DO NOT MATCH BETWEEN fmz --- pbt ... see 100-init-rootpbl.sml*)
17 case locatetac tac (pt,p) of
18 ("ok", (_, _, ptp)) => ptp;
20 (case step p ((pt, e_pos'),[]) of
21 ("ok", (ts as (tac,_,_)::_, _, _)) => ("",ts))
22 ERROR: ts = [(Tac "appl_add: syntax error in 'equality (<markup> + <markup> = <markup>)'", ...*)
23 "~~~~~ fun step, args:"; val (((ip as (_,p_)):pos'), ((ptp as (pt,p), tacis):calcstate)) =
24 (p, ((pt, e_pos'),[]));
25 val pIopt = get_pblID (pt,ip);
26 ip = ([],Res); (* = false*)
28 pIopt; (* = SOME ["sqroot-test", "univariate", "equation", "test"]*)
29 member op = [Pbl,Met] p_ andalso is_none (get_obj g_env pt (fst p)); (* = true*)
31 (* nxt_specify_ (pt, ip)
32 ERROR: = ([(Tac "appl_add: syntax error in 'equality (<markup> + <markup> = <markup>)'",...*)
33 "~~~~~ fun nxt_specify_, args:"; val (ptp as (pt, pos as (p,p_))) = (pt, ip);
34 val pblobj as (PblObj{meth,origin=origin as (oris,(dI',pI',mI'),_),
35 probl,spec=(dI,pI,mI), ...}) = get_obj I pt p;
36 just_created_ pblobj (*by Subproblem*) andalso origin <> e_origin; (* = false*)
37 val cpI = if pI = e_pblID then pI' else pI;
38 val cmI = if mI = e_metID then mI' else mI;
39 val {ppc, prls, where_, ...} = get_pbt cpI;
40 val pre = check_preconds "thy 100820" prls where_ probl;
41 val pb = foldl and_ (true, map fst pre);
43 (* val (_,tac) = nxt_spec p_ pb oris (dI',pI',mI') (probl, meth)
44 (ppc, (#ppc o get_met) cmI) (dI, pI, mI);
45 ERROR: val tac = Add_Given "equality (<markup> + <markup> = <markup>)"*)
46 "~~~~~ fun nxt_spec, args:"; val (Pbl, preok, (oris : ori list), ((dI', pI', mI') : spec),
47 ((pbl : itm list), (met : itm list)), (pbt, mpc), ((dI, pI, mI) : spec)) =
48 (p_, pb, oris, (dI',pI',mI'), (probl, meth),
49 (ppc, (#ppc o get_met) cmI), (dI, pI, mI));
51 dI' = e_domID andalso dI = e_domID; (* = false*)
52 pI' = e_pblID andalso pI = e_pblID; (* = false*)
53 find_first (is_error o #5) (pbl:itm list); (* = NONE*)
55 (* nxt_add (assoc_thy (if dI = e_domID then dI' else dI)) oris pbt pbl;
56 = SOME ("#Given", "equality (<markup> + <markup> = <markup>)") *)
57 "~~~~~ fun nxt_add, args:"; val (thy, oris, pbt, itms) =
58 ((assoc_thy (if dI = e_domID then dI' else dI)), oris, pbt, pbl);
61 | x mem (y :: ys) = x = y orelse x mem ys;
63 fun testr_vt v ori = (curry (op mem) v) (#2 (ori:ori))
64 andalso (#3 ori) <>"#undef";
65 fun testi_vt v itm = (curry (op mem) v) (#2 (itm:itm));
66 fun test_id ids r = curry (op mem) (#1 (r:ori)) ids;
67 fun test_subset (itm:itm) ((_,_,_,d,ts):ori) =
68 (d_in (#5 itm)) = d andalso subset op = (ts_in (#5 itm), ts);
69 fun false_and_not_Sup((i,v,false,f,Sup _):itm) = false
70 | false_and_not_Sup (i,v,false,f, _) = true
71 | false_and_not_Sup _ = false;
73 val v = if itms = [] then 1 else max_vt itms;
74 val vors = if v = 0 then oris else filter (testr_vt v) oris;(*oris..vat*)
75 val vits = if v = 0 then itms (*because of dsc without dat*)
76 else filter (testi_vt v) itms; (*itms..vat*)
77 val icl = filter false_and_not_Sup vits; (* incomplete *)
78 icl = []; (* = false*)
79 val SOME ori = find_first (test_subset (hd icl)) vors;
81 (* SOME (geti_ct thy ori (hd icl))
82 ERROR: SOME (geti_ct thy ori (hd icl))*)
83 "~~~~~ fun geti_ct, args:"; val (thy, ((_, _, _, d, ts) : ori), ((_, _, _, fd, itm_) : itm)) =
85 "~~~~~ to return val:"; val xxx =
87 ((term_to_string''' thy) o comp_dts) (d, subtract op = (ts_in itm_) ts) : cterm'
89 if xxx = ("#Given", "equality (x + 1 = 2)") then () else error "";
91 (* resuming after stepping into code*)
92 val (p,f,nxt,pt) = (p''',f''',nxt''',pt''');
94 val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = (_,Add_Given "equality (x + 1 = 2)*)
95 val (p,_,f,nxt,_,pt) = me nxt p [1] pt; (*nxt = (_,Add_Given "solveFor x"*)
96 case nxt of (_, Add_Given "solveFor x") => ()
97 | _ => error "minisubpbl: Add_Given is broken in root-problem";