Repository navigation
The branches a simplification went down and came back from (#273) - #1139
Merged
Merged
Conversation
#273 asks for two things: recording the steps taken while solving, and being able to see the return to a branch's root where a method fails. The first was already here -- `RewriteRecording` and `DerivationPath`. This is the second, and it turned out to need no new recording at all. `PathFrom` searches the recorded edges for a chain from the input to the result and throws the rest away. The rest is exactly the branches: each carries the expression it left from, which is the root the search returned to. `DerivationPath.Abandoned` hands them over beside the `Steps` it kept. What that shows, on the smallest case that has any: simplifying `(x + 1)^2` keeps one step and abandons seven, among them `AsPolynomial` and `Expand` both reaching `x^2 + 2x + 1` -- the search expanding the square and coming back, because the unexpanded form rates better. A `Steps` list on its own reads as though the library had walked straight to the answer. **Deduplicated, and that is not tidying.** The simplifier runs the same passes over the same expressions at every level of its candidate search, so the raw edges are mostly one rewrite recorded over and over: `x^(-1)/(y/z)` produces 425 of them across 13 distinct steps. Worse, the raw list included edges the kept chain had also taken, so the branches read as though the search had rejected the very step it went on to keep -- `sin(x)^2 + cos(x)^2` reported two abandoned branches, both duplicates of its two kept steps, and now reports none. A list of 425 is a record of how often the search was asked rather than of where it went. Neither list is an error list. A step here is a road not taken, usually to a perfectly correct expression that rated worse than the one kept, and the documentation says so rather than leaving a reader to assume otherwise. One member added to the public surface, `PublicApi.txt` regenerated: nothing removed. Part of #273.
…arch-came-back-from # Conflicts: # BREAKING-CHANGES.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #273.
The issue asks for two things:
RewriteRecordingandDerivationPathNo new recording was needed
PathFromsearches the recorded edges for a chain from the input to the result and throws the rest away. The rest is exactly the branches, and each already carries the expression it left from — the branch's root, in the issue's words.DerivationPath.Abandonedhands them over beside theStepsit kept.What it shows
Simplifying
(x + 1)^2keeps one step and abandons seven:The search expands the square and comes back, because the unexpanded form rates better. A
Stepslist on its own reads as though the library had walked straight to the answer.Deduplicated, and that is not tidying
The simplifier runs the same passes over the same expressions at every level of its candidate search, so the raw edges are mostly one rewrite recorded over and over:
x^(-1)/(y/z)(x + 1)^2sin(x)^2 + cos(x)^2That last row is the one that mattered. Both raw entries were duplicates of the kept steps, so the branch list read as though the search had rejected the very steps it went on to keep. A list of 425 is a record of how often the search was asked, not of where it went — so entries are deduplicated against each other and against the kept chain, and a test asserts both.
Not an error list
A step here is a road not taken, usually to a perfectly correct expression that simply rated worse than the one kept. The documentation says so rather than leaving a reader to infer that
Abandonedmeans "went wrong".Tests
Seven, and the interesting ones are the negative shapes: no kept step also appears as abandoned, no branch is reported twice, every branch leaves from an expression the search had actually reached, and expressions that were their own answer abandon nothing rather than "unknown".
One member added to the public surface,
PublicApi.txtregenerated. Nothing removed:Failed: 0, Passed: 9228on net10.0.🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura