Zulip Chat Archive

Stream: new members

Topic: No to_* on extended struct


Marcus Rossel (Jul 15 2021 at 20:02):

In the following example, n.to_root does not work.

structure root (x : ) := (a : )

structure next (x : ) extends r : (root 0) := (b : r.a = 12)

example (n : next 1) : (root 0) := n.to_root

If I change this to the following, it works.

structure root (x : ) := (a : )

structure next (x : ) extends (root 0) := (b : to_root.a = 12)

example (n : next 1) : (root 0) := n.to_root

Why is that?

Yakov Pechersky (Jul 15 2021 at 20:05):

I'm not familiar with declaring a structure that extends a different one, and at the same time, providing a value for it

Kyle Miller (Jul 15 2021 at 20:18):

@Marcus Rossel The colon notation for extends is what names the function.

structure root (x : ) := (a : )

structure next (x : ) extends r : (root 0) := (b : r.a = 12)

example (n : next 1) : (root 0) := n.r

Kyle Miller (Jul 15 2021 at 20:19):

A helpful command to see what gets defined for the next structure is

#print prefix next

Last updated: Dec 20 2023 at 11:08 UTC