Zulip Chat Archive
Stream: general
Topic: unbundled equiv
David Wärn (Apr 09 2020 at 09:41):
Is there no typeclass saying that a specified function has a two-sided inverse? Like bijective f
but carrying data for the inverse. I tried to define this but noticed that simp doesn't like the lemma f (inv f y) = y
Kenny Lau (Apr 09 2020 at 09:43):
you can create your own structure.
Mario Carneiro (Apr 09 2020 at 09:47):
That's equiv
Mario Carneiro (Apr 09 2020 at 09:47):
however it bundles both functions inside the structure
Mario Carneiro (Apr 09 2020 at 09:48):
which plays better with simp lemmas like the one you gave
Kenny Lau (Apr 09 2020 at 09:48):
this new structure would be a subsingleton, which might have some advantage
Scott Morrison (Apr 09 2020 at 10:49):
is_iso
Scott Morrison (Apr 09 2020 at 10:50):
You might have to make sure category_theory.types
is also imported, to hook in the right instance.
David Wärn (Apr 09 2020 at 11:22):
I like this idea
David Wärn (Apr 09 2020 at 11:24):
How do I tell Lean to think of my function as a hom?
import category_theory.types open category_theory variables (α β : Type) (f : α → β) #check is_iso (f : α ⟶ β)
Here Lean complains that f is a \r
arrow and not an \h
arrow (unless I declare it as an \h
arrow to begin with)
Johan Commelin (Apr 09 2020 at 11:38):
@David Wärn Weird... that shouldn't happen
Johan Commelin (Apr 09 2020 at 11:42):
The problem is that it doesn't find the category instance...
import category_theory.types open category_theory variables (α β : Type) (f : α → β) instance foo : category Type := by apply_instance #check @is_iso Type _ α β _
Johan Commelin (Apr 09 2020 at 11:42):
Don't ask me why it doesn't...
Johan Commelin (Apr 09 2020 at 11:43):
This works:
#check @is_iso Type category_theory.types α β f
Kevin Buzzard (Apr 09 2020 at 11:46):
include
the instance? Isn't this often what we have to do?
David Wärn (Apr 09 2020 at 11:54):
include category_theory.types
is invalid as types
is not a parameter/variable
David Wärn (Apr 09 2020 at 11:54):
#print instances category
shows that the instance is in scope anyway
Kevin Buzzard (Apr 09 2020 at 11:55):
Even though it's in scope, it is sometimes not picked up because of universe issues.
Johan Commelin (Apr 09 2020 at 12:00):
Even
#check is_iso.{0} (f : α ⟶ β)
doesn't work
Scott Morrison (Apr 09 2020 at 12:05):
Hmm... that's a pity.
Scott Morrison (Apr 09 2020 at 12:05):
@Johan Commelin -- could you explain to me the difference between { }
brackets and the double braces I've seen you use?
Scott Morrison (Apr 09 2020 at 12:05):
I never learnt this.
Scott Morrison (Apr 09 2020 at 12:06):
def bar := @is_iso.{0} _ _ _ β f
Scott Morrison (Apr 09 2020 at 12:07):
works, but you can't replace the \beta with an _, even if you supply the additional universe level @is_iso.{0 1}
.
Mario Carneiro (Apr 09 2020 at 12:19):
a double brace argument is implicit but it doesn't get applied unless some argument coming after it also gets applied. For example if f : \all {{x y : A}}, A -> A
then f
results in just @f
, while f z
is elaborated to @f _ _ z
Johan Commelin (Apr 09 2020 at 12:19):
@Scott Morrison I think function.injective
is a good example.
def function.injective (f : X → Y) := \forall {{x y}}, f x = f y → x = y
without the double braces hf : function.injective f
would have type f ?1 = f ?2 → ?1 = ?2
. And you would get two crazy meta-variable goals. But with the double braces, hf : function.injective f
has type \forall {x y}, f x = f y → x = y
. Does that make sense?
Mario Carneiro (Apr 09 2020 at 12:20):
It is good for definitions that are hiding a forall, like set.subset
and function.injective
Johan Commelin (Apr 09 2020 at 12:23):
Scott Morrison said:
works, but you can't replace the \beta with an _, even if you supply the additional universe level
@is_iso.{0 1}
.
This is really annoying and sad....
Scott Morrison (Apr 09 2020 at 13:04):
This is the best I can do so far:
import category_theory.types import category_theory.epi_mono open category_theory universe u variables (α β γ : Type) (f : α → β) (g : β → γ) -- We can define an `abbreviation` wrapper that -- lifts honest functions to morphisms in the category `Type`. abbreviation as_hom {α β : Type u} (f : α → β) : α ⟶ β := f example : α → γ := (as_hom f) ≫ (as_hom g) example [is_iso (as_hom f)] : mono (as_hom f) := by apply_instance example [is_iso (as_hom f)] : (as_hom f) ≫ inv (as_hom f) = 𝟙 α := by simp -- If you don't mind some notation you can use fewer keystrokes: notation `↾` f : 200 := as_hom f example : α → γ := ↾f ≫ ↾g example [is_iso ↾f] : mono ↾f := by apply_instance example [is_iso ↾f] : ↾f ≫ inv ↾f = 𝟙 α := by simp
Last updated: Dec 20 2023 at 11:08 UTC