Documentation

Lean.Declaration

inductive Lean.ReducibilityHints:
Type

Reducibility hints are used in the convertibility checker. When trying to solve a constraint such a

       (f ...) =?= (g ...)

where f and g are definitions, the checker has to decide which one will be unfolded. If f (g) is opaque, then g (f) is unfolded if it is also not marked as opaque, Else if f (g) is abbrev, then f (g) is unfolded if g (f) is also not marked as abbrev, Else if f and g are regular, then we unfold the one with the biggest definitional height. Otherwise both are unfolded.

The arguments of the regular Constructor are: the definitional height and the flag selfOpt.

The definitional height is by default computed by the kernel. It only takes into account other regular definitions used in a definition. When creating declarations using meta-programming, we can specify the definitional depth manually.

Remark: the hint only affects performance. None of the hints prevent the kernel from unfolding a declaration during Type checking.

Remark: the ReducibilityHints are not related to the attributes: reducible/irrelevance/semireducible. These attributes are used by the Elaborator. The ReducibilityHints are used by the kernel (and Elaborator). Moreover, the ReducibilityHints cannot be changed after a declaration is added to the kernel.

@[export lean_reducibility_hints_get_height]
Equations
Equations
  • One or more equations did not get rendered due to their size.
Equations
Equations
structure Lean.AxiomValextends Lean.ConstantVal :
Type
Equations
@[export lean_mk_axiom_val]
def Lean.mkAxiomValEx (name : Lean.Name) (levelParams : List Lean.Name) (type : Lean.Expr) (isUnsafe : Bool) :
Equations
  • Lean.mkAxiomValEx name levelParams type isUnsafe = { toConstantVal := { name := name, levelParams := levelParams, type := type }, isUnsafe := isUnsafe }
@[export lean_axiom_val_is_unsafe]
Equations
structure Lean.DefinitionValextends Lean.ConstantVal :
Type
  • value : Lean.Expr
  • 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.

Equations
@[export lean_mk_definition_val]
Equations
  • One or more equations did not get rendered due to their size.
@[export lean_definition_val_get_safety]
Equations
structure Lean.TheoremValextends Lean.ConstantVal :
Type
  • value : Lean.Expr
  • List of all (including this one) declarations in the same mutual block. See comment at DefinitionVal.all.

Equations
structure Lean.OpaqueValextends Lean.ConstantVal :
Type
  • value : Lean.Expr
  • isUnsafe : Bool
  • List of all (including this one) declarations in the same mutual block. See comment at DefinitionVal.all.

Equations
@[export lean_mk_opaque_val]
def Lean.mkOpaqueValEx (name : Lean.Name) (levelParams : List Lean.Name) (type : Lean.Expr) (value : Lean.Expr) (isUnsafe : Bool) (all : List Lean.Name) :
Equations
  • Lean.mkOpaqueValEx name levelParams type value isUnsafe all = { toConstantVal := { name := name, levelParams := levelParams, type := type }, value := value, isUnsafe := isUnsafe, all := all }
@[export lean_opaque_val_is_unsafe]
Equations
structure Lean.Constructor:
Type
Equations
Equations
inductive Lean.Declaration:
Type

Declaration object that can be sent to the kernel.

@[export lean_mk_inductive_decl]
def Lean.mkInductiveDeclEs (lparams : List Lean.Name) (nparams : Nat) (types : List Lean.InductiveType) (isUnsafe : Bool) :
Equations
@[export lean_is_unsafe_inductive_decl]
Equations
@[specialize]
def Lean.Declaration.foldExprM {α : Type} {m : TypeType} [inst : Monad m] (d : Lean.Declaration) (f : αLean.Exprm α) (a : α) :
m α
Equations
  • One or more equations did not get rendered due to their size.
