Zulip Chat Archive
Stream: general
Topic: extending instances
Kevin Buzzard (Nov 20 2019 at 10:08):
What's the sensible way to get the bounded lattice instance when type class inference knows all the ingredients? by apply_instance
doesn't work for me.
import order.conditionally_complete_lattice open lattice variables {α : Type*} [conditionally_complete_lattice α] example : lattice (with_bot (with_top α)) := by apply_instance -- with_bot.lattice example : order_bot (with_bot (with_top α)) := by apply_instance -- with_bot.order_bot example : order_top (with_bot (with_top α)) := by apply_instance -- with_bot.order_top -- class bounded_lattice (α : Type u) extends lattice α, order_top α, order_bot α example : bounded_lattice (with_bot (with_top α)) := by sorry
Mario Carneiro (Nov 20 2019 at 10:12):
I think {}
works
Mario Carneiro (Nov 20 2019 at 10:12):
If not, {..instance1, ..instance2}
should
Kevin Buzzard (Nov 20 2019 at 10:13):
I had trouble with both of these approaches. Hang on.
Mario Carneiro (Nov 20 2019 at 10:13):
Note that this is expected behavior. There is no instance deriving a subclass from its parents, even if there are no fields. You have to explicitly instantiate the substructure
Kevin Buzzard (Nov 20 2019 at 10:14):
{}
gives 17 errors of the form
invalid structure value { ... }, field 'inf' was not provided
Mario Carneiro (Nov 20 2019 at 10:15):
this works for me:
example : bounded_lattice (with_bot (with_top α)) := {..with_bot.lattice, ..with_bot.order_bot, ..with_bot.order_top}
Mario Carneiro (Nov 20 2019 at 10:15):
Oh I see, it's because bounded_lattice
is an old style structure
Kevin Buzzard (Nov 20 2019 at 10:16):
Yup, works for me too. Thanks.
Kevin Buzzard (Nov 20 2019 at 10:16):
While I'm here, what's the idiomatic way for getting set X
from set (with_top X)
?
Mario Carneiro (Nov 20 2019 at 10:16):
When you use a new style structure, these parents are inferred by type class inference, but with an old style structure the fields are splayed and reconstructed, so you need {.. foo}
to construct the instance
Kevin Buzzard (Nov 20 2019 at 10:16):
i.e the intersection.
Mario Carneiro (Nov 20 2019 at 10:17):
I guess that would be coe '' X
Mario Carneiro (Nov 20 2019 at 10:17):
or rather coe ⁻¹' X
Kevin Buzzard (Nov 20 2019 at 10:17):
right. Thanks.
Last updated: Dec 20 2023 at 11:08 UTC