Skip to content

Conversation

@andreiburdusa
Copy link
Contributor


Fixes #1886

Reviewer checklist
  • Test coverage: stack test --coverage
  • Public API documentation: stack haddock

@andreiburdusa andreiburdusa marked this pull request as ready for review June 19, 2020 13:56
_intRight <- expectBuiltinInt eqKey _intRight
_intLeft == _intRight
& Bool.asPattern resultSort
& returnPattern
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no need to even consider the extra side-conditions in the concrete case.

(_ :< VariableF varLeft, _ :< VariableF varRight) ->
varLeft == varRight
& Bool.asPattern resultSort
& returnPattern
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not right: varLeft == varRight implies that varLeft ==Int varRight, but not the other way around! We cannot say anything when varLeft /= varRight.

Because variables are always defined, there is also no need to include the side conditions here. On the other hand, if we do include the stronger side conditions above, then we do not need to restrict to variables here; we can compare any two symbolic patterns.

concrete <|> symbolicReflexivity
where
mkCeilUnlessDefined termLike
| TermLike.isDefinedPattern termLike = Condition.topOf resultSort
Copy link
Contributor

Choose a reason for hiding this comment

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

We actually need a stronger condition here: the arguments must be functional. If the arguments could take multiple values, then we would have to return multiple values. Consider:

\or(1, 2) ==Int 1 = \or(true, false)


test_reflexivity_symbolic :: TestTree
test_reflexivity_symbolic =
testPropertyWithSolver (Text.unpack name) $ do
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an ordinary integration test, not a integration property test. We should use HUnit instead, to avoid running the test 100 times.

Please also add a unit (not integration) test to show that x ==Int y is inconclusive.

@andreiburdusa andreiburdusa requested a review from ttuegel June 22, 2020 15:32
Comment on lines 354 to 357
let (_ :< patternLeft) = Recursive.project _intLeft
(_ :< patternRight) = Recursive.project _intRight
in
if patternLeft == patternRight then
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to project the patterns here:

Suggested change
let (_ :< patternLeft) = Recursive.project _intLeft
(_ :< patternRight) = Recursive.project _intRight
in
if patternLeft == patternRight then
if _intLeft == _intRight then

& Bool.asPattern resultSort
& return

symbolicReflexivity =
Copy link
Contributor

Choose a reason for hiding this comment

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

Even though we add side conditions to make sure the inputs are defined, we still need to make sure that the inputs are function-like patterns:

Suggested change
symbolicReflexivity =
symbolicReflexivity =
Control.Monad.guard (TermLike.isFunctionPattern _intLeft)
-- Do not need to check _intRight because we only return a result
-- when _intLeft and _intRight are equal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, mkCeilUnlessDefined uses isFunctionalPattern. I forgot to change its name 😅 . Should I make it check only if the inputs are defined and use the guard you suggested for function-like check?

Comment on lines 339 to 344
mkCeilUnlessDefined termLike
| TermLike.isFunctionalPattern termLike = Condition.topOf resultSort
| otherwise =
Condition.fromPredicate (makeCeilPredicate resultSort termLike)
returnPattern = return . flip Pattern.andCondition conditions
conditions = foldMap mkCeilUnlessDefined arguments
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's move these closer to the definition of symbolicReflexivity because that is the only place they are used.

@andreiburdusa andreiburdusa requested a review from ttuegel June 24, 2020 13:51
@andreiburdusa andreiburdusa merged commit 4066d2c into runtimeverification:master Jun 24, 2020
@andreiburdusa andreiburdusa deleted the built-in-==Int branch June 24, 2020 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No built-in rule for symbolic ==Int

2 participants