]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/matitaTypes.ml
snapshot
[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 let unopt_uri ?(kind = `Con) = function
42   | Some uri -> uri
43   | None ->
44       (match kind with `Con -> untitled_con_uri | `Def -> untitled_def_uri)
45
46 class type parserr =  (* "parser" is a keyword :-( *)
47   object
48     method parseTerm:     char Stream.t -> DisambiguateTypes.term
49     method parseTactical: char Stream.t -> DisambiguateTypes.tactical
50   end
51
52 class type disambiguator =
53   object
54     method parserr: parserr
55     method setParserr: parserr -> unit
56
57     method env: DisambiguateTypes.environment
58     method setEnv: DisambiguateTypes.environment -> unit
59
60       (* TODO Zack: as long as matita doesn't support MDI inteface,
61       * disambiguateTerm will return a single term *)
62       (** @param env disambiguation environment. If this parameter is given the
63       * disambiguator act statelessly, that is internal disambiguation status
64       * want be changed but only returned. If this parameter is not given the
65       * internal one will be used and updated with the disambiguation status
66       * resulting from the disambiguation *)
67     method disambiguateTerm:
68       ?context:Cic.context -> ?metasenv:Cic.metasenv ->
69       ?env:DisambiguateTypes.environment ->
70         char Stream.t ->
71           (DisambiguateTypes.environment * Cic.metasenv * Cic.term)
72       (** @param env @see disambiguateTerm above *)
73     method disambiguateTermAst:
74       ?context:Cic.context -> ?metasenv:Cic.metasenv ->
75       ?env:DisambiguateTypes.environment ->
76         DisambiguateTypes.term ->
77           (DisambiguateTypes.environment * Cic.metasenv * Cic.term)
78   end
79
80 type hist_metadata =
81   (                                         (** proof object part *)
82     (Cic.annobj *                             (** annotated object    *)
83     (Cic.id, Cic.term) Hashtbl.t *            (** ids_to_terms        *)
84     (Cic.id, Cic.id option) Hashtbl.t *       (** ids_to_father_ids   *)
85     (Cic.id, string) Hashtbl.t *              (** ids_to_inner_sorts  *)
86     (Cic.id, Cic2acic.anntypes) Hashtbl.t *   (** ids_to_inner_types  *)
87     (Cic.id, Cic.conjecture) Hashtbl.t *      (** ids_to_conjectures  *)
88     (Cic.id, Cic.hypothesis) Hashtbl.t)       (** ids_to_hypotheses   *)
89     *                                       (** sequents part *)
90     ((int *                                   (** sequent (meta) index *)
91       (Cic.annconjecture *                    (** annotated conjecture *)
92       (Cic.id, Cic.term) Hashtbl.t *          (** ids_to_terms *)
93       (Cic.id, Cic.id option) Hashtbl.t *     (** ids_to_father_ids *)
94       (Cic.id, string) Hashtbl.t *            (** ids_to_inner_sorts *)
95       (Cic.id, Cic.hypothesis) Hashtbl.t))    (** ids_to_hypotheses *)
96         list)
97   )
98
99 class type proof =
100   object
101     inherit [hist_metadata] StatefulProofEngine.status
102
103     (** return a pair of "xml" (as defined in Xml module) representing the *
104      * current proof type and body, respectively *)
105     method toXml: Xml.token Stream.t * Xml.token Stream.t
106     method toString: string
107   end
108
109 type proof_handler =
110   { get_proof: unit -> proof; (* return current proof or fail *)
111     abort_proof: unit -> unit;(* abort current proof, cleaning up garbage *)
112     has_proof: unit -> bool;  (* check if a current proof is available or not *)
113     new_proof: proof -> unit; (* as a set_proof but takes care also to register
114                               observers *)
115     quit: unit -> unit
116   }
117
118   (** interpreter for toplevel phrases given via console *)
119 class type interpreter =
120   object
121     method evalPhrase: string -> unit
122   end
123
124 (** {2 MathML widgets} *)
125
126 type mml_of_cic_sequent =
127   Cic.metasenv -> int * Cic.context * Cic.term ->
128     Gdome.document *
129     ((Cic.id, Cic.term) Hashtbl.t *
130     (Cic.id, Cic.id option) Hashtbl.t *
131     (string, Cic.hypothesis) Hashtbl.t)
132
133 type mml_of_cic_object =
134   explode_all:bool -> UriManager.uri -> Cic.annobj ->
135   (string, string) Hashtbl.t -> (string, Cic2acic.anntypes) Hashtbl.t ->
136     Gdome.document
137
138 class type sequent_viewer =
139   object
140     inherit GMathViewAux.multi_selection_math_view
141
142       (** @return the list of selected terms. Selections which are not terms are
143       * ignored *)
144     method get_selected_terms: Cic.term list
145
146       (** @return the list of selected hypothese. Selections which are not
147       * hypotheses are ignored *)
148     method get_selected_hypotheses: Cic.hypothesis list
149
150       (** load a sequent and render it into parent widget *)
151     method load_sequent: Gdome.document -> hist_metadata -> int -> unit
152   end
153
154 class type proof_viewer =
155   object
156     inherit GMathViewAux.single_selection_math_view
157
158     method load_proof: Gdome.document -> hist_metadata -> unit
159
160   end
161
162 (** {2 shorthands} *)
163
164 type namer = ProofEngineTypes.mk_fresh_name_type
165
166 type choose_uris_callback =
167   selection_mode:[`MULTIPLE|`SINGLE] ->
168   ?title:string -> ?msg:string -> ?nonvars_button:bool ->
169   string list ->
170     string list
171
172 type choose_interp_callback = (string * string) list list -> int list
173