Unified symbolic-numeric expression runtime with EML lowering
Project description
uninum
A symbolic-numeric expression runtime for Python with EML lowering.
Build mathematical expressions as Python objects, then evaluate, differentiate, simplify, compile to fast callables, or lower to a universal representation where every expression becomes a tree of a single binary operator.
Based off of the work and research presented in the paper "All elementary functions from a single operator" - (Odrzywolek, 2026) https://arxiv.org/pdf/2603.21852
Features
- Expression building with natural Python syntax (
+,-,*,/,**) and standard math functions (sin,cos,exp,ln,sqrt, ...) - Symbolic differentiation with automatic chain rule, product rule, and all standard derivatives
- Algebraic simplification via identity elimination, constant folding, and inverse cancellation
- Compilation to fast callables with a numpy (vectorized) or pure-Python backend
- EML lowering -- rewrite any expression to a tree of a single operator
eml(x, y) = exp(x) - ln(y)plus the constant 1
Install
Requires Python >= 3.10.
python -m venv .venv
source .venv/bin/activate # Linux/macOS
# .venv\Scripts\activate # Windows
pip install . # core
pip install .[numpy] # with numpy backend support
pip install .[dev] # with pytest for running tests
Quickstart
from uninum import var, sin, ln, compile_expr
x = var("x")
y = var("y")
# Build an expression
expr = (x + y) * sin(x) / ln(y)
print(expr) # (x + y) * sin(x) / ln(y)
# Evaluate numerically
print(expr.evaluate(x=1.2, y=3.4)) # 3.503404...
# Differentiate and simplify
df = expr.diff(x).simplify()
print(df)
# Compile to a fast callable
fn = compile_expr(expr, backend="python")
print(fn(x=1.2, y=3.4))
# Lower to pure EML form
lowered = expr.to_eml()
print(lowered.evaluate(x=1.2, y=3.4)) # same result
API Overview
| Category | Name | Description |
|---|---|---|
| Node types | Expr |
Base class for all expression nodes |
Const(value, name=None) |
Numeric constant | |
Var(name) |
Variable | |
UnaryOp(op, arg) |
Unary function application | |
BinOp(op, left, right) |
Binary operation | |
| Constructors | var(name) |
Create a variable |
exp, ln, log |
Exponential and natural log (log is alias for ln) |
|
sin, cos, tan |
Trigonometric functions | |
asin, acos, atan |
Inverse trigonometric functions | |
sinh, cosh, tanh |
Hyperbolic functions | |
sqrt |
Square root | |
eml(x, y) |
The EML operator: exp(x) - ln(y) |
|
| Constants | e, pi, I |
Euler's number, pi, imaginary unit |
| Methods | .evaluate(**kwargs) |
Numeric evaluation with variable bindings |
.diff(wrt) |
Symbolic derivative (accepts Var or str) |
|
.simplify() |
Algebraic simplification | |
.to_eml() |
Lower to pure EML representation | |
.to_latex() |
Render as LaTeX math string | |
| Compilation | compile_expr(expr, backend) |
Compile to callable; "numpy" or "python" |
| Rendering | to_latex(expr) |
Convert expression to LaTeX |
EML in 30 Seconds
The EML operator eml(x, y) = exp(x) - ln(y) is a single binary function that, combined with the constant 1, can express all elementary mathematics. This was shown by Odrzywolek (2024).
from uninum import var, sin, exp
x = var("x")
f = sin(x) + exp(x)
lowered = f.to_eml() # pure eml(S, S) tree with leaves = 1 or x
print(lowered.evaluate(x=1.0)) # matches f.evaluate(x=1.0)
The grammar of every lowered expression is simply S -> 1 | x | eml(S, S). See docs/eml_explained.md for the full theory.
Examples
| Script | What it covers |
|---|---|
| 01_expressions.py | Building expressions, evaluation, named constants |
| 02_differentiation.py | Symbolic derivatives, chain rule, numerical verification |
| 03_simplification.py | Simplification rules, capabilities, and limitations |
| 04_compilation.py | Python and numpy backends, vectorized evaluation |
| 05_eml_lowering.py | EML operator, lowering process, correctness verification |
| 06_full_workflow.py | End-to-end: build, diff, simplify, compile, lower |
Documentation
- API Reference -- complete reference for all public symbols
- EML Explained -- theory and implementation of EML lowering
- Cookbook -- copy-paste recipes for common tasks
Running Tests
pip install .[dev]
pytest tests/ -v
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 uninum-0.2.0.tar.gz.
File metadata
- Download URL: uninum-0.2.0.tar.gz
- Upload date:
- Size: 21.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f378acbc4b7d5e6dac6e4c11339841535b9dad848cf6b20d20eb3e63c54f58a
|
|
| MD5 |
73aaea13cb61ca7bfb1cc5359b5831e3
|
|
| BLAKE2b-256 |
95ccf36635b8e5880119d92af967fb918ba51a7301408e21321dcdde17d25bb8
|
Provenance
The following attestation bundles were made for uninum-0.2.0.tar.gz:
Publisher:
publish.yml on Brumbelow/uninum
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
uninum-0.2.0.tar.gz -
Subject digest:
6f378acbc4b7d5e6dac6e4c11339841535b9dad848cf6b20d20eb3e63c54f58a - Sigstore transparency entry: 1299431571
- Sigstore integration time:
-
Permalink:
Brumbelow/uninum@8a0a669040dfbb051d82798429ddf9eeaa44a135 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Brumbelow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8a0a669040dfbb051d82798429ddf9eeaa44a135 -
Trigger Event:
push
-
Statement type:
File details
Details for the file uninum-0.2.0-py3-none-any.whl.
File metadata
- Download URL: uninum-0.2.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2f708e82af6fb4202b352db26f1b61d6979ffae3381f6d00deb0d6c6cb748ab
|
|
| MD5 |
7e60cf599f5a05ab2e3207ef6d6a5105
|
|
| BLAKE2b-256 |
d85dec3c0c01a14f5d6c4e72c4698bd34115e30b49b9dc2be15c3602a93bbb52
|
Provenance
The following attestation bundles were made for uninum-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on Brumbelow/uninum
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
uninum-0.2.0-py3-none-any.whl -
Subject digest:
e2f708e82af6fb4202b352db26f1b61d6979ffae3381f6d00deb0d6c6cb748ab - Sigstore transparency entry: 1299431665
- Sigstore integration time:
-
Permalink:
Brumbelow/uninum@8a0a669040dfbb051d82798429ddf9eeaa44a135 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Brumbelow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8a0a669040dfbb051d82798429ddf9eeaa44a135 -
Trigger Event:
push
-
Statement type: