setreplace
Wolfram models in Python — hypergraph substitution systems with the exact
semantics of Wolfram's SetReplace,
plus HypergraphPlot-style rendering, powered by a Rust engine. No Wolfram
Language license, no graphviz, no native dependencies to install.
import setreplace as sr
# The rule from the Wolfram Physics Project announcement
system = sr.evolve("{{x, y}, {x, z}} -> {{x, z}, {x, w}, {y, w}, {z, w}}",
[[1, 2], [2, 3], [3, 4], [2, 4]], events=1500)
system.plot() # ↑ renders inline in Jupyter
States are plain list[list[int]]; rules are the same strings the
SetReplace docs use. Evolution is incremental and fully deterministic
(seeded), and every token and event keeps its causal history:
rule = "{{v1, v2, v3}, {v2, v4, v5}} -> {{v5, v6, v1}, {v6, v4, v2}, {v4, v5, v3}}"
system = sr.evolve(rule, [[1, 2, 3], [2, 4, 5], [4, 6, 7]], events=10)
system # <HypergraphSystem: 10 events, 5 generations, 13 edges, MaxEvents>
system.final_state # [[7, 2, 9], [7, 14, 6], ...]
system.evolve(max_events=100)
system.termination_reason # "MaxEvents" | "FixedPoint" | "MaxGenerations" | ...
system.tokens()[0] # Token(atoms=[1, 2, 3], creator_event=0, ...)
system.causal_graph_plot() # layered causal graph, inline
system.plot().save("state.png")
sr.set_replace([[1, 2], [2, 3]], "{{a_, b_}, {b_, c_}} :> {{a, c}}") # [[1, 3]]
pos = sr.layout(system.final_state) # {atom: (x, y)} for matplotlib & friends
| Wolfram Language | Python |
|---|---|
WolframModel[rules, init, g] |
sr.evolve(rules, init, generations=g) |
SetReplace[set, rules, n] |
sr.set_replace(set, rules, n) |
<|"MaxEvents" -> n, "MaxVertices" -> v|> |
system.evolve(max_events=n, max_vertices=v) |
"EventOrderingFunction" -> {"OldestEdge", ...} |
event_ordering=["OldestEdge", ...] |
"CausalGraph" / "LayeredCausalGraph" |
system.causal_graph_edges() / .causal_graph_plot() |
HypergraphPlot[state, VertexLabels -> Automatic] |
sr.plot(state, labels=True) |
The engine is a verified port of SetReplace's C++ core: test vectors lifted from SetReplace's own suite, plus live cross-checks against SetReplace under wolframscript — final states, event traces, causal graphs, and every event ordering agree exactly. The renderer's palette and arrowhead geometry are transcribed from SetReplace's style sources, and large states lay out in seconds via a multilevel spring-electrical embedding.
Docs, gallery, and the Rust crates: github.com/kovasb/setreplace-py.
Independent reimplementation of SetReplace (MIT) by Max Piskunov and contributors; not affiliated with the SetReplace project, the Wolfram Physics Project, or Wolfram Research. MIT licensed.
Metadata
Release files for setreplace 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| setreplace-0.2.0.tar.gz | 5.7 MB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| setreplace-0.2.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details |
| setreplace-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| setreplace-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| setreplace-0.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64, macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64) | Details |
Total release size: 15.0 MB
Release files / setreplace-0.2.0.tar.gz
| Download URL | setreplace-0.2.0.tar.gz |
|---|---|
| Size | 5.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
90af2f48a97a481040934511ba45bd643b9ff46e8e12c7799199608a958ad017
|
|
BLAKE2b-256 checksum How to use checksums |
cefe9966876bbba4095ff64e448cf2789aa21ad0e3cb42a8e57ddd1a39f5c0c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.
Transparency logRelease files / setreplace-0.2.0-cp39-abi3-win_amd64.whl
| Download URL | setreplace-0.2.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
f80de255844b441b9f617fc6e75709a4bc8bccf62ae0bff8bef3d676c41092d9
|
|
BLAKE2b-256 checksum How to use checksums |
7b3270559f21791ccf76b51d52e124e6ef91a6fc9ea0212a294598773580844b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.
Transparency logRelease files / setreplace-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | setreplace-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
62e75176152cd32b5cc83119a24a270748a0e365a1b8a21a0d7988e6c0c6062f
|
|
BLAKE2b-256 checksum How to use checksums |
94a55a327f11d3d14419a5faff7a8f388b4fdbb5e5da8f25dddf259497ec69c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.
Transparency logRelease files / setreplace-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | setreplace-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
45317af87879ab1fb0fc86ca37aea7a40c65170912427f65503c31499e03604d
|
|
BLAKE2b-256 checksum How to use checksums |
9dbda2d57d63fc3559bca6013ef1e240376c276f5bd54d1807de4793f51be948
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.
Transparency logRelease files / setreplace-0.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | setreplace-0.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.9 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2641f8ef3a0aa79d8f427b274b826565a2923be0726e28e022723528f2a5b46a
|
|
BLAKE2b-256 checksum How to use checksums |
5094d4c00d71b3f3d9d557241ad902660af5151a0d208b4dd2c6255a4c67953d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.
Transparency log