Library FinSet.Quotients.Quotient

In this file we define concrete quotients in the style of Cyril Cohen. The central remark is that for countable types (or, for that matter any type supporting constructive indefinite description and having decidable equality, which is "almost" the same) quotients by decidable equivalence relations can be constructed using only the native equality of Coq. These quotients have the pleasant additional property of being retracts of the original type.

Require Import Coq.Classes.RelationClasses.
Require Import Coq.Classes.Morphisms.
Require Import FinSet.Lib.DProp.
Require Import FinSet.Quotients.Countable.
Require Import FinSet.Quotients.Retract.

The quotient of A by R maps x to the canonical representative of the equivalence class R x (which is given by definite description). The definition of Quotient R requires that R is reflexive to ensure that R x is non-empty. Of course, the quotient construction is only really useful when R is an equivalence. Indeed, symmetry and transitivity will ensure that R x and R y are equivalent when R x y, which, by extensionality of choose will ensure that the canonical representatives of R x and R y are indeed equal. The use of Canonize in the definition makes it so that extensional equality on Quotient R is Coq's primitive equality.
Program Definition Quotient {A} {_:Countable A} (R:AADProp) {_:Reflexive R} : Type :=
  { x:A | Canonize (eq_countable (choose (R x) _) x) }.

Program Definition quotient {A} {_:Countable A} (R:AADProp) {_:Equivalence R} :
      Retract A (Quotient R) := {|
  inj x := x;
  proj x := choose (R x) _
|}.

Universal property of quotients


Lemma universal A (_:Countable A) (R:AADProp) (_:Equivalence R) :
   x, R ((quotient R).(inj) ((quotient R).(proj) x)) x.

Instance proj_proper A (_:Countable A) (R:AADProp) (_:Equivalence R) :
  Proper (R==>eq) (quotient R).(proj).

Extentionality of quotient equality


Lemma quotient_ext A (_:Countable A)
      (R:AADProp) (_:Equivalence R) (u v: Quotient R):
  R ((quotient R).(inj) u) ((quotient R).(inj) v) u=v.

Quotients are countable