Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 17 additions & 7 deletions kore/src/Kore/Step/Simplification/Iff.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module Kore.Step.Simplification.Iff (
simplifyEvaluated,
) where

import qualified Kore.Internal.MultiAnd as MultiAnd
import Kore.Internal.OrPattern (
OrPattern,
)
Expand All @@ -30,8 +31,15 @@ import qualified Kore.Internal.TermLike as TermLike (
import Kore.Rewriting.RewritingVariable (
RewritingVariableName,
)
import qualified Kore.Step.Simplification.And as And (
simplify,
)
import qualified Kore.Step.Simplification.Implies as Implies (
simplifyEvaluated,
)
import qualified Kore.Step.Simplification.Not as Not (
makeEvaluate,
notSimplifier,
simplifyEvaluated,
)
import Kore.Step.Simplification.Simplify
Expand Down Expand Up @@ -83,13 +91,15 @@ simplifyEvaluated
| OrPattern.isFalse first = Not.simplifyEvaluated sideCondition second
| OrPattern.isTrue second = return first
| OrPattern.isFalse second = Not.simplifyEvaluated sideCondition first
| otherwise =
return $ case (firstPatterns, secondPatterns) of
([firstP], [secondP]) -> makeEvaluate firstP secondP
_ ->
makeEvaluate
(OrPattern.toPattern first)
(OrPattern.toPattern second)
| otherwise = case (firstPatterns, secondPatterns) of
([firstP], [secondP]) -> return $ makeEvaluate firstP secondP
_ -> do
fwd <- Implies.simplifyEvaluated sideCondition first second
bwd <- Implies.simplifyEvaluated sideCondition second first
And.simplify
Not.notSimplifier
sideCondition
(MultiAnd.make [fwd, bwd])
where
firstPatterns = toList first
secondPatterns = toList second
Expand Down
2 changes: 1 addition & 1 deletion kore/test/Test/Kore/Step/Simplification/Integration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ test_simplificationIntegration =
)
[ [fromNot cfCeil, fromNot chCeil]
, [chCeil, cgCeil, cfCeil]
, [chCeil, cfCeil]
, [chCeil, cfCeil, fromNot cgCeil]
Copy link
Contributor

Choose a reason for hiding this comment

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

I made a truth table to check this change, and found that the old output is equivalent to the new output. After that, I found a clear way to show that. Consider the second and third clauses, we have:

old: ( \ceil(f) ∧ \ceil(g) ∧ \ceil(h) ) ∨ ( \ceil(f) ∧ \ceil(h) )

If we do some factoring, we find:

old: \ceil(f) ∧ \ceil(h) ∧ ( \ceil(g) ∨ \top )

Look at the last conjunct: \ceil(g) ∨ \top. This is just \top. In other words, this term completely subsumes the last two clauses:

old: \ceil(f) ∧ \ceil(h)

In the new output, we are going to do the same factoring trick:

new: ( \ceil(f) ∧ \ceil(g) ∧ \ceil(h) ) ∨ ( \ceil(f) ∧ \not \ceil(g) ∧ \ceil(h) )
new: \ceil(f) ∧ \ceil(h) ∧ ( \ceil(g) ∨ \not \ceil(g) )
new: \ceil(f) ∧ \ceil(h)

So, the output in either case is equivalent. The output changes because it isn't minimal, in the sense that we don't do this kind of simplification.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, this is really helpful!

]
cfCeil = makeCeilPredicate Mock.cf
cgCeil = makeCeilPredicate Mock.cg
Expand Down