Debian Codegraph @

pretyping/evarconv.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 EConstr
12 open Environ
13 open Reductionops
14 open Evd
15 open Locus
16
17 (** {4 Unification for type inference. } *)
18
19 type unify_flags = Evarsolve.unify_flags
20
21 (** The default subterm transparent state is no unfoldings *)
22 val default_flags_of : ?subterm_ts:TransparentState.t -> TransparentState.t -> unify_flags
23
24 type unify_fun = unify_flags ->
25 env -> evar_map -> conv_pb -> constr -> constr -> Evarsolve.unification_result
26
27 val conv_fun : unify_fun -> Evarsolve.unifier
28
29 exception UnableToUnify of evar_map * Pretype_errors.unification_error
30
31 (** {6 Main unification algorithm for type inference. } *)
32
33 (** There are two variants for unification: one that delays constraints outside its capabilities
34 ([unify_delay]) and another that tries to solve such remaining constraints using
35 heuristics ([unify]). *)
36
37 (** These functions allow to pass arbitrary flags to the unifier and can delay constraints.
38 In case the flags are not specified, they default to
39 [default_flags_of TransparentState.full] currently.
40
41 In case of success, the two terms are hence unifiable only if the remaining constraints
42 can be solved or [check_problems_are_solved] is true.
43
44 @raises UnableToUnify in case the two terms do not unify *)
45
46 val unify_delay : ?flags:unify_flags -> env -> evar_map -> constr -> constr -> evar_map
47 val unify_leq_delay : ?flags:unify_flags -> env -> evar_map -> constr -> constr -> evar_map
48
49 (** This function also calls [solve_unif_constraints_with_heuristics] to resolve any remaining
50 constraints. In case of success the two terms are unified without condition.
51
52 The with_ho option tells if higher-order unification should be tried to resolve the
53 constraints.
54
55 @raises a PretypeError if it cannot unify *)
56 val unify : ?flags:unify_flags -> ?with_ho:bool ->
57 env -> evar_map -> conv_pb -> constr -> constr -> evar_map
58
59 (** {6 Unification heuristics. } *)
60
61 (** Try heuristics to solve pending unification problems and to solve
62 evars with candidates.
63
64 The with_ho option tells if higher-order unification should be tried
65 to resolve the constraints.
66
67 @raises a PretypeError if it fails to resolve some problem *)
68
69 val solve_unif_constraints_with_heuristics :
70 env -> ?flags:unify_flags -> ?with_ho:bool -> evar_map -> evar_map
71
72 (** Check all pending unification problems relative to a set of evars
73 are solved and raise a PretypeError otherwise *)
74
75 val check_problems_are_solved : ?evars:Evar.Set.t -> env -> evar_map -> unit
76
77 (** Hook for the canonical structure resolution *)
78
79 type hook = Environ.env -> Evd.evar_map -> ((Names.Constant.t * EConstr.EInstance.t) * EConstr.t list option * EConstr.t) -> (EConstr.t * EConstr.t list) -> (Evd.evar_map * Structures.CanonicalSolution.t) option
80
81 val all_hooks : hook CString.Map.t ref
82
83 val register_hook : name:CString.Map.key -> ?override:bool -> hook -> unit
84
85 val active_hooks : string list ref
86
87 val deactivate_hook : name:Util.String.t -> unit
88
89 val activate_hook : name:CString.Map.key -> unit
90
91 val apply_hooks : hook
92
93 (** Check if a canonical structure is applicable. *)
94
95 val decompose_proj : ?metas:(Constr.metavariable -> types option) -> env -> evar_map -> state -> (Names.Constant.t * EConstr.EInstance.t) *
96 (EConstr.t list option * EConstr.t * Reductionops.Stack.t)
97 val check_conv_record : env -> evar_map ->
98 (Names.Constant.t * EConstr.EInstance.t) *
99 (EConstr.t list option * EConstr.t * Reductionops.Stack.t) ->
100 state ->
101 evar_map * (constr * constr)
102 * constr * constr list * (EConstr.t list * EConstr.t list option) *
103 (EConstr.t list * EConstr.t list) *
104 (Stack.t * Stack.t) * constr *
105 (int option * constr)
106
107 (** Compares two constants/inductives/constructors unifying their universes.
108 It required the number of arguments applied to the c/i/c in order to decided
109 the kind of check it must perform. *)
110 val compare_heads : env -> evar_map ->
111 nargs:int -> EConstr.t -> EConstr.t -> Evarsolve.unification_result
112
113 (** Try to solve problems of the form ?x[args] = c by second-order
114 matching, using typing to select occurrences *)
115
116 type occurrence_match_test =
117 env -> evar_map -> constr -> constr -> bool * evar_map
118
119 (** When given the choice of abstracting an occurrence or leaving it,
120 force abstration. *)
121
122 type occurrence_selection =
123 | AtOccurrences of occurrences
124 | Unspecified of Abstraction.abstraction
125
126 (** By default, unspecified, not preferring abstraction.
127 This provides the most general solutions. *)
128 val default_occurrence_selection : occurrence_selection
129
130 type occurrences_selection =
131 occurrence_match_test * occurrence_selection list
132
133 val default_occurrence_test : allowed_evars:Evarsolve.AllowedEvars.t -> TransparentState.t -> occurrence_match_test
134
135 (** [default_occurrence_selection n]
136 Gives the default test and occurrences for [n] arguments *)
137 val default_occurrences_selection : ?allowed_evars:Evarsolve.AllowedEvars.t (* By default, all *) ->
138 TransparentState.t -> int -> occurrences_selection
139
140 val second_order_matching : unify_flags -> env -> evar_map ->
141 EConstr.existential -> occurrences_selection -> constr -> evar_map * bool
142
143 (** Declare function to enforce evars resolution by using typing constraints *)
144
145 val set_solve_evars : (env -> evar_map -> constr -> evar_map * constr) -> unit
146
147 (** Override default [evar_conv_x] algorithm. *)
148 val set_evar_conv : unify_fun -> unit
149
150 (** The default unification algorithm with evars and universes. *)
151 val evar_conv_x : unify_fun
152
153 val evar_unify : Evarsolve.unifier
154
155 (**/**)
156 (* For debugging *)
157 module Cs_keys_cache : sig type t end
158
159 type orig = { left: state; right: state }
160
161 val evar_eqappr_x : ?rhs_is_already_stuck:bool -> unify_flags ->
162 env -> evar_map -> conv_pb ->
163 Cs_keys_cache.t ->
164 bool option -> orig -> state -> state ->
165 Evarsolve.unification_result
166
167 val occur_rigidly : Evarsolve.unify_flags ->
168 'a -> Evd.evar_map -> Evar.t * 'b -> EConstr.t -> bool
169 (**/**)
170
171 (** {6 Functions to deal with impossible cases } *)
172 val coq_unit_judge : env -> evar_map -> evar_map * EConstr.unsafe_judgment