247 (ptree * pos'); (*the calc-state resulting from the application of tacis*) |
247 (ptree * pos'); (*the calc-state resulting from the application of tacis*) |
248 val e_calcstate' = ([e_taci], [e_pos'], (EmptyPtree, e_pos')):calcstate'; |
248 val e_calcstate' = ([e_taci], [e_pos'], (EmptyPtree, e_pos')):calcstate'; |
249 |
249 |
250 (*FIXXXME.WN020430 intermediate hack for fun ass_up*) |
250 (*FIXXXME.WN020430 intermediate hack for fun ass_up*) |
251 fun f_mout thy (Form' (FormKF (_,_,_,_,f))) = (term_of o the o (parse thy)) f |
251 fun f_mout thy (Form' (FormKF (_,_,_,_,f))) = (term_of o the o (parse thy)) f |
252 | f_mout thy _ = raise error "f_mout: not called with formula"; |
252 | f_mout thy _ = error "f_mout: not called with formula"; |
253 |
253 |
254 |
254 |
255 (*.is the calchead complete ?.*) |
255 (*.is the calchead complete ?.*) |
256 fun ocalhd_complete (its: itm list) (pre: (bool * term) list) (dI,pI,mI) = |
256 fun ocalhd_complete (its: itm list) (pre: (bool * term) list) (dI,pI,mI) = |
257 foldl and_ (true, map #3 its) andalso |
257 foldl and_ (true, map #3 its) andalso |
558 | miss => SOME (getr_ct thy (hd miss)) |
558 | miss => SOME (getr_ct thy (hd miss)) |
559 else |
559 else |
560 case find_first (test_subset (hd icl)) vors of |
560 case find_first (test_subset (hd icl)) vors of |
561 (* val SOME ori = find_first (test_subset (hd icl)) vors; |
561 (* val SOME ori = find_first (test_subset (hd icl)) vors; |
562 *) |
562 *) |
563 NONE => raise error "nxt_add: EX itm. not(dat(itm)<=dat(ori))" |
563 NONE => error "nxt_add: EX itm. not(dat(itm)<=dat(ori))" |
564 | SOME ori => SOME (geti_ct thy ori (hd icl)) |
564 | SOME ori => SOME (geti_ct thy ori (hd icl)) |
565 end |
565 end |
566 end; |
566 end; |
567 |
567 |
568 |
568 |
569 |
569 |
570 fun mk_delete thy "#Given" itm_ = Del_Given (itm_out thy itm_) |
570 fun mk_delete thy "#Given" itm_ = Del_Given (itm_out thy itm_) |
571 | mk_delete thy "#Find" itm_ = Del_Find (itm_out thy itm_) |
571 | mk_delete thy "#Find" itm_ = Del_Find (itm_out thy itm_) |
572 | mk_delete thy "#Relate" itm_ = Del_Relation(itm_out thy itm_) |
572 | mk_delete thy "#Relate" itm_ = Del_Relation(itm_out thy itm_) |
573 | mk_delete thy str _ = |
573 | mk_delete thy str _ = |
574 raise error ("mk_delete: called with field '"^str^"'"); |
574 error ("mk_delete: called with field '"^str^"'"); |
575 fun mk_additem "#Given" ct = Add_Given ct |
575 fun mk_additem "#Given" ct = Add_Given ct |
576 | mk_additem "#Find" ct = Add_Find ct |
576 | mk_additem "#Find" ct = Add_Find ct |
577 | mk_additem "#Relate"ct = Add_Relation ct |
577 | mk_additem "#Relate"ct = Add_Relation ct |
578 | mk_additem str _ = |
578 | mk_additem str _ = |
579 raise error ("mk_additem: called with field '"^str^"'"); |
579 error ("mk_additem: called with field '"^str^"'"); |
580 |
580 |
581 |
581 |
582 |
582 |
583 |
583 |
584 |
584 |
684 |
684 |
685 (*3.3.-- |
685 (*3.3.-- |
686 fun update_itm (cl,d,ts) ((id,vt,_,sl,Cor (_,_)):itm) = |
686 fun update_itm (cl,d,ts) ((id,vt,_,sl,Cor (_,_)):itm) = |
687 (id,vt,cl,sl,Cor (d,ts)):itm |
687 (id,vt,cl,sl,Cor (d,ts)):itm |
688 | update_itm (cl,d,ts) (id,vt,_,sl,Syn (_)) = |
688 | update_itm (cl,d,ts) (id,vt,_,sl,Syn (_)) = |
689 raise error ("update_itm "^((Syntax.string_of_term (thy2ctxt thy)) (comp_dts thy (d,ts)))^ |
689 error ("update_itm "^((Syntax.string_of_term (thy2ctxt thy)) (comp_dts thy (d,ts)))^ |
690 " not not for Syn (s:cterm')") |
690 " not not for Syn (s:cterm')") |
691 | update_itm (cl,d,ts) (id,vt,_,sl,Typ (_)) = |
691 | update_itm (cl,d,ts) (id,vt,_,sl,Typ (_)) = |
692 raise error ("update_itm "^((Syntax.string_of_term (thy2ctxt thy)) (comp_dts thy (d,ts)))^ |
692 error ("update_itm "^((Syntax.string_of_term (thy2ctxt thy)) (comp_dts thy (d,ts)))^ |
693 " not not for Typ (s:cterm')") |
693 " not not for Typ (s:cterm')") |
694 | update_itm (cl,d,ts) (id,vt,_,sl,Fal (_,_)) = |
694 | update_itm (cl,d,ts) (id,vt,_,sl,Fal (_,_)) = |
695 (id,vt,cl,sl,Fal (d,ts)) |
695 (id,vt,cl,sl,Fal (d,ts)) |
696 | update_itm (cl,d,ts) (id,vt,_,sl,Inc (_,_)) = |
696 | update_itm (cl,d,ts) (id,vt,_,sl,Inc (_,_)) = |
697 (id,vt,cl,sl,Inc (d,ts)) |
697 (id,vt,cl,sl,Inc (d,ts)) |
719 val complete = if eq_set op = (ts', all) then true else false; |
719 val complete = if eq_set op = (ts', all) then true else false; |
720 in case itm_ of |
720 in case itm_ of |
721 (Cor _) => |
721 (Cor _) => |
722 (if fd = "#undef" then (id,vt,complete,fd,Sup(d,ts')) |
722 (if fd = "#undef" then (id,vt,complete,fd,Sup(d,ts')) |
723 else (id,vt,complete,fd,Cor((d,ts'),(pid, pval)))):itm |
723 else (id,vt,complete,fd,Cor((d,ts'),(pid, pval)))):itm |
724 | (Syn c) => raise error ("ori_2itm wants to overwrite "^c) |
724 | (Syn c) => error ("ori_2itm wants to overwrite "^c) |
725 | (Typ c) => raise error ("ori_2itm wants to overwrite "^c) |
725 | (Typ c) => error ("ori_2itm wants to overwrite "^c) |
726 | (Inc _) => if complete |
726 | (Inc _) => if complete |
727 then (id,vt,true ,fd, Cor ((d,ts'),(pid, pval))) |
727 then (id,vt,true ,fd, Cor ((d,ts'),(pid, pval))) |
728 else (id,vt,false,fd, Inc ((d,ts'),(pid, pval))) |
728 else (id,vt,false,fd, Inc ((d,ts'),(pid, pval))) |
729 | (Sup ((*_,_*)d,ts')) => (*4.9.01 lost env*) |
729 | (Sup ((*_,_*)d,ts')) => (*4.9.01 lost env*) |
730 (*if fd = "#undef" then*) (id,vt,complete,fd,Sup(d,ts')) |
730 (*if fd = "#undef" then*) (id,vt,complete,fd,Sup(d,ts')) |
971 (*.match each pat of the model-pattern with an actual argument; |
971 (*.match each pat of the model-pattern with an actual argument; |
972 precondition: copy-named vars are filtered out.*) |
972 precondition: copy-named vars are filtered out.*) |
973 fun matc thy ([]:pat list) _ (oris:preori list) = oris |
973 fun matc thy ([]:pat list) _ (oris:preori list) = oris |
974 | matc thy pbt [] _ = |
974 | matc thy pbt [] _ = |
975 (tracing (dashs 70); |
975 (tracing (dashs 70); |
976 raise error ("actual arg(s) missing for '"^pats2str pbt |
976 error ("actual arg(s) missing for '"^pats2str pbt |
977 ^"' i.e. should be 'copy-named' by '*_._'")) |
977 ^"' i.e. should be 'copy-named' by '*_._'")) |
978 | matc thy ((p as (s,(d,t)))::pbt) (a::ags) oris = |
978 | matc thy ((p as (s,(d,t)))::pbt) (a::ags) oris = |
979 (* val (thy, ((p as (s,(d,t)))::pbt), (a::ags), oris) = |
979 (* val (thy, ((p as (s,(d,t)))::pbt), (a::ags), oris) = |
980 (thy, pbt', ags, []); |
980 (thy, pbt', ags, []); |
981 (*recursion..*) |
981 (*recursion..*) |
1017 val vals = map sel oris |
1017 val vals = map sel oris |
1018 val cy_ext = (free2str o the) (assoc (vars'~~vals, cy'))^"_"^ext |
1018 val cy_ext = (free2str o the) (assoc (vars'~~vals, cy'))^"_"^ext |
1019 in ([1], field, dsc, [mk_free (type_of t) cy_ext]):preori end |
1019 in ([1], field, dsc, [mk_free (type_of t) cy_ext]):preori end |
1020 else ([1], field, dsc, [t]) |
1020 else ([1], field, dsc, [t]) |
1021 ) |
1021 ) |
1022 handle _ => raise error ("cpy_nam: for "^(term2str t)); |
1022 handle _ => error ("cpy_nam: for "^(term2str t)); |
1023 |
1023 |
1024 (*.match the actual arguments of a SubProblem with a model-pattern |
1024 (*.match the actual arguments of a SubProblem with a model-pattern |
1025 and create an ori list (in root-pbl created from formalization). |
1025 and create an ori list (in root-pbl created from formalization). |
1026 expects ags:pats = 1:1, while copy-named are filtered out of pats; |
1026 expects ags:pats = 1:1, while copy-named are filtered out of pats; |
1027 if no 1:1 the exn raised by matc/mtc and handled at call. |
1027 if no 1:1 the exn raised by matc/mtc and handled at call. |
1061 in ((map var_of_pbl_)(* o (filter_out is_copy_named)*)) pbl_ end; |
1061 in ((map var_of_pbl_)(* o (filter_out is_copy_named)*)) pbl_ end; |
1062 |
1062 |
1063 fun overwrite_ppc thy itm ppc = |
1063 fun overwrite_ppc thy itm ppc = |
1064 let |
1064 let |
1065 fun repl ppc' (_,_,_,_,itm_) [] = |
1065 fun repl ppc' (_,_,_,_,itm_) [] = |
1066 raise error ("overwrite_ppc: " ^ (itm_2str_ (thy2ctxt thy) itm_) ^ |
1066 error ("overwrite_ppc: " ^ (itm_2str_ (thy2ctxt thy) itm_) ^ |
1067 " not found") |
1067 " not found") |
1068 | repl ppc' itm (p::ppc) = |
1068 | repl ppc' itm (p::ppc) = |
1069 if (#1 itm) = (#1 (p:itm)) then ppc' @ [itm] @ ppc |
1069 if (#1 itm) = (#1 (p:itm)) then ppc' @ [itm] @ ppc |
1070 else repl (ppc' @ [p]) itm ppc |
1070 else repl (ppc' @ [p]) itm ppc |
1071 in repl [] itm ppc end; |
1071 in repl [] itm ppc end; |
1104 |
1104 |
1105 (*. output the headline to a ppc .*) |
1105 (*. output the headline to a ppc .*) |
1106 fun header p_ pI mI = |
1106 fun header p_ pI mI = |
1107 case p_ of Pbl => Problem (if pI = e_pblID then [] else pI) |
1107 case p_ of Pbl => Problem (if pI = e_pblID then [] else pI) |
1108 | Met => Method mI |
1108 | Met => Method mI |
1109 | pos => raise error ("header called with "^ pos_2str pos); |
1109 | pos => error ("header called with "^ pos_2str pos); |
1110 |
1110 |
1111 |
1111 |
1112 |
1112 |
1113 (* test-printouts --- |
1113 (* test-printouts --- |
1114 val _=tracing("### insert_ppc: (d,ts)="^((Syntax.string_of_term (thy2ctxt thy))(comp_dts thy(d,ts)))); |
1114 val _=tracing("### insert_ppc: (d,ts)="^((Syntax.string_of_term (thy2ctxt thy))(comp_dts thy(d,ts)))); |
1393 nxt, Safe,pt) end |
1393 nxt, Safe,pt) end |
1394 end |
1394 end |
1395 (* itms2itemppc thy [](*mpc*) pre |
1395 (* itms2itemppc thy [](*mpc*) pre |
1396 *) |
1396 *) |
1397 | specify m' _ _ _ = |
1397 | specify m' _ _ _ = |
1398 raise error ("specify: not impl. for "^tac_2str m'); |
1398 error ("specify: not impl. for "^tac_2str m'); |
1399 |
1399 |
1400 (* val (sel, Add_Given ct, ptp as (pt,(p,Pbl))) = ("#Given", tac, ptp); |
1400 (* val (sel, Add_Given ct, ptp as (pt,(p,Pbl))) = ("#Given", tac, ptp); |
1401 val (sel, Add_Find ct, ptp as (pt,(p,Pbl))) = ("#Find", tac, ptp); |
1401 val (sel, Add_Find ct, ptp as (pt,(p,Pbl))) = ("#Find", tac, ptp); |
1402 *) |
1402 *) |
1403 fun nxt_specif_additem sel ct (ptp as (pt,(p,Pbl))) = |
1403 fun nxt_specif_additem sel ct (ptp as (pt,(p,Pbl))) = |
1464 |
1464 |
1465 pre |
1465 pre |
1466 *) |
1466 *) |
1467 fun ori2Coritm pbt ((i,v,f,d,ts):ori) = |
1467 fun ori2Coritm pbt ((i,v,f,d,ts):ori) = |
1468 (i,v,true,f, Cor ((d,ts),(((snd o snd o the o (find_first (eq1 d))) pbt) |
1468 (i,v,true,f, Cor ((d,ts),(((snd o snd o the o (find_first (eq1 d))) pbt) |
1469 handle _ => raise error ("ori2Coritm: dsc "^ |
1469 handle _ => error ("ori2Coritm: dsc "^ |
1470 term2str d^ |
1470 term2str d^ |
1471 "in ori, but not in pbt") |
1471 "in ori, but not in pbt") |
1472 ,ts))):itm; |
1472 ,ts))):itm; |
1473 fun ori2Coritm (pbt:pat list) ((i,v,f,d,ts):ori) = |
1473 fun ori2Coritm (pbt:pat list) ((i,v,f,d,ts):ori) = |
1474 ((i,v,true,f, Cor ((d,ts),((snd o snd o the o |
1474 ((i,v,true,f, Cor ((d,ts),((snd o snd o the o |
1643 in (*FIXXXME: check if met can still be parsed*) |
1643 in (*FIXXXME: check if met can still be parsed*) |
1644 ([(Specify_Theory dI, Specify_Theory' dI, (pos,Uistate))], c, |
1644 ([(Specify_Theory dI, Specify_Theory' dI, (pos,Uistate))], c, |
1645 (pt, pos)) end |
1645 (pt, pos)) end |
1646 |
1646 |
1647 | nxt_specif m' _ = |
1647 | nxt_specif m' _ = |
1648 raise error ("nxt_specif: not impl. for "^tac2str m'); |
1648 error ("nxt_specif: not impl. for "^tac2str m'); |
1649 |
1649 |
1650 (*.get the values from oris; handle the term list w.r.t. penv.*) |
1650 (*.get the values from oris; handle the term list w.r.t. penv.*) |
1651 |
1651 |
1652 local infix mem; |
1652 local infix mem; |
1653 fun x mem [] = false |
1653 fun x mem [] = false |
1730 (((head_of o term_of) given) $ (term_of formal)); WN100819*) |
1730 (((head_of o term_of) given) $ (term_of formal)); WN100819*) |
1731 fun tag_form thy (formal, given) = |
1731 fun tag_form thy (formal, given) = |
1732 (let val gf = (head_of given) $ formal; |
1732 (let val gf = (head_of given) $ formal; |
1733 val _ = cterm_of thy gf |
1733 val _ = cterm_of thy gf |
1734 in gf end) |
1734 in gf end) |
1735 handle _ => raise error ("calchead.tag_form: " ^ |
1735 handle _ => error ("calchead.tag_form: " ^ |
1736 Syntax.string_of_term (thy2ctxt thy) given ^ |
1736 Syntax.string_of_term (thy2ctxt thy) given ^ |
1737 " .. " ^ |
1737 " .. " ^ |
1738 Syntax.string_of_term (thy2ctxt thy) formal ^ |
1738 Syntax.string_of_term (thy2ctxt thy) formal ^ |
1739 " ..types do not match"); |
1739 " ..types do not match"); |
1740 (* val formal = (the o (parse thy)) "[R::real]"; |
1740 (* val formal = (the o (parse thy)) "[R::real]"; |
1855 ["no_met"] => |
1855 ["no_met"] => |
1856 (snd3 o hd o fst3) (nxt_specif (Refine_Tacitly pblID) ptp) |
1856 (snd3 o hd o fst3) (nxt_specif (Refine_Tacitly pblID) ptp) |
1857 | _ => (snd3 o hd o fst3) (nxt_specif Model_Problem ptp)) |
1857 | _ => (snd3 o hd o fst3) (nxt_specif Model_Problem ptp)) |
1858 (*all stored in tac_ itms ^^^^^^^^^^*) |
1858 (*all stored in tac_ itms ^^^^^^^^^^*) |
1859 | nxt_model_pbl tac_ _ = |
1859 | nxt_model_pbl tac_ _ = |
1860 raise error ("nxt_model_pbl: called by tac= "^tac_2str tac_); |
1860 error ("nxt_model_pbl: called by tac= "^tac_2str tac_); |
1861 (* run subp_rooteq.sml '' |
1861 (* run subp_rooteq.sml '' |
1862 until nxt=("Subproblem",Subproblem ("SqRoot.thy",["univariate","equation"])) |
1862 until nxt=("Subproblem",Subproblem ("SqRoot.thy",["univariate","equation"])) |
1863 > val (_, (Subproblem'((_,pblID,metID),_,_,_,_),_,_,_,_,_)) = |
1863 > val (_, (Subproblem'((_,pblID,metID),_,_,_,_),_,_,_,_,_)) = |
1864 (last_elem o drop_last) ets''; |
1864 (last_elem o drop_last) ets''; |
1865 > val mst = (last_elem o drop_last) ets''; |
1865 > val mst = (last_elem o drop_last) ets''; |
1899 val pt = update_pblppc pt p pits |
1899 val pt = update_pblppc pt p pits |
1900 val pt = update_metppc pt p mits |
1900 val pt = update_metppc pt p mits |
1901 in (pt, (p,Met):pos') end |
1901 in (pt, (p,Met):pos') end |
1902 ; |
1902 ; |
1903 (*| complete_mod (pt, pos as (p, Met):pos') = |
1903 (*| complete_mod (pt, pos as (p, Met):pos') = |
1904 raise error ("###complete_mod: only impl.for Pbl, called with "^ |
1904 error ("###complete_mod: only impl.for Pbl, called with "^ |
1905 pos'2str pos);*) |
1905 pos'2str pos);*) |
1906 |
1906 |
1907 (*.complete _EMPTY_ calc-head for autocalc (sub-)pbl from oris(+met from fmz); |
1907 (*.complete _EMPTY_ calc-head for autocalc (sub-)pbl from oris(+met from fmz); |
1908 oris and spec (incl. pbl-refinement) given from init_calc or SubProblem .*) |
1908 oris and spec (incl. pbl-refinement) given from init_calc or SubProblem .*) |
1909 fun all_modspec (pt, (p,_):pos') = |
1909 fun all_modspec (pt, (p,_):pos') = |
1924 | is_complete_mod_ itms = |
1924 | is_complete_mod_ itms = |
1925 foldl and_ (true, (map #3 itms)); |
1925 foldl and_ (true, (map #3 itms)); |
1926 fun is_complete_mod (pt, pos as (p, Pbl): pos') = |
1926 fun is_complete_mod (pt, pos as (p, Pbl): pos') = |
1927 if (is_pblobj o (get_obj I pt)) p |
1927 if (is_pblobj o (get_obj I pt)) p |
1928 then (is_complete_mod_ o (get_obj g_pbl pt)) p |
1928 then (is_complete_mod_ o (get_obj g_pbl pt)) p |
1929 else raise error ("is_complete_mod: called by PrfObj at "^pos'2str pos) |
1929 else error ("is_complete_mod: called by PrfObj at "^pos'2str pos) |
1930 | is_complete_mod (pt, pos as (p, Met)) = |
1930 | is_complete_mod (pt, pos as (p, Met)) = |
1931 if (is_pblobj o (get_obj I pt)) p |
1931 if (is_pblobj o (get_obj I pt)) p |
1932 then (is_complete_mod_ o (get_obj g_met pt)) p |
1932 then (is_complete_mod_ o (get_obj g_met pt)) p |
1933 else raise error ("is_complete_mod: called by PrfObj at "^pos'2str pos) |
1933 else error ("is_complete_mod: called by PrfObj at "^pos'2str pos) |
1934 | is_complete_mod (_, pos) = |
1934 | is_complete_mod (_, pos) = |
1935 raise error ("is_complete_mod called by "^pos'2str pos^ |
1935 error ("is_complete_mod called by "^pos'2str pos^ |
1936 " (should be Pbl or Met)"); |
1936 " (should be Pbl or Met)"); |
1937 |
1937 |
1938 (*.have (thy, pbl, met) _all_ been specified explicitly ?.*) |
1938 (*.have (thy, pbl, met) _all_ been specified explicitly ?.*) |
1939 fun is_complete_spec (pt, pos as (p,_): pos') = |
1939 fun is_complete_spec (pt, pos as (p,_): pos') = |
1940 if (not o is_pblobj o (get_obj I pt)) p |
1940 if (not o is_pblobj o (get_obj I pt)) p |
1941 then raise error ("is_complete_spec: called by PrfObj at "^pos'2str pos) |
1941 then error ("is_complete_spec: called by PrfObj at "^pos'2str pos) |
1942 else let val (dI,pI,mI) = get_obj g_spec pt p |
1942 else let val (dI,pI,mI) = get_obj g_spec pt p |
1943 in dI<>e_domID andalso pI<>e_pblID andalso mI<>e_metID end; |
1943 in dI<>e_domID andalso pI<>e_pblID andalso mI<>e_metID end; |
1944 (*.complete empty items in specification from origin (pbl, met ev.refined); |
1944 (*.complete empty items in specification from origin (pbl, met ev.refined); |
1945 assumes 'is_complete_mod'.*) |
1945 assumes 'is_complete_mod'.*) |
1946 fun complete_spec (pt, pos as (p,_): pos') = |
1946 fun complete_spec (pt, pos as (p,_): pos') = |