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 ⌀ |
|---|---|---|---|---|---|---|
LawfulSingleton (α : Type u) (β : Type v) [EmptyCollection β] [Insert α β] [Singleton α β] :
Prop where
/-- `insert x ∅ = {x}` -/
insert_empty_eq (x : α) : (insert x ∅ : β) = singleton x
export LawfulSingleton (insert_empty_eq)
attribute [simp] insert_empty_eq | class | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | LawfulSingleton | `insert x ∅ = {x}` |
Sep (α : outParam <| Type u) (γ : Type v) where
/-- Computes `{ a ∈ c | p a }`. -/
sep : (α → Prop) → γ → γ | class | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Sep | Type class used to implement the notation `{ a ∈ c | p a }` |
Task (α : Type u) : Type u where
/-- `Task.pure (a : α)` constructs a task that is already resolved with value `a`. -/
pure ::
/--
Blocks the current thread until the given task has finished execution, and then returns the result
of the task. If the current thread is itself executing a (non-dedicated) task, t... | structure | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Task | `Task α` is a primitive for asynchronous computation.
It represents a computation that will resolve to a value of type `α`,
possibly being computed on another thread. This is similar to `Future` in Scala,
`Promise` in Javascript, and `JoinHandle` in Rust.
The tasks have an overridden representation in the runtime. |
Priority := Nat | abbrev | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Priority | Task priority.
Tasks with higher priority will always be scheduled before tasks with lower priority. Tasks with a
priority greater than `Task.Priority.max` are scheduled on dedicated threads. |
Priority.default : Priority := 0 | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Priority.default | The default priority for spawned tasks, also the lowest priority: `0`. |
Priority.dedicated : Priority := 9
set_option linter.unusedVariables.funArgs false in | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Priority.dedicated | The highest regular priority for spawned tasks: `8`.
Spawning a task with a priority higher than `Task.Priority.max` is not an error but will spawn a
dedicated worker for the task. This is indicated using `Task.Priority.dedicated`. Regular priority
tasks are placed in a thread pool and worked on according to their pri... |
@[noinline, extern "lean_task_spawn"]
protected spawn {α : Type u} (fn : Unit → α) (prio := Priority.default) : Task α :=
⟨fn ()⟩
set_option linter.unusedVariables.funArgs false in | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | spawn | `spawn fn : Task α` constructs and immediately launches a new task for
evaluating the function `fn () : α` asynchronously.
`prio`, if provided, is the priority of the task. |
@[noinline, extern "lean_task_map"]
protected map (f : α → β) (x : Task α) (prio := Priority.default) (sync := false) : Task β :=
⟨f x.get⟩
set_option linter.unusedVariables.funArgs false in | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | map | `map f x` maps function `f` over the task `x`: that is, it constructs
(and immediately launches) a new task which will wait for the value of `x` to
be available and then calls `f` on the result.
`prio`, if provided, is the priority of the task.
If `sync` is set to true, `f` is executed on the current thread if `x` has... |
@[noinline, extern "lean_task_bind"]
protected bind (x : Task α) (f : α → Task β) (prio := Priority.default) (sync := false) :
Task β :=
⟨(f x.get).get⟩ | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | bind | `bind x f` does a monad "bind" operation on the task `x` with function `f`:
that is, it constructs (and immediately launches) a new task which will wait
for the value of `x` to be available and then calls `f` on the result,
resulting in a new task which is then run for a result.
`prio`, if provided, is the priority of... |
NonScalar where
/-- You should not use this function -/ mk ::
/-- You should not use this function -/ val : Nat | structure | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | NonScalar | `NonScalar` is a type that is not a scalar value in our runtime.
It is used as a stand-in for an arbitrary boxed value to avoid excessive
monomorphization, and it is only created using `unsafeCast`. It is somewhat
analogous to C `void*` in usage, but the type itself is not special. |
PNonScalar : Type u where
/-- You should not use this function -/
| mk (v : Nat) : PNonScalar
@[simp] protected theorem Nat.add_zero (n : Nat) : n + 0 = n := rfl | inductive | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | PNonScalar | `PNonScalar` is a type that is not a scalar value in our runtime.
It is used as a stand-in for an arbitrary boxed value to avoid excessive
monomorphization, and it is only created using `unsafeCast`. It is somewhat
analogous to C `void*` in usage, but the type itself is not special.
This is the universe-polymorphic ve... |
optParam_eq (α : Sort u) (default : α) : optParam α default = α := rfl
/-! # Boolean operators -/ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | optParam_eq | null |
@[extern "lean_strict_or"] strictOr (b₁ b₂ : Bool) := b₁ || b₂ | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | strictOr | `strictOr` is the same as `or`, but it does not use short-circuit evaluation semantics:
both sides are evaluated, even if the first value is `true`. |
@[extern "lean_strict_and"] strictAnd (b₁ b₂ : Bool) := b₁ && b₂ | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | strictAnd | `strictAnd` is the same as `and`, but it does not use short-circuit evaluation semantics:
both sides are evaluated, even if the first value is `false`. |
@[inline] bne {α : Type u} [BEq α] (a b : α) : Bool :=
!(a == b)
@[inherit_doc] infix:50 " != " => bne
macro_rules | `($x != $y) => `(binrel_no_prop% bne $x $y)
recommended_spelling "bne" for "!=" in [bne, «term_!=_»] | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | bne | `x != y` is boolean not-equal. It is the negation of `x == y` which is supplied by
the `BEq` typeclass.
Unlike `x ≠ y` (which is notation for `Ne x y`), this is `Bool` valued instead of
`Prop` valued. It is mainly intended for programming applications. |
ReflBEq (α) [BEq α] : Prop where
/-- `==` is reflexive, that is, `(a == a) = true`. -/
protected rfl {a : α} : a == a
@[simp] theorem BEq.rfl [BEq α] [ReflBEq α] {a : α} : a == a := ReflBEq.rfl | class | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | ReflBEq | `ReflBEq α` says that the `BEq` implementation is reflexive. |
BEq.refl [BEq α] [ReflBEq α] (a : α) : a == a := BEq.rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | BEq.refl | null |
beq_of_eq [BEq α] [ReflBEq α] {a b : α} : a = b → a == b
| rfl => BEq.rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | beq_of_eq | null |
not_eq_of_beq_eq_false [BEq α] [ReflBEq α] {a b : α} (h : (a == b) = false) : ¬a = b := by
intro h'; subst h'; have : true = false := BEq.rfl.symm.trans h; contradiction | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | not_eq_of_beq_eq_false | null |
LawfulBEq (α : Type u) [BEq α] : Prop extends ReflBEq α where
/-- If `a == b` evaluates to `true`, then `a` and `b` are equal in the logic. -/
eq_of_beq : {a b : α} → a == b → a = b
export LawfulBEq (eq_of_beq) | class | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | LawfulBEq | A Boolean equality test coincides with propositional equality.
In other words:
* `a == b` implies `a = b`.
* `a == a` is true. |
instDecidableEqOfLawfulBEq [BEq α] [LawfulBEq α] : DecidableEq α := fun x y =>
match h : x == y with
| false => .isFalse (not_eq_of_beq_eq_false h)
| true => .isTrue (eq_of_beq h) | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | instDecidableEqOfLawfulBEq | Non-instance for `DecidableEq` from `LawfulBEq`.
To use this, add `attribute [local instance 5] instDecidableEqOfLawfulBEq` at the top of a file. |
@[inherit_doc True.intro] trivial : True := ⟨⟩ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | trivial | null |
mt {a b : Prop} (h₁ : a → b) (h₂ : ¬b) : ¬a :=
fun ha => h₂ (h₁ ha) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | mt | null |
not_false : ¬False := id | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | not_false | null |
not_not_intro {p : Prop} (h : p) : ¬ ¬ p :=
fun hn : ¬ p => hn h
-- proof irrelevance is built in | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | not_not_intro | null |
proof_irrel {a : Prop} (h₁ h₂ : a) : h₁ = h₂ := rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | proof_irrel | null |
@[macro_inline] Eq.mp {α β : Sort u} (h : α = β) (a : α) : β :=
h ▸ a | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Eq.mp | If `h : α = β` is a proof of type equality, then `h.mp : α → β` is the induced
"cast" operation, mapping elements of `α` to elements of `β`.
You can prove theorems about the resulting element by induction on `h`, since
`rfl.mp` is definitionally the identity function. |
@[macro_inline] Eq.mpr {α β : Sort u} (h : α = β) (b : β) : α :=
h ▸ b
@[elab_as_elim] | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Eq.mpr | If `h : α = β` is a proof of type equality, then `h.mpr : β → α` is the induced
"cast" operation in the reverse direction, mapping elements of `β` to elements of `α`.
You can prove theorems about the resulting element by induction on `h`, since
`rfl.mpr` is definitionally the identity function. |
Eq.substr {α : Sort u} {p : α → Prop} {a b : α} (h₁ : b = a) (h₂ : p a) : p b :=
h₁ ▸ h₂
@[simp] theorem cast_eq {α : Sort u} (h : α = α) (a : α) : cast h a = a :=
rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Eq.substr | null |
@[reducible] Ne {α : Sort u} (a b : α) :=
¬(a = b)
@[inherit_doc] infix:50 " ≠ " => Ne
macro_rules | `($x ≠ $y) => `(binrel% Ne $x $y)
recommended_spelling "ne" for "≠" in [Ne, «term_≠_»] | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Ne | `a ≠ b`, or `Ne a b` is defined as `¬ (a = b)` or `a = b → False`,
and asserts that `a` and `b` are not equal. |
Ne.intro (h : a = b → False) : a ≠ b := h | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Ne.intro | null |
Ne.elim (h : a ≠ b) : a = b → False := h | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Ne.elim | null |
Ne.irrefl (h : a ≠ a) : False := h rfl
@[symm] theorem Ne.symm (h : a ≠ b) : b ≠ a := fun h₁ => h (h₁.symm) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Ne.irrefl | null |
ne_comm {α} {a b : α} : a ≠ b ↔ b ≠ a := ⟨Ne.symm, Ne.symm⟩ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | ne_comm | null |
false_of_ne : a ≠ a → False := Ne.irrefl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | false_of_ne | null |
ne_false_of_self : p → p ≠ False :=
fun (hp : p) (h : p = False) => h ▸ hp | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | ne_false_of_self | null |
ne_true_of_not : ¬p → p ≠ True :=
fun (hnp : ¬p) (h : p = True) =>
have : ¬True := h ▸ hnp
this trivial | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | ne_true_of_not | null |
true_ne_false : ¬True = False := ne_false_of_self trivial | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | true_ne_false | null |
false_ne_true : False ≠ True := fun h => h.symm ▸ trivial | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | false_ne_true | null |
Bool.of_not_eq_true : {b : Bool} → ¬ (b = true) → b = false
| true, h => absurd rfl h
| false, _ => rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Bool.of_not_eq_true | null |
Bool.of_not_eq_false : {b : Bool} → ¬ (b = false) → b = true
| true, _ => rfl
| false, h => absurd rfl h | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Bool.of_not_eq_false | null |
ne_of_beq_false [BEq α] [ReflBEq α] {a b : α} (h : (a == b) = false) : a ≠ b :=
not_eq_of_beq_eq_false h | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | ne_of_beq_false | null |
beq_false_of_ne [BEq α] [LawfulBEq α] {a b : α} (h : a ≠ b) : (a == b) = false :=
have : ¬ (a == b) = true := by
intro h'; rw [eq_of_beq h'] at h; contradiction
Bool.of_not_eq_true this | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | beq_false_of_ne | null |
noncomputable HEq.ndrec.{u1, u2} {α : Sort u2} {a : α} {motive : {β : Sort u2} → β → Sort u1} (m : motive a) {β : Sort u2} {b : β} (h : a ≍ b) : motive b :=
h.rec m | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | HEq.ndrec. | Non-dependent recursor for `HEq` |
noncomputable HEq.ndrecOn.{u1, u2} {α : Sort u2} {a : α} {motive : {β : Sort u2} → β → Sort u1} {β : Sort u2} {b : β} (h : a ≍ b) (m : motive a) : motive b :=
h.rec m | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | HEq.ndrecOn. | `HEq.ndrec` variant |
noncomputable HEq.elim {α : Sort u} {a : α} {p : α → Sort v} {b : α} (h₁ : a ≍ b) (h₂ : p a) : p b :=
eq_of_heq h₁ ▸ h₂ | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | HEq.elim | `HEq.ndrec` variant |
HEq.subst {p : (T : Sort u) → T → Prop} (h₁ : a ≍ b) (h₂ : p α a) : p β b :=
HEq.ndrecOn h₁ h₂ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | HEq.subst | Substitution with heterogeneous equality. |
@[symm] HEq.symm (h : a ≍ b) : b ≍ a :=
h.rec (HEq.refl a) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | HEq.symm | Heterogeneous equality is symmetric. |
HEq.trans (h₁ : a ≍ b) (h₂ : b ≍ c) : a ≍ c :=
HEq.subst h₂ h₁ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | HEq.trans | Heterogeneous equality is transitive. |
heq_of_heq_of_eq (h₁ : a ≍ b) (h₂ : b = b') : a ≍ b' :=
HEq.trans h₁ (heq_of_eq h₂) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | heq_of_heq_of_eq | Heterogeneous equality precomposes with propositional equality. |
heq_of_eq_of_heq (h₁ : a = a') (h₂ : a' ≍ b) : a ≍ b :=
HEq.trans (heq_of_eq h₁) h₂ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | heq_of_eq_of_heq | Heterogeneous equality postcomposes with propositional equality. |
type_eq_of_heq (h : a ≍ b) : α = β :=
h.rec (Eq.refl α) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | type_eq_of_heq | If two terms are heterogeneously equal then their types are propositionally equal. |
eqRec_heq {α : Sort u} {φ : α → Sort v} {a a' : α} : (h : a = a') → (p : φ a) → Eq.recOn (motive := fun x _ => φ x) h p ≍ p
| rfl, p => HEq.refl p | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | eqRec_heq | Rewriting inside `φ` using `Eq.recOn` yields a term that's heterogeneously equal to the original
term. |
eqRec_heq_iff {α : Sort u} {a : α} {motive : (b : α) → a = b → Sort v}
{b : α} {refl : motive a (Eq.refl a)} {h : a = b} {c : motive b h}
: @Eq.rec α a motive refl b h ≍ c ↔ refl ≍ c :=
h.rec (fun _ => ⟨id, id⟩) c | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | eqRec_heq_iff | Heterogeneous equality with an `Eq.rec` application on the left is equivalent to a heterogeneous
equality on the original term. |
heq_eqRec_iff {α : Sort u} {a : α} {motive : (b : α) → a = b → Sort v}
{b : α} {refl : motive a (Eq.refl a)} {h : a = b} {c : motive b h} :
c ≍ @Eq.rec α a motive refl b h ↔ c ≍ refl :=
h.rec (fun _ => ⟨id, id⟩) c | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | heq_eqRec_iff | Heterogeneous equality with an `Eq.rec` application on the right is equivalent to a heterogeneous
equality on the original term. |
apply_eqRec {α : Sort u} {a : α} (motive : (b : α) → a = b → Sort v)
{b : α} {h : a = b} {c : motive a (Eq.refl a) → β} {d : motive b h} :
@Eq.rec α a (fun b h => motive b h → β) c b h d = c (h.symm ▸ d) := by
cases h; rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | apply_eqRec | Moves an cast using `Eq.rec` from the function to the argument.
Note: because the motive isn't reliably detected by unification,
it needs to be provided as an explicit parameter. |
heq_of_eqRec_eq {α β : Sort u} {a : α} {b : β} (h₁ : α = β) (h₂ : Eq.rec (motive := fun α _ => α) a h₁ = b) : a ≍ b := by
subst h₁
apply heq_of_eq
exact h₂ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | heq_of_eqRec_eq | If casting a term with `Eq.rec` to another type makes it equal to some other term, then the two
terms are heterogeneously equal. |
cast_heq {α β : Sort u} : (h : α = β) → (a : α) → cast h a ≍ a
| rfl, a => HEq.refl a
variable {a b c d : Prop} | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | cast_heq | The result of casting a term with `cast` is heterogeneously equal to the original term. |
iff_iff_implies_and_implies {a b : Prop} : (a ↔ b) ↔ (a → b) ∧ (b → a) :=
Iff.intro (fun h => And.intro h.mp h.mpr) (fun h => Iff.intro h.left h.right)
@[refl] theorem Iff.refl (a : Prop) : a ↔ a :=
Iff.intro (fun h => h) (fun h => h) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | iff_iff_implies_and_implies | null |
protected Iff.rfl {a : Prop} : a ↔ a :=
Iff.refl a
-- And, also for backward compatibility, we try `Iff.rfl.` using `exact` (see #5366)
macro_rules | `(tactic| rfl) => `(tactic| exact Iff.rfl) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Iff.rfl | null |
Iff.of_eq (h : a = b) : a ↔ b := h ▸ Iff.rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Iff.of_eq | null |
Iff.trans (h₁ : a ↔ b) (h₂ : b ↔ c) : a ↔ c :=
Iff.intro (h₂.mp ∘ h₁.mp) (h₁.mpr ∘ h₂.mpr)
-- This is needed for `calc` to work with `iff`. | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Iff.trans | null |
Eq.comm {a b : α} : a = b ↔ b = a := Iff.intro Eq.symm Eq.symm | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Eq.comm | null |
eq_comm {a b : α} : a = b ↔ b = a := Eq.comm | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | eq_comm | null |
HEq.comm {a : α} {b : β} : a ≍ b ↔ b ≍ a := Iff.intro HEq.symm HEq.symm | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | HEq.comm | null |
heq_comm {a : α} {b : β} : a ≍ b ↔ b ≍ a := HEq.comm
@[symm] theorem Iff.symm (h : a ↔ b) : b ↔ a := Iff.intro h.mpr h.mp | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | heq_comm | null |
Iff.comm : (a ↔ b) ↔ (b ↔ a) := Iff.intro Iff.symm Iff.symm | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Iff.comm | null |
iff_comm : (a ↔ b) ↔ (b ↔ a) := Iff.comm
@[symm] theorem And.symm : a ∧ b → b ∧ a := fun ⟨ha, hb⟩ => ⟨hb, ha⟩ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | iff_comm | null |
And.comm : a ∧ b ↔ b ∧ a := Iff.intro And.symm And.symm | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | And.comm | null |
and_comm : a ∧ b ↔ b ∧ a := And.comm
@[symm] theorem Or.symm : a ∨ b → b ∨ a := .rec .inr .inl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | and_comm | null |
Or.comm : a ∨ b ↔ b ∨ a := Iff.intro Or.symm Or.symm | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Or.comm | null |
or_comm : a ∨ b ↔ b ∨ a := Or.comm
/-! # Exists -/ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | or_comm | null |
Exists.elim {α : Sort u} {p : α → Prop} {b : Prop}
(h₁ : Exists (fun x => p x)) (h₂ : ∀ (a : α), p a → b) : b :=
match h₁ with
| intro a h => h₂ a h
/-! # Decidable -/
@[simp] theorem decide_true (h : Decidable True) : @decide True h = true :=
match h with
| isTrue _ => rfl
| isFalse h => False.elim <| ... | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Exists.elim | null |
@[inline] toBoolUsing {p : Prop} (d : Decidable p) : Bool :=
decide (h := d) | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | toBoolUsing | Similar to `decide`, but uses an explicit instance |
toBoolUsing_eq_true {p : Prop} (d : Decidable p) (h : p) : toBoolUsing d = true :=
decide_eq_true (inst := d) h | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | toBoolUsing_eq_true | null |
of_toBoolUsing_eq_true {p : Prop} {d : Decidable p} (h : toBoolUsing d = true) : p :=
of_decide_eq_true h | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | of_toBoolUsing_eq_true | null |
of_toBoolUsing_eq_false {p : Prop} {d : Decidable p} (h : toBoolUsing d = false) : ¬p :=
of_decide_eq_false h | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | of_toBoolUsing_eq_false | null |
@[macro_inline] byCases {q : Sort u} [dec : Decidable p] (h1 : p → q) (h2 : ¬p → q) : q :=
match dec with
| isTrue h => h1 h
| isFalse h => h2 h | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | byCases | Construct a `q` if some proposition `p` is decidable, and both the truth and falsity of `p` are
sufficient to construct a `q`.
This is a synonym for `dite`, the dependent if-then-else operator. |
em (p : Prop) [Decidable p] : p ∨ ¬p :=
byCases Or.inl Or.inr
set_option linter.unusedVariables.funArgs false in | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | em | null |
byContradiction [dec : Decidable p] (h : ¬p → False) : p :=
byCases id (fun np => False.elim (h np)) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | byContradiction | null |
of_not_not [Decidable p] : ¬ ¬ p → p :=
fun hnn => byContradiction (fun hn => absurd hn hnn) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | of_not_not | null |
not_and_iff_or_not {p q : Prop} [d₁ : Decidable p] [d₂ : Decidable q] : ¬ (p ∧ q) ↔ ¬ p ∨ ¬ q :=
Iff.intro
(fun h => match d₁, d₂ with
| isTrue h₁, isTrue h₂ => absurd (And.intro h₁ h₂) h
| _, isFalse h₂ => Or.inr h₂
| isFalse h₁, _ => Or.inl h₁)
(fun (h) ⟨hp, hq⟩ => m... | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | not_and_iff_or_not | null |
@[inline] decidable_of_decidable_of_iff [Decidable p] (h : p ↔ q) : Decidable q :=
if hp : p then
isTrue (Iff.mp h hp)
else
isFalse fun hq => absurd (Iff.mpr h hq) hp | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | decidable_of_decidable_of_iff | Transfer a decidability proof across an equivalence of propositions. |
@[inline] decidable_of_decidable_of_eq [Decidable p] (h : p = q) : Decidable q :=
decidable_of_decidable_of_iff (p := p) (h ▸ Iff.rfl) | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | decidable_of_decidable_of_eq | Transfer a decidability proof across an equality of propositions. |
if_pos {c : Prop} {h : Decidable c} (hc : c) {α : Sort u} {t e : α} : (ite c t e) = t :=
match h with
| isTrue _ => rfl
| isFalse hnc => absurd hc hnc | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | if_pos | null |
if_neg {c : Prop} {h : Decidable c} (hnc : ¬c) {α : Sort u} {t e : α} : (ite c t e) = e :=
match h with
| isTrue hc => absurd hc hnc
| isFalse _ => rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | if_neg | null |
iteInduction {c} [inst : Decidable c] {motive : α → Sort _} {t e : α}
(hpos : c → motive t) (hneg : ¬c → motive e) : motive (ite c t e) :=
match inst with
| isTrue h => hpos h
| isFalse h => hneg h | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | iteInduction | Split an if-then-else into cases. The `split` tactic is generally easier to use than this theorem. |
dif_pos {c : Prop} {h : Decidable c} (hc : c) {α : Sort u} {t : c → α} {e : ¬ c → α} : (dite c t e) = t hc :=
match h with
| isTrue _ => rfl
| isFalse hnc => absurd hc hnc | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | dif_pos | null |
dif_neg {c : Prop} {h : Decidable c} (hnc : ¬c) {α : Sort u} {t : c → α} {e : ¬ c → α} : (dite c t e) = e hnc :=
match h with
| isTrue hc => absurd hc hnc
| isFalse _ => rfl
@[macro_inline] | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | dif_neg | null |
noConfusionTypeEnum {α : Sort u} {β : Sort v} [inst : DecidableEq β] (f : α → β) (P : Sort w) (x y : α) : Sort w :=
(inst (f x) (f y)).casesOn
(fun _ => P)
(fun _ => P → P) | abbrev | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | noConfusionTypeEnum | Auxiliary definition for generating compact `noConfusion` for enumeration types |
noConfusionEnum {α : Sort u} {β : Sort v} [inst : DecidableEq β] (f : α → β) {P : Sort w} {x y : α} (h : x = y) : noConfusionTypeEnum f P x y :=
Decidable.casesOn
(motive := fun (inst : Decidable (f x = f y)) => Decidable.casesOn (motive := fun _ => Sort w) inst (fun _ => P) (fun _ => P → P))
(inst (f x) (f y... | abbrev | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | noConfusionEnum | Auxiliary definition for generating compact `noConfusion` for enumeration types |
Subsingleton (α : Sort u) : Prop where
/-- Prove that `α` is a subsingleton by showing that any two elements are equal. -/
intro ::
/-- Any two elements of a subsingleton are equal. -/
allEq : (a b : α) → a = b | class | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Subsingleton | A _subsingleton_ is a type with at most one element. It is either empty or has a unique element.
All propositions are subsingletons because of proof irrelevance: false propositions are empty, and
all proofs of a true proposition are equal to one another. Some non-propositional types are also
subsingletons. |
protected Subsingleton.elim {α : Sort u} [h : Subsingleton α] : (a b : α) → a = b :=
h.allEq | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Subsingleton.elim | If a type is a subsingleton, then all of its elements are equal. |
protected Subsingleton.helim {α β : Sort u} [h₁ : Subsingleton α] (h₂ : α = β) (a : α) (b : β) : a ≍ b := by
subst h₂
apply heq_of_eq
apply Subsingleton.elim | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Subsingleton.helim | If two types are equal and one of them is a subsingleton, then all of their elements are
[heterogeneously equal](lean-manual://section/HEq). |
recSubsingleton
{p : Prop} [h : Decidable p]
{h₁ : p → Sort u}
{h₂ : ¬p → Sort u}
[h₃ : ∀ (h : p), Subsingleton (h₁ h)]
[h₄ : ∀ (h : ¬p), Subsingleton (h₂ h)]
: Subsingleton (h.casesOn h₂ h₁) :=
match h with
| isTrue h => h₃ h
| isFalse h => h₄ h | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | recSubsingleton | null |
Equivalence {α : Sort u} (r : α → α → Prop) : Prop where
/-- An equivalence relation is reflexive: `r x x` -/
refl : ∀ x, r x x
/-- An equivalence relation is symmetric: `r x y` implies `r y x` -/
symm : ∀ {x y}, r x y → r y x
/-- An equivalence relation is transitive: `r x y` and `r y z` implies `r x z` -/... | structure | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Equivalence | An equivalence relation `r : α → α → Prop` is a relation that is
* reflexive: `r x x`,
* symmetric: `r x y` implies `r y x`, and
* transitive: `r x y` and `r y z` implies `r x z`.
Equality is an equivalence relation, and equivalence relations share many of the properties of
equality. |
emptyRelation {α : Sort u} (_ _ : α) : Prop :=
False | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | emptyRelation | The empty relation is the relation on `α` which is always `False`. |
Subrelation {α : Sort u} (q r : α → α → Prop) :=
∀ {x y}, q x y → r x y | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Subrelation | `Subrelation q r` means that `q ⊆ r` or `∀ x y, q x y → r x y`.
It is the analogue of the subset relation on relations. |
InvImage {α : Sort u} {β : Sort v} (r : β → β → Prop) (f : α → β) : α → α → Prop :=
fun a₁ a₂ => r (f a₁) (f a₂) | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | InvImage | The inverse image of `r : β → β → Prop` by a function `α → β` is the relation
`s : α → α → Prop` defined by `s a b = r (f a) (f b)`. |
Relation.TransGen {α : Sort u} (r : α → α → Prop) : α → α → Prop
/-- If `r a b`, then `TransGen r a b`. This is the base case of the transitive closure. -/
| single {a b} : r a b → TransGen r a b
/-- If `TransGen r a b` and `r b c`, then `TransGen r a c`.
This is the inductive case of the transitive closure. -/... | inductive | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Relation.TransGen | The transitive closure `TransGen r` of a relation `r` is the smallest relation which is
transitive and contains `r`. `TransGen r a z` if and only if there exists a sequence
`a r b r ... r z` of length at least 1 connecting `a` to `z`. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.