21637
|
1 |
(* Title: Pure/ProofGeneral/pgip_isabelle.ML
|
|
2 |
ID: $Id$
|
|
3 |
Author: David Aspinall
|
|
4 |
|
22165
|
5 |
Prover-side PGIP abstraction: Isabelle configuration and mapping to Isabelle types.
|
21637
|
6 |
*)
|
|
7 |
|
|
8 |
signature PGIP_ISABELLE =
|
|
9 |
sig
|
|
10 |
val isabelle_pgml_version_supported : string
|
|
11 |
val isabelle_pgip_version_supported : string
|
|
12 |
val accepted_inputs : (string * bool * (string list)) list
|
22165
|
13 |
|
|
14 |
val location_of_position : Position.T -> PgipTypes.location
|
22403
|
15 |
|
|
16 |
(* Additional types of objects in Isar scripts *)
|
|
17 |
|
|
18 |
val ObjTheoryBody : PgipTypes.objtype
|
|
19 |
val ObjTheoryDecl : PgipTypes.objtype
|
|
20 |
val ObjTheoryBodySubsection : PgipTypes.objtype
|
|
21 |
val ObjProofBody : PgipTypes.objtype
|
|
22 |
val ObjFormalComment : PgipTypes.objtype
|
|
23 |
val ObjClass : PgipTypes.objtype
|
|
24 |
val ObjTheoremSet : PgipTypes.objtype
|
|
25 |
val ObjOracle : PgipTypes.objtype
|
|
26 |
val ObjLocale : PgipTypes.objtype
|
|
27 |
|
21637
|
28 |
end
|
|
29 |
|
|
30 |
structure PgipIsabelle : PGIP_ISABELLE =
|
|
31 |
struct
|
|
32 |
|
|
33 |
val isabelle_pgml_version_supported = "1.0";
|
|
34 |
val isabelle_pgip_version_supported = "2.0"
|
|
35 |
|
|
36 |
(** Accepted commands **)
|
|
37 |
|
|
38 |
local
|
|
39 |
|
|
40 |
(* These element names are a subset of those in pgip_input.ML.
|
|
41 |
They must be handled in proof_general_pgip.ML/process_pgip_element. *)
|
|
42 |
|
|
43 |
val accepted_names =
|
|
44 |
(* not implemented: "askconfig", "forget", "restoregoal" *)
|
|
45 |
["askpgip","askpgml","askprefs","getpref","setpref",
|
|
46 |
"proverinit","proverexit","startquiet","stopquiet",
|
|
47 |
"pgmlsymbolson", "pgmlsymbolsoff",
|
|
48 |
"dostep", "undostep", "redostep", "abortgoal",
|
|
49 |
"askids", "showid", "askguise",
|
|
50 |
"parsescript",
|
|
51 |
"showproofstate", "showctxt", "searchtheorems", "setlinewidth", "viewdoc",
|
|
52 |
"doitem", "undoitem", "redoitem", "abortheory",
|
|
53 |
"retracttheory", "loadfile", "openfile", "closefile",
|
|
54 |
"abortfile", "retractfile", "changecwd", "systemcmd"];
|
|
55 |
|
|
56 |
fun element_async p =
|
|
57 |
false (* single threaded only *)
|
|
58 |
|
|
59 |
fun supported_optional_attrs p = (case p of
|
|
60 |
"undostep" => ["times"]
|
|
61 |
(* TODO: we could probably extend these too:
|
|
62 |
| "redostep" => ["times"]
|
|
63 |
| "undoitem" => ["times"]
|
|
64 |
| "redoitem" => ["times"] *)
|
|
65 |
| _ => [])
|
|
66 |
in
|
|
67 |
val accepted_inputs =
|
|
68 |
(map (fn p=> (p, element_async p, supported_optional_attrs p))
|
|
69 |
accepted_names);
|
|
70 |
end
|
|
71 |
|
22165
|
72 |
|
|
73 |
(* Now we have to parse strings constructed elsewhere in Isabelle, which is silly!
|
|
74 |
This is another case where Isabelle should use structured types
|
|
75 |
from the ground up to help its interfaces, instead of just plain
|
|
76 |
strings.
|
|
77 |
*)
|
|
78 |
fun unquote s = case explode s of
|
|
79 |
"\""::xs => (case (rev xs) of
|
|
80 |
"\""::_ => SOME (String.substring(s,1,(String.size s) - 2))
|
|
81 |
| _ => NONE)
|
|
82 |
| _ => NONE
|
|
83 |
|
|
84 |
fun location_of_position pos =
|
|
85 |
let val line = Position.line_of pos
|
|
86 |
val (url,descr) =
|
|
87 |
(case Position.name_of pos of
|
|
88 |
NONE => (NONE,NONE)
|
|
89 |
| SOME possiblyfile =>
|
|
90 |
(case unquote possiblyfile of
|
|
91 |
SOME fname => let val path = (Path.explode fname) in
|
|
92 |
case ThyLoad.check_file NONE path of
|
|
93 |
SOME _ => (SOME (PgipTypes.pgipurl_of_path path), NONE)
|
|
94 |
| NONE => (NONE,SOME fname)
|
|
95 |
end
|
|
96 |
| _ => (NONE,SOME possiblyfile)))
|
|
97 |
in
|
|
98 |
{ descr=descr, url=url, line=line, column=NONE, char=NONE, length=NONE }
|
|
99 |
end
|
22403
|
100 |
|
|
101 |
|
|
102 |
val [ObjTheoryBody,
|
|
103 |
ObjTheoryDecl,
|
|
104 |
ObjTheoryBodySubsection,
|
|
105 |
ObjProofBody,
|
|
106 |
ObjFormalComment,
|
|
107 |
ObjClass,
|
|
108 |
ObjTheoremSet,
|
|
109 |
ObjOracle,
|
|
110 |
ObjLocale] =
|
|
111 |
map PgipTypes.ObjOther
|
|
112 |
["theory body",
|
|
113 |
"theory declaration",
|
|
114 |
"theory subsection",
|
|
115 |
"proof body",
|
|
116 |
"formal comment",
|
|
117 |
"class",
|
|
118 |
"theorem set declaration",
|
|
119 |
"oracle",
|
|
120 |
"locale"];
|
|
121 |
|
22165
|
122 |
|
21637
|
123 |
end
|
|
124 |
|