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.
Development
python3 -m venv .venv
source .venv/bin/activate
pip install -e .[dev]
Run the full test suite in parallel:
python tests/run_parallel_unittest.py
Run individual test files:
python -m unittest tests/tests_check_calculation.py
python -m unittest tests/tests_check_substitution.py
python -m unittest tests/tests_check_util.py
python -m unittest tests/tests_extract_variables.py
python -m unittest tests/tests_subscript_substitution.py
python -m unittest tests/tests_verify_yaml.py
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.
Metadata
Release files for symbolic-math-verify 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| symbolic_math_verify-0.2.1.tar.gz | 48.4 kB | Without provenance | Details for symbolic_math_verify-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| symbolic_math_verify-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for symbolic_math_verify-0.2.1-py3-none-any.whl |
Total release size: 90.3 kB
Release files / symbolic_math_verify-0.2.1.tar.gz
| Download URL | symbolic_math_verify-0.2.1.tar.gz |
|---|---|
| Size | 48.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
23b501822dd8e958b15b952a62e6cc94722d8a35a700d2f6dac0ae9de8017c9c
|
|
BLAKE2b-256 checksum How to use checksums |
22085172a9eb5fab511477d7f12dd3c8be9749f7fd6ff598151f1f87237a3dc6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / symbolic_math_verify-0.2.1-py3-none-any.whl
| Download URL | symbolic_math_verify-0.2.1-py3-none-any.whl |
|---|---|
| Size | 41.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
41289cc6ad4bf1516588e2229b92daee16af30b9cbe85a5e4c9e2c8424f36020
|
|
BLAKE2b-256 checksum How to use checksums |
6a963695612c339f99aa457b81f7839aba4becadd5f0dfc067fcf8e25ad5d63c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for symbolic-math-verify 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.