Skip to content

Setoid.Relations.Discrete

Discrete Relations on Setoids

This is the Setoid.Relations.Discrete module of the Agda Universal Algebra Library.

"Discrete" here means binary, as opposed to the arbitrary-arity relations of Setoid.Relations.Continuous.

The centre of the module is the kernel of a setoid function: the relation on the domain holding of two elements just when the function sends them to elements that are equal in the codomain. It appears in three shapes, because three are wanted downstream: fker as a binary relation, fkerPred as a predicate on pairs, and fkerlift with its level raised. Also here are function-equality, pointwise equality of setoid functions, and Im_โІ_, the assertion that a function's image lands inside a given subset.

Kernels of homomorphisms, which are these kernels together with compatibility with the operations, are in Setoid.Homomorphisms.Kernels.

{-# OPTIONS --cubical-compatible --exact-split --safe #-}

module Setoid.Relations.Discrete where

-- Imports from Agda and the Agda Standard Library ----------------------------------------------
open import Agda.Primitive               using () renaming ( Set to Type )
open import Data.Product                 using ( _,_ ; _ร—_ )
open import Function                     using () renaming ( Func to _โŸถ_ )
open import Level                        using ( Level ;  _โŠ”_ ; Lift )
open import Relation.Binary              using ( IsEquivalence ; Setoid )
open import Relation.Binary.Core         using ()
                                         renaming ( Rel to BinaryRel )
open import Relation.Unary               using ( _โˆˆ_; Pred )

-- Imports from agda-algebras -------------------------------------------------------------------

private variable ฮฑ ฮฒ ฯแตƒ ฯแต‡ โ„“ : Level

Here is a function that is useful for defining pointwise equality of functions wrt a given equality.

open _โŸถ_ renaming ( to to _โŸจ$โŸฉ_ )
module _ {๐ด : Setoid ฮฑ ฯแตƒ}{๐ต : Setoid ฮฒ ฯแต‡} where
  open Setoid ๐ด  using () renaming ( Carrier to A ; _โ‰ˆ_ to _โ‰ˆโ‚_ )
  open Setoid ๐ต  using () renaming ( Carrier to B ; _โ‰ˆ_ to _โ‰ˆโ‚‚_ )

  function-equality : BinaryRel (๐ด โŸถ ๐ต) (ฮฑ โŠ” ฯแต‡)
  function-equality f g = โˆ€ x โ†’ f โŸจ$โŸฉ x โ‰ˆโ‚‚ g โŸจ$โŸฉ x

Here is useful notation for asserting that the image of a function (the first argument) is contained in a predicate, the second argument (a "subset" of the codomain).

  Im_โІ_ : (๐ด โŸถ ๐ต) โ†’ Pred B โ„“ โ†’ Type (ฮฑ โŠ” โ„“)
  Im f โІ S = โˆ€ x โ†’ f โŸจ$โŸฉ x โˆˆ S

Kernels on setoids

Given setoids ๐ด and ๐ต (with carriers A and B, resp), the kernel of a function f : ๐ด โŸถ ๐ต is defined informally by {(x , y) โˆˆ A ร— A : f โŸจ$โŸฉ x โ‰ˆโ‚‚ f โŸจ$โŸฉ y}.

  fker : (๐ด โŸถ ๐ต) โ†’ BinaryRel A ฯแต‡
  fker g x y = g โŸจ$โŸฉ x โ‰ˆโ‚‚ g โŸจ$โŸฉ y

  fkerPred : (๐ด โŸถ ๐ต) โ†’ Pred (A ร— A) ฯแต‡
  fkerPred g (x , y) = g โŸจ$โŸฉ x โ‰ˆโ‚‚ g โŸจ$โŸฉ y

  open IsEquivalence

  fkerlift : (๐ด โŸถ ๐ต) โ†’ (โ„“ : Level) โ†’ BinaryRel A (โ„“ โŠ” ฯแต‡)
  fkerlift g โ„“ x y = Lift โ„“ (g โŸจ$โŸฉ x โ‰ˆโ‚‚ g โŸจ$โŸฉ y)

  -- The *identity relation* (equivalently, the kernel of a 1-to-1 function)
  0rel : {โ„“ : Level} โ†’ BinaryRel A (ฯแตƒ โŠ” โ„“)
  0rel {โ„“} = ฮป x y โ†’ Lift โ„“ (x โ‰ˆโ‚ y)