Equations
Instances For
Controls which constants isDefEq (definitional equality) and whnf (weak head normal form)
are allowed to unfold.
Background: "try-hard" vs "speculative" modes #
During type checking of user input, we assume the input is most likely correct, and we want
Lean to try hard before reporting a failure. Here, it is fine to unfold [semireducible] definitions
(the .default setting).
During proof automation (simp, rw, type class resolution), we perform many speculative
isDefEq calls — most of which fail. In this setting, we do not want to try hard: unfolding
too many definitions is a performance footgun. This is why .reducible exists.
The transparency hierarchy #
The levels form a linear order: none < reducible < instances < default < all.
Each level unfolds everything the previous level does, plus more:
reducible: Only unfolds[reducible]definitions. Used for speculativeisDefEqchecks (e.g., discrimination tree lookups insimp, type class resolution). Think of[reducible]as[inline]for type checking and indexing.instances: Also unfolds[implicit_reducible]definitions. Instance diamonds are common: for example,Add Natcan come from a direct instance or viaSemiring. These instances are all definitionally equal but structurally different, soisDefEqmust unfold them to confirm equality. This level also handles definitions used in types that appear in implicit arguments (e.g.,Nat.add,Array.size). However, these definitions must not be eagerly reduced (instances become huge terms), and discrimination trees do not index them. This makes.instancessafe for speculative checks involving implicit arguments without the performance cost of.default.default: Also unfolds[semireducible]definitions (anything not[irreducible]). Used for type checking user input where we want to try hard.all: Also unfolds[irreducible]definitions. Rarely used.
Implicit arguments and transparency #
When proof automation (e.g., simp, rw) applies a lemma, explicit arguments are checked at the
caller's transparency (typically .reducible). But implicit arguments are often "invisible" to the
user — if a lemma fails to apply because of an implicit argument mismatch, the user is confused.
Historically, Lean bumped transparency to .default for implicit arguments, but this eventually
became a performance bottleneck in Mathlib. The option backward.isDefEq.respectTransparency
(default: true) disables this bump. Instead, instance-implicit arguments ([..]) are checked at
.instances, and other implicit arguments are checked at the caller's transparency.
See also: ReducibilityStatus, backward.isDefEq.respectTransparency,
backward.whnf.reducibleClassField.
- all : TransparencyMode
Unfolds all constants, even those tagged as
@[irreducible]. - default : TransparencyMode
Unfolds all constants except those tagged as
@[irreducible]. Used for type checking user-written terms where we expect the input to be correct and want to try hard. - reducible : TransparencyMode
Unfolds only constants tagged with the
@[reducible]attribute. Used for speculativeisDefEqin proof automation (simp,rw, type class resolution) where most checks fail and we must not try too hard. - instances : TransparencyMode
Unfolds reducible constants and constants tagged with
@[implicit_reducible]. Used for checking implicit arguments during proof automation, and for unfolding class projections applied to instances. Instance diamonds (e.g.,Add Natfrom a direct instance vs fromSemiring) are definitionally equal but structurally different, soisDefEqmust unfold them. Also handles definitions used in types of implicit arguments (e.g.,Nat.add,Array.size). - none : TransparencyMode
Do not unfold anything.
Instances For
Equations
Equations
- Lean.Meta.instBEqTransparencyMode.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
Which structure types should eta be used with?
- all : EtaStructMode
Enable eta for structure and classes.
- notClasses : EtaStructMode
Enable eta only for structures that are not classes.
- none : EtaStructMode
Disable eta for structures and classes.
Instances For
Equations
Equations
- Lean.Meta.instBEqEtaStructMode.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
The configuration for dsimp.
Passed to dsimp using, for example, the dsimp (config := {zeta := false}) syntax.
Implementation note: this structure is only used for processing the (config := ...) syntax, and it is not used internally.
It is immediately converted to Lean.Meta.Simp.Config by Lean.Elab.Tactic.elabSimpConfig.
- zeta : Bool
- beta : Bool
When
true(default:true), performs beta reduction of applications offunexpressions. That is,(fun x => e[x]) vreduces toe[v]. - eta : Bool
TODO (currently unimplemented). When
true(default:true), performs eta reduction forfunexpressions. That is,(fun x => f x)reduces tof. - etaStruct : EtaStructMode
Configures how to determine definitional equality between two structure instances. See documentation for
Lean.Meta.EtaStructMode. - iota : Bool
When
true(default:true), reducesmatchexpressions applied to constructors. - proj : Bool
When
true(default:true), reduces projections of structure constructors. - decide : Bool
- autoUnfold : Bool
When
true(default:false), unfolds applications of functions defined by pattern matching, when one of the patterns applies. This can be enabled using thesimp!syntax. - failIfUnchanged : Bool
If
failIfUnchangedistrue(default:true), then calls tosimp,dsimp, orsimp_allwill fail if they do not make progress. - unfoldPartialApp : Bool
If
unfoldPartialAppistrue(default:false), then calls tosimp,dsimp, orsimp_allwill unfold even partial applications offwhen we requestfto be unfolded. - zetaDelta : Bool
When
true(default:false), local definitions are unfolded. That is, given a local context containingx : t := e, then the free variablexreduces toe. Otherwise,xmust be provided as asimpargument. - index : Bool
When
index(default :true) isfalse,simpwill only use the root symbol to find candidatesimptheorems. It approximates Lean 3simpbehavior. - zetaUnused : Bool
When
true(default :true), thensimpwill remove unusedletandhaveexpressions:let x := v; esimplifies toewhenxdoes not occur ine. - zetaHave : Bool
When
false(default:true), then disables zeta reduction ofhaveexpressions. Ifzetaisfalse, then this option has no effect. Unusedhaves are still removed ifzetaorzetaUnusedare true. - locals : Bool
- instances : Bool
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Lean.Meta.DSimp.instBEqConfig.beq x✝¹ x✝ = false
Instances For
Equations
The configuration for simp.
Passed to simp using, for example, the simp +contextual or simp (maxSteps := 100000) syntax.
See also Lean.Meta.Simp.neutralConfig and Lean.Meta.DSimp.Config.
- maxSteps : Nat
The maximum number of subexpressions to visit when performing simplification. The default is 100000.
- maxDischargeDepth : Nat
When simp discharges side conditions for conditional lemmas, it can recursively apply simplification. The
maxDischargeDepth(default: 2) is the maximum recursion depth when recursively applying simplification to side conditions. - contextual : Bool
When
contextualis true (default:false) and simplification encounters an implicationp → qit includespas an additional simp lemma when simplifyingq. - memoize : Bool
When true (default:
true) then the simplifier caches the result of simplifying each sub-expression, if possible. - singlePass : Bool
When
singlePassistrue(default:false), the simplifier runs through a single round of simplification, which consists of running pre-methods, recursing using congruence lemmas, and then running post-methods. Otherwise, when it isfalse, it iteratively applies this simplification procedure. - zeta : Bool
- beta : Bool
When
true(default:true), performs beta reduction of applications offunexpressions. That is,(fun x => e[x]) vreduces toe[v]. - eta : Bool
TODO (currently unimplemented). When
true(default:true), performs eta reduction forfunexpressions. That is,(fun x => f x)reduces tof. - etaStruct : EtaStructMode
Configures how to determine definitional equality between two structure instances. See documentation for
Lean.Meta.EtaStructMode. - iota : Bool
When
true(default:true), reducesmatchexpressions applied to constructors. - proj : Bool
When
true(default:true), reduces projections of structure constructors. - decide : Bool
- arith : Bool
When
true(default:false), simplifies simple arithmetic expressions. - autoUnfold : Bool
When
true(default:false), unfolds applications of functions defined by pattern matching, when one of the patterns applies. This can be enabled using thesimp!syntax. - dsimp : Bool
- failIfUnchanged : Bool
If
failIfUnchangedistrue(default:true), then calls tosimp,dsimp, orsimp_allwill fail if they do not make progress. - ground : Bool
If
groundistrue(default:false), then ground terms are reduced. A term is ground when it does not contain free or meta variables. Reduction is interrupted at a function applicationf ...iffis marked to not be unfolded. Ground term reduction applies@[seval]lemmas. - unfoldPartialApp : Bool
If
unfoldPartialAppistrue(default:false), then calls tosimp,dsimp, orsimp_allwill unfold even partial applications offwhen we requestfto be unfolded. - zetaDelta : Bool
When
true(default:false), local definitions are unfolded. That is, given a local context containingx : t := e, then the free variablexreduces toe. Otherwise,xmust be provided as asimpargument. - index : Bool
When
index(default :true) isfalse,simpwill only use the root symbol to find candidatesimptheorems. It approximates Lean 3simpbehavior. - implicitDefEqProofs : Bool
If
implicitDefEqProofs := true,simpdoes not create proof terms when the input and output terms are definitionally equal. - zetaUnused : Bool
- catchRuntime : Bool
When
true(default :true), thensimpcatches runtime exceptions and converts them intosimpexceptions. - zetaHave : Bool
When
false(default:true), then disables zeta reduction ofhaveexpressions. Ifzetaisfalse, then this option has no effect. Unusedhaves are still removed ifzetaorzetaUnusedare true. - letToHave : Bool
When
true(default :true), thensimpwill attempt to transformlets intohaves if they are non-dependent. This only applies whenzeta := false. - congrConsts : Bool
When
true(default:true),simptries to realize constantf.congr_simpwhen constructing an auxiliary congruence proof forf. This option exists because the termination prover usessimpandwithoutModifyingEnvwhile constructing the termination proof. Thus, any constant realized bysimpis deleted. - bitVecOfNat : Bool
When
true(default:true), the bitvector simprocs useBitVec.ofNatfor representing bitvector literals. - warnExponents : Bool
When
true(default:true), the^simprocs generate an warning it the exponents are too big. - suggestions : Bool
If
suggestionsistrue,simp?will invoke the currently configured library suggestion engine on the current goal, and attempt to use the resulting suggestions as parameters to thesimptactic. Maximum number of library suggestions to use. If
none, uses the default limit. Only relevant whensuggestionsistrue.- locals : Bool
If
localsistrue,simpwill unfold all definitions from the current file. For local theorems, use+suggestionsinstead. - instances : Bool
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
- Lean.Meta.Simp.instBEqConfig.beq x✝¹ x✝ = false
Instances For
Equations
Instances For
A neutral configuration for simp, turning off all reductions and other built-in simplifications.
Equations
Instances For
Instances For
Configuration for which occurrences that match an expression should be rewritten.
- all : Occurrences
All occurrences should be rewritten.
- pos
(idxs : List Nat)
: Occurrences
A list of indices for which occurrences should be rewritten.
- neg
(idxs : List Nat)
: Occurrences
A list of indices for which occurrences should not be rewritten.
Instances For
Equations
Equations
Equations
- Lean.Meta.instBEqOccurrences.beq Lean.Meta.Occurrences.all Lean.Meta.Occurrences.all = true
- Lean.Meta.instBEqOccurrences.beq (Lean.Meta.Occurrences.pos a) (Lean.Meta.Occurrences.pos b) = (a == b)
- Lean.Meta.instBEqOccurrences.beq (Lean.Meta.Occurrences.neg a) (Lean.Meta.Occurrences.neg b) = (a == b)
- Lean.Meta.instBEqOccurrences.beq x✝¹ x✝ = false
Instances For
Equations
Configuration for the extract_lets tactic.
- proofs : Bool
If true (default: false), extract lets from subterms that are proofs. Top-level lets are always extracted.
- types : Bool
If true (default: true), extract lets from subterms that are types. Top-level lets are always extracted.
- implicits : Bool
If true (default: false), extract lets from subterms that are implicit arguments.
- descend : Bool
- underBinder : Bool
If true (default: true), descend into forall/lambda/let bodies when extracting. Only relevant when
descendis true. - usedOnly : Bool
If true (default: false), eliminate unused lets rather than extract them.
- merge : Bool
If true (default: true), reuse local declarations that have syntactically equal values. Note that even when false, the caching strategy for
extract_letsmay result in fewer extracted let bindings than expected. - useContext : Bool
When merging is enabled, if true (default: true), make use of pre-existing local definitions in the local context.
- onlyGivenNames : Bool
If true (default: false), then once
givenNamesis exhausted, stop extracting lets. Otherwise continue extracting lets. - preserveBinderNames : Bool
If true (default: false), then when no name is provided for a 'let' expression, the name is used as-is without making it be inaccessible. The name still might be inaccessible if the binder name was.
- lift : Bool
If true (default: false), lift non-extractable
lets as far out as possible.
Instances For
Configuration for the lift_lets tactic.