src/Pure/ProofGeneral/pgip_isabelle.ML
author berghofe
Wed, 07 Feb 2007 17:30:53 +0100
changeset 22264 6a65e9b2ae05
parent 22165 eaec72532dd7
child 22403 12892a6677c6
permissions -rw-r--r--
Theorems for converting between wf and wfP are now declared as hints.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     1
(*  Title:      Pure/ProofGeneral/pgip_isabelle.ML
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     2
    ID:         $Id$
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     3
    Author:     David Aspinall
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     4
22165
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
     5
Prover-side PGIP abstraction: Isabelle configuration and mapping to Isabelle types.
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     6
*)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     7
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     8
signature PGIP_ISABELLE =
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
     9
sig
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    10
    val isabelle_pgml_version_supported : string
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    11
    val isabelle_pgip_version_supported : string
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    12
    val accepted_inputs : (string * bool * (string list)) list 
22165
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    13
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    14
    val location_of_position : Position.T -> PgipTypes.location
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    15
end
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    16
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    17
structure PgipIsabelle : PGIP_ISABELLE =
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    18
struct
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    19
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    20
val isabelle_pgml_version_supported = "1.0";
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    21
val isabelle_pgip_version_supported = "2.0"
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    22
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    23
(** Accepted commands **)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    24
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    25
local
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    26
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    27
    (* These element names are a subset of those in pgip_input.ML.
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    28
       They must be handled in proof_general_pgip.ML/process_pgip_element. *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    29
						    
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    30
    val accepted_names =
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    31
    (* not implemented: "askconfig", "forget", "restoregoal" *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    32
    ["askpgip","askpgml","askprefs","getpref","setpref",
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    33
     "proverinit","proverexit","startquiet","stopquiet",
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    34
     "pgmlsymbolson", "pgmlsymbolsoff",
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    35
     "dostep", "undostep", "redostep", "abortgoal", 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    36
     "askids", "showid", "askguise",
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    37
     "parsescript",
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    38
     "showproofstate", "showctxt", "searchtheorems", "setlinewidth", "viewdoc",
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    39
     "doitem", "undoitem", "redoitem", "abortheory",
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    40
     "retracttheory", "loadfile", "openfile", "closefile",
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    41
     "abortfile", "retractfile", "changecwd", "systemcmd"];
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    42
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    43
    fun element_async p = 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    44
	false (* single threaded only *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    45
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    46
    fun supported_optional_attrs p = (case p of
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    47
					  "undostep" => ["times"]
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    48
					(* TODO: we could probably extend these too:
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    49
					| "redostep" => ["times"]
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    50
					| "undoitem" => ["times"]
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    51
					| "redoitem" => ["times"] *)
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    52
				        | _ => [])
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    53
in
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    54
val accepted_inputs = 
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    55
    (map (fn p=> (p, element_async p, supported_optional_attrs p))
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    56
         accepted_names);
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    57
end
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    58
22165
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    59
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    60
(* Now we have to parse strings constructed elsewhere in Isabelle, which is silly!
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    61
   This is another case where Isabelle should use structured types
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    62
   from the ground up to help its interfaces, instead of just plain
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    63
   strings.
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    64
*)
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    65
fun unquote s = case explode s of 
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    66
		    "\""::xs => (case (rev xs) of
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    67
				    "\""::_ => SOME (String.substring(s,1,(String.size s) - 2))
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    68
			         | _ => NONE)
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    69
		  | _ => NONE
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    70
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    71
fun location_of_position pos = 
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    72
    let val line = Position.line_of pos
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    73
	val (url,descr) = 
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    74
	    (case Position.name_of pos of
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    75
		 NONE => (NONE,NONE)
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    76
	       | SOME possiblyfile => 
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    77
		 (case unquote possiblyfile of
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    78
		      SOME fname => let val path = (Path.explode fname) in
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    79
					case ThyLoad.check_file NONE path of
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    80
					    SOME _ => (SOME (PgipTypes.pgipurl_of_path path), NONE)
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    81
					  | NONE => (NONE,SOME fname)
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    82
				    end
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    83
		    | _ => (NONE,SOME possiblyfile)))
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    84
    in 
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    85
	{ descr=descr, url=url, line=line, column=NONE, char=NONE, length=NONE }
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    86
    end 
eaec72532dd7 Add location_of_position. Needs work elsewhere.
aspinall
parents: 21940
diff changeset
    87
	
21637
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    88
end
a7b156c404e2 Revamped Proof General interface.
aspinall
parents:
diff changeset
    89