Skip to content

fix: prevent vacuous match for symbol-free and constant relations (fixes #87) - #94

Open
pfolex wants to merge 1 commit into
huggingface:mainfrom
pfolex:fix/symbol-free-equations-issue-87
Open

pfolex wants to merge 1 commit into
huggingface:mainfrom
pfolex:fix/symbol-free-equations-issue-87

Conversation

@pfolex

@pfolex pfolex commented Oct 24, 2026

Copy link
Copy Markdown

Summary

Fixes #87.
Resolves an issue where verify() erroneously returned True for structurally different equations lacking free symbols (such as OlympiadBench function applications like $I_{e}(0)=\gamma I_{i}(0)$ vs $I_{i}(0)=I_{e}(0)$) or contradictory numerical relations with matching differences (like $3 = 4$ vs $1 = 2$).

Key Changes

  1. Guard Empty Solutions: sympy_solve_and_compare returns False if not solved_gold or not solved_pred, preventing vacuous all([]) equality matches.
  2. dict=True Equation Solving: Request dict=True from solve() for Eq comparisons and order dictionary keys with default_sort_key(item[0]) to support single- and multi-variable equations.
  3. Direct/Flipped Comparison for Numerical Relations: In sympy_compare_relational, prevent relations with constant numerical differences from matching via difference equality.
  4. Unit Tests: Added test coverage in tests/test_symbol_free_equations.py.

Validation

  • All 294 unit tests in pytest tests/ pass (0 regressions).
  • Code formatted with ruff.

 huggingface#87)

- Guard sympy_solve_and_compare to return False when solved_gold or solved_pred is empty, preventing vacuous all([]) equality matches on symbol-free relations.
- Request dict=True from sympy.solve for Eq comparisons and sort items with default_sort_key to properly support single and multi-variable equations.
- In sympy_compare_relational, prevent constant numerical differences (e.g. 3 - 4 == 1 - 2) from falsely matching unrelated numerical relations.
- Add comprehensive test suite in tests/test_symbol_free_equations.py covering symbol-free OlympiadBench relations, numerical relations, and symbolic equations.
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.

verify() returns True for any two equations with no free symbols

1 participant