Skip to content

Symbolic execution and search should apply rules correctly #2234

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

Merged
merged 51 commits into from
Nov 19, 2020

Conversation

ana-pantilie
Copy link
Contributor

@ana-pantilie ana-pantilie commented Nov 1, 2020

Fixes #2205

Needs #2231
Needs #2261


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

@ana-pantilie ana-pantilie changed the title Bug fix: --strategy all is ignored Symbolic execution and search should apply rules correctly Nov 10, 2020
@ana-pantilie ana-pantilie marked this pull request as ready for review November 17, 2020 14:46
@ana-pantilie ana-pantilie requested a review from ttuegel November 17, 2020 14:46
Comment on lines 350 to 351
[ ("any", Any)
, ("all", All)
Copy link
Contributor

Choose a reason for hiding this comment

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

Because this uses an enumeration type now, there is no reason to keep the String part of the tuple.

-> ([Rewrite] -> [Strategy (Prim Rewrite)])
-- ^ The strategy to use for execution; see examples in "Kore.Step.Step"
-> ExecutionMode
-- ^ The execution mode
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 this documentation is helpful. The reader can always jump to the documentation for ExecutionMode!

Suggested change
-- ^ The execution mode

data Prim rewrite = Simplify | Rewrite !rewrite
{- | The program's state during symbolic execution.
-}
data ProgramState a = Start !a | Rewritten !a | Remaining !a
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add documentation for each constructor?

data Prim
= Begin
| Simplify
| ApplyRewrites
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless this name is already taken, I suggest changing to a simple imperative verb to match the other constructors:

Suggested change
| ApplyRewrites
| Rewrite

Comment on lines 150 to 158
transitionRuleWorker All ApplyRewrites (Remaining patt) =
transitionAllRewrite patt
transitionRuleWorker All ApplyRewrites (Start patt) =
transitionAllRewrite patt
transitionRuleWorker Any ApplyRewrites (Remaining patt) =
transitionAnyRewrite patt
transitionRuleWorker Any ApplyRewrites (Start patt) =
transitionAnyRewrite patt
transitionRuleWorker _ ApplyRewrites state = pure state
Copy link
Contributor

Choose a reason for hiding this comment

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

We can reduce duplication with a simple helper function. Explicitly matching on all the ProgramState constructors makes the logic clearer and protects us if we ever add constructors to ProgramState.

Suggested change
transitionRuleWorker All ApplyRewrites (Remaining patt) =
transitionAllRewrite patt
transitionRuleWorker All ApplyRewrites (Start patt) =
transitionAllRewrite patt
transitionRuleWorker Any ApplyRewrites (Remaining patt) =
transitionAnyRewrite patt
transitionRuleWorker Any ApplyRewrites (Start patt) =
transitionAnyRewrite patt
transitionRuleWorker _ ApplyRewrites state = pure state
transitionRuleWorker mode ApplyRewrites (Remaining patt) =
transitionRewrite mode patt
transitionRuleWorker mode ApplyRewrites (Start patt) =
transitionRewrite mode patt
transitionRuleWorker _ ApplyRewrites state@(Rewritten patt) = pure state
transitionRewrite All = transitionAllRewrite
transitionRewrite Any = transitionAnyRewrite

@ana-pantilie ana-pantilie requested a review from ttuegel November 18, 2020 11:04
@ttuegel ttuegel merged commit 6ae3e32 into runtimeverification:master Nov 19, 2020
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.

--strategy all is ignored
3 participants