Debian Codegraph @

pretyping/unification.mli

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 open Util
12 open Names
13 open Constr
14 open EConstr
15 open Environ
16 open Evd
17
18 (** {5 Meta machinery}
19
20 These functions are almost deprecated. They were used before the
21 introduction of the full-fledged evar calculus. In an ideal world, they
22 should be removed. Alas, some parts of the code still use them. Do not use
23 in newly-written code. *)
24
25 module Metaset : Set.S with type elt = metavariable
26 module Metamap : Map.ExtS with type key = metavariable and module Set := Metaset
27
28 type 'a freelisted = private {
29 rebus : 'a;
30 freemetas : Metaset.t }
31
32 val metavars_of : econstr -> Metaset.t
33
34 (** Metas *)
35 module Meta :
36 sig
37
38 type t
39 type instance_typing_status = CoerceToType | TypeNotProcessed | TypeProcessed
40
41 val empty : t
42
43 val meta_opt_fvalue : t -> metavariable -> econstr freelisted option
44 val meta_ftype : t -> metavariable -> etypes freelisted
45 val meta_name : t -> metavariable -> Name.t
46 val meta_declare : metavariable -> etypes -> ?name:Name.t -> t -> t
47 val meta_assign : metavariable -> econstr * instance_typing_status -> t -> evar_map -> evar_map * t
48 val meta_type : t -> env -> evar_map -> metavariable -> types
49 val meta_instance : t -> env -> evar_map -> constr -> constr
50
51 (** [meta_merge evd1 evd2] returns [evd2] extended with the metas of [evd1] *)
52 val meta_merge : t -> t -> t
53
54 val map_metas : (econstr -> econstr) -> t -> t
55
56 val evar_source_of_meta : metavariable -> t -> Evar_kinds.t Loc.located
57
58 val fold : (metavariable -> 'a -> 'a) -> t -> 'a -> 'a
59
60 val pr_metaset : Metaset.t -> Pp.t
61 val pr_metamap : env -> evar_map -> t -> Pp.t
62
63 end
64
65 (** {5 Legacy unification} *)
66
67 type core_unify_flags = {
68 modulo_conv_on_closed_terms : TransparentState.t option;
69 use_metas_eagerly_in_conv_on_closed_terms : bool;
70 use_evars_eagerly_in_conv_on_closed_terms : bool;
71 modulo_delta : TransparentState.t;
72 modulo_delta_types : TransparentState.t;
73 check_applied_meta_types : bool;
74 use_pattern_unification : bool;
75 use_meta_bound_pattern_unification : bool;
76 allowed_evars : Evarsolve.AllowedEvars.t;
77 restrict_conv_on_strict_subterms : bool;
78 modulo_betaiota : bool;
79 modulo_eta : bool;
80 }
81
82 type unify_flags = {
83 core_unify_flags : core_unify_flags;
84 merge_unify_flags : core_unify_flags;
85 subterm_unify_flags : core_unify_flags;
86 allow_K_in_toplevel_higher_order_unification : bool;
87 resolve_evars : bool
88 }
89
90 val default_core_unify_flags : unit -> core_unify_flags
91 val default_no_delta_core_unify_flags : unit -> core_unify_flags
92
93 val default_unify_flags : unit -> unify_flags
94 val default_no_delta_unify_flags : TransparentState.t -> unify_flags
95
96 val elim_flags : unit -> unify_flags
97 val elim_no_delta_flags : unit -> unify_flags
98
99 val is_keyed_unification : unit -> bool
100
101 (** The "unique" unification function *)
102 val w_unify :
103 ?metas:Meta.t ->
104 env -> evar_map -> conv_pb -> ?flags:unify_flags -> constr -> constr -> Meta.t * evar_map
105
106 (** [w_unify_to_subterm env m (c,t)] performs unification of [c] with a
107 subterm of [t]. Constraints are added to [m] and the matched
108 subterm of [t] is also returned. *)
109 val w_unify_to_subterm :
110 ?metas:Meta.t ->
111 env -> evar_map -> ?flags:unify_flags -> constr * constr -> (Meta.t * evar_map) * constr
112
113 val w_unify_to_subterm_all :
114 ?metas:Meta.t ->
115 env -> evar_map -> ?flags:unify_flags -> constr * constr -> (Meta.t * evar_map) list
116
117 val w_unify_meta_types :
118 ?metas:Meta.t ->
119 env -> ?flags:unify_flags -> evar_map -> Meta.t * evar_map
120
121 (** [w_coerce_to_type env evd c ctyp typ] tries to coerce [c] of type
122 [ctyp] so that its gets type [typ]; [typ] may contain metavariables *)
123 val w_coerce_to_type :
124 ?metas:Meta.t ->
125 env -> evar_map -> constr -> types -> types ->
126 evar_map * Meta.t * constr
127
128 (* Looking for subterms in contexts at some occurrences, possibly with pattern*)
129
130 exception PatternNotFound
131
132 type prefix_of_inductive_support_flag = bool
133
134 type abstraction_request =
135 | AbstractPattern of prefix_of_inductive_support_flag * (types -> bool) * Names.Name.t * (evar_map option * constr) * Locus.clause
136 | AbstractExact of Names.Name.t * constr * types option * Locus.clause * bool
137
138 type 'r abstraction_result =
139 Names.Id.t * named_context_val *
140 named_declaration list * Names.Id.t option *
141 types * (evar_map * constr) option
142
143 val make_abstraction : env -> evar_map -> constr ->
144 abstraction_request -> 'r abstraction_result
145
146 val pose_all_metas_as_evars : metas:Meta.t -> env -> evar_map -> constr -> evar_map * Meta.t * constr
147
148 (*i This should be in another module i*)
149
150 (** [abstract_list_all env evd t c l]
151 abstracts the terms in l over c to get a term of type t
152 (exported for inv.ml) *)
153 val abstract_list_all :
154 env -> evar_map -> constr -> constr -> constr list -> evar_map * (constr * types)