Skip to main content

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.

PyPI Version


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:


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

Metadata

Release files for constraint-theory-sdk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for constraint-theory-sdk 0.1.0
File Size Uploaded Provenance Actions
constraint_theory_sdk-0.1.0.tar.gz 6.2 kB Without provenance Details for constraint_theory_sdk-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for constraint-theory-sdk 0.1.0
File Interpreter ABI Platform Actions
constraint_theory_sdk-0.1.0-py3-none-any.whl Python 3 none any Details for constraint_theory_sdk-0.1.0-py3-none-any.whl

Total release size: 12.0 kB

Release files / constraint_theory_sdk-0.1.0.tar.gz

Download URL constraint_theory_sdk-0.1.0.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d2e5f5cebe8ee787300b04fae1ff8f1fa44d2b41ce14af52653749c3bd36911a
BLAKE2b-256 checksum
How to use checksums
107bfa07ce20ebeb50385ebbe69a62d13ca216076d13ec6035fe098fa1815c81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / constraint_theory_sdk-0.1.0-py3-none-any.whl

Download URL constraint_theory_sdk-0.1.0-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bde58d3cf6702423db628550ee7be4382087106d37912ba100b741a6c8af5a8d
BLAKE2b-256 checksum
How to use checksums
c3db1363ba12e8396e44ec4f0b2c5ff50c2d4e039da69006d0a988032e0a9295
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for constraint-theory-sdk 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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