| 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 Names |
| 12 | open Environ |
| 13 | open Evd |
| 14 | open Tactypes |
| 15 | |
| 16 | (** {6 Evar-based clauses} *) |
| 17 | |
| 18 | (** The following code is an adaptation of the [Clenv.make_clenv_*] functions, |
| 19 | except that it uses evars instead of metas, and naturally fits in the new |
| 20 | refinement monad. It should eventually replace all uses of the |
| 21 | aforementioned functions. |
| 22 | |
| 23 | A clause is constructed as follows: assume a type [t := forall (x1 : A1) ... |
| 24 | (xn : An), T], we instantiate all the [xi] with a fresh evar [ei] and |
| 25 | return [T(xi := ei)] together with the [ei] enriched with a bit of |
| 26 | additional data. This is the simple part done by [make_evar_clause]. |
| 27 | |
| 28 | The problem lies in the fact we want to solve such holes with some |
| 29 | [constr bindings]. This entails some subtleties, because the provided terms |
| 30 | may only be well-typed up to a coercion, which we can only infer if we have |
| 31 | enough typing information. The meta machinery could insert coercions through |
| 32 | tricky instantiation delays. The only solution we have now is to delay the |
| 33 | tentative resolution of clauses by providing the [solve_evar_clause] |
| 34 | function, to be called at a smart enough time. |
| 35 | *) |
| 36 | |
| 37 | type hole = { |
| 38 | hole_evar : EConstr.constr; |
| 39 | (** The hole itself. Guaranteed to be an evar. *) |
| 40 | hole_type : EConstr.types; |
| 41 | (** Type of the hole in the current environment. *) |
| 42 | hole_deps : bool; |
| 43 | (** Whether the remainder of the clause was dependent in the hole. Note that |
| 44 | because let binders are substituted, it does not mean that it actually |
| 45 | appears somewhere in the returned clause. *) |
| 46 | hole_name : Name.t; |
| 47 | (** Name of the hole coming from its binder. *) |
| 48 | hole_evar_key : Evar.t; |
| 49 | (** Internal evar key of the hole. *) |
| 50 | } |
| 51 | |
| 52 | type clause = { |
| 53 | cl_holes : hole list; |
| 54 | cl_concl : EConstr.types; |
| 55 | } |
| 56 | |
| 57 | val make_evar_clause : env -> evar_map -> ?len:int -> EConstr.types -> |
| 58 | (evar_map * clause) |
| 59 | (** An evar version of {!make_clenv_binding}. Given a type [t], |
| 60 | [evar_environments env sigma ~len t bl] tries to eliminate at most [len] |
| 61 | products of the type [t] by filling it with evars. It returns the resulting |
| 62 | type together with the list of holes generated. Assumes that [t] is |
| 63 | well-typed in the environment. *) |
| 64 | |
| 65 | val solve_evar_clause : env -> evar_map -> bool -> clause -> EConstr.constr bindings -> |
| 66 | evar_map |
| 67 | (** [solve_evar_clause env sigma hyps cl bl] tries to solve the holes contained |
| 68 | in [cl] according to the [bl] argument. Assumes that [bl] are well-typed in |
| 69 | the environment. The boolean [hyps] is a compatibility flag that allows to |
| 70 | consider arguments to be dependent only when they appear in hypotheses and |
| 71 | not in the conclusion. This boolean is only used when [bl] is of the form |
| 72 | [ImplicitBindings _]. *) |
| 73 | |
| 74 | val check_bindings : 'a explicit_bindings -> unit |
| 75 | |
| 76 | val explain_no_such_bound_variable : Id.t list -> Id.t CAst.t -> 'a |
| 77 | |
| 78 | val error_not_right_number_missing_arguments : int -> 'a |
| 79 | |
| 80 | val check_evar_clause : Environ.env -> evar_map -> evar_map -> clause -> unit |