mathlib documentation

data.setoid.basic

Equivalence relations #

This file defines the complete lattice of equivalence relations on a type, results about the inductively defined equivalence closure of a binary relation, and the analogues of some isomorphism theorems for quotients of arbitrary types.

Implementation notes #

The function rel and lemmas ending in ' make it easier to talk about different equivalence relations on the same type.

The complete lattice instance for equivalence relations could have been defined by lifting the Galois insertion of equivalence relations on α into binary relations on α, and then using complete_lattice.copy to define a complete lattice instance with more appropriate definitional equalities (a similar example is filter.complete_lattice in order/filter/basic.lean). This does not save space, however, and is less clear.

Partitions are not defined as a separate structure here; users are encouraged to reason about them using the existing setoid and its infrastructure.

Tags #

setoid, equivalence, iseqv, relation, equivalence relation

def setoid.rel {α : Type u_1} (r : setoid α) :
α → α → Prop

A version of setoid.r that takes the equivalence relation as an explicit argument.

Equations
theorem quotient.eq_rel {α : Type u_1} {r : setoid α} {x y : α} :

A version of quotient.eq' compatible with setoid.rel, to make rewriting possible.

@[ext]
theorem setoid.ext' {α : Type u_1} {r s : setoid α} (H : ∀ (a b : α), r.rel a b s.rel a b) :
r = s
theorem setoid.ext_iff {α : Type u_1} {r s : setoid α} :
r = s ∀ (a b : α), r.rel a b s.rel a b
theorem setoid.eq_iff_rel_eq {α : Type u_1} {r₁ r₂ : setoid α} :
r₁ = r₂ r₁.rel = r₂.rel

Two equivalence relations are equal iff their underlying binary operations are equal.

@[protected, instance]
def setoid.has_le {α : Type u_1} :

Defining for equivalence relations.

Equations
theorem setoid.le_def {α : Type u_1} {r s : setoid α} :
r s ∀ {x y : α}, r.rel x ys.rel x y
theorem setoid.refl' {α : Type u_1} (r : setoid α) (x : α) :
r.rel x x
theorem setoid.symm' {α : Type u_1} (r : setoid α) {x y : α} :
r.rel x yr.rel y x
theorem setoid.trans' {α : Type u_1} (r : setoid α) {x y z : α} :
r.rel x yr.rel y zr.rel x z
theorem setoid.comm' {α : Type u_1} (s : setoid α) {x y : α} :
s.rel x y s.rel y x
def setoid.ker {α : Type u_1} {β : Type u_2} (f : α → β) :

The kernel of a function is an equivalence relation.

Equations
@[simp]
theorem setoid.ker_mk_eq {α : Type u_1} (r : setoid α) :

The kernel of the quotient map induced by an equivalence relation r equals r.

theorem setoid.ker_apply_mk_out {α : Type u_1} {β : Type u_2} {f : α → β} (a : α) :
f a.out = f a
theorem setoid.ker_apply_mk_out' {α : Type u_1} {β : Type u_2} {f : α → β} (a : α) :
f (quotient.mk' a).out' = f a
theorem setoid.ker_def {α : Type u_1} {β : Type u_2} {f : α → β} {x y : α} :
(setoid.ker f).rel x y f x = f y
@[protected]
def setoid.prod {α : Type u_1} {β : Type u_2} (r : setoid α) (s : setoid β) :
setoid × β)

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.

Equations
@[protected, instance]
def setoid.has_inf {α : Type u_1} :

The infimum of two equivalence relations.

Equations
theorem setoid.inf_def {α : Type u_1} {r s : setoid α} :
(r s).rel = r.rel s.rel

The infimum of 2 equivalence relations r and s is the same relation as the infimum of the underlying binary operations.

theorem setoid.inf_iff_and {α : Type u_1} {r s : setoid α} {x y : α} :
(r s).rel x y r.rel x y s.rel x y
@[protected, instance]
def setoid.has_Inf {α : Type u_1} :

The infimum of a set of equivalence relations.

Equations
theorem setoid.Inf_def {α : Type u_1} {s : set (setoid α)} :

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.

@[protected, instance]
def setoid.partial_order {α : Type u_1} :
Equations
@[protected, instance]
def setoid.complete_lattice {α : Type u_1} :

The complete lattice of equivalence relations on a type, with bottom element = and top element the trivial equivalence relation.

Equations
@[simp]
theorem setoid.top_def {α : Type u_1} :
@[simp]
theorem setoid.bot_def {α : Type u_1} :
theorem setoid.eq_top_iff {α : Type u_1} {s : setoid α} :
s = ∀ (x y : α), s.rel x y
theorem setoid.eqv_gen_eq {α : Type u_1} (r : α → α → Prop) :
eqv_gen.setoid r = Inf {s : setoid α | ∀ ⦃x y : α⦄, r x ys.rel x y}

The inductively defined equivalence closure of a binary relation r is the infimum of the set of all equivalence relations containing r.

theorem setoid.sup_eq_eqv_gen {α : Type u_1} (r s : setoid α) :
r s = eqv_gen.setoid (λ (x y : α), r.rel x y s.rel x y)

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 setoid.sup_def {α : Type u_1} {r s : setoid α} :

The supremum of 2 equivalence relations r and s is the equivalence closure of the supremum of the underlying binary operations.

