Python SDK for constraint theory: H¹ cohomology, holonomy, Laman rigidity
Project description
Constraint Theory SDK
Python SDK for constraint theory: H¹ cohomology, holonomy, Laman rigidity
Wraps the core mathematics from FM's constraint theory for use in fleet routing, emergence detection, and graph analysis.
Quick Start
pip install constraint-theory-sdk
from constraint_theory_sdk import compute_h1, is_emergence, is_laman_rigid, compute_holonomy
# H¹ cohomology dimension
h1 = compute_h1(n_vertices=10, n_edges=18) # → 9
# H¹ = E - V + H0 = 18 - 10 + 1 = 9
# Check for emergence (β₁ > V-2)
if is_emergence(h1, n_vertices=10):
print("⚠️ Emergence detected — graph is under-constrained")
# Check Laman rigidity
is_rigid, margin = is_laman_rigid(n_vertices=10, n_edges=17)
print(f"Rigid: {is_rigid}, margin: {margin}") # Rigid: True, margin: 0
# Compute holonomy around a cycle
hol = compute_holonomy(
edges=[("A","B"), ("B","C"), ("C","A")],
direction=1.0 # parallel transport angle in radians
)
print(f"Holonomy: {hol:.3f} rad") # Non-zero means curvature
Core Mathematics
H¹ Cohomology
For a constraint graph G = (V, E) with H₀ connected components:
H¹_dim = E - V + H₀
- H¹ = V-2: Laman rigid (minimally constrained, just enough to determine positions)
- H¹ > V-2: Under-constrained (coordination fails — emergence detected)
- H¹ < V-2: Over-constrained (redundant edges)
Emergence Threshold
Emergence when: β₁ > V - 2
Laman Rigidity
A graph is minimally rigid when:
- E = 2V - 3 edges
- No subgraph has more edges than 2V' - 3
Holonomy
Holonomy measures the curvature of the connection around closed loops:
Holonomy = ∮ A·dx (line integral of connection)
In discrete terms: multiply edge connection values around a cycle. Non-zero holonomy means parallel transport doesn't return to original value.
API Reference
compute_h1(n_vertices, n_edges, n_components=1)
from constraint_theory_sdk import compute_h1
h1 = compute_h1(n_vertices=10, n_edges=18, n_components=1)
# Returns: 9
is_emergence(h1, n_vertices, offset=-2)
from constraint_theory_sdk import is_emergence
if is_emergence(h1=12, n_vertices=10):
print("⚠️ Emergence — β₁=12 > V-2=8")
is_laman_rigid(n_vertices, n_edges)
from constraint_theory_sdk import is_laman_rigid
is_rigid, margin = is_laman_rigid(n_vertices=10, n_edges=17)
# is_rigid = True (E = 2*10 - 3 = 17)
# margin = 0 (exactly minimal)
compute_holonomy(edges, direction=1.0)
from constraint_theory_sdk import compute_holonomy
# Edges: list of (node_a, node_b) pairs forming a cycle
holonomy = compute_holonomy(
edges=[("A","B"), ("B","C"), ("C","A")],
direction=1.0
)
FleetGraph
from constraint_theory_sdk import FleetGraph
graph = FleetGraph()
graph.add_nodes(["oracle1", "ccc", "forgemaster"])
graph.add_edge("oracle1", "plato-sync")
graph.add_edge("ccc", "telegram-bot")
graph.add_edge("forgemaster", "llvm-compile")
status = graph.get_status()
print(f"H¹: {status['h1_dimension']}, {status['description']}")
Installation
pip install constraint-theory-sdk
Or from source:
git clone https://github.com/SuperInstance/constraint-theory-sdk.git
cd constraint-theory-sdk
pip install -e .
Related Research
This SDK implements the constraint theory mathematics from:
- FM's constraint_theory_core (SuperInstance/constraint-theory-core) — Rust implementation with full formal proofs
- Fleet Math Foundations (fleet-math-foundations) — Research documentation
- H1 Routing (fleet-h1-router) — Fleet routing driven by H¹ constraints
Citation
If you use this SDK in research, cite:
Cocapn. (2026). Constraint Theory SDK.
https://github.com/SuperInstance/constraint-theory-sdk
Based on:
- Forgemaster's constraint theory research (SuperInstance)
- Laman, G. (1972). On graphs and the rigidity of plane skeletal structures.
- Barrett, T.W. et al. (2025). Holonomy and curvature in agent coordination frameworks.
License
Apache 2.0
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 constraint_theory_sdk-0.1.0.tar.gz.
File metadata
- Download URL: constraint_theory_sdk-0.1.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2e5f5cebe8ee787300b04fae1ff8f1fa44d2b41ce14af52653749c3bd36911a
|
|
| MD5 |
172d726f930ba14c6fe0551f31bf9f03
|
|
| BLAKE2b-256 |
107bfa07ce20ebeb50385ebbe69a62d13ca216076d13ec6035fe098fa1815c81
|
File details
Details for the file constraint_theory_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: constraint_theory_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bde58d3cf6702423db628550ee7be4382087106d37912ba100b741a6c8af5a8d
|
|
| MD5 |
cf2e576fae543f6bc44df9e85a972d60
|
|
| BLAKE2b-256 |
c3db1363ba12e8396e44ec4f0b2c5ff50c2d4e039da69006d0a988032e0a9295
|