The parser: equation strings to a term model - #3
Open
roed-math wants to merge 1 commit into
Open
Conversation
Closed
roed-math
force-pushed
the
split/01-bibliography
branch
from
August 8, 2026 16:12
8e824be to
c747532
Compare
roed-math
force-pushed
the
split/02-parsing
branch
from
August 8, 2026 16:12
08dd5eb to
8c77c0e
Compare
roed-math
force-pushed
the
split/01-bibliography
branch
from
August 9, 2026 02:43
c747532 to
cbc6bd5
Compare
roed-math
force-pushed
the
split/02-parsing
branch
from
August 9, 2026 02:43
8c77c0e to
13e7a5e
Compare
roed-math
force-pushed
the
split/01-bibliography
branch
from
August 9, 2026 05:01
cbc6bd5 to
5424adf
Compare
roed-math
force-pushed
the
split/02-parsing
branch
from
August 9, 2026 05:01
13e7a5e to
16a4760
Compare
roed-math
force-pushed
the
split/01-bibliography
branch
from
August 9, 2026 05:21
5424adf to
1eafd8f
Compare
roed-math
force-pushed
the
split/02-parsing
branch
from
August 9, 2026 05:21
16a4760 to
08dca27
Compare
roed-math
force-pushed
the
split/01-bibliography
branch
from
August 9, 2026 08:23
1eafd8f to
94de58a
Compare
roed-math
force-pushed
the
split/02-parsing
branch
from
August 9, 2026 08:23
08dca27 to
4bc7e6c
Compare
The parser: equation string to `ParsedEquation`. Recognizes the term model the rest of the classifier works with: polynomial terms, `2^n`-style exponential terms and `y^q` power terms, with parameters living in the coefficient ring. Denominators are cleared, and the hypotheses that introduces are kept as structured, executable predicates rather than prose. **API note:** `ParsedEquation.conditions` is a tuple of `NonzeroCondition` objects (`conditions.py`), not a list of display strings; `str(c)` renders one and `c.as_dict()` serializes it. The conditions are collected from the source syntax *before* Sage can simplify a denominator away, so `1/(x - 1) = 1/(y - 1)` records `x - 1 != 0` (not `x != 0`) and `x/x = y` keeps both the condition and `x` as an unknown. `source_lhs`/`source_rhs` keep the user's equation beside the normalized model, and `is_solution()` checks candidates against it exactly — the final correctness filter for every solver's output. No family data is involved: the parser is exercised by its own doctests and by `tests/test_parsing.py`. Part of the series that splits #1 into reviewable pieces: 1. `01-bibliography` — packaging, docs, annotated bibliography 2. `02-parsing` — equation strings to a term model 3. `03-registry` — the YAML family registry (3 seed families) 4. `04-matchers` — shape recognizers 5. `05-classify` — the classification pipeline 6. `06-solvers` — solver framework, two seed solvers, and the CLI 7. `07..09-backbone` — the 23 parent families of the DAG, by depth 8. one PR per remaining family (38 of them, mutually independent) 9. `99-polish` — restore the full doctests and tighten the invariants
roed-math
force-pushed
the
split/01-bibliography
branch
from
August 9, 2026 20:35
94de58a to
353fb02
Compare
roed-math
force-pushed
the
split/02-parsing
branch
from
August 9, 2026 20:35
4bc7e6c to
32ba147
Compare
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.
The parser: equation string to
ParsedEquation.Recognizes the term model the rest of the classifier works with: polynomial
terms,
2^n-style exponential terms andy^qpower terms, with parametersliving in the coefficient ring.
Denominators are cleared, and the hypotheses that introduces are kept as
structured, executable predicates rather than prose. API note:
ParsedEquation.conditionsis a tuple ofNonzeroConditionobjects(
conditions.py), not a list of display strings;str(c)renders one andc.as_dict()serializes it. The conditions are collected from the sourcesyntax before Sage can simplify a denominator away, so
1/(x - 1) = 1/(y - 1)records
x - 1 != 0(notx != 0) andx/x = ykeeps both the condition andxas an unknown.source_lhs/source_rhskeep the user's equation besidethe normalized model, and
is_solution()checks candidates against it exactly —the final correctness filter for every solver's output.
No family data is involved: the parser is exercised by its own doctests and by
tests/test_parsing.py.Part of the series that splits #1 into reviewable pieces:
01-bibliography— packaging, docs, annotated bibliography02-parsing— equation strings to a term model03-registry— the YAML family registry (3 seed families)04-matchers— shape recognizers05-classify— the classification pipeline06-solvers— solver framework, two seed solvers, and the CLI07..09-backbone— the 23 parent families of the DAG, by depth99-polish— restore the full doctests and tighten the invariants