Symbolic math verification utilities built on SymPy.
Project description
Symbolic Math Verify
Symbolic math verification utilities built on SymPy.
This project checks whether equations are equivalent, whether a substitution step is valid, whether a uniform subscript rename is valid, whether a numeric calculation matches an expected value, and whether a YAML proof file is valid.
PyPI package: symbolic-math-verify
Install
pip install symbolic-math-verify
Import it as symbolic_math_verify.
Public API
from symbolic_math_verify import extract_variables
from symbolic_math_verify import is_calculation_correct
from symbolic_math_verify import is_equation_equal
from symbolic_math_verify import is_subscript_substitution_correct
from symbolic_math_verify import is_substitution_correct
from symbolic_math_verify import verify_yaml_file
What It Does
is_equation_equal(symbol_list, lhs_equation, rhs_equation) -> boolProves whether two equations define the same zero relation.is_substitution_correct(symbol_list, equation_before, substitute_equation, equation_after) -> boolProves whetherequation_afteris a valid substitution result.is_subscript_substitution_correct(symbol_list, equation_before, subscript, equation_after) -> boolProves whether the same suffix such as_iwas applied consistently to every declared symbol.is_calculation_correct(symbol_list, symbol_val, equation, expected_value, tolerance) -> boolEvaluates an expression or equation residual numerically and compares it to an expected value.extract_variables(math_expression) -> list[str]Extracts variable names from math-like text while skipping known functions and constants.verify_yaml_file(file_path) -> strValidates YAML axioms, proof chains, substitution steps, subscript-substitution steps, and calculations.
Examples
Equation equivalence:
from symbolic_math_verify import is_equation_equal
is_equation_equal(["x"], "x + 2 = 5", "x = 3")
# True
Substitution:
from symbolic_math_verify import is_substitution_correct
is_substitution_correct(
["x", "y", "z"],
"y = 1/x + 5*z",
"x = z^3",
"y = 1/(z^3) + 5*z",
)
# True
Subscript substitution:
from symbolic_math_verify import is_subscript_substitution_correct
is_subscript_substitution_correct(
["E", "m", "v"],
"E = (1/2)*m*(v^2)",
"_i",
"E_i = (1/2)*m_i*(v_i^2)",
)
# True
Calculation:
from symbolic_math_verify import is_calculation_correct
is_calculation_correct(
["x", "y", "z"],
[0.5, -0.2, 14.0],
"x + y^2 + 1/z",
0.61142,
0.001,
)
# True
Variable extraction:
from symbolic_math_verify import extract_variables
extract_variables("P = I*V ; V = I*R -> P = R*I^2")
# ['P', 'I', 'V', 'R']
YAML verification:
from symbolic_math_verify import verify_yaml_file
verify_yaml_file("test_yaml/valid_11_prompt_with_calculation.yaml")
# "Math proofs are valid"
YAML Support
verify_yaml_file() validates YAML files containing:
axioms- theorem/proof sections with
->,;, and:proof steps - optional
calculations
For axioms and theorem sections, vars may be omitted and will be auto-detected from the math text. For calculations, vars is required.
See YAML_tutorial.md for a full YAML proof example and validation rules.
Notes
- The checker is conservative:
Truemeans proven, whileFalsemeans wrong, invalid, ambiguous, or not proven. - Equations may be written as
lhs = rhsor as zero expressions such asx^2 - 1. - Common Unicode math characters such as
−,×,÷, andπare normalized before parsing.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file symbolic_math_verify-0.1.1.tar.gz.
File metadata
- Download URL: symbolic_math_verify-0.1.1.tar.gz
- Upload date:
- Size: 47.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d3394b2d774d0fa2250e53736fe9605518bfb1d7ba4d49d006a851320cbcfc1
|
|
| MD5 |
7245cfec456adce2982b318096d95290
|
|
| BLAKE2b-256 |
b2bf19957665efcee7f97727c2f30bba586aa13a44340ab7f24028917068c87e
|
File details
Details for the file symbolic_math_verify-0.1.1-py3-none-any.whl.
File metadata
- Download URL: symbolic_math_verify-0.1.1-py3-none-any.whl
- Upload date:
- Size: 41.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e38d79c3f750eef0b4a101ea0e7b9dbe81818f1cfb3e284019a0e1e750ee5bf2
|
|
| MD5 |
971d8c362c0c1bac5e4cc9ae79d37a37
|
|
| BLAKE2b-256 |
b8fb6ee1a7551e5e1ff5db0637735989463a435b926ba4b2a95eb1a7b7fa0af1
|