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

Add cheatcodes that generate symbolic variables with custom names #902

Merged
merged 10 commits into from
Dec 9, 2024

Conversation

anvacaru
Copy link
Contributor

@anvacaru anvacaru commented Dec 5, 2024

Using custom_step to rename symbolic variables generated by cheatcodes.
Blocked on : runtimeverification/kontrol-cheatcodes#16

In this PR:

  1. Adding a new #rename rule that all cheatcodes that generate symbolic variables would rewrite into.
    syntax RenameTarget ::= Int | Bytes | Map
    syntax KItem ::= #rename ( RenameTarget , String ) [symbol(foundry_rename)]
 // ---------------------------------------------------------------------------
    rule [rename]: <k> #rename(_,_) => .K ... </k>

The goal is to have a single cut-rule rename.
2. In KontrolSemantics, we add:

  • _check_rename_pattern(self, cterm: CTerm) -> bool:
    • checks if the #rename cut-rule is at the top of the K Cell.
  • _exec_rename_custom_step(self, cterm: CTerm) -> KCFGExtendResult | None:
    • takes the newly generated symbolic variable (target_var) and new name (new_name) from the top of the K Rule.
    • ensures that the new name is unique in the CTerm, if not, it appends an indexed suffix.
    • using Subst replaces all instances of the target_var with a new KVariable(new_name.token, target_var.sort) in the given CTerm configuration and constraints.
  1. Added new unit and show integration tests.
  2. Bumping kontrol-cheatcodes and forge-std versions for tests/integration/test-data/foundry

src/kontrol/utils.py Outdated Show resolved Hide resolved
src/kontrol/utils.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@palinatolmach palinatolmach left a comment

Choose a reason for hiding this comment

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

lgtm!

@automergerpr-permission-manager automergerpr-permission-manager bot merged commit eb61949 into master Dec 9, 2024
12 checks passed
@PetarMax
Copy link
Contributor

PetarMax commented Dec 9, 2024

Slightly late to the party - it would be great if we could make a minor adjustment where the indices are not separated from the name, like the backend has been doing for a while now - X, X0, X1, etc.

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.

3 participants