Reducibility hints guide the kernel's lazy delta reduction strategy. When the kernel encounters a definitional equality constraint
(f ...) =?= (g ...)
where f and g are definitions, it must decide which side to unfold. The rules (implemented in
lazy_delta_reduction_step in src/kernel/type_checker.cpp) are:
- If
fandghave the same hint kind:- Both
.opaqueor both.abbrev: unfold both. - Both
.regular: unfold the one with the greater height first. If their heights are equal (in particular, iffandgare the same definition), first try to compare their arguments for definitional equality (short-circuiting the unfolding if they match), then unfold both.
- Both
- If
fandghave different hint kinds: unfold the one that is not.opaque, preferring to unfold.abbrevover.regular.
The .regular constructor carries a UInt32 definitional height, which is computed by the
elaborator as one plus the maximum height of all .regular constants appearing in the definition's
body (see getMaxHeight). This means .abbrev and .opaque constants do not contribute to the
height. When creating declarations via meta-programming, the height can be specified manually.
The hints only affect performance — they control the order in which definitions are unfolded, but never prevent the kernel from unfolding a definition during type checking.
The ReducibilityHints are not related to the @[reducible]/@[irreducible]/@[semireducible]
attributes. Those attributes are used by the elaborator to control which definitions tactics like
simp, rfl, and dsimp will unfold; they do not affect the kernel. Conversely,
ReducibilityHints are set when a declaration is added to the kernel and cannot be changed
afterwards.
- opaque : ReducibilityHints
- abbrev : ReducibilityHints
- regular : UInt32 → ReducibilityHints
Instances For
Instances For
Instances For
Instances For
Instances For
Base structure for AxiomVal, DefinitionVal, TheoremVal, InductiveVal, ConstructorVal, RecursorVal and QuotVal.
Instances For
- isUnsafe : Bool
Instances For
Instances For
- unsafe : DefinitionSafety
- safe : DefinitionSafety
- partial : DefinitionSafety
Instances For
- value : Expr
- hints : ReducibilityHints
- safety : DefinitionSafety
List of all (including this one) declarations in the same mutual block. Note that this information is not used by the kernel, and is only used to save the information provided by the user when using mutual blocks. Recall that the Lean kernel does not support recursive definitions and they are compiled using recursors and
WellFounded.fix.
Instances For
Instances For
Instances For
- value : Expr
List of all (including this one) declarations in the same mutual block. See comment at
DefinitionVal.all.
Instances For
Value for an opaque constant declaration opaque x : t := e
- value : Expr
- isUnsafe : Bool
List of all (including this one) declarations in the same mutual block. See comment at
DefinitionVal.all.
Instances For
Instances For
Declaration object that can be sent to the kernel.
- axiomDecl (val : AxiomVal) : Declaration
- defnDecl (val : DefinitionVal) : Declaration
- thmDecl (val : TheoremVal) : Declaration
- opaqueDecl (val : OpaqueVal) : Declaration
- quotDecl : Declaration
- mutualDefnDecl (defns : List DefinitionVal) : Declaration
- inductDecl (lparams : List Name) (nparams : Nat) (types : List InductiveType) (isUnsafe : Bool) : Declaration
Instances For
Instances For
Instances For
Returns all top-level names to be defined by adding this declaration to the environment, i.e. excluding nested helper declarations generated automatically.
Instances For
Returns all names to be defined by adding this declaration to the environment. This does not include auxiliary definitions such as projections added by the elaborator, nor auxiliary recursors computed by the kernel for nested inductive types.
Instances For
Instances For
Instances For
The kernel compiles (mutual) inductive declarations (see inductiveDecls) into a set of
Declaration.inductDecl(for each inductive datatype in the mutual Declaration),Declaration.ctorDecl(for each Constructor in the mutual Declaration),Declaration.recDecl(automatically generated recursors).
This data is used to implement iota-reduction efficiently and compile nested inductive declarations.
A series of checks are performed by the kernel to check whether a inductiveDecls
is valid or not.
- numParams : Nat
Number of parameters. A parameter is an argument to the defined type that is fixed over constructors. An example of this is the
α : Typeargument in the vector constructorsnil : Vector α 0andcons : α → Vector α n → Vector α (n+1).The intuition is that the inductive type must exhibit parametric polymorphism over the inductive parameter, as opposed to ad-hoc polymorphism.
- numIndices : Nat
List of all (including this one) inductive datatypes in the mutual declaration containing this one
List of the names of the constructors for this inductive datatype.
- numNested : Nat
- isRec : Bool
truewhen recursive (that is, the inductive type appears as an argument in a constructor). - isUnsafe : Bool
Whether the definition is flagged as unsafe.
- isReflexive : Bool
An inductive type is called reflexive if it has at least one constructor that takes as an argument a function returning the same type we are defining. Consider the type:
inductive WideTree where | branch: (Nat -> WideTree) -> WideTree | leaf: WideTreethis is reflexive due to the presence of the
branch : (Nat -> WideTree) -> WideTreeconstructor.See also: 'Inductive Definitions in the system Coq Rules and Properties' by Christine Paulin-Mohring Section 2.2, Definition 3
Instances For
Instances For
Instances For
Instances For
Instances For
List of all inductive datatypes in the mutual declaration that generated this recursor
- numParams : Nat
Number of parameters
- numIndices : Nat
Number of indices
- numMotives : Nat
Number of motives
- numMinors : Nat
Number of minor premises
- rules : List RecursorRule
A reduction for each Constructor
- k : Bool
It supports K-like reduction. A recursor is said to support K-like reduction if one can assume it behaves like
Equnder axiomK--- that is, it has one constructor, the constructor has 0 arguments, and it is an inductive predicate (ie, it lives in Prop).Examples of inductives with K-like reduction is
Eq,Acc, andAnd.intro. Non-examples areexists(where the constructor has arguments) andOr.intro(which has multiple constructors). - isUnsafe : Bool
Instances For
Instances For
The inductive type of the major argument of the recursor.
Instances For
- kind : QuotKind
Instances For
Information associated with constant declarations.
- axiomInfo (val : AxiomVal) : ConstantInfo
- defnInfo (val : DefinitionVal) : ConstantInfo
- thmInfo (val : TheoremVal) : ConstantInfo
- opaqueInfo (val : OpaqueVal) : ConstantInfo
- quotInfo (val : QuotVal) : ConstantInfo
- inductInfo (val : InductiveVal) : ConstantInfo
- ctorInfo (val : ConstructorVal) : ConstantInfo
- recInfo (val : RecursorVal) : ConstantInfo
Instances For
Returns the value of a definition. With allowOpaque := true, values
of theorems and opaque declarations are also returned.
Instances For
Returns true if this declaration as a value for the purpose of reduction
and type-checking, i.e. is a definition.
With allowOpaque := true, theorems and opaque declarations are also considered to have values.
Instances For
Returns the value of a definition. With allowOpaque := true, values
of theorems and opaque declarations are also returned.
Instances For
List of all (including this one) declarations in the same mutual block.