Skip to content

Support chained equalities in the answer and response - #278

Draft
m-messer wants to merge 1 commit into
feature/inequalitiesfrom
feature/chained-equalities
Draft

m-messer wants to merge 1 commit into
feature/inequalitiesfrom
feature/chained-equalities

Conversation

@m-messer

Copy link
Copy Markdown
Member

Problem

Chained equalities were silently truncated. parse_expression split on = but
only used the first two parts, so everything after the second operand was
discarded — never parsed, never validated, no error. x = y = z became
Eq(x, y), and a wrong third term was marked correct:

Response Answer Before After
x = y = w x = y = z ✅ correct ❌ incorrect
x = y = 5 x = y = 7 ✅ correct ❌ incorrect
x = y = z x = y ✅ correct ❌ incorrect

The preview showed the student's full x=y=z back to them, so nothing on screen
hinted that only x = y was being graded.

Changes

  • parse_expression now parses every operand and returns the conjunction of the
    equalities between adjacent ones: x = y = z → And(Eq(x, y), Eq(y, z)). A
    single equality is still a bare Equality, so that path is unchanged. An empty
    operand (x = = y) is now a parse error.
  • check_equality_equivalence in app/context/symbolic.py, mirroring
    check_inequality_equivalence. Chains are compared by solution set, since a
    chain carries no meaning in the order it is written — z = y = x states what
    x = y = z states, and scaled or offset chains (2x = 2y = 2z) match too.
    Non-affine chains fall back to matching parts one-to-one.
  • New CHAIN_NOT_EQUALITY / EQUALITY_NOT_CHAIN feedback tags for a chain
    compared against a single equality.
  • Docs and tests: 31 new tests, 1809 passed, 2 skipped.

Stacked on #276

Based on feature/inequalities, not main. Merge #276 first, then retarget
this to main; until then the diff against main includes #276's commits.

🤖 Generated with Claude Code

…parsing, and feedback, with tests and documentation updates.

This branch has not been deployed

No deployments
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.

1 participant