]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/matitaTypes.ml
snapshot, notably:
[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 open Printf
27
28 exception Not_implemented of string
29 let not_implemented feature = raise (Not_implemented feature)
30
31 exception Failure of string
32 let error s = raise (Failure s)
33 let warning s = prerr_endline ("MATITA WARNING:\t" ^ s)
34 let debug_print s =
35   if BuildTimeConf.debug then prerr_endline ("MATITA DEBUG:\t" ^ s)
36
37 let explain = function
38   | StatefulProofEngine.Tactic_failure exn ->
39       sprintf "Tactic failed: %s"(Printexc.to_string exn)
40   | StatefulProofEngine.Observer_failures exns ->
41       String.concat "\n"
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   | exn -> sprintf "Uncaught exception: %s" (Printexc.to_string exn)
47
48 exception No_proof
49
50 exception Cancel
51 exception Unbound_identifier of string
52
53 (*
54 let untitled_con_uri = UriManager.uri_of_string "cic:/untitled.con"
55 let untitled_def_uri = UriManager.uri_of_string "cic:/untitled.ind"
56
57 let unopt_uri ?(kind = `Con) = function
58   | Some uri -> uri
59   | None ->
60       (match kind with `Con -> untitled_con_uri | `Def -> untitled_def_uri)
61 *)
62 let unopt_uri = function Some uri -> uri | None -> assert false
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 console =
71   object
72     method echo_message   : string -> unit
73     method echo_error     : string -> unit
74     method clear          : unit -> unit
75     method wrap_exn       : 'a. (unit -> 'a) -> 'a option
76   end
77
78 class type disambiguator =
79   object
80     method parserr: parserr
81     method setParserr: parserr -> unit
82
83     method env: DisambiguateTypes.environment
84     method setEnv: DisambiguateTypes.environment -> unit
85
86     method disambiguateTerm:
87       ?context:Cic.context -> ?metasenv:Cic.metasenv ->
88       ?env:DisambiguateTypes.environment ->
89         char Stream.t ->
90           (DisambiguateTypes.environment * Cic.metasenv * Cic.term *
91            CicUniv.universe_graph)
92     method disambiguateTermAst:
93       ?context:Cic.context -> ?metasenv:Cic.metasenv ->
94       ?env:DisambiguateTypes.environment ->
95         DisambiguateTypes.term ->
96           (DisambiguateTypes.environment * Cic.metasenv * Cic.term *
97            CicUniv.universe_graph) 
98
99     method disambiguateTermAsts:
100       ?metasenv:Cic.metasenv ->
101       ?env:DisambiguateTypes.environment ->
102       DisambiguateTypes.term list ->
103           (DisambiguateTypes.environment * Cic.metasenv * Cic.term list *
104           CicUniv.universe_graph)
105   end
106
107 class type proof =
108   object
109     inherit [unit] StatefulProofEngine.status
110
111     method toXml: Xml.token Stream.t * Xml.token Stream.t
112     method toString: string
113   end
114
115 class type currentProof =
116   object
117     method onGoing: unit -> bool
118     method proof: proof
119     method start: proof -> unit
120     method abort: unit -> unit
121     method quit: unit -> unit
122   end
123
124 type command_outcome = bool * bool
125
126 class type interpreter =
127   object
128     method endOffset : int
129     method evalAst : DisambiguateTypes.tactical -> command_outcome
130     method evalPhrase : string -> command_outcome
131 (*     method evalStream: char Stream.t -> command_outcome *)
132     method reset : unit
133   end
134
135 class type mathViewer =
136   object
137     method checkTerm: Cic.conjecture -> Cic.metasenv -> unit
138     method unload: unit -> unit
139     method set_href_callback: (UriManager.uri -> unit) option -> unit
140   end
141
142 type mml_of_cic_sequent =
143   Cic.metasenv -> Cic.conjecture ->
144     Gdome.document *
145     ((Cic.id, Cic.term) Hashtbl.t *
146     (Cic.id, Cic.id option) Hashtbl.t *
147     (string, Cic.hypothesis) Hashtbl.t)
148
149 type mml_of_cic_object =
150   explode_all:bool -> UriManager.uri -> Cic.annobj ->
151   (string, string) Hashtbl.t -> (string, Cic2acic.anntypes) Hashtbl.t ->
152     Gdome.document
153
154 type namer = ProofEngineTypes.mk_fresh_name_type
155
156 type choose_uris_callback =
157   selection_mode:[`MULTIPLE|`SINGLE] ->
158   ?title:string -> ?msg:string -> ?nonvars_button:bool ->
159   string list ->
160     string list
161 type choose_interp_callback = (string * string) list list -> int list
162
163 let mono_uris_callback ~selection_mode ?title ?msg ?nonvars_button _ =
164   raise (Failure "ambiguous input")
165 let mono_interp_callback _ = raise (Failure "ambiguous input")
166