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:A→A→DProp) {_:Reflexive R} : Type :=
{ x:A | Canonize (eq_countable (choose (R x) _) x) }.
Program Definition quotient {A} {_:Countable A} (R:A→A→DProp) {_:Equivalence R} :
Retract A (Quotient R) := {|
inj x := x;
proj x := choose (R x) _
|}.
{ x:A | Canonize (eq_countable (choose (R x) _) x) }.
Program Definition quotient {A} {_:Countable A} (R:A→A→DProp) {_:Equivalence R} :
Retract A (Quotient R) := {|
inj x := x;
proj x := choose (R x) _
|}.
Lemma universal A (_:Countable A) (R:A→A→DProp) (_:Equivalence R) :
∀ x, R ((quotient R).(inj) ((quotient R).(proj) x)) x.
Instance proj_proper A (_:Countable A) (R:A→A→DProp) (_:Equivalence R) :
Proper (R==>eq) (quotient R).(proj).
Lemma quotient_ext A (_:Countable A)
(R:A→A→DProp) (_:Equivalence R) (u v: Quotient R):
R ((quotient R).(inj) u) ((quotient R).(inj) v) → u=v.
Instance quotient_countable A (_:Countable A) (R:A→A→DProp) (_:Equivalence R)
: Countable (Quotient R) :=
Retract.compose countable (Retract.opt_lift (quotient R)).
Instance quotient_inhabited A (_:Countable A) (_:Inhabited A) (R:A→A→DProp) (_:Equivalence R)
: Inhabited (Quotient R) :=
(quotient R).(proj) inhabitant.