Skip to content

Commit 1d245bc

Browse files
authored
Remove Defined markers in simplifyConjunctionByAssumption (#2372)
1 parent bedb3ca commit 1d245bc

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

kore/src/Kore/Step/Simplification/Condition.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@ simplifyConjunctionByAssumption (toList -> andPredicates) =
278278
HashMap.insert predicate makeTruePredicate
279279
assumeEqualTerms =
280280
case predicate of
281-
PredicateEquals t1 t2 ->
281+
PredicateEquals
282+
(TermLike.unDefined -> t1)
283+
(TermLike.unDefined -> t2)
284+
->
282285
case retractLocalFunction (mkEquals_ t1 t2) of
283286
Just (Pair t1' t2') ->
284287
Lens.over (field @"termLikeMap") $
@@ -342,7 +345,7 @@ simplifyConjunctionByAssumption (toList -> andPredicates) =
342345
:: HashMap (TermLike variable) (TermLike variable)
343346
-> TermLike variable
344347
-> Changed (TermLike variable)
345-
applyAssumptionsWorkerTerm assumptions original
348+
applyAssumptionsWorkerTerm assumptions (TermLike.unDefined -> original)
346349
| Just result <- HashMap.lookup original assumptions = Changed result
347350

348351
| HashMap.null assumptions' = Unchanged original

kore/test/Test/Kore/Step/Simplification/Condition.hs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,13 @@ test_simplify_local_functions =
7676
, test "contradiction: \"one\" = f(x) ∧ f(x) = \"two\"" fString (Left strOne) (Right strTwo)
7777
, test "contradiction: \"one\" = f(x) ∧ \"two\" = f(x)" fString (Left strOne) (Left strTwo)
7878
, test "contradiction: f(x) = \"one\"\"two\" = f(x)" fString (Right strOne) (Left strTwo)
79+
-- Ignore Defined marker
80+
, testDefined "contradiction: f(g(x)) = a ∧ f(g(x)) = b" (Right fg) (Right a) (Right b)
81+
, testDefined "contradiction: f(g(x)) = a ∧ f(g(x)) = b" (Left fg) (Right a) (Right b)
7982
]
8083
where
8184
f = Mock.f (mkElemVar Mock.x)
85+
fg = Mock.f (Mock.g (mkElemVar Mock.x))
8286
fInt = Mock.fInt (mkElemVar Mock.xInt)
8387
fBool = Mock.fBool (mkElemVar Mock.xBool)
8488
fString = Mock.fString (mkElemVar Mock.xString)
@@ -102,6 +106,11 @@ test_simplify_local_functions =
102106
mkLocalDefn func (Left t) = makeEqualsPredicate t func
103107
mkLocalDefn func (Right t) = makeEqualsPredicate func t
104108

109+
applyDefined1 (Left func) = mkDefined func
110+
applyDefined1 (Right func) = func
111+
applyDefined2 (Left func) = func
112+
applyDefined2 (Right func) = mkDefined func
113+
105114
test name func eitherC1 eitherC2 =
106115
testCase name $ do
107116
let equals1 = mkLocalDefn func eitherC1 & Condition.fromPredicate
@@ -110,6 +119,18 @@ test_simplify_local_functions =
110119
actual <- simplify condition
111120
assertBool "Expected \\bottom" $ isBottom actual
112121

122+
testDefined name eitherFunc eitherC1 eitherC2 =
123+
testCase name $ do
124+
let equals1 =
125+
mkLocalDefn (applyDefined1 eitherFunc) eitherC1
126+
& Condition.fromPredicate
127+
equals2 =
128+
mkLocalDefn (applyDefined2 eitherFunc) eitherC2
129+
& Condition.fromPredicate
130+
condition = equals1 <> equals2
131+
actual <- simplify condition
132+
assertBool "Expected \\bottom" $ isBottom actual
133+
113134
test_predicateSimplification :: [TestTree]
114135
test_predicateSimplification =
115136
[ testCase "Identity for top and bottom" $ do

0 commit comments

Comments
 (0)