Zulip Chat Archive
Stream: new members
Topic: Type mismatch creating instance of One α and using `1`
Shanghe Chen (Mar 09 2024 at 03:47):
Hi I am continuing the topic Failed to write a*b on Group₁ but now with a smaller example for failed using the notations:
class One1 (α : Type u) where
a : α
instance onehh {α : Type u} [One1 α] : One α := ⟨One1.a⟩
theorem one_1 [One1 α] : a = 1 := rfl
Shanghe Chen (Mar 09 2024 at 03:47):
But it gives an error:
error : type mismathced:
rfl
has type
a = a : Prop
but is expected to have type
a = 1 : Prop
Group.{u} (G : Type u) : Type u
Kevin Buzzard (Mar 09 2024 at 03:49):
Have you got autoImplicit on and you're a beginner? This is a big footgun for beginners. I conjecture that that a is an autoImplicit.
Shanghe Chen (Mar 09 2024 at 03:53):
Shanghe Chen (Mar 09 2024 at 03:53):
Oh I did not turn any option about autoImplicit. Let me check how to turn it on.
Kevin Buzzard (Mar 09 2024 at 03:53):
Yeah I think that has autoImplicit on?
Shanghe Chen (Mar 09 2024 at 03:56):
Kevin Buzzard (Mar 09 2024 at 03:57):
I'm suggesting that you turn it and relaxedAutoImplicit off and then you'll see your error
Shanghe Chen (Mar 09 2024 at 03:59):
Yeah now I get the maybe right error:
image.png
Shanghe Chen (Mar 09 2024 at 04:04):
Still some werid error. Maybe I should read MIL chapter7 first where there are more content on the notations. I am still in MIL chapter 6:tada:
Shanghe Chen (Mar 09 2024 at 06:35):
Ah with the option
set_option relaxedAutoImplicit false
set_option autoImplicit false
Now I get it (at lest for the current topic): the a
in the theorem is not the same a
as in line 8 inside the class. It's in fact an argument created implicitly. Hence they are not the same.
Shanghe Chen (Mar 09 2024 at 06:37):
@Kevin Buzzard Thank you very much for for supplying the information of these options. :tada:
Kevin Buzzard (Mar 09 2024 at 08:46):
No worries!
Last updated: May 02 2025 at 03:31 UTC