Zulip Chat Archive

Stream: general

Topic: Where is Subtype.val turned into a coe?


Johan Commelin (Jul 16 2024 at 05:12):

For a PR I'm working on, I need to figure out where Subtype.val is turned into a coe. And I realised that I don't know how to answer that question...
What's the tool for that?

Damiano Testa (Jul 16 2024 at 05:42):

Can you #synth Coe (Subtype Nat) or something similar? (On mobile)

Johan Commelin (Jul 16 2024 at 06:54):

I have not managed to trick #synth into giving me this info

Yaël Dillies (Jul 16 2024 at 06:56):

What do you mean by "turn into a coe"? It could mean two things

Kevin Buzzard (Jul 16 2024 at 06:57):

Right -- there's the attribute and the instance

Johan Commelin (Jul 16 2024 at 06:57):

Where is \u first made to work for Subtype.val.

Johan Commelin (Jul 16 2024 at 06:58):

I know there are two things, but that still doesn't help me figure out where those things are...

Kevin Buzzard (Jul 16 2024 at 06:59):

It also doesn't help me to figure out which of those things is what you're looking for because I still don't understand the lean 4 coercion system :-) Do you need both for the up arrow to work?

Ruben Van de Velde (Jul 16 2024 at 07:26):

You need the instance to be able to type , and the attribute for lean to output the back to you

Ruben Van de Velde (Jul 16 2024 at 07:27):

It's docs#subtypeCoe and it uses CoeOut instead of Coe

Ruben Van de Velde (Jul 16 2024 at 07:27):

I don't understand the difference

Andrew Yang (Jul 16 2024 at 07:33):

According to my superficial understanding, Coe (Subtype p) α looks at α and finds Subtype p, and CoeOut (Subtype p) α looks at Subtype p and finds α. But the former isn't possible, so the latter it is.

Johan Commelin (Jul 16 2024 at 07:38):

Ruben Van de Velde said:

It's docs#subtypeCoe and it uses CoeOut instead of Coe

Awesome! Thanks for finding this for me

Ruben Van de Velde (Jul 16 2024 at 07:39):

I used loogle "Coe", Subtype

Johan Commelin (Jul 16 2024 at 07:42):

My next question is: why is this coe not found in https://github.com/leanprover-community/mathlib4/actions/runs/9945993507/job/27475513441?pr=14769

Ruben Van de Velde (Jul 16 2024 at 08:03):

That's not the issue

theorem Subtype.mono_coe [Preorder α] (t : Set α) : Monotone (( ·) : Subtype t  α) := -- works
  fun _ _  id

theorem Subtype.mono_coe' [Preorder α] (t : Set α) : Monotone (() : Subtype t  α) := -- fails
  fun _ _  id

Ruben Van de Velde (Jul 16 2024 at 08:03):

And the docstring for Mathlib.Tactic.Coe has

Defines notations for coercions.
1. `↑ t` is defined in core.
2. `()` is equivalent to the eta-reduction of `( ·)`

Ruben Van de Velde (Jul 16 2024 at 08:04):

I pushed the import

Johan Commelin (Jul 16 2024 at 08:20):

Aah, very good find!

Johan Commelin (Jul 16 2024 at 09:47):

Awesome! CI is now happy with

chore(Data/Bool): merge Init.Data.Bool.* into Data.Bool.Basic #14769


Last updated: May 02 2025 at 03:31 UTC