123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339(************************************************************************)(* * The Coq Proof Assistant / The Coq Development Team *)(* v * Copyright INRIA, CNRS and contributors *)(* <O___,, * (see version control and CREDITS file for authors & dates) *)(* \VV/ **************************************************************)(* // * This file is distributed under the terms of the *)(* * GNU Lesser General Public License Version 2.1 *)(* * (see LICENSE file for the text of the license) *)(************************************************************************)openNamesopenConstr(** This module defines the internal representation of global
declarations. This includes global constants/axioms, mutual
inductive definitions, modules and module types *)typeset_predicativity=ImpredicativeSet|PredicativeSettypeengagement=set_predicativity(** {6 Representation of constants (Definition/Axiom) } *)(** Non-universe polymorphic mode polymorphism (Coq 8.2+): inductives
and constants hiding inductives are implicitly polymorphic when
applied to parameters, on the universes appearing in the whnf of
their parameters and their conclusion, in a template style.
In truly universe polymorphic mode, we always use RegularArity.
*)typetemplate_arity={template_level:Univ.Universe.t;}typetemplate_universes={template_param_levels:Univ.Level.toptionlist;template_context:Univ.ContextSet.t;}type('a,'b)declaration_arity=|RegularArityof'a|TemplateArityof'b(** Inlining level of parameters at functor applications.
None means no inlining *)typeinline=intoption(** A constant can have no body (axiom/parameter), or a
transparent body, or an opaque one *)(* Global declarations (i.e. constants) can be either: *)type('a,'opaque)constant_def=|Undefofinline(** a global assumption *)|Defof'a(** or a transparent global definition *)|OpaqueDefof'opaque(** or an opaque global definition *)|PrimitiveofCPrimitives.t(** or a primitive operation *)typeuniverses=|MonomorphicofUniv.ContextSet.t|PolymorphicofUniv.AUContext.t(** The [typing_flags] are instructions to the type-checker which
modify its behaviour. The typing flags used in the type-checking
of a constant are tracked in their {!constant_body} so that they
can be displayed to the user. *)typetyping_flags={check_guarded:bool;(** If [false] then fixed points and co-fixed points are assumed to
be total. *)check_positive:bool;(** If [false] then inductive types are assumed positive and co-inductive
types are assumed productive. *)check_universes:bool;(** If [false] universe constraints are not checked *)conv_oracle:Conv_oracle.oracle;(** Unfolding strategies for conversion *)share_reduction:bool;(** Use by-need reduction algorithm *)enable_VM:bool;(** If [false], all VM conversions fall back to interpreted ones *)enable_native_compiler:bool;(** If [false], all native conversions fall back to VM ones *)indices_matter:bool;(** The universe of an inductive type must be above that of its indices. *)cumulative_sprop:bool;(** SProp <= Type *)allow_uip:bool;(** Allow definitional UIP (breaks termination) *)}(* some contraints are in constant_constraints, some other may be in
* the OpaqueDef *)type'opaqueconstant_body={const_hyps:Constr.named_context;(** New: younger hyp at top *)const_body:(Constr.t,'opaque)constant_def;const_type:types;const_relevance:Sorts.relevance;const_body_code:Vmemitcodes.body_codeoption;const_universes:universes;const_inline_code:bool;const_typing_flags:typing_flags;(** The typing options which
were used for
type-checking. *)}(** {6 Representation of mutual inductive types in the kernel } *)typenested_type=|NestedIndofinductive|NestedPrimitiveofConstant.ttyperecarg=|Norec|Mrecofinductive|Nestedofnested_typetypewf_paths=recargRtree.t(**
{v
Inductive I1 (params) : U1 := c11 : T11 | ... | c1p1 : T1p1
...
with In (params) : Un := cn1 : Tn1 | ... | cnpn : Tnpn
v}
*)(** Record information:
If the type is not a record, then NotRecord
If the type is a non-primitive record, then FakeRecord
If it is a primitive record, for every type in the block, we get:
- The identifier for the binder name of the record in primitive projections.
- The constants associated to each projection.
- The projection types (under parameters).
The kernel does not exploit the difference between [NotRecord] and
[FakeRecord]. It is mostly used by extraction, and should be extruded from
the kernel at some point.
*)typerecord_info=|NotRecord|FakeRecord|PrimRecordof(Id.t*Label.tarray*Sorts.relevancearray*typesarray)arraytyperegular_inductive_arity={mind_user_arity:types;mind_sort:Sorts.t;}typeinductive_arity=(regular_inductive_arity,template_arity)declaration_aritytypeone_inductive_body={(** {8 Primitive datas } *)mind_typename:Id.t;(** Name of the type: [Ii] *)mind_arity_ctxt:Constr.rel_context;(** Arity context of [Ii] with parameters: [forall params, Ui] *)mind_arity:inductive_arity;(** Arity sort and original user arity *)mind_consnames:Id.tarray;(** Names of the constructors: [cij] *)mind_user_lc:typesarray;(** Types of the constructors with parameters: [forall params, Tij],
where the Ik are replaced by de Bruijn index in the
context I1:forall params, U1 .. In:forall params, Un *)(** {8 Derived datas } *)mind_nrealargs:int;(** Number of expected real arguments of the type (no let, no params) *)mind_nrealdecls:int;(** Length of realargs context (with let, no params) *)mind_kelim:Sorts.family;(** Highest allowed elimination sort *)mind_nf_lc:(rel_context*types)array;(** Head normalized constructor types so that their conclusion exposes the inductive type *)mind_consnrealargs:intarray;(** Number of expected proper arguments of the constructors (w/o params) *)mind_consnrealdecls:intarray;(** Length of the signature of the constructors (with let, w/o params) *)mind_recargs:wf_paths;(** Signature of recursive arguments in the constructors *)mind_relevance:Sorts.relevance;(** {8 Datas for bytecode compilation } *)mind_nb_constant:int;(** number of constant constructor *)mind_nb_args:int;(** number of no constant constructor *)mind_reloc_tbl:Vmvalues.reloc_table;}typerecursivity_kind=|Finite(** = inductive *)|CoFinite(** = coinductive *)|BiFinite(** = non-recursive, like in "Record" definitions *)typemutual_inductive_body={mind_packets:one_inductive_bodyarray;(** The component of the mutual inductive block *)mind_record:record_info;(** The record information *)mind_finite:recursivity_kind;(** Whether the type is inductive or coinductive *)mind_ntypes:int;(** Number of types in the block *)mind_hyps:Constr.named_context;(** Section hypotheses on which the block depends *)mind_nparams:int;(** Number of expected parameters including non-uniform ones (i.e. length of mind_params_ctxt w/o let-in) *)mind_nparams_rec:int;(** Number of recursively uniform (i.e. ordinary) parameters *)mind_params_ctxt:Constr.rel_context;(** The context of parameters (includes let-in declaration) *)mind_universes:universes;(** Information about monomorphic/polymorphic/cumulative inductives and their universes *)mind_template:template_universesoption;mind_variance:Univ.Variance.tarrayoption;(** Variance info, [None] when non-cumulative. *)mind_sec_variance:Univ.Variance.tarrayoption;(** Variance info for section polymorphic universes. [None]
outside sections. The final variance once all sections are
discharged is [mind_sec_variance ++ mind_variance]. *)mind_private:booloption;(** allow pattern-matching: Some true ok, Some false blocked *)mind_typing_flags:typing_flags;(** typing flags at the time of the inductive creation *)}(** {6 Module declarations } *)(** Functor expressions are forced to be on top of other expressions *)type('ty,'a)functorize=|NoFunctorof'a|MoreFunctorofMBId.t*'ty*('ty,'a)functorize(** The fully-algebraic module expressions : names, applications, 'with ...'.
They correspond to the user entries of non-interactive modules.
They will be later expanded into module structures in [Mod_typing],
and won't play any role into the kernel after that : they are kept
only for short module printing and for extraction. *)typewith_declaration=|WithModofId.tlist*ModPath.t|WithDefofId.tlist*(constr*Univ.AUContext.toption)typemodule_alg_expr=|MEidentofModPath.t|MEapplyofmodule_alg_expr*ModPath.t|MEwithofmodule_alg_expr*with_declaration(** A component of a module structure *)typestructure_field_body=|SFBconstofOpaqueproof.opaqueconstant_body|SFBmindofmutual_inductive_body|SFBmoduleofmodule_body|SFBmodtypeofmodule_type_body(** A module structure is a list of labeled components.
Note : we may encounter now (at most) twice the same label in
a [structure_body], once for a module ([SFBmodule] or [SFBmodtype])
and once for an object ([SFBconst] or [SFBmind]) *)andstructure_body=(Label.t*structure_field_body)list(** A module signature is a structure, with possibly functors on top of it *)andmodule_signature=(module_type_body,structure_body)functorize(** A module expression is an algebraic expression, possibly functorized. *)andmodule_expression=(module_type_body,module_alg_expr)functorizeandmodule_implementation=|Abstract(** no accessible implementation *)|Algebraicofmodule_expression(** non-interactive algebraic expression *)|Structofmodule_signature(** interactive body *)|FullStruct(** special case of [Struct] : the body is exactly [mod_type] *)and'ageneric_module_body={mod_mp:ModPath.t;(** absolute path of the module *)mod_expr:'a;(** implementation *)mod_type:module_signature;(** expanded type *)mod_type_alg:module_expressionoption;(** algebraic type *)mod_delta:Mod_subst.delta_resolver;(**
quotiented set of equivalent constants and inductive names *)mod_retroknowledge:'amodule_retroknowledge}(** For a module, there are five possible situations:
- [Declare Module M : T] then [mod_expr = Abstract; mod_type_alg = Some T]
- [Module M := E] then [mod_expr = Algebraic E; mod_type_alg = None]
- [Module M : T := E] then [mod_expr = Algebraic E; mod_type_alg = Some T]
- [Module M. ... End M] then [mod_expr = FullStruct; mod_type_alg = None]
- [Module M : T. ... End M] then [mod_expr = Struct; mod_type_alg = Some T]
And of course, all these situations may be functors or not. *)andmodule_body=module_implementationgeneric_module_body(** A [module_type_body] is just a [module_body] with no implementation and
also an empty [mod_retroknowledge]. Its [mod_type_alg] contains
the algebraic definition of this module type, or [None]
if it has been built interactively. *)andmodule_type_body=unitgeneric_module_bodyand_module_retroknowledge=|ModBodyRK:Retroknowledge.actionlist->module_implementationmodule_retroknowledge|ModTypeRK:unitmodule_retroknowledge(** Extra invariants :
- No [MEwith] inside a [mod_expr] implementation : the 'with' syntax
is only supported for module types
- A module application is atomic, for instance ((M N) P) :
* the head of [MEapply] can only be another [MEapply] or a [MEident]
* the argument of [MEapply] is now directly forced to be a [ModPath.t].
*)