F-family fusion pattern rewriter for symbolic expressions and Python source.
Project description
eml-rewrite
Pre-release. Patent pending. Not for redistribution.
F-family fusion pattern rewriter for symbolic expressions. Detects
equivalent rewrites that strictly reduce predicted EML cost (per
eml-cost). Provable non-regression: every proposed
rewrite either improves the cost or is filtered out.
Status
Pre-release. Covered by Monogate Research patent applications #11 and #12 (filed 2026-04-25). Public release follows post-prosecution licensing.
Library API
from eml_rewrite import suggest, best, score, Suggestion
import sympy as sp
x = sp.Symbol("x", real=True)
# Find improving rewrites (provably non-regressing)
sugg = suggest(sp.exp(x) / (1 + sp.exp(x)))
# [Suggestion(pattern_name="sigmoid",
# rewritten=1/(1 + exp(-x)),
# score_before=3, score_after=2, reduction=1)]
# Pick the lowest-score rewrite, or original if no improvement
best(sp.sinh(x) / sp.cosh(x))
# tanh(x)
best(sp.exp(sp.exp(x)))
# exp(exp(x)) ← original; nothing in library matches
Pattern library (9)
exp(x)/(1+exp(x))→1/(1+exp(-x))— sigmoid canonicalizationsinh(x)/cosh(x)→tanh(x)— F-family fusion(exp(x)+exp(-x))/2→cosh(x)— hyperbolic fusion(exp(x)-exp(-x))/2→sinh(x)— hyperbolic fusionsin(x)² + cos(x)²→1— Pythagorean identitycosh(x)² - sinh(x)²→1— hyperbolic identityexp(log(x)),log(exp(x))→x— inverse pairlog(a/b)→log(a) - log(b)— when score improveslog(x^n)→n·log(x)— when score improves
Command line
eml-rewrite scan FILE [FILE ...] # report rewrites without applying
eml-rewrite fix FILE [FILE ...] # show rewrites that would be applied
eml-rewrite analyze "exp(sin(x))" # full Pfaffian profile + suggestions
Example:
$ eml-rewrite analyze "exp(x)/(1 + exp(x))"
Expression: exp(x)/(1 + exp(x))
pfaffian_r: 1
max_path_r: 1
eml_depth: 2
structural_overhead: 3
corrections: Corrections(c_osc=0, c_composite=0, delta_fused=0)
predicted_depth: 4
is_pfaffian_not_eml: False
Suggested rewrites (1):
[sigmoid] 1/(1 + exp(-x)) (-1 cost units)
Provable non-regression
The library's headline guarantee:
for expr in any_collection:
for s in suggest(expr, only_improvements=True):
assert s.score_after < s.score_before # always
Every rewrite returned with only_improvements=True strictly reduces
the EML predicted depth. The test suite validates this on a hand-checked
panel; the engine filters non-improvements before returning them.
Installation (pre-release, local only)
pip install -e /path/to/eml-rewrite-pkg
Requires eml-cost (also pre-release).
License
PROPRIETARY-PRE-RELEASE. See LICENSE.
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 eml_rewrite-0.1.0a0.tar.gz.
File metadata
- Download URL: eml_rewrite-0.1.0a0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f5472b06086bc96f83bfd542d2a2066d775fde7f746aef08aa423aa4d0b2b19
|
|
| MD5 |
3b43dbbb34ea7b08175426603d1dab66
|
|
| BLAKE2b-256 |
d78c3fc7e374fe6dfa6f657399c078e484062e11e336298a9e1f7fcf8f2052aa
|
File details
Details for the file eml_rewrite-0.1.0a0-py3-none-any.whl.
File metadata
- Download URL: eml_rewrite-0.1.0a0-py3-none-any.whl
- Upload date:
- Size: 9.8 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 |
5ad368f3931a6420137f0ca8678cbdd7b25e86c7f95a21fb5446cec6a918f706
|
|
| MD5 |
42255fe6f8704a950d72fa3fda3d8c32
|
|
| BLAKE2b-256 |
66019cded72edc0632206266ae33bf36327fe82f2384694137d2f179e82d1dd1
|