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/
28 exception Not_implemented of string
29 let not_implemented feature = raise (Not_implemented feature)
31 exception Failure of string
32 let error s = raise (Failure s)
33 let warning s = prerr_endline ("MATITA WARNING:\t" ^ s)
35 if BuildTimeConf.debug then prerr_endline ("MATITA DEBUG:\t" ^ s)
37 let explain = function
38 | StatefulProofEngine.Tactic_failure exn ->
39 sprintf "Tactic failed: %s"(Printexc.to_string exn)
40 | StatefulProofEngine.Observer_failures exns ->
42 (List.map (fun (_, exn) -> Printexc.to_string exn) exns)
43 | CicTextualParser2.Parse_error (floc, msg) ->
44 let (x, y) = CicAst.loc_of_floc floc in
45 sprintf "parse error at character %d-%d: %s" x y msg
46 | CicEnvironment.Object_not_found uri ->
47 sprintf "object not found: %s" (UriManager.string_of_uri uri)
48 | exn -> sprintf "Uncaught exception: %s" (Printexc.to_string exn)
53 exception Unbound_identifier of string
56 let untitled_con_uri = UriManager.uri_of_string "cic:/untitled.con"
57 let untitled_def_uri = UriManager.uri_of_string "cic:/untitled.ind"
59 let unopt_uri ?(kind = `Con) = function
62 (match kind with `Con -> untitled_con_uri | `Def -> untitled_def_uri)
64 let unopt_uri = function Some uri -> uri | None -> assert false
66 class type parserr = (* "parser" is a keyword :-( *)
68 method parseTerm: char Stream.t -> DisambiguateTypes.term
69 method parseTactical: char Stream.t -> DisambiguateTypes.tactical
74 method echo_message : string -> unit
75 method echo_error : string -> unit
76 method clear : unit -> unit
77 method wrap_exn : 'a. (unit -> 'a) -> 'a option
80 type choose_uris_callback =
81 selection_mode:[`MULTIPLE|`SINGLE] ->
82 ?title:string -> ?msg:string -> ?nonvars_button:bool ->
85 type choose_interp_callback = (string * string) list list -> int list
87 class type disambiguator =
89 method env: DisambiguateTypes.environment
90 method setEnv: DisambiguateTypes.environment -> unit
92 method chooseUris: choose_uris_callback
93 method setChooseUris: choose_uris_callback -> unit
95 method chooseInterp: choose_interp_callback
96 method setChooseInterp: choose_interp_callback -> unit
98 method parserr: parserr
100 method disambiguateTerm:
101 ?context:Cic.context -> ?metasenv:Cic.metasenv ->
102 ?env:DisambiguateTypes.environment ->
104 (DisambiguateTypes.environment * Cic.metasenv * Cic.term *
105 CicUniv.universe_graph)
106 method disambiguateTermAst:
107 ?context:Cic.context -> ?metasenv:Cic.metasenv ->
108 ?env:DisambiguateTypes.environment ->
109 DisambiguateTypes.term ->
110 (DisambiguateTypes.environment * Cic.metasenv * Cic.term *
111 CicUniv.universe_graph)
113 method disambiguateTermAsts:
114 ?metasenv:Cic.metasenv ->
115 ?env:DisambiguateTypes.environment ->
116 DisambiguateTypes.term list ->
117 (DisambiguateTypes.environment * Cic.metasenv * Cic.term list *
118 CicUniv.universe_graph)
123 inherit [unit] StatefulProofEngine.status
125 method toXml: Xml.token Stream.t * Xml.token Stream.t
126 method toString: string
129 class type currentProof =
131 method onGoing: unit -> bool
133 method start: proof -> unit
134 method abort: unit -> unit
135 method quit: unit -> unit
138 type command_outcome = bool * bool
140 class type interpreter =
142 method endOffset : int
143 method evalAst : DisambiguateTypes.tactical -> command_outcome
144 method evalPhrase : string -> command_outcome
145 (* method evalStream: char Stream.t -> command_outcome *)
150 [ `Ast of DisambiguateTypes.term
155 class type mathViewer =
157 method checkTerm: term_source -> unit
160 class type cicBrowser =
162 method loadUri: string -> unit
163 method loadTerm: term_source -> unit
166 type mml_of_cic_sequent =
167 Cic.metasenv -> Cic.conjecture ->
169 ((Cic.id, Cic.term) Hashtbl.t *
170 (Cic.id, Cic.id option) Hashtbl.t *
171 (string, Cic.hypothesis) Hashtbl.t)
173 type mml_of_cic_object =
174 explode_all:bool -> UriManager.uri -> Cic.annobj ->
175 (string, string) Hashtbl.t -> (string, Cic2acic.anntypes) Hashtbl.t ->
178 type namer = ProofEngineTypes.mk_fresh_name_type
180 let mono_uris_callback ~selection_mode ?title ?msg ?nonvars_button _ =
181 raise (Failure "ambiguous input")
182 let mono_interp_callback _ = raise (Failure "ambiguous input")