Zulip Chat Archive

Stream: lean4

Topic: KeyedDeclsAttribute


Daniel Selsam (May 25 2021 at 02:23):

Does anybody have a working example of declaring a new (non-builtin) KeyedDeclsAttribute?

Mario Carneiro (May 25 2021 at 02:24):

I thought that custom attributes were not yet supported? I tried going through the motions a while ago and hit some error about initialize not working after initialization

Daniel Selsam (May 25 2021 at 02:28):

Okay, thanks.

Mac (May 25 2021 at 05:47):

Mario Carneiro said:

I thought that custom attributes were not yet supported? I tried going through the motions a while ago and hit some error about initialize not working after initialization

What makes you think that custom attributes are not yet supported? It seems to me one can register attributes the same way core Lean does (with builtin_initialize).

Mario Carneiro (May 25 2021 at 05:56):

that's what I thought as well, but I tried it and it didn't work

Mario Carneiro (May 25 2021 at 05:56):

and I didn't know enough about how initialize is set up to troubleshoot it

Mario Carneiro (May 25 2021 at 06:03):

Here's a MWE:

-- A.lean
initialize fooAttr : TagAttribute 
  registerTagAttribute `foo "test"
-- B.lean
import A -- error: failed to register environment, extensions can only be registered during initialization

Mac (May 25 2021 at 06:14):

Yes, you can't use initialize, but you can use builtin_initialize

Mac (May 25 2021 at 06:16):

I think initialize, despite its name, actually runs after initializing the environment, whereas bulitin_initialize actually runs during initialization.

Mac (May 25 2021 at 06:17):

However, I think this may mean you need to feed in the code that initializes the attribute as a --plugin to lean.

Mac (May 25 2021 at 06:19):

Unfortunately, I had trouble testing this due to issue #486 (which I just posted).


Last updated: Dec 20 2023 at 11:08 UTC