]> matita.cs.unibo.it Git - helm.git/blob - helm/software/components/cic_disambiguation/disambiguate.mli
201bdb3b7bb7178f7f4c11111b0062426dbfe5bc
[helm.git] / helm / software / components / cic_disambiguation / disambiguate.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 (** {2 Disambiguation interface} *)
27
28 (* the integer is an offset to be added to each location *)
29 (* list of located error messages, each list is a tuple:
30   * - environment in string form
31   * - environment patch
32   * - location
33   * - error message
34   * - significancy of the error message, if false the error is likely to be
35   *   useless for the final user ... *)
36 exception NoWellTypedInterpretation of
37  int *
38  ((Stdpp.location list * string * string) list *
39   (DisambiguateTypes.domain_item * string) list *
40   (Stdpp.location * string) Lazy.t *
41   bool) list
42 exception PathNotWellFormed
43
44 val interpretate_path :
45   context:Cic.name list -> CicNotationPt.term -> Cic.term
46
47 type 'a disambiguator_input = string * int * 'a
48     
49 type domain = domain_tree list
50 and domain_tree = 
51   Node of Stdpp.location list * DisambiguateTypes.domain_item * domain
52
53 type ('term,'metasenv,'subst,'graph) test_result =
54   | Ok of 'term * 'metasenv * 'subst * 'graph
55   | Ko of (Stdpp.location * string) Lazy.t
56   | Uncertain of (Stdpp.location * string) Lazy.t
57
58 exception Try_again of string Lazy.t
59
60 val domain_of_ast_term: context:Cic.name list -> CicNotationPt.term -> domain
61
62 module type Disambiguator =
63 sig
64   val disambiguate_thing:
65     context:'context ->
66     metasenv:'metasenv ->
67     subst:'subst ->
68     mk_implicit:([ `Closed ] option -> 'refined_thing) ->
69     initial_ugraph:'ugraph ->
70     hint: ('metasenv -> 'raw_thing -> 'raw_thing) * 
71           (('refined_thing,'metasenv,'subst,'ugraph) test_result ->
72               ('refined_thing,'metasenv,'subst,'ugraph) test_result) ->
73     aliases:'refined_thing DisambiguateTypes.codomain_item DisambiguateTypes.Environment.t ->
74     universe:'refined_thing DisambiguateTypes.codomain_item list
75              DisambiguateTypes.Environment.t option ->
76     lookup_in_library:((selection_mode:[ `MULTIPLE | `SINGLE ] ->
77                         ?ok:string ->
78                         ?enable_button_for_non_vars:bool ->
79                         title:string ->
80                         msg:string ->
81                         id:string ->
82                         UriManager.uri list -> UriManager.uri list) ->
83                        (title:string -> ?id:string -> unit -> UriManager.uri option) ->
84                        DisambiguateTypes.Environment.key ->
85                        'refined_thing DisambiguateTypes.codomain_item list) ->
86     uri:'uri ->
87     pp_thing:('ast_thing -> string) ->
88     domain_of_thing:(context:'context -> 'ast_thing -> domain) ->
89     interpretate_thing:(context:'context ->
90                         env:'refined_thing DisambiguateTypes.codomain_item
91                             DisambiguateTypes.Environment.t ->
92                         uri:'uri ->
93                         is_path:bool -> 'ast_thing -> localization_tbl:'cichash -> 'raw_thing) ->
94     refine_thing:('metasenv ->
95                   'subst ->
96                   'context ->
97                   'uri ->
98                   'raw_thing ->
99                   'ugraph -> localization_tbl:'cichash -> 
100                   ('refined_thing, 'metasenv,'subst,'ugraph) test_result) ->
101     localization_tbl:'cichash ->
102     string * int * 'ast_thing ->
103     ((DisambiguateTypes.Environment.key * 
104     'refined_thing DisambiguateTypes.codomain_item) list * 
105      'metasenv * 'subst * 'refined_thing * 'ugraph)
106      list * bool
107
108   val disambiguate_term :
109     ?fresh_instances:bool ->
110     context:Cic.context ->
111     metasenv:Cic.metasenv -> 
112     subst:Cic.substitution ->
113     ?goal:int ->
114     ?initial_ugraph:CicUniv.universe_graph -> 
115     aliases:Cic.term DisambiguateTypes.environment ->(* previous interpretation status *)
116     universe:Cic.term DisambiguateTypes.multiple_environment option ->
117     lookup_in_library:((selection_mode:[ `MULTIPLE | `SINGLE ] ->
118                         ?ok:string ->
119                         ?enable_button_for_non_vars:bool ->
120                         title:string ->
121                         msg:string ->
122                         id:string ->
123                         UriManager.uri list -> UriManager.uri list) ->
124                        (title:string -> ?id:string -> unit -> UriManager.uri option) ->
125                        DisambiguateTypes.Environment.key ->
126                        Cic.term DisambiguateTypes.codomain_item list) ->
127     CicNotationPt.term disambiguator_input ->
128     ((DisambiguateTypes.domain_item * Cic.term DisambiguateTypes.codomain_item) list *
129      Cic.metasenv *                  (* new metasenv *)
130      Cic.substitution *
131      Cic.term*
132      CicUniv.universe_graph) list *  (* disambiguated term *)
133     bool
134
135   val disambiguate_obj :
136     ?fresh_instances:bool ->
137     aliases:Cic.term DisambiguateTypes.environment ->(* previous interpretation status *)
138     universe:Cic.term DisambiguateTypes.multiple_environment option ->
139     uri:UriManager.uri option ->     (* required only for inductive types *)
140     lookup_in_library:((selection_mode:[ `MULTIPLE | `SINGLE ] ->
141                         ?ok:string ->
142                         ?enable_button_for_non_vars:bool ->
143                         title:string ->
144                         msg:string ->
145                         id:string ->
146                         UriManager.uri list -> UriManager.uri list) ->
147                        (title:string -> ?id:string -> unit -> UriManager.uri option) ->
148                        DisambiguateTypes.Environment.key ->
149                        Cic.term DisambiguateTypes.codomain_item list) ->
150     CicNotationPt.term CicNotationPt.obj disambiguator_input ->
151     ((DisambiguateTypes.domain_item * Cic.term DisambiguateTypes.codomain_item) list *
152      Cic.metasenv *                  (* new metasenv *)
153      Cic.substitution *
154      Cic.obj *
155      CicUniv.universe_graph) list *  (* disambiguated obj *)
156     bool
157 end
158
159 module Make (C : DisambiguateTypes.Callbacks) : Disambiguator
160