Equation parsing and equivalence comparison
Project description
eq-equiv
Equation parsing and equivalence comparison for typed symbolic equations.
eq-equiv parses a deliberately small equation surface, binds authored
symbols to stable concept identifiers, renders typed expression trees, and
compares equations through deterministic structural and SymPy-backed
normalization.
Supported Surface
Equations must contain exactly one = relation. Expressions support:
- symbols declared by
EquationSymbolBinding; - integers, decimals, and exponent notation;
- unary
+and-; - binary
+,-,*,/, and^; - one-argument functions
abs,log,ln,exp, andsqrt.
Unsupported functions, unknown symbols, inequalities, chained equalities, and
raw executable SymPy surfaces return typed EquationFailure values instead of
being evaluated.
Comparison Outcomes
EQUIVALENT: the equations are proven equivalent under the declared domain.DIFFERENT: the equations are proven different for the supported theory.INCOMPARABLE: parsing or normalization failed.UNKNOWN: both equations parsed, but the available algebraic procedure cannot make a sound equivalence or difference decision.
Domain-sensitive identities return UNKNOWN unless the caller supplies the
needed assumptions. For example, log(x * y) = z and
log(x) + log(y) = z require positive assumptions for x and y.
Related
For converting human-typed equation strings (with ^, broad function names,
constants like pi) into canonical SymPy expression strings, see the sibling
package human-to-sympy. It is
deliberately a separate library — eq-equiv deals with semantic equivalence
over a narrow grammar; human-to-sympy deals with surface translation into
SymPy. They do not depend on each other.
Example
from eq_equiv import (
BoundEquation,
EquationComparisonStatus,
EquationSymbolBinding,
Positive,
compare_equations,
)
bindings = (
EquationSymbolBinding(symbol="x", concept_id="x"),
EquationSymbolBinding(symbol="y", concept_id="y"),
EquationSymbolBinding(symbol="z", concept_id="z"),
)
left = BoundEquation("log(x * y) = z", variables=bindings)
right = BoundEquation("log(x) + log(y) = z", variables=bindings)
result = compare_equations(
left,
right,
domain_assumptions=(Positive("x"), Positive("y")),
)
assert result.status == EquationComparisonStatus.EQUIVALENT
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 eq_equiv-0.1.0.tar.gz.
File metadata
- Download URL: eq_equiv-0.1.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9a3835f556285e1435071f8966a5e4f5fc1fad3ca9d3d923a7794d20a3623fa
|
|
| MD5 |
64bc9cdaa1f29c64c7161ca92a16622b
|
|
| BLAKE2b-256 |
99657ce04ed6224660b18811c1280e89266f8a5ea1c0ae62ce14bdefed5beaee
|
File details
Details for the file eq_equiv-0.1.0-py3-none-any.whl.
File metadata
- Download URL: eq_equiv-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb07850fd626550ddf626a76b254b1042aa1a9f6fadec1d90556af533e5b0c2e
|
|
| MD5 |
bc09d7d7391134effbcc8b7d879d5894
|
|
| BLAKE2b-256 |
6246c5c14321afed703356bd3cea49a3abdcd03a8b300c2b38dfecd857bfb101
|