File: Mathlib/Data/Setoid/Basic.lean

full_name: Setoid.Rel
code: /-- A version of `Setoid.r` that takes the equivalence relation as an explicit argument. -/
def Setoid.Rel (r : Setoid α) : α → α → Prop 
goal: α → α → Prop

full_name: Setoid.decidableRel
code: instance Setoid.decidableRel (r : Setoid α) [h : DecidableRel r.r] : DecidableRel r.Rel 
goal: DecidableRel r.Rel

full_name: Quotient.eq_rel
code: /-- A version of `Quotient.eq'` compatible with `Setoid.Rel`, to make rewriting possible. -/
theorem Quotient.eq_rel {r : Setoid α} {x y} :
    (Quotient.mk' x : Quotient r) = Quotient.mk' y ↔ r.Rel x y 
goal: Quotient.mk' x = Quotient.mk' y ↔ r.Rel x y

full_name: Setoid.ext'
code: @[ext]
theorem ext' {r s : Setoid α} (H : ∀ a b, r.Rel a b ↔ s.Rel a b) : r = s 
goal: r = s

full_name: Setoid.ext_iff
code: theorem ext_iff {r s : Setoid α} : r = s ↔ ∀ a b, r.Rel a b ↔ s.Rel a b 
goal: r = s ↔ ∀ (a b : α), r.Rel a b ↔ s.Rel a b

full_name: Setoid.eq_iff_rel_eq
code: /-- Two equivalence relations are equal iff their underlying binary operations are equal. -/
theorem eq_iff_rel_eq {r₁ r₂ : Setoid α} : r₁ = r₂ ↔ r₁.Rel = r₂.Rel 
goal: r₁ = r₂ ↔ r₁.Rel = r₂.Rel

full_name: Setoid.instLE_mathlib
code: /-- Defining `≤` for equivalence relations. -/
instance : LE (Setoid α) 
goal: LE (Setoid α)

full_name: Setoid.le_def
code: theorem le_def {r s : Setoid α} : r ≤ s ↔ ∀ {x y}, r.Rel x y → s.Rel x y 
goal: r ≤ s ↔ ∀ {x y : α}, r.Rel x y → s.Rel x y

full_name: Setoid.refl'
code: @[refl]
theorem refl' (r : Setoid α) (x) : r.Rel x x 
goal: r.Rel x x

full_name: Setoid.symm'
code: @[symm]
theorem symm' (r : Setoid α) : ∀ {x y}, r.Rel x y → r.Rel y x 
goal: r.Rel x y → r.Rel y x

full_name: Setoid.trans'
code: @[trans]
theorem trans' (r : Setoid α) : ∀ {x y z}, r.Rel x y → r.Rel y z → r.Rel x z 
goal: r.Rel x y → r.Rel y z → r.Rel x z

full_name: Setoid.comm'
code: theorem comm' (s : Setoid α) {x y} : s.Rel x y ↔ s.Rel y x 
goal: s.Rel x y ↔ s.Rel y x

full_name: Setoid.ker
code: /-- The kernel of a function is an equivalence relation. -/
def ker (f : α → β) : Setoid α 
goal: Setoid α

full_name: Setoid.ker_mk_eq
code: /-- The kernel of the quotient map induced by an equivalence relation r equals r. -/
@[simp]
theorem ker_mk_eq (r : Setoid α) : ker (@Quotient.mk'' _ r) = r 
goal: Setoid.ker Quotient.mk'' = r

full_name: Setoid.ker_apply_mk_out
code: theorem ker_apply_mk_out {f : α → β} (a : α) : f (haveI := Setoid.ker f; ⟦a⟧.out) = f a 
goal: f ⟦a⟧.out = f a

full_name: Setoid.ker_apply_mk_out'
code: theorem ker_apply_mk_out' {f : α → β} (a : α) :
    f (Quotient.mk _ a : Quotient <| Setoid.ker f).out' = f a 
goal: f ⟦a⟧.out' = f a

full_name: Setoid.ker_def
code: theorem ker_def {f : α → β} {x y : α} : (ker f).Rel x y ↔ f x = f y 
goal: (Setoid.ker f).Rel x y ↔ f x = f y

full_name: Setoid.prod
code: /-- Given types `α`, `β`, the product of two equivalence relations `r` on `α` and `s` on `β`:
    `(x₁, x₂), (y₁, y₂) ∈ α × β` are related by `r.prod s` iff `x₁` is related to `y₁`
    by `r` and `x₂` is related to `y₂` by `s`. -/
protected def prod (r : Setoid α) (s : Setoid β) :
    Setoid (α × β) 
goal: Setoid (α × β)

full_name: Setoid.instInf
code: /-- The infimum of two equivalence relations. -/
instance : Inf (Setoid α) 
goal: Inf (Setoid α)

full_name: Setoid.inf_def
code: /-- The infimum of 2 equivalence relations r and s is the same relation as the infimum
    of the underlying binary operations. -/
theorem inf_def {r s : Setoid α} : (r ⊓ s).Rel = r.Rel ⊓ s.Rel 
goal: (r ⊓ s).Rel = r.Rel ⊓ s.Rel

full_name: Setoid.inf_iff_and
code: theorem inf_iff_and {r s : Setoid α} {x y} : (r ⊓ s).Rel x y ↔ r.Rel x y ∧ s.Rel x y 
goal: (r ⊓ s).Rel x y ↔ r.Rel x y ∧ s.Rel x y

full_name: Setoid.instInfSet
code: /-- The infimum of a set of equivalence relations. -/
instance : InfSet (Setoid α) 
goal: InfSet (Setoid α)

full_name: Setoid.sInf_def
code: /-- The underlying binary operation of the infimum of a set of equivalence relations
    is the infimum of the set's image under the map to the underlying binary operation. -/
theorem sInf_def {s : Set (Setoid α)} : (sInf s).Rel = sInf (Rel '' s) 
goal: (sInf s).Rel = sInf (Setoid.Rel '' s)

full_name: Setoid.instPartialOrder
code: instance : PartialOrder (Setoid α) 
goal: PartialOrder (Setoid α)

full_name: Setoid.completeLattice
code: /-- The complete lattice of equivalence relations on a type, with bottom element `=`
    and top element the trivial equivalence relation. -/
instance completeLattice : CompleteLattice (Setoid α) 
goal: CompleteLattice (Setoid α)

full_name: Setoid.top_def
code: @[simp]
theorem top_def : (⊤ : Setoid α).Rel = ⊤ 
goal: ⊤.Rel = ⊤

full_name: Setoid.bot_def
code: @[simp]
theorem bot_def : (⊥ : Setoid α).Rel = (· = ·) 
goal: ⊥.Rel = fun x x_1 => x = x_1

full_name: Setoid.eq_top_iff
code: theorem eq_top_iff {s : Setoid α} : s = (⊤ : Setoid α) ↔ ∀ x y : α, s.Rel x y 
goal: s = ⊤ ↔ ∀ (x y : α), s.Rel x y

full_name: Setoid.sInf_equiv
code: lemma sInf_equiv {S : Set (Setoid α)} {x y : α} :
    letI := sInf S
    x ≈ y ↔ ∀ s ∈ S, s.Rel x y 
goal: x ≈ y ↔ ∀ s ∈ S, s.Rel x y

full_name: Setoid.quotient_mk_sInf_eq
code: lemma quotient_mk_sInf_eq {S : Set (Setoid α)} {x y : α} :
    Quotient.mk (sInf S) x = Quotient.mk (sInf S) y ↔ ∀ s ∈ S, s.Rel x y 
goal: ⟦x⟧ = ⟦y⟧ ↔ ∀ s ∈ S, s.Rel x y

full_name: Setoid.map_of_le
code: /-- The map induced between quotients by a setoid inequality. -/
def map_of_le {s t : Setoid α} (h : s ≤ t) : Quotient s → Quotient t 
goal: Quotient s → Quotient t

full_name: Setoid.map_sInf
code: /-- The map from the quotient of the infimum of a set of setoids into the quotient
by an element of this set. -/
def map_sInf {S : Set (Setoid α)} {s : Setoid α} (h : s ∈ S) :
    Quotient (sInf S) → Quotient s 
goal: Quotient (sInf S) → Quotient s

full_name: Setoid.eqvGen_eq
code: /-- The inductively defined equivalence closure of a binary relation r is the infimum
    of the set of all equivalence relations containing r. -/
theorem eqvGen_eq (r : α → α → Prop) :
    EqvGen.Setoid r = sInf { s : Setoid α | ∀ ⦃x y⦄, r x y → s.Rel x y } 
goal: EqvGen.Setoid r = sInf {s | ∀ ⦃x y : α⦄, r x y → s.Rel x y}

full_name: Setoid.sup_eq_eqvGen
code: /-- The supremum of two equivalence relations r and s is the equivalence closure of the binary
    relation `x is related to y by r or s`. -/
theorem sup_eq_eqvGen (r s : Setoid α) :
    r ⊔ s = EqvGen.Setoid fun x y => r.Rel x y ∨ s.Rel x y 
goal: r ⊔ s = EqvGen.Setoid fun x y => r.Rel x y ∨ s.Rel x y

full_name: Setoid.sup_def
code: /-- The supremum of 2 equivalence relations r and s is the equivalence closure of the
    supremum of the underlying binary operations. -/
theorem sup_def {r s : Setoid α} : r ⊔ s = EqvGen.Setoid (r.Rel ⊔ s.Rel) 
goal: r ⊔ s = EqvGen.Setoid (r.Rel ⊔ s.Rel)

full_name: Setoid.sSup_eq_eqvGen
code: /-- The supremum of a set S of equivalence relations is the equivalence closure of the binary
    relation `there exists r ∈ S relating x and y`. -/
theorem sSup_eq_eqvGen (S : Set (Setoid α)) :
    sSup S = EqvGen.Setoid fun x y => ∃ r : Setoid α, r ∈ S ∧ r.Rel x y 
goal: sSup S = EqvGen.Setoid fun x y => ∃ r ∈ S, r.Rel x y

full_name: Setoid.sSup_def
code: /-- The supremum of a set of equivalence relations is the equivalence closure of the
    supremum of the set's image under the map to the underlying binary operation. -/
theorem sSup_def {s : Set (Setoid α)} : sSup s = EqvGen.Setoid (sSup (Rel '' s)) 
goal: sSup s = EqvGen.Setoid (sSup (Setoid.Rel '' s))

full_name: Setoid.eqvGen_of_setoid
code: /-- The equivalence closure of an equivalence relation r is r. -/
@[simp]
theorem eqvGen_of_setoid (r : Setoid α) : EqvGen.Setoid r.r = r 
goal: EqvGen.Setoid Setoid.r = r

full_name: Setoid.eqvGen_idem
code: /-- Equivalence closure is idempotent. -/
@[simp]
theorem eqvGen_idem (r : α → α → Prop) : EqvGen.Setoid (EqvGen.Setoid r).Rel = EqvGen.Setoid r 
goal: EqvGen.Setoid (EqvGen.Setoid r).Rel = EqvGen.Setoid r

full_name: Setoid.eqvGen_le
code: /-- The equivalence closure of a binary relation r is contained in any equivalence
    relation containing r. -/
theorem eqvGen_le {r : α → α → Prop} {s : Setoid α} (h : ∀ x y, r x y → s.Rel x y) :
    EqvGen.Setoid r ≤ s 
goal: EqvGen.Setoid r ≤ s

full_name: Setoid.eqvGen_mono
code: /-- Equivalence closure of binary relations is monotone. -/
theorem eqvGen_mono {r s : α → α → Prop} (h : ∀ x y, r x y → s x y) :
    EqvGen.Setoid r ≤ EqvGen.Setoid s 
goal: EqvGen.Setoid r ≤ EqvGen.Setoid s

full_name: Setoid.gi
code: /-- There is a Galois insertion of equivalence relations on α into binary relations
    on α, with equivalence closure the lower adjoint. -/
def gi : @GaloisInsertion (α → α → Prop) (Setoid α) _ _ EqvGen.Setoid Rel 
goal: GaloisInsertion EqvGen.Setoid Setoid.Rel

full_name: Setoid.injective_iff_ker_bot
code: /-- A function from α to β is injective iff its kernel is the bottom element of the complete lattice
    of equivalence relations on α. -/
theorem injective_iff_ker_bot (f : α → β) : Injective f ↔ ker f = ⊥ 
goal: Function.Injective f ↔ Setoid.ker f = ⊥

full_name: Setoid.ker_iff_mem_preimage
code: /-- The elements related to x ∈ α by the kernel of f are those in the preimage of f(x) under f. -/
theorem ker_iff_mem_preimage {f : α → β} {x y} : (ker f).Rel x y ↔ x ∈ f ⁻¹' {f y} 
goal: (Setoid.ker f).Rel x y ↔ x ∈ f ⁻¹' {f y}

full_name: Setoid.liftEquiv
code: /-- Equivalence between functions `α → β` such that `r x y → f x = f y` and functions
`quotient r → β`. -/
def liftEquiv (r : Setoid α) : { f : α → β // r ≤ ker f } ≃ (Quotient r → β) 
goal: { f // r ≤ Setoid.ker f } ≃ (Quotient r → β)

full_name: Setoid.lift_unique
code: /-- The uniqueness part of the universal property for quotients of an arbitrary type. -/
theorem lift_unique {r : Setoid α} {f : α → β} (H : r ≤ ker f) (g : Quotient r → β)
    (Hg : f = g ∘ Quotient.mk'') : Quotient.lift f H = g 
goal: Quotient.lift f H = g

full_name: Setoid.ker_lift_injective
code: /-- Given a map f from α to β, the natural map from the quotient of α by the kernel of f is
    injective. -/
theorem ker_lift_injective (f : α → β) : Injective (@Quotient.lift _ _ (ker f) f fun _ _ h => h) 
goal: Function.Injective (Quotient.lift f ⋯)

full_name: Setoid.ker_eq_lift_of_injective
code: /-- Given a map f from α to β, the kernel of f is the unique equivalence relation on α whose
    induced map from the quotient of α to β is injective. -/
theorem ker_eq_lift_of_injective {r : Setoid α} (f : α → β) (H : ∀ x y, r.Rel x y → f x = f y)
    (h : Injective (Quotient.lift f H)) : ker f = r 
goal: Setoid.ker f = r

full_name: Setoid.quotientKerEquivRange
code: /-- The first isomorphism theorem for sets: the quotient of α by the kernel of a function f
    bijects with f's image. -/
noncomputable def quotientKerEquivRange : Quotient (ker f) ≃ Set.range f 
goal: Quotient (Setoid.ker f) ≃ ↑(Set.range f)

full_name: Setoid.quotientKerEquivOfRightInverse_apply
code: /-- If `f` has a computable right-inverse, then the quotient by its kernel is equivalent to its
domain. -/
@[simps]
def quotientKerEquivOfRightInverse (g : β → α) (hf : Function.RightInverse g f) :
    Quotient (ker f) ≃ β 
goal: (Setoid.quotientKerEquivOfRightInverse f g hf) a = a.liftOn' f ⋯

full_name: Setoid.quotientKerEquivOfRightInverse_symm_apply
code: /-- If `f` has a computable right-inverse, then the quotient by its kernel is equivalent to its
domain. -/
@[simps]
def quotientKerEquivOfRightInverse (g : β → α) (hf : Function.RightInverse g f) :
    Quotient (ker f) ≃ β 
goal: (Setoid.quotientKerEquivOfRightInverse f g hf).symm b = Quotient.mk'' (g b)

full_name: Setoid.quotientKerEquivOfRightInverse
code: /-- If `f` has a computable right-inverse, then the quotient by its kernel is equivalent to its
domain. -/
@[simps]
def quotientKerEquivOfRightInverse (g : β → α) (hf : Function.RightInverse g f) :
    Quotient (ker f) ≃ β 
goal: Quotient (Setoid.ker f) ≃ β

full_name: Setoid.quotientKerEquivOfSurjective
code: /-- The quotient of α by the kernel of a surjective function f bijects with f's codomain.

If a specific right-inverse of `f` is known, `Setoid.quotientKerEquivOfRightInverse` can be
definitionally more useful. -/
noncomputable def quotientKerEquivOfSurjective (hf : Surjective f) : Quotient (ker f) ≃ β 
goal: Quotient (Setoid.ker f) ≃ β

full_name: Setoid.map
code: /-- Given a function `f : α → β` and equivalence relation `r` on `α`, the equivalence
    closure of the relation on `f`'s image defined by '`x ≈ y` iff the elements of `f⁻¹(x)` are
    related to the elements of `f⁻¹(y)` by `r`.' -/
def map (r : Setoid α) (f : α → β) : Setoid β 
goal: Setoid β

full_name: Setoid.mapOfSurjective
code: /-- Given a surjective function f whose kernel is contained in an equivalence relation r, the
    equivalence relation on f's codomain defined by x ≈ y ↔ the elements of f⁻¹(x) are related to
    the elements of f⁻¹(y) by r. -/
def mapOfSurjective (r) (f : α → β) (h : ker f ≤ r) (hf : Surjective f) : Setoid β 
goal: Setoid β

full_name: Setoid.mapOfSurjective_eq_map
code: /-- A special case of the equivalence closure of an equivalence relation r equalling r. -/
theorem mapOfSurjective_eq_map (h : ker f ≤ r) (hf : Surjective f) :
    map r f = mapOfSurjective r f h hf 
goal: r.map f = r.mapOfSurjective f h hf

full_name: Setoid.comap
code: /-- Given a function `f : α → β`, an equivalence relation `r` on `β` induces an equivalence
relation on `α` defined by '`x ≈ y` iff `f(x)` is related to `f(y)` by `r`'.

See note [reducible non-instances]. -/
abbrev comap (f : α → β) (r : Setoid β) : Setoid α 
goal: Setoid α

full_name: Setoid.comap_rel
code: theorem comap_rel (f : α → β) (r : Setoid β) (x y : α) : (comap f r).Rel x y ↔ r.Rel (f x) (f y) 
goal: (Setoid.comap f r).Rel x y ↔ r.Rel (f x) (f y)

full_name: Setoid.comap_eq
code: /-- Given a map `f : N → M` and an equivalence relation `r` on `β`, the equivalence relation
    induced on `α` by `f` equals the kernel of `r`'s quotient map composed with `f`. -/
theorem comap_eq {f : α → β} {r : Setoid β} : comap f r = ker (@Quotient.mk'' _ r ∘ f) 
goal: Setoid.comap f r = Setoid.ker (Quotient.mk'' ∘ f)

full_name: Setoid.comapQuotientEquiv
code: /-- The second isomorphism theorem for sets. -/
noncomputable def comapQuotientEquiv (f : α → β) (r : Setoid β) :
    Quotient (comap f r) ≃ Set.range (@Quotient.mk'' _ r ∘ f) 
goal: Quotient (Setoid.comap f r) ≃ ↑(Set.range (Quotient.mk'' ∘ f))

full_name: Setoid.quotientQuotientEquivQuotient
code: /-- The third isomorphism theorem for sets. -/
def quotientQuotientEquivQuotient (s : Setoid α) (h : r ≤ s) :
    Quotient (ker (Quot.mapRight h)) ≃ Quotient s 
goal: Quotient (Setoid.ker (Quot.mapRight h)) ≃ Quotient s

full_name: Setoid.correspondence
code: /-- Given an equivalence relation `r` on `α`, the order-preserving bijection between the set of
equivalence relations containing `r` and the equivalence relations on the quotient of `α` by `r`. -/
def correspondence (r : Setoid α) : { s // r ≤ s } ≃o Setoid (Quotient r) 
goal: { s // r ≤ s } ≃o Setoid (Quotient r)

full_name: Setoid.sigmaQuotientEquivOfLe
code: /-- Given two equivalence relations with `r ≤ s`, a bijection between the sum of the quotients by
`r` on each equivalence class by `s` and the quotient by `r`. -/
def sigmaQuotientEquivOfLe {r s : Setoid α} (hle : r ≤ s) :
    (Σ q : Quotient s, Quotient (r.comap (Subtype.val : Quotient.mk s ⁻¹' {q} → α))) ≃
      Quotient r 
goal: (q : Quotient s) × Quotient (Setoid.comap Subtype.val r) ≃ Quotient r

full_name: Quotient.subsingleton_iff
code: @[simp]
theorem Quotient.subsingleton_iff {s : Setoid α} : Subsingleton (Quotient s) ↔ s = ⊤ 
goal: Subsingleton (Quotient s) ↔ s = ⊤

full_name: Quot.subsingleton_iff
code: theorem Quot.subsingleton_iff (r : α → α → Prop) : Subsingleton (Quot r) ↔ EqvGen r = ⊤ 
goal: Subsingleton (Quot r) ↔ EqvGen r = ⊤