Skip to content

Support chained equalities in the answer and response - #302

Draft
m-messer wants to merge 2 commits into
feat/inequalitiesfrom
feat/chained-equalities
Draft

m-messer wants to merge 2 commits into
feat/inequalitiesfrom
feat/chained-equalities

Conversation

@m-messer

Copy link
Copy Markdown
Member

Stacked on #301 (inequalities), which is stacked on #300, #299 and the rc4 pin in #298. Hold until #298 merges. Replaces #278.

The parsing is in lambda-feedback/lambda-feedback-packages#13. x = y = z now parses to And(Eq(x, y), Eq(y, z)). Before, only the first two operands were kept, so x = y = w was marked correct against x = y = z. A single = still parses to a bare Equality. x = = y and x = y < z are parse errors.

Behaviour (unchanged from #278)

Response Answer Result
z = y = x, y = x = z, 2x = 2y = 2z, x + 1 = y + 1 = z + 1 x = y = z correct
x = y = w, x = y = 5 x = y = z incorrect
x = y = y x = y correct (the chain states no more than the single equality)
x = y = z x = y incorrect, CHAIN_NOT_EQUALITY
x = y x = y = z incorrect, EQUALITY_NOT_CHAIN

Where it goes

  • New app/context/symbolic/equalities.py: equality_parts, is_equality_chain and check_equality_equivalence.
    • Chains are compared by solution set: the ranks of the augmented coefficient matrices from linear_eq_to_matrix.
    • A chain that isn't affine with numeric coefficients falls back to matching its parts one-to-one over every ordering, up to MAX_CHAINED_EQUALITY_PARTS.
    • The result is an EqualityComparison enum, and each member's name is the criterion tag suffix. Support chained equalities in the answer and response #278's bare except Exception is now except ValueError (sympy's NonlinearError).
  • The single-equality ratio test moved, unchanged, from _equality_equivalence into _compare_single_equality. _equality_equivalence now calls check_equality_equivalence.
  • check_equality: chains are caught before the lhs - rhs subtraction, the same as inequalities.
  • app/context/symbolic/graphs/equivalence.py: two new outcomes, CHAIN_NOT_EQUALITY and EQUALITY_NOT_CHAIN. criterion_equality_node uses equality_parts, so it also handles chains.
  • app/feedback/symbolic.py: the two new strings.
  • Docs in app/docs/user.md and app/docs/dev.md.
  • Removed the old # TODO: Remove when criteria for checking proportionality is implemented. PROPORTIONAL_TO has existed since 472319a, and moving the equality check onto it wouldn't change behaviour.

Tests

  • Ported Support chained equalities in the answer and response #278's evaluation tests into symbolic_evaluation_test.py, and its preview test into symbolic_preview_test.py. The parser tests are in packages#13.
  • 1568 passed, 1 failed: test_radians_to_frequency, which fails before this PR too.
  • mypy is clean. The blocking flake8 selection reports 0. In the warning-only run, check_equality complexity rises to 15.

🤖 Generated with Claude Code

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