Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: define Squash as a Quotient #6642

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/Init/Core.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1908,6 +1908,13 @@ instance Pi.instSubsingleton {α : Sort u} {β : α → Sort v} [∀ a, Subsingl

/-! # Squash -/

theorem equivalence_true (α : Sort u) : Equivalence fun _ _ : α ↦ True :=
⟨fun _ ↦ trivial, fun _ ↦ trivial, fun _ _ ↦ trivial⟩

/-- Always-true relation as a `Setoid`. -/
def Setoid.trivial (α : Sort u) : Setoid α :=
⟨_, equivalence_true α⟩

/--
`Squash α` is the quotient of `α` by the always true relation.
It is empty if `α` is empty, otherwise it is a singleton.
Expand All @@ -1921,8 +1928,12 @@ represents an element of `Squash α` the same as `α` itself

`Squash.lift` will extract a value in any subsingleton `β` from a function on `α`,
while `Nonempty.rec` can only do the same when `β` is a proposition.

We define `Squash` in terms of `Quotient` rather than just `Quot`. This means that
`Squash` can be used when a `Quotient` argument is expected, and the setoid will be
automatically inferred.
-/
def Squash (α : Sort u) := Quot (fun (_ _ : α) => True)
def Squash (α : Sort u) := Quotient (Setoid.trivial α)

/-- The canonical quotient map into `Squash α`. -/
def Squash.mk {α : Sort u} (x : α) : Squash α := Quot.mk _ x
Expand Down
Loading