Proof Assistant Projects
Collection
Digesting proof assistant libraries for AI ingestion. • 84 items • Updated • 3
fact stringlengths 10 4.79k | type stringclasses 9
values | library stringclasses 44
values | imports listlengths 0 13 | filename stringclasses 718
values | symbolic_name stringlengths 1 76 | docstring stringlengths 10 64.6k ⌀ |
|---|---|---|---|---|---|---|
@[simp ↓, expose]
binderNameHint {α : Sort u} {β : Sort v} {γ : Sort w} (v : α) (binder : β) (e : γ) : γ := e | def | Init.BinderNameHint | [
"Init.Tactics"
] | Init/BinderNameHint.lean | binderNameHint | The expression `binderNameHint v binder e` defined to be `e`.
If it is used on the right-hand side of an equation that is used for rewriting by `rw` or `simp`,
and `v` is a local variable, and `binder` is an expression that (after beta-reduction) is a binder
(`fun w => …` or `∀ w, …`), then it will rename `v` to the n... |
@[simp] if_true {_ : Decidable True} (t e : α) : ite True t e = t := if_pos trivial
@[simp] theorem if_false {_ : Decidable False} (t e : α) : ite False t e = e := if_neg id | theorem | Init.ByCases | [
"Init.Classical"
] | Init/ByCases.lean | if_true | `by_cases (h :)? p` splits the main goal into two cases, assuming `h : p` in the first branch, and `h : ¬ p` in the second branch.
-/
syntax "by_cases " (atomic(ident " : "))? term : tactic
macro_rules
| `(tactic| by_cases $e) => `(tactic| by_cases h : $e)
macro_rules
| `(tactic| by_cases $h : $e) =>
`(tactic|... |
ite_id [Decidable c] {α} (t : α) : (if c then t else t) = t := by split <;> rfl | theorem | Init.ByCases | [
"Init.Classical"
] | Init/ByCases.lean | ite_id | null |
apply_dite (f : α → β) (P : Prop) [Decidable P] (x : P → α) (y : ¬P → α) :
f (dite P x y) = dite P (fun h => f (x h)) (fun h => f (y h)) := by
by_cases h : P <;> simp [h] | theorem | Init.ByCases | [
"Init.Classical"
] | Init/ByCases.lean | apply_dite | A function applied to a `dite` is a `dite` of that function applied to each of the branches. |
apply_ite (f : α → β) (P : Prop) [Decidable P] (x y : α) :
f (ite P x y) = ite P (f x) (f y) :=
apply_dite f P (fun _ => x) (fun _ => y) | theorem | Init.ByCases | [
"Init.Classical"
] | Init/ByCases.lean | apply_ite | A function applied to a `ite` is a `ite` of that function applied to each of the branches. |
@[simp] dite_eq_ite [Decidable P] :
(dite P (fun _ => a) (fun _ => b)) = ite P a b := rfl
-- Remark: dite and ite are "defally equal" when we ignore the proofs.
@[deprecated dite_eq_ite (since := "2025-10-29")] | theorem | Init.ByCases | [
"Init.Classical"
] | Init/ByCases.lean | dite_eq_ite | A `dite` whose results do not actually depend on the condition may be reduced to an `ite`. |
dif_eq_if (c : Prop) {h : Decidable c} {α : Sort u} (t : α) (e : α) : dite c (fun _ => t) (fun _ => e) = ite c t e :=
match h with
| isTrue _ => rfl
| isFalse _ => rfl | theorem | Init.ByCases | [
"Init.Classical"
] | Init/ByCases.lean | dif_eq_if | null |
noncomputable indefiniteDescription {α : Sort u} (p : α → Prop) (h : ∃ x, p x) : {x // p x} :=
choice <| let ⟨x, px⟩ := h; ⟨⟨x, px⟩⟩ | def | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | indefiniteDescription | null |
noncomputable choose {α : Sort u} {p : α → Prop} (h : ∃ x, p x) : α :=
(indefiniteDescription p h).val | def | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | choose | Given that there exists an element satisfying `p`, returns one such element.
This is a straightforward consequence of, and equivalent to, `Classical.choice`.
See also `choose_spec`, which asserts that the returned value has property `p`. |
choose_spec {α : Sort u} {p : α → Prop} (h : ∃ x, p x) : p (choose h) :=
(indefiniteDescription p h).property | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | choose_spec | null |
em (p : Prop) : p ∨ ¬p :=
let U (x : Prop) : Prop := x = True ∨ p
let V (x : Prop) : Prop := x = False ∨ p
have exU : ∃ x, U x := ⟨True, Or.inl rfl⟩
have exV : ∃ x, V x := ⟨False, Or.inl rfl⟩
let u : Prop := choose exU
let v : Prop := choose exV
have u_def : U u := choose_spec exU
have v_def : V v := ch... | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | em | **Diaconescu's theorem**: excluded middle from choice, Function extensionality and propositional extensionality. |
exists_true_of_nonempty {α : Sort u} : Nonempty α → ∃ _ : α, True
| ⟨x⟩ => ⟨x, trivial⟩ | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | exists_true_of_nonempty | null |
noncomputable inhabited_of_nonempty {α : Sort u} (h : Nonempty α) : Inhabited α :=
⟨choice h⟩ | def | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | inhabited_of_nonempty | null |
noncomputable inhabited_of_exists {α : Sort u} {p : α → Prop} (h : ∃ x, p x) : Inhabited α :=
inhabited_of_nonempty (Exists.elim h (fun w _ => ⟨w⟩)) | def | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | inhabited_of_exists | null |
noncomputable epsilon {α : Sort u} [h : Nonempty α] (p : α → Prop) : α :=
(strongIndefiniteDescription p h).val | def | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | epsilon | All propositions are `Decidable`. -/
noncomputable scoped instance (priority := low) propDecidable (a : Prop) : Decidable a :=
choice <| match em a with
| Or.inl h => ⟨isTrue h⟩
| Or.inr h => ⟨isFalse h⟩
noncomputable def decidableInhabited (a : Prop) : Inhabited (Decidable a) where
default := inferInstanc... |
epsilon_spec_aux {α : Sort u} (h : Nonempty α) (p : α → Prop) : (∃ y, p y) → p (@epsilon α h p) :=
(strongIndefiniteDescription p h).property | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | epsilon_spec_aux | null |
epsilon_spec {α : Sort u} {p : α → Prop} (hex : ∃ y, p y) : p (@epsilon α hex.nonempty p) :=
epsilon_spec_aux hex.nonempty p hex | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | epsilon_spec | null |
epsilon_singleton {α : Sort u} (x : α) : @epsilon α ⟨x⟩ (fun y => y = x) = x :=
@epsilon_spec α (fun y => y = x) ⟨x, rfl⟩ | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | epsilon_singleton | null |
axiomOfChoice {α : Sort u} {β : α → Sort v} {r : ∀ x, β x → Prop} (h : ∀ x, ∃ y, r x y) : ∃ (f : ∀ x, β x), ∀ x, r x (f x) :=
⟨_, fun x => choose_spec (h x)⟩ | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | axiomOfChoice | the axiom of choice |
skolem {α : Sort u} {b : α → Sort v} {p : ∀ x, b x → Prop} : (∀ x, ∃ y, p x y) ↔ ∃ (f : ∀ x, b x), ∀ x, p x (f x) :=
⟨axiomOfChoice, fun ⟨f, hw⟩ (x) => ⟨f x, hw x⟩⟩ | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | skolem | null |
propComplete (a : Prop) : a = True ∨ a = False :=
match em a with
| Or.inl ha => Or.inl (eq_true ha)
| Or.inr hn => Or.inr (eq_false hn)
-- this supersedes byCases in Decidable | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | propComplete | null |
byCases {p q : Prop} (hpq : p → q) (hnpq : ¬p → q) : q :=
Decidable.byCases (dec := propDecidable _) hpq hnpq
-- this supersedes byContradiction in Decidable | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | byCases | null |
byContradiction {p : Prop} (h : ¬p → False) : p :=
Decidable.byContradiction (dec := propDecidable _) h | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | byContradiction | null |
@[simp] not_not : ¬¬a ↔ a := Decidable.not_not | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | not_not | The Double Negation Theorem: `¬¬P` is equivalent to `P`.
The left-to-right direction, double negation elimination (DNE),
is classically true but not constructively. |
@[simp low] protected dite_not [hn : Decidable (¬p)] (x : ¬p → α) (y : ¬¬p → α) :
dite (¬p) x y = dite p (fun h => y (not_not_intro h)) x := by
cases hn <;> rename_i g
· simp [not_not.mp g]
· simp [g]
attribute [local instance] decidable_of_decidable_not in | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | dite_not | Transfer decidability of `¬ p` to decidability of `p`. -/
-- This can not be an instance as it would be tried everywhere.
def decidable_of_decidable_not (p : Prop) [h : Decidable (¬ p)] : Decidable p :=
match h with
| isFalse h => isTrue (Classical.not_not.mp h)
| isTrue h => isFalse h
attribute [local instance]... |
@[simp low] protected ite_not (p : Prop) [Decidable (¬ p)] (x y : α) : ite (¬p) x y = ite p y x :=
dite_not (fun _ => x) (fun _ => y)
attribute [local instance] decidable_of_decidable_not in
@[simp low] protected theorem decide_not (p : Prop) [Decidable (¬ p)] : decide (¬p) = !decide p :=
byCases (fun h : p => by ... | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | ite_not | Negation of the condition `P : Prop` in a `ite` is the same as swapping the branches. |
not_forall_not {p : α → Prop} : (¬∀ x, ¬p x) ↔ ∃ x, p x := Decidable.not_forall_not | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | not_forall_not | null |
not_exists_not {p : α → Prop} : (¬∃ x, ¬p x) ↔ ∀ x, p x := Decidable.not_exists_not | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | not_exists_not | null |
forall_or_exists_not (P : α → Prop) : (∀ a, P a) ∨ ∃ a, ¬ P a := by
rw [← not_forall]; exact em _ | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | forall_or_exists_not | null |
exists_or_forall_not (P : α → Prop) : (∃ a, P a) ∨ ∀ a, ¬ P a := by
rw [← not_exists]; exact em _ | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | exists_or_forall_not | null |
or_iff_not_imp_left : a ∨ b ↔ (¬a → b) := Decidable.or_iff_not_imp_left | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | or_iff_not_imp_left | null |
or_iff_not_imp_right : a ∨ b ↔ (¬b → a) := Decidable.or_iff_not_imp_right | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | or_iff_not_imp_right | null |
not_imp_iff_and_not : ¬(a → b) ↔ a ∧ ¬b := Decidable.not_imp_iff_and_not | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | not_imp_iff_and_not | null |
not_and_iff_not_or_not : ¬(a ∧ b) ↔ ¬a ∨ ¬b := Decidable.not_and_iff_not_or_not | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | not_and_iff_not_or_not | null |
not_iff : ¬(a ↔ b) ↔ (¬a ↔ b) := Decidable.not_iff
@[simp] theorem imp_iff_left_iff : (b ↔ a → b) ↔ a ∨ b := Decidable.imp_iff_left_iff
@[simp] theorem imp_iff_right_iff : (a → b ↔ b) ↔ a ∨ b := Decidable.imp_iff_right_iff
@[simp] theorem and_or_imp : a ∧ b ∨ (a → c) ↔ a → b ∨ c := Decidable.and_or_imp
@[simp] theo... | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | not_iff | null |
Exists.choose_spec {p : α → Prop} (P : ∃ a, p a) : p P.choose := Classical.choose_spec P
grind_pattern Exists.choose_spec => P.choose | theorem | Init.Classical | [
"Init.PropLemmas"
] | Init/Classical.lean | Exists.choose_spec | Extract an element from an existential statement, using `Classical.choose`. -/
-- This enables projection notation.
@[reducible] noncomputable def Exists.choose {p : α → Prop} (P : ∃ a, p a) : α := Classical.choose P
/-- Show that an element extracted from `P : ∃ a, p a` using `P.choose` satisfies `p`. |
f (x : Nat) : Int := x
```
then this is clearly not type correct as is, because `x` has type `Nat` but
type `Int` is expected, and normally you will get an error message saying exactly that.
But before it shows that message, it will attempt to synthesize an instance of
`CoeT Nat x Int`, which will end up going through ... | def | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | f | null |
f (x : Nat) : Int := Int.ofNat x
```
which is not a type error anymore.
You can also use the `↑` operator to explicitly indicate a coercion. Using `↑x`
instead of `x` in the example will result in the same output.
Because there are many polymorphic functions in Lean, it is often ambiguous where
the coercion can go. F... | def | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | f | null |
f (x y : Nat) : Int := x + y
```
This could be either `↑x + ↑y` where `+` is the addition on `Int`, or `↑(x + y)`
where `+` is addition on `Nat`, or even `x + y` using a heterogeneous addition
with the type `Nat → Nat → Int`. You can use the `↑` operator to disambiguate
between these possibilities, but generally Lean w... | def | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | f | null |
f (x : Nat) : Int := x | def | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | f | null |
Coe (α : semiOutParam (Sort u)) (β : Sort v) where
/-- Coerces a value of type `α` to type `β`. Accessible by the notation `↑x`,
or by double type ascription `((x : α) : β)`. -/
coe : α → β
attribute [coe_decl] Coe.coe | class | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | Coe | `Coe α β` is the typeclass for coercions from `α` to `β`. It can be transitively
chained with other `Coe` instances, and coercion is automatically used when
`x` has type `α` but it is used in a context where `β` is expected.
You can use the `↑x` operator to explicitly trigger coercion. |
CoeTC (α : Sort u) (β : Sort v) where
/-- Coerces a value of type `α` to type `β`. Accessible by the notation `↑x`,
or by double type ascription `((x : α) : β)`. -/
coe : α → β
attribute [coe_decl] CoeTC.coe | class | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | CoeTC | Auxiliary class implementing `Coe*`.
Users should generally not implement this directly. |
CoeOut (α : Sort u) (β : semiOutParam (Sort v)) where
/-- Coerces a value of type `α` to type `β`. Accessible by the notation `↑x`,
or by double type ascription `((x : α) : β)`. -/
coe : α → β
attribute [coe_decl] CoeOut.coe | class | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | CoeOut | `CoeOut α β` is for coercions that are applied from left-to-right. |
CoeOTC (α : Sort u) (β : Sort v) where
/-- Coerces a value of type `α` to type `β`. Accessible by the notation `↑x`,
or by double type ascription `((x : α) : β)`. -/
coe : α → β
attribute [coe_decl] CoeOTC.coe | class | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | CoeOTC | Auxiliary class implementing `CoeOut* Coe*`.
Users should generally not implement this directly. |
CoeHead (α : Sort u) (β : semiOutParam (Sort v)) where
/-- Coerces a value of type `α` to type `β`. Accessible by the notation `↑x`,
or by double type ascription `((x : α) : β)`. -/
coe : α → β
attribute [coe_decl] CoeHead.coe | class | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | CoeHead | `CoeHead α β` is for coercions that are applied from left-to-right at most once
at beginning of the coercion chain. |
CoeHTC (α : Sort u) (β : Sort v) where
/-- Coerces a value of type `α` to type `β`. Accessible by the notation `↑x`,
or by double type ascription `((x : α) : β)`. -/
coe : α → β
attribute [coe_decl] CoeHTC.coe | class | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | CoeHTC | Auxiliary class implementing `CoeHead CoeOut* Coe*`.
Users should generally not implement this directly. |
CoeTail (α : semiOutParam (Sort u)) (β : Sort v) where
/-- Coerces a value of type `α` to type `β`. Accessible by the notation `↑x`,
or by double type ascription `((x : α) : β)`. -/
coe : α → β
attribute [coe_decl] CoeTail.coe | class | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | CoeTail | `CoeTail α β` is for coercions that can only appear at the end of a
sequence of coercions. That is, `α` can be further coerced via `Coe σ α` and
`CoeHead τ σ` instances but `β` will only be the expected type of the expression. |
CoeHTCT (α : Sort u) (β : Sort v) where
/-- Coerces a value of type `α` to type `β`. Accessible by the notation `↑x`,
or by double type ascription `((x : α) : β)`. -/
coe : α → β
attribute [coe_decl] CoeHTCT.coe | class | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | CoeHTCT | Auxiliary class implementing `CoeHead* Coe* CoeTail?`.
Users should generally not implement this directly. |
CoeDep (α : Sort u) (_ : α) (β : Sort v) where
/-- The resulting value of type `β`. The input `x : α` is a parameter to
the type class, so the value of type `β` may possibly depend on additional
typeclasses on `x`. -/
coe : β
attribute [coe_decl] CoeDep.coe | class | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | CoeDep | `CoeDep α (x : α) β` is a typeclass for dependent coercions, that is, the type `β`
can depend on `x` (or rather, the value of `x` is available to typeclass search
so an instance that relates `β` to `x` is allowed).
Dependent coercions do not participate in the transitive chaining process of
regular coercions: they mus... |
CoeT (α : Sort u) (_ : α) (β : Sort v) where
/-- The resulting value of type `β`. The input `x : α` is a parameter to
the type class, so the value of type `β` may possibly depend on additional
typeclasses on `x`. -/
coe : β
attribute [coe_decl] CoeT.coe | class | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | CoeT | `CoeT` is the core typeclass which is invoked by Lean to resolve a type error.
It can also be triggered explicitly with the notation `↑x` or by double type
ascription `((x : α) : β)`.
A `CoeT` chain has the grammar `CoeHead? CoeOut* Coe* CoeTail? | CoeDep`. |
CoeFun (α : Sort u) (γ : outParam (α → Sort v)) where
/-- Coerces a value `f : α` to type `γ f`, which should be either be a
function type or another `CoeFun` type, in order to resolve a mistyped
application `f x`. -/
coe : (f : α) → γ f
attribute [coe_decl] CoeFun.coe | class | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | CoeFun | `CoeFun α (γ : α → Sort v)` is a coercion to a function. `γ a` should be a
(coercion-to-)function type, and this is triggered whenever an element
`f : α` appears in an application like `f x`, which would not make sense since
`f` does not have a function type.
`CoeFun` instances apply to `CoeOut` as well. |
CoeSort (α : Sort u) (β : outParam (Sort v)) where
/-- Coerces a value of type `α` to `β`, which must be a universe. -/
coe : α → β
attribute [coe_decl] CoeSort.coe | class | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | CoeSort | `CoeSort α β` is a coercion to a sort. `β` must be a universe, and this is
triggered when `a : α` appears in a place where a type is expected, like
`(x : a)` or `a → a`.
`CoeSort` instances apply to `CoeOut` as well. |
boolToProp : Coe Bool Prop where
coe b := Eq b true | instance | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | boolToProp | `↑x` represents a coercion, which converts `x` of type `α` to type `β`, using
typeclasses to resolve a suitable conversion function. You can often leave the
`↑` off entirely, since coercion is triggered implicitly whenever there is a
type error, but in ambiguous cases it can be useful to use `↑` to disambiguate
between... |
boolToSort : CoeSort Bool Prop where
coe b := b | instance | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | boolToSort | null |
decPropToBool (p : Prop) [Decidable p] : CoeDep Prop p Bool where
coe := decide p | instance | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | decPropToBool | null |
subtypeCoe {α : Sort u} {p : α → Prop} : CoeOut (Subtype p) α where
coe v := v.val
/-! # Coe bridge -/ | instance | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | subtypeCoe | null |
@[coe_decl] Lean.Internal.liftCoeM {m : Type u → Type v} {n : Type u → Type w} {α β : Type u}
[MonadLiftT m n] [∀ a, CoeT α a β] [Monad n] (x : m α) : n β := do
let a ← liftM x
pure (CoeT.coe a) | abbrev | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | Lean.Internal.liftCoeM | Helper definition used by the elaborator. It is not meant to be used directly by users.
This is used for coercions between monads, in the case where we want to apply
a monad lift and a coercion on the result type at the same time. |
@[coe_decl] Lean.Internal.coeM {m : Type u → Type v} {α β : Type u}
[∀ a, CoeT α a β] [Monad m] (x : m α) : m β := do
let a ← x
pure (CoeT.coe a) | abbrev | Init.Coe | [
"Init.Prelude"
] | Init/Coe.lean | Lean.Internal.coeM | Helper definition used by the elaborator. It is not meant to be used directly by users.
This is used for coercing the result type under a monad. |
@[simp] inline {α : Sort u} (a : α) : α := a | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | inline | `inline (f x)` is an indication to the compiler to inline the definition of `f`
at the application site itself (by comparison to the `@[inline]` attribute,
which applies to all applications of the function). |
id_def {α : Sort u} (a : α) : id a = a := rfl
attribute [grind] id | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | id_def | null |
@[expose] eagerReduce {α : Sort u} (a : α) : α := a | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | eagerReduce | A helper gadget for instructing the kernel to eagerly reduce terms.
When the gadget wraps the argument of an application, then when checking that
the expected and inferred type of the argument match, the kernel will evaluate terms more eagerly.
It is often used to wrap `Eq.refl true` proof terms as `eagerReduce (Eq.re... |
@[inline] flip {α : Sort u} {β : Sort v} {φ : Sort w} (f : α → β → φ) : β → α → φ :=
fun b a => f a b
@[simp] theorem Function.const_apply {y : β} {x : α} : const α y x = y := rfl
@[simp] theorem Function.comp_apply {f : β → δ} {g : α → β} {x : α} : comp f g x = f (g x) := rfl | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | flip | `flip f a b` is `f b a`. It is useful for "point-free" programming,
since it can sometimes be used to avoid introducing variables.
For example, `(·<·)` is the less-than relation,
and `flip (·<·)` is the greater-than relation. |
Function.comp_def {α β δ} (f : β → δ) (g : α → β) : f ∘ g = fun x => f (g x) := rfl
@[simp] theorem Function.const_comp {f : α → β} {c : γ} :
(Function.const β c ∘ f) = Function.const α c :=
rfl
@[simp] theorem Function.comp_const {f : β → γ} {b : β} :
(f ∘ Function.const α b) = Function.const α (f b) :=
r... | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Function.comp_def | null |
@[macro_inline] Empty.elim {C : Sort u} : Empty → C := Empty.rec | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Empty.elim | `Empty.elim : Empty → C` says that a value of any type can be constructed from
`Empty`. This can be thought of as a compiler-checked assertion that a code path is unreachable. |
@[macro_inline] PEmpty.elim {C : Sort _} : PEmpty → C := fun a => nomatch a | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | PEmpty.elim | Decidable equality for Empty -/
instance : DecidableEq Empty := fun a => a.elim
/--
`PEmpty.elim : Empty → C` says that a value of any type can be constructed from
`PEmpty`. This can be thought of as a compiler-checked assertion that a code path is unreachable. |
Thunk (α : Type u) : Type u where
/--
Constructs a new thunk from a function `Unit → α` that will be called when the thunk is first
forced.
The result is cached. It is re-used when the thunk is forced again.
-/
mk ::
/-- Extract the getter function out of a thunk. Use `Thunk.get` instead. -/
-- The fie... | structure | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Thunk | Decidable equality for PEmpty -/
instance : DecidableEq PEmpty := fun a => a.elim
/--
Delays evaluation. The delayed code is evaluated at most once.
A thunk is code that constructs a value when it is requested via `Thunk.get`, `Thunk.map`, or
`Thunk.bind`. The resulting value is cached, so the code is executed at mos... |
@[extern "lean_thunk_pure"] protected Thunk.pure (a : α) : Thunk α :=
⟨fun _ => a⟩ | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Thunk.pure | Stores an already-computed value in a thunk.
Because the value has already been computed, there is no laziness. |
@[inline] Thunk.fnImpl (x : Thunk α) : Unit → α := fun _ => x.get
@[csimp] theorem Thunk.fn_eq_fnImpl : @Thunk.fn = @Thunk.fnImpl := rfl | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Thunk.fnImpl | Gets the thunk's value. If the value is cached, it is returned in constant time; if not, it is
computed.
Computed values are cached, so the value is not recomputed.
-/
-- NOTE: we use `Thunk.get` instead of `Thunk.fn` as the accessor primitive as the latter has an additional `Unit` argument
@[extern "lean_thunk_get_ow... |
@[inline] protected Thunk.map (f : α → β) (x : Thunk α) : Thunk β :=
⟨fun _ => f x.get⟩ | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Thunk.map | Constructs a new thunk that forces `x` and then applies `x` to the result. Upon forcing, the result
of `f` is cached and the reference to the thunk `x` is dropped. |
@[inline] protected Thunk.bind (x : Thunk α) (f : α → Thunk β) : Thunk β :=
⟨fun _ => (f x.get).get⟩
@[simp] theorem Thunk.sizeOf_eq [SizeOf α] (a : Thunk α) : sizeOf a = 1 + sizeOf a.get := by
cases a; rfl | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Thunk.bind | Constructs a new thunk that applies `f` to the result of `x` when forced. |
thunkCoe : CoeTail α (Thunk α) where
-- Since coercions are expanded eagerly, `a` is evaluated lazily.
coe a := ⟨fun _ => a⟩ | instance | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | thunkCoe | null |
Eq.ndrecOn.{u1, u2} {α : Sort u2} {a : α} {motive : α → Sort u1} {b : α} (h : a = b) (m : motive a) : motive b :=
Eq.ndrec m h
/-! # definitions -/ | abbrev | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Eq.ndrecOn. | A variation on `Eq.ndrec` with the equality argument first. |
Iff (a b : Prop) : Prop where
/-- If `a → b` and `b → a` then `a` and `b` are equivalent. -/
intro ::
/-- Modus ponens for if and only if. If `a ↔ b` and `a`, then `b`. -/
mp : a → b
/-- Modus ponens for if and only if, reversed. If `a ↔ b` and `b`, then `a`. -/
mpr : b → a
@[inherit_doc] infix:20 " <-> " ... | structure | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Iff | If and only if, or logical bi-implication. `a ↔ b` means that `a` implies `b` and vice versa.
By `propext`, this implies that `a` and `b` are equal and hence any expression involving `a`
is equivalent to the corresponding expression with `b` instead. |
@[suggest_for Either]
Sum (α : Type u) (β : Type v) where
/-- Left injection into the sum type `α ⊕ β`. -/
| inl (val : α) : Sum α β
/-- Right injection into the sum type `α ⊕ β`. -/
| inr (val : β) : Sum α β
@[inherit_doc] infixr:30 " ⊕ " => Sum | inductive | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Sum | prefer `↔` over `<->` -/
recommended_spelling "iff" for "<->" in [Iff, «term_<->_»]
/--
The disjoint union of types `α` and `β`, ordinarily written `α ⊕ β`.
An element of `α ⊕ β` is either an `a : α` wrapped in `Sum.inl` or a `b : β` wrapped in `Sum.inr`.
`α ⊕ β` is not equivalent to the set-theoretic union of `α` an... |
PSum (α : Sort u) (β : Sort v) where
/-- Left injection into the sum type `α ⊕' β`.-/
| inl (val : α) : PSum α β
/-- Right injection into the sum type `α ⊕' β`. -/
| inr (val : β) : PSum α β
@[inherit_doc] infixr:30 " ⊕' " => PSum | inductive | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | PSum | The disjoint union of arbitrary sorts `α` `β`, or `α ⊕' β`.
It differs from `α ⊕ β` in that it allows `α` and `β` to have arbitrary sorts `Sort u` and `Sort v`,
instead of restricting them to `Type u` and `Type v`. This means that it can be used in situations
where one side is a proposition, like `True ⊕' Nat`. Howeve... |
@[reducible] PSum.inhabitedLeft {α β} [Inhabited α] : Inhabited (PSum α β) := ⟨PSum.inl default⟩ | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | PSum.inhabitedLeft | If the left type in a sum is inhabited then the sum is inhabited.
This is not an instance to avoid non-canonical instances when both the left and right types are
inhabited. |
@[reducible] PSum.inhabitedRight {α β} [Inhabited β] : Inhabited (PSum α β) := ⟨PSum.inr default⟩ | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | PSum.inhabitedRight | If the right type in a sum is inhabited then the sum is inhabited.
This is not an instance to avoid non-canonical instances when both the left and right types are
inhabited. |
PSum.nonemptyLeft [h : Nonempty α] : Nonempty (PSum α β) :=
Nonempty.elim h (fun a => ⟨PSum.inl a⟩) | instance | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | PSum.nonemptyLeft | null |
PSum.nonemptyRight [h : Nonempty β] : Nonempty (PSum α β) :=
Nonempty.elim h (fun b => ⟨PSum.inr b⟩) | instance | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | PSum.nonemptyRight | null |
@[pp_using_anonymous_constructor]
Sigma {α : Type u} (β : α → Type v) where
/--
Constructs a dependent pair.
Using this constructor in a context in which the type is not known usually requires a type
ascription to determine `β`. This is because the desired relationship between the two values can't
generally ... | structure | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Sigma | Dependent pairs, in which the second element's type depends on the value of the first element. The
type `Sigma β` is typically written `Σ a : α, β a` or `(a : α) × β a`.
Although its values are pairs, `Sigma` is sometimes known as the *dependent sum type*, since it is
the type level version of an indexed summation. |
@[pp_using_anonymous_constructor]
PSigma {α : Sort u} (β : α → Sort v) where
/-- Constructs a fully universe-polymorphic dependent pair. -/
mk ::
/--
The first component of a dependent pair.
-/
fst : α
/--
The second component of a dependent pair. Its type depends on the first component.
-/
snd : β ... | structure | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | PSigma | Fully universe-polymorphic dependent pairs, in which the second element's type depends on the value
of the first element and both types are allowed to be propositions. The type `PSigma β` is typically
written `Σ' a : α, β a` or `(a : α) ×' β a`.
In practice, this generality leads to universe level constraints that are... |
Exists {α : Sort u} (p : α → Prop) : Prop where
/-- Existential introduction. If `a : α` and `h : p a`,
then `⟨a, h⟩` is a proof that `∃ x : α, p x`. -/
| intro (w : α) (h : p w) : Exists p | inductive | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Exists | Existential quantification. If `p : α → Prop` is a predicate, then `∃ x : α, p x`
asserts that there is some `x` of type `α` such that `p x` holds.
To create an existential proof, use the `exists` tactic,
or the anonymous constructor notation `⟨x, h⟩`.
To unpack an existential, use `cases h` where `h` is a proof of `∃ ... |
ForInStep (α : Type u) where
/--
The loop should terminate early.
`ForInStep.done` is produced by uses of `break` or `return` in the loop body.
-/
| done : α → ForInStep α
/--
The loop should continue with the next iteration, using the returned state.
`ForInStep.yield` is produced by `continue` and b... | inductive | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | ForInStep | An indication of whether a loop's body terminated early that's used to compile the `for x in xs`
notation.
A collection's `ForIn` or `ForIn'` instance describes how to iterate over its elements. The monadic
action that represents the body of the loop returns a `ForInStep α`, where `α` is the local state
used to implem... |
ForIn (m : Type u₁ → Type u₂) (ρ : Type u) (α : outParam (Type v)) where
/--
Monadically iterates over the contents of a collection `xs`, with a local state `b` and the
possibility of early termination.
Because a `do` block supports local mutable bindings along with `return`, and `break`, the monadic
action ... | class | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | ForIn | Monadic iteration in `do`-blocks, using the `for x in xs` notation.
The parameter `m` is the monad of the `do`-block in which iteration is performed, `ρ` is the type of
the collection being iterated over, and `α` is the type of elements. |
ForIn' (m : Type u₁ → Type u₂) (ρ : Type u) (α : outParam (Type v)) (d : outParam (Membership α ρ)) where
/--
Monadically iterates over the contents of a collection `xs`, with a local state `b` and the
possibility of early termination. At each iteration, the body of the loop is provided with a proof
that the cu... | class | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | ForIn' | Monadic iteration in `do`-blocks with a membership proof, using the `for h : x in xs` notation.
The parameter `m` is the monad of the `do`-block in which iteration is performed, `ρ` is the type of
the collection being iterated over, `α` is the type of elements, and `d` is the specific membership
predicate to provide. |
DoResultPRBC (α β σ : Type u) where
/-- `pure (a : α) s` means that the block exited normally with return value `a` -/
| pure : α → σ → DoResultPRBC α β σ
/-- `return (b : β) s` means that the block exited via a `return b` early-exit command -/
| return : β → σ → DoResultPRBC α β σ
/-- `break s` means that `b... | inductive | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | DoResultPRBC | Auxiliary type used to compile `do` notation. It is used when compiling a do block
nested inside a combinator like `tryCatch`. It encodes the possible ways the
block can exit:
* `pure (a : α) s` means that the block exited normally with return value `a`.
* `return (b : β) s` means that the block exited via a `return b`... |
DoResultPR (α β σ : Type u) where
/-- `pure (a : α) s` means that the block exited normally with return value `a` -/
| pure : α → σ → DoResultPR α β σ
/-- `return (b : β) s` means that the block exited via a `return b` early-exit command -/
| return : β → σ → DoResultPR α β σ | inductive | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | DoResultPR | Auxiliary type used to compile `do` notation. It is the same as
`DoResultPRBC α β σ` except that `break` and `continue` are not available
because we are not in a loop context. |
DoResultBC (σ : Type u) where
/-- `break s` means that `break` was called, meaning that we should exit
from the containing loop -/
| break : σ → DoResultBC σ
/-- `continue s` means that `continue` was called, meaning that we should continue
to the next iteration of the containing loop -/
| continue : σ →... | inductive | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | DoResultBC | Auxiliary type used to compile `do` notation. It is an optimization of
`DoResultPRBC PEmpty PEmpty σ` to remove the impossible cases,
used when neither `pure` nor `return` are possible exit paths. |
DoResultSBC (α σ : Type u) where
/-- This encodes either `pure (a : α)` or `return (a : α)`:
* `pure (a : α) s` means that the block exited normally with return value `a`
* `return (b : β) s` means that the block exited via a `return b` early-exit command
The one that is actually encoded depends on the context... | inductive | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | DoResultSBC | Auxiliary type used to compile `do` notation. It is an optimization of
either `DoResultPRBC α PEmpty σ` or `DoResultPRBC PEmpty α σ` to remove the
impossible case, used when either `pure` or `return` is never used. |
HasEquiv (α : Sort u) where
/-- `x ≈ y` says that `x` and `y` are equivalent. Because this is a typeclass,
the notion of equivalence is type-dependent. -/
Equiv : α → α → Sort v
@[inherit_doc] infix:50 " ≈ " => HasEquiv.Equiv
recommended_spelling "equiv" for "≈" in [HasEquiv.Equiv, «term_≈_»]
/-! # set notati... | class | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | HasEquiv | `HasEquiv α` is the typeclass which supports the notation `x ≈ y` where `x y : α`. |
HasSubset (α : Type u) where
/-- Subset relation: `a ⊆ b` -/
Subset : α → α → Prop
export HasSubset (Subset) | class | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | HasSubset | Notation type class for the subset relation `⊆`. |
HasSSubset (α : Type u) where
/-- Strict subset relation: `a ⊂ b` -/
SSubset : α → α → Prop
export HasSSubset (SSubset) | class | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | HasSSubset | Notation type class for the strict subset relation `⊂`. |
Superset [HasSubset α] (a b : α) := Subset b a | abbrev | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Superset | Superset relation: `a ⊇ b` |
SSuperset [HasSSubset α] (a b : α) := SSubset b a | abbrev | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | SSuperset | Strict superset relation: `a ⊃ b` |
Union (α : Type u) where
/-- `a ∪ b` is the union of `a` and `b`. -/
union : α → α → α | class | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Union | Notation type class for the union operation `∪`. |
Inter (α : Type u) where
/-- `a ∩ b` is the intersection of `a` and `b`. -/
inter : α → α → α | class | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Inter | Notation type class for the intersection operation `∩`. |
SDiff (α : Type u) where
/--
`a \ b` is the set difference of `a` and `b`,
consisting of all elements in `a` that are not in `b`.
-/
sdiff : α → α → α | class | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | SDiff | Notation type class for the set difference `\`. |
EmptyCollection (α : Type u) where
/-- `∅` or `{}` is the empty set or empty collection.
It is supported by the `EmptyCollection` typeclass. -/
emptyCollection : α
@[inherit_doc] notation "{" "}" => EmptyCollection.emptyCollection
@[inherit_doc] notation "∅" => EmptyCollection.emptyCollection
recommended_sp... | class | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | EmptyCollection | Subset relation: `a ⊆ b` -/
infix:50 " ⊆ " => Subset
/-- Strict subset relation: `a ⊂ b` -/
infix:50 " ⊂ " => SSubset
/-- Superset relation: `a ⊇ b` -/
infix:50 " ⊇ " => Superset
/-- Strict superset relation: `a ⊃ b` -/
infix:50 " ⊃ " => SSuperset
/-- `a ∪ b` is the union of `a` and `b`. -/
infixl:65 " ∪ " => U... |
Insert (α : outParam <| Type u) (γ : Type v) where
/-- `insert x xs` inserts the element `x` into the collection `xs`. -/
insert : α → γ → γ
export Insert (insert) | class | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Insert | Type class for the `insert` operation.
Used to implement the `{ a, b, c }` syntax. |
Singleton (α : outParam <| Type u) (β : Type v) where
/-- `singleton x` is a collection with the single element `x` (notation: `{x}`). -/
singleton : α → β
export Singleton (singleton) | class | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Singleton | Type class for the `singleton` operation.
Used to implement the `{ a, b, c }` syntax. |
Structured dataset of definitions and theorems from the Lean 4 standard library (Init + Std).
| Column | Type | Description |
|---|---|---|
| fact | string | Declaration body (without type keyword) |
| type | string | theorem, def, class, structure, instance, inductive, abbrev, axiom, opaque |
| library | string | Init.* or Std.* module |
| imports | list | Import statements |
| filename | string | Source file path |
| symbolic_name | string | Declaration identifier |
| docstring | string | Documentation comment (16% coverage) |
| Type | Count |
|---|---|
| theorem | 31,887 |
| def | 6,600 |
| instance | 426 |
| abbrev | 425 |
| opaque | 399 |
| structure | 382 |
| class | 302 |
| inductive | 163 |
| axiom | 16 |