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