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 ⌀ |
|---|---|---|---|---|---|---|
Relation.TransGen.trans {α : Sort u} {r : α → α → Prop} {a b c} :
TransGen r a b → TransGen r b c → TransGen r a c := by
intro hab hbc
induction hbc with
| single h => exact TransGen.tail hab h
| tail _ h ih => exact TransGen.tail ih h
/-! # Subtype -/ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Relation.TransGen.trans | The transitive closure is transitive. |
exists_of_subtype {α : Type u} {p : α → Prop} : { x // p x } → Exists (fun x => p x)
| ⟨a, h⟩ => ⟨a, h⟩
variable {α : Sort u} {p : α → Prop} | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | exists_of_subtype | null |
protected ext : ∀ {a1 a2 : {x // p x}}, val a1 = val a2 → a1 = a2
| ⟨_, _⟩, ⟨_, _⟩, rfl => rfl
@[deprecated Subtype.ext (since := "2025-10-26")] | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | ext | null |
protected eq : ∀ {a1 a2 : {x // p x}}, val a1 = val a2 → a1 = a2
| ⟨_, _⟩, ⟨_, _⟩, rfl => rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | eq | null |
eta (a : {x // p x}) (h : p (val a)) : mk (val a) h = a := by
cases a
exact rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | eta | null |
@[reducible, inherit_doc PSum.inhabitedLeft]
Sum.inhabitedLeft [Inhabited α] : Inhabited (Sum α β) where
default := Sum.inl default
@[reducible, inherit_doc PSum.inhabitedRight] | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Sum.inhabitedLeft | null |
Sum.inhabitedRight [Inhabited β] : Inhabited (Sum α β) where
default := Sum.inr default | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Sum.inhabitedRight | null |
Sum.nonemptyLeft [h : Nonempty α] : Nonempty (Sum α β) :=
Nonempty.elim h (fun a => ⟨Sum.inl a⟩) | instance | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Sum.nonemptyLeft | null |
Sum.nonemptyRight [h : Nonempty β] : Nonempty (Sum α β) :=
Nonempty.elim h (fun b => ⟨Sum.inr b⟩)
deriving instance DecidableEq for Sum | instance | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Sum.nonemptyRight | null |
Prod.lexLt [LT α] [LT β] (s : α × β) (t : α × β) : Prop :=
s.1 < t.1 ∨ (s.1 = t.1 ∧ s.2 < t.2) | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Prod.lexLt | Lexicographical order for products.
Two pairs are lexicographically ordered if their first elements are ordered or if their first
elements are equal and their second elements are ordered. |
Prod.lexLtDec
[LT α] [LT β] [DecidableEq α]
[(a b : α) → Decidable (a < b)] [(a b : β) → Decidable (a < b)]
: (s t : α × β) → Decidable (Prod.lexLt s t) :=
fun _ _ => inferInstanceAs (Decidable (_ ∨ _)) | instance | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Prod.lexLtDec | null |
Prod.lexLt_def [LT α] [LT β] (s t : α × β) : (Prod.lexLt s t) = (s.1 < t.1 ∨ (s.1 = t.1 ∧ s.2 < t.2)) :=
rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Prod.lexLt_def | null |
Prod.eta (p : α × β) : (p.1, p.2) = p := rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Prod.eta | null |
Prod.map {α₁ : Type u₁} {α₂ : Type u₂} {β₁ : Type v₁} {β₂ : Type v₂}
(f : α₁ → α₂) (g : β₁ → β₂) : α₁ × β₁ → α₂ × β₂
| (a, b) => (f a, g b)
@[simp] theorem Prod.map_apply (f : α → β) (g : γ → δ) (x) (y) :
Prod.map f g (x, y) = (f x, g y) := rfl
-- We add `@[grind =]` to these in `Init.Data.Prod`.
@[simp] theorem Prod.map_fst (f : α → β) (g : γ → δ) (x) : (Prod.map f g x).1 = f x.1 := rfl
@[simp] theorem Prod.map_snd (f : α → β) (g : γ → δ) (x) : (Prod.map f g x).2 = g x.2 := rfl
/-! # Dependent products -/ | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Prod.map | Transforms a pair by applying functions to both elements.
Examples:
* `(1, 2).map (· + 1) (· * 3) = (2, 6)`
* `(1, 2).map toString (· * 3) = ("1", 6)` |
Exists.of_psigma_prop {α : Sort u} {p : α → Prop} : (PSigma (fun x => p x)) → Exists (fun x => p x)
| ⟨x, hx⟩ => ⟨x, hx⟩ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Exists.of_psigma_prop | null |
protected PSigma.eta {α : Sort u} {β : α → Sort v} {a₁ a₂ : α} {b₁ : β a₁} {b₂ : β a₂}
(h₁ : a₁ = a₂) (h₂ : Eq.ndrec b₁ h₁ = b₂) : PSigma.mk a₁ b₁ = PSigma.mk a₂ b₂ := by
subst h₁
subst h₂
exact rfl
/-! # Universe polymorphic unit -/ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | PSigma.eta | null |
PUnit.ext (a b : PUnit) : a = b := by
cases a; cases b; exact rfl
@[deprecated PUnit.ext (since := "2025-10-26")] | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | PUnit.ext | null |
PUnit.subsingleton (a b : PUnit) : a = b := by
cases a; cases b; exact rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | PUnit.subsingleton | null |
PUnit.eq_punit (a : PUnit) : a = ⟨⟩ :=
PUnit.ext a ⟨⟩ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | PUnit.eq_punit | null |
Setoid (α : Sort u) where
/-- `x ≈ y` is the distinguished equivalence relation of a setoid. -/
r : α → α → Prop
/-- The relation `x ≈ y` is an equivalence relation. -/
iseqv : Equivalence r | class | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Setoid | A setoid is a type with a distinguished equivalence relation, denoted `≈`.
The `Quotient` type constructor requires a `Setoid` instance. |
refl (a : α) : a ≈ a :=
iseqv.refl a | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | refl | A setoid's equivalence relation is reflexive. |
symm {a b : α} (hab : a ≈ b) : b ≈ a :=
iseqv.symm hab | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | symm | A setoid's equivalence relation is symmetric. |
trans {a b c : α} (hab : a ≈ b) (hbc : b ≈ c) : a ≈ c :=
iseqv.trans hab hbc | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | trans | A setoid's equivalence relation is transitive. |
propext {a b : Prop} : (a ↔ b) → a = b | axiom | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | propext | The [axiom](lean-manual://section/axioms) of **propositional extensionality**. It asserts that if
propositions `a` and `b` are logically equivalent (that is, if `a` can be proved from `b` and vice
versa), then `a` and `b` are *equal*, meaning `a` can be replaced with `b` in all contexts.
The standard logical connectives provably respect propositional extensionality. However, an axiom is
needed for higher order expressions like `P a` where `P : Prop → Prop` is unknown, as well as for
equality. Propositional extensionality is intuitionistically valid. |
Eq.propIntro {a b : Prop} (h₁ : a → b) (h₂ : b → a) : a = b :=
propext <| Iff.intro h₁ h₂
-- Eq for Prop is now decidable if the equivalent Iff is decidable | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Eq.propIntro | null |
Nat.succ.inj {m n : Nat} : m.succ = n.succ → m = n :=
fun x => Nat.noConfusion x id | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Nat.succ.inj | null |
Nat.succ.injEq (u v : Nat) : (u.succ = v.succ) = (u = v) :=
Eq.propIntro Nat.succ.inj (congrArg Nat.succ)
@[simp] theorem beq_iff_eq [BEq α] [LawfulBEq α] {a b : α} : a == b ↔ a = b :=
⟨eq_of_beq, beq_of_eq⟩
/-! # Prop lemmas -/ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Nat.succ.injEq | null |
Not.elim {α : Sort _} (H1 : ¬a) (H2 : a) : α := absurd H2 H1 | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Not.elim | *Ex falso* for negation: from `¬a` and `a` anything follows. This is the same as `absurd` with
the arguments flipped, but it is in the `Not` namespace so that projection notation can be used. |
And.elim (f : a → b → α) (h : a ∧ b) : α := f h.left h.right | abbrev | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | And.elim | Non-dependent eliminator for `And`. |
Iff.elim (f : (a → b) → (b → a) → α) (h : a ↔ b) : α := f h.mp h.mpr | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Iff.elim | Non-dependent eliminator for `Iff`. |
Iff.subst {a b : Prop} {p : Prop → Prop} (h₁ : a ↔ b) (h₂ : p a) : p b :=
Eq.subst (propext h₁) h₂ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Iff.subst | Iff can now be used to do substitutions in a calculation |
Not.intro {a : Prop} (h : a → False) : ¬a := h | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Not.intro | null |
Not.imp {a b : Prop} (H2 : ¬b) (H1 : a → b) : ¬a := mt H1 H2 | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Not.imp | null |
not_congr (h : a ↔ b) : ¬a ↔ ¬b := ⟨mt h.2, mt h.1⟩ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | not_congr | null |
not_not_not : ¬¬¬a ↔ ¬a := ⟨mt not_not_intro, not_not_intro⟩ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | not_not_not | null |
iff_of_true (ha : a) (hb : b) : a ↔ b := Iff.intro (fun _ => hb) (fun _ => ha) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | iff_of_true | null |
iff_of_false (ha : ¬a) (hb : ¬b) : a ↔ b := Iff.intro ha.elim hb.elim | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | iff_of_false | null |
iff_true_left (ha : a) : (a ↔ b) ↔ b := Iff.intro (·.mp ha) (iff_of_true ha) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | iff_true_left | null |
iff_true_right (ha : a) : (b ↔ a) ↔ b := Iff.comm.trans (iff_true_left ha) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | iff_true_right | null |
iff_false_left (ha : ¬a) : (a ↔ b) ↔ ¬b := Iff.intro (mt ·.mpr ha) (iff_of_false ha) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | iff_false_left | null |
iff_false_right (ha : ¬a) : (b ↔ a) ↔ ¬b := Iff.comm.trans (iff_false_left ha) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | iff_false_right | null |
of_iff_true (h : a ↔ True) : a := h.mpr trivial | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | of_iff_true | null |
iff_true_intro (h : a) : a ↔ True := iff_of_true h trivial | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | iff_true_intro | null |
eq_iff_true_of_subsingleton [Subsingleton α] (x y : α) : x = y ↔ True :=
iff_true_intro (Subsingleton.elim ..) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | eq_iff_true_of_subsingleton | null |
not_of_iff_false : (p ↔ False) → ¬p := Iff.mp | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | not_of_iff_false | null |
iff_false_intro (h : ¬a) : a ↔ False := iff_of_false h id | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | iff_false_intro | null |
not_iff_false_intro (h : a) : ¬a ↔ False := iff_false_intro (not_not_intro h) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | not_iff_false_intro | null |
not_true : (¬True) ↔ False := iff_false_intro (not_not_intro trivial) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | not_true | null |
not_false_iff : (¬False) ↔ True := iff_true_intro not_false | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | not_false_iff | null |
Eq.to_iff : a = b → (a ↔ b) := Iff.of_eq | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Eq.to_iff | null |
iff_of_eq : a = b → (a ↔ b) := Iff.of_eq | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | iff_of_eq | null |
neq_of_not_iff : ¬(a ↔ b) → a ≠ b := mt Iff.of_eq | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | neq_of_not_iff | null |
iff_iff_eq : (a ↔ b) ↔ a = b := Iff.intro propext Iff.of_eq
@[simp] theorem eq_iff_iff : (a = b) ↔ (a ↔ b) := iff_iff_eq.symm | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | iff_iff_eq | null |
eq_self_iff_true (a : α) : a = a ↔ True := iff_true_intro rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | eq_self_iff_true | null |
ne_self_iff_false (a : α) : a ≠ a ↔ False := not_iff_false_intro rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | ne_self_iff_false | null |
false_of_true_iff_false (h : True ↔ False) : False := h.mp trivial | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | false_of_true_iff_false | null |
false_of_true_eq_false (h : True = False) : False := false_of_true_iff_false (Iff.of_eq h) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | false_of_true_eq_false | null |
true_eq_false_of_false : False → (True = False) := False.elim | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | true_eq_false_of_false | null |
iff_def : (a ↔ b) ↔ (a → b) ∧ (b → a) := iff_iff_implies_and_implies | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | iff_def | null |
iff_def' : (a ↔ b) ↔ (b → a) ∧ (a → b) := Iff.trans iff_def And.comm | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | iff_def' | null |
true_iff_false : (True ↔ False) ↔ False := iff_false_intro (·.mp True.intro) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | true_iff_false | null |
false_iff_true : (False ↔ True) ↔ False := iff_false_intro (·.mpr True.intro) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | false_iff_true | null |
iff_not_self : ¬(a ↔ ¬a) | H => let f h := H.1 h h; f (H.2 f) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | iff_not_self | null |
heq_self_iff_true (a : α) : a ≍ a ↔ True := iff_true_intro HEq.rfl
/-! ## implies -/ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | heq_self_iff_true | null |
not_not_of_not_imp : ¬(a → b) → ¬¬a := mt Not.elim | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | not_not_of_not_imp | null |
not_of_not_imp {a : Prop} : ¬(a → b) → ¬b := mt fun h _ => h
@[simp] theorem imp_not_self : (a → ¬a) ↔ ¬a := Iff.intro (fun h ha => h ha ha) (fun h _ => h) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | not_of_not_imp | null |
imp_intro {α β : Prop} (h : α) : β → α := fun _ => h | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | imp_intro | null |
imp_imp_imp {a b c d : Prop} (h₀ : c → a) (h₁ : b → d) : (a → b) → (c → d) := (h₁ ∘ · ∘ h₀) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | imp_imp_imp | null |
imp_iff_right {a : Prop} (ha : a) : (a → b) ↔ b := Iff.intro (· ha) (fun a _ => a)
-- This is not marked `@[simp]` because we have `implies_true : (α → True) = True` | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | imp_iff_right | null |
imp_true_iff (α : Sort u) : (α → True) ↔ True := iff_true_intro (fun _ => trivial) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | imp_true_iff | null |
false_imp_iff (a : Prop) : (False → a) ↔ True := iff_true_intro False.elim | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | false_imp_iff | null |
true_imp_iff {α : Prop} : (True → α) ↔ α := imp_iff_right True.intro
@[simp high] theorem imp_self : (a → a) ↔ True := iff_true_intro id
@[simp] theorem imp_false : (a → False) ↔ ¬a := Iff.rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | true_imp_iff | null |
imp.swap : (a → b → c) ↔ (b → a → c) := Iff.intro flip flip | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | imp.swap | null |
imp_not_comm : (a → ¬b) ↔ (b → ¬a) := imp.swap | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | imp_not_comm | null |
imp_congr_left (h : a ↔ b) : (a → c) ↔ (b → c) := Iff.intro (· ∘ h.mpr) (· ∘ h.mp) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | imp_congr_left | null |
imp_congr_right (h : a → (b ↔ c)) : (a → b) ↔ (a → c) :=
Iff.intro (fun hab ha => (h ha).mp (hab ha)) (fun hcd ha => (h ha).mpr (hcd ha)) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | imp_congr_right | null |
imp_congr_ctx (h₁ : a ↔ c) (h₂ : c → (b ↔ d)) : (a → b) ↔ (c → d) :=
Iff.trans (imp_congr_left h₁) (imp_congr_right h₂) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | imp_congr_ctx | null |
imp_congr (h₁ : a ↔ c) (h₂ : b ↔ d) : (a → b) ↔ (c → d) := imp_congr_ctx h₁ fun _ => h₂ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | imp_congr | null |
imp_iff_not (hb : ¬b) : a → b ↔ ¬a := imp_congr_right fun _ => iff_false_intro hb
/-! # Quotients -/ | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | imp_iff_not | null |
sound : ∀ {α : Sort u} {r : α → α → Prop} {a b : α}, r a b → Quot.mk r a = Quot.mk r b | axiom | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | sound | The **quotient axiom**, which asserts the equality of elements related by the quotient's relation.
The relation `r` does not need to be an equivalence relation to use this axiom. When `r` is not an
equivalence relation, the quotient is with respect to the equivalence relation generated by `r`.
`Quot.sound` is part of the built-in primitive quotient type:
* `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.ind` is used to write proofs about quotients by assuming that all elements are constructed
with `Quot.mk`; it is analogous to the [recursor](lean-manual://section/recursors) for a
structure.
[Quotient types](lean-manual://section/quotients) are described in more detail in the Lean Language
Reference. |
protected liftBeta {α : Sort u} {r : α → α → Prop} {β : Sort v}
(f : α → β)
(c : (a b : α) → r a b → f a = f b)
(a : α)
: lift f c (Quot.mk r a) = f a :=
rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | liftBeta | null |
protected indBeta {α : Sort u} {r : α → α → Prop} {motive : Quot r → Prop}
(p : (a : α) → motive (Quot.mk r a))
(a : α)
: (ind p (Quot.mk r a) : motive (Quot.mk r a)) = p a :=
rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | indBeta | null |
protected liftOn {α : Sort u} {β : Sort v} {r : α → α → Prop}
(q : Quot r) (f : α → β) (c : (a b : α) → r a b → f a = f b) : β :=
lift f c q
@[elab_as_elim] | abbrev | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | liftOn | 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's value `q : Quot r`, applying a `f : α → β`
requires a proof `c` that `f` respects `r`. In this case, `Quot.liftOn q f h : β` evaluates
to the result of applying `f` to the underlying value in `α` from `q`.
`Quot.liftOn` is a version of the built-in primitive `Quot.lift` with its parameters re-ordered.
[Quotient types](lean-manual://section/quotients) are described in more detail in the Lean Language
Reference. |
protected inductionOn {α : Sort u} {r : α → α → Prop} {motive : Quot r → Prop}
(q : Quot r)
(h : (a : α) → motive (Quot.mk r a))
: motive q :=
ind h q | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | inductionOn | null |
exists_rep {α : Sort u} {r : α → α → Prop} (q : Quot r) : Exists (fun a => (Quot.mk r a) = q) :=
q.inductionOn (fun a => ⟨a, rfl⟩) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | exists_rep | null |
@[reducible, macro_inline]
protected indep (f : (a : α) → motive (Quot.mk r a)) (a : α) : PSigma motive :=
⟨Quot.mk r a, f a⟩ | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | indep | Auxiliary definition for `Quot.rec`. |
protected indepCoherent
(f : (a : α) → motive (Quot.mk r a))
(h : (a b : α) → (p : r a b) → Eq.ndrec (f a) (sound p) = f b)
: (a b : α) → r a b → Quot.indep f a = Quot.indep f b :=
fun a b e => PSigma.eta (sound e) (h a b e) | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | indepCoherent | null |
protected liftIndepPr1
(f : (a : α) → motive (Quot.mk r a))
(h : ∀ (a b : α) (p : r a b), Eq.ndrec (f a) (sound p) = f b)
(q : Quot r)
: (lift (Quot.indep f) (Quot.indepCoherent f h) q).1 = q := by
induction q using Quot.ind
exact rfl | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | liftIndepPr1 | null |
@[elab_as_elim] protected rec
(f : (a : α) → motive (Quot.mk r a))
(h : (a b : α) → (p : r a b) → Eq.ndrec (f a) (sound p) = f b)
(q : Quot r) : motive q :=
Eq.ndrecOn (Quot.liftIndepPr1 f h q) ((lift (Quot.indep f) (Quot.indepCoherent f h) q).2) | abbrev | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | rec | A dependent recursion principle for `Quot`. It is analogous to the
[recursor](lean-manual://section/recursors) for a structure, and can be used when the resulting type
is not necessarily a proposition.
While it is very general, this recursor can be tricky to use. The following simpler alternatives may
be easier to use:
* `Quot.lift` is useful for defining non-dependent functions.
* `Quot.ind` is useful for proving theorems about quotients.
* `Quot.recOnSubsingleton` can be used whenever the target type is a `Subsingleton`.
* `Quot.hrecOn` uses [heterogeneous equality](lean-manual://section/HEq) instead of rewriting with
`Quot.sound`.
`Quot.recOn` is a version of this recursor that takes the quotient parameter first. |
@[elab_as_elim] protected recOn
(q : Quot r)
(f : (a : α) → motive (Quot.mk r a))
(h : (a b : α) → (p : r a b) → Eq.ndrec (f a) (sound p) = f b)
: motive q :=
q.rec f h | abbrev | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | recOn | A dependent recursion principle for `Quot` that takes the quotient first. It is analogous to the
[recursor](lean-manual://section/recursors) for a structure, and can be used when the resulting type
is not necessarily a proposition.
While it is very general, this recursor can be tricky to use. The following simpler alternatives may
be easier to use:
* `Quot.lift` is useful for defining non-dependent functions.
* `Quot.ind` is useful for proving theorems about quotients.
* `Quot.recOnSubsingleton` can be used whenever the target type is a `Subsingleton`.
* `Quot.hrecOn` uses [heterogeneous equality](lean-manual://section/HEq) instead of rewriting with
`Quot.sound`.
`Quot.rec` is a version of this recursor that takes the quotient parameter last. |
@[elab_as_elim] protected recOnSubsingleton
[h : (a : α) → Subsingleton (motive (Quot.mk r a))]
(q : Quot r)
(f : (a : α) → motive (Quot.mk r a))
: motive q := by
induction q using Quot.rec
apply f
apply Subsingleton.elim | abbrev | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | recOnSubsingleton | An alternative induction principle for quotients that can be used when the target type is a
subsingleton, in which all elements are equal.
In these cases, the proof that the function respects the quotient's relation is trivial, so any
function can be lifted.
`Quot.rec` does not assume that the type is a subsingleton. |
protected hrecOn
(q : Quot r)
(f : (a : α) → motive (Quot.mk r a))
(c : (a b : α) → (p : r a b) → f a ≍ f b)
: motive q :=
Quot.recOn q f fun a b p => eq_of_heq (eqRec_heq_iff.mpr (c a b p)) | abbrev | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | hrecOn | A dependent recursion principle for `Quot` that uses [heterogeneous
equality](lean-manual://section/HEq), analogous to a [recursor](lean-manual://section/recursors) for
a structure.
`Quot.recOn` is a version of this recursor that uses `Eq` instead of `HEq`. |
Quotient {α : Sort u} (s : Setoid α) :=
@Quot α Setoid.r | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | Quotient | Quotient types coarsen the propositional equality for a type so that terms related by some
equivalence relation are considered equal. The equivalence relation is given by an instance of
`Setoid`.
Set-theoretically, `Quotient s` can seen as the set of equivalence classes of `α` modulo the
`Setoid` instance's relation `s.r`. Functions from `Quotient s` must prove that they respect `s.r`:
to define a function `f : Quotient s → β`, it is necessary to provide `f' : α → β` and prove that
for all `x : α` and `y : α`, `s.r x y → f' x = f' y`. `Quotient.lift` implements this operation.
The key quotient operators are:
* `Quotient.mk` places elements of the underlying type `α` into the quotient.
* `Quotient.lift` allows the definition of functions from the quotient to some other type.
* `Quotient.sound` asserts the equality of elements related by `r`
* `Quotient.ind` is used to write proofs about quotients by assuming that all elements are
constructed with `Quotient.mk`.
`Quotient` is built on top of the primitive quotient type `Quot`, which does not require a proof
that the relation is an equivalence relation. `Quotient` should be used instead of `Quot` for
relations that actually are equivalence relations. |
@[inline]
protected mk {α : Sort u} (s : Setoid α) (a : α) : Quotient s :=
Quot.mk Setoid.r a | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | mk | Places an element of a type into the quotient that equates terms according to an equivalence
relation.
The setoid instance is provided explicitly. `Quotient.mk'` uses instance synthesis instead.
Given `v : α`, `Quotient.mk s v : Quotient s` is like `v`, except all observations of `v`'s value
must respect `s.r`. `Quotient.lift` allows values in a quotient to be mapped to other types, so long
as the mapping respects `s.r`. |
protected mk' {α : Sort u} [s : Setoid α] (a : α) : Quotient s :=
Quotient.mk s a | def | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | mk' | Places an element of a type into the quotient that equates terms according to an equivalence
relation.
The equivalence relation is found by synthesizing a `Setoid` instance. `Quotient.mk` instead expects
the instance to be provided explicitly.
Given `v : α`, `Quotient.mk' v : Quotient s` is like `v`, except all observations of `v`'s value
must respect `s.r`. `Quotient.lift` allows values in a quotient to be mapped to other types, so long
as the mapping respects `s.r`. |
sound {α : Sort u} {s : Setoid α} {a b : α} : a ≈ b → Quotient.mk s a = Quotient.mk s b :=
Quot.sound | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | sound | The **quotient axiom**, which asserts the equality of elements related in the setoid.
Because `Quotient` is built on a lower-level type `Quot`, `Quotient.sound` is implemented as a
theorem. It is derived from `Quot.sound`, the soundness axiom for the lower-level quotient type
`Quot`. |
protected lift {α : Sort u} {β : Sort v} {s : Setoid α} (f : α → β) : ((a b : α) → a ≈ b → f a = f b) → Quotient s → β :=
Quot.lift f | abbrev | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | lift | Lifts a function from an underlying type to a function on a quotient, requiring that it respects the
quotient's equivalence relation.
Given `s : Setoid α` and a quotient `Quotient s`, applying a function `f : α → β` requires a proof
`h` that `f` respects the equivalence relation `s.r`. In this case, the function
`Quotient.lift f h : Quotient s → β` computes the same values as `f`.
`Quotient.liftOn` is a version of this operation that takes the quotient value as its first explicit
parameter. |
protected ind {α : Sort u} {s : Setoid α} {motive : Quotient s → Prop} : ((a : α) → motive (Quotient.mk s a)) → (q : Quotient s) → motive q :=
Quot.ind | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | ind | A reasoning principle for quotients that allows proofs about quotients to assume that all values are
constructed with `Quotient.mk`. |
protected liftOn {α : Sort u} {β : Sort v} {s : Setoid α} (q : Quotient s) (f : α → β) (c : (a b : α) → a ≈ b → f a = f b) : β :=
Quot.liftOn q f c | abbrev | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | liftOn | Lifts a function from an underlying type to a function on a quotient, requiring that it respects the
quotient's equivalence relation.
Given `s : Setoid α` and a quotient value `q : Quotient s`, applying a function `f : α → β` requires
a proof `c` that `f` respects the equivalence relation `s.r`. In this case, the term
`Quotient.liftOn q f h : β` reduces to the result of applying `f` to the underlying `α` value.
`Quotient.lift` is a version of this operation that takes the quotient value last, rather than
first. |
@[elab_as_elim]
protected inductionOn {α : Sort u} {s : Setoid α} {motive : Quotient s → Prop}
(q : Quotient s)
(h : (a : α) → motive (Quotient.mk s a))
: motive q :=
Quot.inductionOn q h | theorem | Init.Core | [
"Init.SizeOf"
] | Init/Core.lean | inductionOn | The analogue of `Quot.inductionOn`: every element of `Quotient s` is of the form `Quotient.mk s a`. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.