Skip to main content

SimpliPy:
Efficient Simplification of Mathematical Expressions

PyPI version PyPI license Documentation Status

pytest quality checks CodeQL Advanced

Publications

  • Saegert & Köthe 2026, Breaking the Simplification Bottleneck in Amortized Neural Symbolic Regression (preprint, under review) https://arxiv.org/abs/2602.08885

Usage

pip install simplipy

The compiled Rust extension (simplipy._core) is required: the inline phase (simplify, conversions, validation) runs on it exclusively, and there is no pure-Python fallback. Prebuilt wheels are published for Linux (x86_64/aarch64), macOS (x86_64/arm64) and Windows (x64) on CPython ≥ 3.11, so pip install simplipy does not compile anything for most users. Installing from the source distribution (an unsupported platform, or --no-binary) requires a Rust toolchain (rustup, MSRV 1.83). If the extension is missing at runtime, constructing an engine raises ImportError.

import simplipy as sp

engine = sp.SimpliPyEngine.load("4-3", install=True)   # a published ruleset artifact

# Simplify prefix expressions
engine.simplify(('/', '<constant>', '*', '/', '*', 'x3', '<constant>', 'x3', 'log', 'x3'))
# > ('/', '<constant>', 'log', 'x3')

# Simplify infix expressions
engine.simplify('x3 * sin(<constant> + 1) / (x3 * x3)')
# > '<constant> / x3'

Normalization

The root-exported normalize_skeleton, normalize_expression, and normalize_variable_token helpers (also available as simplipy.normalization) canonicalize a prefix token sequence so that two expressions that are "the same" up to variable renaming / constant values compare equal. They are pure-string helpers with no engine state, so consumers such as holdout matching and symbolic-recovery scoring share identical behavior by construction.

import simplipy as sp

# Skeleton form: variables -> x{n}, numeric literals -> <constant>
sp.normalize_skeleton(['+', 'v1', '2.5'])
# > ['+', 'x1', '<constant>']

# Expression form: variables canonicalized, numeric literals kept intact
sp.normalize_expression(['+', 'V1', '2.5'])
# > ['+', 'x1', '2.5']

# Classify / canonicalize a single token -> (normalized_token, is_variable)
sp.normalize_variable_token('X3')
# > ('x3', True)
sp.normalize_variable_token('sin')
# > ('sin', False)

More examples can be found in the documentation.

Performance

As of 0.6.0 the simplify hot path defers match-time certificates to completed matches (memoized generationally, never stopping memoization), memoizes whole fixpoint passes and rule-normal subtrees, and runs on interned token ids (~20× fewer allocations per call) — all at byte-identical outputs. On a 65,536-expression training-prior benchmark, large certificate-bearing rulesets simplify ~59× faster than 0.5.0 and certificate-free rulesets ~2.3× faster; see the CHANGELOG for details. Since 0.7.0 there is a single compiled engine line; the published ruleset artifacts (2-1, 3-2, 4-3, …) are the distinguishing factor between engines. Rule application always considers every pattern in the loaded artifact (the former max_pattern_length knob was removed in 0.10.0). (To reproduce the historical dev_7-3 / v23.0-era behavior byte-for-byte, install simplipy<=0.6.0.)

Simplification time and ratio ECDFs: SimpliPy 0.9.1 vs SymPy across three axes (mined rulesets, safe vs aggressive, search budget) on 64k Lample-Charton expressions from the Flash-ANSR v23.0 prior

Empirical Cumulative Distribution Functions (ECDFs) of simplification wall-clock time (top row) and simplification ratio |simp| / |orig| in prefix tokens (bottom row, inset: zoom on the low-ratio tail), over 65,536 randomly generated Lample-Charton expressions sampled from the Flash-ANSR v23.0 training prior (0 to 17 unique variables, 1 to 35 symbols [Saegert & Köthe 2026]). Three axes vary SimpliPy (green) while SymPy [Meurer et al. 2017] (orange ratio=None / red ratio=1) is the fixed reference: Mined Rulesets — the published 2-1/3-2/4-3 artifacts, every pattern active (darker = larger); Safe vs Aggressive4-3 in the deployed SOUND mode vs the training-only LOSSY mode; Search Budget4-3 SOUND at node budgets 1 to 48. SimpliPy is timed per call (perf_counter, gc off); SymPy is given each <constant> as a free symbol and simplified symbolically inside a per-expression worker with a 1 s timeout, then scored by its native prefix length. The measured quantities are the two ECDFs; the plot, not this caption, reports what they show.

Development

Setup

To set up the development environment, run the following commands:

pip install -e .[dev]
pre-commit install

Tests

Test the package with pytest:

pytest tests --cov src --cov-report html

or to skip integration tests,

pytest tests --cov src --cov-report html -m "not integration"

