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

Cleanups to handling ml predicates and substitutions #4625

Merged
merged 15 commits into from
Sep 9, 2024

Conversation

ehildenb
Copy link
Member

@ehildenb ehildenb commented Sep 5, 2024

Blocked on: #4631
Blocked on: #4630
Blocked on: #4633

While reviewing and going over #4621 with @Stevengre , it became somewhat clear that how we handle turning substitions into ML predicates is a bit dirty. This attempts to clean this up a bit. Where potentially breaking changes to API are introduced here, I've checked if it affects the following repos when I mention "downstream" below: evm-semantics kontrol wasm-semantics riscv-semantics mir-semantics.

In particular:

  • The function CTerm.anti_unify has a simplification where it reuses a function from kast.manip instead of reimplementing it.
  • The functions CSubst.from_pred and CSubst.pred are added, as replacements for Subst.ml_pred. This is because Subst.ml_pred doesn't have a good way to produce correctly sorted predicates, because it's in module kast.inner.
    • Subst.ml_pred is removed, and tests are updated to use the new CSubst variant. None of the downstream repositories use Subst.ml_pred directly.
    • The new CSubst.pred correctly sorts the generated #Equals clauses, defaulting to K sort or if a KDefinition is supplied using it to do sort inference. It also provides options for controlling whether we include the substitution or the constraints in the generated predicate.
    • A test is added for a CSubst.pred case which caused a bug in the integration tests dealing with identity substitutions.
  • The CTermSymbolic.implies function is updated to reuse CSubst.from_pred instead of reimplementing it.
    • On the case of duplicate entries, the first is kept and the latter are made as predicates.

@rv-jenkins rv-jenkins changed the base branch from master to develop September 5, 2024 22:15
@ehildenb ehildenb changed the title Some cleanups to how we compute ml predicates from substitutions Cleanups to handling ml predicates and substitutions Sep 6, 2024
@ehildenb ehildenb self-assigned this Sep 6, 2024
rv-jenkins added a commit that referenced this pull request Sep 6, 2024
Pulled out of: #4625

This PR improves the substitution extraction machinery in `kast.manip`,
and adds tests. This isn't used anywhere at the moment, but #4625 will
start using it heavily.

- The code for `extract_substs` is simplified.
- The cases of circular substitutions are handled slightly more
gracefully.

---------

Co-authored-by: rv-jenkins <admin@runtimeverification.com>
@ehildenb ehildenb marked this pull request as ready for review September 6, 2024 20:57
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.

Nice refactoring!

pyk/src/pyk/cterm/cterm.py Outdated Show resolved Hide resolved
@rv-jenkins rv-jenkins merged commit 2f4d4f5 into develop Sep 9, 2024
17 checks passed
@rv-jenkins rv-jenkins deleted the fix-subst-ml-pred branch September 9, 2024 18:28
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