Documentation

Mathlib.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 CompleteLattice.copy to define a complete lattice instance with more appropriate definitional equalities (a similar example is Filter.CompleteLattice 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
  • r.Rel = Setoid.r
Instances For
    instance Setoid.decidableRel {α : Type u_1} (r : Setoid α) [h : DecidableRel Setoid.r] :
    Equations
    • r.decidableRel = h
    theorem Quotient.eq_rel {α : Type u_1} {r : Setoid α} {x : α} {y : α} :

    A version of Quotient.eq' compatible with Setoid.Rel, to make rewriting possible.

    theorem Setoid.ext'_iff {α : Type u_1} {r : Setoid α} {s : Setoid α} :
    r = s ∀ (a b : α), r.Rel a b s.Rel a b
    theorem Setoid.ext' {α : Type u_1} {r : Setoid α} {s : Setoid α} (H : ∀ (a b : α), r.Rel a b s.Rel a b) :
    r = s
    theorem Setoid.ext_iff {α : Type u_1} {r : Setoid α} {s : Setoid α} :
    r = s ∀ (a b : α), r.Rel a b s.Rel a b
    theorem Setoid.eq_iff_rel_eq {α : Type u_1} {r₁ : Setoid α} {r₂ : Setoid α} :
    r₁ = r₂ r₁.Rel = r₂.Rel

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

    instance Setoid.instLE_mathlib {α : Type u_1} :
    LE (Setoid α)

    Defining for equivalence relations.

    Equations
    • Setoid.instLE_mathlib = { le := fun (r s : Setoid α) => ∀ ⦃x y : α⦄, r.Rel x ys.Rel x y }
    theorem Setoid.le_def {α : Type u_1} {r : Setoid α} {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
    • Setoid.ker f = { r := (fun (x1 x2 : β) => x1 = x2) on f, iseqv := }
    Instances For
      @[simp]
      theorem Setoid.ker_mk_eq {α : Type u_1} (r : Setoid α) :
      Setoid.ker Quotient.mk'' = r

      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 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
      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
      • r.prod s = { r := fun (x y : α × β) => r.Rel x.1 y.1 s.Rel x.2 y.2, iseqv := }
      Instances For
        instance Setoid.instInf {α : Type u_1} :
        Inf (Setoid α)

        The infimum of two equivalence relations.

        Equations
        • Setoid.instInf = { inf := fun (r s : Setoid α) => { r := fun (x y : α) => r.Rel x y s.Rel x y, iseqv := } }
        theorem Setoid.inf_def {α : Type u_1} {r : Setoid α} {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 : Setoid α} {s : Setoid α} {x : α} {y : α} :
        (r s).Rel x y r.Rel x y s.Rel x y
        instance Setoid.instInfSet {α : Type u_1} :

        The infimum of a set of equivalence relations.

        Equations
        • Setoid.instInfSet = { sInf := fun (S : Set (Setoid α)) => { r := fun (x y : α) => rS, r.Rel x y, iseqv := } }
        theorem Setoid.sInf_def {α : Type u_1} {s : Set (Setoid α)} :
        (sInf s).Rel = sInf (Setoid.Rel '' s)

        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.

        Equations

        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} :
        .Rel =
        @[simp]
        theorem Setoid.bot_def {α : Type u_1} :
        .Rel = fun (x1 x2 : α) => x1 = x2
        theorem Setoid.eq_top_iff {α : Type u_1} {s : Setoid α} :
        s = ∀ (x y : α), s.Rel x y
        theorem Setoid.sInf_equiv {α : Type u_1} {S : Set (Setoid α)} {x : α} {y : α} :
        x y sS, s.Rel x y
        theorem Setoid.quotient_mk_sInf_eq {α : Type u_1} {S : Set (Setoid α)} {x : α} {y : α} :
        x = y sS, s.Rel x y
        def Setoid.map_of_le {α : Type u_1} {s : Setoid α} {t : Setoid α} (h : s t) :

        The map induced between quotients by a setoid inequality.

        Equations
        Instances For
          def Setoid.map_sInf {α : Type u_1} {S : Set (Setoid α)} {s : Setoid α} (h : s S) :

          The map from the quotient of the infimum of a set of setoids into the quotient by an element of this set.

          Equations
          Instances For
            theorem Setoid.eqvGen_eq {α : Type u_1} (r : ααProp) :
            Relation.EqvGen.setoid r = sInf {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_eqvGen {α : Type u_1} (r : Setoid α) (s : Setoid α) :
            r s = Relation.EqvGen.setoid fun (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 : Setoid α} {s : Setoid α} :
            r s = Relation.EqvGen.setoid (r.Rel s.Rel)

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

            theorem Setoid.sSup_eq_eqvGen {α : Type u_1} (S : Set (Setoid α)) :
            sSup S = Relation.EqvGen.setoid fun (x y : α) => rS, 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.sSup_def {α : Type u_1} {s : Set (Setoid α)} :
            sSup s = Relation.EqvGen.setoid (sSup (Setoid.Rel '' s))

            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.eqvGen_of_setoid {α : Type u_1} (r : Setoid α) :

            The equivalence closure of an equivalence relation r is r.

            @[simp]

            Equivalence closure is idempotent.

            theorem Setoid.eqvGen_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.eqvGen_mono {α : Type u_1} {r : ααProp} {s : ααProp} (h : ∀ (x y : α), r x ys x y) :

            Equivalence closure of binary relations is monotone.

            def Setoid.gi {α : Type u_1} :
            GaloisInsertion Relation.EqvGen.setoid Setoid.Rel

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

            Equations
            Instances For
              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.liftEquiv {α : 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
              • r.liftEquiv = { toFun := fun (f : { f : αβ // r Setoid.ker f }) => Quotient.lift f , invFun := fun (f : Quotient rβ) => f Quotient.mk'', , left_inv := , right_inv := }
              Instances For
                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.quotientKerEquivRange {α : 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
                Instances For
                  @[simp]
                  theorem Setoid.quotientKerEquivOfRightInverse_apply {α : Type u_1} {β : Type u_2} (f : αβ) (g : βα) (hf : Function.RightInverse g f) (a : Quotient (Setoid.ker f)) :
                  (Setoid.quotientKerEquivOfRightInverse f g hf) a = a.liftOn' f
                  @[simp]
                  theorem Setoid.quotientKerEquivOfRightInverse_symm_apply {α : Type u_1} {β : Type u_2} (f : αβ) (g : βα) (hf : Function.RightInverse g f) (b : β) :
                  def Setoid.quotientKerEquivOfRightInverse {α : Type u_1} {β : Type u_2} (f : αβ) (g : βα) (hf : Function.RightInverse g f) :

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

                  Equations
                  Instances For
                    noncomputable def Setoid.quotientKerEquivOfSurjective {α : 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.quotientKerEquivOfRightInverse can be definitionally more useful.

                    Equations
                    Instances For
                      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
                      Instances For
                        def Setoid.mapOfSurjective {α : 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
                        • r.mapOfSurjective f h hf = { r := fun (x y : β) => ∃ (a : α) (b : α), f a = x f b = y r.Rel a b, iseqv := }
                        Instances For
                          theorem Setoid.mapOfSurjective_eq_map {α : Type u_1} {β : Type u_2} {r : Setoid α} {f : αβ} (h : Setoid.ker f r) (hf : Function.Surjective f) :
                          r.map f = r.mapOfSurjective f h hf

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

                          @[reducible, inline]
                          abbrev 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'.

                          See note [reducible non-instances].

                          Equations
                          Instances For
                            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 β} :
                            Setoid.comap f r = Setoid.ker (Quotient.mk'' f)

                            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.comapQuotientEquiv {α : Type u_1} {β : Type u_2} (f : αβ) (r : Setoid β) :
                            Quotient (Setoid.comap f r) (Set.range (Quotient.mk'' f))

                            The second isomorphism theorem for sets.

                            Equations
                            Instances For

                              The third isomorphism theorem for sets.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                def Setoid.correspondence {α : Type u_1} (r : Setoid α) :
                                { s : Setoid α // 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
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  def Setoid.sigmaQuotientEquivOfLe {α : Type u_1} {r : Setoid α} {s : Setoid α} (hle : r s) :
                                  (q : Quotient s) × Quotient (Setoid.comap Subtype.val r) Quotient r

                                  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.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    @[simp]
                                    theorem Quotient.subsingleton_iff {α : Type u_1} {s : Setoid α} :
                                    theorem Quot.subsingleton_iff {α : Type u_1} (r : ααProp) :