EnvironUnsafe 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:
type key = int CEphemeron.key option Stdlib.reftype constant_key = Declarations.constant_body * (link_info Stdlib.ref * key)type mind_key = Declarations.mutual_inductive_body * link_info Stdlib.refmodule Globals : sig ... endtype 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_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_universes_lbound : UGraph.Bound.t; |
irr_constants : Names.Cset_env.t; |
irr_inds : Names.Indset_env.t; |
env_typing_flags : Declarations.typing_flags; |
retroknowledge : Retroknowledge.retroknowledge; |
indirect_pterms : Opaqueproof.opaquetab; |
}val oracle : env -> Conv_oracle.oracleval set_oracle : env -> Conv_oracle.oracle -> envval eq_named_context_val : named_context_val -> named_context_val -> boolval empty_env : envval universes_lbound : env -> UGraph.Bound.tval set_universes_lbound : env -> UGraph.Bound.t -> envval rel_context : env -> Constr.rel_contextval named_context : env -> Constr.named_contextval named_context_val : env -> named_context_valval opaque_tables : env -> Opaqueproof.opaquetabval set_opaque_tables : env -> Opaqueproof.opaquetab -> envval typing_flags : env -> Declarations.typing_flagsval is_impredicative_set : env -> boolval type_in_type : env -> boolval deactivated_guard : env -> boolval indices_matter : env -> boolval is_impredicative_family : env -> Sorts.family -> boolval empty_context : env -> boolis the local context empty
rel_context)val nb_rel : env -> intval push_rel : Constr.rel_declaration -> env -> envval push_rel_context : Constr.rel_context -> env -> envval push_rec_types : Constr.rec_declaration -> env -> envval lookup_rel : int -> env -> Constr.rel_declarationLooks up in the context of local vars referred by indice (rel_context) raises Not_found if the index points out of the context
val evaluable_rel : int -> env -> boolrel_contextval fold_rel_context : (env -> Constr.rel_declaration -> 'a -> 'a) -> env -> init:'a -> 'aval named_context_of_val : named_context_val -> Constr.named_contextval val_of_named_context : Constr.named_context -> named_context_valval empty_named_context_val : named_context_valval ids_of_named_context_val : named_context_val -> Names.Id.Set.tval 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 : Constr.named_declaration -> env -> envval push_named_context : Constr.named_context -> env -> envval 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
val lookup_named : Names.variable -> env -> Constr.named_declarationval lookup_named_ctxt : Names.variable -> named_context_val -> Constr.named_declarationval evaluable_named : Names.variable -> env -> boolval named_type : Names.variable -> env -> Constr.typesval named_body : Names.variable -> env -> Constr.constr optionnamed_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
val reset_with_named_context : named_context_val -> env -> envThis forgets rel context and sets a new named 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 : Names.Constant.t -> Declarations.constant_body -> env -> envval add_constant_key : Names.Constant.t -> Declarations.constant_body -> link_info -> env -> envval lookup_constant_key : Names.Constant.t -> env -> constant_keyval lookup_constant : Names.Constant.t -> env -> Declarations.constant_bodyLooks up in the context of global constant names raises an anomaly if the required path is not found
val evaluable_constant : Names.Constant.t -> env -> boolval mem_constant : Names.Constant.t -> env -> boolval polymorphic_constant : Names.Constant.t -> env -> boolNew-style polymorphism
val polymorphic_pconstant : Constr.pconstant -> env -> boolval type_in_type_constant : Names.Constant.t -> env -> boolconstant_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
exception NotEvaluableConst of const_evaluation_resultval constant_type : env -> Names.Constant.t Univ.puniverses -> Constr.types Univ.constrainedval constant_value_and_type : env -> Names.Constant.t Univ.puniverses -> Constr.constr option * Constr.types * Univ.Constraints.tThe universe context associated to the constant, empty if not polymorphic
val constant_context : env -> Names.Constant.t -> Univ.AbstractContext.tThe universe context associated to the constant, empty if not polymorphic
val constant_value_in : env -> Names.Constant.t Univ.puniverses -> Constr.constrval constant_type_in : env -> Names.Constant.t Univ.puniverses -> Constr.typesval constant_opt_value_in : env -> Names.Constant.t Univ.puniverses -> Constr.constr optionval is_primitive : env -> Names.Constant.t -> boolval get_primitive : env -> Names.Constant.t -> CPrimitives.t optionval is_array_type : env -> Names.Constant.t -> boolval is_int63_type : env -> Names.Constant.t -> boolval is_float64_type : env -> Names.Constant.t -> boolval is_primitive_type : env -> Names.Constant.t -> boolval lookup_projection : Names.Projection.t -> env -> Constr.typesChecks that the number of parameters is correct.
val get_projection : env -> Names.inductive -> proj_arg:int -> Names.Projection.Repr.tAnomaly when not a primitive record or invalid proj_arg.
val get_projections : env -> Names.inductive -> Names.Projection.Repr.t array optionval lookup_mind_key : Names.MutInd.t -> env -> mind_keyInductive types
val add_mind_key : Names.MutInd.t -> mind_key -> env -> envval add_mind : Names.MutInd.t -> Declarations.mutual_inductive_body -> env -> envval lookup_mind : Names.MutInd.t -> env -> Declarations.mutual_inductive_bodyLooks up in the context of global inductive names raises an anomaly if the required path is not found
val mem_mind : Names.MutInd.t -> env -> boolval mind_context : env -> Names.MutInd.t -> Univ.AbstractContext.tThe universe context associated to the inductive, empty if not polymorphic
val polymorphic_ind : Names.inductive -> env -> boolNew-style polymorphism
val polymorphic_pind : Constr.pinductive -> env -> boolval type_in_type_ind : Names.inductive -> env -> boolval template_polymorphic_ind : Names.inductive -> env -> boolOld-style polymorphism
val template_polymorphic_variables : Names.inductive -> env -> Univ.Level.t listval template_polymorphic_pind : Constr.pinductive -> env -> boolmodule type QNameS = sig ... endmodule QConstant : QNameS with type t = Names.Constant.tmodule QMutInd : QNameS with type t = Names.MutInd.tmodule QInd : QNameS with type t = Names.Ind.tmodule QConstruct : QNameS with type t = Names.Construct.tmodule QProjection : sig ... endmodule QGlobRef : QNameS with type t = Names.GlobRef.tval add_modtype : Declarations.module_type_body -> env -> envval shallow_add_module : Declarations.module_body -> env -> envshallow_add_module does not add module components
val lookup_module : Names.ModPath.t -> env -> Declarations.module_bodyval lookup_modtype : Names.ModPath.t -> env -> Declarations.module_type_bodyval add_constraints : Univ.Constraints.t -> env -> envAdd universe constraints to the environment.
val check_constraints : Univ.Constraints.t -> env -> boolCheck constraints are satifiable in the environment.
val push_context : ?strict:bool -> Univ.UContext.t -> env -> envpush_context ?(strict=false) ctx env pushes the universe context to the environment.
val push_context_set : ?strict:bool -> Univ.ContextSet.t -> env -> envpush_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.
val push_subgraph : Univ.ContextSet.t -> env -> envpush_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.
val set_typing_flags : Declarations.typing_flags -> env -> envval sprop_allowed : env -> boolval same_flags : Declarations.typing_flags -> Declarations.typing_flags -> boolval update_typing_flags : ?typing_flags:Declarations.typing_flags -> env -> envupdate_typing_flags ?typing_flags may update env with optional typing flags
val universes_of_global : env -> Names.GlobRef.t -> Univ.AbstractContext.tglobal_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
val global_vars_set : env -> Constr.constr -> Names.Id.Set.tval vars_of_global : env -> Names.GlobRef.t -> Names.Id.Set.tval really_needed : env -> Names.Id.Set.t -> Names.Id.Set.tclosure of the input id set w.r.t. dependency
val keep_hyps : env -> Names.Id.Set.t -> Constr.named_contextlike 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 on_judgment : ('a -> 'b) -> ('a, 'a) punsafe_judgment -> ('b, 'b) punsafe_judgmentval on_judgment_value : ('c -> 'c) -> ('c, 't) punsafe_judgment -> ('c, 't) punsafe_judgmentval on_judgment_type : ('t -> 't) -> ('c, 't) punsafe_judgment -> ('c, 't) punsafe_judgmenttype unsafe_judgment = (Constr.constr, Constr.types) punsafe_judgmentval make_judge : 'constr -> 'types -> ('constr, 'types) punsafe_judgmentval j_val : ('constr, 'types) punsafe_judgment -> 'constrval j_type : ('constr, 'types) punsafe_judgment -> 'typestype unsafe_type_judgment = Constr.types punsafe_type_judgmentval 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_valval is_polymorphic : env -> Names.GlobRef.t -> boolval is_template_polymorphic : env -> Names.GlobRef.t -> boolval get_template_polymorphic_variables : env -> Names.GlobRef.t -> Univ.Level.t listval is_type_in_type : env -> Names.GlobRef.t -> boolval no_link_info : link_infoNative compiler
val set_retroknowledge : env -> Retroknowledge.retroknowledge -> envPrimitives