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

Explore the remainder branch when Booster is uncertain about rewrite rule conditions #3960

Closed
wants to merge 73 commits into from

Conversation

geo2a
Copy link
Collaborator

@geo2a geo2a commented Jun 24, 2024

Part of #3956

@geo2a geo2a force-pushed the georgy/booster-remainders branch from 9d065d9 to 391b47c Compare July 7, 2024 14:33
@geo2a geo2a force-pushed the georgy/booster-remainders branch from 71ba327 to ad42fbd Compare July 7, 2024 14:55
@geo2a
Copy link
Collaborator Author

geo2a commented Jul 30, 2024

KEVM performance at 7bf75ea:

| Test                                                                    | georgy-booster-remainders time | master-3b90f2b79 time | (georgy-booster-remainders/master-3b90f2b79) time
|-------------------------------------------------------------------------|--------------------------------|-----------------------|---------------------------------------------------
| mcd/flopper-dent-guy-same-pass-rough-spec.k                             | 923.28                         | 971.42                | 0.9504436803854152
| mcd/end-subuu-pass-spec.k                                               | 58.38                          | 61.04                 | 0.956422018348624
| mcd/flopper-dent-guy-diff-tic-not-0-pass-rough-spec.k                   | 1012.77                        | 1056.91               | 0.9582367467428635
| kontrol/test-arithmetictest-test_wdiv_rounding-uint256-uint256-0-spec.k | 57.41                          | 59.82                 | 0.95971247074557
| mcd/flopper-tick-pass-rough-spec.k                                      | 217.44                         | 225.81                | 0.9629334396173774
| erc20/hkg/transferFrom-success-2-spec.k                                 | 60.72                          | 58.62                 | 1.0358239508700102
| kontrol/test-allowchangestest-testfailallowchangestostorage-0-spec.k    | 77.34                          | 74.53                 | 1.0377029384140615
| erc20/ds/transferFrom-failure-1-c-spec.k                                | 118.03                         | 113.72                | 1.0379001055223356
| kontrol/test-allowchangestest-testallow_fail-0-spec.k                   | 54.75                          | 52.66                 | 1.0396885681731864
| kontrol/test-emitcontracttest-testexpectemitdonotcheckdata-0-spec.k     | 53.58                          | 51.44                 | 1.041601866251944
| erc20/hkg/transferFrom-failure-1-spec.k                                 | 94.08                          | 89.88                 | 1.046728971962617
| mcd/end-cash-pass-rough-spec.k                                          | 229.3                          | 218.66                | 1.0486600201225649
| erc20/ds/transferFrom-failure-1-b-spec.k                                | 151.48                         | 144.06                | 1.0515063168124392
| erc20/ds/transfer-failure-1-a-spec.k                                    | 75.35                          | 71.45                 | 1.0545836249125262
| benchmarks/ecrecoverloop00-sig1-invalid-spec.k                          | 118.31                         | 109.35                | 1.0819387288523092
| TOTAL                                                                   | 3302.22                        | 3359.3699999999994    | 0.9829878816563821

@geo2a geo2a force-pushed the georgy/booster-remainders branch from fcc8ed0 to a580cfc Compare August 6, 2024 15:29
geo2a added a commit that referenced this pull request Sep 25, 2024
geo2a added a commit that referenced this pull request Oct 7, 2024
geo2a added a commit that referenced this pull request Oct 15, 2024
geo2a added a commit that referenced this pull request Oct 15, 2024
geo2a added a commit that referenced this pull request Oct 17, 2024
geo2a added a commit that referenced this pull request Oct 22, 2024
geo2a added a commit that referenced this pull request Oct 23, 2024
geo2a added a commit that referenced this pull request Oct 25, 2024
@geo2a
Copy link
Collaborator Author

geo2a commented Oct 28, 2024

Closed in favor of #4058

@geo2a geo2a closed this Oct 28, 2024
geo2a added a commit that referenced this pull request Oct 29, 2024
Part of #3956
Partially subsumes
#3960

This PR makes the rewrite rule application algorithm of Booster more
powerful by allowing branching on *complete conditions*.

The rewriting algorithm is modified:
- when checking the `requires` clause of a rule, we compute the
remainder condition `RULE_REM` of that attempted, which is the
semantically-checked subset of the required conjuncts `P` which
*unclear* after checking its entailment form the pattern's constrains
`PC`, meaning that (PC /\ P, PC /\ not P) is (SAT, SAT) or any of the
two queries were UNKNOWN
- if that remainder is not empty, we return it's *negation* together
with the result
- when we are finished attempting a *priority group* of rules, we
collect the negated remainder conditions `not RULE_REM_i` and conjunct
them. This the groups remainder condition `GROUP_REM == not RULE_REM_1
/\ not RULE_REM_2 /\ ... /\ not RULE_REM_n`
- At that point, we need to check `GROUP_REM` for satisfiablity.
- **If the `GROUP_REM` condition is UNSAT, it means that this group of
rules is *complete***, meaning that no other rule can possibly apply,
and we do not need to even attempt applying rules of lower priority.
This behaviour is the **primary contribution of this PR**.
- Otherwise, if it is SAT or solver said UNKNOWN, it means that this
group of rules is not complete, i.e. it does not cover the whole space
of logical possibility, and we need to construct a remainder
configuration, and continue attempting to apply other rules to it. If no
rules remain, it means that we are stuck and the semantics is
incomplete. This PR does not implement the process of descending into
the remainder branch. **Booster with this PR will abort on a SAT
remainder**.

This behaviour is active by default in `booster-dev` and can be enabled
in `kore-rpc-booster` with the flag `--fallback-on Aborted,Stuck` (the
default is `Aborted,Stuck,Branching`). Note that with the default
reasons, the behaviour of `kore-rpc-booster` is functionally the same,
but operationally slightly different: In `Proxy.hs`, Booster may not
return `Branching`, and the fallback logic will confirm that Kore
returns `Branching` as well, flagging any differences in the `[proxy]`
logs (see
[Proxy.hs#L391](https://github.com/runtimeverification/haskell-backend/blob/3956-booster-rewrite-rule-remainders/booster/tools/booster/Proxy.hs#L391)).

TODO: we need a better flag to enabled branching in Booster, as giving a
`--fallback-on Aborted,Stuck` is really non-intuitive.

Note:
a naive algorithm to compute the remainder conditions would be: after
applying a group of rules, take their substituted requires clauses,
disjunct and negate. However, this yields a non-minimal predicate that
was not simplified and syntactically filtered, potentially making it
harder for the SMT solver to solve. The algorithm described above and
implemented in this PR re-uses the indeterminate results obtained while
applying individual rules and simplifying/checking their individual
requires clauses. This logic has been originally proposed by Sam in
#3960.

See
[remainder-predicates.k](https://github.com/runtimeverification/haskell-backend/blob/3956-booster-rewrite-rule-remainders/booster/test/rpc-integration/resources/remainder-predicates.k)
and
[test-remainder-predicates](https://github.com/runtimeverification/haskell-backend/blob/3956-booster-rewrite-rule-remainders/booster/test/rpc-integration/test-remainder-predicates)
for a series of integrations tests that cover the behaviour of
`booster-dev` and `kore-rpc-booster`.
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