1 (* Copyright (C) 2004, HELM Team.
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.
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.
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.
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,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
26 (** exceptions whose content should be presented to the user *)
27 exception Not_implemented of string
28 exception Failure of string
30 val not_implemented : string -> 'a
31 val error : string -> 'a
32 val warning : string -> unit
33 val debug_print : string -> unit
35 exception No_proof (** no current proof is available *)
37 exception Unbound_identifier of string
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
44 val unopt_uri : 'a option -> 'a
46 (** {3 disambiguator callbacks} *)
48 type choose_uris_callback =
49 selection_mode:[ `MULTIPLE | `SINGLE ] ->
51 ?msg:string -> ?nonvars_button:bool -> string list -> string list
53 type choose_interp_callback = (string * string) list list -> int list
55 (** @raise Failure if called, use if unambiguous input is required *)
56 val mono_uris_callback: choose_uris_callback
57 (** @raise Failure if called, use if unambiguous input is required *)
58 val mono_interp_callback: choose_interp_callback
60 (** {2 major matita objects} *)
64 method parseTactical : char Stream.t -> DisambiguateTypes.tactical
65 method parseTerm : char Stream.t -> DisambiguateTypes.term
68 (* subset of MatitaConsole.console methods needed by MatitaInterpreter *)
71 method clear : unit -> unit
72 method echo_error : string -> unit
73 method echo_message : string -> unit
74 method wrap_exn : 'a. (unit -> 'a) -> 'a option
77 class type disambiguator =
79 method env : DisambiguateTypes.environment
80 method setEnv : DisambiguateTypes.environment -> unit
82 method chooseUris: choose_uris_callback
83 method setChooseUris: choose_uris_callback -> unit
85 method chooseInterp: choose_interp_callback
86 method setChooseInterp: choose_interp_callback -> unit
88 method parserr: parserr
90 (* TODO Zack: as long as matita doesn't support MDI inteface,
91 * disambiguateTerm will return a single term *)
92 (** @param env disambiguation environment. If this parameter is given the
93 * disambiguator act statelessly, that is internal disambiguation status
94 * want be changed but only returned. If this parameter is not given the
95 * internal one will be used and updated with the disambiguation status
96 * resulting from the disambiguation *)
97 method disambiguateTerm :
98 ?context:Cic.context ->
99 ?metasenv:Cic.metasenv ->
100 ?env:DisambiguateTypes.environment ->
102 DisambiguateTypes.environment * Cic.metasenv * Cic.term *
103 CicUniv.universe_graph
105 (** @param env @see disambiguateTerm above *)
106 method disambiguateTermAst :
107 ?context:Cic.context ->
108 ?metasenv:Cic.metasenv ->
109 ?env:DisambiguateTypes.environment ->
110 DisambiguateTypes.term ->
111 DisambiguateTypes.environment * Cic.metasenv * Cic.term *
112 CicUniv.universe_graph
114 (** as disambiguateTermAst, but disambiguate a list of ASTs at once. All
115 * AST should be closed hence no context param is permitted on this method
117 method disambiguateTermAsts :
118 ?metasenv:Cic.metasenv ->
119 ?env:DisambiguateTypes.environment ->
120 DisambiguateTypes.term list ->
121 DisambiguateTypes.environment * Cic.metasenv * Cic.term list *
122 CicUniv.universe_graph
127 inherit [unit] StatefulProofEngine.status
129 (** return a pair of "xml" (as defined in Xml module) representing the *
130 * current proof type and body, respectively *)
131 method toXml : Xml.token Stream.t * Xml.token Stream.t
133 method toString : string
136 class type currentProof =
138 method onGoing: unit -> bool (** true if a proof is on going *)
139 method proof: proof (** @raise Failure "No current proof" *)
140 method start: proof -> unit (** starts a new proof *)
141 method abort: unit -> unit (** abort the on going proof *)
142 method quit: unit -> unit (** quit matita *)
145 (** first component represents success: true = success, false = failure
146 * second component represents console action: true = hide, false = keep *)
147 type command_outcome = bool * bool
149 (** interpreter for toplevel phrases given via console *)
150 class type interpreter =
152 method reset: unit (** return the interpreter to the initial state *)
154 (** parse a single phrase contained in the input string. Additional
155 * garbage at the end of the phrase is ignored
156 * @return true if no exception has been raised by the evaluation, false
159 method evalPhrase: string -> command_outcome
161 (** as evalPhrase above, but parses a character stream. Only characters
162 * composing next phrases are consumed *)
163 (* method evalStream: char Stream.t -> command_outcome *)
165 (** as above, evaluating a command/tactics AST *)
166 method evalAst: DisambiguateTypes.tactical -> command_outcome
168 (** offset from the starting of the last string parser by evalPhrase where
170 * @raise Failure when no offset has been recorded *)
171 method endOffset: int
175 (** {2 MathML widgets} *)
178 [ `Ast of DisambiguateTypes.term
183 class type mathViewer =
185 method checkTerm: term_source -> unit
188 class type cicBrowser =
190 method loadUri: string -> unit
191 method loadTerm: term_source -> unit
194 type mml_of_cic_sequent =
198 ((Cic.id, Cic.term) Hashtbl.t * (Cic.id, Cic.id option) Hashtbl.t *
199 (string, Cic.hypothesis) Hashtbl.t)
201 type mml_of_cic_object =
205 (string, string) Hashtbl.t ->
206 (string, Cic2acic.anntypes) Hashtbl.t -> Gdome.document
208 (** {2 shorthands} *)
210 type namer = ProofEngineTypes.mk_fresh_name_type