]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/matitaTypes.ml
snapshot
[helm.git] / helm / matita / matitaTypes.ml
1 (* Copyright (C) 2004, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 exception Not_implemented of string
27 let not_implemented feature = raise (Not_implemented feature)
28
29   (** exceptions whose content should be presented to the user *)
30 exception Failure of string
31 let error s = raise (Failure s)
32 let warning s = prerr_endline ("MATITA WARNING:\t" ^ s)
33 let debug_print s =
34   if BuildTimeConf.debug then prerr_endline ("MATITA DEBUG:\t" ^ s)
35
36 exception No_proof  (** no current proof is available *)
37
38 let untitled_con_uri = UriManager.uri_of_string "cic:/untitled.con"
39 let untitled_def_uri = UriManager.uri_of_string "cic:/untitled.def"
40
41 class type observer =
42   (* "observer" pattern *)
43   object
44     method update: unit -> unit
45   end
46
47 class subject =
48   (* "observer" pattern *)
49   object
50     val mutable observers = []
51     method attach (o: observer) = observers <- o :: observers
52     method detach (o: observer) =
53       observers <- List.filter (fun o' -> o' != o) observers
54     method notify () = List.iter (fun o -> o#update ()) observers
55   end
56
57 class type command =
58   (* "command" pattern *)
59   object
60     method execute: unit -> unit
61     method undo: unit -> unit
62   end
63
64 class type parserr =  (* "parser" is a keyword :-( *)
65   object
66     method parseTerm:     char Stream.t -> DisambiguateTypes.term
67     method parseTactic:   char Stream.t -> DisambiguateTypes.tactic
68     method parseTactical: char Stream.t -> DisambiguateTypes.tactical
69     method parseCommand:  char Stream.t -> DisambiguateTypes.command
70     method parseScript:   char Stream.t -> DisambiguateTypes.script
71   end
72
73 class type disambiguator =
74   object
75     method parserr: parserr
76     method setParserr: parserr -> unit
77
78     method env: DisambiguateTypes.environment
79     method setEnv: DisambiguateTypes.environment -> unit
80
81       (* TODO Zack: as long as matita doesn't support MDI inteface,
82       * disambiguateTerm will return a single term *)
83       (** @param env defaults to self#env *)
84     method disambiguateTerm:
85       ?context:Cic.context -> ?metasenv:Cic.metasenv ->
86       ?env:DisambiguateTypes.environment ->
87         char Stream.t ->
88           (DisambiguateTypes.environment * Cic.metasenv * Cic.term)
89     method disambiguateTermAst:
90       ?context:Cic.context -> ?metasenv:Cic.metasenv ->
91       ?env:DisambiguateTypes.environment ->
92         DisambiguateTypes.term ->
93           (DisambiguateTypes.environment * Cic.metasenv * Cic.term)
94   end
95
96 class type proofStatus =
97   object
98     inherit subject
99
100       (** {3 properties} *)
101
102     method proof: ProofEngineTypes.proof
103     method setProof: ProofEngineTypes.proof -> unit
104
105     method goal: ProofEngineTypes.goal option
106     method setGoal: ProofEngineTypes.goal option -> unit
107
108       (** @raise MatitaTypes.No_proof *)
109     method status: ProofEngineTypes.status (* proof, goal *)
110     method setStatus: ProofEngineTypes.status -> unit
111
112       (** {3 actions} *)
113
114     (** return a pair of "xml" (as defined in Xml module) representing the *
115      * current proof type and body, respectively *)
116     method toXml: Xml.token Stream.t * Xml.token Stream.t
117     method toString: string
118   end
119
120 class type proof =
121   object
122       (** {3 status} *)
123     method status: proofStatus
124     method setStatus: proofStatus -> unit
125   end
126
127 (** {2 shorthands} *)
128
129 type namer = ProofEngineTypes.mk_fresh_name_type
130
131 type choose_uris_callback =
132   selection_mode:[`MULTIPLE|`SINGLE] ->
133   ?title:string -> ?msg:string -> ?nonvars_button:bool ->
134   string list ->
135     string list
136
137 type choose_interp_callback = (string * string) list list -> int list
138