]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/matitaTypes.mli
snapshot, notably:
[helm.git] / helm / matita / matitaTypes.mli
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   (** exceptions whose content should be presented to the user *)
27 exception Not_implemented of string
28 exception Failure of string
29
30 val not_implemented : string -> 'a
31 val error : string -> 'a
32 val warning : string -> unit
33 val debug_print : string -> unit
34
35 exception No_proof  (** no current proof is available *)
36 exception Cancel
37 exception Unbound_identifier of string
38
39   (** @param exn an exception
40   * @return a string which is meant to be a textual explaination of the
41    exception understandable by a user *)
42 val explain: exn -> string
43
44 val unopt_uri : 'a option -> 'a
45
46 class type parserr =
47   object
48     method parseTactical : char Stream.t -> DisambiguateTypes.tactical
49     method parseTerm : char Stream.t -> DisambiguateTypes.term
50   end
51
52   (* subset of MatitaConsole.console methods needed by MatitaInterpreter *)
53 class type console =
54   object
55     method clear : unit -> unit
56     method echo_error : string -> unit
57     method echo_message : string -> unit
58     method wrap_exn : 'a. (unit -> 'a) -> 'a option
59   end
60
61 class type disambiguator =
62   object
63     method parserr : parserr
64     method setParserr : parserr -> unit
65
66     method env : DisambiguateTypes.environment
67     method setEnv : DisambiguateTypes.environment -> unit
68
69       (* TODO Zack: as long as matita doesn't support MDI inteface,
70       * disambiguateTerm will return a single term *)
71       (** @param env disambiguation environment. If this parameter is given the
72       * disambiguator act statelessly, that is internal disambiguation status
73       * want be changed but only returned. If this parameter is not given the
74       * internal one will be used and updated with the disambiguation status
75       * resulting from the disambiguation *)
76     method disambiguateTerm :
77       ?context:Cic.context ->
78       ?metasenv:Cic.metasenv ->
79       ?env:DisambiguateTypes.environment ->
80       char Stream.t ->
81       DisambiguateTypes.environment * Cic.metasenv * Cic.term *
82       CicUniv.universe_graph
83
84       (** @param env @see disambiguateTerm above *)
85     method disambiguateTermAst :
86       ?context:Cic.context ->
87       ?metasenv:Cic.metasenv ->
88       ?env:DisambiguateTypes.environment ->
89       DisambiguateTypes.term ->
90       DisambiguateTypes.environment * Cic.metasenv * Cic.term *
91       CicUniv.universe_graph
92
93       (** as disambiguateTermAst, but disambiguate a list of ASTs at once. All
94       * AST should be closed hence no context param is permitted on this method
95       *)
96     method disambiguateTermAsts :
97       ?metasenv:Cic.metasenv ->
98       ?env:DisambiguateTypes.environment ->
99       DisambiguateTypes.term list ->
100       DisambiguateTypes.environment * Cic.metasenv * Cic.term list *
101       CicUniv.universe_graph
102   end
103
104 class type proof =
105   object
106     inherit [unit] StatefulProofEngine.status
107
108     (** return a pair of "xml" (as defined in Xml module) representing the *
109      * current proof type and body, respectively *)
110     method toXml : Xml.token Stream.t * Xml.token Stream.t
111
112     method toString : string
113   end
114
115 class type currentProof =
116   object
117     method onGoing: unit -> bool  (** true if a proof is on going *)
118     method proof: proof           (** @raise Failure "No current proof" *)
119     method start: proof -> unit   (** starts a new proof *)
120     method abort: unit -> unit    (** abort the on going proof *)
121     method quit: unit -> unit     (** quit matita *)
122   end
123
124   (** first component represents success: true = success, false = failure
125   * second component represents console action: true = hide, false = keep *)
126 type command_outcome = bool * bool
127
128   (** interpreter for toplevel phrases given via console *)
129 class type interpreter =
130   object
131     method reset: unit  (** return the interpreter to the initial state *)
132
133       (** parse a single phrase contained in the input string. Additional
134       * garbage at the end of the phrase is ignored
135       * @return true if no exception has been raised by the evaluation, false
136       * otherwise
137       *)
138     method evalPhrase: string -> command_outcome
139
140       (** as evalPhrase above, but parses a character stream. Only characters
141       * composing next phrases are consumed *)
142 (*     method evalStream: char Stream.t -> command_outcome *)
143
144       (** as above, evaluating a command/tactics AST *)
145     method evalAst: DisambiguateTypes.tactical -> command_outcome
146
147       (** offset from the starting of the last string parser by evalPhrase where
148       * parsing stop.
149       * @raise Failure when no offset has been recorded *)
150     method endOffset: int
151
152   end
153
154 (** {2 MathML widgets} *)
155
156 class type mathViewer =
157   object
158     method checkTerm: Cic.conjecture -> Cic.metasenv -> unit
159     method unload: unit -> unit
160     method set_href_callback: (UriManager.uri -> unit) option -> unit
161   end
162
163 type mml_of_cic_sequent =
164   Cic.metasenv ->
165   Cic.conjecture ->
166   Gdome.document *
167   ((Cic.id, Cic.term) Hashtbl.t * (Cic.id, Cic.id option) Hashtbl.t *
168    (string, Cic.hypothesis) Hashtbl.t)
169
170 type mml_of_cic_object =
171   explode_all:bool ->
172   UriManager.uri ->
173   Cic.annobj ->
174   (string, string) Hashtbl.t ->
175   (string, Cic2acic.anntypes) Hashtbl.t -> Gdome.document
176
177 (** {2 shorthands} *)
178
179 type namer = ProofEngineTypes.mk_fresh_name_type
180
181   (** {3 disambiguator callbacks} *)
182
183 type choose_uris_callback =
184   selection_mode:[ `MULTIPLE | `SINGLE ] ->
185   ?title:string ->
186   ?msg:string -> ?nonvars_button:bool -> string list -> string list
187
188 type choose_interp_callback = (string * string) list list -> int list
189
190   (** @raise Failure if called, use if unambiguous input is required *)
191 val mono_uris_callback: choose_uris_callback
192   (** @raise Failure if called, use if unambiguous input is required *)
193 val mono_interp_callback: choose_interp_callback
194