theorem setoid.Sup_eq_eqv_gen {α : Type u_1} (S : set (setoid α)) :
Sup S = eqv_gen.setoid (λ (x y : α), ∃ (r : setoid α), r S r.rel x y)

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 setoid.Sup_def {α : Type u_1} {s : set (setoid α)} :

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.

@[simp]
theorem setoid.eqv_gen_of_setoid {α : Type u_1} (r : setoid α) :

The equivalence closure of an equivalence relation r is r.

@[simp]
theorem setoid.eqv_gen_idem {α : Type u_1} (r : α → α → Prop) :

Equivalence closure is idempotent.

theorem setoid.eqv_gen_le {α : Type u_1} {r : α → α → Prop} {s : setoid α} (h : ∀ (x y : α), r x ys.rel x y) :

The equivalence closure of a binary relation r is contained in any equivalence relation containing r.

theorem setoid.eqv_gen_mono {α : Type u_1} {r s : α → α → Prop} (h : ∀ (x y : α), r x ys x y) :

Equivalence closure of binary relations is monotone.

There is a Galois insertion of equivalence relations on α into binary relations on α, with equivalence closure the lower adjoint.

Equations
theorem setoid.injective_iff_ker_bot {α : Type u_1} {β : Type u_2} (f : α → β) :

A function from α to β is injective iff its kernel is the bottom element of the complete lattice of equivalence relations on α.

theorem setoid.ker_iff_mem_preimage {α : Type u_1} {β : Type u_2} {f : α → β} {x y : α} :
(setoid.ker f).rel x y x f ⁻¹' {f y}

The elements related to x ∈ α by the kernel of f are those in the preimage of f(x) under f.

def setoid.lift_equiv {α : Type u_1} {β : Type u_2} (r : setoid α) :
{f // r setoid.ker f} (quotient r → β)

Equivalence between functions α → β such that r x y → f x = f y and functions quotient r → β.

Equations
theorem setoid.lift_unique {α : Type u_1} {β : Type u_2} {r : setoid α} {f : α → β} (H : r setoid.ker f) (g : quotient r → β) (Hg : f = g quotient.mk) :

The uniqueness part of the universal property for quotients of an arbitrary type.

theorem setoid.ker_lift_injective {α : Type u_1} {β : Type u_2} (f : α → β) :

Given a map f from α to β, the natural map from the quotient of α by the kernel of f is injective.

theorem setoid.ker_eq_lift_of_injective {α : Type u_1} {β : Type u_2} {r : setoid α} (f : α → β) (H : ∀ (x y : α), r.rel x yf x = f y) (h : function.injective (quotient.lift f H)) :

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.

noncomputable def setoid.quotient_ker_equiv_range {α : Type u_1} {β : Type u_2} (f : α → β) :

The first isomorphism theorem for sets: the quotient of α by the kernel of a function f bijects with f's image.

Equations
@[simp]
theorem setoid.quotient_ker_equiv_of_right_inverse_apply {α : Type u_1} {β : Type u_2} (f : α → β) (g : β → α) (hf : function.right_inverse g f) (a : quotient (setoid.ker f)) :
@[simp]
theorem setoid.quotient_ker_equiv_of_right_inverse_symm_apply {α : Type u_1} {β : Type u_2} (f : α → β) (g : β → α) (hf : function.right_inverse g f) (b : β) :
def setoid.quotient_ker_equiv_of_right_inverse {α : Type u_1} {β : Type u_2} (f : α → β) (g : β → α) (hf : function.right_inverse g f) :

If f has a computable right-inverse, then the quotient by its kernel is equivalent to its domain.

Equations
noncomputable def setoid.quotient_ker_equiv_of_surjective {α : Type u_1} {β : Type u_2} (f : α → β) (hf : function.surjective f) :

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.quotient_ker_equiv_of_right_inverse can be definitionally more useful.

Equations
def setoid.map {α : Type u_1} {β : Type u_2} (r : setoid α) (f : α → β) :

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.'

Equations
def setoid.map_of_surjective {α : Type u_1} {β : Type u_2} (r : setoid α) (f : α → β) (h : setoid.ker f r) (hf : function.surjective f) :

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.

Equations
theorem setoid.map_of_surjective_eq_map {α : Type u_1} {β : Type u_2} {r : setoid α} {f : α → β} (h : setoid.ker f r) (hf : function.surjective f) :
r.map f = r.map_of_surjective f h hf

A special case of the equivalence closure of an equivalence relation r equalling r.

def setoid.comap {α : Type u_1} {β : Type u_2} (f : α → β) (r : setoid β) :

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'.

Equations
theorem setoid.comap_rel {α : Type u_1} {β : Type u_2} (f : α → β) (r : setoid β) (x y : α) :
(setoid.comap f r).rel x y r.rel (f x) (f y)
theorem setoid.comap_eq {α : Type u_1} {β : Type u_2} {f : α → β} {r : setoid β} :

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.

noncomputable def setoid.comap_quotient_equiv {α : Type u_1} {β : Type u_2} (f : α → β) (r : setoid β) :

The second isomorphism theorem for sets.

Equations
def setoid.quotient_quotient_equiv_quotient {α : Type u_1} (r s : setoid α) (h : r s) :

The third isomorphism theorem for sets.

Equations
def setoid.correspondence {α : Type u_1} (r : setoid α) :
{s // r s} ≃o setoid (quotient r)

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.

Equations
@[simp]
theorem quotient.subsingleton_iff {α : Type u_1} {s : setoid α} :
theorem quot.subsingleton_iff {α : Type u_1} (r : α → α → Prop) :