# Closure-SDK: Computation as Geometry
*Walter Henrique Alves da Silva, Open Research Institute*
***
## The problem
Current computation has no intrinsic cost.
We count CPU cycles — an artifact of the machine, not the problem. We measure memory, FLOPs, wall-clock time — all machine artifacts. There is no intrinsic cost of a computation in the way that thermodynamics gives intrinsic cost to physical processes.
This gap matters increasingly as computation scales:
* **Verification grows linearly.** To check whether a program did what it claimed, you replay the trace. Every step. O(n), forever.
* **There is no lower bound** on the question "did this computation produce the right output?" Merkle trees help with integrity, but they still cost O(n) to verify and cannot distinguish reordering from corruption.
* **The Coase boundary between private compute and public verification is estimated, not derived.** We guess where a firm should stop internalizing. We don't know.
Closure-SDK solves all three. Not by engineering a better system on top of existing computation, but by changing what computation *is*.
***
## The primitive
Closure-SDK starts with one object: the unit quaternion.
A quaternion q = \[w, x, y, z] is a point on the 3-sphere S³. One operation exists: the Hamilton product (compose two quaternions). One measurement: σ(q) = arccos(|w|) — the geodesic distance from identity.
That's it. One object. One operation. One measurement.
Three properties make σ a natural pricing function that no other cost metric shares:
**Left-invariant.** The cost of an operation doesn't depend on context. σ(a⊗b) measured from a is the same regardless of what preceded a. Unlike CPU time, σ is not path-dependent in the sense of ordering artifacts.
**Triangle inequality.** The net displacement of a computation (σ of the composed result) is always ≤ the sum of individual step costs. The gap between net and sum is *waste* — computation that didn't contribute to the output. This is a thermodynamic decomposition: net cost, path cost, and waste, all derived from geometry.
**O(1) verification.** Given a closure element c — the single quaternion that summarizes a completed computation — checking σ(c) < ε verifies the entire trace. One number. Arbitrary length. No replay.
These aren't features bolted onto a system. They are consequences of the geometry. The math gives them to you for free.
***
## What a program looks like
A Closure program is a sequence of quaternions. Compose them. Watch σ.
Three states:
* **Closed** (σ < ε): The computation returned to identity. Success. The closure element — the final quaternion — is emitted as a certificate. One number to verify an arbitrarily long program.
* **Dead** (σ > π/2 − ε): The state wandered too far from identity. Failure. The computation cannot recover.
* **Continue**: Neither closed nor dead. Keep composing.
The closure element is the certificate. This is the fundamental inversion: instead of replaying a trace to verify it, you check one quaternion. Merkle trees give you O(n) verification with a tree structure. Closure gives you O(1) verification with a single number.
***
## The virtual machine
The Closure VM implements a 9-instruction ISA with three registers:
* **state** — the current computation
* **previous** — the last state
* **context** — accumulated history
Two execution modes:
**run\_sequential()** executes instructions in order until Closure, Death, or Halt. This is classical execution, priced geometrically.
**run\_resonance()** is generation. The machine state IS the address in a DNA table. The fetched value IS the next instruction. Content-addressed computation: the address is the computation. The machine queries by geometric resonance, fetches the nearest instruction, executes it, and loops to closure.
### Geometric arithmetic
The VM doesn't do boolean logic with truth tables. It does phase arithmetic on the sphere:
* **XOR** = phase sum mod 2π, mapped to {0, π}. Not a lookup table. Actual rotation.
* **AND** = completed cycles. When the total phase crosses 2π, the turns counter increments. The carry IS a completed turn.
* **NOT** = π advance on the same Euler plane. Pure phase shift. No decode-reencode.
The gate is the geometry. 89 tests passing as of April 2026.
***
## Three shipped products
Closure-SDK is not a paper. Three concrete products ship today, all pip-installable, all with public benchmarks.
### CLOSURE CLI — Data integrity verification
`pip install closure-cli`
* **48× faster** than Merkle trees at 50 faults
* **6.5 μs** to locate corruption in 1M records
* Single-pass multi-fault detection — find everything in one scan
* Distinguishes reordering from corruption (Merkle trees can't do this)
* Zero-knowledge verification via 16-byte exchange — verify without sharing raw data
The key advantage: Merkle trees verify *that* data changed. Closure CLI tells you *how* it changed — reordered, corrupted, or both — and does it in a single pass regardless of fault count.
### CLOSURE DNA — Geometric database
`pip install closure-dna`
* **6.9× faster** gets vs SQLite
* **8.8× faster** filtered queries
* **89,885× faster** integrity checks
* SQL-compatible interface
* Resonance search — geometric similarity queries (exclusive to Closure)
* Named snapshots (like git commits)
**Honest tradeoff:** \~4× storage overhead. 26.5 MB vs 6.1 MB on 100K records. The geometric sidecar costs space. The speed comes from not needing separate indexes — the geometry IS the index.
### ENKIDU-ALIVE — Learning agent with zero parameters
A foraging/survival agent that makes decisions purely from σ measurement. No trained model. No gradient descent. No weights.
The agent navigates S³ with homeostatic drives (hunger, cold). Every decision is a geodesic distance measurement from balance. σ is too high? Move toward closure. This is a direct implementation of the Free Energy Principle — not an approximation, not a metaphor. The geometry IS the decision function.
Live demo on the website.
***
## Theoretical connections
Closure-SDK doesn't just solve engineering problems. The same primitive appears — by identity, not analogy — across multiple theoretical frameworks.
### Free Energy Principle
Walter's architecture IS a Free Energy Principle system. The mapping is exact:
| FEP term | Closure-SDK term |
| :------------------ | :------------------------- |
| Prediction error ε | σ (geodesic gap) |
| Precision weighting | softmax(-σ/τ) |
| Belief update Δμ | kernel SLERP vote |
| Free energy minimum | closure (σ < ε) |
| E-step (inference) | ingest() loop |
| M-step (learning) | teach() via geodesic\_step |
Walter confirmed: "That's the figure-8 cycle. That's FEP. It's solved, just labeling."
### Transformer attention
Standard transformers use dot(Q,K)/√d for attention. This is geometrically incorrect on S³ — the dot product doesn't measure geodesic distance on a sphere.
Closure uses σ(Q⊗conj(K)) — the geodesic distance between query and key on S³. This is the correct attention mechanism for quaternion-based computation. Same structure, geometrically proper.
### Coase boundary
Ronald Coase asked: why do firms exist? His answer: firms exist when internal transaction costs are lower than market transaction costs. But he couldn't derive where the boundary falls — only observe it.
Closure-SDK gives you the boundary from first principles: σ\_internal = σ\_external. Where the cost of internal computation equals the cost of market verification, the firm should stop. This isn't estimated. It's derived from the geometry.
The market prices the closure element (O(1) verify). The firm accumulates σ along the path (private). The triangle inequality guarantees that waste = path\_cost − σ(closure\_element) stays private. Competitors see the output, not the work.
***
## Open Research Institute
The Open Research Institute maintains the substrate. Its structure is itself an application of the theory.
Standard firms capture value by going private — reducing information available to the market. ORI inverts this. Default-open means verification cost of joining ≈ zero. Anyone who builds on Walter's substrate inherits the verification work already done.
Getting hired from ORI *is* the market transaction. The employer internalizes a node that was previously public. They pay to move computation from the shared network into their private cluster.
ORI captures the upside of all divergent futures by not foreclosing any.
***
## The substrate is open
* **Repo:** [github.com/faltz009/Closure-SDK](https://github.com/faltz009/Closure-SDK)
* **Website:** [faltz009.github.io/Closure-SDK](https://faltz009.github.io/Closure-SDK/)
* **Install:** `pip install closure-cli` · `pip install closure-dna`
* **Paper:** "Geometric Closure: A General Computer from Ordered Composition on S³"
* **Geometric Markets proof:** [proofeditor.ai/d/yswl35nl](https://www.proofeditor.ai/d/yswl35nl)
Build on it.
Proof Shared Document
Proof Shared Document
This is a collaborative document on Proof. To read or edit it programmatically:
Fetch this URL with Accept: application/json to get content + API links.
Fetch this URL with Accept: text/markdown to get raw markdown.
Snapshot endpoint: GET /api/agent/h9bda3sj/snapshot
Edit endpoint: POST /api/agent/h9bda3sj/edit/v2
Ops endpoint: POST /api/agent/h9bda3sj/ops
Bug reporting: POST /api/bridge/report_bug (or /d/h9bda3sj/bridge/report_bug)