277 |
277 |
278 |
278 |
279 (*.to an input (d,ts) find the according ori and insert the ts.*) |
279 (*.to an input (d,ts) find the according ori and insert the ts.*) |
280 (*WN.11.03: + dont take first inter<>[]*) |
280 (*WN.11.03: + dont take first inter<>[]*) |
281 fun seek_oridts thy sel (d,ts) [] = |
281 fun seek_oridts thy sel (d,ts) [] = |
282 ("'"^(string_of_cterm (comp_dts thy (d,ts)))^ |
282 ("'"^(Syntax.string_of_term (thy2ctxt' thy) (comp_dts thy (d,ts)))^ |
283 (*"' not found (typed)", e_ori_:ori, []) ///11.11.03*) |
283 (*"' not found (typed)", e_ori_:ori, []) ///11.11.03*) |
284 "' not found (typed)", (0,[],sel,d,ts):ori, []) |
284 "' not found (typed)", (0,[],sel,d,ts):ori, []) |
285 (* val (id,vat,sel',d',ts')::oris = ori; |
285 (* val (id,vat,sel',d',ts')::oris = ori; |
286 val (id,vat,sel',d',ts') = ori; |
286 val (id,vat,sel',d',ts') = ori; |
287 *) |
287 *) |
288 | seek_oridts thy sel (d,ts) ((id,vat,sel',d',ts')::(oris:ori list)) = |
288 | seek_oridts thy sel (d,ts) ((id,vat,sel',d',ts')::(oris:ori list)) = |
289 if sel = sel' andalso d=d' andalso (ts inter ts') <> [] |
289 if sel = sel' andalso d=d' andalso (ts inter ts') <> [] |
290 then if sel = sel' |
290 then if sel = sel' |
291 then ("",(id,vat,sel,d, ts inter(*!overlap!*) ts'):ori, ts') |
291 then ("",(id,vat,sel,d, ts inter(*!overlap!*) ts'):ori, ts') |
292 else ((string_of_cterm (comp_dts thy(d,ts)))^ |
292 else ((Syntax.string_of_term (thy2ctxt' thy) (comp_dts thy(d,ts)))^ |
293 " not for "^sel, e_ori_, []) |
293 " not for "^sel, e_ori_, []) |
294 else seek_oridts thy sel (d,ts) oris; |
294 else seek_oridts thy sel (d,ts) oris; |
295 |
|
296 (*FIXXXME.WN.11.03: + dont take first inter<>[] .. ev. variants are following: |
|
297 thus take largest intersection !!! |
|
298 if sel NOTok .. then the correct itm should NOT be overwritten by insert_ppc*) |
|
299 (*fun eq7 d (_,_,_,d',_) = d = d'; |
|
300 fun inter_length ((_,_,_,_,ts), (_,_,_,_,ts')) = (length ts) < (length ts'); |
|
301 fun seek_oridts _ sel (d,ts) [] = |
|
302 ("'"^(string_of_cterm (comp_dts thy (d,ts)))^ |
|
303 (*"' not found (typed)", e_ori_:ori, []) ///11.11.03*) |
|
304 "' not found (typed)", (0,[],sel,d,ts):ori, []) |
|
305 (* val (id,vat,sel',d',ts')::oris = ori; |
|
306 val (id,vat,sel',d',ts') = ori; |
|
307 *) |
|
308 | seek_oridts _ sel (d,ts) oris = |
|
309 let val dscOK = filter (eq7 d) oris; |
|
310 in if dscOK = [] then ("'"^(string_of_cterm (comp_dts thy (d,ts)))^ |
|
311 "' not found (typed)", (0,[],sel,d,ts):ori, []) |
|
312 else let val (id,vat,sel',d',ts') = gen_max inter_length dscOK; |
|
313 in if sel = sel' then ("",(id,vat,sel,d,ts inter ts'), []) |
|
314 else ("wrong field",(id,vat,sel,d,ts inter ts'), []) end |
|
315 end; |
|
316 --------------------didnt work with Add_Given/_Find/_Relation 11.03*) |
|
317 |
295 |
318 (*.to an input (_,ts) find the according ori and insert the ts.*) |
296 (*.to an input (_,ts) find the according ori and insert the ts.*) |
319 fun seek_orits thy sel ts [] = |
297 fun seek_orits thy sel ts [] = |
320 ("'"^ |
298 ("'"^ |
321 (strs2str (map (Sign.string_of_term (sign_of thy)) ts))^ |
299 (strs2str (map (Syntax.string_of_term (thy2ctxt' thy)) ts))^ |
322 "' not found (typed)", e_ori_, []) |
300 "' not found (typed)", e_ori_, []) |
323 | seek_orits thy sel ts ((id,vat,sel',d,ts')::(oris:ori list)) = |
301 | seek_orits thy sel ts ((id,vat,sel',d,ts')::(oris:ori list)) = |
324 if sel = sel' andalso (ts inter ts') <> [] |
302 if sel = sel' andalso (ts inter ts') <> [] |
325 then if sel = sel' |
303 then if sel = sel' |
326 then ("",(id,vat,sel,d,ts inter(*!overlap!*) ts'):ori, ts') |
304 then ("",(id,vat,sel,d,ts inter(*!overlap!*) ts'):ori, ts') |
327 else (((strs2str' o map (Sign.string_of_term (sign_of thy))) ts)^ |
305 else (((strs2str' o map (Syntax.string_of_term (thy2ctxt' thy))) ts)^ |
328 " not for "^sel, e_ori_, []) |
306 " not for "^sel, e_ori_, []) |
329 else seek_orits thy sel ts oris; |
307 else seek_orits thy sel ts oris; |
330 (* false |
308 (* false |
331 > val ((id,vat,sel',d,ts')::(ori':ori)) = ori; |
309 > val ((id,vat,sel',d,ts')::(ori':ori)) = ori; |
332 > seek_orits thy sel ts [(id,vat,sel',d,ts')]; |
310 > seek_orits thy sel ts [(id,vat,sel',d,ts')]; |
797 SOME (_,_,_,_,itm_) => |
775 SOME (_,_,_,_,itm_) => |
798 let |
776 let |
799 val ts' = (ts_in itm_) inter ts; |
777 val ts' = (ts_in itm_) inter ts; |
800 in if ts subset ts' |
778 in if ts subset ts' |
801 then (((strs2str' o |
779 then (((strs2str' o |
802 map (Sign.string_of_term (sign_of thy))) ts')^ |
780 map (Syntax.string_of_term (thy2ctxt' thy))) ts')^ |
803 " already input", e_itm) (*2*) |
781 " already input", e_itm) (*2*) |
804 else ("", ori_2itm thy itm_ pid all (i,v,f,d,ts\\ts')) (*3,4*) |
782 else ("", ori_2itm thy itm_ pid all (i,v,f,d,ts\\ts')) (*3,4*) |
805 end |
783 end |
806 | NONE => ("", ori_2itm thy (Inc ((e_term,[]),(pid,[]))) |
784 | NONE => ("", ori_2itm thy (Inc ((e_term,[]),(pid,[]))) |
807 pid all (i,v,f,d,ts)) (*1*) |
785 pid all (i,v,f,d,ts)) (*1*) |
1865 then ("re\\(gi union fi)",re\\(gi union fi)) |
1843 then ("re\\(gi union fi)",re\\(gi union fi)) |
1866 else ("ok",[]) end;*) |
1844 else ("ok",[]) end;*) |
1867 fun chk_vars ctppc = |
1845 fun chk_vars ctppc = |
1868 let val {Given=gi,Where=wh,Find=fi,With=wi,Relate=re} = |
1846 let val {Given=gi,Where=wh,Find=fi,With=wi,Relate=re} = |
1869 appc flat (mappc (vars o term_of) ctppc) |
1847 appc flat (mappc (vars o term_of) ctppc) |
1870 in let val chked = subtract op = gi wh |
1848 val chked = subtract op = gi wh |
1871 if chked <> [] then ("wh\\gi", chked) |
1849 in if chked <> [] then ("wh\\gi", chked) |
1872 else let val chked = subtract op = (union op = gi fi) re |
1850 else let val chked = subtract op = (union op = gi fi) re |
1873 if chked <> [] |
1851 in if chked <> [] |
1874 then ("re\\(gi union fi)", chked) |
1852 then ("re\\(gi union fi)", chked) |
1875 else ("ok", []) end; |
1853 else ("ok", []) |
|
1854 end |
|
1855 end; |
1876 |
1856 |
1877 (* check a new pbltype: variables (Free) unbound by given, find*) |
1857 (* check a new pbltype: variables (Free) unbound by given, find*) |
1878 fun unbound_ppc ctppc = |
1858 fun unbound_ppc ctppc = |
1879 let val {Given=gi,Find=fi,Relate=re,...} = |
1859 let val {Given=gi,Find=fi,Relate=re,...} = |
1880 appc flat (mappc (vars o term_of) ctppc) |
1860 appc flat (mappc (vars o term_of) ctppc) |