Citation

@misc{saegert2026breakingsimplificationbottleneckamortized,
  title   = {Breaking the Simplification Bottleneck in Amortized Neural Symbolic Regression},
  author  = {Paul Saegert and Ullrich Köthe},
  year    = {2026},
  eprint  = {2602.08885},
  archivePrefix =  {arXiv},
  primaryClass  = {cs.LG},
  url     = {https://arxiv.org/abs/2602.08885},
}

% Optionally
@software{simplipy-2025,
    author = {Paul Saegert},
    title = {Efficient Simplification of Mathematical Expressions},
    year = 2026,
    publisher = {GitHub},
    version = {0.9.1},
    url = {https://github.com/psaegert/simplipy}
}

Download files

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

Source Distribution

simplipy-0.10.0.tar.gz (1.8 MB view details)

Uploaded Source

Built Distributions

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

simplipy-0.10.0-cp311-abi3-win_amd64.whl (883.7 kB view details)

Uploaded CPython 3.11+Windows x86-64

simplipy-0.10.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

simplipy-0.10.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (972.5 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

simplipy-0.10.0-cp311-abi3-macosx_11_0_arm64.whl (916.1 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

simplipy-0.10.0-cp311-abi3-macosx_10_12_x86_64.whl (951.3 kB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file simplipy-0.10.0.tar.gz.

File metadata

  • Download URL: simplipy-0.10.0.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for simplipy-0.10.0.tar.gz
Algorithm Hash digest
SHA256 2b76e8f3599f8a7a824b44771d3db4fbf95cd66aef4bac0c90b2f78a7252b866
MD5 310573f4f911545aae5eeba79a4d73e3
BLAKE2b-256 ad6614244ff06558f69a05771c3602890c04cb69f54473c0f7ae57a9240f315e

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.10.0.tar.gz:

Publisher: publish.yml on psaegert/simplipy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simplipy-0.10.0-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: simplipy-0.10.0-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 883.7 kB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for simplipy-0.10.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5ede4947974c575649f30cfa235b0ba46c675bd867c404a7d5e3ca77dabf6f91
MD5 31ded45a03092ea0e97663789fa979a9
BLAKE2b-256 2beaf628ba93b646c1864181752914efe5559fe4d5c6f6d1996f0d8046fa837b

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.10.0-cp311-abi3-win_amd64.whl:

Publisher: publish.yml on psaegert/simplipy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simplipy-0.10.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for simplipy-0.10.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 511671fef52a44209bcd0edd5b5a898f14ab273d465c569427beff8048ea06a0
MD5 89d22ceda6d8f35bdb5fb17e3919729f
BLAKE2b-256 fa543c0c14271d6093e89b51e47141feb6bf47956a1699e37fcf256a216348de

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.10.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on psaegert/simplipy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simplipy-0.10.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for simplipy-0.10.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 eba9827c058ea93d8871e23ff568569fe9fe43444216c35ddd2a4f3d1431e27a
MD5 efb09905a157744fa2c46bbe13306565
BLAKE2b-256 d12693b0eac377a71d53a745d3ffd3922276de06814ad070286556821cd50f96

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.10.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on psaegert/simplipy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simplipy-0.10.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for simplipy-0.10.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1d27b808ce4ec5f24b20c9b8f976f89270db189dca0a689bea433def6f156eb8
MD5 198364fdd37fd332834d02ee2c8fb373
BLAKE2b-256 604267fc6bb6b7aa7a19146af130c20ba5b1ea3ce1bfdb92dba9504ef26c683c

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.10.0-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on psaegert/simplipy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simplipy-0.10.0-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for simplipy-0.10.0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e52d900a0680265d1cc82b4ed6002f758b9c3c80cfb422dd898fcd1a034555a3
MD5 33281620c65be2824f918ca37fa3b4c6
BLAKE2b-256 fdbbb385fccb93022b52390fc9d6e432e7dc400ac459cf1e5631960a2f9a3941

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.10.0-cp311-abi3-macosx_10_12_x86_64.whl:

Publisher: publish.yml on psaegert/simplipy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.14.6

6 files

0.14.5

6 files

0.14.4

6 files

0.14.2

6 files

0.14.1

6 files

0.14.0

6 files

0.13.1

6 files

0.13.0

6 files

0.12.0

6 files

0.11.0

6 files

0.10.1

6 files

This release

0.10.0 This release

6 files

0.9.1

6 files

0.9.0

6 files

0.8.0

6 files

0.7.1

6 files

0.7.0

6 files

0.4.2

6 files

0.4.1

6 files

0.4.0

6 files

0.3.1

6 files

0.3.0

6 files

0.2.15

2 files

0.2.14

2 files

0.2.13

2 files

0.2.12

2 files

0.2.11

2 files

0.2.10

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.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