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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
09f8916
Add condition to Applied
geo2a Jun 24, 2024
254e877
Allow assuming unclear requires clauses
geo2a Jun 24, 2024
1ee240d
Draft remainder predicate computation and check
geo2a Jun 24, 2024
b67a97f
Reorganised doSteps function in performRewrite
goodlyrottenapple Jun 26, 2024
0d6092b
Format with fourmolu
invalid-email-address Jun 26, 2024
a5e8318
further tweaks to performRewrite
goodlyrottenapple Jun 27, 2024
770d65b
merge
goodlyrottenapple Jun 27, 2024
3a47065
implment isSat
goodlyrottenapple Jun 27, 2024
c5dd30b
actually return the branching condition as part of the rewritten patt…
goodlyrottenapple Jun 27, 2024
07189d7
fourmolu
goodlyrottenapple Jun 27, 2024
b0fd4e8
Merge branch 'master' into georgy/booster-remainders
goodlyrottenapple Jun 27, 2024
5f5e2de
merge master
goodlyrottenapple Jun 28, 2024
cee50e9
misc
goodlyrottenapple Jun 28, 2024
e384a97
Log rule remainder predicates
geo2a Jul 1, 2024
e70bdca
Continue with lower-priority rules if no rules applied group
geo2a Jul 1, 2024
ded261a
Merge remote-tracking branch 'origin/master' into georgy/booster-rema…
geo2a Jul 1, 2024
ac350fd
Fix KEVM script by calling the new Makefile target
geo2a Jul 1, 2024
775218c
Merge remote-tracking branch 'origin/master' into georgy/booster-rema…
geo2a Jul 2, 2024
cab49d7
Increment rewrite depth counter in the same way as before, add comments
geo2a Jul 2, 2024
b4d3a99
Log uncovered remainder
geo2a Jul 2, 2024
fafaf13
Increment depth counter when pruning branch in post-simpl
geo2a Jul 7, 2024
5e03d41
Add rule predicates
geo2a Jul 7, 2024
391b47c
Apply substitution to the rule predicate
geo2a Jul 7, 2024
ad42fbd
Return rule substitution
geo2a Jul 7, 2024
7ee244d
Make rule predicate construction more explicit
geo2a Jul 7, 2024
6b7bb6a
Do not return rule substitution for now
geo2a Jul 7, 2024
bf200c3
Use termSort when externalising rule predicate
geo2a Jul 7, 2024
d6e2043
Ignore rule predicate and substitution in unit tests
geo2a Jul 8, 2024
f65cd34
Log rule priorities when processing groups
geo2a Jul 8, 2024
2ae3693
Remove directory name assumption in `kore-rpc-client`
geo2a Jul 8, 2024
119476a
Return False when the remainder is trivial
geo2a Jul 8, 2024
221083e
Check remainder for literal false when there's not SMT solver
geo2a Jul 8, 2024
00898f4
Add test-remainder-predicates integration test
geo2a Jul 8, 2024
df0047f
Oops, remove awkward print
geo2a Jul 8, 2024
555728d
Add comment
geo2a Jul 8, 2024
2d0b0fd
Bring back the abort message on unclear rewrite rule match
geo2a Jul 9, 2024
554d701
Refactor match remainder into a function to deduplicate code
geo2a Jul 10, 2024
d8e712f
Factor-out `mkRulePredicate`
geo2a Jul 10, 2024
b709fb8
Ignore rule substitution when comparing branching responses
geo2a Jul 10, 2024
c3a88f2
Merge remote-tracking branch 'origin/master' into georgy/booster-rema…
geo2a Jul 10, 2024
55c9dcf
Do not send trivial remainders to SMT
geo2a Jul 10, 2024
e5f674c
Remove trivial rule predicates from tests
geo2a Jul 10, 2024
f227ad7
Rework test-use-path-condition-in-equations
geo2a Jul 10, 2024
3a2b13f
Update test-non-linear-int-requires
geo2a Jul 10, 2024
c5edee4
Merge remote-tracking branch 'origin/master' into georgy/booster-rema…
geo2a Jul 12, 2024
6d730a5
Only emit proxy branch-eliminating rewrite trace when asked for
geo2a Jul 12, 2024
4e1524e
Update output of test-3934-smt: slight change in rule predicate
geo2a Jul 12, 2024
4d12b6a
Merge remote-tracking branch 'origin/master' into georgy/booster-rema…
geo2a Jul 12, 2024
18ca384
Do not ignore rule predicates in unit-tests, only rule subst
geo2a Jul 12, 2024
6ef5cd3
Merge remote-tracking branch 'origin/master' into georgy/booster-rema…
geo2a Jul 15, 2024
8d1c69e
Merge remote-tracking branch 'origin/master' into georgy/booster-rema…
geo2a Jul 16, 2024
c072d46
Merge remote-tracking branch 'origin/master' into georgy/booster-rema…
geo2a Jul 18, 2024
979606a
Merge remote-tracking branch 'origin/master' into georgy/booster-rema…
geo2a Jul 19, 2024
9c82e4e
Merge remote-tracking branch 'origin/master' into georgy/booster-rema…
geo2a Jul 23, 2024
8c943d3
Make default fallback reasons more explicit, fix comment
geo2a Jul 24, 2024
13b4b9e
Refactor result printing messages
geo2a Jul 24, 2024
3b179b2
Add a new handler for Booster Branching in Proxy.hs
geo2a Jul 24, 2024
cbfa774
Update `kore-rpc-client` to use `tar-0.6.3` (#3996)
geo2a Jul 25, 2024
01c344c
Fixes to simplification diff, request statistics, process-logs (#3992)
jberthold Jul 25, 2024
b7590bc
TEMP comment-out Kore fallback
geo2a Jul 26, 2024
f52088d
Merge remote-tracking branch 'origin/master' into georgy/booster-rema…
geo2a Jul 29, 2024
7bf75ea
Merge remote-tracking branch 'origin/master' into georgy/booster-rema…
geo2a Jul 29, 2024
7bdf0a7
Allow matching functions when rewriting
geo2a Jul 30, 2024
bf05ef2
Allow matching empty sets
geo2a Jul 30, 2024
70817d4
Add dummy unit test for set matching
geo2a Jul 30, 2024
a580cfc
Merge remote-tracking branch 'origin/master' into georgy/booster-rema…
geo2a Aug 6, 2024
4f955f2
Make unit-tests typecheck
geo2a Aug 6, 2024
342ddd9
Revert "Allow matching functions when rewriting"
geo2a Aug 7, 2024
3d56118
Eliminate redundant pattern matches
geo2a Aug 7, 2024
188075d
hlint
geo2a Aug 7, 2024
1c48bc3
Factor-out checkRequires
geo2a Sep 23, 2024
1ad0dd0
Factor-out checkEnsures
geo2a Sep 23, 2024
e675f3c
Refactor applyEquation
geo2a Sep 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 32 additions & 16 deletions booster/library/Booster/JsonRpc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import Booster.Definition.Base qualified as Definition (RewriteRule (..))
import Booster.LLVM as LLVM (API)
import Booster.Log
import Booster.Pattern.ApplyEquations qualified as ApplyEquations
import Booster.Pattern.Base (Pattern (..), Sort (SortApp), Term, Variable)
import Booster.Pattern.Base (Pattern (..), Predicate (..), Sort (SortApp), Term, Variable)
import Booster.Pattern.Base qualified as Pattern
import Booster.Pattern.Bool (pattern TrueBool)
import Booster.Pattern.Match (FailReason (..), MatchResult (..), MatchType (..), matchTerms)
Expand Down Expand Up @@ -609,11 +609,14 @@ execResponse req (d, traces, rr) originalSubstitution unsupported = case rr of
{ reason = RpcTypes.Branching
, depth
, logs
, state = toExecState p originalSubstitution unsupported Nothing
, state = toExecState p originalSubstitution unsupported Nothing Nothing Nothing
, nextStates =
Just $
map (\(_, muid, p') -> toExecState p' originalSubstitution unsupported (Just muid)) $
toList nexts
-- FIXME return _ruleSubst in the response, removing '#'s from the variable names to make pyk happy
Just
$ map
( \(_, muid, p', mrulePred, _ruleSubst) -> toExecState p' originalSubstitution unsupported (Just muid) mrulePred Nothing
)
$ toList nexts
, rule = Nothing
, unknownPredicate = Nothing
}
Expand All @@ -624,7 +627,7 @@ execResponse req (d, traces, rr) originalSubstitution unsupported = case rr of
{ reason = RpcTypes.Stuck
, depth
, logs
, state = toExecState p originalSubstitution unsupported Nothing
, state = toExecState p originalSubstitution unsupported Nothing Nothing Nothing
, nextStates = Nothing
, rule = Nothing
, unknownPredicate = Nothing
Expand All @@ -636,7 +639,7 @@ execResponse req (d, traces, rr) originalSubstitution unsupported = case rr of
{ reason = RpcTypes.Vacuous
, depth
, logs
, state = toExecState p originalSubstitution unsupported Nothing
, state = toExecState p originalSubstitution unsupported Nothing Nothing Nothing
, nextStates = Nothing
, rule = Nothing
, unknownPredicate = Nothing
Expand All @@ -648,8 +651,8 @@ execResponse req (d, traces, rr) originalSubstitution unsupported = case rr of
{ reason = RpcTypes.CutPointRule
, depth
, logs
, state = toExecState p originalSubstitution unsupported Nothing
, nextStates = Just [toExecState next originalSubstitution unsupported Nothing]
, state = toExecState p originalSubstitution unsupported Nothing Nothing Nothing
, nextStates = Just [toExecState next originalSubstitution unsupported Nothing Nothing Nothing]
, rule = Just lbl
, unknownPredicate = Nothing
}
Expand All @@ -660,7 +663,7 @@ execResponse req (d, traces, rr) originalSubstitution unsupported = case rr of
{ reason = RpcTypes.TerminalRule
, depth
, logs
, state = toExecState p originalSubstitution unsupported Nothing
, state = toExecState p originalSubstitution unsupported Nothing Nothing Nothing
, nextStates = Nothing
, rule = Just lbl
, unknownPredicate = Nothing
Expand All @@ -672,7 +675,7 @@ execResponse req (d, traces, rr) originalSubstitution unsupported = case rr of
{ reason = RpcTypes.DepthBound
, depth
, logs
, state = toExecState p originalSubstitution unsupported Nothing
, state = toExecState p originalSubstitution unsupported Nothing Nothing Nothing
, nextStates = Nothing
, rule = Nothing
, unknownPredicate = Nothing
Expand All @@ -689,7 +692,7 @@ execResponse req (d, traces, rr) originalSubstitution unsupported = case rr of
(logSuccessfulRewrites, logFailedRewrites)
(RewriteStepFailed failure)
in logs <|> abortRewriteLog
, state = toExecState p originalSubstitution unsupported Nothing
, state = toExecState p originalSubstitution unsupported Nothing Nothing Nothing
, nextStates = Nothing
, rule = Nothing
, unknownPredicate = Nothing
Expand All @@ -712,19 +715,32 @@ execResponse req (d, traces, rr) originalSubstitution unsupported = case rr of
xs@(_ : _) -> Just xs

toExecState ::
Pattern -> Map Variable Term -> [Syntax.KorePattern] -> Maybe UniqueId -> RpcTypes.ExecuteState
toExecState pat sub unsupported muid =
Pattern ->
Map Variable Term ->
[Syntax.KorePattern] ->
Maybe UniqueId ->
Maybe Predicate ->
Maybe (Map Variable Term) ->
RpcTypes.ExecuteState
toExecState pat sub unsupported muid mrulePredicate mruleSubst =
RpcTypes.ExecuteState
{ term = addHeader t
, predicate = addHeader <$> addUnsupported p
, substitution = addHeader <$> s
, ruleSubstitution = Nothing
, rulePredicate = Nothing
, ruleSubstitution = addHeader <$> mruleSubstExt
, rulePredicate = addHeader <$> mrulePredExt
, ruleId = getUniqueId <$> muid
}
where
mrulePredExt = externalisePredicate termSort <$> mrulePredicate
mruleSubstExt =
Syntax.KJAnd predicateSort
. map (uncurry $ externaliseSubstitution predicateSort)
. Map.toList
<$> mruleSubst
(t, p, s) = externalisePattern pat sub
termSort = externaliseSort $ sortOfPattern pat
predicateSort = externaliseSort Pattern.SortBool
allUnsupported = Syntax.KJAnd termSort unsupported
addUnsupported
| null unsupported = id
Expand Down
6 changes: 5 additions & 1 deletion booster/library/Booster/JsonRpc/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,19 @@ diffJson file1 file2 =
-- \| Branching execution results are considered equivalent if
-- \* they both have two branches
-- \* branches are syntactically the same, but may be in different order
-- \* the "rule-substitution" field is ignored
sameModuloBranchOrder :: ExecuteResult -> ExecuteResult -> Bool
sameModuloBranchOrder res1 res2
| res1.reason == Branching && res1.reason == res2.reason =
case (res1.nextStates, res2.nextStates) of
case (map ignoreRuleSubstituiton <$> res1.nextStates, map ignoreRuleSubstituiton <$> res2.nextStates) of
(Just xs, Just ys) ->
length xs == 2 && length ys == 2 && (xs == ys || xs == reverse ys)
_ -> False
| otherwise = False

ignoreRuleSubstituiton :: ExecuteState -> ExecuteState
ignoreRuleSubstituiton state = state{ruleSubstitution = Nothing}

data DiffResult
= Identical KoreRpcType
| DifferentType KoreRpcType KoreRpcType
Expand Down
Loading