Quotient types coarsen the propositional equality for a type so that terms related by some
equivalence relation are considered equal. The equivalence relation is given by an instance of
Setoid.
Set-theoretically, Quotient s can seen as the set of equivalence classes of α modulo the
Setoid instance's relation s.r. Functions from Quotient s must prove that they respect s.r:
to define a function f : Quotient s → β, it is necessary to provide f' : α → β and prove that
for all x : α and y : α, s.r x y → f' x = f' y. Quotient.lift implements this operation.
The key quotient operators are:
-
Quotient.mkplaces elements of the underlying typeαinto the quotient. -
Quotient.liftallows the definition of functions from the quotient to some other type. -
Quotient.soundasserts the equality of elements related byr -
Quotient.indis used to write proofs about quotients by assuming that all elements are constructed withQuotient.mk.
Quotient is built on top of the primitive quotient type Quot, which does not require a proof
that the relation is an equivalence relation. Quotient should be used instead of Quot for
relations that actually are equivalence relations.