Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid clashes of generated declarations and Lean 4 #4742

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

JuanCoRo
Copy link
Member

Some generated names might clash with Lean's built in declarations. For instance, generating the function symbols for evm-semantics produces axiom ite, which clashes with Lean:

axiom ite {SortSort : Type} (x0 : SortBool) (x1 : SortSort) (x2 : SortSort) : Option SortSort

To avoid the clash error, it is now generated as:

axiom iteAx {SortSort : Type} (x0 : SortBool) (x1 : SortSort) (x2 : SortSort) : Option SortSort

Safeguards are put in place for other types of declarations, such as inductive, structure, abbrev and instance.

@JuanCoRo JuanCoRo requested a review from tothtamas28 January 21, 2025 16:39
@JuanCoRo JuanCoRo self-assigned this Jan 21, 2025
Copy link
Contributor

@tothtamas28 tothtamas28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider opening an issue for this instead. We can clear up minor issues like this once we have a semi-automatic end-to-end example worked out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be handled in the generator, and maybe checked in the model.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave this as a future item if/when work on this PR resumes.

@@ -7,6 +7,9 @@

if TYPE_CHECKING:
from collections.abc import Iterable
from typing import Final

_LEAN_KEYWORDS: Final = {'ite', 'end', 'where'} # Words that cannot be a the name of a declaration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end and where are keywords, ite is probably just a predefined function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to _LEAN_WORDS. Let me know if this notation is not desired, or if we should separate into two sets depending on keyword or definition.

@JuanCoRo
Copy link
Member Author

I'll open an issue then, and leave finishing the rest of the work here for when we decide to tackle it 👌

@JuanCoRo JuanCoRo mentioned this pull request Jan 21, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants