Zulip Chat Archive

Stream: mathlib4

Topic: unique term inhabiting the unit


Dean Young (Dec 14 2022 at 18:54):

I'm looking for answers to these two questions:

def constituent  : Unit := ?
def uniqueness : forall (x : Unit), forall (y : Unit) (x = y) := ?

Kevin Buzzard (Dec 14 2022 at 19:17):

Right click on the definition of Unit and jump to its definition to see the answers!

Mario Carneiro (Dec 14 2022 at 19:18):

I think even the docstring will answer one of them

Kevin Buzzard (Dec 14 2022 at 19:18):

It's spelt like this by the way:

def constituent : Unit := sorry
def uniqueness :  (x : Unit) (y : Unit), (x = y) := sorry

(maybe jumping to definition doesn't work if there are syntax errors everywhere)

Kevin Buzzard (Dec 14 2022 at 19:20):

Actually the second one isn't immediately obvious from the definition :-(

def constituent : Unit := Unit.unit
def uniqueness :  (x : Unit) (y : Unit), (x = y) := Subsingleton.elim

Mario Carneiro (Dec 14 2022 at 19:21):

the second question is less obvious, the exact answer is PUnit.subsingleton but Subsingleton.elim is the more general version

Mario Carneiro (Dec 14 2022 at 19:21):

we should put info about Subsingleton in the Unit docstring

Yaël Dillies (Dec 14 2022 at 19:22):

The second shouldn't be a def, Kevin :wink:

Kevin Buzzard (Dec 14 2022 at 19:27):

import Mathlib

def constituent : Unit := Unit.unit
theorem uniqueness :  (x : Unit) (y : Unit), (x = y) := by library_search -- works

Kevin Buzzard (Dec 14 2022 at 19:27):

library_search is a useful tool to answer questions of the form "how do I do this thing which is probably in the library"

Scott Kovach (Dec 14 2022 at 20:01):

mildly interesting: I tried library_search here and it gave me fun a b ↦ rfl, avoiding the case analysis needed in lean3. can anyone explain why rfl alone works in lean4?

Eric Wieser (Dec 14 2022 at 20:07):

I think this might be a weird case of the new structure eta feature that makes Prod.Mk x.1 x.2 = x, but for Unit which has no arguments

Scott Kovach (Dec 14 2022 at 20:13):

you're right! but actually intentionally supported: https://github.com/leanprover/lean4/issues/777#issuecomment-977970138


Last updated: Dec 20 2023 at 11:08 UTC