-
Notifications
You must be signed in to change notification settings - Fork 44
Implies endpoint in booster #3846
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
Changes from all commits
b33755c
0a40b69
f4fcc3b
b45ffa4
908544c
e10e47f
2eefa9e
fa0d73b
6be8498
e5b55ba
a5f740c
e7ac98a
5154be2
4d7a127
b1408eb
9c21c9c
bf0ea9f
d6666b7
bd01cae
40c0488
9bef22d
7ef58ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ module Booster.Pattern.ApplyEquations ( | |
simplifyConstraint, | ||
simplifyConstraints, | ||
SimplifierCache, | ||
evaluateConstraints, | ||
) where | ||
|
||
import Control.Applicative (Alternative (..)) | ||
|
@@ -568,7 +569,7 @@ evaluatePattern doTracing def mLlvmLibrary smtSolver cache = | |
|
||
-- version for internal nested evaluation | ||
evaluatePattern' :: | ||
MonadLoggerIO io => | ||
LoggerMIO io => | ||
Pattern -> | ||
EquationT io Pattern | ||
evaluatePattern' pat@Pattern{term, constraints, ceilConditions} = withPatternContext pat $ do | ||
|
@@ -580,14 +581,38 @@ evaluatePattern' pat@Pattern{term, constraints, ceilConditions} = withPatternCon | |
-- this may yield additional new constraints, left unevaluated | ||
evaluatedConstraints <- predicates <$> getState | ||
pure Pattern{constraints = evaluatedConstraints, term = newTerm, ceilConditions} | ||
where | ||
-- evaluate the given predicate assuming all others | ||
simplifyAssumedPredicate p = withContext "constraint" $ do | ||
allPs <- predicates <$> getState | ||
let otherPs = Set.delete p allPs | ||
eqState $ modify $ \s -> s{predicates = otherPs} | ||
newP <- simplifyConstraint' True $ coerce p | ||
pushConstraints $ Set.singleton $ coerce newP | ||
|
||
-- evaluate the given predicate assuming all others | ||
simplifyAssumedPredicate :: LoggerMIO io => Predicate -> EquationT io () | ||
simplifyAssumedPredicate p = do | ||
allPs <- predicates <$> getState | ||
let otherPs = Set.delete p allPs | ||
eqState $ modify $ \s -> s{predicates = otherPs} | ||
newP <- simplifyConstraint' True $ coerce p | ||
pushConstraints $ Set.singleton $ coerce newP | ||
|
||
evaluateConstraints :: | ||
LoggerMIO io => | ||
Flag "CollectEquationTraces" -> | ||
KoreDefinition -> | ||
Maybe LLVM.API -> | ||
Maybe SMT.SMTContext -> | ||
SimplifierCache -> | ||
Set Predicate -> | ||
io (Either EquationFailure (Set Predicate), SimplifierCache) | ||
evaluateConstraints doTracing def mLlvmLibrary smtSolver cache = | ||
runEquationT doTracing def mLlvmLibrary smtSolver cache . evaluateConstraints' | ||
|
||
evaluateConstraints' :: | ||
LoggerMIO io => | ||
Set Predicate -> | ||
EquationT io (Set Predicate) | ||
evaluateConstraints' constraints = do | ||
pushConstraints constraints | ||
-- evaluate all existing constraints, once | ||
traverse_ simplifyAssumedPredicate . predicates =<< getState | ||
-- this may yield additional new constraints, left unevaluated | ||
predicates <$> getState | ||
Comment on lines
+610
to
+615
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrt. the comment above in |
||
|
||
---------------------------------------- | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The legacy backend would first simplify both patterns and return the simplified implication.
Not sure whether we would want to keep that behaviour (did it matter in the tests?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess this would matter if e.g. the antecedent goes to #bottom? i guess here i am assuming things are defined and the constraints don't contradict each other