EnvironSourceUnsafe environments. We define here a datatype for environments. Since typing is not yet defined, it is not possible to check the informations added in environments, and that is why we speak here of ``unsafe'' environments.
Environments have the following components:
Linking information for the native compiler
type named_context_val = private {env_named_ctx : Constr.named_context;env_named_map : Constr.named_declaration Names.Id.Map.t;Identifier-indexed version of env_named_ctx
env_named_idx : Constr.named_declaration Range.t;Same as env_named_ctx but with a fast-access list.
*)}type rel_context_val = private {env_rel_ctx : Constr.rel_context;env_rel_map : Constr.rel_declaration Range.t;}type env = private {env_globals : Globals.t;env_named_context : named_context_val;env_rel_context : rel_context_val;env_nb_rel : int;env_universes : UGraph.t;env_qualities : Sorts.QVar.Set.t;irr_constants : Sorts.relevance Names.Cmap_env.t;irr_constants is a cache of the relevances which are not Relevant. In other words, const_relevance == Option.default Relevant (find_opt con irr_constants).
irr_inds : Sorts.relevance Names.Indmap_env.t;irr_inds is a cache of the relevances which are not Relevant. cf irr_constants.
symb_pats : Declarations.rewrite_rule list Names.Cmap_env.t;env_typing_flags : Declarations.typing_flags;vm_library : Vmlibrary.t;retroknowledge : Retroknowledge.retroknowledge;rewrite_rules_allowed : bool;Allow rewrite rules (breaks e.g. SR)
*)}rel_context)Looks up in the context of local vars referred by indice (rel_context) raises Not_found if the index points out of the context
rel_contextval map_named_val :
(Constr.named_declaration -> Constr.named_declaration) ->
named_context_val ->
named_context_valmap_named_val f ctxt apply f to the body and the type of each declarations. *** /!\ *** f t should be convertible with t, and preserve the name
val push_named_context_val :
Constr.named_declaration ->
named_context_val ->
named_context_valLooks up in the context of local vars referred by names (named_context) raises Not_found if the Id.t is not found
named_context: older declarations processed firstval fold_named_context :
(env -> Constr.named_declaration -> 'a -> 'a) ->
env ->
init:'a ->
'aval match_named_context_val :
named_context_val ->
(Constr.named_declaration * named_context_val) optionval fold_named_context_reverse :
('a -> Constr.named_declaration -> 'a) ->
init:'a ->
env ->
'aRecurrence on named_context starting from younger decl
This forgets rel context and sets a new named context
This removes the n last declarations from the rel context
val fold_constants :
(Names.Constant.t -> Declarations.constant_body -> 'a -> 'a) ->
env ->
'a ->
'aUseful for printing
val fold_inductives :
(Names.MutInd.t -> Declarations.mutual_inductive_body -> 'a -> 'a) ->
env ->
'a ->
'aval add_constant_key :
Names.Constant.t ->
Declarations.constant_body ->
link_info ->
env ->
envLooks up in the context of global constant names raises an anomaly if the required path is not found
New-style polymorphism
constant_value env c raises NotEvaluableConst Opaque if c is opaque, NotEvaluableConst NoBody if it has no body, NotEvaluableConst IsProj if c is a projection, NotEvaluableConst (IsPrimitive p) if c is primitive p and an anomaly if it does not exist in env
type const_evaluation_result = | NoBody| Opaque| IsPrimitive of UVars.Instance.t * CPrimitives.t| HasRules of UVars.Instance.t * bool * Declarations.rewrite_rule listval constant_value_and_type :
env ->
Names.Constant.t UVars.puniverses ->
Constr.constr option * Constr.types * Univ.Constraints.tThe universe context associated to the constant, empty if not polymorphic
The universe context associated to the constant, empty if not polymorphic
Checks that the number of parameters is correct.
val get_projection :
env ->
Names.inductive ->
proj_arg:int ->
Names.Projection.Repr.t * Sorts.relevanceAnomaly when not a primitive record or invalid proj_arg.
val get_projections :
env ->
Names.inductive ->
(Names.Projection.Repr.t * Sorts.relevance) array optionInductive types
Looks up in the context of global inductive names raises an anomaly if the required path is not found
The universe context associated to the inductive, empty if not polymorphic
New-style polymorphism
Old-style polymorphism
val expand_arity :
Declarations.mind_specif ->
Constr.pinductive ->
Constr.constr array ->
Names.Name.t Constr.binder_annot array ->
Constr.rel_contextGiven an inductive type and its parameters, builds the context of the return clause, including the inductive being eliminated. The additional binder array is only used to set the names of the context variables, we use the less general type to make it easy to use this function on Case nodes.
val expand_branch_contexts :
Declarations.mind_specif ->
UVars.Instance.t ->
Constr.constr array ->
(Names.Name.t Constr.binder_annot array * 'a) array ->
Constr.rel_context arrayGiven an inductive type and its parameters, builds the context of the return clause, including the inductive being eliminated. The additional binder array is only used to set the names of the context variables, we use the less general type to make it easy to use this function on Case nodes.
val instantiate_context :
UVars.Instance.t ->
Vars.substl ->
Names.Name.t Constr.binder_annot array ->
Constr.rel_context ->
Constr.rel_contextinstantiate_context u subst nas ctx applies both u and subst to ctx while replacing names using nas (order reversed). In particular, assumes that ctx and nas have the same length.
shallow_add_module does not add module components
Add universe constraints to the environment.
Check constraints are satifiable in the environment.
push_context ?(strict=false) ctx env pushes the universe context to the environment.
push_context_set ?(strict=false) ctx env pushes the universe context set to the environment. It does not fail even if one of the universes is already declared.
Same as above but keep the universes floating for template. Do not use.
push_subgraph univs env adds the universes and constraints in univs to env as push_context_set ~strict:false univs env, and also checks that they do not imply new transitive constraints between pre-existing universes in env.
update_typing_flags ?typing_flags may update env with optional typing flags
global_vars_set env c returns the list of id's occurring either directly as Var id in c or indirectly as a section variable dependent in a global reference occurring in c
closure of the input id set w.r.t. dependency
like really_needed but computes a well ordered named context
We introduce here the pre-type of judgments, which is actually only a datatype to store a term with its type and the type of its type.
val apply_to_hyp :
named_context_val ->
Names.variable ->
(Constr.named_context ->
Constr.named_declaration ->
Constr.named_context ->
Constr.named_declaration) ->
named_context_valapply_to_hyp sign id f split sign into tail::(id,_,_)::head and return tail::(f head (id,_,_) (rev tail))::head. the value associated to id should not change
val remove_hyps :
Names.Id.Set.t ->
(Constr.named_declaration -> Constr.named_declaration) ->
named_context_val ->
named_context_valPrimitives