Skip to main content

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.

1500 events of the Wolfram Physics Project announcement's rule

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


Download files

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

Source Distribution

setreplace-0.1.0.tar.gz (5.7 MB view details)

Uploaded Source

Built Distributions

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

setreplace-0.1.0-cp39-abi3-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.9+Windows x86-64

setreplace-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

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

setreplace-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.9 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

setreplace-0.1.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (3.5 MB view details)

Uploaded CPython 3.9+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file setreplace-0.1.0.tar.gz.

File metadata

  • Download URL: setreplace-0.1.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

Hashes for setreplace-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7a7d08e04d379f42ec670bbdc328dc812f88dd60a223a1112ebf72cc8178551c
MD5 596b04489a891628151d93d9fed21fe4
BLAKE2b-256 391ad6badad07121c7e67983097b3ababce5f53301dacb83048954cc2b3933f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for setreplace-0.1.0.tar.gz:

Publisher: release.yml on kovasb/setreplace-py

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

File details

Details for the file setreplace-0.1.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: setreplace-0.1.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.6 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

Hashes for setreplace-0.1.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 90faef260571515326fa553b4dbfad11103e72551d8077ad2ca05a97870cb32c
MD5 a54254851b1624e2f2c145d2ea735001
BLAKE2b-256 22ca1ad15c34e993454a6c0d05905925485e58d8bc11c82060a1484addcb2536

See more details on using hashes here.

Provenance

The following attestation bundles were made for setreplace-0.1.0-cp39-abi3-win_amd64.whl:

Publisher: release.yml on kovasb/setreplace-py

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

File details

Details for the file setreplace-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for setreplace-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 30ebb819d08998a47eb3e75cb7a3189d20659a055956f6fa371c32f40303a577
MD5 5202daffe0c2789a2bf08c3c21e0b097
BLAKE2b-256 62b499161e346964b518eede2c5b9bee1e2109dc0ac0599021be0ca24b402273

See more details on using hashes here.

Provenance

The following attestation bundles were made for setreplace-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on kovasb/setreplace-py

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

File details

Details for the file setreplace-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for setreplace-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c8684614941d5b2ee4016f18c5fe9952c63be31d631e92e70aac2108fa93a2fc
MD5 ee712d3c45027b871d50a19764bf9d2d
BLAKE2b-256 ad4560fd457e80ce2758e76e66942753f9cc63cbe9c66b2ad6dc9020e6a60edc

See more details on using hashes here.

Provenance

The following attestation bundles were made for setreplace-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on kovasb/setreplace-py

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

File details

Details for the file setreplace-0.1.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for setreplace-0.1.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 d2d74e36bce2350c31682e002f26a5ac0801a97f986b43ad1e243b17e51866d8
MD5 c4b25742382fd6ae6ea7e6533473d14e
BLAKE2b-256 d6dda028d10534e223ab0171ddbfd2baf77c2c729a7eda489929c5fb5580fb4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for setreplace-0.1.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: release.yml on kovasb/setreplace-py

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page