Zulip Chat Archive
Stream: new members
Topic: questions about type class instance
Winston Yin (Jun 22 2021 at 08:20):
I'm trying to do two things.
- Define a structure containing, say,
(ι : Type*)
, but also requiringnontrivial ι
, perhaps by type class inference rather than explicit proof. E.g.
structure my_struct :=
(ι : Type*)
[nontriv_ι : nontrivial ι]
...
- In a proof, I need to provide a term for the type
Π₀ i : ι, M i
. When I construct this term using an object ofmy_struct
, Lean fails to seenontriv_ι
when synthesising thenontrivial ι
for thedfinsupp
. How can I help Lean see the type class instance provided bynontriv_ι
? Lean keeps saying "failed to synthesise type class instance".
Kevin Buzzard (Jun 22 2021 at 08:21):
The square brackets in the definition do not make it an instance. Try attribute [instance] my_struct.nontriv_ι
after the definition and see if this fixes things.
Eric Wieser (Jun 22 2021 at 08:37):
I think for this specific example #lint
will complain the instance is dangerous / impossible, but that might just be because you over-minimized the example
Last updated: Dec 20 2023 at 11:08 UTC