Zulip Chat Archive

Stream: new members

Topic: Structure which extends two different structures


Dean Young (Mar 10 2023 at 14:56):

Is it possible to make a structure which extends two different structures at once?

Alex J. Best (Mar 10 2023 at 15:07):

https://leanprover.github.io/theorem_proving_in_lean/structures_and_records.html#inheritance

Dean Young (Mar 11 2023 at 05:48):

If two structures extend a common substructure, then does their mutual extension know not to duplicate the items in the common substructure?

Jireh Loreaux (Mar 11 2023 at 22:34):

Yes

Jireh Loreaux (Mar 11 2023 at 22:34):

If those fields have the same names.

Eric Wieser (Mar 11 2023 at 23:15):

@Kind Bubble, have you considered just trying this and seeing what happens?

Eric Wieser (Mar 11 2023 at 23:15):

Lean will give you a much faster answer to "what does this code do" than zulip will.

Jireh Loreaux (Mar 11 2023 at 23:49):

To follow-up on Eric's point, they way you would check this is:

structure foo :=
(x : nat)
(y : nat)

structure bar :=
(y : nat)
(z : nat)

structure baz extends foo, bar

#print baz

Last updated: Dec 20 2023 at 11:08 UTC