Init.Prelude #
This is the first file in the Lean import hierarchy. It is responsible for setting
up basic definitions, most of which Lean already has "built in knowledge" about,
so it is important that they be set up in exactly this way. (For example, Lean will
use PUnit
in the desugaring of do
notation, or in the pattern match compiler.)
The identity function. id
takes an implicit argument α : Sort u
(a type in any universe), and an argument a : α
, and returns a
.
Although this may look like a useless function, one application of the identity
function is to explicitly put a type on an expression. If e
has type T
,
and T'
is definitionally equal to T
, then @id T' e
typechecks, and Lean
knows that this expression has type T'
rather than T
. This can make a
difference for typeclass inference, since T
and T'
may have different
typeclass instances on them. show T' from e
is sugar for an @id T' e
expression.
Instances For
Function composition, usually written with the infix operator ∘
. A new function is created from
two existing functions, where one function's output is used as input to the other.
Examples:
Function.comp List.reverse (List.drop 2) [3, 2, 4, 1] = [1, 4]
(List.reverse ∘ List.drop 2) [3, 2, 4, 1] = [1, 4]
Conventions for notations in identifiers:
- The recommended spelling of
∘
in identifiers iscomp
.
Instances For
The constant function that ignores its argument.
If a : α
, then Function.const β a : β → α
is the “constant function with value a
”. For all
arguments b : β
, Function.const β a b = a
.
Examples:
Function.const Bool 10 true = 10
Function.const Bool 10 false = 10
Function.const String 10 "any string" = 10
Equations
- Function.const β a x✝ = a
The encoding of let_fun x := v; b
is letFun v (fun x => b)
.
This is equal to (fun x => b) v
, so the value of x
is not accessible to b
.
This is in contrast to let x := v; b
, where the value of x
is accessible to b
.
There is special support for letFun
.
Both WHNF and simp
are aware of letFun
and can reduce it when zeta reduction is enabled,
despite the fact it is marked irreducible
.
For metaprogramming, the function Lean.Expr.letFun?
can be used to recognize a let_fun
expression
to extract its parts as if it were a let
expression.
inferInstance
synthesizes a value of any target type by typeclass
inference. This function has the same type signature as the identity
function, but the square brackets on the [i : α]
argument means that it will
attempt to construct this argument by typeclass inference. (This will fail if
α
is not a class
.) Example:
#check (inferInstance : Inhabited Nat) -- Inhabited Nat
def foo : Inhabited (Nat × Nat) :=
inferInstance
example : foo.default = (default, default) :=
rfl
Equations
inferInstanceAs α
synthesizes a value of any target type by typeclass
inference. This is just like inferInstance
except that α
is given
explicitly instead of being inferred from the target type. It is especially
useful when the target type is some α'
which is definitionally equal to α
,
but the instance we are looking for is only registered for α
(because
typeclass search does not unfold most definitions, but definitional equality
does.) Example:
#check inferInstanceAs (Inhabited Nat) -- Inhabited Nat
Equations
- inferInstanceAs α = i
The canonical universe-polymorphic type with just one element.
It should be used in contexts that require a type to be universe polymorphic, thus disallowing
Unit
.
- unit : PUnit
The only element of the universe-polymorphic unit type.
Instances For
- EStateM.nonBacktrackable
- Lean.Meta.instFastSubsingletonPUnit
- Mathlib.instToExprPUnitOfToLevel_mathlib
- PUnit.encodable
- PUnit.fintype
- PUnit.instBiheytingAlgebra
- PUnit.instBooleanAlgebra
- PUnit.instCompleteAtomicBooleanAlgebra
- PUnit.instCompleteBooleanAlgebra
- PUnit.instCompleteLinearOrder
- PUnit.instDenselyOrdered
- PUnit.instLinearOrder
- PUnit.instUnique
- Primcodable.unit
- instCountablePUnit
- instHashablePUnit
- instInhabitedPUnit
- instReprPUnit
- instSubsingletonPUnit
- instToStringPUnit
The canonical type with one element. This element is written ()
.
Unit
has a number of uses:
- It can be used to model control flow that returns from a function call without providing other information.
- Monadic actions that return
Unit
have side effects without computing values. - In polymorphic types, it can be used to indicate that no data is to be stored in a particular field.
Instances For
- Lake.instDataKindUnit
- Lake.instFamilyDefNameDataTypeMkStr1Unit
- Lake.instFamilyDefNameFacetOutHAppendMkStr1Unit
- Lake.instFamilyDefNameFacetOutHAppendMkStr1Unit_1
- Lake.instFamilyDefNameFacetOutHAppendMkStr1Unit_2
- Lake.instFamilyDefNameFacetOutHAppendMkStr1Unit_3
- Lake.instFamilyDefNameFacetOutHAppendMkStr1Unit_4
- Lake.instFamilyDefNameFacetOutHAppendMkStr1Unit_5
- Lake.instFamilyDefNameFacetOutHAppendMkStr1Unit_6
- Lake.instFamilyDefNameFacetOutHAppendMkStr1Unit_7
- Lake.instFamilyDefNameFacetOutMkStr2Unit
- Lake.instFamilyDefNameFacetOutMkStr2Unit_1
- Lake.instFamilyDefNameFacetOutMkStr2Unit_2
- Lake.instFamilyDefNameFacetOutMkStr2Unit_3
- Lake.instFamilyDefNameFacetOutMkStr2Unit_4
- Lake.instFamilyDefNameFacetOutMkStr2Unit_5
- Lake.instFamilyDefNameFacetOutMkStr2Unit_6
- Lake.instFamilyDefNameFacetOutMkStr2Unit_7
- Lake.instFormatQueryUnit
- Lean.instForInLoopUnit
- Lean.instToExprUnit
- OptionT.instMonadExceptOfUnit
- Plausible.Unit.sampleableExt
- Plausible.Unit.shrinkable
- Unit.fintype
- instMonadBacktrackUnitId_batteries
- instMonadExceptOfUnitOption
- instReprUnit
- instToStringUnit
Auxiliary unsafe constant used by the Compiler when erasing proofs from code.
It may look strange to have an axiom that says "every proposition is true",
since this is obviously unsound, but the unsafe
marker ensures that the
kernel will not let this through into regular proofs. The lower levels of the
code generator don't need proofs in terms, so this is used to stub the proofs
out.
Auxiliary unsafe constant used by the Compiler to mark unreachable code.
Like lcProof
, this is an unsafe axiom
, which means that even though it is
not sound, the kernel will not let us use it for regular proofs.
Executing this expression to actually synthesize a value of type α
causes
immediate undefined behavior, and the compiler does take advantage of this
to optimize the code assuming that it is not called. If it is not optimized out,
it is likely to appear as a print message saying "unreachable code", but this
behavior is not guaranteed or stable in any way.
True
is a proposition and has only an introduction rule, True.intro : True
.
In other words, True
is simply true, and has a canonical proof, True.intro
For more information: Propositional Logic
- intro : True
True
is true, andTrue.intro
(or more commonly,trivial
) is the proof.
False
is the empty proposition. Thus, it has no introduction rules.
It represents a contradiction. False
elimination rule, False.rec
,
expresses the fact that anything follows from a contradiction.
This rule is sometimes called ex falso (short for ex falso sequitur quodlibet),
or the principle of explosion.
For more information: Propositional Logic
The empty type. It has no constructors.
Use Empty.elim
in contexts where a value of type Empty
is in scope.
Not p
, or ¬p
, is the negation of p
. It is defined to be p → False
,
so if your goal is ¬p
you can use intro h
to turn the goal into
h : p ⊢ False
, and if you have hn : ¬p
and h : p
then hn h : False
and (hn h).elim
will prove anything.
For more information: Propositional Logic
Conventions for notations in identifiers:
- The recommended spelling of
¬
in identifiers isnot
.
Instances For
False.elim : False → C
says that from False
, any desired proposition
C
holds. Also known as ex falso quodlibet (EFQ) or the principle of explosion.
The target type is actually C : Sort u
which means it works for both
propositions and types. When executed, this acts like an "unreachable"
instruction: it is undefined behavior to run, but it will probably print
"unreachable code". (You would need to construct a proof of false to run it
anyway, which you can only do using sorry
or unsound axioms.)
The equality relation. It has one introduction rule, Eq.refl
.
We use a = b
as notation for Eq a b
.
A fundamental property of equality is that it is an equivalence relation.
variable (α : Type) (a b c d : α)
variable (hab : a = b) (hcb : c = b) (hcd : c = d)
example : a = d :=
Eq.trans (Eq.trans hab (Eq.symm hcb)) hcd
Equality is much more than an equivalence relation, however. It has the important property that every assertion
respects the equivalence, in the sense that we can substitute equal expressions without changing the truth value.
That is, given h1 : a = b
and h2 : p a
, we can construct a proof for p b
using substitution: Eq.subst h1 h2
.
Example:
example (α : Type) (a b : α) (p : α → Prop)
(h1 : a = b) (h2 : p a) : p b :=
Eq.subst h1 h2
example (α : Type) (a b : α) (p : α → Prop)
(h1 : a = b) (h2 : p a) : p b :=
h1 ▸ h2
The triangle in the second presentation is a macro built on top of Eq.subst
and Eq.symm
, and you can enter it by typing \t
.
For more information: Equality
Conventions for notations in identifiers:
- The recommended spelling of
=
in identifiers iseq
.
Instances For
- AddOpposite.instDecidableEq
- AddUnits.instDecidableEq
- Aesop.Iteration.instDecidableEq
- Aesop.instDecidableEqGoalId
- Aesop.instDecidableEqLevelIndex
- Aesop.instDecidableEqPremiseIndex
- Aesop.instDecidableEqRappId
- Aesop.instDecidableEqSlotIndex
- Array.instDecidableEq
- Batteries.Tactic.Lint.instDecidableEqLintVerbosity
- BitVec.instDecidableEqLiteral
- Fin.instDecidableEqValue
- Finset.Colex.instDecidableEq
- Finset.decidableEq
- Finset.decidableEqPiFinset
- Fintype.decidableEqEmbeddingFintype
- Fintype.decidableEqEquivFintype
- Fintype.decidablePiFintype
- Function.decidableEqPFun
- IO.instDecidableEqTaskState
- Int.instDecidableEq
- LO.FirstOrder.Arith.HierarchySymbol.BoldfaceRel.eq
- LO.FirstOrder.Language.ORing.instDecidableEqFuncORing
- LO.FirstOrder.Language.ORing.instDecidableEqRelORing
- LO.FirstOrder.Language.instDecidableEqFuncEqual
- LO.FirstOrder.Language.instDecidableEqRelEqual
- LO.FirstOrder.Semiformula.instDecidableEq
- LO.FirstOrder.Semiformulaᵢ.instDecidableEq
- LO.FirstOrder.Semiterm.instDecidableEq
- LO.FirstOrder.instDecidableEqFuncOfDecidableEq
- LO.FirstOrder.instDecidableEqRelOfDecidableEq
- LO.FirstOrder.instDecidableEqRelOfDecidableEq_1
- LO.Meta.Kite.Arith.instDecidableEqEdgeType
- LO.Meta.Kite.Modal.instDecidableEqEdgeType
- LO.Modal.Formula.instDecidableEq
- LO.Modal.Kripke.Frame.pointGenerate.instDecidableEqWorld
- LO.Modal.instDecidableEqFormula
- LO.Modal.instDecidableEqNNFormula
- LO.Propositional.Formula.instDecidableEq
- LO.Propositional.Kripke.Frame.pointGenerate.instDecidableEqWorld
- LO.Propositional.NNFormula.instDecidableEq
- LO.Propositional.instDecidableEqFormula
- Lake.Log.instDecidableEqPos
- Lake.Toml.instDecidableEqDateTime
- Lake.Toml.instDecidableEqTime
- Lake.instDecidableEqBackend
- Lake.instDecidableEqBuildKey
- Lake.instDecidableEqBuildType
- Lake.instDecidableEqDate
- Lake.instDecidableEqGlob
- Lake.instDecidableEqHash
- Lake.instDecidableEqJobAction
- Lake.instDecidableEqLogLevel
- Lake.instDecidableEqSemVerCore
- Lake.instDecidableEqStdVer
- Lake.instDecidableEqToolchainVer
- Lake.instDecidableEqVerbosity
- Lean.Elab.Command.Structure.instDecidableEqStructFieldKind
- Lean.Elab.WF.GuessLex.instDecidableEqGuessLexRel
- Lean.Lsp.instDecidableEqCompletionItemKind
- Lean.Lsp.instDecidableEqCompletionItemTag
- Lean.Lsp.instDecidableEqMarkupContent
- Lean.Lsp.instDecidableEqMarkupKind
- Lean.Meta.LibrarySearch.instDecidableEqDeclMod
- Lean.Meta.NormCast.instDecidableEqLabel
- Lean.Meta.Simp.instDecidableEqDischargeResult
- Lean.Meta.instDecidableEqCoeFnType
- Lean.Meta.instDecidableEqProjReductionKind
- Lean.Name.instDecidableEq
- Lean.Omega.instDecidableEqConstraint
- Lean.Omega.instDecidableEqLinearCombo
- Lean.Parser.instDecidableEqRecoveryContext
- Lean.SubExpr.Pos.instDecidableEq
- Lean.instDecidableEqDeclarationLocation
- Lean.instDecidableEqDeclarationRange
- Lean.instDecidableEqJsonNumber
- Lean.instDecidableEqLocalDeclKind
- Lean.instDecidableEqModuleIdx_batteries
- Lean.instDecidableEqOLeanLevel
- Lean.instDecidableEqPosition
- List.Vector.instDecidableEq
- Mathlib.Linter.Flexible.instDecidableEqStained
- MulOpposite.instDecidableEq
- Multiset.decidableEq
- Multiset.decidableEqPiMultiset
- Nat.instPrimesDecidableEq
- Option.instDecidableEq
- PLift.instDecidableEq_mathlib
- PSigma.decidableEq
- Plausible.Bool.printableProp
- Plausible.Eq.printableProp
- Quotient.decidableEq
- Sigma.instDecidableEqSigma
- Std.CloseableChannel.instDecidableEqError
- Std.Internal.instDecidableEqRat
- Std.Net.instDecidableEqAddressFamily
- Std.Net.instDecidableEqIPAddr
- Std.Net.instDecidableEqIPv4Addr
- Std.Net.instDecidableEqIPv6Addr
- Std.Net.instDecidableEqInterfaceAddress
- Std.Net.instDecidableEqMACAddr
- Std.Net.instDecidableEqSocketAddress
- Std.Net.instDecidableEqSocketAddressV4
- Std.Net.instDecidableEqSocketAddressV6
- Std.Sat.AIG.instDecidableEqDecl
- Std.Sat.AIG.instDecidableEqFanin
- Std.Tactic.BVDecide.BVExpr.Cache.instDecidableEqKey
- Std.Tactic.BVDecide.BVExpr.instDecidableEq
- Std.Tactic.BVDecide.LRAT.Internal.instDecidableEqAssignment
- Std.Tactic.BVDecide.LRAT.Internal.instDecidableEqPosFin
- Std.Tactic.BVDecide.LRAT.Internal.instDecidableEqResult
- Std.Tactic.BVDecide.instDecidableEqBVBinOp
- Std.Tactic.BVDecide.instDecidableEqBVBit
- Std.Tactic.BVDecide.instDecidableEqBVUnOp
- Std.Time.Day.Ordinal.instDecidableEqOfYear
- Std.Time.Day.instOffsetDecidableEq
- Std.Time.Day.instOrdinalDecidableEq
- Std.Time.Hour.instOffsetDecidableEq
- Std.Time.Hour.instOrdinalDecidableEq
- Std.Time.Internal.Bounded.instDecidableEq
- Std.Time.Internal.instDecidableEqUnitVal
- Std.Time.Millisecond.instOffsetDecidableEq
- Std.Time.Millisecond.instOrdinalDecidableEq
- Std.Time.Minute.instOffsetDecidableEq
- Std.Time.Minute.instOrdinalDecidableEq
- Std.Time.Month.instOffsetDecidableEq
- Std.Time.Month.instOrdinalDecidableEq
- Std.Time.Month.instQuarterDecidableEq
- Std.Time.Nanosecond.Ordinal.instOfDayDecidableEq
- Std.Time.Nanosecond.instOffsetDecidableEq
- Std.Time.Nanosecond.instOrdinalDecidableEq
- Std.Time.Nanosecond.instSpanDecidableEq
- Std.Time.Second.instDecidableEqOrdinal
- Std.Time.Second.instOffsetDecidableEq
- Std.Time.TimeZone.instDecidableEqOffset
- Std.Time.Week.Ordinal.instOfMonthDecidableEq
- Std.Time.Week.instOffsetDecidableEq
- Std.Time.Week.instOrdinalDecidableEq
- Std.Time.Weekday.instOrdinalDecidableEq
- Std.Time.Year.instOffsetDecidableEq
- Std.Time.instDecidableEqDuration
- Std.Time.instDecidableEqHourMarker
- Std.Time.instDecidableEqPlainDate
- Std.Time.instDecidableEqPlainDateTime
- Std.Time.instDecidableEqPlainTime
- Std.Time.instDecidableEqTimeZone
- Std.Time.instDecidableEqTimestamp
- Std.Time.instDecidableEqValidDate
- Std.Time.instDecidableEqWeekday
- String.instDecidableEqIterator
- Subtype.instDecidableEq
- Sum.instDecidableEq
- System.instDecidableEqFilePath
- ULift.instDecidableEq_mathlib
- Units.instDecidableEq
- Vector.instDecidableEq
- WithBot.decidableEq
- WithTop.decidableEq
- ZMod.decidableEq
- decidableEq_of_subsingleton
- instDecidableEqAdditive
- instDecidableEqBitVec
- instDecidableEqBool
- instDecidableEqChar
- instDecidableEqEmpty
- instDecidableEqFin
- instDecidableEqISize
- instDecidableEqInt16
- instDecidableEqInt32
- instDecidableEqInt64
- instDecidableEqInt8
- instDecidableEqLex
- instDecidableEqList
- instDecidableEqMultiplicative
- instDecidableEqNat
- instDecidableEqOfIff
- instDecidableEqOrdering
- instDecidableEqPEmpty
- instDecidableEqPLift
- instDecidableEqPUnit
- instDecidableEqPos
- instDecidableEqProd
- instDecidableEqRat
- instDecidableEqString
- instDecidableEqSum
- instDecidableEqSym
- instDecidableEqUInt16
- instDecidableEqUInt32
- instDecidableEqUInt64
- instDecidableEqUInt8
- instDecidableEqULift
- instDecidableEqULower
- instDecidableEqUSize
- instDecidableEqVector
- instPNatDecidableEq
- instTransEq
- instTransEq_1
rfl : a = a
is the unique constructor of the equality type. This is the
same as Eq.refl
except that it takes a
implicitly instead of explicitly.
This is a more powerful theorem than it may appear at first, because although
the statement of the theorem is a = a
, Lean will allow anything that is
definitionally equal to that type. So, for instance, 2 + 2 = 4
is proven in
Lean by rfl
, because both sides are the same up to definitional equality.
Equations
- ⋯ = ⋯
The substitution principle for equality. If a = b
and P a
holds,
then P b
also holds. We conventionally use the name motive
for P
here,
so that you can specify it explicitly using e.g.
Eq.subst (motive := fun x => x < 5)
if it is not otherwise inferred correctly.
This theorem is the underlying mechanism behind the rw
tactic, which is
essentially a fancy algorithm for finding good motive
arguments to usefully
apply this theorem to replace occurrences of a
with b
in the goal or
hypotheses.
For more information: Equality
Cast across a type equality. If h : α = β
is an equality of types, and
a : α
, then a : β
will usually not typecheck directly, but this function
will allow you to work around this and embed a
in type β
as cast h a : β
.
It is best to avoid this function if you can, because it is more complicated to reason about terms containing casts, but if the types don't match up definitionally sometimes there isn't anything better you can do.
For more information: Equality
Congruence in the function argument: if a₁ = a₂
then f a₁ = f a₂
for
any (nondependent) function f
. This is more powerful than it might look at first, because
you can also use a lambda expression for f
to prove that
<something containing a₁> = <something containing a₂>
. This function is used
internally by tactics like congr
and simp
to apply equalities inside
subterms.
For more information: Equality
Congruence in both function and argument. If f₁ = f₂
and a₁ = a₂
then
f₁ a₁ = f₂ a₂
. This only works for nondependent functions; the theorem
statement is more complex in the dependent case.
For more information: Equality
Initialize the Quotient Module, which effectively adds the following definitions:
opaque Quot {α : Sort u} (r : α → α → Prop) : Sort u
opaque Quot.mk {α : Sort u} (r : α → α → Prop) (a : α) : Quot r
opaque Quot.lift {α : Sort u} {r : α → α → Prop} {β : Sort v} (f : α → β) :
(∀ a b : α, r a b → Eq (f a) (f b)) → Quot r → β
opaque Quot.ind {α : Sort u} {r : α → α → Prop} {β : Quot r → Prop} :
(∀ a : α, β (Quot.mk r a)) → ∀ q : Quot r, β q
Low-level quotient types. Quotient types coarsen the propositional equality for a type α
, so that
terms related by some relation r
are considered equal in Quot r
.
Set-theoretically, Quot r
can seen as the set of equivalence classes of α
modulo r
. Functions
from Quot r
must prove that they respect r
: to define a function f : Quot r → β
, it is
necessary to provide f' : α → β
and prove that for all x : α
and y : α
, r x y → f' x = f' y
.
Quot
is a built-in primitive:
Quot.mk
places elements of the underlying typeα
into the quotient.Quot.lift
allows the definition of functions from the quotient to some other type.Quot.sound
asserts the equality of elements related byr
.Quot.ind
is used to write proofs about quotients by assuming that all elements are constructed withQuot.mk
.
The relation r
is not required to be an equivalence relation; the resulting quotient type's
equality extends r
to an equivalence as a consequence of the rules for equality and quotients.
When r
is an equivalence relation, it can be more convenient to use the higher-level type
Quotient
.
Places an element of a type into the quotient that equates terms according to the provided relation.
Given v : α
and relation r : α → α → Prop
, Quot.mk r v : Quot r
is like v
, except all
observations of v
's value must respect r
.
Quot.mk
is a built-in primitive:
Quot
is the built-in quotient type.Quot.lift
allows the definition of functions from the quotient to some other type.Quot.sound
asserts the equality of elements related byr
.Quot.ind
is used to write proofs about quotients by assuming that all elements are constructed withQuot.mk
.
A reasoning principle for quotients that allows proofs about quotients to assume that all values are
constructed with Quot.mk
.
Quot.rec
is analogous to the recursor for a structure, and can
be used when the resulting type is not necessarily a proposition.
Quot.ind
is a built-in primitive:
Quot
is the built-in quotient type.Quot.mk
places elements of the underlying typeα
into the quotient.Quot.lift
allows the definition of functions from the quotient to some other type.Quot.sound
asserts the equality of elements related byr
.
Lifts a function from an underlying type to a function on a quotient, requiring that it respects the quotient's relation.
Given a relation r : α → α → Prop
and a quotient Quot r
, applying a function f : α → β
requires a proof a
that f
respects r
. In this case, Quot.lift f a : Quot r → β
computes the
same values as f
.
Lean's type theory includes a definitional reduction from
Quot.lift f h (Quot.mk r v)
to f v
.
Quot.lift
is a built-in primitive:
Quot
is the built-in quotient type.Quot.mk
places elements of the underlying typeα
into the quotient.Quot.sound
asserts the equality of elements related byr
Quot.ind
is used to write proofs about quotients by assuming that all elements are constructed withQuot.mk
; it is analogous to the recursor for a structure.
Heterogeneous equality. HEq a b
asserts that a
and b
have the same
type, and casting a
across the equality yields b
, and vice versa.
You should avoid using this type if you can. Heterogeneous equality does not
have all the same properties as Eq
, because the assumption that the types of
a
and b
are equal is often too weak to prove theorems of interest. One
important non-theorem is the analogue of congr
: If HEq f g
and HEq x y
and f x
and g y
are well typed it does not follow that HEq (f x) (g y)
.
(This does follow if you have f = g
instead.) However if a
and b
have
the same type then a = b
and HEq a b
are equivalent.
The product type, usually written α × β
. Product types are also called pair or tuple types.
Elements of this type are pairs in which the first element is an α
and the second element is a
β
.
Products nest to the right, so (x, y, z) : α × β × γ
is equivalent to (x, (y, z)) : α × (β × γ)
.
Conventions for notations in identifiers:
- The recommended spelling of
×
in identifiers isProd
.
- fst : α
The first element of a pair.
- snd : β
The second element of a pair.
Instances For
- Denumerable.prod
- Encodable.Prod.encodable
- Finite.instProd
- Function.hasUncurryInduction
- Lake.instForInNameMapProdName_lake
- Lean.AssocList.instForInProd
- Lean.KVMap.instForInProdNameDataValue
- Lean.Lsp.instForInModuleRefsProdRefIdentRefInfo
- Lean.Meta.AC.instContextInformationProdPreContextArrayBool
- Lean.NameMap.instForInProdName
- Lean.Parser.TokenMap.instForInProdNameList
- Lean.PersistentHashMap.instForInProd
- Lean.RBMap.instForInProd
- Lean.SMap.instForInProd
- Lean.SMap.instForMProd
- Lean.Server.Watchdog.RequestQueueMap.instForInProdRequestIDMessage
- Lean.Server.instRpcEncodableProd
- Lean.instForInLMVarIdMapProdLMVarId
- Lean.instForInMVarIdMapProdMVarId
- Lean.instForInOptionsProdNameDataValue
- Lean.instFromJsonProd
- Lean.instQuoteProdMkStr1
- Lean.instToExprProdOfToLevel
- Lean.instToFormatProdNameDataValue
- Lean.instToJsonProd
- Lean.instToMessageDataProd
- Plausible.Prod.sampleableExt
- Plausible.Prod.shrinkable
- Primcodable.prod
- Prod.IsTrichotomous
- Prod.Lex.instIsWellFounded
- Prod.SubtractionCommMonoid
- Prod.infSet
- Prod.infinite_of_left
- Prod.infinite_of_right
- Prod.instAdd
- Prod.instAddCancelCommMonoid
- Prod.instAddCancelMonoid
- Prod.instAddCommGroup
- Prod.instAddCommMonoid
- Prod.instAddCommSemigroup
- Prod.instAddGroup
- Prod.instAddLeftCancelMonoid
- Prod.instAddLeftCancelSemigroup
- Prod.instAddMonoid
- Prod.instAddRightCancelMonoid
- Prod.instAddRightCancelSemigroup
- Prod.instAddSemigroup
- Prod.instAddZeroClass
- Prod.instBiheytingAlgebra
- Prod.instBooleanAlgebra
- Prod.instBot
- Prod.instBoundedOrder
- Prod.instCancelCommMonoid
- Prod.instCancelMonoid
- Prod.instCoframe
- Prod.instCoheytingAlgebra
- Prod.instCommGroup
- Prod.instCommMonoid
- Prod.instCommSemigroup
- Prod.instCompleteAtomicBooleanAlgebra
- Prod.instCompleteBooleanAlgebra
- Prod.instCompleteDistribLattice
- Prod.instCompleteLattice
- Prod.instCompletelyDistribLattice
- Prod.instDistribLattice
- Prod.instDiv
- Prod.instDivInvMonoid
- Prod.instDivisionCommMonoid
- Prod.instDivisionMonoid
- Prod.instFrame
- Prod.instGeneralizedBooleanAlgebra
- Prod.instGeneralizedCoheytingAlgebra
- Prod.instGeneralizedHeytingAlgebra
- Prod.instGroup
- Prod.instHImp
- Prod.instHNot
- Prod.instHasCompl
- Prod.instHeytingAlgebra
- Prod.instInv
- Prod.instInvolutiveInv
- Prod.instInvolutiveNeg
- Prod.instIsAddCancel
- Prod.instIsAddLeftCancel
- Prod.instIsAddRightCancel
- Prod.instIsAntisymmLexOfIsStrictOrder
- Prod.instIsAsymmLex
- Prod.instIsCancelMul
- Prod.instIsLeftCancelMul
- Prod.instIsReflLex
- Prod.instIsReflLex_1
- Prod.instIsRightCancelMul
- Prod.instIsTransLex
- Prod.instLE_mathlib
- Prod.instLattice
- Prod.instLawfulBEq
- Prod.instLeftCancelMonoid
- Prod.instLeftCancelSemigroup
- Prod.instLocallyFiniteOrder
- Prod.instLocallyFiniteOrderBot
- Prod.instLocallyFiniteOrderTop
- Prod.instMax_mathlib
- Prod.instMin_mathlib
- Prod.instMonoid
- Prod.instMul
- Prod.instMulOneClass
- Prod.instNatPowAssoc
- Prod.instNeg
- Prod.instOmegaCompletePartialOrder
- Prod.instOne
- Prod.instOrderBot
- Prod.instOrderTop
- Prod.instPartialOrder
- Prod.instPow
- Prod.instPreorder
- Prod.instReflBEq
- Prod.instRightCancelMonoid
- Prod.instRightCancelSemigroup
- Prod.instSDiff
- Prod.instSMul
- Prod.instSemigroup
- Prod.instSemilatticeInf
- Prod.instSemilatticeSup
- Prod.instSub
- Prod.instSubtractionMonoid
- Prod.instTop
- Prod.instVAdd
- Prod.instWellFoundedRelation
- Prod.instZero
- Prod.isEmpty_left
- Prod.isEmpty_right
- Prod.isIrrefl
- Prod.isTotal_left
- Prod.isTotal_right
- Prod.subNegMonoid
- Prod.supSet
- Prod.wellFoundedGT
- Prod.wellFoundedLT
- Std.ExtHashMap.instInsertProdOfEquivBEqOfLawfulHashable
- Std.ExtHashMap.instLawfulSingletonProd
- Std.ExtHashMap.instSingletonProdOfEquivBEqOfLawfulHashable
- Std.HashMap.Raw.instForInProd
- Std.HashMap.Raw.instForMProd
- Std.HashMap.Raw.instInsertProdOfBEqOfHashable
- Std.HashMap.Raw.instLawfulSingletonProd
- Std.HashMap.Raw.instSingletonProdOfBEqOfHashable
- Std.HashMap.instForInProd
- Std.HashMap.instForMProd
- Std.HashMap.instInsertProd
- Std.HashMap.instLawfulSingletonProd
- Std.HashMap.instSingletonProd
- Std.TreeMap.Raw.instForInProd
- Std.TreeMap.Raw.instForMProd
- Std.TreeMap.Raw.instInsertProd
- Std.TreeMap.Raw.instLawfulSingletonProd
- Std.TreeMap.Raw.instSingletonProd
- Std.TreeMap.instForInProd
- Std.TreeMap.instForMProd
- Std.TreeMap.instInsertProd
- Std.TreeMap.instLawfulSingletonProd
- Std.TreeMap.instSingletonProd
- Std.instLawfulEqOrdProd
- Std.instOrientedOrdProd
- Std.instReflOrdProd
- Std.instTransOrdProd
- instBEqProd
- instCountableProd
- instDenselyOrderedProd
- instFintypeProd
- instHashableProd
- instInhabitedProd
- instIsWellOrderProdLex
- instNonemptyProd
- instReprProdOfReprTuple
- instReprTupleProdOfRepr
- instStreamProd
- instSubsingletonProd
- instToFormatProd
- instToStringProd
- instUncountableProdOfNonempty
- instUncountableProdOfNonempty_1
- noMaxOrder_of_left
- noMaxOrder_of_right
- noMinOrder_of_left
- noMinOrder_of_right
- nontrivial_prod_left
- nontrivial_prod_right
- small_prod
A product type in which the types may be propositions, usually written α ×' β
.
This type is primarily used internally and as an implementation detail of proof automation. It is rarely useful in hand-written code.
Conventions for notations in identifiers:
- The recommended spelling of
×'
in identifiers isPProd
.
- fst : α
The first element of a pair.
- snd : β
The second element of a pair.
A product type in which both α
and β
are in the same universe.
It is called MProd
is because it is the universe-monomorphic product type.
- fst : α
The first element of a pair.
- snd : β
The second element of a pair.
Instances For
And a b
, or a ∧ b
, is the conjunction of propositions. It can be
constructed and destructed like a pair: if ha : a
and hb : b
then
⟨ha, hb⟩ : a ∧ b
, and if h : a ∧ b
then h.left : a
and h.right : b
.
Conventions for notations in identifiers:
Or a b
, or a ∨ b
, is the disjunction of propositions. There are two
constructors for Or
, called Or.inl : a → a ∨ b
and Or.inr : b → a ∨ b
,
and you can use match
or cases
to destruct an Or
assumption into the
two cases.
Conventions for notations in identifiers:
The Boolean values, true
and false
.
Logically speaking, this is equivalent to Prop
(the type of propositions). The distinction is
important for programming: both propositions and their proofs are erased in the code generator,
while Bool
corresponds to the Boolean type in most programming languages and carries precisely one
bit of run-time information.
Instances For
- Batteries.instLawfulOrdBool
- BitVec.instGetElemNatBoolLt
- Bool.countable
- Bool.encodable
- Bool.fintype
- Bool.instBooleanAlgebra
- Bool.instBoundedOrder
- Bool.instDistribLattice
- Bool.instFinite
- Bool.instLE
- Bool.instLT
- Bool.instMax
- Bool.instMin
- Bool.instNontrivial
- Bool.instPartialOrder
- Bool.instWellFoundedGT
- Bool.instWellFoundedLT
- Bool.linearOrder
- Lake.InputDirConfig.text.instConfigField
- Lake.InputFileConfig.text.instConfigField
- Lake.LeanExeConfig.supportInterpreter.instConfigField
- Lake.LeanLibConfig.precompileModules.instConfigField
- Lake.PackageConfig.bootstrap.instConfigField
- Lake.PackageConfig.precompileModules.instConfigField
- Lake.PackageConfig.preferReleaseBuild.instConfigField
- Lake.PackageConfig.reservoir.instConfigField
- Lake.instComputeHashBoolId
- Lake.instDataKindBool
- Lake.instFamilyDefNameDataTypeMkStr1Bool
- Lake.instFamilyDefNameFacetOutHAppendMkStr1Bool
- Lake.instFamilyDefNameFacetOutHAppendMkStr1Bool_1
- Lake.instFamilyDefNameFacetOutHAppendMkStr1Bool_2
- Lake.instFamilyDefNameFacetOutMkStr2Bool
- Lake.instFamilyDefNameFacetOutMkStr2Bool_1
- Lake.instFamilyDefNameFacetOutMkStr2Bool_2
- Lean.Compiler.LCNF.Simp.ConstantFold.instLiteralBool
- Lean.Json.instCoeBool
- Lean.KVMap.instValueBool
- Lean.Meta.instReduceEvalBool_qq
- Lean.instCoeBoolDataValue
- Lean.instCoeBoolLeanOptionValue
- Lean.instExceptToEmojiBool
- Lean.instFromJsonBool
- Lean.instQuoteBoolMkStr1
- Lean.instToExprBool
- Lean.instToJsonBool
- Plausible.Bool.sampleableExt
- Plausible.Bool.shrinkable
- Plausible.Random.instBool
- Primcodable.bool
- Std.Bool.instLawfulEqOrdBool
- Std.Bool.instTransOrdBool
- boolToProp
- boolToSort
- decPropToBool
- instHashableBool
- instInhabitedBool
- instLawfulBEqBool
- instOrdBool
- instReprAtomBool
- instReprBool
- instToBoolBool
- instToStringBool
All the elements of a type that satisfy a predicate.
Subtype p
, usually written { x : α // p x }
or { x // p x }
, contains all elements x : α
for
which p x
is true. Its constructor is a pair of the value and the proof that it satisfies the
predicate. In run-time code, { x : α // p x }
is represented identically to α
.
There is a coercion from { x : α // p x }
to α
, so elements of a subtype may be used where the
underlying type is expected.
Examples:
{ n : Nat // n % 2 = 0 }
is the type of even numbers.{ xs : Array String // xs.size = 5 }
is the type of arrays with fiveString
s.- Given
xs : List α
,List { x : α // x ∈ xs }
is the type of lists in which all elements are contained inxs
.
Conventions for notations in identifiers:
- The recommended spelling of
{ x // p x }
in identifiers issubtype
.
- val : α
The value in the underlying type that satisfies the predicate.
- property : p self.val
The proof that
val
satisfies the predicatep
.
Instances For
- Acc.wfRel
- Filter.inhabitedMem
- Finset.FinsetCoe.canLift
- Finset.Subtype.fintype
- Finset.fintypeCoeSort
- Finset.instIsEmpty
- Finset.instUniqueSubtypeMemSingleton
- Fintype.subtypeEq
- Fintype.subtypeEq'
- Flag.instBoundedOrderSubtypeMem
- Flag.instLinearOrderSubtypeMemOfDecidableLEOfDecidableLTOfDecidableEq
- Flag.instOrderBotSubtypeMem
- Flag.instOrderTopSubtypeMem
- IsWellOrder.subtype_nonempty
- LO.FirstOrder.Structure.ClosedSubset.toStructure
- List.Nodup.finite
- List.Subtype.fintype
- List.finiteNodupList
- MulPosMono.to_covariantClass_pos_mul_le
- MulPosReflectLT.to_contravariantClass_pos_mul_lt
- Multiset.Subtype.fintype
- Nat.Partrec.Code.instCountableSubtypeForallComputable
- Nat.Partrec.Code.instCountableSubtypePFunPartrec
- Nonneg.add
- Nonneg.addCommMonoid
- Nonneg.addMonoid
- Nonneg.addMonoidWithOne
- Nonneg.commMonoidWithZero
- Nonneg.commSemiring
- Nonneg.inhabited
- Nonneg.monoidWithZero
- Nonneg.mul
- Nonneg.natCast
- Nonneg.nsmul
- Nonneg.one
- Nonneg.pow
- Nonneg.semiring
- Nonneg.sub
- Nonneg.zero
- Plausible.Subtype.shrinkable
- PosMulMono.to_covariantClass_pos_mul_le
- PosMulReflectLT.to_contravariantClass_pos_mul_lt
- Positive.addCommSemigroup
- Positive.addLeftCancelSemigroup
- Positive.addLeftMono
- Positive.addLeftReflectLE
- Positive.addLeftReflectLT
- Positive.addLeftStrictMono
- Positive.addRightCancelSemigroup
- Positive.addRightReflectLE
- Positive.addRightReflectLT
- Positive.addRightStrictMono
- Positive.addSemigroup
- Positive.commMonoid
- Positive.instAddSubtypeLtOfNat_mathlib
- Positive.instDistribSubtypeLtOfNat
- Positive.instMonoidSubtypeLtOfNat
- Positive.instMulSubtypeLtOfNat_mathlib
- Positive.instOneSubtypeLtOfNat_mathlib
- Positive.instPowSubtypeLtOfNatNat_mathlib
- Positive.instSemigroupSubtypeLtOfNat
- Positive.isOrderedCancelMonoid
- Positive.isOrderedMonoid
- Set.Finite.inhabited
- Subrel.instIsAsymmSubtype
- Subrel.instIsIrreflSubtype
- Subrel.instIsPreorderSubtype
- Subrel.instIsReflSubtype
- Subrel.instIsStrictOrderSubtype
- Subrel.instIsSymmSubtype
- Subrel.instIsTransSubtype
- Subrel.instIsTrichotomousSubtype
- Subrel.instIsWellFoundedSubtype
- Subrel.instIsWellOrderSubtype
- Subtype.canLift
- Subtype.countable
- Subtype.encodable
- Subtype.finite
- Subtype.fintype
- Subtype.instBEq
- Subtype.instHasEquiv_mathlib
- Subtype.instLawfulBEq
- Subtype.instLinearOrder
- Subtype.instLocallyFiniteOrder
- Subtype.instLocallyFiniteOrderBot
- Subtype.instLocallyFiniteOrderTop
- Subtype.instReflBEq
- Subtype.instSetoid_mathlib
- Subtype.isEmpty_false
- Subtype.le
- Subtype.lt
- Subtype.partialOrder
- Subtype.preorder
- Subtype.wellFoundedGT
- Subtype.wellFoundedLT
- Unique.subtypeEq
- Unique.subtypeEq'
- fintypeNodupList
- instFiniteSubtypeLeOfLocallyFiniteOrderBot
- instFiniteSubtypeLeOfLocallyFiniteOrderTop
- instFiniteSubtypeLtOfLocallyFiniteOrderBot
- instFiniteSubtypeLtOfLocallyFiniteOrderTop
- instHashableSubtype
- instIsEmptySubtype
- instLocallyFiniteOrderBotSubtypeLeOfDecidableLEOfLocallyFiniteOrder
- instLocallyFiniteOrderBotSubtypeLtOfDecidableLTOfLocallyFiniteOrder
- instLocallyFiniteOrderTopSubtypeLeOfDecidableLEOfLocallyFiniteOrder
- instLocallyFiniteOrderTopSubtypeLtOfDecidableLTOfLocallyFiniteOrder
- instReprSubtype
- instSubsingletonSubtype_mathlib
- instToStringSubtype
- nonempty_gt
- nonempty_lt
- small_subtype
- subtypeCoe
Gadget for marking output parameters in type classes.
For example, the Membership
class is defined as:
class Membership (α : outParam (Type u)) (γ : Type v)
This means that whenever a typeclass goal of the form Membership ?α ?γ
comes
up, Lean will wait to solve it until ?γ
is known, but then it will run
typeclass inference, and take the first solution it finds, for any value of ?α
,
which thereby determines what ?α
should be.
This expresses that in a term like a ∈ s
, s
might be a Set α
or
List α
or some other type with a membership operation, and in each case
the "member" type α
is determined by looking at the container type.
Gadget for marking semi output parameters in type classes.
Semi-output parameters influence the order in which arguments to type class
instances are processed. Lean determines an order where all non-(semi-)output
parameters to the instance argument have to be figured out before attempting to
synthesize an argument (that is, they do not contain assignable metavariables
created during TC synthesis). This rules out instances such as [Mul β] : Add α
(because β
could be anything). Marking a parameter as semi-output is a
promise that instances of the type class will always fill in a value for that
parameter.
For example, the Coe
class is defined as:
class Coe (α : semiOutParam (Sort u)) (β : Sort v)
This means that all Coe
instances should provide a concrete value for α
(i.e., not an assignable metavariable). An instance like Coe Nat Int
or Coe α (Option α)
is fine, but Coe α Nat
is not since it does not provide a value
for α
.
Equations
- semiOutParam α = α
Auxiliary axiom used to implement the sorry
term and tactic.
The sorry
term/tactic expands to sorryAx _ (synthetic := false)
.
It is intended for stubbing-out incomplete parts of a value or proof while still having a syntactically correct skeleton.
Lean will give a warning whenever a declaration uses sorry
, so you aren't likely to miss it,
but you can check if a declaration depends on sorry
either directly or indirectly by looking for sorryAx
in the output
of the #print axioms my_thm
command.
The synthetic
flag is false when a sorry
is written explicitly by the user, but it is
set to true
when a tactic fails to prove a goal, or if there is a type error
in the expression. A synthetic sorry
acts like a regular one, except that it
suppresses follow-up errors in order to prevent an error from causing a cascade
of other errors because the desired term was not constructed.
Inhabited α
is a typeclass that says that α
has a designated element,
called (default : α)
. This is sometimes referred to as a "pointed type".
This class is used by functions that need to return a value of the type
when called "out of domain". For example, Array.get! arr i : α
returns
a value of type α
when arr : Array α
, but if i
is not in range of
the array, it reports a panic message, but this does not halt the program,
so it must still return a value of type α
(and in fact this is required
for logical consistency), so in this case it returns default
.
- default : α
Instances
- AbsoluteValue.instInhabited
- AddAut.instInhabited
- AddEquiv.instInhabited
- AddMonoid.End.instInhabited
- AddOpposite.instInhabited
- AddUnits.instInhabited
- Aesop.BaseM.instInhabitedState
- Aesop.ClusterState.instInhabited
- Aesop.Frontend.instInhabitedAttrConfig
- Aesop.Frontend.instInhabitedDBuilderName
- Aesop.Frontend.instInhabitedFeature
- Aesop.Frontend.instInhabitedPriority
- Aesop.Frontend.instInhabitedRuleExpr
- Aesop.Frontend.instInhabitedRuleSets
- Aesop.NormM.instInhabitedState
- Aesop.RulePatternIndex.instInhabitedEntry
- Aesop.SaturateM.instInhabitedContext
- Aesop.SaturateM.instInhabitedState
- Aesop.Script.DynStructureM.instInhabitedContext
- Aesop.Script.instInhabitedSScript
- Aesop.Script.instInhabitedTacticState
- Aesop.SearchM.instInhabited
- Aesop.SearchM.instInhabitedState
- Aesop.TreeM.instInhabited
- Aesop.UnsafeQueue.instInhabited
- Aesop.instCasesPatternInhabited
- Aesop.instInhabitedBaseRuleSet
- Aesop.instInhabitedBaseRuleSetMember
- Aesop.instInhabitedBuilderName
- Aesop.instInhabitedCasesTarget
- Aesop.instInhabitedCompleteMatch
- Aesop.instInhabitedDeclaredRuleSets
- Aesop.instInhabitedDisplayRuleName
- Aesop.instInhabitedElabRuleTerm
- Aesop.instInhabitedFVarIdSubst
- Aesop.instInhabitedForwardIndex
- Aesop.instInhabitedForwardRule
- Aesop.instInhabitedForwardRuleInfo
- Aesop.instInhabitedForwardRuleMatch
- Aesop.instInhabitedForwardRuleMatches
- Aesop.instInhabitedForwardRulePriority
- Aesop.instInhabitedForwardState
- Aesop.instInhabitedGlobalRuleSet
- Aesop.instInhabitedGlobalRuleSetMember
- Aesop.instInhabitedGoalDiff
- Aesop.instInhabitedGoalId
- Aesop.instInhabitedGoalOrigin
- Aesop.instInhabitedGoalState
- Aesop.instInhabitedGoalWithMVars
- Aesop.instInhabitedHyp
- Aesop.instInhabitedIndex
- Aesop.instInhabitedIndexMatchLocation
- Aesop.instInhabitedIndexMatchResult
- Aesop.instInhabitedIndexingMode
- Aesop.instInhabitedInstMap
- Aesop.instInhabitedLevelIndex
- Aesop.instInhabitedLocalNormSimpRule
- Aesop.instInhabitedLocalRuleSet
- Aesop.instInhabitedLocalRuleSetMember
- Aesop.instInhabitedMVarClusterData
- Aesop.instInhabitedMatch
- Aesop.instInhabitedNanos
- Aesop.instInhabitedNodeState
- Aesop.instInhabitedNormRuleInfo
- Aesop.instInhabitedNormSimpContext
- Aesop.instInhabitedNormSimpRule
- Aesop.instInhabitedNormalizationState
- Aesop.instInhabitedOptions
- Aesop.instInhabitedOptions'
- Aesop.instInhabitedPINF
- Aesop.instInhabitedPINFRaw
- Aesop.instInhabitedPatSubstSource
- Aesop.instInhabitedPercent
- Aesop.instInhabitedPhaseName
- Aesop.instInhabitedPhaseSpec
- Aesop.instInhabitedPostponedSafeRule
- Aesop.instInhabitedPremiseIndex
- Aesop.instInhabitedRPINFCache
- Aesop.instInhabitedRappId
- Aesop.instInhabitedRawHyp
- Aesop.instInhabitedRegularRule
- Aesop.instInhabitedRule
- Aesop.instInhabitedRuleBuilderInput
- Aesop.instInhabitedRuleBuilderOptions
- Aesop.instInhabitedRuleName
- Aesop.instInhabitedRulePattern
- Aesop.instInhabitedRulePatternCache
- Aesop.instInhabitedRulePatternIndex
- Aesop.instInhabitedRuleState
- Aesop.instInhabitedRuleStats
- Aesop.instInhabitedRuleTac
- Aesop.instInhabitedRuleTacDescr
- Aesop.instInhabitedRuleTacInput
- Aesop.instInhabitedRuleTacOutput
- Aesop.instInhabitedRuleTerm
- Aesop.instInhabitedSafeRuleInfo
- Aesop.instInhabitedSafety
- Aesop.instInhabitedScopeName
- Aesop.instInhabitedScriptGenerated
- Aesop.instInhabitedSlot
- Aesop.instInhabitedSlotIndex
- Aesop.instInhabitedStats
- Aesop.instInhabitedStrategy
- Aesop.instInhabitedSubgoal
- Aesop.instInhabitedSubstitution
- Aesop.instInhabitedTraceOption
- Aesop.instInhabitedUnfoldRule
- Aesop.instInhabitedUnionFind
- Aesop.instInhabitedUnorderedArraySet
- Aesop.instInhabitedUnsafeQueueEntry
- Aesop.instInhabitedUnsafeRuleInfo
- Aesop.instInhabitedVariableMap
- Aesop.instIterationInhabited
- ApplicativeTransformation.instInhabited
- Array.instInhabited
- Associates.instInhabited
- Batteries.BinomialHeap.instInhabited
- Batteries.CodeAction.instInhabitedTacticCodeActionEntry
- Batteries.CodeAction.instInhabitedTacticCodeActions
- Batteries.Tactic.Alias.instInhabitedAliasInfo
- Batteries.Tactic.Lint.instInhabitedLintVerbosity
- Batteries.Util.LibraryNote.instLibraryNoteEntryInhabited
- BitVec.instInhabited
- BotHom.instInhabited
- BoundedLatticeHom.instInhabited
- BoundedOrderHom.instInhabited
- ByteArray.instInhabited
- ByteArray.instInhabitedIterator
- Cardinal.instInhabited
- Char.instInhabited
- ClosureOperator.instInhabited
- Complementeds.instInhabited
- EStateM.instInhabited
- EStateM.instInhabitedResult
- Equiv.inhabited'
- ExceptCpsT.instInhabited
- FBinopElab.instInhabitedSRec
- Filter.Nat.inhabitedCountableFilterBasis
- Filter.inhabitedMem
- Filter.instInhabited
- Fin.inhabitedFinOneAdd
- Fin.instInhabited
- Finset.inhabitedFinset
- Finset.instInhabitedColex
- FloatArray.instInhabited
- Functor.Comp.instInhabited
- Functor.Const.instInhabited
- Functor.instInhabitedAddConst
- IO.AsyncList.instInhabited
- IO.FS.instInhabitedStream
- IO.FS.instInhabitedSystemTime
- IO.instInhabitedTaskState
- InfHom.instInhabited
- InfTopHom.instInhabited
- InitialSeg.instInhabited
- Int.Linear.instInhabitedExpr
- Int.instInhabited
- LO.FirstOrder.Completeness.instInhabitedModel
- LO.FirstOrder.Language.instInhabited
- LO.FirstOrder.Language.instInhabitedFuncOfNatNatOfConstantInhabited
- LO.FirstOrder.Semiterm.instInhabited
- LO.FirstOrder.Semiterm.instInhabited_1
- LO.Meta.Kite.Arith.instInhabitedEdgeType
- LO.Meta.Kite.Modal.instInhabitedEdgeType
- LO.Modal.ComplementClosedConsistentFinset.instInhabitedOfConsistentFormula
- Lake.EStateT.instInhabitedOfPure
- Lake.Log.instInhabitedPos
- Lake.MonadLog.instInhabitedOfPure
- Lake.MonadLogT.instInhabitedOfPure
- Lake.OpaquePostUpdateHook.instInhabitedOfPostUpdateHook
- Lake.OpaqueTargetConfig.instInhabitedNameOfTargetConfig
- Lake.OpaqueWorkspace.instInhabitedOfWorkspace
- Lake.Toml.instInhabitedDateTime
- Lake.Toml.instInhabitedElabState
- Lake.Toml.instInhabitedKeyTy
- Lake.Toml.instInhabitedRBDict
- Lake.Toml.instInhabitedTime
- Lake.Toml.instInhabitedValue
- Lake.inhabitedOfEmptyCollection
- Lake.inhabitedOfMonadCycle
- Lake.inhabitedOfNilTrace
- Lake.instInhabitedBackend
- Lake.instInhabitedBaseIOTask
- Lake.instInhabitedBinderSyntaxView
- Lake.instInhabitedBuildKey
- Lake.instInhabitedBuildType
- Lake.instInhabitedCliError
- Lake.instInhabitedDate
- Lake.instInhabitedDependency
- Lake.instInhabitedDependencySrc
- Lake.instInhabitedDynlib
- Lake.instInhabitedEResult
- Lake.instInhabitedEResult_1
- Lake.instInhabitedElanInstall
- Lake.instInhabitedEnv
- Lake.instInhabitedEquipT
- Lake.instInhabitedExternLibConfig
- Lake.instInhabitedFacetConfig
- Lake.instInhabitedGlob
- Lake.instInhabitedJob
- Lake.instInhabitedJobAction
- Lake.instInhabitedJobState
- Lake.instInhabitedLakeInstall
- Lake.instInhabitedLeanConfig
- Lake.instInhabitedLeanExeConfig
- Lake.instInhabitedLeanInstall
- Lake.instInhabitedLeanLibConfig
- Lake.instInhabitedLeanOption
- Lake.instInhabitedLog
- Lake.instInhabitedLogEntry
- Lake.instInhabitedLogLevel
- Lake.instInhabitedModuleDeps
- Lake.instInhabitedOptDataKind
- Lake.instInhabitedOptionIOTask
- Lake.instInhabitedOrderedTagAttribute
- Lake.instInhabitedPackageConfig
- Lake.instInhabitedPackageEntry
- Lake.instInhabitedPackageEntrySrc
- Lake.instInhabitedPackageEntryV6
- Lake.instInhabitedPathPatDescr
- Lake.instInhabitedPattern
- Lake.instInhabitedPatternDescr
- Lake.instInhabitedPostUpdateHook
- Lake.instInhabitedRegistryPkg
- Lake.instInhabitedRegistrySrc
- Lake.instInhabitedScript
- Lake.instInhabitedSemVerCore
- Lake.instInhabitedStdVer
- Lake.instInhabitedStrPatDescr
- Lake.instInhabitedTargetConfig
- Lake.instInhabitedVerbosity
- Lake.instInhabitedWorkspaceConfig
- LatticeHom.instInhabited
- Lean.CodeAction.instInhabitedCommandCodeActionEntry
- Lean.CodeAction.instInhabitedCommandCodeActions
- Lean.CollectFVars.instInhabitedState
- Lean.CollectLevelMVars.instInhabitedState
- Lean.CollectLevelParams.instInhabitedState
- Lean.CollectMVars.instInhabitedState
- Lean.Compiler.CSimp.instInhabitedEntry
- Lean.Compiler.CSimp.instInhabitedState
- Lean.Compiler.LCNF.CompilerM.instInhabitedContext
- Lean.Compiler.LCNF.CompilerM.instInhabitedState
- Lean.Compiler.LCNF.FixedParams.instInhabitedAbsValue
- Lean.Compiler.LCNF.FloatLetIn.instInhabitedDecision
- Lean.Compiler.LCNF.JoinPointFinder.instInhabitedCandidateInfo
- Lean.Compiler.LCNF.PullFunDecls.instInhabitedToPull
- Lean.Compiler.LCNF.Simp.instInhabitedConfig
- Lean.Compiler.LCNF.Simp.instInhabitedFunDeclInfo
- Lean.Compiler.LCNF.Simp.instInhabitedFunDeclInfoMap
- Lean.Compiler.LCNF.Simp.instInhabitedJpCasesInfo
- Lean.Compiler.LCNF.Specialize.instInhabitedCacheEntry
- Lean.Compiler.LCNF.ToLCNF.instInhabitedElement
- Lean.Compiler.LCNF.UnreachableBranches.instInhabitedValue
- Lean.Compiler.LCNF.instInhabitedAltCore
- Lean.Compiler.LCNF.instInhabitedArg
- Lean.Compiler.LCNF.instInhabitedCacheExtension
- Lean.Compiler.LCNF.instInhabitedCasesCore
- Lean.Compiler.LCNF.instInhabitedCode
- Lean.Compiler.LCNF.instInhabitedCodeDecl
- Lean.Compiler.LCNF.instInhabitedConfigOptions
- Lean.Compiler.LCNF.instInhabitedDecl
- Lean.Compiler.LCNF.instInhabitedDeclValue
- Lean.Compiler.LCNF.instInhabitedFunDeclCore
- Lean.Compiler.LCNF.instInhabitedLCtx
- Lean.Compiler.LCNF.instInhabitedLetDecl
- Lean.Compiler.LCNF.instInhabitedLetValue
- Lean.Compiler.LCNF.instInhabitedLitValue
- Lean.Compiler.LCNF.instInhabitedNormFVarResult
- Lean.Compiler.LCNF.instInhabitedParam
- Lean.Compiler.LCNF.instInhabitedPass
- Lean.Compiler.LCNF.instInhabitedPassInstaller
- Lean.Compiler.LCNF.instInhabitedPassManager
- Lean.Compiler.LCNF.instInhabitedPhase
- Lean.Compiler.LCNF.instInhabitedSpecEntry
- Lean.Compiler.LCNF.instInhabitedSpecParamInfo
- Lean.Compiler.LCNF.instInhabitedSpecState
- Lean.Compiler.LCNF.instInhabitedTrivialStructureInfo
- Lean.Compiler.instInhabitedInlineAttributeKind
- Lean.Compiler.instInhabitedSpecArgKind
- Lean.Compiler.instInhabitedSpecEntry
- Lean.Compiler.instInhabitedSpecInfo
- Lean.Compiler.instInhabitedSpecState
- Lean.Compiler.instInhabitedSpecializeAttributeKind
- Lean.Core.instInhabitedCache
- Lean.Core.instInhabitedCoreM
- Lean.Data.AC.instInhabitedExpr
- Lean.Data.Trie.instInhabited
- Lean.Elab.Command.Structure.instInhabitedState
- Lean.Elab.Command.Structure.instInhabitedStructElabM
- Lean.Elab.Command.Structure.instInhabitedStructFieldInfo
- Lean.Elab.Command.Structure.instInhabitedStructFieldKind
- Lean.Elab.Command.Structure.instInhabitedStructParentInfo
- Lean.Elab.Command.Structure.instInhabitedStructView
- Lean.Elab.Command.instInhabitedCommandElabM
- Lean.Elab.Command.instInhabitedCtorView
- Lean.Elab.Command.instInhabitedElabHeaderResult
- Lean.Elab.Command.instInhabitedInductiveElabDescr
- Lean.Elab.Command.instInhabitedInductiveElabStep1
- Lean.Elab.Command.instInhabitedInductiveElabStep2
- Lean.Elab.Command.instInhabitedInductiveView
- Lean.Elab.Command.instInhabitedPreElabHeaderResult
- Lean.Elab.Command.instInhabitedScope
- Lean.Elab.Eqns.instInhabitedEqnInfoCore
- Lean.Elab.PartialFixpoint.instInhabitedEqnInfo
- Lean.Elab.Structural.instInhabitedEqnInfo
- Lean.Elab.Structural.instInhabitedIndGroupInfo
- Lean.Elab.Structural.instInhabitedIndGroupInst
- Lean.Elab.Structural.instInhabitedM
- Lean.Elab.Structural.instInhabitedRecArgInfo
- Lean.Elab.Tactic.ElimApp.instInhabitedAlt
- Lean.Elab.Tactic.Omega.MetaProblem.instInhabited
- Lean.Elab.Tactic.Omega.Problem.instInhabitedFourierMotzkinData
- Lean.Elab.Tactic.RCases.RCasesPatt.instInhabited
- Lean.Elab.Tactic.instInhabitedCache
- Lean.Elab.Tactic.instInhabitedCacheKey
- Lean.Elab.Tactic.instInhabitedSimpKind
- Lean.Elab.Tactic.instInhabitedState
- Lean.Elab.Tactic.instInhabitedTacticFinishedSnapshot
- Lean.Elab.Tactic.instInhabitedTacticM
- Lean.Elab.Tactic.instInhabitedTacticParsedSnapshot
- Lean.Elab.Term.CollectPatternVars.instInhabitedContext
- Lean.Elab.Term.CollectPatternVars.instInhabitedState
- Lean.Elab.Term.Do.ToTerm.instInhabitedKind
- Lean.Elab.Term.Do.instInhabitedAlt
- Lean.Elab.Term.Do.instInhabitedAltExpr
- Lean.Elab.Term.Do.instInhabitedCode
- Lean.Elab.Term.StructInst.instInhabitedExplicitSourceView
- Lean.Elab.Term.StructInst.instInhabitedFieldLHS
- Lean.Elab.Term.StructInst.instInhabitedFieldView
- Lean.Elab.Term.StructInst.instInhabitedSourcesView
- Lean.Elab.Term.StructInst.instInhabitedStructInstState
- Lean.Elab.Term.StructInst.instInhabitedStructInstView
- Lean.Elab.Term.instInhabitedArg
- Lean.Elab.Term.instInhabitedCalcStepView
- Lean.Elab.Term.instInhabitedDiscr
- Lean.Elab.Term.instInhabitedElabElimInfo
- Lean.Elab.Term.instInhabitedLetRecToLift
- Lean.Elab.Term.instInhabitedLevelMVarErrorInfo
- Lean.Elab.Term.instInhabitedMVarErrorInfo
- Lean.Elab.Term.instInhabitedMVarErrorKind
- Lean.Elab.Term.instInhabitedMatchAltView
- Lean.Elab.Term.instInhabitedNamedArg
- Lean.Elab.Term.instInhabitedPostponeBehavior
- Lean.Elab.Term.instInhabitedState
- Lean.Elab.Term.instInhabitedSyntheticMVarDecl
- Lean.Elab.Term.instInhabitedSyntheticMVarKind
- Lean.Elab.Term.instInhabitedTermElabM
- Lean.Elab.WF.GuessLex.instInhabitedBasicMeasure
- Lean.Elab.WF.instInhabitedEqnInfo
- Lean.Elab.instInhabitedAttribute
- Lean.Elab.instInhabitedCommandInfo
- Lean.Elab.instInhabitedDecreasingBy
- Lean.Elab.instInhabitedDefKind
- Lean.Elab.instInhabitedDefView
- Lean.Elab.instInhabitedDefViewElabHeader
- Lean.Elab.instInhabitedDefViewElabHeaderData
- Lean.Elab.instInhabitedElabInfo
- Lean.Elab.instInhabitedFieldInfo
- Lean.Elab.instInhabitedFixedParamPerms
- Lean.Elab.instInhabitedInfo
- Lean.Elab.instInhabitedInfoState
- Lean.Elab.instInhabitedInfoTree
- Lean.Elab.instInhabitedMacroExpansionInfo
- Lean.Elab.instInhabitedModifiers
- Lean.Elab.instInhabitedPartialFixpoint
- Lean.Elab.instInhabitedPartialFixpointType
- Lean.Elab.instInhabitedPartialTermInfo
- Lean.Elab.instInhabitedPreDefinition
- Lean.Elab.instInhabitedRecKind
- Lean.Elab.instInhabitedTacticInfo
- Lean.Elab.instInhabitedTermInfo
- Lean.Elab.instInhabitedTerminationBy
- Lean.Elab.instInhabitedTerminationHints
- Lean.Elab.instInhabitedTerminationMeasure
- Lean.Elab.instInhabitedVisibility
- Lean.EnvExtension.instInhabitedAsyncMode
- Lean.Firefox.instInhabitedFrameTable
- Lean.Firefox.instInhabitedMilliseconds
- Lean.FuzzyMatching.instInhabitedCharRole
- Lean.Grind.CommRing.instInhabitedExpr
- Lean.Grind.CommRing.instInhabitedMon
- Lean.Grind.CommRing.instInhabitedPoly
- Lean.Grind.CommRing.instInhabitedPower
- Lean.Grind.instInhabitedConfig
- Lean.IR.EmitLLVM.instInhabitedM
- Lean.IR.ExplicitRC.instInhabitedVarInfo
- Lean.IR.UnreachableBranches.instInhabitedValue
- Lean.IR.instInhabitedAlt
- Lean.IR.instInhabitedArg
- Lean.IR.instInhabitedCtorFieldInfo
- Lean.IR.instInhabitedCtorInfo
- Lean.IR.instInhabitedDecl
- Lean.IR.instInhabitedExpr
- Lean.IR.instInhabitedFnBody
- Lean.IR.instInhabitedIRType
- Lean.IR.instInhabitedIndexSet
- Lean.IR.instInhabitedJoinPointId
- Lean.IR.instInhabitedLiveVarSet
- Lean.IR.instInhabitedParam
- Lean.IR.instInhabitedVarId
- Lean.IR.instInhabitedVarIdSet
- Lean.JsonNumber.instInhabited
- Lean.JsonRpc.instInhabitedErrorCode
- Lean.JsonRpc.instInhabitedMessage
- Lean.JsonRpc.instInhabitedNotification
- Lean.JsonRpc.instInhabitedRequest
- Lean.JsonRpc.instInhabitedRequestID
- Lean.JsonRpc.instInhabitedResponse
- Lean.JsonRpc.instInhabitedResponseError
- Lean.Kernel.instInhabitedDiagnostics
- Lean.KeyedDeclsAttribute.instInhabitedDef
- Lean.KeyedDeclsAttribute.instInhabitedExtensionState
- Lean.KeyedDeclsAttribute.instInhabitedOLeanEntry
- Lean.Language.Snapshot.instInhabitedDiagnostics
- Lean.Language.instInhabitedDynamicSnapshot
- Lean.Language.instInhabitedSnapshot
- Lean.Language.instInhabitedSnapshotTask
- Lean.Language.instInhabitedSnapshotTree
- Lean.Linter.instInhabitedDeprecationEntry
- Lean.Lsp.RefInfo.instInhabitedLocation
- Lean.Lsp.instInhabitedCallHierarchyIncomingCall
- Lean.Lsp.instInhabitedCallHierarchyItem
- Lean.Lsp.instInhabitedCallHierarchyOutgoingCall
- Lean.Lsp.instInhabitedCancelParams
- Lean.Lsp.instInhabitedCompletionItem
- Lean.Lsp.instInhabitedCompletionItemKind
- Lean.Lsp.instInhabitedCompletionItemTag
- Lean.Lsp.instInhabitedDependencyBuildMode
- Lean.Lsp.instInhabitedDiagnosticCode
- Lean.Lsp.instInhabitedDiagnosticRelatedInformation
- Lean.Lsp.instInhabitedDiagnosticSeverity
- Lean.Lsp.instInhabitedDiagnosticTag
- Lean.Lsp.instInhabitedDiagnosticWith
- Lean.Lsp.instInhabitedLeanDiagnosticTag
- Lean.Lsp.instInhabitedLeanFileProgressKind
- Lean.Lsp.instInhabitedLeanQueryModuleResponse
- Lean.Lsp.instInhabitedLineRange
- Lean.Lsp.instInhabitedLocation
- Lean.Lsp.instInhabitedPosition
- Lean.Lsp.instInhabitedPublishDiagnosticsParams
- Lean.Lsp.instInhabitedRange
- Lean.Lsp.instInhabitedRefIdent
- Lean.Lsp.instInhabitedSymbolKind
- Lean.Lsp.instInhabitedSymbolTag
- Lean.Macro.instInhabitedMethods
- Lean.Macro.instInhabitedMethodsRef
- Lean.Macro.instInhabitedState
- Lean.Meta.AC.instInhabitedPreContext
- Lean.Meta.Canonicalizer.instInhabitedExprVisited
- Lean.Meta.Canonicalizer.instInhabitedState
- Lean.Meta.Closure.instInhabitedToProcessElement
- Lean.Meta.DSimp.instInhabitedConfig
- Lean.Meta.DiscrTree.instInhabited
- Lean.Meta.DiscrTree.instInhabitedKey
- Lean.Meta.DiscrTree.instInhabitedTrie
- Lean.Meta.Ext.instInhabitedExtTheorem
- Lean.Meta.Ext.instInhabitedExtTheorems
- Lean.Meta.ExtractLets.instInhabitedState
- Lean.Meta.Grind.Arith.CommRing.Null.instInhabitedPreNullCert
- Lean.Meta.Grind.Arith.CommRing.instInhabitedEqCnstr
- Lean.Meta.Grind.Arith.CommRing.instInhabitedEqCnstrProof
- Lean.Meta.Grind.Arith.CommRing.instInhabitedRing
- Lean.Meta.Grind.Arith.CommRing.instInhabitedState
- Lean.Meta.Grind.Arith.Cutsat.Search.instInhabitedKind
- Lean.Meta.Grind.Arith.Cutsat.instInhabitedCase
- Lean.Meta.Grind.Arith.Cutsat.instInhabitedCaseKind
- Lean.Meta.Grind.Arith.Cutsat.instInhabitedCooperSplit
- Lean.Meta.Grind.Arith.Cutsat.instInhabitedCooperSplitPred
- Lean.Meta.Grind.Arith.Cutsat.instInhabitedDvdCnstr
- Lean.Meta.Grind.Arith.Cutsat.instInhabitedFindIntValResult
- Lean.Meta.Grind.Arith.Cutsat.instInhabitedLeCnstr
- Lean.Meta.Grind.Arith.Cutsat.instInhabitedState
- Lean.Meta.Grind.Arith.Offset.instInhabitedCnstr
- Lean.Meta.Grind.Arith.Offset.instInhabitedProofInfo
- Lean.Meta.Grind.Arith.Offset.instInhabitedState
- Lean.Meta.Grind.Arith.Offset.instInhabitedToPropagate
- Lean.Meta.Grind.Arith.instInhabitedState
- Lean.Meta.Grind.Canon.instInhabitedShouldCanonResult
- Lean.Meta.Grind.Canon.instInhabitedState
- Lean.Meta.Grind.Clean.instInhabitedState
- Lean.Meta.Grind.EMatch.instInhabitedChoice
- Lean.Meta.Grind.EMatch.instInhabitedCnstr
- Lean.Meta.Grind.EMatch.instInhabitedContext
- Lean.Meta.Grind.EMatch.instInhabitedSearchState
- Lean.Meta.Grind.EMatch.instInhabitedState
- Lean.Meta.Grind.Split.instInhabitedState
- Lean.Meta.Grind.instInhabitedBuiltinPropagators
- Lean.Meta.Grind.instInhabitedCaseTrace
- Lean.Meta.Grind.instInhabitedCasesEntry
- Lean.Meta.Grind.instInhabitedCasesTypes
- Lean.Meta.Grind.instInhabitedCounters
- Lean.Meta.Grind.instInhabitedEMatchTheorem
- Lean.Meta.Grind.instInhabitedEMatchTheoremKind
- Lean.Meta.Grind.instInhabitedEMatchTheorems
- Lean.Meta.Grind.instInhabitedENode
- Lean.Meta.Grind.instInhabitedGoal
- Lean.Meta.Grind.instInhabitedIntroResult
- Lean.Meta.Grind.instInhabitedMethods
- Lean.Meta.Grind.instInhabitedNewRawFact
- Lean.Meta.Grind.instInhabitedOrigin
- Lean.Meta.Grind.instInhabitedSplitInfo
- Lean.Meta.Grind.instInhabitedSplitStatus
- Lean.Meta.Grind.instInhabitedTrace
- Lean.Meta.IndPredBelow.instInhabitedVariables
- Lean.Meta.LazyDiscrTree.instInhabited
- Lean.Meta.LazyDiscrTree.instInhabitedInitResults
- Lean.Meta.LazyDiscrTree.instInhabitedKey
- Lean.Meta.LazyDiscrTree.instInhabitedPartialMatch
- Lean.Meta.LazyDiscrTree.instInhabitedPreDiscrTree
- Lean.Meta.LazyDiscrTree.instInhabitedTrie
- Lean.Meta.LibrarySearch.instInhabitedDeclMod
- Lean.Meta.Match.Extension.instInhabitedState
- Lean.Meta.Match.instInhabitedAlt
- Lean.Meta.Match.instInhabitedDiscrInfo
- Lean.Meta.Match.instInhabitedMatchEqns
- Lean.Meta.Match.instInhabitedMatchEqnsExtState
- Lean.Meta.Match.instInhabitedPattern
- Lean.Meta.Match.instInhabitedProblem
- Lean.Meta.NormCast.instInhabitedLabel
- Lean.Meta.NormCast.instInhabitedNormCastExtension
- Lean.Meta.Simp.instInhabitedBuiltinSimprocs
- Lean.Meta.Simp.instInhabitedConfig
- Lean.Meta.Simp.instInhabitedContext
- Lean.Meta.Simp.instInhabitedDiagnostics
- Lean.Meta.Simp.instInhabitedMethods
- Lean.Meta.Simp.instInhabitedResult
- Lean.Meta.Simp.instInhabitedSimpM
- Lean.Meta.Simp.instInhabitedSimprocDecl
- Lean.Meta.Simp.instInhabitedSimprocDeclExtState
- Lean.Meta.Simp.instInhabitedSimprocOLeanEntry
- Lean.Meta.Simp.instInhabitedSimprocs
- Lean.Meta.Simp.instInhabitedStats
- Lean.Meta.Simp.instInhabitedStep
- Lean.Meta.Simp.instInhabitedUsedSimps
- Lean.Meta.SimpAll.instInhabitedEntry
- Lean.Meta.SynthInstance.instInhabitedAnswer
- Lean.Meta.SynthInstance.instInhabitedConsumerNode
- Lean.Meta.SynthInstance.instInhabitedGeneratorNode
- Lean.Meta.SynthInstance.instInhabitedInstance
- Lean.Meta.SynthInstance.instInhabitedSynthM
- Lean.Meta.Tactic.TryThis.instInhabitedSuggestion
- Lean.Meta.Tactic.TryThis.instInhabitedSuggestionText
- Lean.Meta.Tactic.TryThis.instSuggestionStyleInhabited
- Lean.Meta.Try.Collector.instInhabitedOrdSet
- Lean.Meta.instInhabitedAbstractMVarsResult
- Lean.Meta.instInhabitedAltVarNames
- Lean.Meta.instInhabitedArgsPacker
- Lean.Meta.instInhabitedAuxLemmas
- Lean.Meta.instInhabitedCache
- Lean.Meta.instInhabitedCaseArraySizesSubgoal
- Lean.Meta.instInhabitedCaseValueSubgoal
- Lean.Meta.instInhabitedCaseValuesSubgoal
- Lean.Meta.instInhabitedCoeFnInfo
- Lean.Meta.instInhabitedCoeFnType
- Lean.Meta.instInhabitedConfig
- Lean.Meta.instInhabitedConfigWithKey
- Lean.Meta.instInhabitedCongrArgKind
- Lean.Meta.instInhabitedCustomEliminator
- Lean.Meta.instInhabitedCustomEliminators
- Lean.Meta.instInhabitedDefEqCacheKey
- Lean.Meta.instInhabitedDefaultInstances
- Lean.Meta.instInhabitedDiagSummary
- Lean.Meta.instInhabitedDiagnostics
- Lean.Meta.instInhabitedElimAltInfo
- Lean.Meta.instInhabitedElimInfo
- Lean.Meta.instInhabitedEqnsExtState
- Lean.Meta.instInhabitedEtaStructMode
- Lean.Meta.instInhabitedExprConfigCacheKey
- Lean.Meta.instInhabitedExprParamInfo
- Lean.Meta.instInhabitedFVarSubst
- Lean.Meta.instInhabitedFunIndInfo
- Lean.Meta.instInhabitedFunIndParamKind
- Lean.Meta.instInhabitedGeneralizeArg
- Lean.Meta.instInhabitedInductionSubgoal
- Lean.Meta.instInhabitedInfoCacheKey
- Lean.Meta.instInhabitedInstanceEntry
- Lean.Meta.instInhabitedInstances
- Lean.Meta.instInhabitedKExprMap
- Lean.Meta.instInhabitedMetaM
- Lean.Meta.instInhabitedOccurrences
- Lean.Meta.instInhabitedOrigin
- Lean.Meta.instInhabitedParamInfo
- Lean.Meta.instInhabitedPostponedEntry
- Lean.Meta.instInhabitedProjReductionKind
- Lean.Meta.instInhabitedSimpCongrTheorem
- Lean.Meta.instInhabitedSimpCongrTheorems
- Lean.Meta.instInhabitedSimpEntry
- Lean.Meta.instInhabitedSimpTheorem
- Lean.Meta.instInhabitedSimpTheorems
- Lean.Meta.instInhabitedState
- Lean.Meta.instInhabitedTransparencyMode
- Lean.Meta.instInhabitedUnificationHintEntry
- Lean.Meta.instInhabitedUnificationHints
- Lean.NameHashSet.instInhabited
- Lean.NameMap.instInhabited
- Lean.NameSSet.instInhabited
- Lean.NameSet.instInhabited
- Lean.Omega.LinearCombo.instInhabited
- Lean.OpenDecl.instInhabited
- Lean.ParseImports.instInhabitedParser
- Lean.ParseImports.instInhabitedState
- Lean.Parser.ParserExtension.instInhabitedEntry
- Lean.Parser.ParserExtension.instInhabitedOLeanEntry
- Lean.Parser.ParserExtension.instInhabitedState
- Lean.Parser.TokenMap.instInhabited
- Lean.Parser.instInhabitedError
- Lean.Parser.instInhabitedFirstTokens
- Lean.Parser.instInhabitedInputContext
- Lean.Parser.instInhabitedLeadingIdentBehavior
- Lean.Parser.instInhabitedModuleParserState
- Lean.Parser.instInhabitedParser
- Lean.Parser.instInhabitedParserCategory
- Lean.Parser.instInhabitedParserFn
- Lean.Parser.instInhabitedParserInfo
- Lean.Parser.instInhabitedPrattParsingTables
- Lean.ParserCompiler.instInhabitedCombinatorAttribute
- Lean.PersistentHashMap.instInhabited
- Lean.PersistentHashMap.instInhabitedEntry
- Lean.PersistentHashMap.instInhabitedNode
- Lean.PersistentHashSet.instInhabited
- Lean.PrettyPrinter.Delaborator.SubExpr.instInhabitedHoleIterator
- Lean.PrettyPrinter.Delaborator.TopDownAnalyze.instInhabitedContext
- Lean.PrettyPrinter.Delaborator.instInhabitedAppImplicitArg
- Lean.PrettyPrinter.Delaborator.instInhabitedDelabM
- Lean.PrettyPrinter.Delaborator.instInhabitedParamKind
- Lean.SMap.instInhabited
- Lean.SSet.instInhabited
- Lean.ScopedEnvExtension.instInhabitedDescr
- Lean.ScopedEnvExtension.instInhabitedScopedEntries
- Lean.ScopedEnvExtension.instInhabitedStateStack
- Lean.Server.FileWorker.instInhabitedInlayHintState
- Lean.Server.FileWorker.instInhabitedPartialHandlerInfo
- Lean.Server.FileWorker.instInhabitedReportSnapshotsState
- Lean.Server.FileWorker.instInhabitedSemanticTokensState
- Lean.Server.Watchdog.instInhabitedRequestData
- Lean.Server.Watchdog.instInhabitedRequestQueueMap
- Lean.Server.instCodeActionProviderInhabited
- Lean.Server.instInhabitedDocumentMeta
- Lean.Server.instInhabitedRequestError
- Lean.Server.instInhabitedRpcProcedure
- Lean.Server.instInhabitedServerRequestResponse
- Lean.Server.instInhabitedServerTask
- Lean.Server.instInhabitedWithRpcRef
- Lean.SimplePersistentEnvExtension.instInhabited
- Lean.SubExpr.Pos.instInhabited
- Lean.TagDeclarationExtension.instInhabited
- Lean.Try.instInhabitedConfig
- Lean.Widget.TaggedText.instInhabitedTaggedState
- Lean.Widget.instInhabitedEmbedFmt
- Lean.Widget.instInhabitedGetInteractiveDiagnosticsParams
- Lean.Widget.instInhabitedInfoPopup
- Lean.Widget.instInhabitedInteractiveHypothesisBundle
- Lean.Widget.instInhabitedMsgEmbed
- Lean.Widget.instInhabitedMsgToInteractive
- Lean.Widget.instInhabitedStrictOrLazy
- Lean.Widget.instInhabitedTaggedText
- Lean.Widget.instInhabitedUserWidgetDefinition
- Lean.Widget.instInhabitedWidgetSource
- Lean.Xml.instInhabitedContent
- Lean.instFVarIdHashSetInhabited
- Lean.instFVarIdSetInhabited
- Lean.instInhabitedAssocList
- Lean.instInhabitedAsyncConstantInfo
- Lean.instInhabitedAsyncConsts
- Lean.instInhabitedAttributeApplicationTime
- Lean.instInhabitedAttributeExtensionState
- Lean.instInhabitedAttributeImpl
- Lean.instInhabitedAttributeImplCore
- Lean.instInhabitedAttributeKind
- Lean.instInhabitedAxiomVal
- Lean.instInhabitedBaseMessage
- Lean.instInhabitedBinderInfo
- Lean.instInhabitedClassState
- Lean.instInhabitedClosedTermCache
- Lean.instInhabitedConstantInfo
- Lean.instInhabitedConstantKind
- Lean.instInhabitedConstantVal
- Lean.instInhabitedConstructor
- Lean.instInhabitedConstructorVal
- Lean.instInhabitedData
- Lean.instInhabitedDataValue
- Lean.instInhabitedData_1
- Lean.instInhabitedDeclaration
- Lean.instInhabitedDeclarationLocation
- Lean.instInhabitedDeclarationRange
- Lean.instInhabitedDeclarationRanges
- Lean.instInhabitedDefinitionSafety
- Lean.instInhabitedDefinitionVal
- Lean.instInhabitedEnumAttributes
- Lean.instInhabitedEnvExtension
- Lean.instInhabitedEnvExtensionState
- Lean.instInhabitedException
- Lean.instInhabitedExpr
- Lean.instInhabitedExprStructEq
- Lean.instInhabitedExternAttrData
- Lean.instInhabitedFVarId
- Lean.instInhabitedFVarIdMap
- Lean.instInhabitedFileMap
- Lean.instInhabitedHeadIndex
- Lean.instInhabitedImport
- Lean.instInhabitedInductiveType
- Lean.instInhabitedInductiveVal
- Lean.instInhabitedInternalExceptionId
- Lean.instInhabitedJson
- Lean.instInhabitedKVMap
- Lean.instInhabitedLBool
- Lean.instInhabitedLMVarIdMap
- Lean.instInhabitedLOption
- Lean.instInhabitedLeanOptionValue
- Lean.instInhabitedLeanOptions
- Lean.instInhabitedLevel
- Lean.instInhabitedLevelMVarId
- Lean.instInhabitedLiteral
- Lean.instInhabitedLocalContext
- Lean.instInhabitedLocalDecl
- Lean.instInhabitedLocalDeclKind
- Lean.instInhabitedLocalInstance
- Lean.instInhabitedMVarId
- Lean.instInhabitedMVarIdMap
- Lean.instInhabitedMacroScopesView
- Lean.instInhabitedMapDeclarationExtension
- Lean.instInhabitedMessageData
- Lean.instInhabitedMessageLog
- Lean.instInhabitedMessageSeverity
- Lean.instInhabitedMetavarContext
- Lean.instInhabitedMetavarDecl
- Lean.instInhabitedMetavarKind
- Lean.instInhabitedModuleData
- Lean.instInhabitedModuleIdx
- Lean.instInhabitedName
- Lean.instInhabitedNameGenerator
- Lean.instInhabitedNameMapAttributeImpl
- Lean.instInhabitedNameMapExtension
- Lean.instInhabitedNameTrie
- Lean.instInhabitedOpaqueVal
- Lean.instInhabitedOption
- Lean.instInhabitedOptionDecl
- Lean.instInhabitedOptionDecls
- Lean.instInhabitedOptions
- Lean.instInhabitedPPFns
- Lean.instInhabitedParametricAttribute
- Lean.instInhabitedParametricAttributeExtra
- Lean.instInhabitedParserDescr
- Lean.instInhabitedPersistentArray
- Lean.instInhabitedPersistentArrayNode
- Lean.instInhabitedPersistentEnvExtension
- Lean.instInhabitedPersistentEnvExtensionState
- Lean.instInhabitedPosition
- Lean.instInhabitedPrefixTree
- Lean.instInhabitedPrefixTreeNode
- Lean.instInhabitedProjectionFunctionInfo
- Lean.instInhabitedQuotKind
- Lean.instInhabitedQuotVal
- Lean.instInhabitedRBMap
- Lean.instInhabitedRBTree
- Lean.instInhabitedRecursorRule
- Lean.instInhabitedRecursorVal
- Lean.instInhabitedReducibilityHints
- Lean.instInhabitedReducibilityStatus
- Lean.instInhabitedScopedEnvExtension
- Lean.instInhabitedSourceInfo
- Lean.instInhabitedStructureDescr
- Lean.instInhabitedStructureFieldInfo
- Lean.instInhabitedStructureInfo
- Lean.instInhabitedStructureParentInfo
- Lean.instInhabitedStructureResolutionOrderConflict
- Lean.instInhabitedStructureResolutionOrderResult
- Lean.instInhabitedStructureResolutionState
- Lean.instInhabitedStructureState
- Lean.instInhabitedSubExpr
- Lean.instInhabitedSyntax
- Lean.instInhabitedTSyntax
- Lean.instInhabitedTagAttribute
- Lean.instInhabitedTagAttributeExtra
- Lean.instInhabitedTheoremVal
- Lean.instInhabitedTraceElem
- Lean.instInhabitedTraceState
- Lean.instInhabitedTransformStep
- Lean.instInhabitedVisibilityMap
- Lean.instLMVarIdSetInhabited
- Lean.instMVarIdSetInhabited
- LeanSearchClient.instInhabitedLoogleMatch
- LeanSearchClient.instInhabitedLoogleResult
- LeanSearchClient.instInhabitedSearchServer
- List.Vector.instInhabited
- LowerAdjoint.instInhabitedId
- LowerSet.instInhabited
- MLList.instInhabited
- Mathlib.Linter.Flexible.instInhabitedStained
- Mathlib.Linter.instInhabitedImportState
- Mathlib.Meta.NormNum.instInhabitedNormNums
- Mathlib.Meta.NormNum.instInhabitedResult
- Mathlib.Meta.NormNum.instInhabitedResult'
- Mathlib.Notation3.instMatcherInhabited
- Mathlib.Tactic.Abel.instInhabitedNormalExpr
- Mathlib.Tactic.AtomM.instInhabitedContext
- Mathlib.Tactic.CC.instInhabitedACApps
- Mathlib.Tactic.CC.instInhabitedACEntry
- Mathlib.Tactic.CC.instInhabitedCCConfig
- Mathlib.Tactic.CC.instInhabitedCCState
- Mathlib.Tactic.CC.instInhabitedCCStructure
- Mathlib.Tactic.CC.instInhabitedDelayedExpr
- Mathlib.Tactic.CC.instInhabitedEntry
- Mathlib.Tactic.CC.instInhabitedEntryExpr
- Mathlib.Tactic.GCongr.instInhabitedGCongrLemma
- Mathlib.Tactic.Ring.instInhabitedResultOfSigmaQuoted
- Mathlib.Tactic.Ring.instInhabitedSigmaQuotedExBase
- Mathlib.Tactic.Ring.instInhabitedSigmaQuotedExProd
- Mathlib.Tactic.Ring.instInhabitedSigmaQuotedExSum
- Mathlib.Tactic.RingNF.instInhabitedConfig
- Mathlib.Tactic.RingNF.instInhabitedRingMode
- Monoid.End.instInhabited
- MonoidWithZeroHom.instInhabited
- MulAut.instInhabited
- MulEquiv.instInhabited
- MulOpposite.instInhabited
- Multiset.inhabitedMultiset
- Nat.ArithPart₁.instInhabitedCode
- Nat.Linear.instInhabitedExpr
- Nat.Partrec.Code.instInhabited
- Nat.Primes.inhabitedPrimes
- Nat.SOM.instInhabitedExpr
- NonUnitalRingHom.instInhabited
- Nondet.instInhabited
- Nonneg.inhabited
- OmegaCompletePartialOrder.Chain.instInhabited
- OmegaCompletePartialOrder.ContinuousHom.instInhabited
- OptionT.instInhabitedOfPure
- OrderAddMonoidHom.instInhabited
- OrderAddMonoidIso.instInhabited
- OrderDual.instInhabited
- OrderHom.instInhabited
- OrderMonoidHom.instInhabited
- OrderMonoidIso.instInhabited
- OrderMonoidWithZeroHom.instInhabited
- OrderRingHom.instInhabited
- OrderRingIso.instInhabited
- PFun.inhabited
- PNat.instInhabited
- PSigma.instInhabitedOfDefault_mathlib
- Part.instInhabited
- Pi.instInhabited
- Plausible.NoShrink.inhabited
- Plausible.Testable.instInhabitedOptionTOfPure
- Plausible.TotalFunction.inhabited
- Plausible.instInhabitedConfiguration
- Plausible.instInhabitedTestResult
- ProofWidgets.instInhabitedHtml
- Qq.instInhabitedQuoted
- Quot.instInhabited_mathlib
- Quotient.instInhabitedQuotient
- RelEmbedding.instInhabited
- RelIso.instInhabited
- RingEquiv.instInhabited
- RingHom.instInhabited
- Set.Finite.inhabited
- Set.instInhabited
- ShareCommon.instInhabitedState
- Sigma.instInhabitedSigma
- Simps.instInhabitedAutomaticProjectionData
- Simps.instInhabitedConfig
- Simps.instInhabitedProjectionData
- Std.DHashMap.Internal.instInhabitedAssocList
- Std.DHashMap.Raw.instInhabited
- Std.DHashMap.instInhabited
- Std.DTreeMap.Internal.instInhabitedImpl
- Std.DTreeMap.Raw.instInhabited
- Std.DTreeMap.instInhabited
- Std.ExtDHashMap.instInhabitedDHashMap
- Std.ExtHashMap.instInhabited
- Std.ExtHashSet.instInhabited
- Std.Format.instInhabitedFlattenBehavior
- Std.Format.instInhabitedSpaceResult
- Std.HashMap.Raw.instInhabited
- Std.HashMap.instInhabited
- Std.HashSet.Raw.instInhabited
- Std.HashSet.instInhabited
- Std.Internal.Parsec.instInhabited
- Std.Internal.instInhabitedRat
- Std.Net.instInhabitedAddressFamily
- Std.Net.instInhabitedIPAddr
- Std.Net.instInhabitedIPv4Addr
- Std.Net.instInhabitedIPv6Addr
- Std.Net.instInhabitedInterfaceAddress
- Std.Net.instInhabitedMACAddr
- Std.Net.instInhabitedSocketAddress
- Std.Net.instInhabitedSocketAddressV4
- Std.Net.instInhabitedSocketAddressV6
- Std.Queue.instInhabited
- Std.Sat.AIG.instInhabitedDecl
- Std.Sat.AIG.instInhabitedFanin
- Std.Tactic.BVDecide.LRAT.Internal.DefaultFormula.instInhabited
- Std.Tactic.BVDecide.LRAT.Internal.instInhabitedAssignment
- Std.Tactic.BVDecide.LRAT.Internal.instInhabitedResult
- Std.Tactic.BVDecide.LRAT.instInhabitedAction
- Std.Tactic.BVDecide.instInhabitedBVBit
- Std.Time.Awareness.instInhabitedType
- Std.Time.DateTime.instInhabited
- Std.Time.Day.Ordinal.instInhabitedOfYear
- Std.Time.Day.instInhabitedOrdinal
- Std.Time.Day.instOffsetInhabited
- Std.Time.Hour.instInhabitedOrdinal
- Std.Time.Hour.instOffsetInhabited
- Std.Time.Internal.Bounded.LE.instInhabitedHAddIntCast
- Std.Time.Internal.instInhabitedUnitVal
- Std.Time.Millisecond.instInhabitedOrdinal
- Std.Time.Millisecond.instOffsetInhabited
- Std.Time.Minute.instInhabitedOrdinal
- Std.Time.Minute.instOffsetInhabited
- Std.Time.Month.instInhabitedOrdinal
- Std.Time.Month.instInhabitedQuarter
- Std.Time.Month.instOffsetInhabited
- Std.Time.Nanosecond.Ordinal.instInhabitedOfDay
- Std.Time.Nanosecond.instInhabitedOrdinal
- Std.Time.Nanosecond.instInhabitedSpan
- Std.Time.Nanosecond.instOffsetInhabited
- Std.Time.PlainDate.instInhabited
- Std.Time.Second.instOffsetInhabited
- Std.Time.TimeZone.TZif.instInhabitedHeader
- Std.Time.TimeZone.TZif.instInhabitedLeapSecond
- Std.Time.TimeZone.TZif.instInhabitedLocalTimeType
- Std.Time.TimeZone.TZif.instInhabitedTZif
- Std.Time.TimeZone.TZif.instInhabitedTZifV1
- Std.Time.TimeZone.TZif.instInhabitedTZifV2
- Std.Time.TimeZone.instInhabitedLocalTimeType
- Std.Time.TimeZone.instInhabitedOffset
- Std.Time.TimeZone.instInhabitedStdWall
- Std.Time.TimeZone.instInhabitedTransition
- Std.Time.TimeZone.instInhabitedUTLocal
- Std.Time.TimeZone.instInhabitedZoneRules
- Std.Time.Week.Ordinal.instInhabitedOfMonth
- Std.Time.Week.instInhabitedOrdinal
- Std.Time.Week.instOffsetInhabited
- Std.Time.Weekday.instInhabitedOrdinal
- Std.Time.Year.instInhabitedEra
- Std.Time.Year.instOffsetInhabited
- Std.Time.instInhabitedDuration
- Std.Time.instInhabitedFormatConfig
- Std.Time.instInhabitedFraction
- Std.Time.instInhabitedGenericFormat
- Std.Time.instInhabitedModifier
- Std.Time.instInhabitedNumber
- Std.Time.instInhabitedOffsetO
- Std.Time.instInhabitedOffsetX
- Std.Time.instInhabitedOffsetZ
- Std.Time.instInhabitedPlainDate
- Std.Time.instInhabitedPlainDateTime
- Std.Time.instInhabitedPlainTime
- Std.Time.instInhabitedText
- Std.Time.instInhabitedTimeZone
- Std.Time.instInhabitedTimestamp
- Std.Time.instInhabitedValidDate
- Std.Time.instInhabitedWeekday
- Std.Time.instInhabitedYear
- Std.Time.instInhabitedZoneId
- Std.Time.instInhabitedZoneName
- Std.Time.instInhabitedZonedDateTime
- Std.TreeMap.Raw.instInhabited
- Std.TreeMap.instInhabited
- Std.TreeSet.Raw.instInhabited
- Std.TreeSet.instInhabited
- Std.instInhabitedFormat
- String.instInhabited
- String.instInhabitedIterator
- String.instInhabitedRange
- Subarray.instInhabited
- SupBotHom.instInhabited
- SupHom.instInhabited
- Sym.inhabitedSym
- Sym.inhabitedSym'
- System.instInhabitedFilePath
- TopHom.instInhabited
- Trunc.instInhabited
- ULower.instInhabited
- Ultrafilter.instInhabited
- Unique.instInhabited
- Units.instInhabited
- UpperSet.instInhabited
- Vector.instInhabited
- WithBot.inhabited
- WithOne.inhabited
- WithTop.inhabited
- WithZero.inhabited
- ZMod.inhabited
- instENatInhabited
- instInhabitedAddHom
- instInhabitedAddMonoidHom
- instInhabitedAdditive
- instInhabitedAntisymmetrization
- instInhabitedAsLinearOrder
- instInhabitedBool
- instInhabitedEIO
- instInhabitedEST
- instInhabitedEnd
- instInhabitedError
- instInhabitedExcept
- instInhabitedExceptTOfMonad
- instInhabitedFilterBasisNat
- instInhabitedFloat
- instInhabitedFloat32
- instInhabitedForInStep
- instInhabitedForInStep_1
- instInhabitedForall
- instInhabitedForallOfMonad
- instInhabitedISize
- instInhabitedInt16
- instInhabitedInt32
- instInhabitedInt64
- instInhabitedInt8
- instInhabitedLex
- instInhabitedList
- instInhabitedMProd
- instInhabitedMonoidHom
- instInhabitedMulHom
- instInhabitedMultiplicative
- instInhabitedNat
- instInhabitedNonScalar
- instInhabitedNonemptyType
- instInhabitedOfMonad
- instInhabitedOneHom
- instInhabitedOption
- instInhabitedOrdering
- instInhabitedPNonScalar
- instInhabitedPProd
- instInhabitedPUnit
- instInhabitedPos
- instInhabitedProd
- instInhabitedProp
- instInhabitedRat
- instInhabitedReaderT
- instInhabitedRel
- instInhabitedSort
- instInhabitedState_mathlib
- instInhabitedStdGen
- instInhabitedSubstring
- instInhabitedTask
- instInhabitedTrue
- instInhabitedUInt16
- instInhabitedUInt32
- instInhabitedUInt64
- instInhabitedUInt8
- instInhabitedUSize
- instInhabitedZeroHom
- instNNRatInhabited
Nonempty α
is a typeclass that says that α
is not an empty type,
that is, there exists an element in the type. It differs from Inhabited α
in that Nonempty α
is a Prop
, which means that it does not actually carry
an element of α
, only a proof that there exists such an element.
Given Nonempty α
, you can construct an element of α
nonconstructively
using Classical.choice
.
Instances
- Aesop.Goal.instNonempty
- Aesop.MVarCluster.instNonempty
- Aesop.Rapp.instNonempty
- Aesop.Script.instNonemptyStepTree
- Aesop.SearchM.instNonemptyContext
- Aesop.instNonemptyGoalData
- Aesop.instNonemptyRappData
- Aesop.instNonemptyTreeSpec
- Batteries.Tactic.instNonemptyCache
- Batteries.Tactic.instNonemptyDeclCache
- Classical.instNonemptyDecidable
- FilterBasis.nonempty_sets
- Finset.instNonemptyElemToSetInsert
- Flag.instNonempty
- IO.instNonemptyBaseMutex
- IO.instNonemptyCancelToken
- IO.instNonemptyCondvar
- IO.instNonemptyMutex
- IO.instNonemptyPromise
- IsWellOrder.subtype_nonempty
- LLVM.instNonemptyAttribute
- LLVM.instNonemptyBasicBlock
- LLVM.instNonemptyBuilder
- LLVM.instNonemptyContext
- LLVM.instNonemptyLLVMType
- LLVM.instNonemptyMemoryBuffer
- LLVM.instNonemptyModule
- LLVM.instNonemptyTarget
- LLVM.instNonemptyTargetMachine
- LLVM.instNonemptyValue
- LO.Arith.instNonempty_foundation
- LO.FirstOrder.ModelOfSatEq.instNonempty
- LO.FirstOrder.Struc.instNonemptyDom
- LO.FirstOrder.Structure.Eq.QuotEq.inhabited
- LO.FirstOrder.Structure.Model.instNonempty
- LO.FirstOrder.Structure.instNonempty
- LO.FirstOrder.Structure.instNonemptyUprod
- LO.FirstOrder.instNonemptyFinSubtheory
- LO.FirstOrder.nonemptyModelOfSat
- LO.Modal.Kripke.FilterEqvQuotient.instNonempty
- LO.Modal.Kripke.instNonemptyWorld
- LO.Modal.MaximalConsistentSet.instNonemptyOfConsistentFormula
- LO.Modal.MaximalConsistentTableau.instNonemptyOfConsistentOfKFormulaOfDecidableEqOfEncodable
- LO.Propositional.Kripke.FilterEqvQuotient.instNonempty
- LO.Propositional.Kripke.instNonemptyWorld
- LO.Propositional.SaturatedConsistentTableau.instNonemptyOfConsistentOfIntFormulaOfDecidableEqOfEncodable
- Lake.instNonemptyNConfigDecl
- Lake.instNonemptyOpaquePostUpdateHook
- Lake.instNonemptyOpaqueTargetConfig
- Lake.instNonemptyOpaqueWorkspace
- Lake.instNonemptyPackage
- Lake.instNonemptyWorkspace
- Lean.Core.instNonemptyContext
- Lean.Core.instNonemptySavedState
- Lean.Core.instNonemptyState
- Lean.Elab.Command.instNonemptyState
- Lean.Elab.Frontend.instNonemptyState
- Lean.Elab.Term.StructInst.instNonemptySavedState
- Lean.Elab.Term.instNonemptySavedState
- Lean.Elab.instNonemptyBodyProcessedSnapshot
- Lean.Elab.instNonemptyDefParsed
- Lean.Elab.instNonemptyDefsParsedSnapshot
- Lean.Elab.instNonemptyHeaderProcessedSnapshot
- Lean.Elab.instNonemptyIncrementalState
- Lean.Environment.instNonemptyConstPromiseVal
- Lean.Kernel.instNonemptyEnvironment
- Lean.Kernel.instNonemptyException
- Lean.Language.Lean.instNonemptyCommandParsedSnapshot
- Lean.Language.Lean.instNonemptyCommandResultSnapshot
- Lean.Language.instNonemptySnapshotLeaf
- Lean.Language.instNonemptySnapshotTask
- Lean.Macro.instNonemptyMethodsRef
- Lean.Meta.Grind.instNonemptyMethodsRef
- Lean.Meta.Simp.instNonemptyMethodsRef
- Lean.Meta.instNonemptySavedState
- Lean.Server.instNonemptyRpcEncodable
- Lean.instNonemptyAsyncContext
- Lean.instNonemptyDynlib
- Lean.instNonemptyEnvExtensionEntry
- Lean.instNonemptyEnvironment
- Lean.instNonemptyEnvironmentHeader
- Lean.instNonemptyKeyedDeclsAttribute
- Lean.instNonemptyRealizationResult
- Lean.instNonemptySymbol
- Lean.instNonemptyVisibilityMap
- MLList.instNonemptySpec
- Nontrivial.to_nonempty
- One.instNonempty
- OrderDual.instNonempty
- PLift.instNonempty_mathlib
- POpaque.instNonempty
- PSum.nonemptyLeft
- PSum.nonemptyRight
- Pi.instNonempty
- ST.instNonemptyRef
- Set.instNonemptyElemImage
- Set.instNonemptyElemInsert
- Set.instNonemptyRange
- Set.instNonemptyTop
- Set.nonempty_Ici_subtype
- Set.nonempty_Iic_subtype
- Set.nonempty_Iio_subtype
- Set.nonempty_Ioi_subtype
- Set.univ.nonempty
- ShareCommon.instNonemptyState
- ShareCommon.instNonemptyStateFactory
- Std.CloseableChannel.Unbounded.instNonemptyState
- Std.CloseableChannel.instNonemptyFlavors
- Std.CloseableChannel.instNonemptyUnbounded
- Std.Internal.UV.TCP.instNonemptySocket
- Std.Internal.UV.UDP.instNonemptySocket
- Std.Internal.UV.instNonemptyTimer
- Std.instNonemptyBaseMutex
- Std.instNonemptyBaseRecursiveMutex
- Std.instNonemptyBaseSharedMutex
- Std.instNonemptyChannel
- Std.instNonemptyCloseableChannel
- Std.instNonemptyCondvar
- Std.instNonemptyMutex
- Std.instNonemptyRecursiveMutex
- Std.instNonemptySharedMutex
- Std.instNonemptySync
- Std.instNonemptySync_1
- Sum.nonemptyLeft
- Sum.nonemptyRight
- ULift.instNonempty_mathlib
- Ultrafilter.instNonempty
- Vector.instNonempty
- Vector.instNonemptyOfNatNat
- Zero.instNonempty
- bot_nonempty
- infSet_to_nonempty
- instNonemptyDynamic
- instNonemptyFloat
- instNonemptyFloat32
- instNonemptyForall
- instNonemptyGCDMonoid
- instNonemptyGCDMonoidOfNormalizedGCDMonoid
- instNonemptyMProd
- instNonemptyNormalizationMonoid
- instNonemptyNormalizationMonoidOfNormalizedGCDMonoid
- instNonemptyNormalizedGCDMonoid
- instNonemptyOfInhabited
- instNonemptyOfMonad
- instNonemptyOfZero_foundation
- instNonemptyPProd
- instNonemptyProd
- instNonemptyTask
- instNonemptyTypeName
- nonempty_equiv_of_countable
- nonempty_gt
- nonempty_lt
- supSet_to_nonempty
- top_nonempty
The axiom of choice. Nonempty α
is a proof that α
has an element,
but the element itself is erased. The axiom choice
supplies a particular
element of α
given only this proof.
The textbook axiom of choice normally makes a family of choices all at once,
but that is implied from this formulation, because if α : ι → Type
is a
family of types and h : ∀ i, Nonempty (α i)
is a proof that they are all
nonempty, then fun i => Classical.choice (h i) : ∀ i, α i
is a family of
chosen elements. This is actually a bit stronger than the ZFC choice axiom;
this is sometimes called "global choice".
In Lean, we use the axiom of choice to derive the law of excluded middle
(see Classical.em
), so it will often show up in axiom listings where you
may not expect. You can use #print axioms my_thm
to find out if a given
theorem depends on this or other axioms.
This axiom can be used to construct "data", but obviously there is no algorithm
to compute it, so Lean will require you to mark any definition that would
involve executing Classical.choice
or other axioms as noncomputable
, and
will not produce any executable code for such definitions.
The elimination principle for Nonempty α
. If Nonempty α
, and we can
prove p
given any element x : α
, then p
holds. Note that it is essential
that p
is a Prop
here; the version with p
being a Sort u
is equivalent
to Classical.choice
.
A variation on Classical.choice
that uses typeclass inference to
infer the proof of Nonempty α
.
Equations
Equations
- instInhabitedSort = { default := PUnit }
Lifts a proposition or type to a higher universe level.
PLift α
wraps a proof or value of type α
. The resulting type is in the next largest universe
after that of α
. In particular, propositions become data.
The related type ULift
can be used to lift a non-proposition type by any number of levels.
Examples:
(False : Prop)
(PLift False : Type)
([.up (by trivial), .up (by simp), .up (by decide)] : List (PLift True))
(Nat : Type 0)
(PLift Nat : Type 1)
- up :: (
- down : α
Extracts a wrapped proof or value from a universe-lifted proposition or type.
- )
Instances For
- Denumerable.plift
- PLift.encodable
- PLift.fintype
- PLift.fintypeProp
- PLift.instIsEmpty
- PLift.instLawfulApplicative_mathlib
- PLift.instLawfulFunctor_mathlib
- PLift.instLawfulMonad_mathlib
- PLift.instMonad_mathlib
- PLift.instNonempty_mathlib
- PLift.instSubsingleton_mathlib
- PLift.instUnique
- instCountablePLift
- instFinitePLift
- instInfinitePLift
- instSubsingletonPLift
- instUncountablePLift
NonemptyType.{u}
is the type of nonempty types in universe u
.
It is mainly used in constant declarations where we wish to introduce a type
and simultaneously assert that it is nonempty, but otherwise make the type
opaque.
Instances For
The underlying type of a NonemptyType
.
NonemptyType
is inhabited, because PUnit
is a nonempty type.
Lifts a type to a higher universe level.
ULift α
wraps a value of type α
. Instead of occupying the same universe as α
, which would be
the minimal level, it takes a further level parameter and occupies their minimum. The resulting type
may occupy any universe that's at least as large as that of α
.
The resulting universe of the lifting operator is the first parameter, and may be written explicitly
while allowing α
's level to be inferred.
The related type PLift
can be used to lift a proposition or type by one level.
Examples:
(Nat : Type 0)
(ULift Nat : Type 0)
(ULift Nat : Type 1)
(ULift Nat : Type 5)
(ULift.{7} (PUnit : Type 3) : Type 7)
- up :: (
- down : α
Extracts a wrapped value from a universe-lifted type.
- )
Instances For
- Denumerable.ulift
- LO.FirstOrder.instStructureULift
- Mathlib.instToExprULiftOfToLevel_mathlib
- Plausible.ULift.sampleableExt
- Plausible.ULift.shrinkable
- RelIso.IsWellOrder.ulift
- ULift.encodable
- ULift.fintype
- ULift.infSet
- ULift.instBEqOrd_mathlib
- ULift.instBEq_mathlib
- ULift.instBot
- ULift.instBoundedOrder
- ULift.instCompleteLattice
- ULift.instDistribLattice
- ULift.instHasCompl
- ULift.instIsEmpty
- ULift.instLEOrd_mathlib
- ULift.instLE_mathlib
- ULift.instLTOrd_mathlib
- ULift.instLT_mathlib
- ULift.instLattice
- ULift.instLawfulApplicative_mathlib
- ULift.instLawfulFunctor_mathlib
- ULift.instLawfulMonad_mathlib
- ULift.instLawfulOrd_mathlib
- ULift.instLinearOrder
- ULift.instMax_mathlib
- ULift.instMin_mathlib
- ULift.instMonad_mathlib
- ULift.instNonempty_mathlib
- ULift.instOrd_mathlib
- ULift.instOrderBot
- ULift.instOrderTop
- ULift.instOrientedOrd_mathlib
- ULift.instPartialOrder
- ULift.instPreorder
- ULift.instSDiff_mathlib
- ULift.instSemilatticeInf
- ULift.instSemilatticeSup
- ULift.instSubsingleton_mathlib
- ULift.instTop
- ULift.instTransOrd_mathlib
- ULift.instUnique
- ULift.supSet
- instCountableULift
- instFiniteULift
- instInfiniteULift
- instReprULift
- instSubsingletonULift
- instToStringULift
- instUncountableULift
- small_ulift
Either a proof that p
is true or a proof that p
is false. This is equivalent to a Bool
paired
with a proof that the Bool
is true
if and only if p
is true.
Decidable
instances are primarily used via if
-expressions and the tactic decide
. In
conditional expressions, the Decidable
instance for the proposition is used to select a branch. At
run time, this case distinction code is identical to that which would be generated for a
Bool
-based conditional. In proofs, the tactic decide
synthesizes an instance of Decidable p
,
attempts to reduce it to isTrue h
, and then succeeds with the proof h
if it can.
Because Decidable
carries data, when writing @[simp]
lemmas which include a Decidable
instance
on the LHS, it is best to use {_ : Decidable p}
rather than [Decidable p]
so that non-canonical
instances can be found via unification rather than instance synthesis.
- isFalse
{p : Prop}
(h : ¬p)
: Decidable p
Proves that
p
is decidable by supplying a proof of¬p
- isTrue
{p : Prop}
(h : p)
: Decidable p
Proves that
p
is decidable by supplying a proof ofp
Instances
- AddOpposite.instDecidableEq
- AddUnits.instDecidableEq
- Additive.instDecidablePredEven
- Aesop.GoalId.instDecidableRelLt
- Aesop.Iteration.instDecidableEq
- Aesop.Iteration.instDecidableRelLe
- Aesop.Iteration.instDecidableRelLt
- Aesop.Nanos.instDecidableRelLe
- Aesop.Nanos.instDecidableRelLt
- Aesop.RappId.instDecidableRelLt
- Aesop.instDecidableEqGoalId
- Aesop.instDecidableEqLevelIndex
- Aesop.instDecidableEqPremiseIndex
- Aesop.instDecidableEqRappId
- Aesop.instDecidableEqSlotIndex
- Aesop.instDecidableRelLevelIndexLe
- Aesop.instDecidableRelLevelIndexLt
- Aesop.instDecidableRelPremiseIndexLe
- Aesop.instDecidableRelPremiseIndexLt
- Aesop.instDecidableRelSlotIndexLe
- Aesop.instDecidableRelSlotIndexLt
- AntisymmRel.decidableRel
- Array.instDecidableEq
- Array.instDecidableExistsAndMemOfDecidablePred
- Array.instDecidableForallForallMemOfDecidablePred
- Array.instDecidableLEOfDecidableEqOfDecidableLT
- Array.instDecidableLTOfDecidableEq
- Array.instDecidableMemOfLawfulBEq
- Associates.instDecidableRelDvd
- Batteries.BinomialHeap.Imp.instDecidableRankGT
- Batteries.Tactic.Lint.instDecidableEqLintVerbosity
- BitVec.instDecidableEqLiteral
- BitVec.instDecidableExistsBitVec
- BitVec.instDecidableExistsBitVecSucc
- BitVec.instDecidableExistsBitVecZero
- BitVec.instDecidableForallBitVec
- BitVec.instDecidableForallBitVecSucc
- BitVec.instDecidableForallBitVecZero
- Bool.instDecidableExistsOfDecidablePred
- Bool.instDecidableForallOfDecidablePred
- Bool.instDecidableLe
- Bool.instDecidableLt
- Bool.instDecidableRelCovBy
- Bool.instDecidableRelWCovBy
- Char.instDecidableLe
- Char.instDecidableLt
- Fin.decLe
- Fin.decLt
- Fin.instDecidableEqValue
- Finset.Colex.instDecidableEq
- Finset.Colex.instDecidableLE
- Finset.Colex.instDecidableLT
- Finset.Nontrivial.instDecidablePred
- Finset.decidableCodisjoint
- Finset.decidableDExistsFinset
- Finset.decidableDforallFinset
- Finset.decidableDisjoint
- Finset.decidableEq
- Finset.decidableEqPiFinset
- Finset.decidableExistsAndFinset
- Finset.decidableExistsAndFinsetCoe
- Finset.decidableExistsOfDecidableSubsets
- Finset.decidableExistsOfDecidableSubsets'
- Finset.decidableForallOfDecidableSubsets
- Finset.decidableForallOfDecidableSubsets'
- Finset.decidableIsCompl
- Finset.decidableMem
- Finset.decidableMem'
- Finset.decidableNonempty
- Finset.instDecidableLE
- Finset.instDecidableLT
- Finset.instDecidableRelSSubset
- Finset.instDecidableRelSubset
- Fintype.decidableBijectiveFintype
- Fintype.decidableEqEmbeddingFintype
- Fintype.decidableEqEquivFintype
- Fintype.decidableExistsFintype
- Fintype.decidableForallFintype
- Fintype.decidableInjectiveFintype
- Fintype.decidableLeftInverseFintype
- Fintype.decidableMemRangeFintype
- Fintype.decidablePiFintype
- Fintype.decidableRightInverseFintype
- Fintype.decidableSubsingleton
- Fintype.decidableSurjectiveFintype
- Function.IsFixedPt.decidable
- Function.decidableEqPFun
- Function.fixedPoints.decidable
- IO.instDecidableEqTaskState
- Int.decLe
- Int.decLt
- Int.decidableDvd
- Int.instDecidableEq
- Int.instDecidablePredEven
- Int.instDecidablePredIsSquare
- Int.instDecidablePredOdd
- IsAddUnit.instDecidableOfExistsAddUnitsEqVal
- IsUnit.instDecidableOfExistsUnitsEqVal
- LO.FirstOrder.Language.ORing.instDecidableEqFuncORing
- LO.FirstOrder.Language.ORing.instDecidableEqRelORing
- LO.FirstOrder.Language.instDecidableEqFuncEqual
- LO.FirstOrder.Language.instDecidableEqRelEqual
- LO.FirstOrder.Semiformula.instDecidableEq
- LO.FirstOrder.Semiformulaᵢ.instDecidableEq
- LO.FirstOrder.Semiterm.instDecidableEq
- LO.FirstOrder.Structure.instDecidable
- LO.FirstOrder.instDecidableEqFuncOfDecidableEq
- LO.FirstOrder.instDecidableEqRelOfDecidableEq
- LO.FirstOrder.instDecidableEqRelOfDecidableEq_1
- LO.Meta.Kite.Arith.instDecidableEqEdgeType
- LO.Meta.Kite.Modal.instDecidableEqEdgeType
- LO.Modal.Formula.instDecidableEq
- LO.Modal.Kripke.Frame.pointGenerate.instDecidableEqWorld
- LO.Modal.instDecidableEqFormula
- LO.Modal.instDecidableEqNNFormula
- LO.Propositional.Formula.instDecidableEq
- LO.Propositional.Kripke.Frame.pointGenerate.instDecidableEqWorld
- LO.Propositional.NNFormula.instDecidableEq
- LO.Propositional.NNFormula.instDecidablePredIsAtomic
- LO.Propositional.Sequent.instDecidablePredIsAtomic
- LO.Propositional.instDecidableEqFormula
- LO.Propositional.instDecidablePredNNFormulaIsTautologyOfDecidableEq
- LO.Propositional.instDecidablePredSequentIsClosedOfDecidableEq
- LO.Propositional.instDecidablePredSequentIsOpenOfDecidableEq
- LO.Propositional.instDecidablePredSequentIsTautologyOfDecidableEq
- LO.Propositional.instDecidablePredSequentsIsClosedOfDecidableEq
- LO.Propositional.instDecidablePredSequentsRefutedOfDecidableEq
- Lake.Log.instDecidableEqPos
- Lake.Toml.instDecidableEqDateTime
- Lake.Toml.instDecidableEqTime
- Lake.ToolchainVer.decLe
- Lake.ToolchainVer.decLt
- Lake.instDecidableEqBackend
- Lake.instDecidableEqBuildKey
- Lake.instDecidableEqBuildType
- Lake.instDecidableEqDate
- Lake.instDecidableEqGlob
- Lake.instDecidableEqHash
- Lake.instDecidableEqJobAction
- Lake.instDecidableEqLogLevel
- Lake.instDecidableEqSemVerCore
- Lake.instDecidableEqStdVer
- Lake.instDecidableEqToolchainVer
- Lake.instDecidableEqVerbosity
- Lake.instDecidableRelPosLe
- Lake.instDecidableRelPosLt
- Lean.Compiler.LCNF.instDecidableLePhase
- Lean.Compiler.LCNF.instDecidableLtPhase
- Lean.Elab.Command.Structure.instDecidableEqStructFieldKind
- Lean.Elab.WF.GuessLex.instDecidableEqGuessLexRel
- Lean.JsonNumber.instDecidableLt
- Lean.JsonRpc.instDecidableLtRequestID
- Lean.Lsp.instDecidableEqCompletionItemKind
- Lean.Lsp.instDecidableEqCompletionItemTag
- Lean.Lsp.instDecidableEqMarkupContent
- Lean.Lsp.instDecidableEqMarkupKind
- Lean.Meta.DiscrTree.instDecidableLtKey
- Lean.Meta.LibrarySearch.instDecidableEqDeclMod
- Lean.Meta.NormCast.instDecidableEqLabel
- Lean.Meta.Simp.instDecidableEqDischargeResult
- Lean.Meta.instDecidableEqCoeFnType
- Lean.Meta.instDecidableEqProjReductionKind
- Lean.Meta.instDecidableLtOrigin
- Lean.Name.instDecidableEq
- Lean.Omega.instDecidableEqConstraint
- Lean.Omega.instDecidableEqLinearCombo
- Lean.Parser.instDecidableEqRecoveryContext
- Lean.SubExpr.Pos.instDecidableEq
- Lean.instDecidableEqDeclarationLocation
- Lean.instDecidableEqDeclarationRange
- Lean.instDecidableEqJsonNumber
- Lean.instDecidableEqLocalDeclKind
- Lean.instDecidableEqModuleIdx_batteries
- Lean.instDecidableEqOLeanLevel
- Lean.instDecidableEqPosition
- Lean.instDecidableLtLiteral
- List.Lex.decidableRel
- List.Vector.instDecidableEq
- List.decidableBAll
- List.decidableBEx
- List.decidableChain
- List.decidableChain'
- List.decidableDuplicate
- List.decidableInfix
- List.decidableLE
- List.decidableLT
- List.decidableLex
- List.decidablePerm
- List.decidableSorted
- List.decidableSubperm
- List.instDecidableBijOnToSetOfDecidableEq
- List.instDecidableForall₂
- List.instDecidableInjOnToSetOfDecidableEq
- List.instDecidableIsPrefixOfDecidableEq
- List.instDecidableIsSuffixOfDecidableEq
- List.instDecidableMapsToToSetOfDecidablePredMemSet
- List.instDecidableMemOfLawfulBEq
- List.instDecidablePairwise
- List.instDecidablePredForall
- List.instDecidableR_mathlib
- List.instDecidableRelSubsetOfDecidableEq
- List.instDecidableSublistOfDecidableEq
- List.instDecidableSurjOnToSetOfDecidableEq
- List.isRotatedDecidable
- List.nodupDecidable
- Mathlib.Linter.Flexible.instDecidableEqStained
- MulOpposite.instDecidableEq
- Multiplicative.instDecidablePredIsSquare
- Multiset.decidableDexistsMultiset
- Multiset.decidableDforallMultiset
- Multiset.decidableEq
- Multiset.decidableEqPiMultiset
- Multiset.decidableLE
- Multiset.decidableMem
- Multiset.instDecidableEquivListOfDecidableEq
- Multiset.instDecidableRListOfDecidableEq
- Multiset.nodupDecidable
- Nat.decLe
- Nat.decLt
- Nat.decidableBallLE
- Nat.decidableBallLT
- Nat.decidableExistsLE
- Nat.decidableExistsLE'
- Nat.decidableExistsLT
- Nat.decidableExistsLT'
- Nat.decidableForallFin
- Nat.decidableLoHi
- Nat.decidableLoHiLe
- Nat.decidablePrime
- Nat.decidable_dvd
- Nat.instDecidableCoprime
- Nat.instDecidableModEq
- Nat.instDecidablePredEven
- Nat.instDecidablePredIsSquare
- Nat.instDecidablePredOdd
- Nat.instPrimesDecidableEq
- Option.decidableExistsMem
- Option.decidableForallMem
- Option.instDecidableEq
- Option.instDecidableMemOfDecidableEq
- Option.instDecidableRelLt
- Ord.instDecidableRelLe
- Ord.instDecidableRelLt
- Order.Preimage.decidable
- PLift.instDecidableEq_mathlib
- PSigma.decidableEq
- Part.noneDecidable
- Part.ofOptionDecidable
- Part.someDecidable
- Prod.Lex.decidable
- Prod.Lex.instDecidableRelOfDecidableEq
- Prod.instDecidableLE
- Prod.lexLtDec
- Prop.decidablePredBot
- Prop.decidablePredTop
- Prop.decidableRelBot
- Prop.decidableRelTop
- Quot.instDecidableLiftOnOfDecidablePred_mathlib
- Quot.instDecidableLiftOn₂OfDecidablePred
- Quot.lift.decidablePred
- Quot.lift₂.decidablePred
- Quotient.decidableEq
- Quotient.instDecidableLiftOn'OfDecidablePred
- Quotient.instDecidableLiftOnOfDecidablePred_mathlib
- Quotient.instDecidableLiftOn₂'OfDecidablePred
- Quotient.instDecidableLiftOn₂OfDecidablePred_mathlib
- Quotient.lift.decidablePred
- Quotient.lift₂.decidablePred
- Rat.instDecidableLe
- Rat.instDecidableLt
- Relation.instDecidableMapOfExistsAndEq
- Set.decidableCompl
- Set.decidableEmptyset
- Set.decidableInsert
- Set.decidableInter
- Set.decidableMemDiagonal
- Set.decidableMemIcc
- Set.decidableMemIci
- Set.decidableMemIco
- Set.decidableMemIic
- Set.decidableMemIio
- Set.decidableMemIoc
- Set.decidableMemIoi
- Set.decidableMemIoo
- Set.decidableMemProd
- Set.decidableSdiff
- Set.decidableSetOf
- Set.decidableSingleton
- Set.decidableUnion
- Set.decidableUniv
- Sigma.instDecidableEqSigma
- Std.CloseableChannel.instDecidableEqError
- Std.DHashMap.Raw.instDecidableMem
- Std.DHashMap.instDecidableMem
- Std.DTreeMap.Internal.Impl.instDecidableMem
- Std.DTreeMap.Raw.instDecidableMem
- Std.DTreeMap.instDecidableMem
- Std.ExtDHashMap.instDecidableMem
- Std.ExtHashMap.instDecidableMem
- Std.ExtHashSet.instDecidableMem
- Std.HashMap.Raw.instDecidableMem
- Std.HashMap.instDecidableMem
- Std.HashSet.Raw.instDecidableMem
- Std.HashSet.instDecidableMem
- Std.Internal.Rat.instDecidableLe
- Std.Internal.Rat.instDecidableLt
- Std.Internal.instDecidableEqRat
- Std.Net.instDecidableEqAddressFamily
- Std.Net.instDecidableEqIPAddr
- Std.Net.instDecidableEqIPv4Addr
- Std.Net.instDecidableEqIPv6Addr
- Std.Net.instDecidableEqInterfaceAddress
- Std.Net.instDecidableEqMACAddr
- Std.Net.instDecidableEqSocketAddress
- Std.Net.instDecidableEqSocketAddressV4
- Std.Net.instDecidableEqSocketAddressV6
- Std.Sat.AIG.instDecidableEqDecl
- Std.Sat.AIG.instDecidableEqFanin
- Std.Sat.CNF.Clause.instDecidableMemOfDecidableEq
- Std.Sat.CNF.instDecidableExistsMemOfDecidableEq
- Std.Sat.CNF.instDecidableMemOfDecidableEq
- Std.Tactic.BVDecide.BVExpr.Cache.instDecidableEqKey
- Std.Tactic.BVDecide.BVExpr.instDecidableEq
- Std.Tactic.BVDecide.LRAT.Internal.Clause.instDecidableEval
- Std.Tactic.BVDecide.LRAT.Internal.Clause.instDecidableEvalLiteral
- Std.Tactic.BVDecide.LRAT.Internal.instDecidableEqAssignment
- Std.Tactic.BVDecide.LRAT.Internal.instDecidableEqPosFin
- Std.Tactic.BVDecide.LRAT.Internal.instDecidableEqResult
- Std.Tactic.BVDecide.instDecidableEqBVBinOp
- Std.Tactic.BVDecide.instDecidableEqBVBit
- Std.Tactic.BVDecide.instDecidableEqBVUnOp
- Std.Time.Day.Ordinal.instDecidableEqOfYear
- Std.Time.Day.instDecidableLeOffset
- Std.Time.Day.instDecidableLeOrdinal
- Std.Time.Day.instDecidableLtOffset
- Std.Time.Day.instDecidableLtOrdinal
- Std.Time.Day.instOffsetDecidableEq
- Std.Time.Day.instOrdinalDecidableEq
- Std.Time.Duration.instDecidableLe
- Std.Time.Hour.instDecidableLeOffset
- Std.Time.Hour.instDecidableLeOrdinal
- Std.Time.Hour.instDecidableLtOffset
- Std.Time.Hour.instDecidableLtOrdinal
- Std.Time.Hour.instOffsetDecidableEq
- Std.Time.Hour.instOrdinalDecidableEq
- Std.Time.Internal.Bounded.instDecidableEq
- Std.Time.Internal.Bounded.instDecidableLe
- Std.Time.Internal.instDecidableEqUnitVal
- Std.Time.Internal.instDecidableLeUnitVal
- Std.Time.Millisecond.instDecidableLeOffset
- Std.Time.Millisecond.instDecidableLeOrdinal
- Std.Time.Millisecond.instDecidableLtOffset
- Std.Time.Millisecond.instDecidableLtOrdinal
- Std.Time.Millisecond.instOffsetDecidableEq
- Std.Time.Millisecond.instOrdinalDecidableEq
- Std.Time.Minute.instDecidableLeOffset
- Std.Time.Minute.instDecidableLeOrdinal
- Std.Time.Minute.instDecidableLtOffset
- Std.Time.Minute.instDecidableLtOrdinal
- Std.Time.Minute.instOffsetDecidableEq
- Std.Time.Minute.instOrdinalDecidableEq
- Std.Time.Month.instDecidableLeOffset
- Std.Time.Month.instDecidableLeOrdinal
- Std.Time.Month.instDecidableLtOffset
- Std.Time.Month.instDecidableLtOrdinal
- Std.Time.Month.instOffsetDecidableEq
- Std.Time.Month.instOrdinalDecidableEq
- Std.Time.Month.instQuarterDecidableEq
- Std.Time.Nanosecond.Ordinal.instDecidableLeOfDay
- Std.Time.Nanosecond.Ordinal.instDecidableLtOfDay
- Std.Time.Nanosecond.Ordinal.instOfDayDecidableEq
- Std.Time.Nanosecond.instDecidableLeOffset
- Std.Time.Nanosecond.instDecidableLeOrdinal
- Std.Time.Nanosecond.instDecidableLeSpan
- Std.Time.Nanosecond.instDecidableLtOffset
- Std.Time.Nanosecond.instDecidableLtOrdinal
- Std.Time.Nanosecond.instDecidableLtSpan
- Std.Time.Nanosecond.instOffsetDecidableEq
- Std.Time.Nanosecond.instOrdinalDecidableEq
- Std.Time.Nanosecond.instSpanDecidableEq
- Std.Time.Second.instDecidableEqOrdinal
- Std.Time.Second.instDecidableLeOffset
- Std.Time.Second.instDecidableLeOrdinal
- Std.Time.Second.instDecidableLtOffset
- Std.Time.Second.instDecidableLtOrdinal
- Std.Time.Second.instOffsetDecidableEq
- Std.Time.TimeZone.instDecidableEqOffset
- Std.Time.Week.Ordinal.instOfMonthDecidableEq
- Std.Time.Week.instDecidableLeOffset
- Std.Time.Week.instDecidableLeOrdinal
- Std.Time.Week.instDecidableLtOffset
- Std.Time.Week.instDecidableLtOrdinal
- Std.Time.Week.instOffsetDecidableEq
- Std.Time.Week.instOrdinalDecidableEq
- Std.Time.Weekday.instDecidableLeOrdinal
- Std.Time.Weekday.instDecidableLtOrdinal
- Std.Time.Weekday.instOrdinalDecidableEq
- Std.Time.Year.instDecidableLeOffset
- Std.Time.Year.instDecidableLtOffset
- Std.Time.Year.instOffsetDecidableEq
- Std.Time.instDecidableEqDuration
- Std.Time.instDecidableEqHourMarker
- Std.Time.instDecidableEqPlainDate
- Std.Time.instDecidableEqPlainDateTime
- Std.Time.instDecidableEqPlainTime
- Std.Time.instDecidableEqTimeZone
- Std.Time.instDecidableEqTimestamp
- Std.Time.instDecidableEqValidDate
- Std.Time.instDecidableEqWeekday
- Std.Time.instDecidableLeTimestamp
- Std.TreeMap.Raw.instDecidableMem
- Std.TreeMap.instDecidableMem
- Std.TreeSet.Raw.instDecidableMem
- Std.TreeSet.instDecidableMem
- String.decLE
- String.decidableLT
- String.instDecidableEqIterator
- Subtype.decidableLE
- Subtype.decidableLT
- Subtype.instDecidableEq
- Sum.instDecidableEq
- Sum.instDecidableLiftRel
- Sum.instDecidableRelSumLex
- Sym.decidableMem
- System.instDecidableEqFilePath
- ULift.instDecidableEq_mathlib
- Units.instDecidableEq
- Vector.instDecidableEq
- Vector.instDecidableExistsAndMemOfDecidablePred
- Vector.instDecidableExistsVectorSucc
- Vector.instDecidableExistsVectorZero
- Vector.instDecidableForallForallMemOfDecidablePred
- Vector.instDecidableForallVectorSucc
- Vector.instDecidableForallVectorZero
- Vector.instDecidableLEOfDecidableEqOfDecidableLT
- Vector.instDecidableLTOfDecidableEq
- Vector.instDecidableMemOfLawfulBEq
- WithBot.decidableEq
- WithBot.decidableLE
- WithBot.decidableLT
- WithTop.decidableEq
- WithTop.decidableLE
- WithTop.decidableLT
- ZMod.decidableEq
- decidableEq_of_subsingleton
- exists_prop_decidable
- float32DecLe
- float32DecLt
- floatDecLe
- floatDecLt
- forall_prop_decidable
- instDecidableAnd
- instDecidableAntitoneOfForallForallForallLe
- instDecidableAntitoneOfForallForallForallLe_1
- instDecidableAntitoneOnOfForallForallMemSetForallForallForallLe
- instDecidableAntitoneOnOfForallForallMemSetForallForallForallLe_1
- instDecidableCurryOfMk_mathlib
- instDecidableDite
- instDecidableEqAdditive
- instDecidableEqBitVec
- instDecidableEqBool
- instDecidableEqChar
- instDecidableEqEmpty
- instDecidableEqFin
- instDecidableEqISize
- instDecidableEqInt16
- instDecidableEqInt32
- instDecidableEqInt64
- instDecidableEqInt8
- instDecidableEqLex
- instDecidableEqList
- instDecidableEqMultiplicative
- instDecidableEqNat
- instDecidableEqOfIff
- instDecidableEqOrdering
- instDecidableEqPEmpty
- instDecidableEqPLift
- instDecidableEqPUnit
- instDecidableEqPos
- instDecidableEqProd
- instDecidableEqRat
- instDecidableEqString
- instDecidableEqSum
- instDecidableEqSym
- instDecidableEqUInt16
- instDecidableEqUInt32
- instDecidableEqUInt64
- instDecidableEqUInt8
- instDecidableEqULift
- instDecidableEqULower
- instDecidableEqUSize
- instDecidableEqVector
- instDecidableFact
- instDecidableFalse
- instDecidableForall
- instDecidableIff
- instDecidableIte
- instDecidableLeBitVec
- instDecidableLeISize
- instDecidableLeInt16
- instDecidableLeInt32
- instDecidableLeInt64
- instDecidableLeInt8
- instDecidableLePos
- instDecidableLeUInt16
- instDecidableLeUInt32
- instDecidableLeUInt64
- instDecidableLeUInt8
- instDecidableLeUSize
- instDecidableLtBitVec
- instDecidableLtISize
- instDecidableLtInt16
- instDecidableLtInt32
- instDecidableLtInt64
- instDecidableLtInt8
- instDecidableLtPos
- instDecidableLtUInt16
- instDecidableLtUInt32
- instDecidableLtUInt64
- instDecidableLtUInt8
- instDecidableLtUSize
- instDecidableMonotoneOfForallForallForallLe
- instDecidableMonotoneOfForallForallForallLe_1
- instDecidableMonotoneOnOfForallForallMemSetForallForallForallLe
- instDecidableMonotoneOnOfForallForallMemSetForallForallForallLe_1
- instDecidableNot
- instDecidableOr
- instDecidablePredAddOppositeEven
- instDecidablePredComp
- instDecidablePredComp_batteries
- instDecidablePredMemLowerClosure
- instDecidablePredMemUpperClosure
- instDecidablePredMulOppositeIsSquare
- instDecidableRelAssociatedOfDvd
- instDecidableRelLe
- instDecidableRelLt
- instDecidableRelVectorEquivOfDecidableEq
- instDecidableStrictAntiOfForallForallForallLt
- instDecidableStrictAntiOfForallForallForallLt_1
- instDecidableStrictAntiOnOfForallForallMemSetForallForallForallLt
- instDecidableStrictAntiOnOfForallForallMemSetForallForallForallLt_1
- instDecidableStrictMonoOfForallForallForallLt
- instDecidableStrictMonoOfForallForallForallLt_1
- instDecidableStrictMonoOnOfForallForallMemSetForallForallForallLt
- instDecidableStrictMonoOnOfForallForallMemSetForallForallForallLt_1
- instDecidableTrue
- instDecidableUncurryOfFstSnd_mathlib
- instDecidableXor'
- instPNatDecidableEq
A decidable predicate.
A predicate is decidable if the corresponding proposition is Decidable
for each possible argument.
Equations
- DecidablePred r = ((a : α) → Decidable (r a))
A decidable relation.
A relation is decidable if the corresponding proposition is Decidable
for all possible arguments.
Equations
- DecidableRel r = ((a : α) → (b : β) → Decidable (r a b))
Propositional equality is Decidable
for all elements of a type.
In other words, an instance of DecidableEq α
is a means of deciding the proposition a = b
is
for all a b : α
.
Equations
- DecidableEq α = ((a b : α) → Decidable (a = b))
Checks whether two terms of a type are equal using the type's DecidableEq
instance.
Decides whether two Booleans are equal.
This function should normally be called via the DecidableEq Bool
instance that it exists to
support.
Equations
BEq α
is a typeclass for supplying a boolean-valued equality relation on
α
, notated as a == b
. Unlike DecidableEq α
(which uses a = b
), this
is Bool
valued instead of Prop
valued, and it also does not have any
axioms like being reflexive or agreeing with =
. It is mainly intended for
programming applications. See LawfulBEq
for a version that requires that
==
and =
coincide.
Typically we prefer to put the "more variable" term on the left, and the "more constant" term on the right.
- beq : α → α → Bool
Boolean equality, notated as
a == b
.Conventions for notations in identifiers:
- The recommended spelling of
==
in identifiers isbeq
.
- The recommended spelling of
Instances
- Aesop.ForwardRule.instBEq
- Aesop.Goal.instBEq
- Aesop.Hyp.instBEq
- Aesop.IndexMatchLocation.instBEq
- Aesop.LocalNormSimpRule.instBEq
- Aesop.Match.instBEq
- Aesop.NormSimpRule.instBEq
- Aesop.Percent.instBEq
- Aesop.Rapp.instBEq
- Aesop.Rule.instBEq
- Aesop.RuleName.instBEq
- Aesop.Substitution.instBEq
- Aesop.UnfoldRule.instBEq
- Aesop.instBEqBuilderName
- Aesop.instBEqCompleteMatch
- Aesop.instBEqDisplayRuleName
- Aesop.instBEqEntry
- Aesop.instBEqForwardRuleMatch
- Aesop.instBEqForwardRulePriority
- Aesop.instBEqGoalState
- Aesop.instBEqGoalWithMVars
- Aesop.instBEqLevelIndex
- Aesop.instBEqNanos
- Aesop.instBEqNodeState
- Aesop.instBEqOptions
- Aesop.instBEqPINF
- Aesop.instBEqPINFRaw
- Aesop.instBEqPatSubstSource
- Aesop.instBEqPhaseName
- Aesop.instBEqPremiseIndex
- Aesop.instBEqRawHyp
- Aesop.instBEqRegularRule
- Aesop.instBEqScopeName
- Aesop.instBEqSlotIndex
- Aesop.instBEqStrategy
- Array.instBEq
- IO.FS.instBEqFileType
- IO.FS.instBEqSystemTime
- Int.Linear.instBEqExpr
- Int.Linear.instBEqPoly
- Int.OfNat.instBEqExpr
- Lake.MTime.instBEq
- Lake.Toml.RBDict.instBEqOfProd
- Lake.Toml.instBEqValue
- Lake.instBEqConfigTarget
- Lake.instBEqHash
- Lake.instBEqModule
- Lake.instBEqPackage
- Lean.Compiler.LCNF.FixedParams.instBEqAbsValue
- Lean.Compiler.LCNF.FloatLetIn.instBEqDecision
- Lean.Compiler.LCNF.UnreachableBranches.Value.instBEq
- Lean.Compiler.LCNF.instBEqArg
- Lean.Compiler.LCNF.instBEqCode
- Lean.Compiler.LCNF.instBEqDecl
- Lean.Compiler.LCNF.instBEqDeclValue
- Lean.Compiler.LCNF.instBEqFunDecl
- Lean.Compiler.LCNF.instBEqLetDecl
- Lean.Compiler.LCNF.instBEqLetValue
- Lean.Compiler.LCNF.instBEqLitValue
- Lean.Compiler.LCNF.instBEqParam
- Lean.Compiler.instBEqInlineAttributeKind
- Lean.Compiler.instBEqSpecializeAttributeKind
- Lean.Data.AC.instBEqExpr
- Lean.Diff.instBEqAction
- Lean.Elab.Structural.instBEqIndGroupInfo
- Lean.Elab.Tactic.BVDecide.Frontend.Normalize.instBEqOp
- Lean.Elab.Tactic.instBEqCacheKey
- Lean.Elab.Tactic.instBEqSimpKind
- Lean.Elab.Term.Op.instBEqBinOpKind
- Lean.Elab.Term.instBEqPostponeBehavior
- Lean.Elab.instBEqDefKind
- Lean.Elab.instBEqInlayHintTextEdit
- Lean.Expr.instBEq
- Lean.ExprStructEq.instBEq
- Lean.Grind.CommRing.instBEqExpr
- Lean.Grind.CommRing.instBEqMon
- Lean.Grind.CommRing.instBEqPoly
- Lean.Grind.CommRing.instBEqPower
- Lean.Grind.instBEqConfig
- Lean.IR.Borrow.OwnedSet.instBEqKey
- Lean.IR.Borrow.ParamMap.instBEqKey
- Lean.IR.IRType.instBEq
- Lean.IR.UnreachableBranches.Value.instBEq
- Lean.IR.instBEqArg
- Lean.IR.instBEqCtorInfo
- Lean.IR.instBEqFnBody
- Lean.IR.instBEqJoinPointId
- Lean.IR.instBEqLitVal
- Lean.IR.instBEqVarId
- Lean.Json.instBEq
- Lean.JsonRpc.instBEqErrorCode
- Lean.JsonRpc.instBEqNotification
- Lean.JsonRpc.instBEqRequest
- Lean.JsonRpc.instBEqRequestID
- Lean.JsonRpc.instBEqResponse
- Lean.JsonRpc.instBEqResponseError
- Lean.KVMap.instBEq
- Lean.Level.instBEq
- Lean.Lsp.instBEqCallHierarchyItem
- Lean.Lsp.instBEqCancelParams
- Lean.Lsp.instBEqCompletionItem
- Lean.Lsp.instBEqDiagnosticCode
- Lean.Lsp.instBEqDiagnosticRelatedInformation
- Lean.Lsp.instBEqDiagnosticSeverity
- Lean.Lsp.instBEqDiagnosticTag
- Lean.Lsp.instBEqDiagnosticWith
- Lean.Lsp.instBEqInsertReplaceEdit
- Lean.Lsp.instBEqLeanDiagnosticTag
- Lean.Lsp.instBEqLeanFileProgressKind
- Lean.Lsp.instBEqLocation
- Lean.Lsp.instBEqPosition
- Lean.Lsp.instBEqPublishDiagnosticsParams
- Lean.Lsp.instBEqRange
- Lean.Lsp.instBEqRefIdent
- Lean.Lsp.instBEqRpcRef
- Lean.Lsp.instBEqSemanticTokenType
- Lean.Lsp.instBEqSymbolKind
- Lean.Lsp.instBEqSymbolTag
- Lean.Meta.Canonicalizer.instBEqExprVisited
- Lean.Meta.DSimp.instBEqConfig
- Lean.Meta.DiscrTree.instBEqKey
- Lean.Meta.Ext.instBEqExtTheorem
- Lean.Meta.FunInd.instBEqCall
- Lean.Meta.Grind.Arith.Cutsat.Search.instBEqKind
- Lean.Meta.Grind.Arith.Cutsat.instBEqForeignType
- Lean.Meta.Grind.Arith.Cutsat.instBEqSupportedTermKind
- Lean.Meta.Grind.instBEqCongrKey
- Lean.Meta.Grind.instBEqCongrTheoremCacheKey
- Lean.Meta.Grind.instBEqEMatchTheoremKind
- Lean.Meta.Grind.instBEqEMatchTheoremTrace
- Lean.Meta.Grind.instBEqENodeKey
- Lean.Meta.Grind.instBEqOrigin
- Lean.Meta.Grind.instBEqOrigin_1
- Lean.Meta.Grind.instBEqPreInstance
- Lean.Meta.Grind.instBEqSplitInfo
- Lean.Meta.Grind.instBEqSplitStatus
- Lean.Meta.LazyDiscrTree.instBEqKey
- Lean.Meta.Simp.instBEqConfig
- Lean.Meta.Simp.instBEqSimprocEntry
- Lean.Meta.instBEqAbstractMVarsResult
- Lean.Meta.instBEqCongrArgKind
- Lean.Meta.instBEqDefEqCacheKey
- Lean.Meta.instBEqEtaStructMode
- Lean.Meta.instBEqExprConfigCacheKey
- Lean.Meta.instBEqFunIndParamKind
- Lean.Meta.instBEqInfoCacheKey
- Lean.Meta.instBEqInstanceEntry
- Lean.Meta.instBEqOccurrences
- Lean.Meta.instBEqOrigin
- Lean.Meta.instBEqSimpTheorem
- Lean.Meta.instBEqSynthInstanceCacheKey
- Lean.Meta.instBEqTransparencyMode
- Lean.Name.instBEq
- Lean.Omega.instBEqConstraint
- Lean.Parser.instBEqCacheableParserContext
- Lean.Parser.instBEqError
- Lean.Parser.instBEqLeadingIdentBehavior
- Lean.Parser.instBEqOrElseOnAntiquotBehavior
- Lean.Parser.instBEqParserCacheKey
- Lean.Parser.instBEqRecoveryContext
- Lean.PersistentHashSet.instBEq_batteries
- Lean.Server.FileWorker.instBEqAbsoluteLspSemanticToken
- Lean.Server.instBEqGoToKind
- Lean.Syntax.instBEq
- Lean.Syntax.instBEqPreresolved
- Lean.Syntax.instBEqTSyntax
- Lean.Widget.instBEqTaggedText
- Lean.instBEqAttributeApplicationTime
- Lean.instBEqAttributeKind
- Lean.instBEqAxiomVal
- Lean.instBEqBinderInfo
- Lean.instBEqConstantKind
- Lean.instBEqConstantVal
- Lean.instBEqConstructor
- Lean.instBEqConstructorVal
- Lean.instBEqData
- Lean.instBEqDataValue
- Lean.instBEqData_1
- Lean.instBEqDeclaration
- Lean.instBEqDefinitionSafety
- Lean.instBEqDefinitionVal
- Lean.instBEqExternAttrData
- Lean.instBEqExternEntry
- Lean.instBEqFVarId
- Lean.instBEqHeadIndex
- Lean.instBEqInductiveType
- Lean.instBEqInternalExceptionId
- Lean.instBEqLBool
- Lean.instBEqLOption
- Lean.instBEqLevelMVarId
- Lean.instBEqLiteral
- Lean.instBEqLocalInstance
- Lean.instBEqMVarId
- Lean.instBEqMessageSeverity
- Lean.instBEqOpaqueVal
- Lean.instBEqOpenDecl
- Lean.instBEqOptions
- Lean.instBEqPtr
- Lean.instBEqRecursorRule
- Lean.instBEqRecursorVal
- Lean.instBEqReducibilityHints
- Lean.instBEqReducibilityStatus
- Lean.instBEqSourceInfo_lean
- Lean.instBEqTheoremVal
- Lean.instModuleIdxBEq
- List.instBEq
- Mathlib.AssertNotExist.instBEqAssertExists
- Mathlib.StacksTag.instBEqDatabase
- Mathlib.StacksTag.instBEqTag
- Mathlib.Tactic.CC.instBEqACApps
- Mathlib.Tactic.CC.instBEqCCCongrTheoremKey
- Mathlib.Tactic.CC.instBEqCongruencesKey
- Mathlib.Tactic.CC.instBEqSymmCongruencesKey
- Mathlib.Tactic.RingNF.instBEqConfig
- Mathlib.Tactic.RingNF.instBEqRingMode
- Nat.Linear.instBEqExpr
- Nat.Linear.instBEqPolyCnstr
- Option.instBEq
- Qq.instBEqQuoted
- Std.Format.instBEqFlattenBehavior
- Std.HashSet.instBEq_batteries
- Std.Internal.instBEqRat
- Std.Tactic.BVDecide.LRAT.Internal.instBEqAssignment
- Std.Tactic.BVDecide.LRAT.Internal.instBEqDefaultClause
- Std.Tactic.BVDecide.LRAT.instBEqAction
- Std.Time.instBEqDateTime
- String.instBEqRange
- Substring.hasBeq
- Subtype.instBEq
- Sum.instBEq
- ULift.instBEq_mathlib
- Vector.instBEq
- instBEqFloat
- instBEqFloat32
- instBEqLex
- instBEqOfDecidableEq
- instBEqProd
"Dependent" if-then-else, normally written via the notation if h : c then t(h) else e(h)
,
is sugar for dite c (fun h => t(h)) (fun h => e(h))
, and it is the same as
if c then t else e
except that t
is allowed to depend on a proof h : c
,
and e
can depend on h : ¬c
. (Both branches use the same name for the hypothesis,
even though it has different types in the two cases.)
We use this to be able to communicate the if-then-else condition to the branches.
For example, Array.get arr i h
expects a proof h : i < arr.size
in order to
avoid a bounds check, so you can write if h : i < arr.size then arr.get i h else ...
to avoid the bounds check inside the if branch. (Of course in this case we have only
lifted the check into an explicit if
, but we could also use this proof multiple times
or derive i < arr.size
from some other proposition that we are checking in the if
.)
Equations
- dite c t e = Decidable.casesOn h e t
Instances For
if-then-else #
if c then t else e
is notation for ite c t e
, "if-then-else", which decides to
return t
or e
depending on whether c
is true or false. The explicit argument
c : Prop
does not have any actual computational content, but there is an additional
[Decidable c]
argument synthesized by typeclass inference which actually
determines how to evaluate c
to true or false. Write if h : c then t else e
instead for a "dependent if-then-else" dite
, which allows t
/e
to use the fact
that c
is true/false.
Instances For
Equations
Equations
Equations
Boolean operators #
The conditional function.
cond c x y
is the same as if c then x else y
, but optimized for a Boolean condition rather than
a decidable proposition. It can also be written using the notation bif c then x else y
.
Just like ite
, cond
is declared @[macro_inline]
, which causes applications of cond
to be
unfolded. As a result, x
and y
are not evaluated at runtime until one of them is selected, and
only the selected branch is evaluated.
The dependent conditional function, in which each branch is provided with a local assumption about the condition's value. This allows the value to be used in proofs as well as for control flow.
dcond c (fun h => x) (fun h => y)
is the same as if h : c then x else y
, but optimized for a
Boolean condition rather than a decidable proposition. Unlike the non-dependent version cond
,
there is no special notation for dcond
.
Just like ite
, dite
, and cond
, dcond
is declared @[macro_inline]
, which causes
applications of dcond
to be unfolded. As a result, x
and y
are not evaluated at runtime until
one of them is selected, and only the selected branch is evaluated. dcond
is intended for
metaprogramming use, rather than for use in verified programs, so behavioral lemmas are not
provided.
Boolean “or”, also known as disjunction. or x y
can be written x || y
.
The corresponding propositional connective is Or : Prop → Prop → Prop
, written with the ∨
operator.
The Boolean or
is a @[macro_inline]
function in order to give it short-circuiting evaluation:
if x
is true
then y
is not evaluated at runtime.
Boolean “and”, also known as conjunction. and x y
can be written x && y
.
The corresponding propositional connective is And : Prop → Prop → Prop
, written with the ∧
operator.
The Boolean and
is a @[macro_inline]
function in order to give it short-circuiting evaluation:
if x
is false
then y
is not evaluated at runtime.
Conventions for notations in identifiers:
Boolean negation, also known as Boolean complement. not x
can be written !x
.
This is a function that maps the value true
to false
and the value false
to true
. The
propositional connective is Not : Prop → Prop
.
Conventions for notations in identifiers:
- The recommended spelling of
!
in identifiers isnot
.
The natural numbers, starting at zero.
This type is special-cased by both the kernel and the compiler, and overridden with an efficient
implementation. Both use a fast arbitrary-precision arithmetic library (usually
GMP); at runtime, Nat
values that are sufficiently small are unboxed.
- zero : Nat
Zero, the smallest natural number.
Using
Nat.zero
explicitly should usually be avoided in favor of the literal0
, which is the simp normal form. - succ
(n : Nat)
: Nat
The successor of a natural number
n
.Using
Nat.succ n
should usually be avoided in favor ofn + 1
, which is the simp normal form.
Instances For
- AddMonoid.toNatSMul
- Aesop.Nanos.instHDivNat
- Aesop.Percent.instHPowNat
- Aesop.instHAddSlotIndexNat
- Aesop.instHSubSlotIndexNat
- Array.instGetElem?NatLtSize
- Array.instGetElemNatLtSize
- Array.instLawfulGetElemNatLtSize
- Batteries.instLawfulOrdNat
- BitVec.instGetElemNatBoolLt
- BitVec.instHShiftLeftNat
- BitVec.instHShiftRightNat
- BitVec.instPowNat
- ByteArray.instGetElemNatUInt8LtSize
- Cardinal.canLiftCardinalNat
- Denumerable.nat
- ENat.canLift
- Equiv.Perm.instPowNat
- Fin.coeToNat
- Fin.instCanLiftNatValLt
- FloatArray.instGetElemNatFloatLtSize
- Int.instHShiftRightNat
- LO.FirstOrder.Arith.Standard.models_CobhamR0
- LO.FirstOrder.Arith.Standard.models_PeanoMinus
- LO.FirstOrder.Arith.Standard.models_iSigma
- LO.FirstOrder.Arith.Standard.models_iSigmaOne
- LO.FirstOrder.Arith.Standard.models_iSigmaZero
- LO.FirstOrder.Arith.Standard.models_peano
- LO.FirstOrder.Arith.Standard.models_trueArith
- LO.FirstOrder.Arith.instModelsTheoryNatConsistentₐOfConsistentSyntacticFormulaORingTheory
- LO.FirstOrder.Arith.instModelsTheoryNatHAddTheoryORingConsistentₐ
- LO.FirstOrder.Arith.instModelsTheoryNatHAddTheoryORingISigmaOfNatOmegaOne
- LO.FirstOrder.Semiterm.instCoeNat
- LO.FirstOrder.instSoundISigmaOfNatNatStandardDPOfWeakerThanSyntacticFormulaORingTheory
- Lake.instLawfulCmpEqNatCompare
- Lean.Compiler.LCNF.Simp.ConstantFold.instLiteralNat
- Lean.Json.instCoeNat
- Lean.JsonNumber.instCoeNat
- Lean.KVMap.instValueNat
- Lean.Meta.instReduceEvalNat
- Lean.PersistentArray.instGetElemNatLtSizeOfInhabited
- Lean.Syntax.instGetElemNatTrue
- Lean.instCoeNatDataValue
- Lean.instCoeNatLeanOptionValue
- Lean.instFromJsonNat
- Lean.instGetElemRArrayNatTrue
- Lean.instQuoteNatNumLitKind
- Lean.instToExprNat
- Lean.instToJsonNat
- List.Vector.instGetElemNatLt
- List.instGetElem?NatLtLength
- List.instGetElemNatLtLength
- List.instLawfulGetElemNatLtLength
- Mathlib.Tactic.Ring.instCSLiftPNatNat
- Monoid.toNatPow
- Nat.ModEq.instIsRefl
- Nat.Primes.coeNat
- Nat.canLiftPNat
- Nat.encodable
- Nat.instAddCancelCommMonoid
- Nat.instAddCommMonoid
- Nat.instAddCommMonoidWithOne
- Nat.instAddCommSemigroup
- Nat.instAddMonoid
- Nat.instAddMonoidWithOne
- Nat.instAddSemigroup
- Nat.instAndOp
- Nat.instCancelCommMonoidWithZero
- Nat.instCanonicallyOrderedAdd
- Nat.instCharZero
- Nat.instCommMonoid
- Nat.instCommMonoidWithZero
- Nat.instCommSemigroup
- Nat.instCommSemiring
- Nat.instDistrib
- Nat.instDiv
- Nat.instDvd
- Nat.instIsLeftCancelMulZero
- Nat.instIsOrderedAddMonoid
- Nat.instIsOrderedCancelAddMonoid
- Nat.instIsPredArchimedean
- Nat.instIsStrictOrderedRing
- Nat.instIsSuccArchimedean
- Nat.instLawfulBEq
- Nat.instLinearOrder
- Nat.instLinearOrderedCommMonoidWithZero
- Nat.instLocallyFiniteOrder
- Nat.instMax
- Nat.instMax_mathlib
- Nat.instMin_mathlib
- Nat.instMod
- Nat.instMonoid
- Nat.instMonoidWithZero
- Nat.instMulDivCancelClass
- Nat.instMulLeftMono
- Nat.instMulOneClass
- Nat.instMulZeroClass
- Nat.instMulZeroOneClass
- Nat.instNoMaxOrder
- Nat.instNonAssocSemiring
- Nat.instNonUnitalNonAssocSemiring
- Nat.instNonUnitalSemiring
- Nat.instNontrivial
- Nat.instOne
- Nat.instOrOp
- Nat.instOrd_mathlib
- Nat.instOrderBot
- Nat.instOrderedSub
- Nat.instPartialOrder
- Nat.instPredOrder
- Nat.instPredSubOrder
- Nat.instPreorder
- Nat.instSemigroup
- Nat.instSemigroupWithZero
- Nat.instSemiring
- Nat.instShiftLeft
- Nat.instShiftRight
- Nat.instSuccAddOrder
- Nat.instSuccOrder
- Nat.instXor
- Nonneg.nsmul
- Nonneg.pow
- OmegaCompletePartialOrder.Chain.instFunLikeNat
- OmegaCompletePartialOrder.Chain.instOrderHomClassNat
- Plausible.Nat.sampleableExt
- Plausible.Nat.shrinkable
- Plausible.Random.instBoundedRandomNat
- Positive.instPowSubtypeLtOfNatNat_mathlib
- Rat.instPowNat
- Std.Internal.Parsec.ByteArray.instInputIteratorUInt8Nat
- Std.Nat.instLawfulEqOrdNat
- Std.Nat.instTransOrdNat
- Std.Range.instForIn'NatInferInstanceMembership
- Std.Range.instForMNat
- Std.Tactic.BVDecide.LRAT.Internal.instCoeOutPosFinNat
- Std.instMembershipNatRange
- Subarray.instGetElemNatLtSize
- Vector.instGetElemNatLt
- WithZero.pow
- coePNatNat
- instAddNat
- instCanLiftIntNatCastLeOfNat
- instCoeHTCTNatOfNatCast
- instCoeTailNatOfNatCast
- instCountableNat
- instDistribLatticeNat
- instHModUInt16Nat
- instHModUInt32Nat
- instHModUInt64Nat
- instHModUInt8Nat
- instHModUSizeNat
- instHashableNat
- instInfiniteNat
- instInhabitedNat
- instLENat
- instLTNat
- instMinNat
- instMulNat
- instNatCastNat
- instNatPowNat
- instOfNatNat
- instOrdNat
- instPowISizeNat
- instPowInt16Nat
- instPowInt32Nat
- instPowInt64Nat
- instPowInt8Nat
- instPowNat
- instPowUInt16Nat
- instPowUInt32Nat
- instPowUInt64Nat
- instPowUInt8Nat
- instPowUSizeNat
- instReprAtomNat
- instReprNat
- instSizeOfNat
- instStreamRangeNat
- instSubNat
- instToStringNat
- instWellFoundedLTNat
The class OfNat α n
powers the numeric literal parser. If you write
37 : α
, Lean will attempt to synthesize OfNat α 37
, and will generate
the term (OfNat.ofNat 37 : α)
.
There is a bit of infinite regress here since the desugaring apparently
still contains a literal 37
in it. The type of expressions contains a
primitive constructor for "raw natural number literals", which you can directly
access using the macro nat_lit 37
. Raw number literals are always of type Nat
.
So it would be more correct to say that Lean looks for an instance of
OfNat α (nat_lit 37)
, and it generates the term (OfNat.ofNat (nat_lit 37) : α)
.
- ofNat : α
The
OfNat.ofNat
function is automatically inserted by the parser when the user writes a numeric literal like1 : α
. Implementations of this typeclass can therefore customize the behavior ofn : α
based onn
andα
.
Instances
- Aesop.Nanos.instOfNat
- BitVec.instOfNat
- Fin.instOfNat
- ISize.instOfNat
- Id.instOfNat
- Int16.instOfNat
- Int32.instOfNat
- Int64.instOfNat
- Int8.instOfNat
- LO.FirstOrder.Arith.Countermodel.OmegaAddOne.instOfNat
- Lake.MTime.instOfNat
- Lake.Toml.Time.instOfNat
- Lake.instOfNatPos
- Lean.Json.instOfNat
- Lean.JsonNumber.instOfNat
- Lean.JsonRpc.instOfNatRequestID
- Lean.Level.instOfNat
- One.toOfNat1
- Pi.instOfNat
- Rat.instOfNat
- Std.Internal.Rat.instOfNat
- Std.Time.Day.Ordinal.instOfNatOfYear
- Std.Time.Day.instOfNatOffset
- Std.Time.Day.instOfNatOrdinal
- Std.Time.Hour.instOfNatOffset
- Std.Time.Hour.instOfNatOrdinal
- Std.Time.Internal.Bounded.LE.instOfNatHAddIntCast
- Std.Time.Internal.UnitVal.instOfNat
- Std.Time.Millisecond.instOfNatOffset
- Std.Time.Millisecond.instOfNatOrdinal
- Std.Time.Minute.instOfNatOffset
- Std.Time.Minute.instOfNatOrdinal
- Std.Time.Month.instOfNatOffset
- Std.Time.Month.instOfNatOrdinal
- Std.Time.Month.instOfNatQuarter
- Std.Time.Nanosecond.instOfNatOffset
- Std.Time.Nanosecond.instOfNatOrdinal
- Std.Time.Second.instOfNatOffset
- Std.Time.Second.instOfNatOrdinal
- Std.Time.Week.Ordinal.instOfNatOfMonth
- Std.Time.Week.instOfNatOffset
- Std.Time.Week.instOfNatOrdinal
- Std.Time.Weekday.instOfNatOrdinal
- Std.Time.Year.instOfNatOffset
- Std.Time.instOfNatDuration
- Std.Time.instOfNatTimestamp
- String.instOfNatPos
- UInt16.instOfNat
- UInt32.instOfNat
- UInt64.instOfNat
- UInt8.instOfNat
- USize.instOfNat
- Zero.toOfNat0
- instOfNat
- instOfNatAtLeastTwo
- instOfNatFloat
- instOfNatFloat32
- instOfNatNat
- instOfNatPNatOfNeZeroNat
Equations
- instOfNatNat n = { ofNat := n }
LE α
is the typeclass which supports the notation x ≤ y
where x y : α
.
- le : α → α → Prop
Instances
- Aesop.Iteration.instLE
- Aesop.Nanos.instLE
- Aesop.Percent.instLE
- Aesop.instLELevelIndex
- Aesop.instLENormRuleInfo
- Aesop.instLEPremiseIndex
- Aesop.instLESafeRuleInfo
- Aesop.instLESlotIndex
- Aesop.instLEUnsafeRuleInfo
- Array.instLE
- Bool.instLE
- BotHom.instLE
- Cardinal.instLE
- Char.instLE
- Finset.Colex.instLE
- IO.FS.instLESystemTime
- IO.instLETaskState
- Int.instLEInt
- LO.Entailment.LindenbaumAlgebra.instLEOfDecidableEq
- Lake.Date.instLE
- Lake.MTime.instLE
- Lake.instLEBuildType
- Lake.instLEJobAction
- Lake.instLELogLevel
- Lake.instLEPos
- Lake.instLESemVerCore
- Lake.instLEStdVer
- Lake.instLEToolchainVer
- Lake.instLEVerbosity
- Lean.Compiler.LCNF.instLEPhase
- Lean.Lsp.instLEPosition
- Lean.Lsp.instLERange
- List.LE'
- List.instLE
- OmegaCompletePartialOrder.Chain.instLE
- OrderDual.instLE
- Pi.hasLe
- Prod.instLE_mathlib
- Prop.le
- Rat.instLE
- Set.instLE
- Setoid.instLE_mathlib
- Std.Internal.Rat.instLE
- Std.Time.Day.instOffsetLE
- Std.Time.Day.instOrdinalLE
- Std.Time.Duration.instLE
- Std.Time.Hour.instOffsetLE
- Std.Time.Hour.instOrdinalLE
- Std.Time.Internal.Bounded.instLE
- Std.Time.Internal.UnitVal.instLE
- Std.Time.Internal.instLEUnitVal
- Std.Time.Millisecond.instOffsetLE
- Std.Time.Millisecond.instOrdinalLE
- Std.Time.Minute.instOffsetLE
- Std.Time.Minute.instOrdinalLE
- Std.Time.Month.instOffsetLE
- Std.Time.Month.instOrdinalLE
- Std.Time.Month.instQuarterLE
- Std.Time.Nanosecond.Ordinal.instOfDayLE
- Std.Time.Nanosecond.instOffsetLE
- Std.Time.Nanosecond.instOrdinalLE
- Std.Time.Nanosecond.instSpanLE
- Std.Time.Second.instLEOrdinal
- Std.Time.Second.instOffsetLE
- Std.Time.Week.instOffsetLE
- Std.Time.Week.instOrdinalLE
- Std.Time.Weekday.instOrdinalLE
- Std.Time.Year.instOffsetLE
- Std.Time.instLETimestamp
- String.instLE
- Subtype.le
- Sum.Lex.LE
- Sum.instLESum
- TopHom.instLE
- ULift.instLE_mathlib
- Vector.instLE
- WithBot.le
- WithTop.le
- instLEAdditive
- instLEBitVec
- instLEFin
- instLEFloat
- instLEFloat32
- instLEISize
- instLEInt16
- instLEInt32
- instLEInt64
- instLEInt8
- instLEMultiplicative
- instLENat
- instLEOption
- instLEPos
- instLEUInt16
- instLEUInt32
- instLEUInt32_1
- instLEUInt64
- instLEUInt8
- instLEUSize
LT α
is the typeclass which supports the notation x < y
where x y : α
.
- lt : α → α → Prop
The less-than relation:
x < y
Conventions for notations in identifiers:
- The recommended spelling of
<
in identifiers islt
.
- The recommended spelling of
Instances
- Aesop.GoalId.instLT
- Aesop.IndexMatchResult.instLTOfOrd
- Aesop.Iteration.instLT
- Aesop.Nanos.instLT
- Aesop.Percent.instLT
- Aesop.RappId.instLT
- Aesop.instLTLevelIndex
- Aesop.instLTNormRuleInfo
- Aesop.instLTPremiseIndex
- Aesop.instLTSafeRuleInfo
- Aesop.instLTSlotIndex
- Aesop.instLTUnsafeRuleInfo
- Array.instLT
- Bool.instLT
- Char.instLT
- IO.FS.instLTSystemTime
- IO.instLTTaskState
- Int.instLTInt
- LO.FirstOrder.ModelOfSatEq.instLTOfLT
- LO.FirstOrder.Structure.Model.instLTOfLT
- Lake.Date.instLT
- Lake.MTime.instLT
- Lake.instLTBuildType
- Lake.instLTJobAction
- Lake.instLTLogLevel
- Lake.instLTPos
- Lake.instLTSemVerCore
- Lake.instLTStdVer
- Lake.instLTToolchainVer
- Lake.instLTVerbosity
- Lean.Compiler.LCNF.instLTPhase
- Lean.JsonNumber.instLT
- Lean.JsonRpc.instLTRequestID
- Lean.Lsp.instLTPosition
- Lean.Lsp.instLTRange
- Lean.Meta.DiscrTree.instLTKey
- Lean.Meta.instLTOrigin
- Lean.instLTLiteral
- List.instLT
- OrderDual.instLT
- Rat.instLT
- Std.Internal.Rat.instLT
- Std.Time.Day.instOffsetLT
- Std.Time.Day.instOrdinalLT
- Std.Time.Hour.instOffsetLT
- Std.Time.Hour.instOrdinalLT
- Std.Time.Internal.Bounded.instLT
- Std.Time.Internal.UnitVal.instLT
- Std.Time.Millisecond.instOffsetLT
- Std.Time.Millisecond.instOrdinalLT
- Std.Time.Minute.instOffsetLT
- Std.Time.Minute.instOrdinalLT
- Std.Time.Month.instOffsetLT
- Std.Time.Month.instOrdinalLT
- Std.Time.Month.instQuarterLT
- Std.Time.Nanosecond.Ordinal.instOfDayLT
- Std.Time.Nanosecond.instOffsetLT
- Std.Time.Nanosecond.instOrdinalLT
- Std.Time.Nanosecond.instSpanLT
- Std.Time.Second.instLTOrdinal
- Std.Time.Second.instOffsetLT
- Std.Time.Week.instOffsetLT
- Std.Time.Week.instOrdinalLT
- Std.Time.Weekday.instOrdinalLT
- Std.Time.Year.instOffsetLT
- String.instLT
- Subtype.lt
- Sum.Lex.LT
- Sum.instLTSum
- ULift.instLT_mathlib
- Vector.instLT
- WithBot.lt
- WithTop.lt
- instLTAdditive
- instLTBitVec
- instLTFin
- instLTFloat
- instLTFloat32
- instLTISize
- instLTInt16
- instLTInt32
- instLTInt64
- instLTInt8
- instLTMultiplicative
- instLTNat
- instLTOption
- instLTPos
- instLTUInt16
- instLTUInt32
- instLTUInt32_1
- instLTUInt64
- instLTUInt8
- instLTUSize
a ≥ b
is an abbreviation for b ≤ a
.
Conventions for notations in identifiers:
a > b
is an abbreviation for b < a
.
Conventions for notations in identifiers:
- The recommended spelling of
>
in identifiers isgt
.
An overloaded operation to find the greater of two values of type α
.
- max : α → α → α
Returns the greater of its two arguments.
Instances
- Bool.instMax
- BotHom.instMax
- Complementeds.instMax
- Filter.instSup
- IO.instMaxTaskState
- Int.instMax
- LO.Entailment.LindenbaumAlgebra.instMaxOfDecidableEq
- Lake.Date.instMax
- Lake.MTime.instMax
- Lake.instMaxBuildType
- Lake.instMaxJobAction
- Lake.instMaxLogLevel
- Lake.instMaxPos
- Lake.instMaxSemVerCore
- Lake.instMaxStdVer
- Lake.instMaxVerbosity
- LowerSet.instMax
- Nat.instMax
- Nat.instMax_mathlib
- Option.instMax
- OrderDual.instSup
- OrderHom.instMax
- Pi.instMaxForall_mathlib
- Prod.instMax_mathlib
- Rat.instSup
- SemilatticeSup.toMax
- SupBotHom.instMax
- SupHom.instMax
- TopHom.instMax
- ULift.instMax_mathlib
- UpperSet.instMax
- instMaxFloat
- instMaxFloat32
- instMaxISize
- instMaxInt16
- instMaxInt32
- instMaxInt64
- instMaxInt8
- instMaxPos
- instMaxUInt16
- instMaxUInt32
- instMaxUInt64
- instMaxUInt8
- instMaxUSize
An overloaded operation to find the lesser of two values of type α
.
- min : α → α → α
Returns the lesser of its two arguments.
Instances
- Bool.instMin
- BotHom.instMin
- Complementeds.instMin
- Filter.instInf
- IO.instMinTaskState
- InfHom.instMin
- InfTopHom.instMin
- Int.instMin
- LO.Entailment.LindenbaumAlgebra.instMinOfDecidableEq
- Lake.Date.instMin
- Lake.MTime.instMin
- Lake.instMinBuildType
- Lake.instMinJobAction
- Lake.instMinLogLevel
- Lake.instMinPos
- Lake.instMinSemVerCore
- Lake.instMinStdVer
- Lake.instMinVerbosity
- LowerSet.instMin
- Nat.instMin_mathlib
- Option.instMin
- OrderDual.instInf
- OrderHom.instMin
- Pi.instMinForall_mathlib
- Prod.instMin_mathlib
- Rat.instInf
- SemilatticeInf.toMin
- Setoid.instMin_mathlib
- TopHom.instMin
- ULift.instMin_mathlib
- UpperSet.instMin
- instMinFloat
- instMinFloat32
- instMinISize
- instMinInt16
- instMinInt32
- instMinInt64
- instMinInt8
- instMinNat
- instMinPos
- instMinUInt16
- instMinUInt32
- instMinUInt64
- instMinUInt8
- instMinUSize
Transitive chaining of proofs, used e.g. by calc
.
It takes two relations r
and s
as "input", and produces an "output"
relation t
, with the property that r a b
and s b c
implies t a c
.
The calc
tactic uses this so that when it sees a chain with a ≤ b
and b < c
it knows that this should be a proof of a < c
because there is an instance
Trans (·≤·) (·<·) (·<·)
.
- trans {a : α} {b : β} {c : γ} : r a b → s b c → t a c
Compose two proofs by transitivity, generalized over the relations involved.
Instances
- Array.instTransLeOfDecidableEqOfDecidableLTOfIrreflOfAsymmOfAntisymmOfNotLt
- Array.instTransLt
- Array.instTransPerm
- Char.leTrans
- Char.ltTrans
- Equiv.instTrans
- Filter.instTransForallEventuallyEq
- Filter.instTransForallEventuallyEqEventuallyLE
- Filter.instTransForallEventuallyLE
- Filter.instTransForallEventuallyLEEventuallyEq
- Filter.instTransSetMemSubset
- Filter.instTransSetSupersetMem
- Function.Embedding.instTrans
- Int.instTransLe
- Int.instTransLeLt
- Int.instTransLt
- Int.instTransLtLe
- List.instTransLeOfDecidableEqOfDecidableLTOfIrreflOfAsymmOfAntisymmOfNotLt
- List.instTransLt
- List.instTransPerm
- List.instTransSublist
- List.instTransSublistMem
- List.instTransSublistSubset
- List.instTransSubset
- List.instTransSubsetMem
- List.instTransSubsetSublist
- Nat.ModEq.instTrans
- Nat.instTransLe
- Nat.instTransLeLt
- Nat.instTransLt
- Nat.instTransLtLe
- Relation.TransGen.instTransReflTransGen
- Relation.TransGen.instTransReflTransGen_1
- Relation.TransGen.instTrans_mathlib
- Set.instTransSSubset
- Set.instTransSSubsetSubset
- Set.instTransSubset
- Set.instTransSubsetSSubset
- Std.DHashMap.Equiv.instTrans
- Std.DHashMap.Raw.Equiv.instTrans
- Std.HashMap.Equiv.instTrans
- Std.HashMap.Raw.Equiv.instTrans
- Std.HashSet.Equiv.instTrans
- Std.HashSet.Raw.Equiv.instTrans
- String.leTrans
- Vector.instTransLeOfDecidableEqOfDecidableLTOfIrreflOfAsymmOfAntisymmOfNotLt
- Vector.instTransLt
- Vector.instTransPerm
- instTransAntisymmRelLe
- instTransAntisymmRelLeLt
- instTransEq
- instTransEq_1
- instTransGeGt_mathlib
- instTransGe_mathlib
- instTransGtGe_mathlib
- instTransGt_mathlib
- instTransIff
- instTransLeAntisymmRel
- instTransLeLt_mathlib
- instTransLe_mathlib
- instTransLtAntisymmRelLe
- instTransLtLe_mathlib
- instTransLt_mathlib
- instTransOfIsTrans
The notation typeclass for heterogeneous addition.
This enables the notation a + b : γ
where a : α
, b : β
.
- hAdd : α → β → γ
a + b
computes the sum ofa
andb
. The meaning of this notation is type-dependent.Conventions for notations in identifiers:
- The recommended spelling of
+
in identifiers isadd
.
- The recommended spelling of
Instances
- Aesop.instHAddSlotIndexNat
- Std.Time.DateTime.instHAddDuration
- Std.Time.DateTime.instHAddOffset
- Std.Time.DateTime.instHAddOffset_1
- Std.Time.DateTime.instHAddOffset_2
- Std.Time.DateTime.instHAddOffset_3
- Std.Time.DateTime.instHAddOffset_4
- Std.Time.DateTime.instHAddOffset_5
- Std.Time.DateTime.instHAddOffset_6
- Std.Time.Duration.instHAdd
- Std.Time.Duration.instHAddOffset
- Std.Time.Duration.instHAddOffset_1
- Std.Time.Duration.instHAddOffset_2
- Std.Time.Duration.instHAddOffset_3
- Std.Time.Duration.instHAddOffset_4
- Std.Time.Duration.instHAddOffset_5
- Std.Time.Duration.instHAddOffset_6
- Std.Time.Duration.instHAddPlainTime
- Std.Time.PlainDate.instHAddOffset
- Std.Time.PlainDate.instHAddOffset_1
- Std.Time.PlainDateTime.instHAddDuration
- Std.Time.PlainDateTime.instHAddOffset
- Std.Time.PlainDateTime.instHAddOffset_1
- Std.Time.PlainDateTime.instHAddOffset_2
- Std.Time.PlainDateTime.instHAddOffset_3
- Std.Time.PlainDateTime.instHAddOffset_4
- Std.Time.PlainDateTime.instHAddOffset_5
- Std.Time.PlainDateTime.instHAddOffset_6
- Std.Time.PlainTime.instHAddOffset
- Std.Time.PlainTime.instHAddOffset_1
- Std.Time.PlainTime.instHAddOffset_2
- Std.Time.PlainTime.instHAddOffset_3
- Std.Time.PlainTime.instHAddOffset_4
- Std.Time.Timestamp.instHAddDuration
- Std.Time.Timestamp.instHAddOffset
- Std.Time.Timestamp.instHAddOffset_1
- Std.Time.Timestamp.instHAddOffset_2
- Std.Time.Timestamp.instHAddOffset_3
- Std.Time.Timestamp.instHAddOffset_4
- Std.Time.Timestamp.instHAddOffset_5
- Std.Time.Timestamp.instHAddOffset_6
- Std.Time.ZonedDateTime.instHAddDuration
- Std.Time.ZonedDateTime.instHAddOffset
- Std.Time.ZonedDateTime.instHAddOffset_1
- Std.Time.ZonedDateTime.instHAddOffset_2
- Std.Time.ZonedDateTime.instHAddOffset_3
- Std.Time.ZonedDateTime.instHAddOffset_4
- Std.Time.ZonedDateTime.instHAddOffset_5
- Std.Time.ZonedDateTime.instHAddOffset_6
- Std.Time.instHAddOffset
- Std.Time.instHAddOffsetOffset
- Std.Time.instHAddOffsetOffset_1
- Std.Time.instHAddOffsetOffset_10
- Std.Time.instHAddOffsetOffset_11
- Std.Time.instHAddOffsetOffset_12
- Std.Time.instHAddOffsetOffset_13
- Std.Time.instHAddOffsetOffset_14
- Std.Time.instHAddOffsetOffset_15
- Std.Time.instHAddOffsetOffset_16
- Std.Time.instHAddOffsetOffset_17
- Std.Time.instHAddOffsetOffset_18
- Std.Time.instHAddOffsetOffset_19
- Std.Time.instHAddOffsetOffset_2
- Std.Time.instHAddOffsetOffset_20
- Std.Time.instHAddOffsetOffset_21
- Std.Time.instHAddOffsetOffset_22
- Std.Time.instHAddOffsetOffset_23
- Std.Time.instHAddOffsetOffset_24
- Std.Time.instHAddOffsetOffset_25
- Std.Time.instHAddOffsetOffset_26
- Std.Time.instHAddOffsetOffset_27
- Std.Time.instHAddOffsetOffset_28
- Std.Time.instHAddOffsetOffset_29
- Std.Time.instHAddOffsetOffset_3
- Std.Time.instHAddOffsetOffset_30
- Std.Time.instHAddOffsetOffset_31
- Std.Time.instHAddOffsetOffset_32
- Std.Time.instHAddOffsetOffset_33
- Std.Time.instHAddOffsetOffset_34
- Std.Time.instHAddOffsetOffset_35
- Std.Time.instHAddOffsetOffset_36
- Std.Time.instHAddOffsetOffset_37
- Std.Time.instHAddOffsetOffset_38
- Std.Time.instHAddOffsetOffset_39
- Std.Time.instHAddOffsetOffset_4
- Std.Time.instHAddOffsetOffset_40
- Std.Time.instHAddOffsetOffset_41
- Std.Time.instHAddOffsetOffset_5
- Std.Time.instHAddOffsetOffset_6
- Std.Time.instHAddOffsetOffset_7
- Std.Time.instHAddOffsetOffset_8
- Std.Time.instHAddOffsetOffset_9
- Std.Time.instHAddOffset_1
- Std.Time.instHAddOffset_2
- Std.Time.instHAddOffset_3
- Std.Time.instHAddOffset_4
- Std.Time.instHAddOffset_5
- Std.Time.instHAddOffset_6
- instHAdd
- instHAddPos
- instHAddPosChar
- instHAddPosString
The notation typeclass for heterogeneous subtraction.
This enables the notation a - b : γ
where a : α
, b : β
.
- hSub : α → β → γ
a - b
computes the difference ofa
andb
. The meaning of this notation is type-dependent.- For natural numbers, this operator saturates at 0:
a - b = 0
whena ≤ b
.
Conventions for notations in identifiers:
- The recommended spelling of
-
in identifiers issub
(when used as a binary operator).
- For natural numbers, this operator saturates at 0:
Instances
- Aesop.instHSubSlotIndexNat
- Std.Time.DateTime.instHSubDuration
- Std.Time.DateTime.instHSubDuration_1
- Std.Time.DateTime.instHSubOffset
- Std.Time.DateTime.instHSubOffset_1
- Std.Time.DateTime.instHSubOffset_2
- Std.Time.DateTime.instHSubOffset_3
- Std.Time.DateTime.instHSubOffset_4
- Std.Time.DateTime.instHSubOffset_5
- Std.Time.DateTime.instHSubOffset_6
- Std.Time.Duration.instHSub
- Std.Time.Duration.instHSubOffset
- Std.Time.Duration.instHSubOffset_1
- Std.Time.Duration.instHSubOffset_2
- Std.Time.Duration.instHSubOffset_3
- Std.Time.Duration.instHSubOffset_4
- Std.Time.Duration.instHSubOffset_5
- Std.Time.Duration.instHSubOffset_6
- Std.Time.Duration.instHSubPlainTime
- Std.Time.PlainDate.instHSubDuration
- Std.Time.PlainDate.instHSubOffset
- Std.Time.PlainDate.instHSubOffset_1
- Std.Time.PlainDateTime.instHSubDuration
- Std.Time.PlainDateTime.instHSubOffset
- Std.Time.PlainDateTime.instHSubOffset_1
- Std.Time.PlainDateTime.instHSubOffset_2
- Std.Time.PlainDateTime.instHSubOffset_3
- Std.Time.PlainDateTime.instHSubOffset_4
- Std.Time.PlainDateTime.instHSubOffset_5
- Std.Time.PlainDateTime.instHSubOffset_6
- Std.Time.PlainTime.instHSubOffset
- Std.Time.PlainTime.instHSubOffset_1
- Std.Time.PlainTime.instHSubOffset_2
- Std.Time.PlainTime.instHSubOffset_3
- Std.Time.PlainTime.instHSubOffset_4
- Std.Time.Timestamp.instHSubDuration
- Std.Time.Timestamp.instHSubDuration_1
- Std.Time.Timestamp.instHSubOffset
- Std.Time.Timestamp.instHSubOffset_1
- Std.Time.Timestamp.instHSubOffset_2
- Std.Time.Timestamp.instHSubOffset_3
- Std.Time.Timestamp.instHSubOffset_4
- Std.Time.Timestamp.instHSubOffset_5
- Std.Time.Timestamp.instHSubOffset_6
- Std.Time.ZonedDateTime.instHSubDuration
- Std.Time.ZonedDateTime.instHSubDuration_1
- Std.Time.ZonedDateTime.instHSubOffset
- Std.Time.ZonedDateTime.instHSubOffset_1
- Std.Time.ZonedDateTime.instHSubOffset_2
- Std.Time.ZonedDateTime.instHSubOffset_3
- Std.Time.ZonedDateTime.instHSubOffset_4
- Std.Time.ZonedDateTime.instHSubOffset_5
- Std.Time.ZonedDateTime.instHSubOffset_6
- Std.Time.instHSubOffset
- Std.Time.instHSubOffsetOffset
- Std.Time.instHSubOffsetOffset_1
- Std.Time.instHSubOffsetOffset_10
- Std.Time.instHSubOffsetOffset_11
- Std.Time.instHSubOffsetOffset_12
- Std.Time.instHSubOffsetOffset_13
- Std.Time.instHSubOffsetOffset_14
- Std.Time.instHSubOffsetOffset_15
- Std.Time.instHSubOffsetOffset_16
- Std.Time.instHSubOffsetOffset_17
- Std.Time.instHSubOffsetOffset_18
- Std.Time.instHSubOffsetOffset_19
- Std.Time.instHSubOffsetOffset_2
- Std.Time.instHSubOffsetOffset_20
- Std.Time.instHSubOffsetOffset_21
- Std.Time.instHSubOffsetOffset_22
- Std.Time.instHSubOffsetOffset_23
- Std.Time.instHSubOffsetOffset_24
- Std.Time.instHSubOffsetOffset_25
- Std.Time.instHSubOffsetOffset_26
- Std.Time.instHSubOffsetOffset_27
- Std.Time.instHSubOffsetOffset_28
- Std.Time.instHSubOffsetOffset_29
- Std.Time.instHSubOffsetOffset_3
- Std.Time.instHSubOffsetOffset_30
- Std.Time.instHSubOffsetOffset_31
- Std.Time.instHSubOffsetOffset_32
- Std.Time.instHSubOffsetOffset_33
- Std.Time.instHSubOffsetOffset_34
- Std.Time.instHSubOffsetOffset_35
- Std.Time.instHSubOffsetOffset_36
- Std.Time.instHSubOffsetOffset_37
- Std.Time.instHSubOffsetOffset_38
- Std.Time.instHSubOffsetOffset_39
- Std.Time.instHSubOffsetOffset_4
- Std.Time.instHSubOffsetOffset_40
- Std.Time.instHSubOffsetOffset_41
- Std.Time.instHSubOffsetOffset_5
- Std.Time.instHSubOffsetOffset_6
- Std.Time.instHSubOffsetOffset_7
- Std.Time.instHSubOffsetOffset_8
- Std.Time.instHSubOffsetOffset_9
- Std.Time.instHSubOffset_1
- Std.Time.instHSubOffset_2
- Std.Time.instHSubOffset_3
- Std.Time.instHSubOffset_4
- Std.Time.instHSubOffset_5
- Std.Time.instHSubOffset_6
- instHSub
- instHSubPos
The notation typeclass for heterogeneous multiplication.
This enables the notation a * b : γ
where a : α
, b : β
.
- hMul : α → β → γ
a * b
computes the product ofa
andb
. The meaning of this notation is type-dependent.Conventions for notations in identifiers:
- The recommended spelling of
*
in identifiers ismul
.
- The recommended spelling of
The notation typeclass for heterogeneous division.
This enables the notation a / b : γ
where a : α
, b : β
.
- hDiv : α → β → γ
a / b
computes the result of dividinga
byb
. The meaning of this notation is type-dependent.- For most types like
Nat
,Int
,Rat
,Real
,a / 0
is defined to be0
. - For
Nat
,a / b
rounds downwards. - For
Int
,a / b
rounds downwards ifb
is positive or upwards ifb
is negative. It is implemented asInt.ediv
, the unique function satisfyinga % b + b * (a / b) = a
and0 ≤ a % b < natAbs b
forb ≠ 0
. Other rounding conventions are available using the functionsInt.fdiv
(floor rounding) andInt.tdiv
(truncation rounding). - For
Float
,a / 0
follows the IEEE 754 semantics for division, usually resulting ininf
ornan
.
Conventions for notations in identifiers:
- The recommended spelling of
/
in identifiers isdiv
.
- For most types like
The notation typeclass for heterogeneous modulo / remainder.
This enables the notation a % b : γ
where a : α
, b : β
.
- hMod : α → β → γ
The notation typeclass for heterogeneous exponentiation.
This enables the notation a ^ b : γ
where a : α
, b : β
.
- hPow : α → β → γ
a ^ b
computesa
to the power ofb
. The meaning of this notation is type-dependent.Conventions for notations in identifiers:
- The recommended spelling of
^
in identifiers ispow
.
- The recommended spelling of
Instances
The notation typeclass for heterogeneous append.
This enables the notation a ++ b : γ
where a : α
, b : β
.
- hAppend : α → β → γ
a ++ b
is the result of concatenation ofa
andb
, usually read "append". The meaning of this notation is type-dependent.Conventions for notations in identifiers:
- The recommended spelling of
++
in identifiers isappend
.
- The recommended spelling of
The typeclass behind the notation a <|> b : γ
where a : α
, b : β
.
Because b
is "lazy" in this notation, it is passed as Unit → β
to the
implementation so it can decide when to evaluate it.
- hOrElse : α → (Unit → β) → γ
a <|> b
executesa
and returns the result, unless it fails in which case it executes and returnsb
. Becauseb
is not always executed, it is passed as a thunk so it can be forced only when needed. The meaning of this notation is type-dependent.Conventions for notations in identifiers:
- The recommended spelling of
<|>
in identifiers isorElse
.
- The recommended spelling of
Instances
The typeclass behind the notation a >> b : γ
where a : α
, b : β
.
Because b
is "lazy" in this notation, it is passed as Unit → β
to the
implementation so it can decide when to evaluate it.
- hAndThen : α → (Unit → β) → γ
a >> b
executesa
, ignores the result, and then executesb
. Ifa
fails thenb
is not executed. Becauseb
is not always executed, it is passed as a thunk so it can be forced only when needed. The meaning of this notation is type-dependent.Conventions for notations in identifiers:
- The recommended spelling of
>>
in identifiers isandThen
.
- The recommended spelling of
Instances
The typeclass behind the notation a &&& b : γ
where a : α
, b : β
.
- hAnd : α → β → γ
a &&& b
computes the bitwise AND ofa
andb
. The meaning of this notation is type-dependent.Conventions for notations in identifiers:
- The recommended spelling of
&&&
in identifiers isand
.
- The recommended spelling of
Instances
The typeclass behind the notation a ^^^ b : γ
where a : α
, b : β
.
- hXor : α → β → γ
a ^^^ b
computes the bitwise XOR ofa
andb
. The meaning of this notation is type-dependent.Conventions for notations in identifiers:
- The recommended spelling of
^^^
in identifiers isxor
.
- The recommended spelling of
Instances
The typeclass behind the notation a ||| b : γ
where a : α
, b : β
.
- hOr : α → β → γ
a ||| b
computes the bitwise OR ofa
andb
. The meaning of this notation is type-dependent.Conventions for notations in identifiers:
- The recommended spelling of
|||
in identifiers isor
.
- The recommended spelling of
Instances
The typeclass behind the notation a <<< b : γ
where a : α
, b : β
.
- hShiftLeft : α → β → γ
a <<< b
computesa
shifted to the left byb
places. The meaning of this notation is type-dependent.- On
Nat
, this is equivalent toa * 2 ^ b
. - On
UInt8
and other fixed width unsigned types, this is the same but truncated to the bit width.
Conventions for notations in identifiers:
- The recommended spelling of
<<<
in identifiers isshiftLeft
.
- On
The typeclass behind the notation a >>> b : γ
where a : α
, b : β
.
- hShiftRight : α → β → γ
a >>> b
computesa
shifted to the right byb
places. The meaning of this notation is type-dependent.Conventions for notations in identifiers:
- The recommended spelling of
>>>
in identifiers isshiftRight
.
- The recommended spelling of
A type with a zero element.
- zero : α
The zero element of the type.
Instances
- AddOpposite.instZero
- AddUnits.instZero
- Associates.instZero
- Cardinal.instZero
- LO.FirstOrder.ModelOfSatEq.instZeroOfZero
- LO.FirstOrder.Structure.Model.instZeroOfZero
- MulOpposite.instZero
- Multiset.instZero
- NonUnitalRingHom.instZero
- Nonneg.zero
- OrderAddMonoidHom.instZero
- Part.instZero
- Pi.instZero
- Prod.instZero
- Sym.instZeroSym
- WithBot.zero
- WithTop.zero
- WithZero.instZero
- Zero.ofOfNat0
- instENatZero
- instZeroAddHom
- instZeroAddMonoidHom
- instZeroAdditiveOfOne
- instZeroLex
- instZeroOrderDual
- instZeroZeroHom
A type with a "one" element.
- one : α
The "one" element of the type.
Instances
- AddMonoid.End.instOne
- AddOpposite.instOne
- Associates.instOne
- Cardinal.instOne
- Equiv.Perm.instOne
- LO.FirstOrder.ModelOfSatEq.instOneOfOne
- LO.FirstOrder.Structure.Model.instOneOfOne
- Monoid.End.instOne
- MulOpposite.instOne
- Nat.instOne
- Nonneg.one
- One.ofOfNat1
- OrderMonoidHom.instOne
- Part.instOne
- Pi.instOne
- Positive.instOneSubtypeLtOfNat_mathlib
- Prod.instOne
- RingHom.instOne
- Units.instOne
- WithBot.one
- WithOne.instOne
- WithTop.one
- WithZero.one
- instOneLex
- instOneMonoidHom
- instOneMulHom
- instOneMultiplicativeOfZero
- instOneOneHom
- instOneOrderDual
- instOnePNat
The homogeneous version of HAdd
: a + b : α
where a b : α
.
- add : α → α → α
a + b
computes the sum ofa
andb
. SeeHAdd
.
Instances
- AddHom.instAdd
- AddMonoidHom.add
- AddOpposite.instAdd
- AddUnits.instAdd
- Additive.add
- Aesop.Nanos.instAdd
- BitVec.instAdd
- Cardinal.instAdd
- Fin.instAdd
- Int.instAdd
- LO.Arith.Formalized.instAddSemitermLOR
- LO.FirstOrder.Language.instAdd
- LO.FirstOrder.ModelOfSatEq.instAddOfAdd
- LO.FirstOrder.Structure.Model.instAddOfAdd
- LO.FirstOrder.Theory.instAdd
- LO.FirstOrder.Theoryᵢ.instAdd
- LO.Modal.QuasiNormalExtension.instAdd
- Lean.Firefox.instAddMilliseconds
- Lean.Omega.IntList.instAdd
- Lean.Omega.LinearCombo.instAdd
- MulOpposite.instAdd
- Multiset.instAdd
- Nonneg.add
- OrderAddMonoidHom.instAddOfIsOrderedAddMonoid
- Part.instAdd
- Pi.instAdd
- Positive.instAddSubtypeLtOfNat_mathlib
- Prod.instAdd
- Rat.instAdd
- Std.Internal.Rat.instAdd
- Std.Time.Day.instOffsetAdd
- Std.Time.Hour.instOffsetAdd
- Std.Time.Internal.UnitVal.instAdd
- Std.Time.Millisecond.instOffsetAdd
- Std.Time.Minute.instOffsetAdd
- Std.Time.Month.instOffsetAdd
- Std.Time.Nanosecond.instOffsetAdd
- Std.Time.Second.instOffsetAdd
- Std.Time.Week.instOffsetAdd
- Std.Time.Year.instOffsetAdd
- WithBot.add
- WithTop.add
- WithZero.instAdd
- instAddFloat
- instAddFloat32
- instAddISize
- instAddInt16
- instAddInt32
- instAddInt64
- instAddInt8
- instAddLex
- instAddNat
- instAddOrderDual
- instAddUInt16
- instAddUInt32
- instAddUInt64
- instAddUInt8
- instAddUSize
- instPNatAdd
The homogeneous version of HSub
: a - b : α
where a b : α
.
- sub : α → α → α
a - b
computes the difference ofa
andb
. SeeHSub
.
Instances
- AddMonoidHom.instSub
- AddUnits.instSub
- Additive.sub
- BitVec.instSub
- Fin.instSub
- Int.instSub
- LO.Arith.instSub_foundation
- Lean.Omega.IntList.instSub
- Lean.Omega.LinearCombo.instSub
- MulOpposite.instSub
- Multiset.instSub
- Nonneg.sub
- PNat.instSub
- Part.instSub
- Pi.instSub
- Prod.instSub
- Rat.instSub
- Std.Internal.Rat.instSub
- Std.Time.Day.instOffsetSub
- Std.Time.Hour.instOffsetSub
- Std.Time.Internal.UnitVal.instSub
- Std.Time.Millisecond.instOffsetSub
- Std.Time.Minute.instOffsetSub
- Std.Time.Month.instOffsetSub
- Std.Time.Nanosecond.instOffsetSub
- Std.Time.Second.instOffsetSub
- Std.Time.Week.instOffsetSub
- Std.Time.Year.instOffsetSub
- WithTop.LinearOrderedAddCommGroup.instSub
- WithTop.instSub
- instENatSub
- instNNRatSub
- instSubFloat
- instSubFloat32
- instSubISize
- instSubInt16
- instSubInt32
- instSubInt64
- instSubInt8
- instSubLex
- instSubNat
- instSubOrderDual
- instSubUInt16
- instSubUInt32
- instSubUInt64
- instSubUInt8
- instSubUSize
The homogeneous version of HMul
: a * b : α
where a b : α
.
- mul : α → α → α
a * b
computes the product ofa
andb
. SeeHMul
.
Instances
- AddMonoid.End.instMul
- AddOpposite.instMul
- Aesop.Percent.instMul
- Associates.instMul
- BitVec.instMul
- Cardinal.instMul
- Equiv.Perm.instMul
- Fin.instMul
- Int.instMul
- LO.Arith.Formalized.instMulSemitermLOR
- LO.FirstOrder.ModelOfSatEq.instMulOfMul
- LO.FirstOrder.Structure.Model.instMulOfMul
- Lean.Omega.IntList.instMul
- Monoid.End.instMul
- MonoidHom.mul
- MonoidWithZeroHom.instMul
- MulHom.instMul
- MulOpposite.instMul
- Multiplicative.mul
- Nonneg.mul
- OrderMonoidHom.instMulOfIsOrderedMonoid
- OrderMonoidWithZeroHom.instMul
- Part.instMul
- Pi.instMul
- Positive.instMulSubtypeLtOfNat_mathlib
- Prod.instMul
- Rat.instMul
- RingHom.instMul
- Std.Internal.Rat.instMul
- Std.Time.Month.instOffsetMul
- Units.instMul
- WithOne.instMul
- instMulFloat
- instMulFloat32
- instMulISize
- instMulInt16
- instMulInt32
- instMulInt64
- instMulInt8
- instMulLex
- instMulNat
- instMulOrderDual
- instMulUInt16
- instMulUInt32
- instMulUInt64
- instMulUInt8
- instMulUSize
- instPNatMul
The notation typeclass for negation.
This enables the notation -a : α
where a : α
.
- neg : α → α
-a
computes the negative or opposite ofa
. The meaning of this notation is type-dependent.Conventions for notations in identifiers:
- The recommended spelling of
-
in identifiers isneg
(when used as a unary operator).
- The recommended spelling of
Instances
- AddMonoidHom.instNeg
- AddOpposite.instNeg
- AddUnits.instNeg
- Additive.neg
- BitVec.instNeg
- Fin.neg
- ISize.instNeg
- Int.instNegInt
- Int16.instNeg
- Int32.instNeg
- Int64.instNeg
- Int8.instNeg
- Lean.JsonNumber.instNeg
- Lean.Omega.IntList.instNeg
- Lean.Omega.LinearCombo.instNeg
- MulOpposite.instNeg
- Part.instNeg
- Pi.instNeg
- Prod.instNeg
- Rat.instNeg
- Std.Internal.Rat.instNeg
- Std.Time.Day.instOffsetNeg
- Std.Time.Hour.instOffsetNeg
- Std.Time.Internal.UnitVal.instNeg
- Std.Time.Millisecond.instOffsetNeg
- Std.Time.Minute.instOffsetNeg
- Std.Time.Month.instOffsetNeg
- Std.Time.Nanosecond.instOffsetNeg
- Std.Time.Second.instOffsetNeg
- Std.Time.Week.instOffsetNeg
- Std.Time.Year.instOffsetNeg
- Units.instNeg
- WithTop.LinearOrderedAddCommGroup.instNeg
- WithZero.instNeg
- instNegFloat
- instNegFloat32
- instNegLex
- instNegOrderDual
- instNegUInt16
- instNegUInt32
- instNegUInt64
- instNegUInt8
- instNegUSize
The homogeneous version of HDiv
: a / b : α
where a b : α
.
- div : α → α → α
a / b
computes the result of dividinga
byb
. SeeHDiv
.
Instances
- AddOpposite.instDiv
- BitVec.instDiv
- Fin.instDiv
- Int.instDiv
- MonoidHom.instDiv
- Multiplicative.div
- NNRat.instDiv
- Nat.instDiv
- Part.instDiv
- Pi.instDiv
- Prod.instDiv
- Rat.instDiv
- Std.Internal.Rat.instDiv
- Std.Time.Month.instOffsetDiv
- System.FilePath.instDiv
- Units.instDiv
- WithZero.div
- instDivFloat
- instDivFloat32
- instDivISize
- instDivInt16
- instDivInt32
- instDivInt64
- instDivInt8
- instDivLex
- instDivOrderDual
- instDivUInt16
- instDivUInt32
- instDivUInt64
- instDivUInt8
- instDivUSize
The homogeneous version of HPow
: a ^ b : α
where a : α
, b : β
.
(The right argument is not the same as the left since we often want this even
in the homogeneous case.)
Types can choose to subscribe to particular defaulting behavior by providing
an instance to either NatPow
or HomogeneousPow
:
NatPow
is for types whose exponents is preferentially aNat
.HomogeneousPow
is for types whose base and exponent are preferentially the same.
- pow : α → β → α
a ^ b
computesa
to the power ofb
. SeeHPow
.
Instances
- AddOpposite.pow
- BitVec.instPowNat
- Cardinal.instPowCardinal
- DivInvMonoid.toZPow
- Equiv.Perm.instPowNat
- Lex.instPow
- Lex.instPow'
- Monoid.toNatPow
- NNRat.instZPow
- Nat.monoid.primePow
- Nonneg.pow
- OrderDual.instPow
- OrderDual.instPow'
- Pi.instPow
- Positive.instPowSubtypeLtOfNatNat_mathlib
- Prod.instPow
- Rat.instPowNat
- WithZero.instPowInt
- WithZero.pow
- instPowISizeNat
- instPowInt16Nat
- instPowInt32Nat
- instPowInt64Nat
- instPowInt8Nat
- instPowNat
- instPowOfHomogeneousPow
- instPowUInt16Nat
- instPowUInt32Nat
- instPowUInt64Nat
- instPowUInt8Nat
- instPowUSizeNat
The homogeneous version of Pow
where the exponent is a Nat
.
The purpose of this class is that it provides a default Pow
instance,
which can be used to specialize the exponent to Nat
during elaboration.
For example, if x ^ 2
should preferentially elaborate with 2 : Nat
then x
's type should
provide an instance for this class.
- pow : α → Nat → α
Instances
The completely homogeneous version of Pow
where the exponent has the same type as the base.
The purpose of this class is that it provides a default Pow
instance,
which can be used to specialize the exponent to have the same type as the base's type during elaboration.
This is to say, a type should provide an instance for this class in case x ^ y
should be elaborated
with both x
and y
having the same type.
For example, the Float
type provides an instance of this class, which causes expressions
such as (2.2 ^ 2.2 : Float)
to elaborate.
- pow : α → α → α
a ^ b
computesa
to the power ofb
wherea
andb
both have the same type.
The homogeneous version of HAppend
: a ++ b : α
where a b : α
.
- append : α → α → α
a ++ b
is the result of concatenation ofa
andb
. SeeHAppend
.
Instances
- Aesop.UnorderedArraySet.instAppend
- Array.instAppend
- ByteArray.instAppend
- Lake.Log.instAppend
- Lake.OrdHashSet.instAppend
- Lake.Toml.RBDict.instAppend
- Lean.Lsp.WorkspaceEdit.instAppend
- Lean.Lsp.instAppendTextEditBatch
- Lean.MessageData.instAppend
- Lean.MessageLog.instAppend
- Lean.Meta.LazyDiscrTree.InitResults.instAppendInitResults
- Lean.Meta.LazyDiscrTree.PreDiscrTree.instAppendPreDiscrTree
- Lean.NameSet.instAppend
- Lean.PersistentArray.instAppend
- Lean.Widget.instAppendExprDiff
- Lean.Widget.instAppendInteractiveGoals
- Lean.instAppendName
- List.instAppend
- Part.instAppend
- Std.Format.instAppend
- String.instAppend
- instAppendSubarray
The homogeneous version of HOrElse
: a <|> b : α
where a b : α
.
Because b
is "lazy" in this notation, it is passed as Unit → α
to the
implementation so it can decide when to evaluate it.
Instances
- EStateM.instOrElseOfBacktrackable
- Lake.EStateT.instOrElseOfMonad
- Lean.Elab.Tactic.instOrElseTacticM
- Lean.Meta.Grind.instOrElseGrindTactic
- Lean.Meta.instOrElseMetaM
- Lean.Parser.instOrElseParser
- Lean.PrettyPrinter.Delaborator.instOrElseDelabM
- Lean.PrettyPrinter.instOrElseFormatterM
- Lean.PrettyPrinter.instOrElseParenthesizerM
- MonadExcept.instOrElse
- Option.instOrElse
- instOrElseEIO
- instOrElseOfAlternative
The typeclass behind the notation ~~~a : α
where a : α
.
- complement : α → α
The implementation of
~~~a : α
.Conventions for notations in identifiers:
- The recommended spelling of
~~~
in identifiers isnot
.
- The recommended spelling of
The homogeneous version of HShiftLeft
: a <<< b : α
where a b : α
.
- shiftLeft : α → α → α
The implementation of
a <<< b : α
. SeeHShiftLeft
.
The homogeneous version of HShiftRight
: a >>> b : α
where a b : α
.
- shiftRight : α → α → α
The implementation of
a >>> b : α
. SeeHShiftRight
.
Equations
- instPowNat = { pow := fun (a : α) (n : Nat) => NatPow.pow a n }
Equations
- instPowOfHomogeneousPow = { pow := fun (a b : α) => HomogeneousPow.pow a b }
Equations
- instHAppendOfAppend = { hAppend := fun (a b : α) => Append.append a b }
Equations
- instHOrElseOfOrElse = { hOrElse := fun (a : α) (b : Unit → α) => OrElse.orElse a b }
Equations
- instHAndThenOfAndThen = { hAndThen := fun (a : α) (b : Unit → α) => AndThen.andThen a b }
Equations
- instHAndOfAndOp = { hAnd := fun (a b : α) => AndOp.and a b }
Equations
- instHXorOfXor = { hXor := fun (a b : α) => Xor.xor a b }
Equations
- instHOrOfOrOp = { hOr := fun (a b : α) => OrOp.or a b }
Equations
- instHShiftLeftOfShiftLeft = { hShiftLeft := fun (a b : α) => ShiftLeft.shiftLeft a b }
Equations
- instHShiftRightOfShiftRight = { hShiftRight := fun (a b : α) => ShiftRight.shiftRight a b }
The typeclass behind the notation a ∈ s : Prop
where a : α
, s : γ
.
Because α
is an outParam
, the "container type" γ
determines the type
of the elements of the container.
- mem : γ → α → Prop
The membership relation
a ∈ s : Prop
wherea : α
,s : γ
.Conventions for notations in identifiers:
- The recommended spelling of
∈
in identifiers ismem
.
- The recommended spelling of
Instances
- Array.instMembership
- Filter.instMembership
- Finset.instMembership
- LO.Arith.instMembershipFormulaSequent
- LO.Arith.instMembershipTheory
- LO.Arith.instMembership_foundation
- LO.Entailment.Context.instMembership
- LO.Entailment.FiniteContext.instMembership
- LO.FirstOrder.ModelOfSatEq.instMembershipOfMem
- LO.FirstOrder.Structure.Model.instMembershipOfMem
- LO.Modal.ComplementClosedConsistentFinset.instMembershipFormula
- LO.Modal.Kripke.Cluster.instMembershipWorld
- LO.Modal.MaximalConsistentSet.instMembershipFormula
- LO.Modal.QuasiNormalExtension.instMembershipFormulaNat
- List.instMembership
- Multiset.instMembership
- Nat.Partrec.Code.instMembershipPFun
- OmegaCompletePartialOrder.Chain.instMembership
- Option.instMembership
- Part.instMembership
- Set.instMembership
- SetLike.instMembership
- Std.DHashMap.Raw.instMembershipOfBEqOfHashable
- Std.DHashMap.instMembership
- Std.DTreeMap.Internal.Impl.instMembershipOfOrd
- Std.DTreeMap.Raw.instMembership
- Std.DTreeMap.instMembership
- Std.ExtDHashMap.instMembershipOfEquivBEqOfLawfulHashable
- Std.ExtHashMap.instMembershipOfEquivBEqOfLawfulHashable
- Std.ExtHashSet.instMembershipOfEquivBEqOfLawfulHashable
- Std.HashMap.Raw.instMembershipOfBEqOfHashable
- Std.HashMap.instMembership
- Std.HashSet.Raw.instMembershipOfBEqOfHashable
- Std.HashSet.instMembership
- Std.Sat.AIG.instMembership
- Std.TreeMap.Raw.instMembership
- Std.TreeMap.instMembership
- Std.TreeSet.Raw.instMembership
- Std.TreeSet.instMembership
- Std.instMembershipNatRange
- Sym.instMembership
- Ultrafilter.instMembershipSet
- Vector.instMembership
- instMembershipSetFilterBasis
Addition of natural numbers, typically used via the +
operator.
This function is overridden in both the kernel and the compiler to efficiently evaluate using the arbitrary-precision arithmetic library. The definition provided here is the logical model.
Multiplication of natural numbers, usually accessed via the *
operator.
This function is overridden in both the kernel and the compiler to efficiently evaluate using the arbitrary-precision arithmetic library. The definition provided here is the logical model.
The power operation on natural numbers, usually accessed via the ^
operator.
This function is overridden in both the kernel and the compiler to efficiently evaluate using the arbitrary-precision arithmetic library. The definition provided here is the logical model.
Boolean equality of natural numbers, usually accessed via the ==
operator.
This function is overridden in both the kernel and the compiler to efficiently evaluate using the arbitrary-precision arithmetic library. The definition provided here is the logical model.
A decision procedure for equality of natural numbers, usually accessed via the DecidableEq Nat
instance.
This function is overridden in both the kernel and the compiler to efficiently evaluate using the arbitrary-precision arithmetic library. The definition provided here is the logical model.
Examples:
The Boolean less-than-or-equal-to comparison on natural numbers.
This function is overridden in both the kernel and the compiler to efficiently evaluate using the arbitrary-precision arithmetic library. The definition provided here is the logical model.
Examples:
The predecessor of a natural number is one less than it. The precedessor of 0
is defined to be
0
.
This definition is overridden in the compiler with an efficient implementation. This definition is the logical model.
A decision procedure for non-strict inequality of natural numbers, usually accessed via the
DecidableLE Nat
instance.
Examples:
A decision procedure for strict inequality of natural numbers, usually accessed via the
DecidableLT Nat
instance.
Examples:
(if 3 < 4 then "yes" else "no") = "yes"
(if 4 < 4 then "yes" else "no") = "no"
(if 6 < 4 then "yes" else "no") = "no"
show 5 < 12 by decide
Subtraction of natural numbers, truncated at 0
. Usually used via the -
operator.
If a result would be less than zero, then the result is zero.
This definition is overridden in both the kernel and the compiler to efficiently evaluate using the arbitrary-precision arithmetic library. The definition provided here is the logical model.
Examples:
5 - 3 = 2
8 - 2 = 6
8 - 8 = 0
8 - 20 = 0
Gets the word size of the curent platform. The word size may be 64 or 32 bits.
This function is opaque because there is no guarantee at compile time that the target will have the same word size as the host. It also helps avoid having type checking be architecture-dependent.
Lean only works on 64 and 32 bit systems. This fact is visible in the return type.
The word size of the current platform, which may be 64 or 32 bits.
Equations
Instances For
Natural numbers less than some upper bound.
In particular, a Fin n
is a natural number i
with the constraint that i < n
. It is the
canonical type with n
elements.
Instances For
- Batteries.instLawfulOrdFin
- Fin.Lt.isWellOrder
- Fin.addCommGroup
- Fin.addCommMonoid
- Fin.addCommSemigroup
- Fin.coeToNat
- Fin.encodable
- Fin.fintype
- Fin.inhabitedFinOneAdd
- Fin.instAdd
- Fin.instAddCommSemigroup
- Fin.instAddLeftCancelSemigroup
- Fin.instAddMonoidWithOne
- Fin.instAddRightCancelSemigroup
- Fin.instAndOp
- Fin.instBiheytingAlgebra
- Fin.instBoundedOrder
- Fin.instCanLiftNatValLt
- Fin.instCoheytingAlgebra
- Fin.instCommRing
- Fin.instCommSemigroup
- Fin.instDistrib
- Fin.instDiv
- Fin.instGetElem?FinVal
- Fin.instGetElemFinVal
- Fin.instHasDistribNeg
- Fin.instHeytingAlgebra
- Fin.instInhabited
- Fin.instInvolutiveNeg
- Fin.instIsCancelAdd
- Fin.instLattice
- Fin.instLawfulGetElemValOfNat
- Fin.instLinearOrder
- Fin.instMod
- Fin.instMul
- Fin.instNatCast
- Fin.instOfNat
- Fin.instOrOp
- Fin.instPartialOrder
- Fin.instShiftLeft
- Fin.instShiftRight
- Fin.instSub
- Fin.instUnique
- Fin.instWellFoundedRelation_mathlib
- Fin.instXor
- Fin.isEmpty
- Fin.isEmpty'
- Fin.neg
- Fin.nontrivial
- Fin.subsingleton_one
- Fin.subsingleton_zero
- Lean.Meta.instFastIsEmptyFinOfNatNat
- Lean.Meta.instFastSubsingletonFinOfNatNat
- Lean.Meta.instReduceEvalFinOfNeZeroNat_qq
- Lean.instToExprFin
- Plausible.Fin.sampleableExt
- Plausible.Fin.shrinkable
- Plausible.Random.instBoundedRandomFin
- Plausible.Random.instFinSucc
- Primcodable.fin
- Std.Fin.instLawfulEqOrdFin
- Std.Fin.instOrientedOrdFin
- Std.Fin.instTransOrdFin
- instCountableFin
- instHashableFin
- instLEFin
- instLTFin
- instOrdFin
- instReprFin
- instToStringFin
- subsingleton_fin_one
- subsingleton_fin_zero
A bitvector of the specified width.
This is represented as the underlying Nat
number in both the runtime
and the kernel, inheriting all the special support for Nat
.
- ofFin :: (
Interpret a bitvector as a number less than
2^w
. O(1), because we useFin
as the internal representation of a bitvector.- )
Instances For
- BitVec.instAdd
- BitVec.instAndOp
- BitVec.instComplement
- BitVec.instDiv
- BitVec.instGetElemNatBoolLt
- BitVec.instHAppendHAddNat
- BitVec.instHShiftLeft
- BitVec.instHShiftLeftNat
- BitVec.instHShiftRight
- BitVec.instHShiftRightNat
- BitVec.instHashable
- BitVec.instInhabited
- BitVec.instIntCast
- BitVec.instMod
- BitVec.instMul
- BitVec.instNeg
- BitVec.instOfNat
- BitVec.instOrOp
- BitVec.instPowNat
- BitVec.instRepr
- BitVec.instSub
- BitVec.instSubsingletonOfNatNat
- BitVec.instToString
- BitVec.instXor
- BitVec.natCastInst
- Lean.Grind.instCommRingBitVec
- Lean.Grind.instIsCharPBitVecHPowNatOfNat
- Lean.Meta.instReduceEvalBitVec_qq
- Lean.instToExprBitVec
- Plausible.BitVec.sampleableExt
- Plausible.BitVec.shrinkable
- Plausible.Random.instBoundedRandomBitVec
- Std.BitVec.instLawfulEqOrdBitVec
- Std.BitVec.instTransOrdBitVec
- instLEBitVec
- instLTBitVec
- instOrdBitVec
Equations
Equations
- instDecidableLtBitVec x y = inferInstanceAs (Decidable (x.toNat < y.toNat))
Equations
- instDecidableLeBitVec x y = inferInstanceAs (Decidable (x.toNat ≤ y.toNat))
The number of distinct values representable by UInt8
, that is, 2^8 = 256
.
Equations
- UInt8.size = 256
Unsigned 8-bit integers.
This type has special support in the compiler so it can be represented by an unboxed 8-bit value
rather than wrapping a BitVec 8
.
- ofBitVec :: (
- toBitVec : BitVec 8
- )
Instances For
- ByteArray.instForInUInt8
- ByteArray.instGetElemNatUInt8LtSize
- ByteArray.instGetElemUSizeUInt8LtNatValToFinSize
- Lean.Compiler.LCNF.Simp.ConstantFold.instLiteralUInt8
- Lean.Grind.instCommRingUInt8
- Lean.Grind.instIsCharPUInt8OfNatNat
- Lean.instToExprUInt8
- Plausible.UInt8.SampleableExt
- Plausible.UInt8.shrinkable
- Std.Internal.Parsec.ByteArray.instInputIteratorUInt8Nat
- Std.UInt8.instLawfulEqOrdUInt8
- Std.UInt8.instTransOrdUInt8
- UInt8.instIntCast
- UInt8.instNatCast
- UInt8.instOfNat
- instAddUInt8
- instAndOpUInt8
- instComplementUInt8
- instDivUInt8
- instHModUInt8Nat
- instHashableUInt8
- instInhabitedUInt8
- instLEUInt8
- instLTUInt8
- instMaxUInt8
- instMinUInt8
- instModUInt8
- instMulUInt8
- instNegUInt8
- instOrOpUInt8
- instOrdUInt8
- instPowUInt8Nat
- instReprAtomUInt8
- instReprUInt8
- instShiftLeftUInt8
- instShiftRightUInt8
- instSubUInt8
- instToStringUInt8
- instXorUInt8
Converts a natural number to an 8-bit unsigned integer. Requires a proof that the number is small
enough to be representable without overflow; it must be smaller than 2^8
.
This function is overridden at runtime with an efficient implementation.
Equations
- UInt8.ofNatLT n h = { toBitVec := n#'h }
Decides whether two 8-bit unsigned integers are equal. Usually accessed via the DecidableEq UInt8
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
UInt8.decEq 123 123 = .isTrue rfl
(if (6 : UInt8) = 7 then "yes" else "no") = "no"
show (7 : UInt8) = 7 by decide
Equations
- instInhabitedUInt8 = { default := UInt8.ofNatLT 0 instInhabitedUInt8._proof_11 }
The number of distinct values representable by UInt16
, that is, 2^16 = 65536
.
Equations
- UInt16.size = 65536
Unsigned 16-bit integers.
This type has special support in the compiler so it can be represented by an unboxed 16-bit value
rather than wrapping a BitVec 16
.
- ofBitVec :: (
- toBitVec : BitVec 16
- )
Instances For
- Lean.Compiler.LCNF.Simp.ConstantFold.instLiteralUInt16
- Lean.Grind.instCommRingUInt16
- Lean.Grind.instIsCharPUInt16OfNatNat
- Lean.instToExprUInt16
- Plausible.UInt16.SampleableExt
- Plausible.UInt16.shrinkable
- Std.UInt16.instLawfulEqOrdUInt16
- Std.UInt16.instTransOrdUInt16
- UInt16.instIntCast
- UInt16.instNatCast
- UInt16.instOfNat
- instAddUInt16
- instAndOpUInt16
- instComplementUInt16
- instDivUInt16
- instHModUInt16Nat
- instHashableUInt16
- instInhabitedUInt16
- instLEUInt16
- instLTUInt16
- instMaxUInt16
- instMinUInt16
- instModUInt16
- instMulUInt16
- instNegUInt16
- instOrOpUInt16
- instOrdUInt16
- instPowUInt16Nat
- instReprAtomUInt16
- instReprUInt16
- instShiftLeftUInt16
- instShiftRightUInt16
- instSubUInt16
- instToStringUInt16
- instXorUInt16
Converts a natural number to a 16-bit unsigned integer. Requires a proof that the number is small
enough to be representable without overflow; it must be smaller than 2^16
.
This function is overridden at runtime with an efficient implementation.
Equations
- UInt16.ofNatLT n h = { toBitVec := n#'h }
Decides whether two 16-bit unsigned integers are equal. Usually accessed via the
DecidableEq UInt16
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
UInt16.decEq 123 123 = .isTrue rfl
(if (6 : UInt16) = 7 then "yes" else "no") = "no"
show (7 : UInt16) = 7 by decide
Equations
Equations
- instInhabitedUInt16 = { default := UInt16.ofNatLT 0 instInhabitedUInt16._proof_14 }
The number of distinct values representable by UInt32
, that is, 2^32 = 4294967296
.
Equations
- UInt32.size = 4294967296
Unsigned 32-bit integers.
This type has special support in the compiler so it can be represented by an unboxed 32-bit value
rather than wrapping a BitVec 32
.
- ofBitVec :: (
- toBitVec : BitVec 32
- )
Instances For
- Lean.Compiler.LCNF.Simp.ConstantFold.instLiteralUInt32
- Lean.Grind.instCommRingUInt32
- Lean.Grind.instIsCharPUInt32OfNatNat
- Lean.instToExprUInt32
- Plausible.UInt32.SampleableExt
- Plausible.UInt32.shrinkable
- Std.UInt32.instLawfulEqOrdUInt32
- Std.UInt32.instTransOrdUInt32
- UInt32.instIntCast
- UInt32.instNatCast
- UInt32.instOfNat
- instAddUInt32
- instAndOpUInt32
- instComplementUInt32
- instDivUInt32
- instHModUInt32Nat
- instHashableUInt32
- instInhabitedUInt32
- instLEUInt32
- instLEUInt32_1
- instLTUInt32
- instLTUInt32_1
- instMaxUInt32
- instMinUInt32
- instModUInt32
- instMulUInt32
- instNegUInt32
- instOrOpUInt32
- instOrdUInt32
- instPowUInt32Nat
- instReprAtomUInt32
- instReprUInt32
- instShiftLeftUInt32
- instShiftRightUInt32
- instSubUInt32
- instToStringUInt32
- instXorUInt32
Converts a natural number to a 32-bit unsigned integer. Requires a proof that the number is small
enough to be representable without overflow; it must be smaller than 2^32
.
This function is overridden at runtime with an efficient implementation.
Equations
- UInt32.ofNatLT n h = { toBitVec := n#'h }
Decides whether two 32-bit unsigned integers are equal. Usually accessed via the
DecidableEq UInt32
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
UInt32.decEq 123 123 = .isTrue rfl
(if (6 : UInt32) = 7 then "yes" else "no") = "no"
show (7 : UInt32) = 7 by decide
Equations
Equations
- instInhabitedUInt32 = { default := UInt32.ofNatLT 0 instInhabitedUInt32._proof_17 }
Decides whether one 8-bit unsigned integer is strictly less than another. Usually accessed via the
DecidableLT UInt32
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
(if (6 : UInt32) < 7 then "yes" else "no") = "yes"
(if (5 : UInt32) < 5 then "yes" else "no") = "no"
show ¬((7 : UInt32) < 7) by decide
Decides whether one 32-bit signed integer is less than or equal to another. Usually accessed via the
DecidableLE UInt32
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
(if (15 : UInt32) ≤ 15 then "yes" else "no") = "yes"
(if (15 : UInt32) ≤ 5 then "yes" else "no") = "no"
(if (5 : UInt32) ≤ 15 then "yes" else "no") = "yes"
show (7 : UInt32) ≤ 7 by decide
Equations
- instDecidableLtUInt32 a b = a.decLt b
Equations
- instDecidableLeUInt32 a b = a.decLe b
The number of distinct values representable by UInt64
, that is, 2^64 = 18446744073709551616
.
Equations
- UInt64.size = 18446744073709551616
Unsigned 64-bit integers.
This type has special support in the compiler so it can be represented by an unboxed 64-bit value
rather than wrapping a BitVec 64
.
- ofBitVec :: (
- toBitVec : BitVec 64
- )
Instances For
- Lake.instLawfulCmpEqUInt64Compare
- Lean.Compiler.LCNF.Simp.ConstantFold.instLiteralUInt64
- Lean.Grind.instCommRingUInt64
- Lean.Grind.instIsCharPUInt64OfNatNat
- Lean.Meta.instReduceEvalUInt64_qq
- Lean.instFromJsonUInt64
- Lean.instToExprUInt64
- Lean.instToJsonUInt64
- Plausible.UInt64.SampleableExt
- Plausible.UInt64.shrinkable
- Std.UInt64.instLawfulEqOrdUInt64
- Std.UInt64.instTransOrdUInt64
- UInt64.instIntCast
- UInt64.instNatCast
- UInt64.instOfNat
- instAddUInt64
- instAndOpUInt64
- instComplementUInt64
- instDivUInt64
- instHModUInt64Nat
- instHashableUInt64
- instInhabitedUInt64
- instLEUInt64
- instLTUInt64
- instMaxUInt64
- instMinUInt64
- instModUInt64
- instMulUInt64
- instNegUInt64
- instOrOpUInt64
- instOrdUInt64
- instPowUInt64Nat
- instReprAtomUInt64
- instReprUInt64
- instShiftLeftUInt64
- instShiftRightUInt64
- instSubUInt64
- instToStringUInt64
- instXorUInt64
Converts a natural number to a 64-bit unsigned integer. Requires a proof that the number is small
enough to be representable without overflow; it must be smaller than 2^64
.
This function is overridden at runtime with an efficient implementation.
Equations
- UInt64.ofNatLT n h = { toBitVec := n#'h }
Decides whether two 64-bit unsigned integers are equal. Usually accessed via the
DecidableEq UInt64
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
UInt64.decEq 123 123 = .isTrue rfl
(if (6 : UInt64) = 7 then "yes" else "no") = "no"
show (7 : UInt64) = 7 by decide
Equations
Equations
- instInhabitedUInt64 = { default := UInt64.ofNatLT 0 instInhabitedUInt64._proof_20 }
Unsigned integers that are the size of a word on the platform's architecture.
On a 32-bit architecture, USize
is equivalent to UInt32
. On a 64-bit machine, it is equivalent
to UInt64
.
- ofBitVec :: (
- toBitVec : BitVec System.Platform.numBits
Unpacks a
USize
into aBitVec System.Platform.numBits
. This function is overridden with a native implementation. - )
Instances For
- Array.instGetElemUSizeLtNatToNatSize
- ByteArray.instGetElemUSizeUInt8LtNatValToFinSize
- FloatArray.instGetElemUSizeFloatLtNatToNatSize
- Lean.Grind.instCommRingUSize
- Lean.Grind.instIsCharPUSizeHPowNatOfNatNumBits
- Lean.Meta.instReduceEvalUSize_qq
- Lean.instFromJsonUSize
- Lean.instToExprUSize
- Lean.instToJsonUSize
- Plausible.USize.SampleableExt
- Plausible.USize.shrinkable
- Std.USize.instLawfulEqOrdUSize
- Std.USize.instTransOrdUSize
- USize.instIntCast
- USize.instNatCast
- USize.instOfNat
- instAddUSize
- instAndOpUSize
- instComplementUSize
- instDivUSize
- instHModUSizeNat
- instHashableUSize
- instInhabitedUSize
- instLEUSize
- instLTUSize
- instMaxUSize
- instMinUSize
- instModUSize
- instMulUSize
- instNegUSize
- instOrOpUSize
- instOrdUSize
- instPowUSizeNat
- instReprAtomUSize
- instReprUSize
- instShiftLeftUSize
- instShiftRightUSize
- instSubUSize
- instToStringUSize
- instXorUSize
Decides whether two word-sized unsigned integers are equal. Usually accessed via the
DecidableEq USize
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
USize.decEq 123 123 = .isTrue rfl
(if (6 : USize) = 7 then "yes" else "no") = "no"
show (7 : USize) = 7 by decide
Equations
- instInhabitedUSize = { default := USize.ofNatLT 0 USize.size_pos }
A UInt32
denotes a valid Unicode code point if it is less than 0x110000
and it is also not a
surrogate code point (the range 0xd800
to 0xdfff
inclusive).
Equations
- n.isValidChar = n.toNat.isValidChar
Characters are Unicode scalar values.
- val : UInt32
The underlying Unicode scalar value as a
UInt32
. - valid : self.val.isValidChar
The value must be a legal scalar value.
Instances For
- Char.instInhabited
- Char.instLE
- Char.instLT
- Lean.Compiler.LCNF.Simp.ConstantFold.instLiteralChar
- Lean.instQuoteCharCharLitKind
- Lean.instToExprChar
- Plausible.Char.sampleableDefault
- Plausible.Char.shrinkable
- Std.Char.instLawfulEqOrdChar
- Std.Char.instTransOrdChar
- Std.Internal.Parsec.String.instInputIteratorCharPos
- instHAddPosChar
- instHashableChar
- instLawfulBEqChar
- instOrdChar
- instReprAtomChar
- instReprChar
- instStreamSubstringChar
- instToStringChar
Converts a Nat
into a Char
. If the Nat
does not encode a valid Unicode scalar value, '\0'
is
returned instead.
Equations
- Char.ofNat n = if h : n.isValidChar then Char.ofNatAux n h else { val := { toBitVec := 0#'Char.ofNat._proof_23 }, valid := Char.ofNat._proof_24 }
Returns the number of bytes required to encode this Char
in UTF-8.
Equations
- One or more equations did not get rendered due to their size.
Optional values, which are either some
around a value from the underlying type or none
.
Option
can represent nullable types or computations that might fail. In the codomain of a function
type, it can also represent partiality.
Instances For
- Denumerable.option
- Lake.LeanConfig.platformIndependent.instConfigField
- Lake.PackageConfig.buildArchive.instConfigField
- Lake.PackageConfig.buildArchive?.instConfigField
- Lake.PackageConfig.manifestFile.instConfigField
- Lake.PackageConfig.releaseRepo.instConfigField
- Lake.PackageConfig.releaseRepo?.instConfigField
- Lake.instMonadLiftTOptionOfAlternative_lake
- Lean.Language.instToSnapshotTreeOption
- Lean.MessageData.instCoeOptionExpr
- Lean.Meta.instReduceEvalOption
- Lean.Option.hasQuote
- Lean.Order.instCCPOOption
- Lean.Order.instMonoBindOption
- Lean.Order.instPartialOrderOption
- Lean.PersistentHashMap.instGetElemOptionTrue
- Lean.Server.instRpcEncodableOption
- Lean.instExceptToEmojiOption
- Lean.instFromJsonOption
- Lean.instToExprOptionOfToLevel
- Lean.instToJsonOption
- Lean.instToMessageDataOption
- Lean.instToMessageDataOptionExpr
- Option.encodable
- Option.instBEq
- Option.instCountable
- Option.instForIn'InferInstanceMembership
- Option.instForM
- Option.instLawfulBEq
- Option.instMax
- Option.instMembership
- Option.instMin
- Option.instOrElse
- Option.instReflBEq
- Option.instUncountable
- Option.instUniqueOfIsEmpty
- Option.nontrivial
- Part.instCoeOption
- Plausible.Option.sampleableExt
- Plausible.Option.shrinkable
- Primcodable.option
- Std.Option.instLawfulBEqOrdOption
- Std.Option.instLawfulEqOrdOption
- Std.Option.instOrientedOrdOption
- Std.Option.instReflOrdOption
- Std.Option.instTransOrdOption
- instAlternativeOption
- instFintypeOption
- instFunctorOption
- instHashableOption
- instInfiniteOption
- instInhabitedOption
- instLEOption
- instLTOption
- instLawfulApplicativeOption
- instLawfulFunctorOption
- instLawfulMonadOption
- instMonadExceptOfUnitOption
- instMonadOption
- instOrdOption
- instReprOption
- instToBoolOption
- instToFormatOption
- instToStringOption
- instTraversableOption
- optionCoe
Equations
- instInhabitedOption = { default := none }
Linked lists: ordered lists, in which each element has a reference to the next element.
Most operations on linked lists take time proportional to the length of the list, because each element must be traversed to find the next element.
List α
is isomorphic to Array α
, but they are useful for different things:
List α
is easier for reasoning, andArray α
is modeled as a wrapper aroundList α
.List α
works well as a persistent data structure, when many copies of the tail are shared. When the value is not shared,Array α
will have better performance because it can do destructive updates.
- nil
{α : Type u}
: List α
The empty list, usually written
[]
.Conventions for notations in identifiers:
- The recommended spelling of
[]
in identifiers isnil
.
- The recommended spelling of
- cons
{α : Type u}
(head : α)
(tail : List α)
: List α
The list whose first element is
head
, wheretail
is the rest of the list. Usually writtenhead :: tail
.Conventions for notations in identifiers:
The recommended spelling of
::
in identifiers iscons
.The recommended spelling of
[a]
in identifiers issingleton
.
Instances For
- Array.instHAppendList
- Denumerable.denumerableList
- IO.AsyncList.instCoeList
- LO.Entailment.FiniteContext.instCoeList
- LO.FirstOrder.Sequent.instTildeListSemiformula
- Lake.instComputeTraceListOfMonad
- Lake.instToTextList
- Lean.MessageData.instCoeList
- Lean.MessageData.instCoeListExpr
- Lean.Meta.instCoeListNatOccurrences
- Lean.Meta.instReduceEvalList_qq
- Lean.instFromJsonList
- Lean.instQuoteListMkStr1
- Lean.instToExprListOfToLevel
- Lean.instToJsonList
- Lean.instToMessageDataList
- List.LE'
- List.Lex.isAsymm
- List.Lex.isOrderConnected
- List.Lex.isTrichotomous
- List.SublistForall₂.is_refl
- List.SublistForall₂.is_trans
- List.canLift
- List.collection
- List.countable
- List.encodable
- List.instAlternative
- List.instAppend
- List.instBEq
- List.instEmptyCollection
- List.instForIn'InferInstanceMembership
- List.instForM
- List.instFunctor
- List.instGetElem?NatLtLength
- List.instGetElemNatLtLength
- List.instHasSubset
- List.instInsertOfDecidableEq_mathlib
- List.instInterOfBEq_batteries
- List.instIsPartialOrderIsInfix
- List.instIsPartialOrderIsPrefix
- List.instIsPartialOrderIsSuffix
- List.instIsSymmPerm
- List.instLE
- List.instLT
- List.instLawfulBEq
- List.instLawfulBEqOrd
- List.instLawfulEqOrd
- List.instLawfulGetElemNatLtLength
- List.instLawfulMonad
- List.instLawfulSingleton_mathlib
- List.instLinearOrder
- List.instMembership
- List.instMonad
- List.instOrd
- List.instOrientedOrd
- List.instReflBEq
- List.instReflOrd
- List.instSDiffOfDecidableEq_mathlib
- List.instSProd
- List.instSingletonList
- List.instTransOrd
- List.instUnionOfBEq_batteries
- List.isSetoid
- List.uniqueOfIsEmpty
- Multiset.instCoeList
- Plausible.List.sampleableExt
- Plausible.List.shrinkable
- Primcodable.list
- instConsList
- instHashableList
- instInfiniteListOfNonempty
- instInhabitedList
- instReprList
- instReprListOfReprAtom
- instStreamList
- instToFormatList
- instToStreamList
- instToStringList
- instTraversableList
Implements decidable equality for List α
, assuming α
has decidable equality.
Equations
Auxiliary function for List.lengthTR
.
Equations
- [].lengthTRAux x✝ = x✝
- (head :: as).lengthTRAux x✝ = as.lengthTRAux x✝.succ
The length of a list.
This is a tail-recursive version of List.length
, used to implement List.length
without running
out of stack space.
Examples:
Equations
- as.lengthTR = as.lengthTRAux 0
Replaces the value at (zero-based) index n
in l
with a
. If the index is out of bounds, then
the list is returned unmodified.
Examples:
Folds a function over a list from the left, accumulating a value starting with init
. The
accumulated value is combined with the each element of the list in order, using f
.
Examples:
[a, b, c].foldl f z = f (f (f z a) b) c
[1, 2, 3].foldl (· ++ toString ·) "" = "123"
[1, 2, 3].foldl (s!"({·} {·})") "" = "((( 1) 2) 3)"
Equations
- List.foldl f x✝ [] = x✝
- List.foldl f x✝ (b :: l) = List.foldl f (f x✝ b) l
Adds an element to the end of a list.
The added element is the last element of the resulting list.
Examples:
List.concat ["red", "yellow"] "green" = ["red", "yellow", "green"]
List.concat [1, 2, 3] 4 = [1, 2, 3, 4]
List.concat [] () = [()]
A string is a sequence of Unicode code points.
At runtime, strings are represented by dynamic arrays
of bytes using the UTF-8 encoding. Both the size in bytes (String.utf8ByteSize
) and in characters
(String.length
) are cached and take constant time. Many operations on strings perform in-place
modifications when the reference to the string is unique.
Instances For
- Lake.LeanExeConfig.exeName.instConfigField
- Lake.LeanLibConfig.libName.instConfigField
- Lake.PackageConfig.description.instConfigField
- Lake.PackageConfig.homepage.instConfigField
- Lake.PackageConfig.license.instConfigField
- Lake.PackageConfig.lintDriver.instConfigField
- Lake.PackageConfig.testDriver.instConfigField
- Lake.PackageConfig.testRunner.instConfigField
- Lake.instCoeStringStrPat
- Lake.instCoeStringStrPatDescr
- Lake.instComputeHashStringId
- Lake.instIsPatternStrPatDescrString
- Lake.instLawfulCmpEqStringCompare
- Lean.Compiler.LCNF.Simp.ConstantFold.instLiteralString
- Lean.Json.instCoeString
- Lean.JsonRpc.instCoeStringRequestID
- Lean.KVMap.instValueString
- Lean.MessageData.instCoeString
- Lean.Meta.Tactic.TryThis.instCoeStringSuggestionText
- Lean.Meta.instReduceEvalString
- Lean.Parser.instCoeStringParser
- Lean.instCoeStringDataValue
- Lean.instCoeStringLeanOptionValue
- Lean.instFromJsonString
- Lean.instQuoteStringStrLitKind
- Lean.instToExprString
- Lean.instToJsonString
- Lean.instToMessageDataString
- Plausible.String.sampleableExt
- Plausible.String.shrinkable
- Std.Format.instCoeString
- Std.String.instLawfulEqOrdString
- Std.String.instTransOrdString
- Std.Time.instCoeStringFormatPart
- Std.instToFormatString
- String.infinite
- String.instAppend
- String.instInhabited
- String.instLE
- String.instLT
- System.FilePath.instHDivString
- System.instCoeStringFilePath
- instCoeStringError
- instCoeStringSubstring_batteries
- instHAddPosString
- instHashableString
- instLawfulBEqString
- instOrdString
- instReprAtomString
- instReprString
- instToStreamStringSubstring
- instToStringString
Decides whether two strings are equal. Normally used via the DecidableEq String
instance and the
=
operator.
At runtime, this function is overridden with an efficient native implementation.
Equations
A byte position in a String
, according to its UTF-8 encoding.
Character positions (counting the Unicode code points rather than bytes) are represented by plain
Nat
s. Indexing a String
by a String.Pos
takes constant time, while character positions need to
be translated internally to byte positions, which takes linear time.
A byte position p
is valid for a string s
if 0 ≤ p ≤ s.endPos
and p
lies on a UTF-8
character boundary.
- byteIdx : Nat
Get the underlying byte index of a
String.Pos
A region or slice of some underlying string.
A substring contains an string together with the start and end byte positions of a region of interest. Actually extracting a substring requires copying and memory allocation, while many substrings of the same underlying string may exist with very little overhead, and they are more convenient than tracking the bounds by hand.
Using its constructor explicitly, it is possible to construct a Substring
in which one or both of
the positions is invalid for the string. Many operations will return unexpected or confusing results
if the start and stop positions are not valid. Instead, it's better to use API functions that ensure
the validity of the positions in a substring to create and manipulate them.
- str : String
The underlying string.
- startPos : String.Pos
The byte position of the start of the string slice.
- stopPos : String.Pos
The byte position of the end of the string slice.
The number of bytes used by the string's UTF-8 encoding.
At runtime, this function takes constant time because the byte length of strings is cached.
Equations
- { data := s }.utf8ByteSize = String.utf8ByteSize.go s
Equations
- String.utf8ByteSize.go [] = 0
- String.utf8ByteSize.go (c :: cs) = String.utf8ByteSize.go cs + c.utf8Size
Equations
- instHAddPos = { hAdd := fun (p₁ p₂ : String.Pos) => { byteIdx := p₁.byteIdx + p₂.byteIdx } }
Equations
- instHSubPos = { hSub := fun (p₁ p₂ : String.Pos) => { byteIdx := p₁.byteIdx - p₂.byteIdx } }
Equations
- instHAddPosString = { hAdd := fun (p : String.Pos) (s : String) => { byteIdx := p.byteIdx + s.utf8ByteSize } }
Equations
- instDecidableLePos p₁ p₂ = inferInstanceAs (Decidable (p₁.byteIdx ≤ p₂.byteIdx))
Equations
- instDecidableLtPos p₁ p₂ = inferInstanceAs (Decidable (p₁.byteIdx < p₂.byteIdx))
Converts a String
into a Substring
that denotes the entire string.
This is a version of String.toSubstring
that doesn't have an @[inline]
annotation.
Equations
- s.toSubstring' = s.toSubstring
This function will cast a value of type α
to type β
, and is a no-op in the
compiler. This function is extremely dangerous because there is no guarantee
that types α
and β
have the same data representation, and this can lead to
memory unsafety. It is also logically unsound, since you could just cast
True
to False
. For all those reasons this function is marked as unsafe
.
It is implemented by lifting both α
and β
into a common universe, and then
using cast (lcProof : ULift (PLift α) = ULift (PLift β))
to actually perform
the cast. All these operations are no-ops in the compiler.
Using this function correctly requires some knowledge of the data representation of the source and target types. Some general classes of casts which are safe in the current runtime:
Array α
toArray β
whereα
andβ
have compatible representations, or more generally for other inductive types.Quot α r
andα
.@Subtype α p
andα
, or generally any structure containing only one non-Prop
field of typeα
.- Casting
α
to/fromNonScalar
whenα
is a boxed generic type (i.e. a function that accepts an arbitrary typeα
and is not specialized to a scalar type likeUInt8
).
(panic "msg" : α)
has a built-in implementation which prints msg
to
the error buffer. It does not terminate execution, and because it is a safe
function, it still has to return an element of α
, so it takes [Inhabited α]
and returns default
. It is primarily intended for debugging in pure contexts,
and assertion failures.
Because this is a pure function with side effects, it is marked as
@[never_extract]
so that the compiler will not perform common sub-expression
elimination and other optimizations that assume that the expression is pure.
Array α
is the type of dynamic arrays with elements
from α
. This type has special support in the runtime.
Arrays perform best when unshared. As long as there is never more than one reference to an array, all updates will be performed destructively. This results in performance comparable to mutable arrays in imperative programming languages.
An array has a size and a capacity. The size is the number of elements present in the array, while
the capacity is the amount of memory currently allocated for elements. The size is accessible via
Array.size
, but the capacity is not observable from Lean code. Array.emptyWithCapacity n
creates
an array which is equal to #[]
, but internally allocates an array of capacity n
. When the size
exceeds the capacity, allocation is required to grow the array.
From the point of view of proofs, Array α
is just a wrapper around List α
.
- toList : List α
Converts an
Array α
into aList α
that contains the same elements in the same order.At runtime, this is implemented by
Array.toListImpl
and isO(n)
in the length of the array.
Instances For
- Array.instAppend
- Array.instBEq
- Array.instCoeSubarray
- Array.instEmptyCollection
- Array.instForIn'InferInstanceMembership
- Array.instForM
- Array.instFunctor
- Array.instGetElem?NatLtSize
- Array.instGetElemNatLtSize
- Array.instGetElemUSizeLtNatToNatSize
- Array.instHAppendList
- Array.instInhabited
- Array.instLE
- Array.instLT
- Array.instLawfulBEq
- Array.instLawfulBEqOrd
- Array.instLawfulEqOrd
- Array.instLawfulGetElemNatLtSize
- Array.instMembership
- Array.instOrd
- Array.instOrientedOrd
- Array.instReflBEq
- Array.instReflOrd
- Array.instRepr
- Array.instToString
- Array.instTransOrd
- Lake.LeanConfig.leanOptions.instConfigField
- Lake.LeanConfig.moreLeanArgs.instConfigField
- Lake.LeanConfig.moreLeancArgs.instConfigField
- Lake.LeanConfig.moreLinkArgs.instConfigField
- Lake.LeanConfig.moreServerOptions.instConfigField
- Lake.LeanConfig.weakLeanArgs.instConfigField
- Lake.LeanConfig.weakLeancArgs.instConfigField
- Lake.LeanConfig.weakLinkArgs.instConfigField
- Lake.LeanExeConfig.extraDepTargets.instConfigField
- Lake.LeanExeConfig.needs.instConfigField
- Lake.LeanLibConfig.defaultFacets.instConfigField
- Lake.LeanLibConfig.extraDepTargets.instConfigField
- Lake.LeanLibConfig.globs.instConfigField
- Lake.LeanLibConfig.needs.instConfigField
- Lake.LeanLibConfig.roots.instConfigField
- Lake.OrdHashSet.instHAppendArray
- Lake.PackageConfig.extraDepTargets.instConfigField
- Lake.PackageConfig.keywords.instConfigField
- Lake.PackageConfig.licenseFiles.instConfigField
- Lake.PackageConfig.lintDriverArgs.instConfigField
- Lake.PackageConfig.moreGlobalServerArgs.instConfigField
- Lake.PackageConfig.moreServerArgs.instConfigField
- Lake.PackageConfig.testDriverArgs.instConfigField
- Lake.Toml.RBDict.instHAppendArrayProd
- Lake.instCoeArrayStringStrPat
- Lake.instCoeArrayStringStrPatDescr
- Lake.instCoeGlobArray
- Lake.instComputeHashArrayOfMonad
- Lake.instComputeTraceArrayOfMonad
- Lake.instFamilyDefNameFacetOutHAppendMkStr1ArrayFilePath
- Lake.instFamilyDefNameFacetOutHAppendMkStr1ArrayModule
- Lake.instFamilyDefNameFacetOutHAppendMkStr1ArrayModule_1
- Lake.instFamilyDefNameFacetOutHAppendMkStr1ArrayModule_2
- Lake.instFamilyDefNameFacetOutHAppendMkStr1ArrayModule_3
- Lake.instFamilyDefNameFacetOutHAppendMkStr1ArrayPackage
- Lake.instFamilyDefNameFacetOutHAppendMkStr1ArrayPackage_1
- Lake.instFamilyDefNameFacetOutMkStr2ArrayFilePath
- Lake.instFamilyDefNameFacetOutMkStr2ArrayModule
- Lake.instFamilyDefNameFacetOutMkStr2ArrayModule_1
- Lake.instFamilyDefNameFacetOutMkStr2ArrayModule_2
- Lake.instFamilyDefNameFacetOutMkStr2ArrayModule_3
- Lake.instFamilyDefNameFacetOutMkStr2ArrayPackage
- Lake.instFamilyDefNameFacetOutMkStr2ArrayPackage_1
- Lake.instToTextArray
- Lean.IR.instAlphaEqvArrayArg
- Lean.Json.instCoeArrayStructured
- Lean.MessageData.instCoeArrayExpr
- Lean.Parser.SyntaxStack.instHAppendArraySyntax
- Lean.Server.instRpcEncodableArray
- Lean.Syntax.instCoeArraySepArray
- Lean.Syntax.instCoeOutSepArrayArray
- Lean.Syntax.instCoeOutTSyntaxArrayArray
- Lean.instFromJsonArray
- Lean.instGetElem?ArrayModuleIdxLtNatToNatSize
- Lean.instGetElemArrayModuleIdxLtNatToNatSize
- Lean.instQuoteArrayMkStr1
- Lean.instToExprArrayOfToLevel
- Lean.instToJsonArray
- Lean.instToMessageDataArray
- Plausible.Array.sampleableExt
- Plausible.Array.shrinkable
- Std.Tactic.BVDecide.LRAT.Internal.Assignment.instEntailsPosFinArray
- instHashableArray
- instToFormatArray
- instToStreamArraySubarray
Converts a List α
into an Array α
.
O(|xs|)
. At runtime, this operation is implemented by List.toArrayImpl
and takes time linear in
the length of the list. List.toArray
should be used instead of Array.mk
.
Examples:
Constructs a new empty array with initial capacity c
.
This will be deprecated in favor of Array.emptyWithCapacity
in the future.
Constructs a new empty array with initial capacity 0
.
Use Array.emptyWithCapacity
to create an array with a greater initial capacity.
Equations
Gets the number of elements stored in an array.
This is a cached value, so it is O(1)
to access. The space allocated for an array, referred to as
its capacity, is at least as large as its size, but may be larger. The capacity of an array is an
internal detail that's not observable by Lean code.
Use the indexing notation a[i]
instead.
Access an element from an array without needing a runtime bounds checks,
using a Nat
index and a proof that it is in bounds.
This function does not use get_elem_tactic
to automatically find the proof that
the index is in bounds. This is because the tactic itself needs to look up values in
arrays.
Returns the element at the provided index, counting from 0
. Returns the fallback value v₀
if the
index is out of bounds.
To return an Option
depending on whether the index is in bounds, use a[i]?
. To panic if the
index is out of bounds, use a[i]!
.
Examples:
#["spring", "summer", "fall", "winter"].getD 2 "never" = "fall"
#["spring", "summer", "fall", "winter"].getD 0 "never" = "spring"
#["spring", "summer", "fall", "winter"].getD 4 "never" = "never"
Equations
- a.getD i v₀ = if h : i < a.size then a.getInternal i h else v₀
Use the indexing notation a[i]!
instead.
Access an element from an array, or panic if the index is out of bounds.
Equations
- a.get!Internal i = a.getD i default
Adds an element to the end of an array. The resulting array's size is one greater than the input array. If there are no other references to the array, then it is modified in-place.
This takes amortized O(1)
time because Array α
is represented by a dynamic array.
Examples:
Create array #[]
Equations
Create array #[a₁]
Equations
- #[a₁] = (Array.emptyWithCapacity 1).push a₁
Slower Array.append
used in quotations.
Equations
- as.appendCore bs = Array.appendCore.loop bs bs.size 0 as
Equations
- Array.appendCore.loop bs i j as = if hlt : j < bs.size then match i with | 0 => as | i'.succ => Array.appendCore.loop bs i' (j + 1) (as.push (bs.getInternal j hlt)) else as
Returns the slice of as
from indices start
to stop
(exclusive). The resulting array has size
(min stop as.size) - start
.
If start
is greater or equal to stop
, the result is empty. If stop
is greater than the size of
as
, the size is used instead.
Examples:
#[0, 1, 2, 3, 4].extract 1 3 = #[1, 2]
#[0, 1, 2, 3, 4].extract 1 30 = #[1, 2, 3, 4]
#[0, 1, 2, 3, 4].extract 0 0 = #[]
#[0, 1, 2, 3, 4].extract 2 1 = #[]
#[0, 1, 2, 3, 4].extract 2 2 = #[]
#[0, 1, 2, 3, 4].extract 2 3 = #[2]
#[0, 1, 2, 3, 4].extract 2 4 = #[2, 3]
Equations
- as.extract start stop = Array.extract.loop as ((min stop as.size).sub start) start (Array.emptyWithCapacity ((min stop as.size).sub start))
Equations
- Array.extract.loop as i j bs = if hlt : j < as.size then match i with | 0 => bs | i'.succ => Array.extract.loop as i' (j + 1) (bs.push (as.getInternal j hlt)) else bs
The >>=
operator is overloaded via instances of bind
.
Bind
is typically used via Monad
, which extends it.
- bind {α β : Type u} : m α → (α → m β) → m β
Sequences two computations, allowing the second to depend on the value computed by the first.
If
x : m α
andf : α → m β
, thenx >>= f : m β
represents the result of executingx
to get a value of typeα
and then passing it tof
.Conventions for notations in identifiers:
- The recommended spelling of
>>=
in identifiers isbind
.
- The recommended spelling of
A functor in the sense used in functional programming, which means a function f : Type u → Type v
has a way of mapping a function over its contents. This map
operator is written <$>
, and
overloaded via Functor
instances.
This map
function should respect identity and function composition. In other words, for all terms
v : f α
, it should be the case that:
id <$> v = v
For all functions
h : β → γ
andg : α → β
,(h ∘ g) <$> v = h <$> g <$> v
While all Functor
instances should live up to these requirements, they are not required to prove
that they do. Proofs may be required or provided via the LawfulFunctor
class.
Assuming that instances are lawful, this definition corresponds to the category-theoretic notion of functor in the special case where the category is the category of types and functions between them.
- map {α β : Type u} : (α → β) → f α → f β
Applies a function inside a functor. This is used to overload the
<$>
operator.When mapping a constant function, use
Functor.mapConst
instead, because it may be more efficient.Conventions for notations in identifiers:
- The recommended spelling of
<$>
in identifiers ismap
.
- The recommended spelling of
- mapConst {α β : Type u} : α → f β → f α
Mapping a constant function.
Given
a : α
andv : f α
,mapConst a v
is equivalent toFunction.const _ a <$> v
. For some functors, this can be implemented more efficiently; for all other functors, the default implementation may be used.
Instances
- Array.instFunctor
- Filter.instFunctor
- Functor.AddConst.functor
- Functor.Comp.functor
- Functor.Const.functor
- Lake.BuildJob.instFunctor
- Lake.EStateT.instFunctor
- Lake.EquipT.instFunctor
- Lake.Job.instFunctor
- Lake.instFunctorEResult
- List.instFunctor
- ReaderT.instFunctorOfMonad
- Set.instFunctor
- Ultrafilter.functor
- instFunctorOption
The <*>
operator is overloaded using the function Seq.seq
.
While <$>
from the class Functor
allows an ordinary function to be mapped over its contents,
<*>
allows a function that's “inside” the functor to be applied. When thinking about f
as
possible side effects, this captures evaluation order: seq
arranges for the effects that produce
the function to occur prior to those that produce the argument value.
For most applications, Applicative
or Monad
should be used rather than Seq
itself.
The implementation of the
<*>
operator.In a monad,
mf <*> mx
is the same asdo let f ← mf; x ← mx; pure (f x)
: it evaluates the function first, then the argument, and applies one to the other.To avoid surprising evaluation semantics,
mx
is taken "lazily", using aUnit → f α
function.Conventions for notations in identifiers:
- The recommended spelling of
<*>
in identifiers isseq
.
- The recommended spelling of
The <*
operator is overloaded using seqLeft
.
When thinking about f
as potential side effects, <*
evaluates first the left and then the right
argument for their side effects, discarding the value of the right argument and returning the value
of the left argument.
For most applications, Applicative
or Monad
should be used rather than SeqLeft
itself.
Sequences the effects of two terms, discarding the value of the second. This function is usually invoked via the
<*
operator.Given
x : f α
andy : f β
,x <* y
runsx
, then runsy
, and finally returns the result ofx
.The evaluation of the second argument is delayed by wrapping it in a function, enabling “short-circuiting” behavior from
f
.Conventions for notations in identifiers:
- The recommended spelling of
<*
in identifiers isseqLeft
.
- The recommended spelling of
Instances
The *>
operator is overloaded using seqRight
.
When thinking about f
as potential side effects, *>
evaluates first the left and then the right
argument for their side effects, discarding the value of the left argument and returning the value
of the right argument.
For most applications, Applicative
or Monad
should be used rather than SeqLeft
itself.
Sequences the effects of two terms, discarding the value of the first. This function is usually invoked via the
*>
operator.Given
x : f α
andy : f β
,x *> y
runsx
, then runsy
, and finally returns the result ofy
.The evaluation of the second argument is delayed by wrapping it in a function, enabling “short-circuiting” behavior from
f
.Conventions for notations in identifiers:
- The recommended spelling of
*>
in identifiers isseqRight
.
- The recommended spelling of
Instances
An applicative functor is more powerful than a Functor
, but
less powerful than a Monad
.
Applicative functors capture sequencing of effects with the <*>
operator, overloaded as seq
, but
not data-dependent effects. The results of earlier computations cannot be used to control later
effects.
Applicative functors should satisfy four laws. Instances of Applicative
are not required to prove
that they satisfy these laws, which are part of the LawfulApplicative
class.
Monads are an abstraction of sequential control flow and side effects used in functional programming. Monads allow both sequencing of effects and data-dependent effects: the values that result from an early step may influence the effects carried out in a later step.
The Monad
API may be used directly. However, it is most commonly accessed through
do
-notation.
Most Monad
instances provide implementations of pure
and bind
, and use default implementations
for the other methods inherited from Applicative
. Monads should satisfy certain laws, but
instances are not required to prove this. An instance of LawfulMonad
expresses that a given
monad's operations are lawful.
Instances
- Aesop.SearchM.instMonad
- Aesop.TreeM.instMonad
- Aesop.instMonadElabM
- Aesop.instMonadEqualUpToIdsM
- EStateM.instMonad
- Except.instMonad
- ExceptCpsT.instMonad
- ExceptT.instMonad
- Id.instMonad
- Lake.EStateT.instMonad
- Lake.EquipT.instMonad
- Lake.instMonadBaseIOTask
- Lake.instMonadTask_lake
- Lean.Compiler.LCNF.Simp.instMonadSimpM
- Lean.Compiler.LCNF.instMonadCompilerM
- Lean.Core.instMonadCoreM
- Lean.Elab.Command.instMonadCommandElabM
- Lean.Elab.Tactic.instMonadTacticM
- Lean.Elab.Term.instMonadTermElabM
- Lean.Meta.instMonadMetaM
- Lean.MonadCacheT.instMonad
- Lean.MonadStateCacheT.instMonad
- List.instMonad
- MLList.instMonad
- Nondet.instMonad
- OptionT.instMonad
- PFun.monad
- PLift.instMonad_mathlib
- Part.instMonad
- ReaderT.instMonad
- StateCpsT.instMonad
- StateRefT'.instMonad
- StateT.instMonad
- Std.Internal.Parsec.instMonad
- Sum.instMonad_mathlib
- Trunc.instMonad
- ULift.instMonad_mathlib
- Ultrafilter.monad
- WithOne.instMonad
- WithZero.instMonad
- instMonadBaseIO
- instMonadEIO
- instMonadEST
- instMonadOption
- instMonadST
Computations in the monad m
can be run in the monad n
. These translations are inserted
automatically by the compiler.
Usually, n
consists of some number of monad transformers applied to m
, but this is not
mandatory.
New instances should use this class, MonadLift
. Clients that require one monad to be liftable into
another should instead request MonadLiftT
, which is the reflexive, transitive closure of
MonadLift
.
- monadLift {α : Type u} : m α → n α
Translates an action from monad
m
into monadn
.
Instances
- Aesop.SearchM.instMonadLiftTreeM
- ExceptCpsT.instMonadLiftOfMonad
- ExceptT.instMonadLift
- ExceptT.instMonadLiftExcept
- IO.instMonadLiftSTRealWorldBaseIO
- Lake.EStateT.instMonadLiftOfMonad
- Lake.EquipT.instMonadLift
- Lake.instMonadLiftFetchMJobM
- Lake.instMonadLiftIOLogIO
- Lake.instMonadLiftIOLoggerIO
- Lake.instMonadLiftJobMFetchM
- Lake.instMonadLiftLakeMBuildTOfPure
- Lake.instMonadLiftLogIOJobM
- Lake.instMonadLiftLogIOLoggerIO
- Lake.instMonadLiftSpawnMJobM
- Lean.Core.instMonadLiftIOCoreM
- Lean.IR.NormalizeIds.instMonadLiftMN
- Lean.Language.Lean.instMonadLiftLeanProcessingMLeanProcessingTIO
- Lean.Language.Lean.instMonadLiftProcessingTLeanProcessingT
- Lean.Language.instMonadLiftProcessingMProcessingTIO
- Lean.MonadCacheT.instMonadLift
- Lean.MonadStateCacheT.instMonadLift
- Lean.Server.instMonadLiftCancellableMRequestM
- Lean.Server.instMonadLiftEIOExceptionRequestM
- Lean.Server.instMonadLiftIORequestM
- Lean.instMonadLiftImportMAttrM
- MLList.instMonadLiftOfMonad
- Nondet.instMonadLift
- OptionT.instMonadLift
- Qq.Impl.instMonadLiftQuoteMUnquoteM
- Qq.Impl.instMonadLiftUnquoteMStateTUnquoteStateDelabM
- ReaderT.instMonadLift
- StateCpsT.instMonadLiftOfMonad
- StateRefT'.instMonadLift
- StateT.instMonadLift
- Std.CloseableChannel.instMonadLiftEIOErrorIO
- instMonadLiftBaseIOEIO
- instMonadLiftSTEST
Computations in the monad m
can be run in the monad n
. These translations are inserted
automatically by the compiler.
Usually, n
consists of some number of monad transformers applied to m
, but this is not
mandatory.
This is the reflexive, transitive closure of MonadLift
. Clients that require one monad to be
liftable into another should request an instance of MonadLiftT
. New instances should instead be
defined for MonadLift
itself.
- monadLift {α : Type u} : m α → n α
Translates an action from monad
m
into monadn
.
Instances
- Lake.instMonadLiftTEIOOfMonadOfMonadExceptOfOfBaseIO_lake
- Lake.instMonadLiftTExceptOfPureOfMonadExceptOf_lake
- Lake.instMonadLiftTExceptTOfMonadOfMonadExceptOf_lake
- Lake.instMonadLiftTIdOfPure_lake
- Lake.instMonadLiftTOfMonadLift_lake
- Lake.instMonadLiftTOptionOfAlternative_lake
- Lake.instMonadLiftTOptionTOfMonadOfAlternative_lake
- Lake.instMonadLiftTReaderTOfBindOfMonadReaderOf_lake
- Lake.instMonadLiftTStateTOfMonadOfMonadStateOf_lake
- Lean.Elab.Command.instMonadLiftTIOCommandElabM
- Plausible.instMonadLiftTRandGTOfMonadLift
- instMonadLiftT
- instMonadLiftTOfMonadLift
Equations
- instMonadLiftTOfMonadLift m n o = { monadLift := fun {α : Type ?u.30} (x : m α) => MonadLift.monadLift (monadLift x) }
Equations
- instMonadLiftT m = { monadLift := fun {α : Type ?u.10} (x : m α) => x }
Typeclass used for adapting monads. This is similar to MonadLift
, but instances are allowed to
make use of default state for the purpose of synthesizing such an instance, if necessary.
Every MonadLift
instance gives a MonadEval
instance.
The purpose of this class is for the #eval
command,
which looks for a MonadEval m CommandElabM
or MonadEval m IO
instance.
- monadEval {α : Type u} : m α → n α
Evaluates a value from monad
m
into monadn
.
Equations
- instMonadEvalOfMonadLift = { monadEval := fun {α : Type ?u.19} => MonadLift.monadLift }
Equations
- instMonadEvalTOfMonadEval m n o = { monadEval := fun {α : Type ?u.30} (x : m α) => MonadEval.monadEval (MonadEvalT.monadEval x) }
Equations
- instMonadEvalT m = { monadEval := fun {α : Type ?u.10} (x : m α) => x }
A way to interpret a fully-polymorphic function in m
into n
. Such a function can be thought of
as one that may change the effects in m
, but can't do so based on specific values that are
provided.
Clients of MonadFunctor
should typically use MonadFunctorT
, which is the reflexive, transitive
closure of MonadFunctor
. New instances should be defined for MonadFunctor.
Lifts a fully-polymorphic transformation of
m
inton
.
A way to interpret a fully-polymorphic function in m
into n
. Such a function can be thought of
as one that may change the effects in m
, but can't do so based on specific values that are
provided.
This is the reflexive, transitive closure of MonadFunctor
. It automatically chains together
MonadFunctor
instances as needed. Clients of MonadFunctor
should typically use MonadFunctorT
,
but new instances should be defined for MonadFunctor
.
Lifts a fully-polymorphic transformation of
m
inton
.
Equations
- One or more equations did not get rendered due to their size.
Except ε α
is a type which represents either an error of type ε
or a successful result with a
value of type α
.
Except ε : Type u → Type v
is a Monad
that represents computations that may throw exceptions:
the pure
operation is Except.ok
and the bind
operation returns the first encountered
Except.error
.
Equations
- instInhabitedExcept = { default := Except.error default }
Exception monads provide the ability to throw errors and handle errors.
In this class, ε
is a semiOutParam
, which means that it can influence the choice of instance.
MonadExcept ε
provides the same operations, but requires that ε
be inferrable from m
.
tryCatchThe
, which takes an explicit exception type, is used to desugar try ... catch ...
steps
inside do
-blocks when the handlers have type annotations.
- throw {α : Type v} : ε → m α
Throws an exception of type
ε
to the nearest enclosingcatch
. Catches errors thrown in
body
, passing them tohandler
. Errors inhandler
are not caught.
Instances
- EStateM.instMonadExceptOfOfBacktrackable
- ExceptCpsT.instMonadExceptOf
- Lake.EStateT.instMonadExceptOfOfMonad
- Lake.EquipT.instMonadExceptOf
- Lean.Elab.Command.instMonadExceptOfExceptionCommandElabM
- Lean.MonadCacheT.instMonadExceptOf
- Lean.MonadStateCacheT.instMonadExceptOf
- Lean.instMonadExceptOfExceptionCoreM
- OptionT.instMonadExceptOf
- OptionT.instMonadExceptOfUnit
- ReaderT.instMonadExceptOf
- StateRefT'.instMonadExceptOf
- StateT.instMonadExceptOf
- instMonadExceptOfEIO
- instMonadExceptOfEST
- instMonadExceptOfExcept
- instMonadExceptOfExceptT
- instMonadExceptOfExceptTOfMonad
- instMonadExceptOfUnitOption
Throws an exception, with the exception type specified explicitly. This is useful when a monad supports throwing more than one type of exception.
Use throw
for a version that expects the exception type to be inferred from m
.
Equations
- throwThe ε e = MonadExceptOf.throw e
Catches errors, recovering using handle
. The exception type is specified explicitly. This is useful when a monad
supports throwing or handling more than one type of exception.
Use tryCatch
, for a version that expects the exception type to be inferred from m
.
Equations
- tryCatchThe ε x handle = MonadExceptOf.tryCatch x handle
Exception monads provide the ability to throw errors and handle errors.
In this class, ε
is an outParam
, which means that it is inferred from m
. MonadExceptOf ε
provides the same operations, but allows ε
to influence instance synthesis.
MonadExcept.tryCatch
is used to desugar try ... catch ...
steps inside do
-blocks when the
handlers do not have exception type annotations.
- throw {α : Type v} : ε → m α
Throws an exception of type
ε
to the nearest enclosing handler. Catches errors thrown in
body
, passing them tohandler
. Errors inhandler
are not caught.
Re-interprets an Except ε
action in an exception monad m
, succeeding if it succeeds and throwing
an exception if it throws an exception.
Equations
- instMonadExceptOfMonadExceptOf ε m = { throw := fun {α : Type ?u.18} => throwThe ε, tryCatch := fun {α : Type ?u.18} => tryCatchThe ε }
Unconditional error recovery that ignores which exception was thrown. Usually used via the <|>
operator.
If both computations throw exceptions, then the result is the second exception.
Equations
- MonadExcept.orElse t₁ t₂ = tryCatch t₁ fun (x : ε) => t₂ ()
Equations
- MonadExcept.instOrElse = { orElse := MonadExcept.orElse }
Adds the ability to access a read-only value of type ρ
to a monad. The value can be locally
overridden by withReader
, but it cannot be mutated.
Actions in the resulting monad are functions that take the local value as a parameter, returning
ordinary actions in m
.
Instances For
- Aesop.instMonadStatsReaderT
- Lake.instMonadLiftTReaderTOfBindOfMonadReaderOf_lake
- Lean.Compiler.LCNF.instMonadCodeBindReaderT
- Lean.instMonadAlwaysExceptReaderT
- Lean.instMonadCacheReaderT
- Lean.instMonadRecDepthReaderT
- Lean.instMonadRuntimeExceptionReaderT
- ReaderT.instAlternativeOfMonad
- ReaderT.instApplicativeOfMonad
- ReaderT.instFunctorOfMonad
- ReaderT.instLawfulApplicative
- ReaderT.instLawfulFunctor
- ReaderT.instLawfulMonad
- ReaderT.instMonad
- ReaderT.instMonadExceptOf
- ReaderT.instMonadFunctor
- ReaderT.instMonadLift
- ReaderT.tryFinally
- instInhabitedReaderT
- instMonadControlReaderT
- instMonadReaderOfReaderTOfMonad
- instMonadWithReaderOfReaderT
Equations
- One or more equations did not get rendered due to their size.
Sequences two reader monad computations. Both are provided with the local value, and the second is
passed the value of the first. Typically used via the >>=
operator.
Equations
- One or more equations did not get rendered due to their size.
Equations
- ReaderT.instMonad = { toApplicative := ReaderT.instApplicativeOfMonad, bind := fun {α β : Type ?u.19} => ReaderT.bind }
Modifies a reader monad's local value with f
. The resulting computation applies f
to the
incoming local value and passes the result to the inner computation.
Equations
- ReaderT.adapt f x r = x (f r)
Reader monads provide the ability to implicitly thread a value through a computation. The value can
be read, but not written. A MonadWithReader ρ
instance additionally allows the value to be locally
overridden for a sub-computation.
In this class, ρ
is a semiOutParam
, which means that it can influence the choice of instance.
MonadReader ρ
provides the same operations, but requires that ρ
be inferrable from m
.
- read : m ρ
Retrieves the local value.
Reader monads provide the ability to implicitly thread a value through a computation. The value can
be read, but not written. A MonadWithReader ρ
instance additionally allows the value to be locally
overridden for a sub-computation.
In this class, ρ
is an outParam
, which means that it is inferred from m
. MonadReaderOf ρ
provides the same operations, but allows ρ
to influence instance synthesis.
- read : m ρ
Retrieves the local value.
Use
readThe
to explicitly specify a type when more than one value is available.
Retrieves the local value whose type is ρ
. This is useful when a monad supports reading more that
one type of value.
Use read
for a version that expects the type ρ
to be inferred from m
.
Equations
Equations
- instMonadReaderOfMonadReaderOf ρ m = { read := readThe ρ }
Equations
- instMonadReaderOfReaderTOfMonad = { read := ReaderT.read }
A reader monad that additionally allows the value to be locally overridden.
In this class, ρ
is a semiOutParam
, which means that it can influence the choice of instance.
MonadWithReader ρ
provides the same operations, but requires that ρ
be inferrable from m
.
Locally modifies the reader monad's value while running an action.
During the inner action
x
, reading the value returnsf
applied to the original value. After control returns fromx
, the reader monad's value is restored.
Locally modifies the reader monad's value while running an action, with the reader monad's local value type specified explicitly. This is useful when a monad supports reading more than one type of value.
During the inner action x
, reading the value returns f
applied to the original value. After
control returns from x
, the reader monad's value is restored.
Use withReader
for a version that expects the local value's type to be inferred from m
.
Equations
- withTheReader ρ f x = MonadWithReaderOf.withReader f x
A reader monad that additionally allows the value to be locally overridden.
In this class, ρ
is an outParam
, which means that it is inferred from m
. MonadWithReaderOf ρ
provides the same operations, but allows ρ
to influence instance synthesis.
- withReader {α : Type u} : (ρ → ρ) → m α → m α
Locally modifies the reader monad's value while running an action.
During the inner action
x
, reading the value returnsf
applied to the original value. After control returns fromx
, the reader monad's value is restored.
Equations
- instMonadWithReaderOfMonadWithReaderOf ρ m = { withReader := fun {α : Type ?u.17} => withTheReader ρ }
Equations
- instMonadWithReaderOfOfMonadFunctor = { withReader := fun {α : Type ?u.28} (f : ρ → ρ) => monadMap fun {β : Type ?u.28} => withTheReader ρ f }
State monads provide a value of a given type (the state) that can be retrieved or replaced.
Instances may implement these operations by passing state values around, by using a mutable
reference cell (e.g. ST.Ref σ
), or in other ways.
In this class, σ
is a semiOutParam
, which means that it can influence the choice of instance.
MonadState σ
provides the same operations, but requires that σ
be inferrable from m
.
The mutable state of a state monad is visible between multiple do
-blocks or functions, unlike
local mutable state in do
-notation.
- get : m σ
Retrieves the current value of the monad's mutable state.
- set : σ → m PUnit
Replaces the current value of the mutable state with a new one.
Applies a function to the current state that both computes a new state and a value. The new state replaces the current state, and the value is returned.
It is equivalent to
do let (a, s) := f (← get); set s; pure a
. However, usingmodifyGet
may lead to higher performance because it doesn't add a new reference to the state value. Additional references can inhibit in-place updates of data.
Instances
- Aesop.TreeM.instMonadStateOfTree
- EStateM.instMonadStateOf
- Lake.EStateT.instMonadStateOfOfPure
- Lake.instMonadStateOfJobStateJobM
- Lake.instMonadStateOfLogJobM
- Lean.PrettyPrinter.Delaborator.instMonadStateOfHoleIteratorDelabM
- StateCpsT.instMonadStateOf
- StateRefT'.instMonadStateOfOfMonadLiftTST
- instMonadStateOfOfMonadLift
- instMonadStateOfStateTOfMonad
Gets the current state that has the explicitly-provided type σ
. When the current monad has
multiple state types available, this function selects one of them.
Equations
Mutates the current state that has the explicitly-provided type σ
, replacing its value with the
result of applying f
to it. When the current monad has multiple state types available, this
function selects one of them.
It is equivalent to do set (f (← get))
. However, using modify
may lead to higher performance
because it doesn't add a new reference to the state value. Additional references can inhibit
in-place updates of data.
Equations
- modifyThe σ f = MonadStateOf.modifyGet fun (s : σ) => (PUnit.unit, f s)
Applies a function to the current state that has the explicitly-provided type σ
. The function both
computes a new state and a value. The new state replaces the current state, and the value is
returned.
It is equivalent to do let (a, s) := f (← getThe σ); set s; pure a
. However, using modifyGetThe
may lead to higher performance because it doesn't add a new reference to the state value. Additional
references can inhibit in-place updates of data.
Equations
State monads provide a value of a given type (the state) that can be retrieved or replaced.
Instances may implement these operations by passing state values around, by using a mutable
reference cell (e.g. ST.Ref σ
), or in other ways.
In this class, σ
is an outParam
, which means that it is inferred from m
. MonadStateOf σ
provides the same operations, but allows σ
to influence instance synthesis.
The mutable state of a state monad is visible between multiple do
-blocks or functions, unlike
local mutable state in do
-notation.
- get : m σ
Retrieves the current value of the monad's mutable state.
- set : σ → m PUnit
Replaces the current value of the mutable state with a new one.
Applies a function to the current state that both computes a new state and a value. The new state replaces the current state, and the value is returned.
It is equivalent to
do let (a, s) := f (← get); set s; pure a
. However, usingmodifyGet
may lead to higher performance because it doesn't add a new reference to the state value. Additional references can inhibit in-place updates of data.
Equations
- instMonadStateOfMonadStateOf σ m = { get := getThe σ, set := set, modifyGet := fun {α : Type ?u.19} (f : σ → α × σ) => MonadStateOf.modifyGet f }
Mutates the current state, replacing its value with the result of applying f
to it.
Use modifyThe
to explicitly select a state type to modify.
It is equivalent to do set (f (← get))
. However, using modify
may lead to higher performance
because it doesn't add a new reference to the state value. Additional references can inhibit
in-place updates of data.
Equations
- EStateM.instInhabitedResult = { default := EStateM.Result.error default default }
A combined state and exception monad in which exceptions do not automatically roll back the state.
Instances of EStateM.Backtrackable
provide a way to roll back some part of the state if needed.
EStateM ε σ
is equivalent to ExceptT ε (StateM σ)
, but it is more efficient.
Equations
- EStateM ε σ α = (σ → EStateM.Result ε σ α)
Equations
- EStateM.instInhabited = { default := fun (s : σ) => EStateM.Result.error default s }
Returns a value without modifying the state or throwing an exception.
Equations
- EStateM.pure a s = EStateM.Result.ok a s
Replaces the current value of the mutable state with a new one.
Equations
- EStateM.set s x✝ = EStateM.Result.ok PUnit.unit s
Retrieves the current value of the monad's mutable state.
Equations
- EStateM.get s = EStateM.Result.ok s s
Applies a function to the current state that both computes a new state and a value. The new state replaces the current state, and the value is returned.
It is equivalent to do let (a, s) := f (← get); set s; pure a
. However, using modifyGet
may
lead to higher performance because it doesn't add a new reference to the state value. Additional
references can inhibit in-place updates of data.
Equations
- EStateM.modifyGet f s = match f s with | (a, s) => EStateM.Result.ok a s
Throws an exception of type ε
to the nearest enclosing handler.
Equations
- EStateM.throw e s = EStateM.Result.error e s
Exception handlers in EStateM
save some part of the state, determined by δ
, and restore it if an
exception is caught. By default, δ
is Unit
, and no information is saved.
- save : σ → δ
Extracts the information in the state that should be rolled back if an exception is handled.
- restore : σ → δ → σ
Updates the current state with the saved information that should be rolled back. This updated state becomes the current state when an exception is handled.
Instances
Handles exceptions thrown in the combined error and state monad.
The Backtrackable δ σ
instance is used to save a snapshot of part of the state prior to running
x
. If an exception is caught, the state is updated with the saved snapshot, rolling back part of
the state. If no instance of Backtrackable
is provided, a fallback instance in which δ
is Unit
is used, and no information is rolled back.
Equations
- x.tryCatch handle s = match x s with | EStateM.Result.error e s_1 => handle e (EStateM.Backtrackable.restore s_1 (EStateM.Backtrackable.save s)) | ok => ok
Failure handling that does not depend on specific exception values.
The Backtrackable δ σ
instance is used to save a snapshot of part of the state prior to running
x₁
. If an exception is caught, the state is updated with the saved snapshot, rolling back part of
the state. If no instance of Backtrackable
is provided, a fallback instance in which δ
is Unit
is used, and no information is rolled back.
Equations
- x₁.orElse x₂ s = match x₁ s with | EStateM.Result.error a s_1 => x₂ () (EStateM.Backtrackable.restore s_1 (EStateM.Backtrackable.save s)) | ok => ok
Transforms exceptions with a function, doing nothing on successful results.
Equations
- EStateM.adaptExcept f x s = match x s with | EStateM.Result.error e s => EStateM.Result.error (f e) s | EStateM.Result.ok a s => EStateM.Result.ok a s
Sequences two EStateM ε σ
actions, passing the returned value from the first into the second.
Equations
- x.bind f s = match x s with | EStateM.Result.ok a s => f a s | EStateM.Result.error e s => EStateM.Result.error e s
Transforms the value returned from an EStateM ε σ
action using a function.
Equations
- EStateM.map f x s = match x s with | EStateM.Result.ok a s => EStateM.Result.ok (f a) s | EStateM.Result.error e s => EStateM.Result.error e s
Sequences two EStateM ε σ
actions, running x
before y
. The first action's return value is
ignored.
Equations
- x.seqRight y s = match x s with | EStateM.Result.ok a s => y () s | EStateM.Result.error e s => EStateM.Result.error e s
Equations
- One or more equations did not get rendered due to their size.
Equations
- EStateM.instOrElseOfBacktrackable = { orElse := EStateM.orElse }
Equations
- EStateM.instMonadStateOf = { get := EStateM.get, set := EStateM.set, modifyGet := fun {α : Type ?u.12} => EStateM.modifyGet }
Equations
- EStateM.instMonadExceptOfOfBacktrackable = { throw := fun {α : Type ?u.23} => EStateM.throw, tryCatch := fun {α : Type ?u.23} => EStateM.tryCatch }
Executes an EStateM
with the initial state s
for the returned value α
, discarding the final
state. Returns none
if an unhandled exception was thrown.
Equations
- x.run' s = match x.run s with | EStateM.Result.ok v a => some v | EStateM.Result.error a a_1 => none
The restore
implementation for Backtrackable PUnit σ
.
Equations
- EStateM.dummyRestore s x✝ = s
A fallback Backtrackable
instance that saves no information from a state. This allows every type
to be used as a state in EStateM
, with no rollback.
Because this is the first declared instance of Backtrackable _ σ
, it will be picked only if there
are no other Backtrackable _ σ
instances registered.
Equations
- EStateM.nonBacktrackable = { save := EStateM.dummySave, restore := EStateM.dummyRestore }
Types that can be hashed into a UInt64
.
Instances
- Aesop.ForwardRule.instHashable
- Aesop.Goal.instHashable
- Aesop.GoalId.instHashable
- Aesop.Hyp.instHashable
- Aesop.IndexMatchLocation.instHashable
- Aesop.LocalNormSimpRule.instHashable
- Aesop.Match.instHashable
- Aesop.NormSimpRule.instHashable
- Aesop.Rapp.instHashable
- Aesop.RappId.instHashable
- Aesop.Rule.instHashable
- Aesop.RuleName.instHashable
- Aesop.Substitution.instHashable
- Aesop.UnfoldRule.instHashable
- Aesop.instHashableBuilderName
- Aesop.instHashableCompleteMatch
- Aesop.instHashableDisplayRuleName
- Aesop.instHashableForwardRuleMatch
- Aesop.instHashableLevelIndex
- Aesop.instHashablePINF
- Aesop.instHashablePINFRaw
- Aesop.instHashablePatSubstSource
- Aesop.instHashablePhaseName
- Aesop.instHashablePremiseIndex
- Aesop.instHashableRawHyp
- Aesop.instHashableScopeName
- Aesop.instHashableSlotIndex
- BitVec.instHashable
- ByteArray.instHashable
- Lake.instHashableBuildKey
- Lake.instHashableConfigTarget
- Lake.instHashableModule
- Lake.instHashablePackage
- Lean.Compiler.LCNF.FixedParams.instHashableAbsValue
- Lean.Compiler.LCNF.FloatLetIn.instHashableDecision
- Lean.Compiler.LCNF.instHashableArg
- Lean.Compiler.LCNF.instHashableCode
- Lean.Compiler.LCNF.instHashableDecl
- Lean.Compiler.LCNF.instHashableDeclValue
- Lean.Compiler.LCNF.instHashableLetValue
- Lean.Compiler.LCNF.instHashableLitValue
- Lean.Compiler.LCNF.instHashableParam
- Lean.Compiler.instHashableInlineAttributeKind
- Lean.Diff.instHashableAction
- Lean.Elab.Tactic.instHashableCacheKey
- Lean.Expr.instHashable
- Lean.ExprStructEq.instHashable
- Lean.Grind.CommRing.instHashableExpr
- Lean.Grind.CommRing.instHashableMon
- Lean.Grind.CommRing.instHashablePoly
- Lean.Grind.CommRing.instHashablePower
- Lean.IR.Borrow.OwnedSet.instHashableKey
- Lean.IR.Borrow.ParamMap.instHashableKey
- Lean.IR.instHashableJoinPointId
- Lean.IR.instHashableVarId
- Lean.Json.instHashable
- Lean.Level.instHashable
- Lean.Lsp.instHashableCallHierarchyItem
- Lean.Lsp.instHashableCompletionItem
- Lean.Lsp.instHashableCompletionItemKind
- Lean.Lsp.instHashableCompletionItemTag
- Lean.Lsp.instHashableInsertReplaceEdit
- Lean.Lsp.instHashableMarkupContent
- Lean.Lsp.instHashableMarkupKind
- Lean.Lsp.instHashablePosition
- Lean.Lsp.instHashableRange
- Lean.Lsp.instHashableRefIdent
- Lean.Lsp.instHashableRpcRef
- Lean.Lsp.instHashableSemanticTokenType
- Lean.Lsp.instHashableSymbolKind
- Lean.Lsp.instHashableSymbolTag
- Lean.Meta.Canonicalizer.instHashableExprVisited
- Lean.Meta.DiscrTree.instHashableKey
- Lean.Meta.Ext.instHashableExtTheorem
- Lean.Meta.FunInd.instHashableCall
- Lean.Meta.Grind.Arith.Cutsat.instHashableExpr_lean
- Lean.Meta.Grind.Arith.Cutsat.instHashableExpr_lean_1
- Lean.Meta.Grind.Arith.Cutsat.instHashableForeignType
- Lean.Meta.Grind.Arith.Cutsat.instHashablePoly_lean
- Lean.Meta.Grind.instHashableCongrKey
- Lean.Meta.Grind.instHashableCongrTheoremCacheKey
- Lean.Meta.Grind.instHashableEMatchTheoremKind
- Lean.Meta.Grind.instHashableEMatchTheoremTrace
- Lean.Meta.Grind.instHashableENodeKey
- Lean.Meta.Grind.instHashableOrigin
- Lean.Meta.Grind.instHashablePreInstance
- Lean.Meta.Grind.instHashableSplitInfo
- Lean.Meta.LazyDiscrTree.Key.instHashable
- Lean.Meta.LibrarySearch.instHashableDeclMod
- Lean.Meta.TransparencyMode.instHashable_lean
- Lean.Meta.instHashableDefEqCacheKey
- Lean.Meta.instHashableExprConfigCacheKey
- Lean.Meta.instHashableInfoCacheKey
- Lean.Meta.instHashableOrigin
- Lean.Meta.instHashableSynthInstanceCacheKey
- Lean.Parser.instHashableParserCacheKey
- Lean.Server.FileWorker.instHashableAbsoluteLspSemanticToken
- Lean.instHashableBinderInfo
- Lean.instHashableExternAttrData
- Lean.instHashableExternEntry
- Lean.instHashableFVarId
- Lean.instHashableHeadIndex
- Lean.instHashableJsonNumber
- Lean.instHashableLevelMVarId
- Lean.instHashableLiteral
- Lean.instHashableLocalDeclKind
- Lean.instHashableLocalInstance
- Lean.instHashableMVarId
- Lean.instHashableName
- Lean.instHashablePtr
- Mathlib.AssertNotExist.instHashableAssertExists
- Mathlib.Linter.Flexible.instHashableStained
- Mathlib.StacksTag.instHashableDatabase
- Mathlib.StacksTag.instHashableTag
- Mathlib.Tactic.CC.instHashableCCCongrTheoremKey
- Mathlib.Tactic.CC.instHashableCongruencesKey
- Mathlib.Tactic.CC.instHashableSymmCongruencesKey
- Qq.instHashableQuoted
- Std.CloseableChannel.instHashableError
- Std.Sat.AIG.instHashableDecl
- Std.Sat.AIG.instHashableFanin
- Std.Tactic.BVDecide.BVExpr.instHashable
- Std.Tactic.BVDecide.BVExpr.instHashableKey
- Std.Tactic.BVDecide.LRAT.Internal.instHashablePosFin
- Std.Tactic.BVDecide.instHashableBVBinOp
- Std.Tactic.BVDecide.instHashableBVBit
- Std.Tactic.BVDecide.instHashableBVUnOp
- String.instHashableRange
- System.instHashableFilePath
- instHashable
- instHashableArray
- instHashableBool
- instHashableByteArray
- instHashableChar
- instHashableFin
- instHashableISize
- instHashableInt
- instHashableInt16
- instHashableInt32
- instHashableInt64
- instHashableInt8
- instHashableList
- instHashableNat
- instHashableOption
- instHashablePEmpty
- instHashablePUnit
- instHashablePos
- instHashableProd
- instHashableString
- instHashableSubtype
- instHashableUInt16
- instHashableUInt32
- instHashableUInt64
- instHashableUInt8
- instHashableUSize
Computes a hash for strings.
Equations
- instHashableString = { hash := String.hash }
Hierarchical names consist of a sequence of components, each of
which is either a string or numeric, that are written separated by dots (.
).
Hierarchical names are used to name declarations and for creating unique identifiers for free variables and metavariables.
You can create hierarchical names using a backtick:
`Lean.Meta.whnf
It is short for .str (.str (.str .anonymous "Lean") "Meta") "whnf"
.
You can use double backticks to request Lean to statically check whether the name corresponds to a Lean declaration in scope.
``Lean.Meta.whnf
If the name is not in scope, Lean will report an error.
There are two ways to convert a String
to a Name
:
Name.mkSimple
creates a name with a single string component.String.toName
first splits the string into its dot-separated components, and then creates a hierarchical name.
- anonymous : Name
The "anonymous" name.
- str (pre : Name) (str : String) : Name
- num (pre : Name) (i : Nat) : Name
Instances For
- Lake.LeanExeConfig.root.instConfigField
- Lake.Name.instLawfulCmpEqNameQuickCmp
- Lake.Name.instLawfulCmpEqNameQuickCmpAux
- Lake.instCoeDepNameModuleFacetOfFamilyOutFacetOut
- Lake.instCoeNameGlob
- Lake.instCoeOutOptDataKindName
- Lake.instMonadStoreNameStateRefT'NameMapOfMonadLiftTSTOfMonad
- Lake.instMonadStoreNameStateTNameMapOfMonad
- Lean.KVMap.instValueName
- Lean.MessageData.instCoeName
- Lean.Meta.instReduceEvalName
- Lean.Name.instBEq
- Lean.Name.instLawfulBEq
- Lean.Name.instRepr
- Lean.Name.instToString
- Lean.NameSet.instForInName
- Lean.NameSet.instSingletonName_batteries
- Lean.instAppendName
- Lean.instCoeNameDataValue
- Lean.instCoeNameImport
- Lean.instFromJsonName
- Lean.instHashableName
- Lean.instInhabitedName
- Lean.instQuoteNameMkStr1
- Lean.instSizeOfName
- Lean.instToExprName
- Lean.instToFormatName_lean
- Lean.instToJsonName
- Lean.instToMessageDataName
A hash function for names, which is stored inside the name itself as a computed field.
Equations
- Lean.Name.anonymous.hash = UInt64.ofNatLT 1723 Lean.Name.hash._proof_40
- (p.str s).hash = mixHash p.hash s.hash
- (p.num v).hash = mixHash p.hash (if h : v < UInt64.size then UInt64.ofNatLT v h else UInt64.ofNatLT 17 Lean.Name.hash._proof_41)
Equations
- Lean.instInhabitedName = { default := Lean.Name.anonymous }
Equations
- Lean.instHashableName = { hash := Lean.Name.hash }
Make name s₁
Equations
Instances For
- Lake.InputDirConfig.filter.instConfigField
- Lake.InputDirConfig.path.instConfigField
- Lake.InputDirConfig.text.instConfigField
- Lake.InputFileConfig.path.instConfigField
- Lake.InputFileConfig.text.instConfigField
- Lake.LeanConfig.backend.instConfigField
- Lake.LeanConfig.buildType.instConfigField
- Lake.LeanConfig.dynlibs.instConfigField
- Lake.LeanConfig.leanOptions.instConfigField
- Lake.LeanConfig.moreLeanArgs.instConfigField
- Lake.LeanConfig.moreLeancArgs.instConfigField
- Lake.LeanConfig.moreLinkArgs.instConfigField
- Lake.LeanConfig.moreLinkLibs.instConfigField
- Lake.LeanConfig.moreLinkObjs.instConfigField
- Lake.LeanConfig.moreServerOptions.instConfigField
- Lake.LeanConfig.platformIndependent.instConfigField
- Lake.LeanConfig.plugins.instConfigField
- Lake.LeanConfig.weakLeanArgs.instConfigField
- Lake.LeanConfig.weakLeancArgs.instConfigField
- Lake.LeanConfig.weakLinkArgs.instConfigField
- Lake.LeanExeConfig.exeName.instConfigField
- Lake.LeanExeConfig.extraDepTargets.instConfigField
- Lake.LeanExeConfig.nativeFacets.instConfigField
- Lake.LeanExeConfig.needs.instConfigField
- Lake.LeanExeConfig.root.instConfigField
- Lake.LeanExeConfig.srcDir.instConfigField
- Lake.LeanExeConfig.supportInterpreter.instConfigField
- Lake.LeanLibConfig.defaultFacets.instConfigField
- Lake.LeanLibConfig.extraDepTargets.instConfigField
- Lake.LeanLibConfig.globs.instConfigField
- Lake.LeanLibConfig.libName.instConfigField
- Lake.LeanLibConfig.nativeFacets.instConfigField
- Lake.LeanLibConfig.needs.instConfigField
- Lake.LeanLibConfig.precompileModules.instConfigField
- Lake.LeanLibConfig.roots.instConfigField
- Lake.LeanLibConfig.srcDir.instConfigField
- Lake.PackageConfig.binDir.instConfigField
- Lake.PackageConfig.bootstrap.instConfigField
- Lake.PackageConfig.buildArchive.instConfigField
- Lake.PackageConfig.buildArchive?.instConfigField
- Lake.PackageConfig.buildDir.instConfigField
- Lake.PackageConfig.description.instConfigField
- Lake.PackageConfig.extraDepTargets.instConfigField
- Lake.PackageConfig.homepage.instConfigField
- Lake.PackageConfig.irDir.instConfigField
- Lake.PackageConfig.keywords.instConfigField
- Lake.PackageConfig.leanLibDir.instConfigField
- Lake.PackageConfig.license.instConfigField
- Lake.PackageConfig.licenseFiles.instConfigField
- Lake.PackageConfig.lintDriver.instConfigField
- Lake.PackageConfig.lintDriverArgs.instConfigField
- Lake.PackageConfig.manifestFile.instConfigField
- Lake.PackageConfig.moreGlobalServerArgs.instConfigField
- Lake.PackageConfig.moreServerArgs.instConfigField
- Lake.PackageConfig.nativeLibDir.instConfigField
- Lake.PackageConfig.precompileModules.instConfigField
- Lake.PackageConfig.preferReleaseBuild.instConfigField
- Lake.PackageConfig.readmeFile.instConfigField
- Lake.PackageConfig.releaseRepo.instConfigField
- Lake.PackageConfig.releaseRepo?.instConfigField
- Lake.PackageConfig.reservoir.instConfigField
- Lake.PackageConfig.srcDir.instConfigField
- Lake.PackageConfig.testDriver.instConfigField
- Lake.PackageConfig.testDriverArgs.instConfigField
- Lake.PackageConfig.testRunner.instConfigField
- Lake.PackageConfig.version.instConfigField
- Lake.PackageConfig.versionTags.instConfigField
- Lake.WorkspaceConfig.packagesDir.instConfigField
- Lake.instFamilyDefNameDataTypeMkStr1Bool
- Lake.instFamilyDefNameDataTypeMkStr1Dynlib
- Lake.instFamilyDefNameDataTypeMkStr1ExternLib
- Lake.instFamilyDefNameDataTypeMkStr1FilePath
- Lake.instFamilyDefNameDataTypeMkStr1InputDir
- Lake.instFamilyDefNameDataTypeMkStr1InputFile
- Lake.instFamilyDefNameDataTypeMkStr1LeanExe
- Lake.instFamilyDefNameDataTypeMkStr1LeanLib
- Lake.instFamilyDefNameDataTypeMkStr1Module
- Lake.instFamilyDefNameDataTypeMkStr1Package
- Lake.instFamilyDefNameDataTypeMkStr1Unit
- Lean.Elab.Term.Quotation.instQuotePreresolvedMkStr1_lean
- Lean.Level.instQuoteMkStr1
- Lean.Option.hasQuote
- Lean.instQuoteArrayMkStr1
- Lean.instQuoteBoolMkStr1
- Lean.instQuoteListMkStr1
- Lean.instQuoteNameMkStr1
- Lean.instQuoteProdMkStr1
- Lean.instQuoteSubstringMkStr1
- Lean.instQuoteTermMkStr1
Make name s₁.s₂
Equations
- Lean.Name.mkStr2 s₁ s₂ = (Lean.Name.anonymous.str s₁).str s₂
Instances For
- Lake.InputDirConfig.instConfigMeta
- Lake.InputFileConfig.instConfigMeta
- Lake.LeanConfig.instConfigMeta
- Lake.LeanExeConfig.instConfigMeta
- Lake.LeanLibConfig.instConfigMeta
- Lake.PackageConfig.instConfigMeta
- Lake.WorkspaceConfig.instConfigMeta
- Lake.instFamilyDefNameFacetOutMkStr2ArrayFilePath
- Lake.instFamilyDefNameFacetOutMkStr2ArrayModule
- Lake.instFamilyDefNameFacetOutMkStr2ArrayModule_1
- Lake.instFamilyDefNameFacetOutMkStr2ArrayModule_2
- Lake.instFamilyDefNameFacetOutMkStr2ArrayModule_3
- Lake.instFamilyDefNameFacetOutMkStr2ArrayPackage
- Lake.instFamilyDefNameFacetOutMkStr2ArrayPackage_1
- Lake.instFamilyDefNameFacetOutMkStr2Bool
- Lake.instFamilyDefNameFacetOutMkStr2Bool_1
- Lake.instFamilyDefNameFacetOutMkStr2Bool_2
- Lake.instFamilyDefNameFacetOutMkStr2Dynlib
- Lake.instFamilyDefNameFacetOutMkStr2Dynlib_1
- Lake.instFamilyDefNameFacetOutMkStr2Dynlib_2
- Lake.instFamilyDefNameFacetOutMkStr2FilePath
- Lake.instFamilyDefNameFacetOutMkStr2FilePath_1
- Lake.instFamilyDefNameFacetOutMkStr2FilePath_10
- Lake.instFamilyDefNameFacetOutMkStr2FilePath_11
- Lake.instFamilyDefNameFacetOutMkStr2FilePath_2
- Lake.instFamilyDefNameFacetOutMkStr2FilePath_3
- Lake.instFamilyDefNameFacetOutMkStr2FilePath_4
- Lake.instFamilyDefNameFacetOutMkStr2FilePath_5
- Lake.instFamilyDefNameFacetOutMkStr2FilePath_6
- Lake.instFamilyDefNameFacetOutMkStr2FilePath_7
- Lake.instFamilyDefNameFacetOutMkStr2FilePath_8
- Lake.instFamilyDefNameFacetOutMkStr2FilePath_9
- Lake.instFamilyDefNameFacetOutMkStr2ModuleDeps
- Lake.instFamilyDefNameFacetOutMkStr2Unit
- Lake.instFamilyDefNameFacetOutMkStr2Unit_1
- Lake.instFamilyDefNameFacetOutMkStr2Unit_2
- Lake.instFamilyDefNameFacetOutMkStr2Unit_3
- Lake.instFamilyDefNameFacetOutMkStr2Unit_4
- Lake.instFamilyDefNameFacetOutMkStr2Unit_5
- Lake.instFamilyDefNameFacetOutMkStr2Unit_6
- Lake.instFamilyDefNameFacetOutMkStr2Unit_7
Make name s₁.s₂.s₃
Equations
- Lean.Name.mkStr3 s₁ s₂ s₃ = ((Lean.Name.anonymous.str s₁).str s₂).str s₃
Make name s₁.s₂.s₃.s₄
Equations
- Lean.Name.mkStr4 s₁ s₂ s₃ s₄ = (((Lean.Name.anonymous.str s₁).str s₂).str s₃).str s₄
Make name s₁.s₂.s₃.s₄.s₅
Equations
- Lean.Name.mkStr5 s₁ s₂ s₃ s₄ s₅ = ((((Lean.Name.anonymous.str s₁).str s₂).str s₃).str s₄).str s₅
Make name s₁.s₂.s₃.s₄.s₅.s₆
Equations
- Lean.Name.mkStr6 s₁ s₂ s₃ s₄ s₅ s₆ = (((((Lean.Name.anonymous.str s₁).str s₂).str s₃).str s₄).str s₅).str s₆
Make name s₁.s₂.s₃.s₄.s₅.s₆.s₇
Equations
- Lean.Name.mkStr7 s₁ s₂ s₃ s₄ s₅ s₆ s₇ = ((((((Lean.Name.anonymous.str s₁).str s₂).str s₃).str s₄).str s₅).str s₆).str s₇
Make name s₁.s₂.s₃.s₄.s₅.s₆.s₇.s₈
This function does not have special support for macro scopes.
See Name.append
.
Equations
- x✝.appendCore Lean.Name.anonymous = x✝
- x✝.appendCore (p.str s) = (x✝.appendCore p).str s
- x✝.appendCore (p.num d) = (x✝.appendCore p).num d
The default maximum recursion depth. This is adjustable using the maxRecDepth
option.
Equations
The message to display on stack overflow.
Equations
- Lean.maxRecDepthErrorMessage = "maximum recursion depth has been reached\nuse `set_option maxRecDepth <num>` to increase limit\nuse `set_option diagnostics true` to get diagnostic information"
Syntax #
Source information that relates syntax to the context that it came from.
The primary purpose of SourceInfo
is to relate the output of the parser and the macro expander to
the original source file. When produced by the parser, Syntax.node
does not carry source info; the
parser associates it only with atoms and identifiers. If a Syntax.node
is introduced by a
quotation, then it has synthetic source info that both associates it with an original reference
position and indicates that the original atoms in it may not originate from the Lean file under
elaboration.
Source info is also used to relate Lean's output to the internal data that it represents; this is
the basis for many interactive features. When used this way, it can occur on Syntax.node
as well.
- original
(leading : Substring)
(pos : String.Pos)
(trailing : Substring)
(endPos : String.Pos)
: SourceInfo
A token produced by the parser from original input that includes both leading and trailing whitespace as well as position information.
The
leading
whitespace is inferred after parsing bySyntax.updateLeading
. This is because the “preceding token” is not well-defined during parsing, especially in the presence of backtracking. - synthetic
(pos endPos : String.Pos)
(canonical : Bool := false)
: SourceInfo
Synthetic syntax is syntax that was produced by a metaprogram or by Lean itself (e.g. by a quotation). Synthetic syntax is annotated with a source span from the original syntax, which relates it to the source file.
The delaborator uses this constructor to store an encoded indicator of which core language expression gave rise to the syntax.
The
canonical
flag on synthetic syntax is enabled for syntax that is not literally part of the original input syntax but should be treated “as if” the user really wrote it for the purpose of hovers and error messages. This is usually used on identifiers in order to connect the binding site to the user's original syntax even if the name of the identifier changes during expansion, as well as on tokens that should receive targeted messages.Generally speaking, a macro expansion should only use a given piece of input syntax in a single canonical token. An exception to this rule is when the same identifier is used to declare two binders, as in the macro expansion for dependent if:
`(if $h : $cond then $t else $e) ~> `(dite $cond (fun $h => $t) (fun $h => $t))
In these cases, if the user hovers over
h
they will see information about both binding sites. - none : SourceInfo
A synthesized token without position information.
Equations
- Lean.instInhabitedSourceInfo = { default := Lean.SourceInfo.none }
Gets the position information from a SourceInfo
, if available.
If canonicalOnly
is true, then .synthetic
syntax with canonical := false
will also return none
.
Gets the end position information from a SourceInfo
, if available.
If canonicalOnly
is true, then .synthetic
syntax with canonical := false
will also return none
.
Equations
- (Lean.SourceInfo.original leading pos trailing endPos).getTailPos? canonicalOnly = some endPos
- (Lean.SourceInfo.synthetic pos endPos true).getTailPos? canonicalOnly = some endPos
- (Lean.SourceInfo.synthetic pos endPos canonical).getTailPos? = some endPos
- info.getTailPos? canonicalOnly = none
Gets the substring representing the trailing whitespace of a SourceInfo
, if available.
Equations
- (Lean.SourceInfo.original leading pos trailing endPos).getTrailing? = some trailing
- info.getTrailing? = none
Gets the end position information of the trailing whitespace of a SourceInfo
, if available.
If canonicalOnly
is true, then .synthetic
syntax with canonical := false
will also return none
.
Equations
- info.getTrailingTailPos? canonicalOnly = match info.getTrailing? with | some trailing => some trailing.stopPos | none => info.getTailPos? canonicalOnly
Specifies the interpretation of a Syntax.node
value. An abbreviation for Name
.
Node kinds may be any name, and do not need to refer to declarations in the environment.
Conventionally, however, a node's kind corresponds to the Parser
or ParserDesc
declaration that
produces it. There are also a number of built-in node kinds that are used by the parsing
infrastructure, such as nullKind
and choiceKind
; these do not correspond to parser declarations.
Equations
Instances For
Syntax AST #
A possible binding of an identifier in the context in which it was quoted.
Identifiers in quotations may refer to either global declarations or to namespaces that are in scope
at the site of the quotation. These are saved in the Syntax.ident
constructor and are part of the
implementation of hygienic macros.
- namespace
(ns : Name)
: Preresolved
A potential namespace reference
- decl
(n : Name)
(fields : List String)
: Preresolved
A potential global constant or section variable reference, with additional field accesses
Lean syntax trees.
Syntax trees are used pervasively throughout Lean: they are produced by the parser, transformed by the macro expander, and elaborated. They are also produced by the delaborator and presented to users.
- missing : Syntax
A portion of the syntax tree that is missing because of a parse error.
The indexing operator on
Syntax
also returnsSyntax.missing
when the index is out of bounds. - node
(info : SourceInfo)
(kind : SyntaxNodeKind)
(args : Array Syntax)
: Syntax
A node in the syntax tree that may have further syntax as child nodes. The node's
kind
determines its interpretation.For nodes produced by the parser, the
info
field is typicallyLean.SourceInfo.none
, and source information is stored in the corresponding fields of identifiers and atoms. This field is used in two ways:- The delaborator uses it to associate nodes with metadata that are used to implement interactive features.
- Nodes created by quotations use the field to mark the syntax as synthetic (storing the result
of
Lean.SourceInfo.fromRef
) even when its leading or trailing tokens are not.
- atom
(info : SourceInfo)
(val : String)
: Syntax
A non-identifier atomic component of syntax.
All of the following are atoms:
- keywords, such as
def
,fun
, andinductive
- literals, such as numeric or string literals
- punctuation and delimiters, such as
(
,)
, and=>
.
Identifiers are represented by the
Lean.Syntax.ident
constructor. Atoms also correspond to quoted strings insidesyntax
declarations. - keywords, such as
- ident
(info : SourceInfo)
(rawVal : Substring)
(val : Name)
(preresolved : List Preresolved)
: Syntax
An identifier.
In addition to source information, identifiers have the following fields:
rawVal
is the literal substring from the input fileval
is the parsed Lean name, potentially including macro scopes.preresolved
is the list of possible declarations this could refer to, populated by quotations.
Instances For
- Lean.KVMap.instValueSyntax
- Lean.MessageData.instCoeSyntax
- Lean.Syntax.instBEq
- Lean.Syntax.instForInTopDown
- Lean.Syntax.instGetElemNatTrue
- Lean.Syntax.instRepr
- Lean.Syntax.instToFormat
- Lean.Syntax.instToString
- Lean.instCoeOutTSyntaxSyntax
- Lean.instCoeSyntaxDataValue
- Lean.instCoeSyntaxTSyntaxConsSyntaxNodeKindMkStr1Nil
- Lean.instInhabitedSyntax
- Lean.instToMessageDataSyntax
- Mathlib.instToExprSyntax_mathlib
Create syntax node with 1 child
Equations
- Lean.Syntax.node1 info kind a₁ = Lean.Syntax.node info kind #[a₁]
Create syntax node with 2 children
Equations
- Lean.Syntax.node2 info kind a₁ a₂ = Lean.Syntax.node info kind #[a₁, a₂]
Create syntax node with 3 children
Equations
- Lean.Syntax.node3 info kind a₁ a₂ a₃ = Lean.Syntax.node info kind #[a₁, a₂, a₃]
Create syntax node with 4 children
Equations
- Lean.Syntax.node4 info kind a₁ a₂ a₃ a₄ = Lean.Syntax.node info kind #[a₁, a₂, a₃, a₄]
Create syntax node with 5 children
Equations
- Lean.Syntax.node5 info kind a₁ a₂ a₃ a₄ a₅ = Lean.Syntax.node info kind #[a₁, a₂, a₃, a₄, a₅]
Create syntax node with 6 children
Equations
- Lean.Syntax.node6 info kind a₁ a₂ a₃ a₄ a₅ a₆ = Lean.Syntax.node info kind #[a₁, a₂, a₃, a₄, a₅, a₆]
Create syntax node with 7 children
Create syntax node with 8 children
SyntaxNodeKinds
is a set of SyntaxNodeKind
, implemented as a list.
Singleton SyntaxNodeKinds
are extremely common. They are written as name literals, rather than as
lists; list syntax is required only for empty or non-singleton sets of kinds.
Equations
Instances For
Typed syntax, which tracks the potential kinds of the Syntax
it contains.
While syntax quotations produce or expect TSyntax
values of the correct kinds, this is not
otherwise enforced; it can easily be circumvented by direct use of the constructor.
Instances For
- Lake.instCoeIdentTSyntaxConsSyntaxNodeKindMkStr4Nil_lake
- Lean.Elab.Tactic.RCases.instCoeIdentTSyntaxConsSyntaxNodeKindMkStr1Nil_lean
- Lean.Elab.Tactic.RCases.instCoeTSyntaxConsSyntaxNodeKindMkStr1NilMkStr4_lean
- Lean.Elab.Tactic.RCases.instCoeTSyntaxConsSyntaxNodeKindMkStr1Nil_lean
- Lean.Elab.Tactic.RCases.instCoeTSyntaxConsSyntaxNodeKindMkStr4Nil_lean
- Lean.Meta.Tactic.TryThis.instCoeHeadTSyntaxConsSyntaxNodeKindNilSuggestionText
- Lean.Parser.Term.instCoeTSyntaxConsSyntaxNodeKindMkStr4Nil_lean
- Lean.Parser.Term.instCoeTSyntaxConsSyntaxNodeKindMkStr4Nil_lean_1
- Lean.Server.RpcEncodable.instCoeTSyntaxConsSyntaxNodeKindStrNumAnonymousOfNatNatNilMkStr4
- Lean.Syntax.instBEqTSyntax
- Lean.Syntax.instCoeIdentTSyntaxConsSyntaxNodeKindMkStr4Nil
- Lean.Syntax.instCoeTermTSyntaxConsSyntaxNodeKindMkStr4Nil
- Lean.Syntax.instReprTSyntax
- Lean.Syntax.instToFormatTSyntax
- Lean.Syntax.instToStringTSyntax
- Lean.TSyntax.instCoeConsSyntaxNodeKind
- Lean.TSyntax.instCoeConsSyntaxNodeKindNil
- Lean.instCoeOutTSyntaxSyntax
- Lean.instCoeSyntaxTSyntaxConsSyntaxNodeKindMkStr1Nil
- Lean.instInhabitedTSyntax
- Lean.instToMessageDataTSyntax
Equations
- Lean.instInhabitedSyntax = { default := Lean.Syntax.missing }
Builtin kinds #
The `choice
kind is used to represent ambiguous parse results.
The parser prioritizes longer matches over shorter ones, but there is not always a unique longest match. All the parse results are saved, and the determination of which to use is deferred until typing information is available.
Equations
- Lean.choiceKind = `choice
`null
is the “fallback” kind, used when no other kind applies. Null nodes result from
repetition operators, and empty null nodes represent the failure of an optional parse.
The null kind is used for raw list parsers like many
.
Equations
- Lean.nullKind = `null
The `group
kind is used for nodes that result from Lean.Parser.group
. This avoids confusion
with the null kind when used inside optional
.
Equations
- Lean.groupKind = `group
The pseudo-kind assigned to identifiers: `ident
.
The name `ident
is not actually used as a kind for Syntax.node
values. It is used by
convention as the kind of Syntax.ident
values.
Equations
- Lean.identKind = `ident
`str
is the node kind of string literals like "foo"
.
Equations
- Lean.strLitKind = `str
Instances For
`char
is the node kind of character literals like 'A'
.
Equations
- Lean.charLitKind = `char
Instances For
`num
is the node kind of number literals like 42
.
Equations
- Lean.numLitKind = `num
Instances For
`scientific
is the node kind of floating point literals like 1.23e-3
.
Equations
- Lean.scientificLitKind = `scientific
`name
is the node kind of name literals like `foo
.
Equations
- Lean.nameLitKind = `name
`` fieldIdx
is the node kind of projection indices like the 2
in x.2
.
Equations
- Lean.fieldIdxKind = `fieldIdx
`hygieneInfo
is the node kind of the Lean.Parser.hygieneInfo
parser, which produces an
“invisible token” that captures the hygiene information at the current point without parsing
anything.
They can be used to generate identifiers (with Lean.HygieneInfo.mkIdent
) as if they were
introduced in a macro's input, rather than by its implementation.
Equations
- Lean.hygieneInfoKind = `hygieneInfo
`interpolatedStrLitKind
is the node kind of interpolated string literal
fragments like "value = {
and }"
in s!"value = {x}"
.
Equations
- Lean.interpolatedStrLitKind = `interpolatedStrLitKind
`interpolatedStrKind
is the node kind of an interpolated string literal like "value = {x}"
in s!"value = {x}"
.
Equations
- Lean.interpolatedStrKind = `interpolatedStrKind
Creates an info-less node of the given kind and children.
Equations
- Lean.mkNode k args = { raw := Lean.Syntax.node Lean.SourceInfo.none k args }
Creates an info-less nullKind
node with the given children, if any.
Equations
- Lean.mkNullNode args = (Lean.mkNode Lean.nullKind args).raw
Gets the kind of a Syntax.node
value, or the pseudo-kind of any other Syntax
value.
“Pseudo-kinds” are kinds that are assigned by convention to non-Syntax.node
values:
identKind
for Syntax.ident
, `missing
for Syntax.missing
, and the atom's string literal
for atoms.
Equations
- (Lean.Syntax.node info k args).getKind = k
- Lean.Syntax.missing.getKind = `missing
- (Lean.Syntax.atom info v).getKind = Lean.Name.mkSimple v
- (Lean.Syntax.ident info rawVal val preresolved).getKind = Lean.identKind
Changes the kind at the root of a Syntax.node
to k
.
Returns all other Syntax
values unchanged.
Equations
- (Lean.Syntax.node info kind args).setKind k = Lean.Syntax.node info k args
- stx.setKind k = stx
Checks whether syntax has the given kind or pseudo-kind.
“Pseudo-kinds” are kinds that are assigned by convention to non-Syntax.node
values:
identKind
for Syntax.ident
, `missing
for Syntax.missing
, and the atom's string literal
for atoms.
Gets the i
'th argument of the syntax node. This can also be written stx[i]
.
Returns missing
if i
is out of range.
Equations
- (Lean.Syntax.node info kind args).getArg i = args.getD i Lean.Syntax.missing
- stx.getArg i = Lean.Syntax.missing
Gets the number of arguments of the syntax node, or 0
if it's not a node
.
Equations
- (Lean.Syntax.node info kind args).getNumArgs = args.size
- stx.getNumArgs = 0
Assuming stx
was parsed by optional
, returns the enclosed syntax
if it parsed something and none
otherwise.
Equations
- (Lean.Syntax.node info kind args).getOptional? = match kind == Lean.nullKind && args.size == 1 with | true => some (args.get!Internal 0) | false => none
- stx.getOptional? = none
Is this syntax a node
with kind k
?
If this is an ident
, return the parsed value, else .anonymous
.
Equations
- (Lean.Syntax.ident info rawVal val preresolved).getId = val
- x✝.getId = Lean.Name.anonymous
Retrieve the immediate info from the Syntax node.
Equations
- (Lean.Syntax.atom info val).getInfo? = some info
- (Lean.Syntax.ident info rawVal val preresolved).getInfo? = some info
- (Lean.Syntax.node info kind args).getInfo? = some info
- Lean.Syntax.missing.getInfo? = none
Retrieve the left-most node or leaf's info in the Syntax tree.
Retrieve the left-most leaf's info in the Syntax tree, or none
if there is no token.
Equations
- stx.getHeadInfo = match stx.getHeadInfo? with | some info => info | none => Lean.SourceInfo.none
Get the starting position of the syntax, if possible.
If canonicalOnly
is true, non-canonical synthetic
nodes are treated as not carrying
position information.
Equations
- stx.getPos? canonicalOnly = stx.getHeadInfo.getPos? canonicalOnly
Get the ending position of the syntax, if possible.
If canonicalOnly
is true, non-canonical synthetic
nodes are treated as not carrying
position information.
An array of syntax elements interspersed with the given separators.
Separator arrays result from repetition operators such as ,*
.
Coercions to and from Array Syntax
insert or remove separators
as required.
The typed equivalent is Lean.Syntax.TSepArray
.
The array of elements and separators, ordered like
#[el1, sep1, el2, sep2, el3]
.
An array of syntax elements that alternate with the given separator. Each syntax element has a kind
drawn from ks
.
Separator arrays result from repetition operators such as ,*
.
Coercions to and from Array (TSyntax ks)
insert or remove
separators as required. The untyped equivalent is Lean.Syntax.SepArray
.
The array of elements and separators, ordered like
#[el1, sep1, el2, sep2, el3]
.
An array of syntaxes of kind ks
.
Equations
- Lean.TSyntaxArray ks = Array (Lean.TSyntax ks)
Implementation of TSyntaxArray.raw
.
Equations
Converts a TSyntaxArray
to an Array Syntax
, without reallocation.
Implementation of TSyntaxArray.mk
.
Equations
Converts an Array Syntax
to a TSyntaxArray
, without reallocation.
Constructs a synthetic SourceInfo
using a ref : Syntax
for the span.
Equations
- One or more equations did not get rendered due to their size.
Constructs a synthetic atom
with no source info.
Equations
Constructs a synthetic atom
with source info coming from src
.
Equations
- Lean.mkAtomFrom src val canonical = Lean.Syntax.atom (Lean.SourceInfo.fromRef src canonical) val
Parser descriptions #
A ParserDescr
is a grammar for parsers. This is used by the syntax
command
to produce parsers without having to import Lean
.
- const
(name : Name)
: ParserDescr
A (named) nullary parser, like
ppSpace
- unary
(name : Name)
(p : ParserDescr)
: ParserDescr
A (named) unary parser, like
group(p)
- binary
(name : Name)
(p₁ p₂ : ParserDescr)
: ParserDescr
A (named) binary parser, like
orelse
orandthen
(written asp1 <|> p2
andp1 p2
respectively insyntax
) - node
(kind : SyntaxNodeKind)
(prec : Nat)
(p : ParserDescr)
: ParserDescr
Parses using
p
, then pops the stack to create a new node with kindkind
. The precedenceprec
is used to determine whether the parser should apply given the current precedence level. - trailingNode
(kind : SyntaxNodeKind)
(prec lhsPrec : Nat)
(p : ParserDescr)
: ParserDescr
Like
node
but for trailing parsers (which start with a nonterminal). Assumes the lhs is already on the stack, and parses usingp
, then pops the stack including the lhs to create a new node with kindkind
. The precedenceprec
andlhsPrec
are used to determine whether the parser should apply. - symbol (val : String) : ParserDescr
- nonReservedSymbol (val : String) (includeIdent : Bool) : ParserDescr
- cat
(catName : Name)
(rbp : Nat)
: ParserDescr
Parses using the category parser
catName
with right binding power (i.e. precedence)rbp
. - parser
(declName : Name)
: ParserDescr
Parses using another parser
declName
, which can be either aParser
orParserDescr
. - nodeWithAntiquot (name : String) (kind : SyntaxNodeKind) (p : ParserDescr) : ParserDescr
- sepBy
(p : ParserDescr)
(sep : String)
(psep : ParserDescr)
(allowTrailingSep : Bool := false)
: ParserDescr
A
sepBy(p, sep)
parses 0 or more occurrences ofp
separated bysep
.psep
is usually the same assymbol sep
, but it can be overridden.sep
is only used in the antiquot syntax:$x;*
would match ifsep
is";"
.allowTrailingSep
is true if e.g.a, b,
is also allowed to match. - sepBy1 (p : ParserDescr) (sep : String) (psep : ParserDescr) (allowTrailingSep : Bool := false) : ParserDescr
Instances For
Equations
- Lean.instInhabitedParserDescr = { default := Lean.ParserDescr.symbol "" }
Although TrailingParserDescr
is an abbreviation for ParserDescr
, Lean will
look at the declared type in order to determine whether to add the parser to
the leading or trailing parser table. The determination is done automatically
by the syntax
command.
Equations
Runtime support for making quotation terms auto-hygienic, by mangling identifiers introduced by them with a "macro scope" supplied by the context. Details to appear in a paper soon.
A macro scope identifier is just a Nat
that gets bumped every time we
enter a new macro scope. Within a macro scope, all occurrences of identifier x
parse to the same thing, but x
parsed from different macro scopes will
produce different identifiers.
Equations
Macro scope used internally. It is not available for our frontend.
Equations
First macro scope available for our frontend
Equations
Equations
- One or more equations did not get rendered due to their size.
Run x : m α
with a modified value for the ref
. This is not exactly
the same as MonadRef.withRef
, because it uses replaceRef
to avoid putting
syntax with bad spans in the state.
Equations
- Lean.withRef ref x = do let oldRef ← Lean.getRef let ref : Lean.Syntax := Lean.replaceRef ref oldRef Lean.MonadRef.withRef ref x
If ref? = some ref
, run x : m α
with a modified value for the ref
by calling withRef
.
Otherwise, run x
directly.
Equations
- Lean.withRef? (some ref) x = Lean.withRef ref x
- Lean.withRef? ref? x = x
A monad that supports syntax quotations. Syntax quotations (in term
position) are monadic values that when executed retrieve the current "macro
scope" from the monad and apply it to every identifier they introduce
(independent of whether this identifier turns out to be a reference to an
existing declaration, or an actually fresh binding during further
elaboration). We also apply the position of the result of getRef
to each
introduced symbol, which results in better error positions than not applying
any position.
- getCurrMacroScope : m MacroScope
Get the fresh scope of the current macro invocation
- getMainModule : m Name
Get the module name of the current file. This is used to ensure that hygienic names don't clash across multiple files.
- withFreshMacroScope {α : Type} : m α → m α
Execute action in a new macro invocation context. This transformer should be used at all places that morally qualify as the beginning of a "macro call", e.g.
elabCommand
andelabTerm
in the case of the elaborator. However, it can also be used internally inside a "macro" if identifiers introduced by e.g. different recursive calls should be independent and not collide. While returning an intermediate syntax tree that will recursively be expanded by the elaborator can be used for the same effect, doing direct recursion inside the macro guarded by this transformer is often easier because one is not restricted to passing a single syntax tree. Modelling this helper as a transformer and not just a monadic action ensures that the current macro scope before the recursive call is restored after it, as expected.
Instances
- Lean.Core.instMonadQuotationCoreM
- Lean.Elab.Command.instMonadQuotationCommandElabM
- Lean.Macro.instMonadQuotationMacroM
- Lean.PrettyPrinter.Delaborator.instMonadQuotationDelabM
- Lean.PrettyPrinter.Parenthesizer.instMonadQuotationParenthesizerM
- Lean.PrettyPrinter.instMonadQuotationUnexpandM
- Lean.Unhygienic.instMonadQuotation
- Lean.instMonadQuotationOfMonadFunctorOfMonadLift
Construct a synthetic SourceInfo
from the ref
in the monad state.
Equations
- Lean.MonadRef.mkInfoFromRefPos = do let __do_lift ← Lean.getRef pure (Lean.SourceInfo.fromRef __do_lift)
Equations
- One or more equations did not get rendered due to their size.
We represent a name with macro scopes as
<actual name>._@.(<module_name>.<scopes>)*.<module_name>._hyg.<scopes>
Example: suppose the module name is Init.Data.List.Basic
, and name is foo.bla
, and macroscopes [2, 5]
foo.bla._@.Init.Data.List.Basic._hyg.2.5
We may have to combine scopes from different files/modules. The main modules being processed is always the right-most one. This situation may happen when we execute a macro generated in an imported file in the current file.
foo.bla._@.Init.Data.List.Basic.2.1.Init.Lean.Expr._hyg.4
The delimiter _hyg
is used just to improve the hasMacroScopes
performance.
Does this name have hygienic macro scopes?
Equations
- (pre.str s).hasMacroScopes = (s == "_hyg")
- (p.num i).hasMacroScopes = p.hasMacroScopes
- x✝.hasMacroScopes = false
Remove the macro scopes from the name.
Equations
- n.eraseMacroScopes = match n.hasMacroScopes with | true => Lean.eraseMacroScopesAux✝ n | false => n
Helper function we use to create binder names that do not need to be unique.
Equations
- n.simpMacroScopes = match n.hasMacroScopes with | true => Lean.simpMacroScopesAux✝ n | false => n
A MacroScopesView
represents a parsed hygienic name. extractMacroScopes
will decode it from a Name
, and .review
will re-encode it. The grammar of a
hygienic name is:
<name>._@.(<module_name>.<scopes>)*.<mainModule>._hyg.<scopes>
- name : Name
The original (unhygienic) name.
- imported : Name
All the name components
(<module_name>.<scopes>)*
from the imports concatenated together. - mainModule : Name
The main module in which this identifier was parsed.
- scopes : List MacroScope
The list of macro scopes.
Instances For
Encode a hygienic name from the parsed pieces.
Equations
- One or more equations did not get rendered due to their size.
Revert all addMacroScope
calls. v = extractMacroScopes n → n = v.review
.
This operation is useful for analyzing/transforming the original identifiers, then adding back
the scopes (via MacroScopesView.review
).
Equations
- One or more equations did not get rendered due to their size.
Add a new macro scope onto the name n
, in the given mainModule
.
Equations
- One or more equations did not get rendered due to their size.
Appends two names a
and b
, propagating macro scopes from a
or b
, if any, to the result.
Panics if both a
and b
have macro scopes.
This function is used for the Append Name
instance.
See also Lean.Name.appendCore
, which appends names without any consideration for macro scopes.
Also consider Lean.Name.eraseMacroScopes
to erase macro scopes before appending, if appropriate.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.instAppendName = { append := Lean.Name.append }
Add a new macro scope onto the name n
, using the monad state to supply the
main module and current macro scope.
Equations
- Lean.MonadQuotation.addMacroScope n = do let mainModule ← Lean.getMainModule let scp ← Lean.getCurrMacroScope pure (Lean.addMacroScope mainModule n scp)
Is this syntax a null node
?
Equations
- stx.matchesNull n = stx.isNodeOf Lean.nullKind n
Function used for determining whether a syntax pattern `(id)
is matched.
There are various conceivable notions of when two syntactic identifiers should be regarded as identical,
but semantic definitions like whether they refer to the same global name cannot be implemented without
context information (i.e. MonadResolveName
). Thus in patterns we default to the structural solution
of comparing the identifiers' Name
values, though we at least do so modulo macro scopes so that
identifiers that "look" the same match. This is particularly useful when dealing with identifiers that
do not actually refer to Lean bindings, e.g. in the stx
pattern `(many($p))
.
Equations
- stx.matchesIdent id = (stx.isIdent && stx.getId.eraseMacroScopes == id.eraseMacroScopes)
Is this syntax a node kind k
wrapping an atom _ val
?
Equations
- (Lean.Syntax.node info kind args).matchesLit k val = (k == kind && match args.getD 0 Lean.Syntax.missing with | Lean.Syntax.atom info val' => val == val' | x => false)
- stx.matchesLit k val = false
The read-only context for the MacroM
monad.
- methods : Lean.Macro.MethodsRef✝
- mainModule : Name
The currently parsing module.
- currMacroScope : MacroScope
The current macro scope.
- currRecDepth : Nat
The current recursion depth.
- maxRecDepth : Nat
The maximum recursion depth.
- ref : Syntax
The syntax which supplies the position of error messages.
An exception in the MacroM
monad.
The mutable state for the MacroM
monad.
- macroScope : MacroScope
The global macro scope counter, used for producing fresh scope names.
The list of trace messages that have been produced, each with a trace class and a message.
Instances For
The MacroM
monad is the main monad for macro expansion. It has the
information needed to handle hygienic name generation, and is the monad that
macro
definitions live in.
Notably, this is a (relatively) pure monad: there is no IO
and no access to
the Environment
. That means that things like declaration lookup are
impossible here, as well as IO.Ref
or other side-effecting operations.
For more capabilities, macros can instead be written as elab
using adaptExpander
.
Equations
- One or more equations did not get rendered due to their size.
Add a new macro scope to the name n
.
Equations
- Lean.Macro.addMacroScope n = do let ctx ← read pure (Lean.addMacroScope ctx.mainModule n ctx.currMacroScope)
Throw an unsupportedSyntax
exception.
Throw an error with the given message,
using the ref
for the location information.
Equations
- Lean.Macro.throwError msg = do let ref ← Lean.getRef throw (Lean.Macro.Exception.error ref msg)
Throw an error with the given message and location information.
Equations
- Lean.Macro.throwErrorAt ref msg = Lean.withRef ref (Lean.Macro.throwError msg)
Increments the macro scope counter so that inside the body of x
the macro
scope is fresh.
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.
Implementation of mkMethods
.
Equations
- Lean.Macro.mkMethodsImp methods = unsafeCast methods
Make an opaque reference to a Methods
.
Equations
- Lean.Macro.instInhabitedMethodsRef = { default := Lean.Macro.mkMethods default }
Implementation of getMethods
.
Equations
- Lean.Macro.getMethodsImp = do let ctx ← read pure (unsafeCast ctx.methods)
Extract the methods list from the MacroM
state.
expandMacro? stx
returns some stxNew
if stx
is a macro,
and stxNew
is its expansion.
Equations
- Lean.expandMacro? stx = do let __do_lift ← Lean.Macro.getMethods __do_lift.expandMacro? stx
Returns true
if the environment contains a declaration with name declName
Equations
- Lean.Macro.hasDecl declName = do let __do_lift ← Lean.Macro.getMethods __do_lift.hasDecl declName
Gets the current namespace given the position in the file.
Equations
- Lean.Macro.getCurrNamespace = do let __do_lift ← Lean.Macro.getMethods __do_lift.getCurrNamespace
Resolves the given name to an overload list of namespaces.
Equations
- Lean.Macro.resolveNamespace n = do let __do_lift ← Lean.Macro.getMethods __do_lift.resolveNamespace n
Resolves the given name to an overload list of global definitions.
The List String
in each alternative is the deduced list of projections
(which are ambiguous with name components).
Remark: it will not trigger actions associated with reserved names. Recall that Lean
has reserved names. For example, a definition foo
has a reserved name foo.def
for theorem
containing stating that foo
is equal to its definition. The action associated with foo.def
automatically proves the theorem. At the macro level, the name is resolved, but the action is not
executed. The actions are executed by the elaborator when converting Syntax
into Expr
.
Equations
- Lean.Macro.resolveGlobalName n = do let __do_lift ← Lean.Macro.getMethods __do_lift.resolveGlobalName n
Add a new trace message, with the given trace class and message.
Equations
- Lean.Macro.trace clsName msg = modify fun (s : Lean.Macro.State) => { macroScope := s.macroScope, traceMsgs := (clsName, msg) :: s.traceMsgs }
Function that tries to reverse macro expansions as a post-processing step of delaboration.
While less general than an arbitrary delaborator, it can be declared without importing Lean
.
Used by the [app_unexpander]
attribute.
Equations
- One or more equations did not get rendered due to their size.