UStateThis file defines universe unification states which are part of evarmaps. Most of the API below is reexported in Evd. Consider using higher-level primitives when needed.
type universes_entry = | Monomorphic_entry of Univ.ContextSet.t * UVars.universe_level_substThe context only mentions global levels, the substitution maps the unification levels it replaces to them.
*)| Polymorphic_entry of UVars.UContext.tType of universe unification states. They allow the incremental building of universe constraints during an interactive proof.
Different ways to create a new universe state
val empty : tval from_env : Environ.env -> tMain entry point at the beginning of a declaration.
val from_auctx :
?of_template:bool ->
Environ.env ->
UVars.AbstractContext.t ->
tMain entry point when the universe declaration has already been computed, e.g. for printing.
val of_names : (UnivNames.universe_binders * UnivNames.rev_binders) -> tMain entry point when only names matter, e.g. for printing.
Misc
val is_empty : t -> boolmerge ~into uctx adds the universes, sort variables and constraints of uctx to into, keeping the namespace of the fresh universes of into. Dangerous API: avoid it when possible. The unification levels and sort variables of a state are only meaningful in the lineage of this state: the states of two branches forked from a common state can both generate the same fresh levels or variables (e.g. ℓ5) for unrelated universes, which merge then identifies. In general, the fresh levels and variables of the two states must be disjoint, e.g. because uctx is generated in a worker (see UnivGen.Supply) or in a namespace of its own (see set_supply_namespace). When uctx extends into, use it instead.
val universe_context_set : t -> Univ.ContextSet.tval sort_context_set : t -> UnivGen.sort_context_setThe local context of the state, i.e. a set of bound variables together with their associated constraints.
type universe_opt_subst = UnivFlex.tval subst : t -> UnivFlex.tThe local universes that are unification variables
val is_above_prop : t -> Sorts.QVar.t -> boolval is_algebraic : Univ.Level.t -> t -> boolCan this universe be instantiated with an algebraic universe (ie it appears in inferred types only).
val constraints : t -> PConstraints.tShorthand for context_set composed with ContextSet.constraints.
val context : t -> UVars.UContext.tShorthand for context_set with Context_set.to_context.
type named_universes_entry = universes_entry * UnivNames.universe_bindersval univ_entry : poly:PolyFlags.t -> t -> named_universes_entryPick from context or context_set based on poly. A monomorphic entry replaces the unification levels by global levels: the ones defined to global levels, e.g. by a previous declaration (see demote_global_univ_entry), are replaced by them and not declared again, the others by fresh global levels.
val monomorphic_entry :
Univ.ContextSet.t ->
UnivNames.universe_binders ->
named_universes_entryReplace the unification levels of the context by fresh global levels, see UnivGen.globalize_context_set.
val globalize_mono_context_set :
subst:UVars.universe_level_subst ->
t ->
Univ.ContextSet.t * UVars.universe_level_substThe monomorphic context of the universe state (see check_mono_sort_constraints), its unification levels replaced by global levels as in univ_entry: the ones defined to global levels are replaced by them and dropped from the context, as they are already declared; the others by their image by subst if any, by fresh global levels otherwise. Returns the extension of subst.
val entry_subst : named_universes_entry -> UVars.universe_level_substThe substitution of a monomorphic entry, empty for a polymorphic one.
val universe_binders : t -> UnivNames.universe_bindersReturn local names of universes.
val compute_instance_binders : t -> UVars.Instance.t -> UVars.bound_namesval nf_qvar : t -> Sorts.QVar.t -> Sorts.Quality.tReturns the normal form of the sort variable.
val nf_quality : t -> Sorts.Quality.t -> Sorts.Quality.tval nf_instance : t -> UVars.Instance.t -> UVars.Instance.tval nf_level : t -> Univ.Level.t -> Univ.Level.tMust not be allowed to be algebraic
val nf_universe : t -> Univ.Universe.t -> Univ.Universe.tval nf_relevance : t -> Sorts.relevance -> Sorts.relevanceReturns the normal form of the relevance.
type constraint_source = | Internal| Rigid| StaticOn an Internal enforcement, checks whether a path is created between two ground/global sorts. The Rigid constraint_source should be used for constraints entered by the user. It allows to create paths between ground/global sorts, but disables path creation between two ground sorts. No additional check is performed on a Static constraint.
val add_univ_constraints : t -> Univ.UnivConstraints.t -> tval add_poly_constraints : ?src:constraint_source -> t -> PConstraints.t -> tval add_constraints : ?src:constraint_source -> t -> UnivProblem.Set.t -> tval set_above_prop : Sorts.QVar.t -> above_prop -> t -> tval check_elim_constraints : t -> Sorts.ElimConstraints.t -> boolval check_constraints : t -> UnivProblem.Set.t -> boolval check_eq_quality : t -> Sorts.Quality.t -> Sorts.Quality.t -> boolval quality_of_name : t -> Names.Id.t -> Sorts.QVar.tval universe_of_name : t -> Names.Id.t -> Univ.Level.tRetrieve the universe associated to the name.
val name_level : Univ.Level.t -> Names.Id.t -> t -> tGives a name to the level (making it a binder). Asserts the name is not already used by a level
val restrict_universe_context :
Univ.ContextSet.t ->
Univ.Level.Set.t ->
Univ.ContextSet.trestrict_universe_context (univs,csts) keep restricts univs to the universes in keep. The constraints csts are adjusted so that transitive constraints between remaining universes (those in keep and those not in univs) are preserved.
val restrict : t -> Univ.Level.Set.t -> trestrict uctx ctx restricts the local universes of uctx to ctx extended by local named universes and side effect universes (from demote_seff_univs). Transitive constraints between retained universes are preserved.
val restrict_even_binders : t -> Univ.Level.Set.t -> trestrict_even_binders uctx ctx restricts the local universes of uctx to ctx extended by side effect universes (from demote_seff_univs). Transitive constraints between retained universes are preserved.
val univ_rigid : rigidval univ_flexible : rigidval univ_flexible_alg : rigidval merge_sort_context_set :
?loc:Loc.t ->
?sort_rigid:bool ->
?src:constraint_source ->
sideff:bool ->
rigid ->
t ->
UnivGen.sort_context_set ->
tval merge_universe_context_set :
?loc:Loc.t ->
sideff:bool ->
rigid ->
t ->
Univ.ContextSet.t ->
tval demote_global_univs : Univ.ContextSet.t -> t -> tAfter declaring global universes, call this if you want to keep using the UState.
Removes from the uctx_local part of the UState the universes that are present in the input constraint set (supposedly the global ones), and adds any new universes and constraints to the UGraph part of the UState.
val demote_global_univ_entry : universes_entry -> t -> tAfter declaring a global, call this with its universe entry if you want to keep using the ustate instead of restarting it with from_env (Global.env()) or using the slow update_sigma_univs _ (Environ.universes (Global/env())).
demote_global_univs), and the local unification levels replaced by global levels become flexible levels defined to them: further entries reuse these global levels (see univ_entry).val emit_side_effects : Safe_typing.private_constants -> t -> tCalls demote_global_univs for the private constant universes.
val new_quality_variable :
?loc:Loc.t ->
?sort_rigid:bool ->
?name:Names.Id.t ->
t ->
t * Sorts.QVar.tDeclare a new local sort.
val new_univ_level_variable :
?loc:Loc.t ->
rigid ->
Names.Id.t option ->
t ->
t * Univ.Level.tDeclare a new local universe; use rigid if a global or bound universe; use flexible for a universe existential variable; use univ_flexible_alg for a universe existential variable allowed to be instantiated with an algebraic universe
val add_forgotten_univ : t -> Univ.Level.t -> tDon't use this, it only exists for funind
val globalize_levels : Univ.Level.Set.t -> t -> t * UVars.universe_level_substglobalize_levels ls uctx replaces the undefined local unification levels of ls by fresh global levels, which become local rigid levels of uctx: the unification levels become flexible levels defined to them, as after a declaration (see demote_global_univ_entry). Returns the substitution of the replaced levels. This is for clients that need names for the levels of a term that stay meaningful outside of the lineage of uctx, e.g. printed names.
val with_supply : t -> (UnivGen.Supply.t -> UnivGen.Supply.t * 'a) -> t * 'aGenerate unification levels or sort variables using the supply of the state, so that they do not clash with the ones it already contains.
val supply_namespace : t -> stringThe namespace of the fresh levels and sort variables of the state, see UnivGen.Supply.set_namespace.
val with_fresh_context :
rigid ->
t ->
(UnivGen.Supply.t -> UnivGen.Supply.t * 'a UnivGen.in_sort_context_set) ->
t * 'aGenerate an object with the supply of the state, and add its context to the state.
val fresh_instance :
rigid ->
t ->
UVars.AbstractContext.t ->
t * UVars.Instance.tA fresh instance of the abstract context, whose variables and constraints are added to the state.
val make_nonalgebraic_variable : t -> Univ.Level.t -> tcf UnivFlex
val constrain_variables : Univ.Level.Set.t -> t -> tval collapse_sort_variables :
?except:Sorts.QVar.Set.t ->
only_above_prop:bool ->
t ->
ttype universe_decl =
(Sorts.QVar.t list,
Sorts.ElimConstraints.t,
Univ.Level.t list,
Univ.UnivConstraints.t)
gen_universe_declval default_univ_decl : universe_declval check_univ_decl :
poly:PolyFlags.t ->
t ->
universe_decl ->
named_universes_entrycheck_poly_decl ctx decl
If non extensible in decl, check that the local universes (resp. universe constraints) in ctx are implied by decl.
Return a universes_entry containing the local universes of ctx and their constraints.
When polymorphic, the universes corresponding to decl.univdecl_instance come first in the order defined by that list.
val check_univ_decl_rev : t -> universe_decl -> t * UVars.UContext.tval check_mono_univ_decl : t -> universe_decl -> Univ.ContextSet.tval check_template_univ_decl :
t ->
template_qvars:Sorts.QVar.Set.t ->
universe_decl ->
Univ.ContextSet.tval check_mono_sort_constraints : t -> Univ.ContextSet.tval pr_uctx_level : t -> Univ.Level.t -> Pp.tval pr_uctx_qglobal : t -> Sorts.QGlobal.t -> Pp.tval pr_uctx_qvar : t -> Sorts.QVar.t -> Pp.tval qualid_of_level : t -> Univ.Level.t -> Libnames.qualid optionval quality_printer : t -> Sorts.Quality.printerval sort_printer : t -> Sorts.printerval id_of_level : t -> Univ.Level.t -> Names.Id.t optionOnly looks in the local names, not in the nametab.
val loc_of_level : t -> Univ.Level.t -> Loc.t optionWhere the universe was introduced, when known.
val id_of_qvar : t -> Sorts.QVar.t -> Names.Id.t optionval is_rigid_qvar : t -> Sorts.QVar.t -> boolval pr_weak : (Univ.Level.t -> Pp.t) -> t -> Pp.tmodule Internal : sig ... endval add_template_default_univs : Environ.env -> Names.MutInd.t -> unit