-
Notifications
You must be signed in to change notification settings - Fork 44
Simplify side conditions #2393
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
Simplify side conditions #2393
Conversation
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.
For a test of the Pattern
simplifier, I recommend simplifying something with a side condition that can be evaluated by function rules. For example, a ∧ (f(a) = b ∧ g(a) = g(b))
where the simplifier knows a function rule that says f(a) = b requires g(a) = g(b)
.
worker (pred' : rest) = do | ||
sideCondition <- State.get | ||
let otherConds = sideCondition <> from (MultiAnd.make rest) | ||
result <- | ||
simplifyCondition otherConds (Condition.fromPredicate pred') | ||
& lift | ||
State.put (SideCondition.andCondition sideCondition result) | ||
worker rest |
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.
Let me make sure I understand this correctly: The SideCondition
comprised of all simplified Predicate
s is held in the State
. At each step, we combine that with the SideCondition
from all (other) un-simplified Predicate
s, and use the combination to simplify the current Predicate
. Then we update the stored SideCondition
. Is that right?
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.
That's right.
To debug the performance regression, you can try the Kore-level profiler with speedscope: https://github.com/kframework/kore/wiki/Profiling#kore-profiling |
This comment has been minimized.
This comment has been minimized.
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.
Please add some documentation for the new functions, even if it is repetitive.
I also thought about how we could name the isSimplified_
family of functions to call attention to their differences:
isSimplified
(that has a side condition input) stays the same.isFullySimplified
becomesisSimplifiedAnyCondition
.isSimplifiedIgnoreCondition
becomesisSimplifiedSomeCondition
.
We don't have to do that; let me know what you think.
@@ -97,6 +100,10 @@ isSimplified | |||
:: SideCondition.Representation -> PredicatePattern variable -> Bool | |||
isSimplified sideCondition = Simplified.isSimplified sideCondition . simplifiedAttribute | |||
|
|||
isSimplifiedIgnoreCondition |
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.
Please add documentation similar to Kore.Attribute.Pattern.isSimplifiedIgnoreCondition
.
kore/src/Kore/Attribute/Pattern.hs
Outdated
@@ -156,6 +159,13 @@ isSimplified sideCondition patt@Pattern {simplified} = | |||
assertSimplifiedConsistency patt | |||
$ Simplified.isSimplified sideCondition simplified | |||
|
|||
isSimplifiedIgnoreCondition |
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.
Please add documentation similar to Kore.Attribute.Pattern.Simplified.isSimplifiedIgnoreCondition
.
kore/src/Kore/Internal/Predicate.hs
Outdated
@@ -914,6 +916,9 @@ simplifiedAttribute = Attribute.simplifiedAttribute . extractAttributes | |||
isSimplified :: SideCondition.Representation -> Predicate variable -> Bool | |||
isSimplified condition = Attribute.isSimplified condition . extractAttributes | |||
|
|||
isSimplifiedIgnoreCondition :: Predicate variable -> Bool |
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.
Please add documentation similar to Kore.Attribute.Pattern.Simplified.isSimplifiedIgnoreCondition
.
@@ -493,6 +494,11 @@ isSimplified _ (Substitution _) = False | |||
isSimplified sideCondition (NormalizedSubstitution normalized) = | |||
all (TermLike.isSimplified sideCondition) normalized | |||
|
|||
isSimplifiedIgnoreCondition :: Substitution variable -> Bool |
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.
Please add documentation similar to Kore.Attribute.Pattern.Simplified.isSimplifiedIgnoreCondition
.
kore/src/Kore/Internal/TermLike.hs
Outdated
@@ -449,6 +450,10 @@ isSimplified :: SideCondition.Representation -> TermLike variable -> Bool | |||
isSimplified sideCondition = | |||
Attribute.isSimplified sideCondition . extractAttributes | |||
|
|||
isSimplifiedIgnoreCondition :: TermLike variable -> Bool |
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.
Please add documentation.
Co-authored-by: Thomas Tuegel <[email protected]>
Fixes #1416
If the side condition contains multiple conditions, these changes will allow each condition to be simplified one time under the assumption that the others are true.
This PR also removes all the cases where we simplify the side condition with itself.
Review checklist
The author performs the actions on the checklist. The reviewer evaluates the work and checks the boxes as they are completed.