@[inline]
def Lean.Declaration.forExprM {m : TypeType} [inst : Monad m] (d : Lean.Declaration) (f : Lean.Exprm Unit) :
Equations
structure Lean.InductiveValextends Lean.ConstantVal :
Type
  • Number of parameters. A parameter is an argument to the defined type that is fixed over constructors.

    numParams : Nat
  • Number of indices. An index is an argument that varies over constructors.

    An example of this is the n : Nat argument in the vector constructor cons : α → Vector α n → Vector α (n+1)

    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.

    ctors : List Lean.Name
  • true when recursive (that is, the inductive type appears as an argument in a constructor).

    isRec : Bool
  • Whether the definition is flagged as unsafe.

    isUnsafe : Bool
  • isReflexive : Bool
  • An inductive definition T is nested when there is a constructor with an argument x : F T, where F : Type → Type is some suitably behaved (ie strictly positive) function (Eg Array T, List T, T × T, ...).

    isNested : Bool

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. 
Equations
  • One or more equations did not get rendered due to their size.
@[export lean_mk_inductive_val]
def Lean.mkInductiveValEx (name : Lean.Name) (levelParams : List Lean.Name) (type : Lean.Expr) (numParams : Nat) (numIndices : Nat) (all : List Lean.Name) (ctors : List Lean.Name) (isRec : Bool) (isUnsafe : Bool) (isReflexive : Bool) (isNested : Bool) :
Equations
  • One or more equations did not get rendered due to their size.
@[export lean_inductive_val_is_rec]
Equations
@[export lean_inductive_val_is_unsafe]
Equations
@[export lean_inductive_val_is_reflexive]
Equations
@[export lean_inductive_val_is_nested]
Equations
structure Lean.ConstructorValextends Lean.ConstantVal :
Type
  • Inductive type this constructor is a member of

    induct : Lean.Name
  • Constructor index (i.e., Position in the inductive declaration)

    cidx : Nat
  • Number of parameters in inductive datatype.

    numParams : Nat
  • Number of fields (i.e., arity - nparams)

    numFields : Nat
  • isUnsafe : Bool
Equations
  • Lean.instInhabitedConstructorVal = { default := { toConstantVal := default, induct := default, cidx := default, numParams := default, numFields := default, isUnsafe := default } }
@[export lean_mk_constructor_val]
def Lean.mkConstructorValEx (name : Lean.Name) (levelParams : List Lean.Name) (type : Lean.Expr) (induct : Lean.Name) (cidx : Nat) (numParams : Nat) (numFields : Nat) (isUnsafe : Bool) :
Equations
  • One or more equations did not get rendered due to their size.
@[export lean_constructor_val_is_unsafe]
Equations
structure Lean.RecursorRule:
Type
  • Reduction rule for this Constructor

    ctor : Lean.Name
  • Number of fields (i.e., without counting inductive datatype parameters)

    nfields : Nat
  • Right hand side of the reduction rule

    rhs : Lean.Expr

Information for reducing a recursor

Equations
structure Lean.RecursorValextends Lean.ConstantVal :
Type
  • List of all inductive datatypes in the mutual declaration that generated this recursor

  • Number of parameters

    numParams : Nat
  • Number of indices

    numIndices : Nat
  • Number of motives

    numMotives : Nat
  • Number of minor premises

    numMinors : Nat
  • A reduction for each Constructor

  • It supports K-like reduction

    k : Bool
  • isUnsafe : Bool
Equations
  • One or more equations did not get rendered due to their size.
@[export lean_mk_recursor_val]
def Lean.mkRecursorValEx (name : Lean.Name) (levelParams : List Lean.Name) (type : Lean.Expr) (all : List Lean.Name) (numParams : Nat) (numIndices : Nat) (numMotives : Nat) (numMinors : Nat) (rules : List Lean.RecursorRule) (k : Bool) (isUnsafe : Bool) :
Equations
  • One or more equations did not get rendered due to their size.
@[export lean_recursor_k]
Equations
@[export lean_recursor_is_unsafe]
Equations
Equations
Equations
Equations
@[export lean_mk_quot_val]
def Lean.mkQuotValEx (name : Lean.Name) (levelParams : List Lean.Name) (type : Lean.Expr) (kind : Lean.QuotKind) :
Equations
  • Lean.mkQuotValEx name levelParams type kind = { toConstantVal := { name := name, levelParams := levelParams, type := type }, kind := kind }
@[export lean_quot_val_kind]
Equations
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations

List of all (including this one) declarations in the same mutual block.

Equations
  • One or more equations did not get rendered due to their size.
@[extern lean_instantiate_type_lparams]
@[extern lean_instantiate_value_lparams]
Equations