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
27 changes: 20 additions & 7 deletions kore/src/Kore/Step/Simplification/And.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ import Kore.Internal.TermLike
( And (..)
, pattern And_
, pattern App_
, pattern Builtin_
, pattern Equals_
, pattern Exists_
, pattern Forall_
, pattern Inj_
, pattern Mu_
, pattern Not_
, pattern Nu_
Expand Down Expand Up @@ -351,18 +353,29 @@ global definitions (axioms) apply. We are looking for a 'TermLike' of the form
\equals(f(...), C(...))
@

where @f@ is a function and @C@ is a constructor. @retractLocalFunction@ will
match an @\equals@ predicate with its arguments in either order, but the
function pattern is always returned first in the 'Pair'.
where @f@ is a function and @C@ is a constructor, sort injection or builtin.
@retractLocalFunction@ will match an @\equals@ predicate with its arguments
in either order, but the function pattern is always returned first in the
'Pair'.

-}
retractLocalFunction
:: TermLike variable
-> Maybe (Pair (TermLike variable))
retractLocalFunction (Equals_ _ _ term1@(App_ symbol1 _) term2@(App_ symbol2 _))
| isConstructor symbol1, isFunction symbol2 = Just (Pair term2 term1)
| isConstructor symbol2, isFunction symbol1 = Just (Pair term1 term2)
retractLocalFunction _ = Nothing
retractLocalFunction =
\case
Equals_ _ _ term1 term2 -> go term1 term2 <|> go term2 term1
_ -> Nothing
where
go term1@(App_ symbol1 _) term2
| isFunction symbol1 =
case term2 of
App_ symbol2 _
| isConstructor symbol2 -> Just (Pair term1 term2)
Inj_ _ -> Just (Pair term1 term2)
Builtin_ _ -> Just (Pair term1 term2)
_ -> Nothing
go _ _ = Nothing

applyAndIdempotenceAndFindContradictions
:: InternalVariable variable
Expand Down
50 changes: 25 additions & 25 deletions kore/test/Test/Kore/Step/Simplification/And.hs
Original file line number Diff line number Diff line change
Expand Up @@ -554,41 +554,41 @@ test_andSimplification =
assertEqual "" (MultiOr.make [expect]) actual
, testGroup "Local function evaluation" $
let f = Mock.f (mkElemVar Mock.x)
fInt = Mock.fInt (mkElemVar Mock.xInt)
defined = makeCeilPredicate_ f & Condition.fromPredicate
a = Mock.a
b = Mock.b
mkLocalDefn (Left t) = makeEqualsPredicate_ t f
mkLocalDefn (Right t) = makeEqualsPredicate_ f t
test name eitherC1 eitherC2 =
injA = Mock.sortInjection10 Mock.a
injB = Mock.sortInjection10 Mock.b
int2 = Mock.builtinInt 2
int3 = Mock.builtinInt 3
mkLocalDefn func (Left t) = makeEqualsPredicate_ t func
mkLocalDefn func (Right t) = makeEqualsPredicate_ func t
test name func eitherC1 eitherC2 =
testCase name $ do
let equals1 = mkLocalDefn eitherC1 & Condition.fromPredicate
equals2 = mkLocalDefn eitherC2 & Condition.fromPredicate
let equals1 = mkLocalDefn func eitherC1 & Condition.fromPredicate
equals2 = mkLocalDefn func eitherC2 & Condition.fromPredicate
pattern1 = Pattern.fromCondition_ (defined <> equals1)
pattern2 = Pattern.fromCondition_ (defined <> equals2)
actual <- evaluatePatterns pattern1 pattern2
assertBool "Expected \\bottom" $ isBottom actual
in
[ test "contradiction: f(x) = a ∧ f(x) = b" (Right a) (Right b)
, test "contradiction: a = f(x) ∧ f(x) = b" (Left a) (Right b)
, test "contradiction: a = f(x) ∧ b = f(x)" (Left a) (Left b)
, test "contradiction: f(x) = a ∧ b = f(x)" (Right a) (Left b)
[ -- Constructor at top
test "contradiction: f(x) = a ∧ f(x) = b" f (Right a) (Right b)
, test "contradiction: a = f(x) ∧ f(x) = b" f (Left a) (Right b)
, test "contradiction: a = f(x) ∧ b = f(x)" f (Left a) (Left b)
, test "contradiction: f(x) = a ∧ b = f(x)" f (Right a) (Left b)
-- Sort injection at top
, test "contradiction: f(x) = injA ∧ f(x) = injB" f (Right injA) (Right injB)
, test "contradiction: injA = f(x) ∧ f(x) = injB" f (Left injA) (Right injB)
, test "contradiction: injA = f(x) ∧ injB = f(x)" f (Left injA) (Left injB)
, test "contradiction: f(x) = injA ∧ injB = f(x)" f (Right injA) (Left injB)
-- Builtin at top
, test "contradiction: f(x) = 2 ∧ f(x) = 3" fInt (Right int2) (Right int3)
, test "contradiction: 2 = f(x) ∧ f(x) = 3" fInt (Left int2) (Right int3)
, test "contradiction: 2 = f(x) ∧ 3 = f(x)" fInt (Left int2) (Left int3)
, test "contradiction: f(x) = 2 ∧ 3 = f(x)" fInt (Right int2) (Left int3)
]
, testCase "Constructor equality" $ do
actual <-
evaluatePatterns
(makeEqualsPredicate_
Mock.c
Mock.a
& Condition.fromPredicate
& Pattern.fromCondition_
)
( makeEqualsPredicate_
Mock.b
Mock.c
& Condition.fromPredicate
& Pattern.fromCondition_
)
assertEqual "" (MultiOr.make []) actual
]
where
yExpanded = Conditional
Expand Down
6 changes: 0 additions & 6 deletions test/symbolic-ensures/1.strict.out.golden
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
#Equals
true
}
#And
{
true
#Equals
?X <=Int 3
}
#And
{
true
Expand Down