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

Declare all Bool combinator equations simplifications (to disambiguate cases) #3786

Closed
wants to merge 5 commits into from

Conversation

jberthold
Copy link
Member

@jberthold jberthold commented Nov 2, 2023

Rules like this pair

rule false andBool _:Bool => false
rule _:Bool andBool false => false

were previously in BOOL-COMMON and were said to demonstrate the implemented semantics of the hooks.
As kore-rpc-booster does not have its own hooks, the rules now come into effect themselves.
This causes issues because of the obvious overlap of rule matches (consider subject term false andBool false which matches both rule LHSs).
This PR addresses the kore-rpc-booster issue by declaring the rules for Bool combinators as simplifications (whose application is optional - simplifications are trusted to be sound regardless of their (priority) order, whereas function equations with overlapping cases or uncertain matches lead to aborting evaluation in kore-rpc-booster to avoid unsoundness).

Also removed some trailing whitespace from the domains.md file.

@rv-jenkins rv-jenkins changed the base branch from master to develop November 2, 2023 03:23
@jberthold jberthold force-pushed the jb/disambiguate-bool-combinator-rules branch from 88b593b to 2b93d97 Compare November 2, 2023 03:26
Comment on lines 1095 to 1097
Note that only `andThenBool` and `orElseBool` are short-circuiting. `andBool`
and `orBool` may be short-circuited in concrete backends, but in symbolic
and `orBool` may be short-circuited in concrete backends, but in symbolic
ackends, both arguments will be evaluated.
Copy link
Member Author

Choose a reason for hiding this comment

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

As a side note, this statement about shortcut evaluation is probably not correct, given we have rules/simplifications like rule _:Bool andBool false => false that focus only on the 2nd argument.

@jberthold
Copy link
Member Author

...not sure why but the build was re-triggered when I edited the PR description. The first build was green so this is presumably ready for review comments.

@jberthold jberthold marked this pull request as ready for review November 2, 2023 11:11
@jberthold
Copy link
Member Author

jberthold commented Nov 2, 2023

Comparison of timings for evm-semantics tests

image
Notable speed-up for booster execution on some of the proofs, no dramatic slowdown on any of them, kore-rpc timings unchanged.

Timings for foundry proofs (kontrol repo integration tests) unchanged

image
(EDIT: this close correspondence is suspicious, I re-ran the standard-K versions to confirm it)

@jberthold jberthold self-assigned this Nov 2, 2023
Comment on lines +1125 to +1128
rule true andBool B:Bool => B:Bool [simplification]
rule B:Bool andBool true => B:Bool [simplification]
rule false andBool _:Bool => false [simplification]
rule _:Bool andBool false => false [simplification]
Copy link
Member

Choose a reason for hiding this comment

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

Why do we mark them all as simplification rules? I guess this is so that we will always optimistically try them, allowing any of them to apply? My intuition would be to provide a set of complete rules for booleans (non simplification), then add simplification rules as well as needed.

So maybe we have a sepraate module with a set of complete and mutually exclusive rules for boolean (for concrete simplifications)?

rule true andBool B => B
rule false andBool _ => false
rule notBool true => false
rule notBool false => true
rule true orBool _ => true
rule false orBool B => B
....

Then have this separate module with all the rules as simplificatino rules.

Maybe there should also be a way for the user to declare that this set of rules are confluent, so that the booster can just assume that?

Copy link
Member Author

@jberthold jberthold Nov 2, 2023

Choose a reason for hiding this comment

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

That would be possible, too. I don' thave a full set of measurements for it but I tested the performance for a variant where all rules that focus on the 2nd argument were declared [simplification], leaving the other rules (the ones you quote above, focussing on the 1st arg) as they were.

OTOH all these rules become obsolete as soon as a backend with an implemented hook is used. Therefore I kept all rules together in one module and made them all [simplification] for homogenous appearance.
If the variant with both simplification rules and defining equations is desired, I can change the code.

jberthold added a commit that referenced this pull request Nov 5, 2023
This is a variant of #3786 which turns all equations that focus on the
2nd argument of a `Bool` combinator as `simplification`s. In doing this,
we retain a complete set of defining equations but avoid the problem
described below.

Equations are kept in groups by combinator, rather than splitting them
into defining and simplification equations in different modules.

-------------------
Rules like this pair
```
rule false andBool _:Bool => false
rule _:Bool andBool false => false
```
were previously in `BOOL-COMMON` and were said to demonstrate the
implemented semantics of the hooks.
As `kore-rpc-booster` does not have its own hooks, the rules now come
into effect themselves.
This causes issues because of the obvious overlap of rule matches
(consider subject term `false andBool false` which matches both rule
LHSs).
This PR addresses the `kore-rpc-booster` issue by declaring some of the
rules for `Bool` combinators as `simplification`s (whose application is
optional - simplifications are trusted to be sound regardless of their
(priority) order, whereas function equations with overlapping cases or
uncertain matches lead to aborting evaluation in `kore-rpc-booster` to
avoid unsoundness).

Also removed some trailing whitespace from the `domains.md` file.

---------

Co-authored-by: Bruce Collie <[email protected]>
@jberthold
Copy link
Member Author

Closed in favour of #3789

@jberthold jberthold closed this Nov 5, 2023
@jberthold jberthold deleted the jb/disambiguate-bool-combinator-rules branch November 5, 2023 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants