EvdThis file defines the pervasive unification state used everywhere in Coq tactic engine. It is very low-level and most of the functions exported here are irrelevant to the standard API user. Consider using Evarutil or Proofview instead.
A unification state (of type evar_map) is primarily a finite mapping from existential variables to records containing the type of the evar (evar_concl), the context under which it was introduced (evar_hyps) and its definition (evar_body). evar_extra is used to add any other kind of information.
It also contains conversion constraints, debugging information and information about meta variables.
type etypes = econstrmodule Filter : sig ... endmodule Abstraction : sig ... endval evar_context : 'a evar_info -> (econstr, etypes, erelevance) Context.Named.ptContext of the evar.
val evar_hyps : 'a evar_info -> Environ.named_context_valContext of the evar.
List of possible solutions when known that it is a finite list
val evar_source : 'a evar_info -> Evar_kinds.t Loc.locatedBoolean mask over evar_hyps. Should have the same length. When filtered out, the corresponding variable is not allowed to occur in the solution
val evar_abstract_arguments : undefined evar_info -> Abstraction.tBoolean information over evar_hyps, telling if an hypothesis instance can be imitated or should stay abstract in HO unification problems and inversion (see second_order_matching_with_args for its use).
val evar_relevance : 'a evar_info -> erelevanceRelevance of the conclusion of the evar.
val evar_filtered_context : 'a evar_info -> (econstr, etypes, erelevance) Context.Named.ptval evar_filtered_hyps : 'a evar_info -> Environ.named_context_valval evar_env : Environ.env -> 'a evar_info -> Environ.envval evar_filtered_env : Environ.env -> 'a evar_info -> Environ.env*
Type of unification state. Essentially a bunch of state-passing data needed to handle incremental term construction.
val empty : evar_mapThe empty evar map.
val from_env : ?binders:Names.lident list -> Environ.env -> evar_mapThe empty evar map with given universe context, taking its initial universes from env, possibly with initial universe binders. This is the main entry point at the beginning of the process of interpreting a declaration (e.g. before entering the interpretation of a Theorem statement).
The empty evar map with given universe context. This is the main entry point when resuming from a already interpreted declaration (e.g. after having interpreted a Theorem statement and preparing to open a goal).
val is_empty : evar_map -> boolWhether an evarmap is empty.
val has_undefined : evar_map -> boolhas_undefined sigma is true if and only if there are uninstantiated evars in sigma.
val has_given_up : evar_map -> boolhas_given_up sigma is true if and only if there are given up evars in sigma.
val has_shelved : evar_map -> boolhas_shelved sigma is true if and only if there are shelved evars in sigma.
val new_pure_evar : ?src:Evar_kinds.t Loc.located -> ?filter:Filter.t -> ?relevance:erelevance -> ?abstract_arguments:Abstraction.t ->
?candidates:econstr list -> ?name:Names.Id.t -> ?typeclass_candidate:bool -> ?principal:bool ->
Environ.named_context_val -> evar_map -> etypes -> evar_map * Evar.tLow-level interface to create an evar.
add sigma ev info adds ev with evar info info in sigma. Precondition: ev must not preexist in sigma.
val find : evar_map -> Evar.t -> any_evar_infoRecover the data associated to an evar.
Same as find but restricted to undefined evars. For efficiency reasons.
Remove the body of an evar. Only there for backward compat, do not use.
val fold : (Evar.t -> any_evar_info -> 'a -> 'a) -> evar_map -> 'a -> 'aApply a function to all evars and their associated info in an evarmap.
Same as fold, but restricted to undefined evars. For efficiency reasons.
Apply the given function to all evars in the map. Beware: this function expects the argument function to preserve the kind of evar_body, i.e. it must send Evar_empty to Evar_empty and Evar_defined c to some Evar_defined c'.
val raw_map_undefined : (Evar.t -> undefined evar_info -> undefined evar_info) -> evar_map -> evar_mapSame as raw_map, but restricted to undefined evars. For efficiency reasons.
Set the body of an evar to the given constr. It is expected that:
Same as define ev body evd, except the body must be an existential variable ev'. This additionally makes ev' inherit the obligation and typeclass flags of ev.
Map the function on all terms in the evar map.
val add_constraints : evar_map -> Univ.Constraints.t -> evar_mapAdd universe constraints in an evar map.
val add_quconstraints : evar_map -> Sorts.QUConstraints.t -> evar_mapval undefined_map : evar_map -> undefined evar_info Evar.Map.tAccess the undefined evar mapping directly.
val defined_map : evar_map -> defined evar_info Evar.Map.tAccess the defined evar mapping directly.
Drop the defined evars in the second evar map which did not exist in the first.
val is_maybe_typeclass_hook : (evar_map -> Constr.constr -> bool) Hook.tval existential_value : evar_map -> econstr Constr.pexistential -> econstrexistential_value sigma ev raises NotInstantiatedEvar if ev has no body and Not_found if it does not exist in sigma
val existential_value0 : evar_map -> Constr.existential -> Constr.constrval existential_type_opt : evar_map -> econstr Constr.pexistential -> etypes optionval existential_type : evar_map -> econstr Constr.pexistential -> etypesval existential_type0 : evar_map -> Constr.existential -> Constr.typesval existential_opt_value : evar_map -> econstr Constr.pexistential -> econstr optionSame as existential_value but returns an option instead of raising an exception.
val existential_opt_value0 : evar_map -> Constr.existential -> Constr.constr optionval evar_handler : evar_map -> CClosure.evar_handlerval existential_expand_value0 : evar_map -> Constr.existential -> Constr.constr CClosure.evar_expansionval expand_existential : evar_map -> econstr Constr.pexistential -> econstr listReturns the full evar instance with implicit default variables turned into explicit Var nodes.
val expand_existential0 : evar_map -> Constr.constr Constr.pexistential -> Constr.constr listval restrict : Evar.t -> Filter.t -> ?candidates:econstr list -> ?src:Evar_kinds.t Loc.located -> evar_map -> evar_map * Evar.tRestrict an undefined evar into a new evar by filtering context and possibly limiting the instances to a set of candidates (candidates are filtered according to the filter)
val update_source : evar_map -> Evar.t -> Evar_kinds.t Loc.located -> evar_mapTo update the source a posteriori, e.g. when an evar type of another evar has to refer to this other evar, with a mutual dependency
val get_aliased_evars : evar_map -> Evar.t Evar.Map.tThe map of aliased evars
Tell if an evar has been aliased to another evar, and if yes, which
If any, the evar with highest id with a non-empty list of candidates.
Mark the given set of evars as available for resolution.
Precondition: they should indeed refer to undefined typeclass evars.
val get_typeclass_evars : evar_map -> Evar.Set.tThe set of undefined typeclass evars
Is the evar declared resolvable for typeclass resolution
val get_obligation_evars : evar_map -> Evar.Set.tThe set of obligation evars
val get_impossible_case_evars : evar_map -> Evar.Set.tSet of undefined evars with ImpossibleCase evar source.
Change the type of an undefined evar to a new type assumed to be a subtype of its current type; subtyping must be ensured by caller
val evar_ident : Evar.t -> evar_map -> Names.Id.t optionval rename : Evar.t -> Names.Id.t -> evar_map -> evar_mapval evar_key : Names.Id.t -> evar_map -> Evar.tval evar_names : evar_map -> Nameops.Fresh.tval evar_source_of_meta : Constr.metavariable -> evar_map -> Evar_kinds.t Loc.locatedval dependent_evar_ident : Evar.t -> evar_map -> Names.Id.ttype side_effects = {seff_private : Safe_typing.private_constants; |
seff_roles : side_effect_role Names.Cmap.t; |
}val empty_side_effects : side_effectsval concat_side_effects : side_effects -> side_effects -> side_effectsval emit_side_effects : side_effects -> evar_map -> evar_mapPush a side-effect into the evar map.
val eval_side_effects : evar_map -> side_effectsReturn the effects contained in the evar map.
Adds an existential variable to the list of future goals. For internal uses only.
Adds an existential variable to the list of future goals and make it principal. Only one existential variable can be made principal, an error is raised otherwise. For internal uses only.
module FutureGoals : sig ... endval pop_future_goals : evar_map -> FutureGoals.t * evar_mapval given_up : evar_map -> Evar.Set.tEvar maps also keep track of the universe constraints defined at a given point. This section defines the relevant manipulation functions.
val add_universe_constraints : evar_map -> UnivProblem.Set.t -> evar_mapAdd the given universe unification constraints to the evar map.
Evar maps can contain arbitrary data, allowing to use an extensible state. As evar maps are theoretically used in a strict state-passing style, such additional data should be passed along transparently. Some old and bug-prone code tends to drop them nonetheless, so you should keep cautious.
These functions are almost deprecated. They were used before the introduction of the full-fledged evar calculus. In an ideal world, they should be removed. Alas, some parts of the code still use them. Do not use in newly-written code.
module Metaset : Util.Set.S with type elt = Constr.metavariablemodule Metamap : Util.Map.ExtS with type key = Constr.metavariable and module Set := Metasetval metavars_of : econstr -> Metaset.tval mk_freelisted : econstr -> econstr freelistedval map_fl : ('a -> 'b) -> 'a freelisted -> 'b freelistedStatus of an instance found by unification wrt to the meta it solves:
P to ?X u v = P u v can be eta-expanded twice)val eq_instance_constraint : instance_constraint -> instance_constraint -> boolStatus of the unification of the type of an instance against the type of the meta it instantiates:
Status of an instance together with the status of its type unification
type instance_status = instance_constraint * instance_typing_statusClausal environments
type clbinding = | Cltyp of Names.Name.t * econstr freelisted |
| Clval of Names.Name.t * econstr freelisted * instance_status * econstr freelisted |
type conv_pb = Conversion.conv_pbUnification constraints
type evar_constraint = conv_pb * Environ.env * econstr * econstrval add_conv_pb : ?tail:bool -> evar_constraint -> evar_map -> evar_mapThe following two functions are for internal use only, see Evarutil.add_unification_pb for a safe interface.
val conv_pbs : evar_map -> evar_constraint listval extract_conv_pbs : evar_map -> (evar_constraint -> bool) -> evar_map * evar_constraint listval extract_changed_conv_pbs : evar_map -> (Evar.Set.t -> evar_constraint -> bool) -> evar_map * evar_constraint listval extract_all_conv_pbs : evar_map -> evar_map * evar_constraint listval loc_of_conv_pb : evar_map -> evar_constraint -> Loc.t optionThe following functions return the set of undefined evars contained in the object.
val evars_of_named_context : evar_map -> (econstr, etypes, erelevance) Context.Named.pt -> Evar.Set.tval meta_value : evar_map -> Constr.metavariable -> econstrmeta_fvalue raises Not_found if meta not in map or Anomaly if meta has no value
val meta_opt_fvalue : evar_map -> Constr.metavariable -> (econstr freelisted * instance_status) optionval meta_ftype : evar_map -> Constr.metavariable -> etypes freelistedval meta_name : evar_map -> Constr.metavariable -> Names.Name.tval meta_declare : Constr.metavariable -> etypes -> ?name:Names.Name.t -> evar_map -> evar_mapval meta_assign : Constr.metavariable -> (econstr * instance_status) -> evar_map -> evar_mapval meta_reassign : Constr.metavariable -> (econstr * instance_status) -> evar_map -> evar_mapmeta_merge evd1 evd2 returns evd2 extended with the metas of evd1
type metabinding = Constr.metavariable * econstr * instance_statusval retract_coercible_metas : evar_map -> metabinding list * evar_mapRigid or flexible universe variables.
UnivRigid variables are user-provided or come from an explicit Type in the source, we do not minimize them or unify them eagerly.
UnivFlexible alg variables are fresh universe variables of polymorphic constants or generated during refinement, sometimes in algebraic position (i.e. not appearing in the term at the moment of creation). They are the candidates for minimization (if alg, to an algebraic universe) and unified eagerly in the first-order unification heurstic.
type rigid = UState.rigid = | UnivRigid | |
| UnivFlexible of bool | (* Is substitution by an algebraic ok? *) |
val univ_rigid : rigidval univ_flexible : rigidval univ_flexible_alg : rigidtype 'a in_evar_universe_context = 'a * UState.tval restrict_universe_context : ?lbound:UGraph.Bound.t -> evar_map -> Univ.Level.Set.t -> evar_mapval universe_of_name : evar_map -> Names.Id.t -> Univ.Level.tRaises Not_found if not a name for a universe in this map.
val quality_of_name : evar_map -> Names.Id.t -> Sorts.QVar.tval is_relevance_irrelevant : evar_map -> erelevance -> boolWhether the relevance is irrelevant modulo qstate
val universe_binders : evar_map -> UnivNames.universe_bindersval new_univ_level_variable : ?loc:Loc.t -> ?name:Names.Id.t -> rigid -> evar_map -> evar_map * Univ.Level.tval new_quality_variable : ?loc:Loc.t -> ?name:Names.Id.t -> evar_map -> evar_map * Sorts.QVar.tval add_global_univ : evar_map -> Univ.Level.t -> evar_mapval universe_rigidity : evar_map -> Univ.Level.t -> rigidval make_nonalgebraic_variable : evar_map -> Univ.Level.t -> evar_mapSee UState.make_nonalgebraic_variable.
val is_flexible_level : evar_map -> Univ.Level.t -> boolval normalize_universe_instance : evar_map -> UVars.Instance.t -> UVars.Instance.tval set_leq_sort : Environ.env -> evar_map -> esorts -> esorts -> evar_mapval set_eq_sort : Environ.env -> evar_map -> esorts -> esorts -> evar_mapval set_eq_level : evar_map -> Univ.Level.t -> Univ.Level.t -> evar_mapval set_leq_level : evar_map -> Univ.Level.t -> Univ.Level.t -> evar_mapval set_eq_instances : ?flex:bool -> evar_map -> UVars.Instance.t -> UVars.Instance.t -> evar_mapval check_constraints : evar_map -> Univ.Constraints.t -> boolval check_qconstraints : evar_map -> Sorts.QConstraints.t -> boolval check_quconstraints : evar_map -> Sorts.QUConstraints.t -> boolval universe_context_set : evar_map -> Univ.ContextSet.tval sort_context_set : evar_map -> UnivGen.sort_context_setval universe_subst : evar_map -> UnivFlex.tval to_universe_context : evar_map -> UVars.UContext.tto_universe_context evm extracts the local universes and constraints of evm and orders the universes the same as Univ.ContextSet.to_context.
val univ_entry : poly:bool -> evar_map -> UState.named_universes_entryval check_univ_decl : poly:bool -> evar_map -> UState.universe_decl -> UState.named_universes_entryval merge_context_set : ?loc:Loc.t -> ?sideff:bool -> rigid -> evar_map -> Univ.ContextSet.t -> evar_mapval merge_sort_context_set : ?loc:Loc.t -> ?sideff:bool -> rigid -> evar_map -> UnivGen.sort_context_set -> evar_mapval merge_sort_variables : ?loc:Loc.t -> ?sideff:bool -> evar_map -> Sorts.QVar.Set.t -> evar_mapval with_context_set : ?loc:Loc.t -> rigid -> evar_map -> 'a Univ.in_universe_context_set -> evar_map * 'aval with_sort_context_set : ?loc:Loc.t -> rigid -> evar_map -> 'a UnivGen.in_sort_context_set -> evar_map * 'aval minimize_universes : ?lbound:UGraph.Bound.t -> evar_map -> evar_mapUniverse minimization
Polymorphic universes
val fresh_constant_instance : ?loc:Loc.t -> ?rigid:rigid -> Environ.env -> evar_map -> Names.Constant.t -> evar_map * Constr.pconstantval fresh_inductive_instance : ?loc:Loc.t -> ?rigid:rigid -> Environ.env -> evar_map -> Names.inductive -> evar_map * Constr.pinductiveval fresh_constructor_instance : ?loc:Loc.t -> ?rigid:rigid -> Environ.env -> evar_map -> Names.constructor -> evar_map * Constr.pconstructorval fresh_array_instance : ?loc:Loc.t -> ?rigid:rigid -> Environ.env -> evar_map -> evar_map * UVars.Instance.tval fresh_global : ?loc:Loc.t -> ?rigid:rigid -> ?names:UVars.Instance.t -> Environ.env -> evar_map -> Names.GlobRef.t -> evar_map * econstrPartially constructed constrs.
val evar_counter_summary_tag : int Summary.Dyn.tagCreate an evar_map with empty meta map:
module MiniEConstr : sig ... endUse this module only to bootstrap EConstr