]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/matitaTypes.ml
first moogle template checkin
[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.ind"
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 parseTactical: char Stream.t -> DisambiguateTypes.tactical
68   end
69
70 class type disambiguator =
71   object
72     method parserr: parserr
73     method setParserr: parserr -> unit
74
75     method env: DisambiguateTypes.environment
76     method setEnv: DisambiguateTypes.environment -> unit
77
78       (* TODO Zack: as long as matita doesn't support MDI inteface,
79       * disambiguateTerm will return a single term *)
80       (** @param env disambiguation environment. If this parameter is given the
81       * disambiguator act statelessly, that is internal disambiguation status
82       * want be changed but only returned. If this parameter is not given the
83       * internal one will be used and updated with the disambiguation status
84       * resulting from the disambiguation *)
85     method disambiguateTerm:
86       ?context:Cic.context -> ?metasenv:Cic.metasenv ->
87       ?env:DisambiguateTypes.environment ->
88         char Stream.t ->
89           (DisambiguateTypes.environment * Cic.metasenv * Cic.term)
90       (** @param env @see disambiguateTerm above *)
91     method disambiguateTermAst:
92       ?context:Cic.context -> ?metasenv:Cic.metasenv ->
93       ?env:DisambiguateTypes.environment ->
94         DisambiguateTypes.term ->
95           (DisambiguateTypes.environment * Cic.metasenv * Cic.term)
96   end
97
98 class type proofStatus =
99   object
100     inherit subject
101
102       (** {3 properties} *)
103
104     method proof: ProofEngineTypes.proof
105     method setProof: ProofEngineTypes.proof -> unit
106
107     method goal: ProofEngineTypes.goal option
108     method setGoal: ProofEngineTypes.goal option -> unit
109
110       (** @raise MatitaTypes.No_proof *)
111     method status: ProofEngineTypes.status (* proof, goal *)
112     method setStatus: ProofEngineTypes.status -> unit
113
114       (** {3 actions} *)
115
116     (** return a pair of "xml" (as defined in Xml module) representing the *
117      * current proof type and body, respectively *)
118     method toXml: Xml.token Stream.t * Xml.token Stream.t
119     method toString: string
120   end
121
122 class type proof =
123   object
124       (** {3 status} *)
125     method status: proofStatus
126     method setStatus: proofStatus -> unit
127   end
128
129 type proof_handler =
130   { get_proof: unit -> proof; (* return current proof or fail *)
131     set_proof: proof option -> unit;  (* set a proof option as current proof *)
132     has_proof: unit -> bool;  (* check if a current proof is available or not *)
133     new_proof: proof -> unit; (* as a set_proof but takes care also to register
134                               observers *)
135     quit: unit -> unit
136   }
137
138   (** interpreter for toplevel phrases given via console *)
139 class type interpreter =
140   object
141     method evalPhrase: string -> unit
142   end
143
144 (** {2 shorthands} *)
145
146 type namer = ProofEngineTypes.mk_fresh_name_type
147
148 type choose_uris_callback =
149   selection_mode:[`MULTIPLE|`SINGLE] ->
150   ?title:string -> ?msg:string -> ?nonvars_button:bool ->
151   string list ->
152     string list
153
154 type choose_interp_callback = (string * string) list list -> int list
155