Skip to content
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

Simplify tactics state structure #1449

Merged
merged 15 commits into from Feb 27, 2021

Conversation

isovector
Copy link
Collaborator

Refinery implements the tactics search by growing a search tree and collapsing back the results of each branch. But this is a complicated thing to think about, because there is data moving in three different directions. The Judgement moves from root to leaves, while the "extract" moves from leaves to root --- and the TacticState moves sideways between branches, just to make things hard.

This PR formalizes the extract to as a dedicated type Synthesized (it corresponds to a synthesized attribute in the lingo of attribute grammars). Having this new conceptual clarity made me realize that I used to be using the TacticState as a hacky way of passing information back up the search tree. So this PR chops out a lot of that complexity and is more principled about how it implements the same behavior.

Specifically, it does the following things:

  • Separate the creation of a local hypothesis (newly created bindings) from the introduction of them in the judgment
  • Pushes these new local hypotheses into the extract, so that we have provenance information when scoring generated solutions
  • Pushes used variables into the extract as well
  • Greatly simplifies the TacticState structure, and removes a lot of imperative statefulness around that

The TacticState still contains some should-be-extract data about recursion usage, but that can't be removed until there are some changes upstream to refinery.

Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

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

Nice summary, thanks

@isovector isovector added the merge me Label to trigger pull request merge label Feb 27, 2021
@mergify mergify bot merged commit f4a9671 into haskell:master Feb 27, 2021
@isovector isovector deleted the synthesized-attributes branch March 1, 2021 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants