Skip to main content

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) -> bool Proves whether two equations define the same zero relation.
  • is_substitution_correct(symbol_list, equation_before, substitute_equation, equation_after) -> bool Proves whether equation_after is a valid substitution result.
  • is_subscript_substitution_correct(symbol_list, equation_before, subscript, equation_after) -> bool Proves whether the same suffix such as _i was applied consistently to every declared symbol.
  • is_calculation_correct(symbol_list, symbol_val, equation, expected_value, tolerance) -> bool Evaluates 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) -> str Validates 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: True means proven, while False means wrong, invalid, ambiguous, or not proven.
  • Equations may be written as lhs = rhs or as zero expressions such as x^2 - 1.
  • Common Unicode math characters such as , ×, ÷, and π are normalized before parsing.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

symbolic_math_verify-0.1.9.tar.gz (47.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

symbolic_math_verify-0.1.9-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

Details for the file symbolic_math_verify-0.1.9.tar.gz.

File metadata

  • Download URL: symbolic_math_verify-0.1.9.tar.gz
  • Upload date:
  • Size: 47.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for symbolic_math_verify-0.1.9.tar.gz
Algorithm Hash digest
SHA256 e3bf1add3a634ca38a6317ae56e6fe29f23d66a05c70ecb7e54389a70d873b2a
MD5 21404279663c3c7ea85d7368bed2373f
BLAKE2b-256 95b2e14e5f7439e8325bcecec1dc612153d11986e15c914eaeb90be77014f134

See more details on using hashes here.

File details

Details for the file symbolic_math_verify-0.1.9-py3-none-any.whl.

File metadata

File hashes

Hashes for symbolic_math_verify-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 3b4f897d7b7483ca5951170dc85ffd1f52f2537663baea6538c58a643952ce54
MD5 a285cc511c0e1bda106705b03beb3fe1
BLAKE2b-256 504906b65a0ed959faf6f4828cbb94688e3b0898cf1c56fcbe04e925515032e2

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.1

2 files

This release

0.1.9 This release

2 files

0.1.6

2 files

0.1.4

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page