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

Improvements/refactors to substitution extraction routine #4631

Merged
merged 5 commits into from
Sep 6, 2024

Conversation

ehildenb
Copy link
Member

@ehildenb ehildenb commented 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.

@ehildenb ehildenb self-assigned this Sep 6, 2024
@rv-jenkins rv-jenkins changed the base branch from master to develop September 6, 2024 06:09
@ehildenb ehildenb marked this pull request as ready for review September 6, 2024 06:39
pyk/src/pyk/kast/manip.py Show resolved Hide resolved
pyk/src/pyk/kast/manip.py Show resolved Hide resolved
@rv-jenkins rv-jenkins merged commit c54f424 into develop Sep 6, 2024
17 checks passed
@rv-jenkins rv-jenkins deleted the extract-subst-improvements branch September 6, 2024 08:43
rv-jenkins pushed a commit that referenced this pull request Sep 6, 2024
In the KCFG printer, we have two separate places where `CSubst` are
printed out, for `Split` and for `Cover`. There was lots of very-similar
code between the two of them, and also some incorrect logic abotu
minimization. This PR:

- Factors out helpers that make this printing logic easier.
- Makes sure that we take into account minimization properly.
- Standardizes how the printing for `CSubst` works.
- Updates expected test output.
- Includes some formatting/style reviews from
#4631 that were skipped
because of automerger.
rv-jenkins pushed a commit that referenced this pull request Sep 9, 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.
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