Wolfram models in Python: SetReplace-exact hypergraph substitution and HypergraphPlot-style rendering, powered by Rust
Project description
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.
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 Distributions
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 setreplace-0.2.0.tar.gz.
File metadata
- Download URL: setreplace-0.2.0.tar.gz
- Upload date:
- Size: 5.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90af2f48a97a481040934511ba45bd643b9ff46e8e12c7799199608a958ad017
|
|
| MD5 |
d631ba52d27fc09a60acf9aff790d6c0
|
|
| BLAKE2b-256 |
cefe9966876bbba4095ff64e448cf2789aa21ad0e3cb42a8e57ddd1a39f5c0c7
|
Provenance
The following attestation bundles were made for setreplace-0.2.0.tar.gz:
Publisher:
release.yml on kovasb/setreplace-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
setreplace-0.2.0.tar.gz -
Subject digest:
90af2f48a97a481040934511ba45bd643b9ff46e8e12c7799199608a958ad017 - Sigstore transparency entry: 1784627655
- Sigstore integration time:
-
Permalink:
kovasb/setreplace-py@bddeeeefa7a96f6880995969935b99962dd01b6d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/kovasb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bddeeeefa7a96f6880995969935b99962dd01b6d -
Trigger Event:
push
-
Statement type:
File details
Details for the file setreplace-0.2.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: setreplace-0.2.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f80de255844b441b9f617fc6e75709a4bc8bccf62ae0bff8bef3d676c41092d9
|
|
| MD5 |
a5bce5009fb4c94914afaff225f48ac3
|
|
| BLAKE2b-256 |
7b3270559f21791ccf76b51d52e124e6ef91a6fc9ea0212a294598773580844b
|
Provenance
The following attestation bundles were made for setreplace-0.2.0-cp39-abi3-win_amd64.whl:
Publisher:
release.yml on kovasb/setreplace-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
setreplace-0.2.0-cp39-abi3-win_amd64.whl -
Subject digest:
f80de255844b441b9f617fc6e75709a4bc8bccf62ae0bff8bef3d676c41092d9 - Sigstore transparency entry: 1784627937
- Sigstore integration time:
-
Permalink:
kovasb/setreplace-py@bddeeeefa7a96f6880995969935b99962dd01b6d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/kovasb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bddeeeefa7a96f6880995969935b99962dd01b6d -
Trigger Event:
push
-
Statement type:
File details
Details for the file setreplace-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: setreplace-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62e75176152cd32b5cc83119a24a270748a0e365a1b8a21a0d7988e6c0c6062f
|
|
| MD5 |
92014d4710c683829de3cca17f15dcd9
|
|
| BLAKE2b-256 |
94a55a327f11d3d14419a5faff7a8f388b4fdbb5e5da8f25dddf259497ec69c7
|
Provenance
The following attestation bundles were made for setreplace-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on kovasb/setreplace-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
setreplace-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
62e75176152cd32b5cc83119a24a270748a0e365a1b8a21a0d7988e6c0c6062f - Sigstore transparency entry: 1784627836
- Sigstore integration time:
-
Permalink:
kovasb/setreplace-py@bddeeeefa7a96f6880995969935b99962dd01b6d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/kovasb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bddeeeefa7a96f6880995969935b99962dd01b6d -
Trigger Event:
push
-
Statement type:
File details
Details for the file setreplace-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: setreplace-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45317af87879ab1fb0fc86ca37aea7a40c65170912427f65503c31499e03604d
|
|
| MD5 |
6b92310b96c31e01261d13d0315511cd
|
|
| BLAKE2b-256 |
9dbda2d57d63fc3559bca6013ef1e240376c276f5bd54d1807de4793f51be948
|
Provenance
The following attestation bundles were made for setreplace-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on kovasb/setreplace-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
setreplace-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
45317af87879ab1fb0fc86ca37aea7a40c65170912427f65503c31499e03604d - Sigstore transparency entry: 1784627762
- Sigstore integration time:
-
Permalink:
kovasb/setreplace-py@bddeeeefa7a96f6880995969935b99962dd01b6d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/kovasb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bddeeeefa7a96f6880995969935b99962dd01b6d -
Trigger Event:
push
-
Statement type:
File details
Details for the file setreplace-0.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.
File metadata
- Download URL: setreplace-0.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.9+, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2641f8ef3a0aa79d8f427b274b826565a2923be0726e28e022723528f2a5b46a
|
|
| MD5 |
4ace9980921eaf4023a9ed7ca5cc252e
|
|
| BLAKE2b-256 |
5094d4c00d71b3f3d9d557241ad902660af5151a0d208b4dd2c6255a4c67953d
|
Provenance
The following attestation bundles were made for setreplace-0.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:
Publisher:
release.yml on kovasb/setreplace-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
setreplace-0.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl -
Subject digest:
2641f8ef3a0aa79d8f427b274b826565a2923be0726e28e022723528f2a5b46a - Sigstore transparency entry: 1784628079
- Sigstore integration time:
-
Permalink:
kovasb/setreplace-py@bddeeeefa7a96f6880995969935b99962dd01b6d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/kovasb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bddeeeefa7a96f6880995969935b99962dd01b6d -
Trigger Event:
push
-
Statement type: