| 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 Evd |
| 12 | open Names |
| 13 | open Environ |
| 14 | open EConstr |
| 15 | open Glob_term |
| 16 | |
| 17 | (** {6 Coercions. } *) |
| 18 | |
| 19 | type coercion_trace |
| 20 | |
| 21 | val empty_coercion_trace : coercion_trace |
| 22 | |
| 23 | val reapply_coercions : evar_map -> coercion_trace -> EConstr.t -> EConstr.t |
| 24 | |
| 25 | (** [inh_coerce_to_sort env isevars j] coerces [j] to a type; i.e. it |
| 26 | inserts a coercion into [j], if needed, in such a way it gets as |
| 27 | type a sort; it fails if no coercion is applicable *) |
| 28 | val inh_coerce_to_sort : ?loc:Loc.t -> ?use_coercions:bool -> |
| 29 | env -> evar_map -> unsafe_judgment -> evar_map * unsafe_type_judgment |
| 30 | |
| 31 | (** [inh_coerce_to_base env isevars j] coerces [j] to its base type; i.e. it |
| 32 | inserts a coercion into [j], if needed, in such a way it gets as |
| 33 | type its base type (the notion depends on the coercion system) *) |
| 34 | val inh_coerce_to_base : ?loc:Loc.t -> program_mode:bool -> |
| 35 | env -> evar_map -> unsafe_judgment -> evar_map * unsafe_judgment |
| 36 | |
| 37 | (** [remove_subset env sigma t] applies program mode transformations |
| 38 | to [t], recursively transforming [{x : A | P}] into [A] *) |
| 39 | val remove_subset : env -> evar_map -> types -> types |
| 40 | |
| 41 | (** [inh_conv_coerce_to resolve_tc Loc.t env isevars j t] coerces [j] to an |
| 42 | object of type [t]; i.e. it inserts a coercion into [j], if needed, in such |
| 43 | a way [t] and [j.uj_type] are convertible; it fails if no coercion is |
| 44 | applicable. resolve_tc=false disables resolving type classes (as the last |
| 45 | resort before failing) *) |
| 46 | |
| 47 | val inh_conv_coerce_to : ?loc:Loc.t -> program_mode:bool -> resolve_tc:bool -> |
| 48 | ?use_coercions:bool -> env -> evar_map -> ?flags:Evarconv.unify_flags -> |
| 49 | unsafe_judgment -> types -> evar_map * unsafe_judgment * coercion_trace option |
| 50 | |
| 51 | val inh_conv_coerce_rigid_to : ?loc:Loc.t -> program_mode:bool -> resolve_tc:bool -> |
| 52 | ?use_coercions:bool -> env -> evar_map -> ?flags:Evarconv.unify_flags -> |
| 53 | unsafe_judgment -> types -> evar_map * unsafe_judgment * coercion_trace option |
| 54 | |
| 55 | (** [inh_pattern_coerce_to loc env isevars pat ind1 ind2] coerces the Cases |
| 56 | pattern [pat] typed in [ind1] into a pattern typed in [ind2]; |
| 57 | raises [Not_found] if no coercion found *) |
| 58 | val inh_pattern_coerce_to : |
| 59 | ?loc:Loc.t -> env -> cases_pattern -> inductive -> inductive -> cases_pattern |
| 60 | |
| 61 | type expected = Type of types | Sort | Product |
| 62 | |
| 63 | type hook = env -> evar_map -> flags:Evarconv.unify_flags -> constr -> |
| 64 | inferred:types -> expected:expected -> (evar_map * constr * constr) option |
| 65 | |
| 66 | (** A plugin can override the coercion mechanism by registering a hook here. |
| 67 | Note that these hooks will only be trigerred when no direct or reversible |
| 68 | coercion applies. |
| 69 | Newly registered hooks are not active by default, see [activate_hook] below. |
| 70 | The same hook cannot be registered twice, except if [override] is [true]. |
| 71 | Beware that this addition is not persistent, it is up to the plugin to use |
| 72 | libobject if needed. *) |
| 73 | val register_hook : name:string -> ?override:bool -> hook -> unit |
| 74 | |
| 75 | (** Activate a previously registered hook. |
| 76 | Most recently activated hooks are tried first. *) |
| 77 | val activate_hook : name:string -> unit |
| 78 | |
| 79 | (** Deactivate a hook. If the hook wasn't registered/active, |
| 80 | this does nothing. *) |
| 81 | val deactivate_hook : name:string -> unit |
| 82 | |
| 83 | type delayed_app_body |
| 84 | |
| 85 | val start_app_body : evar_map -> constr -> delayed_app_body |
| 86 | |
| 87 | val push_arg : delayed_app_body -> constr -> delayed_app_body |
| 88 | |
| 89 | val force_app_body : delayed_app_body -> constr |
| 90 | |
| 91 | val reapply_coercions_body : evar_map -> coercion_trace -> delayed_app_body -> delayed_app_body |
| 92 | |
| 93 | (** [inh_app_fun resolve_tc env isevars j] coerces [j] to a function; i.e. it |
| 94 | inserts a coercion into [j], if needed, in such a way it gets as |
| 95 | type a product; it returns [j] if no coercion is applicable. |
| 96 | resolve_tc=false disables resolving type classes (as the last |
| 97 | resort before failing) *) |
| 98 | val inh_app_fun : program_mode:bool -> resolve_tc:bool -> ?use_coercions:bool -> |
| 99 | env -> evar_map -> ?flags:Evarconv.unify_flags -> delayed_app_body -> types -> evar_map * delayed_app_body * types * coercion_trace |