-
Notifications
You must be signed in to change notification settings - Fork 42
#3143 rewrite graph traversal + output unexplored leaves #3168
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
#3143 rewrite graph traversal + output unexplored leaves #3168
Conversation
|
|
|
|
|
|
New traversal models required functionality in data types rather than using exceptions and monad stack layers to add functionality. The `graphTraversal` function operates with a list of "steps" (sequences of "instructions") that take a configuration to a result containing new configurations. The traversal is parameterised with a specific transition function `([Step instr],config) -> m (TransitionResult ([Step instr],config))` which interprets step results. `TransitionResult` can indicate to continue with one (`Continuing`) or more (`Branch`) new configurations, or that the configuration is final, stuck, or should be stopped. One reason to stop is when the list of steps runs empty, other reasons could be to stop execuction on the application of certain rules. The transition function can be constructed from one that operates on the primitive instructions, together with an interpretation function that differs depending on the use case (proving or executing).
466f594 to
1662e72
Compare
|
ana-pantilie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach is definitely friendlier than the old one, but I think it's still a bit hard to understand just by reading the code, so my suggestions currently concern readability.
I also noticed that allocation has decreased a bit. Should we expect some performance improvements as well? That would be amazing. 😁
| import Kore.Simplify.Data (Simplifier) | ||
| import Prelude.Kore | ||
| import Pretty | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this module would benefit from some extra documentation. My first thought was, how do TransitionResult, StepResult and TraversalResult all relate to eachother?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added documentation that describes all these types together, in a haddock comment on graphTraversal. Is this what you had in mind?
| -- execution is not a generic tree, but a cofree comonad with exactly the | ||
| -- branching structure described by the strategy algebra. | ||
| data Strategy prim where | ||
| -- The recursive arguments of these constructors are /intentionally/ lazy to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably out of scope for this PR, but we should probably keep in mind that we'd like to get rid of this type in the near future. Maybe a subsequent PR could take care of that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this type (and maybe even the whole module Strategy) is on the list of things to remove. I would think we lift everything worth keeping into the new GraphTraversal module.
Currently the Prove module still uses Strategy for the single-step function, and the repl uses the computation graph directly. Removing this and consolidating the parts we need from Strategy into GraphTraversal would be follow-up work in a new ticket and PR.
The new version is a bit faster, yes. My experiment PR had some KEVM timing comparisons - around 3% faster overall, most of it probably because of using |
Command > nix run .#update-cabal-ghc9
| "flake-utils_2": { | ||
| "locked": { | ||
| "lastModified": 1642700792, | ||
| "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", | ||
| "owner": "numtide", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes here were auto-generated from running command nix run .#update-cabal-ghc9 (as instructed by @goodlyrottenapple )
|
|
ana-pantilie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🎉
…traversal-output-unexplored-leaves
|
Related to #3119
Part of #3143
Scope:
Rewrite of graph traversal used by Kore.Exec and Kore.Reachability.Prove
New traversal models required functionality in data types rather than using exceptions and monad stack layers to add functionality.
The
graphTraversalfunction operates with a list of "steps" (sequences of "instructions") that take a configuration to a result containing new configurations.The traversal is parameterised with a specific transition function
([Step instr],config) -> m (TransitionResult ([Step instr],config))which interprets step results.
TransitionResultcan indicate to continue with one (Continuing) or more (Branch) new configurations, or that the configuration is final, stuck, or should be stopped.One reason to stop is when the list of steps runs empty, other reasons could be to stop execuction on the application of certain rules.
The transition function can be constructed from one that operates on the primitive instructions, together with an interpretation function that differs depending on the use case (proving or executing).
Estimate:
Review checklist
The author performs the actions on the checklist. The reviewer evaluates the work and checks the boxes as they are completed.