eliminate use of Thy_Info 12: prep.arg. ctxt in TermC, UnparseC
1 (* Title: BridgeLibisabelle/present-tool.sml
3 (c) due to copyright terms
5 This code remains in order to
6 keep tests of interaction Java-frontend <-> Kernel running.
9 signature PRESENTATION_TOOL =
13 val ketype2str: ketype -> string
14 val str2ketype': string -> ketype
17 val pblID2guh : Proof.context -> Problem.id -> Check_Unique.id
18 val metID2guh : (*Proof.context ->*) MethodC.id -> Check_Unique.id
19 val kestoreID2guh : Proof.context -> ketype -> kestoreID -> Check_Unique.id
20 val guh2kestoreID : Check_Unique.id -> string list
24 structure Ptool(**) : PRESENTATION_TOOL(**) =
28 (* lookup a guh in hierarchy of problems / methods depending on fst 4 chars in guh *)
29 fun guh2kestoreID guh =
30 case (implode o (take_fromto 1 4) o Symbol.explode) guh of
33 fun node ids gu (Store.Node (id, [{guh, ...}], ns)) =
34 if gu = guh then SOME (ids @ [id]) else nodes (ids @ [id]) gu ns
35 | node _ _ _ = raise ERROR "Ptool.guh2kestoreID node: uncovered fun def."
36 and nodes _ _ [] = NONE
37 | nodes ids gu (n :: ns) = case node ids gu n of
39 | NONE => nodes ids gu ns
40 in case nodes [] guh (get_pbls ()) of
42 | NONE => raise ERROR ("Ptool.guh2kestoreID: \"" ^ guh ^ "\" " ^ "not found in ptyps")
46 fun node ids gu (Store.Node (id, [{guh, ...}], ns)) =
47 if gu = guh then SOME (ids @ [id]) else nodes (ids @ [id]) gu ns
48 | node _ _ _ = raise ERROR "Ptool.guh2kestoreID node: uncovered fun def."
49 and nodes _ _ [] = NONE
50 | nodes ids gu (n :: ns) = case node ids gu n of
52 | NONE => nodes ids gu ns
53 in case nodes [] guh (get_mets ()) of
55 | NONE => raise ERROR ("Ptool.guh2kestoreID: \"" ^ guh ^ "\" " ^ "not found in mets")
57 | _ => raise ERROR ("Ptool.guh2kestoreID called with \"" ^ guh ^ "\":");
59 (* for distinction of contexts WN130621: disambiguate with Isabelle's Context *)
60 datatype ketype = Exp_ | Thy_ | Pbl_ | Met_;
61 fun ketype2str Exp_ = "Exp_"
62 | ketype2str Thy_ = "Thy_"
63 | ketype2str Pbl_ = "Pbl_"
64 | ketype2str Met_ = "Met_";
65 (* for conversion from XML *)
66 fun str2ketype' "exp" = Exp_
67 | str2ketype' "thy" = Thy_
68 | str2ketype' "pbl" = Pbl_
69 | str2ketype' "met" = Met_
70 | str2ketype' str = raise ERROR ("str2ketype': WRONG arg = " ^ str)
72 (*either ThyC.id or Problem.id or MethodC.id*)
73 type kestoreID = string list;
75 (* make a guh from a reference to an element in the kestore;
76 EXCEPT theory hierarchy ... compare 'fun keref2xml' *)
77 fun pblID2guh ctxt pblID = (((#guh o (Problem.from_store ctxt)) pblID)
78 handle ERROR _ => raise ERROR ("Ptool.pblID2guh: not for \"" ^ strs2str' pblID ^ "\""));
80 (((#guh o MethodC.from_store ("Isac_Knowledge" |> Know_Store.get_via_last_thy |> Proof_Context.init_global)) metID)
81 handle ERROR _ => raise ERROR ("metID2guh: no 'Met_' for \"" ^ strs2str' metID ^ "\""));
82 fun kestoreID2guh ctxt Pbl_ kestoreID = pblID2guh ctxt kestoreID
83 | kestoreID2guh _ Met_ kestoreID = metID2guh kestoreID
84 | kestoreID2guh _ ketyp kestoreID =
85 raise ERROR ("kestoreID2guh: \"" ^ ketype2str ketyp ^ "\" not for \"" ^ strs2str' kestoreID ^ "\"");