Zulip Chat Archive

Stream: new members

Topic: Extending a class with two classes


Mukesh Tiwari (Sep 28 2019 at 08:42):

I have a definition of class meet_semilattice (A : Type u) (R : A -> A -> Prop) (meet : A -> A -> A) extends partial_order A R and
class join_semilattice (A : Type u) (R : A -> A -> Prop) (join : A -> A -> A) extends partial_order A R, and Now I am trying to extend these two classes to
class lattice (A : Type u) (R : A -> A -> Prop) (meet : A -> A -> A) (join : A -> A -> A) extends
(meet_semilattice A R meet)(join_semilattice A R join) by following https://github.com/leanprover/lean/blob/master/library/init/algebra/group.lean#L33

Mukesh Tiwari (Sep 28 2019 at 08:44):

But I am getting this error "Invalid 'structure' header, field 'to_partial_order' from 'Ordering.join_semilattice' has already been declared

Mukesh Tiwari (Sep 28 2019 at 08:47):

https://gist.github.com/mukeshtiwari/6d40904d33911e46d342d194c1771a5b

Patrick Massot (Sep 28 2019 at 08:52):

You could have a look at how all this is done in the standard library: https://github.com/leanprover-community/mathlib/blob/master/src/order/lattice.lean

Patrick Massot (Sep 28 2019 at 08:57):

If you want something closer to what you try, you can change meet_semilattice, join_semilattice and lattice to take [partial_order A R] as a parameter. Of course you'll also need to find other names for H₁ etc in order to avoid name clashes.

Patrick Massot (Sep 28 2019 at 08:58):

But the setup in mathlib will probably be much more convenient.

Mukesh Tiwari (Sep 28 2019 at 08:59):

Thanks for the help Patrick.

Kevin Buzzard (Sep 28 2019 at 11:51):

You might also want to use the "old structure command" -- ("old" as in "the way it used to be done by default", rather than "deprecated"): see https://github.com/leanprover/lean/wiki/Refactoring-structures . In that document, "the current approach" is what is now called the old approach. For lattices this might be what you want. set_option old_structure_cmd true

Mukesh Tiwari (Sep 28 2019 at 12:40):

Thanks Kevin.


Last updated: Dec 20 2023 at 11:08 UTC