Skip to content

Support inequalities in the answer and response - #301

Draft
m-messer wants to merge 1 commit into
feat/sig-figs-decimal-placesfrom
feat/inequalities
Draft

m-messer wants to merge 1 commit into
feat/sig-figs-decimal-placesfrom
feat/inequalities

Conversation

@m-messer

Copy link
Copy Markdown
Member

Stacked on #300, which is stacked on #299 and the rc4 pin in #298. Hold until #298 merges. Replaces #276.

The parsing is in lambda-feedback/lambda-feedback-packages#13. <, <=, >, >= and != (and ≠, ≤, ≥) now parse to SymPy relations. 1 < x < 5 parses to an And of two relations. Grading, feedback, preview and docs stay here.

Behaviour (unchanged from #276)

Answer Accepted Rejected
2x - 10 >= 0 x >= 5, 5 <= x, 4x - 20 >= 0, 10 - 2x <= 0 x > 5 (strictness), x <= 5 (opposite direction)
1 < x < 5 5 > x > 1, 0 < x - 1 < 4, 2 < 2x < 10 1 <= x < 5 (strictness)
x != 5 5 != x, 2x != 10, x - 5 != 0, x ≠ 5 x = 5

Where it goes

  • New app/context/symbolic/inequalities.py: inequality_bounds and check_inequality_equivalence, along with the single, chained and != helpers. The result is an InequalityComparison enum, and each member's name is the criterion tag suffix (_TRUE, _WRONG_DIRECTION, _STRICTNESS_MISMATCH, ...). This replaces Support inequalities in the answer and response #276's mix of True/False/None/str and its result-to-tag dict. Support inequalities in the answer and response #276's bare except Exception is now except TypeError.
  • check_equality (app/context/symbolic/comparison.py): relations are caught before the lhs - rhs subtraction, which raised a TypeError on them.
  • app/context/symbolic/graphs/equivalence.py: add_inequality_equivalence_nodes. criterion_equality_node uses it after set equivalence and before equalities.
  • app/feedback/symbolic.py: the seven new INTERNAL strings.
  • app/preview/symbolic.py: the response is split only on a lone =, so x >= 5 and x != 5 preview as one relation.
  • Docs in app/docs/user.md and app/docs/dev.md.

Not changed: check_order still subtracts lhs - rhs without a guard. #276 didn't touch it either.

Tests

🤖 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