57 "#Given" => #Given (ppc:'a ppc) |
57 "#Given" => #Given (ppc:'a ppc) |
58 | "#Where" => #Where (ppc:'a ppc) |
58 | "#Where" => #Where (ppc:'a ppc) |
59 | "#Find" => #Find (ppc:'a ppc) |
59 | "#Find" => #Find (ppc:'a ppc) |
60 | "#With" => #With (ppc:'a ppc) |
60 | "#With" => #With (ppc:'a ppc) |
61 | "#Relate" => #Relate (ppc:'a ppc) |
61 | "#Relate" => #Relate (ppc:'a ppc) |
62 | _ => raise error ("sel_ppc tried to select by '"^sel^"'"); |
62 | _ => error ("sel_ppc tried to select by '"^sel^"'"); |
63 |
63 |
64 fun repl_sel_ppc sel |
64 fun repl_sel_ppc sel |
65 ({Given=gi,Where=wh,Find=fi,With=wi,Relate=re}:'a ppc) x = |
65 ({Given=gi,Where=wh,Find=fi,With=wi,Relate=re}:'a ppc) x = |
66 case sel of |
66 case sel of |
67 "#Given" => ({Given= x,Where=wh,Find=fi,With=wi,Relate=re}:'a ppc) |
67 "#Given" => ({Given= x,Where=wh,Find=fi,With=wi,Relate=re}:'a ppc) |
68 | "#Where" => {Given=gi,Where= x,Find=fi,With=wi,Relate=re} |
68 | "#Where" => {Given=gi,Where= x,Find=fi,With=wi,Relate=re} |
69 | "#Find" => {Given=gi,Where=wh,Find= x,With=wi,Relate=re} |
69 | "#Find" => {Given=gi,Where=wh,Find= x,With=wi,Relate=re} |
70 | "#With" => {Given=gi,Where=wh,Find=fi,With= x,Relate=re} |
70 | "#With" => {Given=gi,Where=wh,Find=fi,With= x,Relate=re} |
71 | "#Relate" => {Given=gi,Where=wh,Find=fi,With=wi,Relate= x} |
71 | "#Relate" => {Given=gi,Where=wh,Find=fi,With=wi,Relate= x} |
72 | _ => raise error ("repl_sel_ppc tried to select by '"^sel^"'"); |
72 | _ => error ("repl_sel_ppc tried to select by '"^sel^"'"); |
73 |
73 |
74 fun add_sel_ppc thy sel |
74 fun add_sel_ppc thy sel |
75 ({Given=gi,Where=wh,Find=fi,With=wi,Relate=re}:'a ppc) x = |
75 ({Given=gi,Where=wh,Find=fi,With=wi,Relate=re}:'a ppc) x = |
76 case sel of |
76 case sel of |
77 "#Given" => ({Given=gi@[x],Where=wh,Find=fi,With=wi,Relate=re}:'a ppc) |
77 "#Given" => ({Given=gi@[x],Where=wh,Find=fi,With=wi,Relate=re}:'a ppc) |
78 | "#Where" => {Given=gi,Where=wh@[x],Find=fi,With=wi,Relate=re} |
78 | "#Where" => {Given=gi,Where=wh@[x],Find=fi,With=wi,Relate=re} |
79 | "#Find" => {Given=gi,Where=wh,Find=fi@[x],With=wi,Relate=re} |
79 | "#Find" => {Given=gi,Where=wh,Find=fi@[x],With=wi,Relate=re} |
80 | "#Relate"=> {Given=gi,Where=wh,Find=fi,With=wi,Relate=re@[x]} |
80 | "#Relate"=> {Given=gi,Where=wh,Find=fi,With=wi,Relate=re@[x]} |
81 | "#undef" => {Given=gi@[x],Where=wh,Find=fi,With=wi,Relate=re}(*ori2itmSup*) |
81 | "#undef" => {Given=gi@[x],Where=wh,Find=fi,With=wi,Relate=re}(*ori2itmSup*) |
82 | _ => raise error ("add_sel_ppc tried to select by '"^sel^"'"); |
82 | _ => error ("add_sel_ppc tried to select by '"^sel^"'"); |
83 fun add_where ({Given=gi,Find=fi,With=wi,Relate=re,...}:'a ppc) wh = |
83 fun add_where ({Given=gi,Find=fi,With=wi,Relate=re,...}:'a ppc) wh = |
84 ({Given=gi,Where=wh,Find=fi,With=wi,Relate=re}:'a ppc); |
84 ({Given=gi,Where=wh,Find=fi,With=wi,Relate=re}:'a ppc); |
85 |
85 |
86 (*-----------------------------------------^^^-(2) aus modspec.sml 23.3.02*) |
86 (*-----------------------------------------^^^-(2) aus modspec.sml 23.3.02*) |
87 |
87 |
208 fun add_field thy pbt (d,ts) = |
208 fun add_field thy pbt (d,ts) = |
209 let fun eq d pt = (d = (fst o snd) pt); |
209 let fun eq d pt = (d = (fst o snd) pt); |
210 in case filter (eq d) pbt of |
210 in case filter (eq d) pbt of |
211 [(fi,(dsc,_))] => (fi,d,ts) |
211 [(fi,(dsc,_))] => (fi,d,ts) |
212 | [] => ("#undef",d,ts) (*may come with met.ppc*) |
212 | [] => ("#undef",d,ts) (*may come with met.ppc*) |
213 | _ => raise error ("add_field: "^ |
213 | _ => error ("add_field: "^ |
214 (Syntax.string_of_term (thy2ctxt' "Isac") d)^ |
214 (Syntax.string_of_term (thy2ctxt' "Isac") d)^ |
215 " more than once in pbt") |
215 " more than once in pbt") |
216 end; |
216 end; |
217 |
217 |
218 (*. take over field from met.ppc at 'Specify_Method' into ori, |
218 (*. take over field from met.ppc at 'Specify_Method' into ori, |
223 let fun eq d pt = (d = (fst o snd) pt); |
223 let fun eq d pt = (d = (fst o snd) pt); |
224 fun repl mpc (i,v,_,d,ts) = |
224 fun repl mpc (i,v,_,d,ts) = |
225 case filter (eq d) mpc of |
225 case filter (eq d) mpc of |
226 [(fi,(dsc,_))] => [(i,v,fi,d,ts)] |
226 [(fi,(dsc,_))] => [(i,v,fi,d,ts)] |
227 | [] => [] (*25.2.02: dsc in ori, but not in met -> superfluous*) |
227 | [] => [] (*25.2.02: dsc in ori, but not in met -> superfluous*) |
228 (*raise error ("add_field': "^ |
228 (*error ("add_field': "^ |
229 (Syntax.string_of_term (thy2ctxt' "Isac") d)^ |
229 (Syntax.string_of_term (thy2ctxt' "Isac") d)^ |
230 " not in met"*) |
230 " not in met"*) |
231 | _ => raise error ("add_field': "^ |
231 | _ => error ("add_field': "^ |
232 (Syntax.string_of_term (thy2ctxt' "Isac") d)^ |
232 (Syntax.string_of_term (thy2ctxt' "Isac") d)^ |
233 " more than once in met"); |
233 " more than once in met"); |
234 in (flat ((map (repl mpc)) ori)):ori list end; |
234 in (flat ((map (repl mpc)) ori)):ori list end; |
235 |
235 |
236 |
236 |
237 (*.mark an element with the position within a plateau; |
237 (*.mark an element with the position within a plateau; |
238 a plateau with length 1 is marked with 0 .*) |
238 a plateau with length 1 is marked with 0 .*) |
239 fun mark eq [] = raise error "mark []" |
239 fun mark eq [] = error "mark []" |
240 | mark eq xs = |
240 | mark eq xs = |
241 let |
241 let |
242 fun mar xx eq [x] n = xx @ [(if n=1 then 0 else n,x)] |
242 fun mar xx eq [x] n = xx @ [(if n=1 then 0 else n,x)] |
243 | mar xx eq (x::x'::xs) n = |
243 | mar xx eq (x::x'::xs) n = |
244 if eq(x,x') then mar (xx @ [(n,x)]) eq (x'::xs) (n+1) |
244 if eq(x,x') then mar (xx @ [(n,x)]) eq (x'::xs) (n+1) |
270 > val xs = [1,1,1,2,4,4,4]; |
270 > val xs = [1,1,1,2,4,4,4]; |
271 > coll (op=) xs; |
271 > coll (op=) xs; |
272 val it = [1,2,4] : int list |
272 val it = [1,2,4] : int list |
273 *) |
273 *) |
274 |
274 |
275 fun max [] = raise error "max of []" |
275 fun max [] = error "max of []" |
276 | max (y::ys) = |
276 | max (y::ys) = |
277 let fun mx x [] = x |
277 let fun mx x [] = x |
278 | mx x (y::ys) = if x < y then mx y ys else mx x ys; |
278 | mx x (y::ys) = if x < y then mx y ys else mx x ys; |
279 in mx y ys end; |
279 in mx y ys end; |
280 fun gen_max _ [] = raise error "gen_max of []" |
280 fun gen_max _ [] = error "gen_max of []" |
281 | gen_max ord (y::ys) = |
281 | gen_max ord (y::ys) = |
282 let fun mx x [] = x |
282 let fun mx x [] = x |
283 | mx x (y::ys) = if ord (x, y) then mx y ys else mx x ys; |
283 | mx x (y::ys) = if ord (x, y) then mx y ys else mx x ys; |
284 in mx y ys end; |
284 in mx y ys end; |
285 |
285 |
336 | prep_ori fmz thy pbt = |
336 | prep_ori fmz thy pbt = |
337 let |
337 let |
338 val ctopts = map (parse thy) fmz |
338 val ctopts = map (parse thy) fmz |
339 val _= (*FIXME.WN060916 improve error report*) |
339 val _= (*FIXME.WN060916 improve error report*) |
340 if null (filter is_none ctopts) then () |
340 if null (filter is_none ctopts) then () |
341 else raise error ("prep_ori: SYNTAX ERROR in " ^ strs2str' fmz) |
341 else error ("prep_ori: SYNTAX ERROR in " ^ strs2str' fmz) |
342 val dts = map ((split_dts thy) o term_of o the) ctopts |
342 val dts = map ((split_dts thy) o term_of o the) ctopts |
343 val ori = map (add_field thy pbt) dts; |
343 val ori = map (add_field thy pbt) dts; |
344 (* val ori = map (flat3 o (pair "#undef")) dts; *) |
344 (* val ori = map (flat3 o (pair "#undef")) dts; *) |
345 val ori' = add_variants ori; |
345 val ori' = add_variants ori; |
346 val maxv = max (map fst ori'); |
346 val maxv = max (map fst ori'); |
660 (Const ("Descript.solveFor","RealDef.real => Tools.una"), |
660 (Const ("Descript.solveFor","RealDef.real => Tools.una"), |
661 Free ("v_","RealDef.real")))] : (string * (term * term)) list*) |
661 Free ("v_","RealDef.real")))] : (string * (term * term)) list*) |
662 |
662 |
663 val fi = filter (eq "#Find") dsc_dats; |
663 val fi = filter (eq "#Find") dsc_dats; |
664 val fi = (case fi of |
664 val fi = (case fi of |
665 [] => [](*28.8.01: ["tool"] ...// raise error |
665 [] => [](*28.8.01: ["tool"] ...// error |
666 ("prep_pbt: no '#Find' in "^(strs2str pblID))*) |
666 ("prep_pbt: no '#Find' in "^(strs2str pblID))*) |
667 (* val ((_,fi')::[]) = fi; |
667 (* val ((_,fi')::[]) = fi; |
668 *) |
668 *) |
669 | ((_,fi')::[]) => |
669 | ((_,fi')::[]) => |
670 ((map (split_did o term_of o the o (parse thy)) fi') |
670 ((map (split_did o term_of o the o (parse thy)) fi') |
671 handle _ => raise error |
671 handle _ => error |
672 ("prep_pbt: syntax error in '#Find' of "^ |
672 ("prep_pbt: syntax error in '#Find' of "^ |
673 (strs2str pblID))) |
673 (strs2str pblID))) |
674 | _ => |
674 | _ => |
675 (raise error ("prep_pbt: more than one '#Find' in "^ |
675 (error ("prep_pbt: more than one '#Find' in "^ |
676 (strs2str pblID)))); |
676 (strs2str pblID)))); |
677 val fi = map (pair "#Find") fi; |
677 val fi = map (pair "#Find") fi; |
678 |
678 |
679 val re = filter (eq "#Relate") dsc_dats; |
679 val re = filter (eq "#Relate") dsc_dats; |
680 val re = (case re of |
680 val re = (case re of |
681 [] => [] |
681 [] => [] |
682 | ((_,re')::[]) => |
682 | ((_,re')::[]) => |
683 ((map (split_did o term_of o the o (parse thy)) re') |
683 ((map (split_did o term_of o the o (parse thy)) re') |
684 handle _ => raise error |
684 handle _ => error |
685 ("prep_pbt: syntax error in '#Relate' of "^ |
685 ("prep_pbt: syntax error in '#Relate' of "^ |
686 (strs2str pblID))) |
686 (strs2str pblID))) |
687 | _ => |
687 | _ => |
688 (raise error ("prep_pbt: more than one '#Relate' in "^ |
688 (error ("prep_pbt: more than one '#Relate' in "^ |
689 (strs2str pblID)))); |
689 (strs2str pblID)))); |
690 val re = map (pair "#Relate") re; |
690 val re = map (pair "#Relate") re; |
691 |
691 |
692 val wh = filter (eq "#Where") dsc_dats; |
692 val wh = filter (eq "#Where") dsc_dats; |
693 val wh = (case wh of |
693 val wh = (case wh of |
694 [] => [] |
694 [] => [] |
695 | ((_,wh')::[]) => |
695 | ((_,wh')::[]) => |
696 ((map (parse_patt thy) wh') |
696 ((map (parse_patt thy) wh') |
697 handle _ => raise error |
697 handle _ => error |
698 ("prep_pbt: syntax error in '#Where' of "^ |
698 ("prep_pbt: syntax error in '#Where' of "^ |
699 (strs2str pblID))) |
699 (strs2str pblID))) |
700 | _ => |
700 | _ => |
701 (raise error ("prep_pbt: more than one '#Where' in "^ |
701 (error ("prep_pbt: more than one '#Where' in "^ |
702 (strs2str pblID)))); |
702 (strs2str pblID)))); |
703 in ({guh=guh,mathauthors=maa,init=init, |
703 in ({guh=guh,mathauthors=maa,init=init, |
704 thy=thy,cas= case ca of NONE => NONE |
704 thy=thy,cas= case ca of NONE => NONE |
705 | SOME s => |
705 | SOME s => |
706 SOME ((term_of o the o (parse thy)) s), |
706 SOME ((term_of o the o (parse thy)) s), |
730 val gi = filter (eq "#Given") ppc; |
730 val gi = filter (eq "#Given") ppc; |
731 val gi = (case gi of |
731 val gi = (case gi of |
732 [] => [] |
732 [] => [] |
733 | ((_,gi')::[]) => |
733 | ((_,gi')::[]) => |
734 ((map (split_did o term_of o the o (parse thy)) gi') |
734 ((map (split_did o term_of o the o (parse thy)) gi') |
735 handle _ => raise error |
735 handle _ => error |
736 ("prep_pbt: syntax error in '#Given' of "^ |
736 ("prep_pbt: syntax error in '#Given' of "^ |
737 (strs2str metID))) |
737 (strs2str metID))) |
738 | _ => |
738 | _ => |
739 (raise error ("prep_pbt: more than one '#Given' in "^ |
739 (error ("prep_pbt: more than one '#Given' in "^ |
740 (strs2str metID)))); |
740 (strs2str metID)))); |
741 val gi = map (pair "#Given") gi; |
741 val gi = map (pair "#Given") gi; |
742 |
742 |
743 val fi = filter (eq "#Find") ppc; |
743 val fi = filter (eq "#Find") ppc; |
744 val fi = (case fi of |
744 val fi = (case fi of |
745 [] => [](*28.8.01: ["tool"] ...// raise error |
745 [] => [](*28.8.01: ["tool"] ...// error |
746 ("prep_pbt: no '#Find' in "^(strs2str metID))*) |
746 ("prep_pbt: no '#Find' in "^(strs2str metID))*) |
747 | ((_,fi')::[]) => |
747 | ((_,fi')::[]) => |
748 ((map (split_did o term_of o the o (parse thy)) fi') |
748 ((map (split_did o term_of o the o (parse thy)) fi') |
749 handle _ => raise error |
749 handle _ => error |
750 ("prep_pbt: syntax error in '#Find' of "^ |
750 ("prep_pbt: syntax error in '#Find' of "^ |
751 (strs2str metID))) |
751 (strs2str metID))) |
752 | _ => |
752 | _ => |
753 (raise error ("prep_pbt: more than one '#Find' in "^ |
753 (error ("prep_pbt: more than one '#Find' in "^ |
754 (strs2str metID)))); |
754 (strs2str metID)))); |
755 val fi = map (pair "#Find") fi; |
755 val fi = map (pair "#Find") fi; |
756 |
756 |
757 val re = filter (eq "#Relate") ppc; |
757 val re = filter (eq "#Relate") ppc; |
758 val re = (case re of |
758 val re = (case re of |
759 [] => [] |
759 [] => [] |
760 | ((_,re')::[]) => |
760 | ((_,re')::[]) => |
761 ((map (split_did o term_of o the o (parse thy)) re') |
761 ((map (split_did o term_of o the o (parse thy)) re') |
762 handle _ => raise error |
762 handle _ => error |
763 ("prep_pbt: syntax error in '#Relate' of "^ |
763 ("prep_pbt: syntax error in '#Relate' of "^ |
764 (strs2str metID))) |
764 (strs2str metID))) |
765 | _ => |
765 | _ => |
766 (raise error ("prep_pbt: more than one '#Relate' in "^ |
766 (error ("prep_pbt: more than one '#Relate' in "^ |
767 (strs2str metID)))); |
767 (strs2str metID)))); |
768 val re = map (pair "#Relate") re; |
768 val re = map (pair "#Relate") re; |
769 |
769 |
770 val wh = filter (eq "#Where") ppc; |
770 val wh = filter (eq "#Where") ppc; |
771 val wh = (case wh of |
771 val wh = (case wh of |
772 [] => [] |
772 [] => [] |
773 | ((_,wh')::[]) => |
773 | ((_,wh')::[]) => |
774 ((map (parse_patt thy) wh') |
774 ((map (parse_patt thy) wh') |
775 handle _ => raise error |
775 handle _ => error |
776 ("prep_pbt: syntax error in '#Where' of "^ |
776 ("prep_pbt: syntax error in '#Where' of "^ |
777 (strs2str metID))) |
777 (strs2str metID))) |
778 | _ => |
778 | _ => |
779 (raise error ("prep_pbt: more than one '#Where' in "^ |
779 (error ("prep_pbt: more than one '#Where' in "^ |
780 (strs2str metID)))); |
780 (strs2str metID)))); |
781 val sc = (((inst_abs thy) o term_of o the o (parse thy)) scr) |
781 val sc = (((inst_abs thy) o term_of o the o (parse thy)) scr) |
782 in ({guh=guh,mathauthors=maa,init=init, |
782 in ({guh=guh,mathauthors=maa,init=init, |
783 ppc=gi@fi@re, pre=wh, rew_ord'=ro, erls=rls, srls=srls, prls=prls, |
783 ppc=gi@fi@re, pre=wh, rew_ord'=ro, erls=rls, srls=srls, prls=prls, |
784 calc = if scr = "empty_script" then [] |
784 calc = if scr = "empty_script" then [] |
905 *) |
905 *) |
906 | chk_ thy pbt ((i,vats,b,f,Mis (d,vs)):itm) = |
906 | chk_ thy pbt ((i,vats,b,f,Mis (d,vs)):itm) = |
907 (case find_first (eq1 d) pbt of |
907 (case find_first (eq1 d) pbt of |
908 (* val SOME (_,(_,id)) = find_first (eq1 d) pbt; |
908 (* val SOME (_,(_,id)) = find_first (eq1 d) pbt; |
909 *) |
909 *) |
910 SOME (_,(_,id)) => raise error "chk_: ((i,vats,b,f,Cor ((d,vs),\ |
910 SOME (_,(_,id)) => error "chk_: ((i,vats,b,f,Cor ((d,vs),\ |
911 \(id, pbl_ids' d vs))):itm)" |
911 \(id, pbl_ids' d vs))):itm)" |
912 | NONE => (i,vats,false,f,Sup (d,[vs]))); |
912 | NONE => (i,vats,false,f,Sup (d,[vs]))); |
913 |
913 |
914 (* chk_ thy pbt i |
914 (* chk_ thy pbt i |
915 *) |
915 *) |
1245 |
1245 |
1246 (*.make a guh from a reference to an element in the kestore; |
1246 (*.make a guh from a reference to an element in the kestore; |
1247 EXCEPT theory hierarchy ... compare 'fun keref2xml'.*) |
1247 EXCEPT theory hierarchy ... compare 'fun keref2xml'.*) |
1248 fun pblID2guh (pblID:pblID) = |
1248 fun pblID2guh (pblID:pblID) = |
1249 (((#guh o get_pbt) pblID) |
1249 (((#guh o get_pbt) pblID) |
1250 handle _ => raise error ("pblID2guh: not for '"^strs2str' pblID ^ "'")); |
1250 handle _ => error ("pblID2guh: not for '"^strs2str' pblID ^ "'")); |
1251 fun metID2guh (metID:metID) = |
1251 fun metID2guh (metID:metID) = |
1252 (((#guh o get_met) metID) |
1252 (((#guh o get_met) metID) |
1253 handle _ => raise error ("metID2guh: no 'Met_' for '"^ |
1253 handle _ => error ("metID2guh: no 'Met_' for '"^ |
1254 strs2str' metID ^ "'")); |
1254 strs2str' metID ^ "'")); |
1255 fun kestoreID2guh Pbl_ (kestoreID:kestoreID) = pblID2guh kestoreID |
1255 fun kestoreID2guh Pbl_ (kestoreID:kestoreID) = pblID2guh kestoreID |
1256 | kestoreID2guh Met_ (kestoreID:kestoreID) = metID2guh kestoreID |
1256 | kestoreID2guh Met_ (kestoreID:kestoreID) = metID2guh kestoreID |
1257 | kestoreID2guh ketype kestoreID = |
1257 | kestoreID2guh ketype kestoreID = |
1258 raise error ("kestoreID2guh: '" ^ ketype2str ketype ^ "' not for '" ^ |
1258 error ("kestoreID2guh: '" ^ ketype2str ketype ^ "' not for '" ^ |
1259 strs2str' kestoreID ^ "'"); |
1259 strs2str' kestoreID ^ "'"); |
1260 |
1260 |
1261 fun show_pblguhs () = |
1261 fun show_pblguhs () = |
1262 (print_depth 999; |
1262 (print_depth 999; |
1263 (tracing o strs2str o (map linefeed)) (coll_pblguhs (!ptyps)); |
1263 (tracing o strs2str o (map linefeed)) (coll_pblguhs (!ptyps)); |