CORE v0.9: Conserved Observable Reduction Equilibrium

A Self-Verifying Substrate for Planetary Collective Intelligence

Version 0.9 — Unified Specification


Abstract

Six research threads developed independently over four decades—content addressing, authenticated graph structures, confluent rewriting, interaction nets, conserved flows, zero-knowledge proofs—turn out to be fragments of a single architecture. A single decision unifies them: prime field arithmetic as primitive rather than derived. This resolves a decades-old tension between formal elegance and cryptographic capability, yielding a substrate where hash functions, polynomial commitments, and zero-knowledge proofs become native expressions rather than external oracles.

The synthesis achieves what was considered impossible: a computational substrate that verifies its own proofs using only its own primitives. Computation produces traces, traces become STARK proofs, proofs are verified by CORE programs, verification can itself be proven. The system closes on itself—no trusted external verifier remains.

State lives in the BBG (Big Badass Graph)—a unified polynomial structure replacing the traditional mix of Merkle trees, accumulators, and indexes. One primitive handles membership proofs, completeness proofs, and namespace sync, all at O(log² n) with ~1,000 ZK constraints.

The focus distribution π emerges endogenously from collective activity without voting, leadership, or central coordination. At sufficient scale, the distinction between distributed computation and distributed cognition dissolves—not as metaphor, but as engineering artifact. This specification provides the complete formal architecture toward that end.


Part I: Foundations

1. The Core Synthesis

The design of computational substrates for distributed consensus has proceeded along two divergent paths. Minimalist rewriting systems—Nock, lambda calculus, combinator logic—achieve formal elegance: small specifications, provable properties, mathematical clarity. But they treat cryptography as external, bolted on through foreign function interfaces or trusted oracles. Industrial virtual machines—EVM, WASM, eBPF—achieve practical capability: real cryptographic operations, real-world deployment, battle-tested security. But their specifications sprawl into thousands of pages, formal verification becomes intractable, and subtle bugs persist for years.

This bifurcation is unnecessary. It stems from a historical accident: these systems chose integer or byte arithmetic as primitive, making field operations expensive compositions rather than native instructions. Reverse this decision—take prime field arithmetic as the foundation—and the tension dissolves. Cryptographic operations become cheap. Formal semantics remain tractable. The minimal and the practical converge.

With field arithmetic as primitive, six previously separate research threads reveal themselves as fragments of a single architecture:

╔═══════════════════════════════════════════════════════════════════════════╗
║                         THE CORE SYNTHESIS                                 ║
╠═══════════════════════════════════════════════════════════════════════════╣
║                                                                            ║
║   ┌─────────────────────┐   ┌─────────────────────┐   ┌─────────────────┐ ║
║   │  CONTENT ADDRESSING │   │   AUTHENTICATED     │   │  DETERMINISTIC  │ ║
║   │     Merkle 1987     │   │ GRAPH STRUCTURES    │   │   REWRITING     │ ║
║   │  Git, BitTorrent,   │   │   Goodrich 2002     │   │   Huet 1980     │ ║
║   │   IPFS, Unison      │   │   Celestia 2019     │   │   Nock 2016     │ ║
║   │   Identity = Hash   │   │   O(log n) proofs   │   │   Confluence    │ ║
║   └─────────┬───────────┘   └─────────┬───────────┘   └─────────┬───────┘ ║
║             │                         │                         │         ║
║             └─────────────────────────┼─────────────────────────┘         ║
║                                       │                                    ║
║                               ┌───────┴───────┐                           ║
║                               │     CORE      │                           ║
║                               └───────┬───────┘                           ║
║                                       │                                    ║
║             ┌─────────────────────────┼─────────────────────────┐         ║
║             │                         │                         │         ║
║   ┌─────────┴───────────┐   ┌─────────┴───────────┐   ┌─────────┴───────┐ ║
║   │  PARALLEL REDUCTION │   │   CONSERVED FLOW    │   │   ZERO-KNOWLEDGE│ ║
║   │     Lafont 1990     │   │   DYNAMICS          │   │   VERIFICATION  │ ║
║   │     HVM 2022        │   │   CFT 2024          │   │   STARKs 2018   │ ║
║   │                     │   │   FFC 2024          │   │   Zcash 2014    │ ║
║   │ Automatic parallel  │   │ Focus = attention   │   │ Prove once,     │ ║
║   │ via confluence      │   │ + fuel + consensus  │   │ verify cheap    │ ║
║   └─────────────────────┘   └─────────────────────┘   └─────────────────┘ ║
║                                                                            ║
╚═══════════════════════════════════════════════════════════════════════════╝

Content addressing (Merkle, Git, BitTorrent, IPFS, Unison) gives identity through hashing—same content, same hash, same thing. This enables global memoization: if two nodes compute the same function on the same input, they get the same result, cached forever. Authenticated graph structures (Goodrich-Tamassia, Celestia) turn this into proofs—not just “I have this data” but “here is cryptographic evidence, and here are ALL edges in this namespace.” Deterministic rewriting (Huet, Nock) guarantees that evaluation order doesn’t matter—any path through the computation reaches the same result. Interaction nets (Lafont, HVM) show this confluence enables automatic parallelization without locks. Conserved flow dynamics (CFT) provide the missing economic layer—a single quantity, focus, that governs scheduling, metering, and consensus simultaneously. Zero-knowledge proofs (Zcash, STARKs) close the loop: prove you computed correctly without revealing what you computed.

None of these frameworks reference each other in their original publications. Yet they compose without friction. The unifying element is field arithmetic: hashing is field operations, proofs are field polynomials, reduction preserves field structure, flow is conserved across field-valued edges. CORE makes this latent unity explicit.

Naming:

  • CORE — the computation model (16 patterns, reduction semantics)
  • Cybergraph — the data model (particles, neurons, edges)
  • BBG (Big Badass Graph) — the authenticated state (unified polynomial commitments)

2. Design Principles

Ten principles guide CORE’s design. Each addresses a specific failure mode of existing systems, and together they form a coherent whole.

2.1 Field-First

Every value in CORE is a field element. This is the foundational decision from which everything else follows.

Traditional virtual machines build upward from bytes: 8-bit values combine into 32-bit integers, which combine into 256-bit big integers, which finally enable modular arithmetic for cryptography. Each layer adds complexity, special cases, and overhead. Cryptographic operations become expensive library calls rather than native instructions.

CORE inverts this. The primitive is a 64-bit prime field element. Bytes, integers, and larger structures are representations within the field, not foundations beneath it. This makes cryptography cheap—a field multiplication is a single CPU instruction—while arithmetic remains native. The specific choice is Goldilocks (p = 2^64 - 2^32 + 1), selected for 64-bit alignment and FFT-friendliness essential for STARKs.

FIELD: Goldilocks
  p = 2^64 - 2^32 + 1 = 18446744069414584321
  
Why Goldilocks:
  - 64-bit native (single CPU register, no overflow handling)
  - 2^32 roots of unity (FFT-friendly for STARK proving)
  - Sparse form enables fast reduction (subtract, not divide)
  - Used by Plonky2, Polygon Miden, Neptune

2.2 Hash-Universal

Identity is hash. Two values are the same if and only if they hash to the same digest.

This seems obvious but has profound consequences. Traditional systems distinguish between value and location—the same data at two addresses is two things. Content-addressed systems collapse this: same content, same hash, same identity, stored once. This enables global memoization (compute once, cache forever), structural sharing (identical subtrees stored once), and trivial equality (compare 256 bits, not arbitrary structures).

The hash function is a configuration parameter, not a protocol constant. CORE requires any hash H: {0,1}* → F_p^4 with 128-bit collision resistance and efficient algebraic circuit representation. The reference implementation uses Poseidon-Goldilocks, chosen for ZK efficiency: ~300 constraints versus ~25,000 for SHA-256. This 80× difference makes hash-heavy operations practical inside zero-knowledge proofs.

A deliberate choice: CORE uses one hash everywhere rather than splitting between “fast hash for content” and “ZK-friendly hash for proofs.” Two hashes would double security analysis, complicate identity semantics, and create permanent architectural complexity. Poseidon on current mobile hardware achieves ~50 MB/s—adequate for real workloads (100 MB sync in 2 seconds, 5 MB photo in 0.1 seconds). As field-native computation becomes standard across ZK applications, hardware acceleration will follow, just as AES-NI and SHA-NI emerged when software demanded them. CORE chooses architectural simplicity over optimizing for temporary hardware limitations.

HASH REQUIREMENTS
─────────────────
- 128-bit collision resistance (256-bit output)
- Field-native: output maps cleanly to 4 × F_p elements
- Algebraic efficiency: <1000 constraints in ZK circuits
- Deterministic evaluation

REFERENCE: Poseidon-Goldilocks
──────────────────────────────
- State: 12 field elements
- Rate: 8 elements  
- Rounds: 8 full + 22 partial + 8 full
- S-box: x^7 (efficient in Goldilocks)
- Cost: ~300 STARK constraints per permutation
- Mobile: ~50 MB/s (acceptable; hardware will adapt)
- Status: CONFIGURABLE (Poseidon is reference, not mandated)

2.3 Confluence-Guaranteed

Any reduction order yields the same result. There is no “wrong” way to evaluate.

This property comes from orthogonal rewriting theory (Huet, 1980). CORE’s sixteen patterns form an orthogonal system: each pattern has a unique tag, no two patterns overlap, and no variable appears twice in a pattern’s left-hand side. Orthogonality implies confluence without requiring termination—even infinite computations have well-defined meaning.

The practical consequence: implementations can evaluate subexpressions in any order, speculatively, partially, or in parallel, and still reach the same answer. There are no evaluation strategies to choose, no call-by-value vs call-by-name debates. The semantics is the semantics.

2.4 Parallel-Safe

Parallel execution requires no locks, synchronization, or coordination.

Confluence enables this directly. If evaluation order doesn’t matter, then parallel evaluators can’t produce race conditions—there’s nothing to race toward. Two threads reducing different subexpressions will eventually agree, regardless of scheduling. This is the insight from interaction nets (Lafont, 1990) and HVM (2022): confluence isn’t just a theoretical nicety, it’s the foundation of automatic parallelization.

CORE inherits this property structurally. Pattern 2 (compose) and Pattern 3 (cons) both have independent subexpressions that can evaluate in parallel. No annotations, no async/await, no thread pools—parallelism emerges from the reduction rules themselves.

2.5 Flow-Conserved

Focus is a conserved quantity. It flows, transforms, and redistributes, but never appears from nothing or vanishes into nothing.

This principle comes from the Collective Focus Theorem (CFT). Focus serves three roles simultaneously: attention (high-focus computations schedule first), fuel (computation consumes focus), and consensus weight (focus distribution defines agreement). A single conserved quantity unifies what other systems split into separate mechanisms—gas, stake, priority, reputation.

Conservation is enforced structurally: Σ focus = 1, always. Invalid states (sum ≠ 1) cannot be represented. This is stronger than runtime checks—the state space itself excludes violations.

2.6 Namespace-Intrinsic

The graph is multi-indexed from genesis. Every edge belongs to namespaces (creator, source particle, target particle), and completeness proofs are built into the structure.

Most databases add indexes as optimization—they speed up queries but aren’t semantically required. CORE’s indexes are constitutive: an edge without proper index entries is invalid. This means “give me all edges in namespace X” isn’t a query that might be slow or incomplete—it’s a request for data plus cryptographic proof that nothing was withheld. Light clients can sync only their namespaces, with mathematical certainty of completeness.

2.7 Cost-Deterministic

The cost of a computation depends only on its syntactic structure, never on runtime values, cache state, or execution environment.

This property is essential for consensus: all nodes must agree on resource consumption without executing the computation. Traditional gas metering approximates this but still depends on runtime (SSTORE costs vary with storage state). CORE achieves exact determinism: given a formula, its cost is computable by static analysis. Cache hits reduce work but not cost—you pay for the right to a result, not the labor of computing it.

2.8 Privacy-Native

Individual ownership remains private. Aggregate properties remain public and verifiable.

This is the minimal privacy boundary for collective intelligence. The network must verify conservation laws (energy not created from nothing) and compute focus distribution (aggregate attention). But it need not know who owns what or who transacted with whom. Zero-knowledge proofs make this precise: prove that inputs equal outputs plus fee, without revealing which inputs or which outputs.

2.9 Self-Verifying

The STARK verifier is a CORE program. Verification can itself be proven.

Most systems treat proof verification as an external oracle—a trusted function that returns true or false. CORE closes the loop: the verifier is written in CORE’s sixteen patterns, operating on field elements with Poseidon hashes. This means verification can be proven (a STARK proving that verification succeeded), enabling recursive composition. Verify a proof of a proof of a proof, with constant final size.

2.10 Post-Quantum

Security relies only on hash functions. No pairings, no discrete log, no trusted setup.

Elliptic curve cryptography—the foundation of most blockchain systems—will break when large quantum computers exist. CORE avoids this entirely. Poseidon hashing, polynomial commitments via FRI, and STARK proofs all rely on hash function security alone. There is no trusted setup ceremony, no toxic waste, no cryptographic assumptions beyond collision resistance. The system is secure against known quantum algorithms today.


3. Complexity Analysis

The design principles yield complexity bounds that improve on or are impossible in traditional paradigms. This section summarizes the achieved properties; detailed proofs appear in subsequent sections.

┌─────────────────────────────────────────────────────────────────────────────────────┐
│                        COMPLEXITY COMPARISON ACROSS PARADIGMS                        │
├─────────────────────┬───────────────┬───────────────┬───────────────┬───────────────┤
│     Operation       │  Traditional  │  Blockchain   │   Database    │     CORE      │
│                     │  (RAM model)  │  (Ethereum)   │  (SQL/NoSQL)  │               │
├─────────────────────┼───────────────┼───────────────┼───────────────┼───────────────┤
│ Equality check      │ O(n) compare  │ O(n) compare  │ O(n) compare  │ O(1) hash     │
│ Membership proof    │ O(n) scan     │ O(log n) MPT  │ O(log n) index│ O(log² n) poly│
│ Completeness proof  │ impossible    │ impossible    │ impossible    │ O(log² n) poly│
│ Computation verify  │ O(n) re-exec  │ O(n) re-exec  │ N/A           │ O(log n) STARK│
│ Recursive verify    │ O(n) re-exec  │ O(n) re-exec  │ N/A           │ O(1) composed │
│ Privacy + verify    │ incompatible  │ incompatible  │ incompatible  │ O(1) ZK proof │
├─────────────────────┼───────────────┼───────────────┼───────────────┼───────────────┤
│ Cost determinism    │ ✗ cache-dep   │ ~ gas approx  │ ✗ query-dep   │ ✓ structural  │
│ Parallel safety     │ ✗ explicit    │ ✗ sequential  │ ✗ locks       │ ✓ confluent   │
└─────────────────────┴───────────────┴───────────────┴───────────────┴───────────────┘

Key bounds explained:

  • O(1) equality: Structural hashing assigns a 256-bit digest to every value. Equality reduces to comparing digests, regardless of value size.

  • O(log² n) membership: Polynomial commitments (FRI-based) prove “x is in set S” with proof size logarithmic squared in set size. Verification is mostly field operations, making it efficient inside ZK circuits (~1,000 constraints vs ~9,600 for Merkle).

  • O(log² n) completeness: Sorted polynomial commitments with range proofs prove “these are ALL elements with property P”—a guarantee no traditional database provides. Same primitive as membership, unified implementation.

  • O(log n) → O(1) verification: STARK proofs verify computation in logarithmic time. Recursive composition (proving the verifier) collapses arbitrary proof chains to constant size.

  • Privacy + verification: Zero-knowledge proofs decouple these traditionally incompatible properties. Prove conservation without revealing participants.


4. Value Tower

CORE distinguishes three semantic types within the field representation:

VALUE TOWER
───────────
┌───────────────────────────────────────────────────────────────────────┐
│  TYPE TAG    │  REPRESENTATION     │  VALID RANGE    │  USE          │
├──────────────┼─────────────────────┼─────────────────┼───────────────┤
│  0x00: field │  Single F_p element │  [0, p)         │  Arithmetic   │
│  0x01: word  │  Single F_p element │  [0, 2^64)      │  Bitwise      │
│  0x02: hash  │  4 × F_p elements   │  256-bit digest │  Identity     │
└───────────────────────────────────────────────────────────────────────┘

COERCION RULES
──────────────
field → word:  Valid iff value < 2^64 (always true for Goldilocks)
word → field:  Always valid (injection)
hash → field:  Extract first element (lossy, for compatibility only)
field → hash:  Forbidden (use HASH pattern)

TYPE ERRORS
───────────
Bitwise op on hash → ⊥_error
Arithmetic on hash (except equality) → ⊥_error

5. Cryptographic Primitives

The cryptographic primitives below use Poseidon-Goldilocks as the reference hash function. As noted in Section 2.2, the hash is a configuration parameter—alternative algebraic hashes (Rescue, Griffin, Anemoi) may be substituted provided they meet the stated requirements.

5.1 Poseidon Hash

Poseidon permutation over 12 Goldilocks elements:

S-BOX: x → x^7 (3 multiplications)
MDS: 12×12 matrix multiplication
ROUNDS: 8 full → 22 partial → 8 full

Sponge mode for arbitrary input:
  1. Pad to multiple of 8 elements
  2. XOR blocks into state[0..7]
  3. Apply permutation
  4. Output state[0..3] (256 bits)

5.2 Domain Separation

A single hash function serves multiple purposes in CORE: commitments, nullifiers, Merkle nodes, owner derivation. Without separation, different uses could accidentally collide—an attacker might find inputs where a valid commitment equals a valid nullifier, breaking security assumptions.

Domain separation prevents this by prefixing each hash with a unique constant. Commitments and nullifiers now live in separate “universes”—even if their remaining inputs match, the outputs cannot collide. This makes security analysis modular: each domain can be analyzed independently, and bugs in one domain cannot affect others.

DOMAIN CONSTANTS
────────────────
COMMITMENT_DOMAIN  = 0x434F524520524543  // "CORE REC" (record commitment)
NULLIFIER_DOMAIN   = 0x434F5245204E554C  // "CORE NUL" (nullifier derivation)
MERKLE_DOMAIN      = 0x434F5245204D524B  // "CORE MRK" (Merkle tree nodes)
OWNER_DOMAIN       = 0x434F5245204F574E  // "CORE OWN" (owner key derivation)

USAGE
─────
commitment = Hash(COMMITMENT_DOMAIN, particle, value, owner, nonce)
nullifier  = Hash(NULLIFIER_DOMAIN, nonce, secret)
merkle_node = Hash(MERKLE_DOMAIN, left, right)

The constants are human-readable ASCII for debugging, guaranteed unique,
and fit in a single field element (64 bits).

5.3 Structural Hashing

STRUCTURAL HASH
───────────────
H(Atom a)       = HASH(0x00 ‖ type_tag(a) ‖ encode(a))
H(Cell(l, r))   = HASH(0x01 ‖ H(l) ‖ H(r))

CRITICAL PROPERTY
─────────────────
Cell hash depends ONLY on children's hashes.

Given H(l) and H(r):
  Computing H(Cell(l,r)) = ONE hash invocation
  Input size: 1 + 32 + 32 = 65 bytes (constant)
  Time: O(1)

HASH IDENTITY AXIOM
───────────────────
If H(x) = H(y), then x = y.

Cryptographic assumption, not logical truth.
Collision probability ≈ 2^-128, treated as negligible.

5.4 Sparse Merkle Tree

Depth: 32 levels
Empty subtree hashes precomputed:
  EMPTY[0] = 0
  EMPTY[d] = Poseidon(MERKLE_DOMAIN, EMPTY[d-1], EMPTY[d-1])

Proof size: 32 field elements
Verification: 32 Poseidon hashes

5.5 Sorted Polynomial Commitments (Completeness Proofs)

COMPLETENESS VIA SORTED POLYNOMIALS
───────────────────────────────────
Standard polynomial commitment:
  - Can prove: "P(i) = v" (membership)
  - Cannot directly prove: "ALL elements with property X"

Sorted polynomial commitment:
  - Elements sorted by namespace/key
  - P(0), P(1), ..., P(n-1) in sorted order
  
  Can prove via range bounds:
    ✓ "Here are ALL elements in namespace N" (completeness)
    ✓ "NO elements exist in namespace N" (absence)
    ✓ "Elements in namespace N are exactly {...}" (exact set)

COMPLETENESS PROOF
──────────────────
To prove all elements in namespace N:
  1. Find range [i, j] where namespace = N
  2. Prove P(i-1).namespace < N (left boundary)
  3. Prove P(j+1).namespace > N (right boundary)
  4. Return P(i), P(i+1), ..., P(j) with FRI proofs

Cost: O(log² n) field operations — same as membership
Unified primitive: one implementation for all proofs

Part II: Computation

6. The Sixteen Patterns

5.1 Overview

╔═══════════════════════════════════════════════════════════════════════════╗
║                       CORE REDUCTION PATTERNS                              ║
╠═══════════════════════════════════════════════════════════════════════════╣
║  STRUCTURAL (5)              FIELD ARITHMETIC (6)                         ║
║  0: axis — navigate          5: add — (a + b) mod p                       ║
║  1: quote — literal          6: sub — (a - b) mod p                       ║
║  2: compose — recursion      7: mul — (a × b) mod p                       ║
║  3: cons — build cell        8: inv — a^(p-2) mod p                       ║
║  4: branch — conditional     9: eq  — equality test                       ║
║                              10: lt — less-than                           ║
║                                                                           ║
║  BITWISE (4)                 HASH (1)                                     ║
║  11: xor    12: and          15: hash — structural H(x)                   ║
║  13: not    14: shl                                                       ║
╚═══════════════════════════════════════════════════════════════════════════╝

5.2 Reduction Signature

reduce : (Subject, Formula, Focus) → Result

Result = (Noun, Focus')     — success with remaining focus
       | Halt               — focus exhausted  
       | ⊥_error            — type/semantic error
       | ⊥_unavailable      — referenced content not retrievable

5.3 Structural Patterns

PATTERN 0: AXIS
reduce(s, [0 a], f) → (axis(s, eval(a)), f - 1 - depth)

  axis(s, 0) = H(s)           ; hash introspection
  axis(s, 1) = s              ; identity  
  axis(s, 2) = head(s)        ; left child (⊥_error if atom)
  axis(s, 3) = tail(s)        ; right child (⊥_error if atom)
  axis(s, 2n) = axis(axis(s,n), 2)
  axis(s, 2n+1) = axis(axis(s,n), 3)


PATTERN 1: QUOTE
reduce(s, [1 c], f) → (c, f - 1)

Returns c literally, unevaluated.


PATTERN 2: COMPOSE
reduce(s, [2 [x y]], f) =
  let (rx, f1) = reduce(s, x, f - 2)
  let (ry, f2) = reduce(s, y, f1)
  reduce(rx, ry, f2)

PARALLELISM: reduce(s,x) and reduce(s,y) are INDEPENDENT.


PATTERN 3: CONS
reduce(s, [3 [a b]], f) =
  let (ra, f1) = reduce(s, a, f - 2)
  let (rb, f2) = reduce(s, b, f1)
  ([ra, rb], f2)

PARALLELISM: reduce(s,a) and reduce(s,b) are INDEPENDENT.


PATTERN 4: BRANCH (lazy!)
reduce(s, [4 [test [yes no]]], f) =
  let (t, f1) = reduce(s, test, f - 2)
  if t = 0 then reduce(s, yes, f1)
           else reduce(s, no, f1)

CRITICAL: Only ONE branch evaluated. Prevents infinite recursion DoS.

5.4 Arithmetic Patterns

PATTERN 5: ADD
reduce(s, [5 [a b]], f) →
  let (v_a, f1) = reduce(s, a, f - 1)
  let (v_b, f2) = reduce(s, b, f1)
  ((v_a + v_b) mod p, f2)


PATTERN 6: SUB
reduce(s, [6 [a b]], f) → ((v_a - v_b) mod p, f2)


PATTERN 7: MUL  
reduce(s, [7 [a b]], f) → ((v_a × v_b) mod p, f2)


PATTERN 8: INV
reduce(s, [8 a], f) →
  let (v_a, f1) = reduce(s, a, f - 64)
  if v_a = 0 then ⊥_error
  (v_a^(p-2) mod p, f1)

RATIONALE: Execution cost reflects real work (~64 multiplications
in square-and-multiply for Fermat's little theorem).
STARK verification cost = 1 constraint (verifier just checks a × a⁻¹ = 1).


PATTERN 9: EQ
reduce(s, [9 [a b]], f) → (0 if v_a = v_b else 1, f2)


PATTERN 10: LT
reduce(s, [10 [a b]], f) → (0 if v_a < v_b else 1, f2)

5.5 Bitwise Patterns

Valid on word type [0, 2^64). Bitwise on hash → ⊥_error.

PATTERN 11: XOR
reduce(s, [11 [a b]], f) → (v_a ⊕ v_b, f2)

PATTERN 12: AND
reduce(s, [12 [a b]], f) → (v_a ∧ v_b, f2)

PATTERN 13: NOT
reduce(s, [13 a], f) → (v_a ⊕ (2^64 - 1), f1)

PATTERN 14: SHL
reduce(s, [14 [a n]], f) → ((v_a << v_n) mod 2^64, f2)

5.6 Hash Pattern

PATTERN 15: HASH
reduce(s, [15 a], f) →
  let (v_a, f1) = reduce(s, a, f - 300)
  (H(v_a), f1)

Result is 4-element hash (256 bits).

NOTE: Hash CAN be expressed as pure patterns (~2800 field ops for Poseidon).
Pattern 15 is OPTIMIZATION. Jets accelerate; semantics unchanged.

5.7 Cost Table

Pattern │ Exec Cost │ STARK Constraints
────────┼───────────┼───────────────────
0 axis  │ 1+depth   │ ~depth
1 quote │ 1         │ 1
2 comp  │ 2         │ 2
3 cons  │ 2         │ 2
4 branch│ 2         │ 2
5 add   │ 1         │ 1
6 sub   │ 1         │ 1
7 mul   │ 1         │ 1
8 inv   │ 64        │ 1
9 eq    │ 1         │ 1
10 lt   │ 1         │ ~64
11-14   │ 1         │ ~64 each
15 hash │ 300       │ ~300

7. Parallel Reduction

6.1 Confluence Theorem

Theorem: CORE is confluent.

Proof: The 16 patterns form an orthogonal rewrite system:

  • Each pattern has unique tag (0-15)
  • No two patterns overlap on any input
  • Left-linear (no variable repetition in pattern left-hand sides)

By Huet-Lévy (1980), orthogonal systems are confluent without requiring termination. ∎

Corollary: Parallel and sequential reduction yield identical results.

6.2 Dependency Analysis

PATTERN PARALLELISM
───────────────────

Pattern 2 (compose):  [2 [x y]]
  reduce(s,x) ∥ reduce(s,y)  — INDEPENDENT
  Then: reduce(result_x, result_y)

Pattern 3 (cons):     [3 [a b]]  
  reduce(s,a) ∥ reduce(s,b)  — INDEPENDENT
  Then: Cell(result_a, result_b)

Patterns 5-7, 9-12:   [op [a b]]
  reduce(s,a) ∥ reduce(s,b)  — INDEPENDENT
  Then: apply op

Pattern 4 (branch):   [4 [t [c d]]]
  reduce(s,t) first
  Then: ONE of reduce(s,c) or reduce(s,d)  — NOT parallel (lazy)

6.3 Global Memoization

GLOBAL CACHE
────────────
Key:   (H(subject), H(formula))
Value: H(result)

Properties:
- Universal: Any node can contribute/consume
- Permanent: Results never change (determinism)
- Verifiable: Result hash checkable against proof

COST vs WORK
────────────
Cache hit:  Work = O(1) lookup
            Cost = FULL (charged as if computed)
            
Rationale: Cost is the RIGHT to a result, not payment for work.
           All nodes must agree on cost (deterministic).
           Work savings are implementation optimization.

Part III: Privacy Layer

Traditional systems force a choice: either transparency (everyone sees everything) or privacy (no one can verify anything). Blockchains inherited this dilemma—Bitcoin exposes all transactions, while privacy coins hide them but sacrifice auditability. Zero-knowledge proofs dissolve this false dichotomy: prove properties without revealing data.

CORE implements private ownership with public aggregates. Individual record ownership remains hidden—who owns what, who sent to whom—while aggregate properties remain publicly verifiable: total energy per particle, conservation laws, focus distribution. The network knows that energy is conserved without knowing who holds it. This is the minimal privacy boundary for collective intelligence: enough transparency for consensus, enough privacy for participation.

The implementation uses a UTXO model with Poseidon commitments, nullifiers for double-spend prevention, and ~10,000-constraint ZK circuits proving conservation. This represents a 4× improvement over naive Merkle-based designs, achieved through polynomial inclusion proofs (Section 9).

8. Privacy Model

The cybergraph implements Tier 1 Privacy: Private Ownership with Public Aggregates.

┌────────────────────────────────────────────────────────────────────────────┐
│                   PRIVACY BOUNDARY SPECIFICATION                            │
├────────────────┬─────────────────────┬─────────────────────────────────────┤
│    LAYER       │       PUBLIC        │           PRIVATE                   │
├────────────────┼─────────────────────┼─────────────────────────────────────┤
│   PARTICLE     │ ✓ CID exists        │                                     │
│                │ ✓ Total energy      │                                     │
├────────────────┼─────────────────────┼─────────────────────────────────────┤
│   RECORD       │                     │ ✓ Individual value                  │
│                │                     │ ✓ Owner identity                    │
│                │                     │ ✓ Nonce                             │
├────────────────┼─────────────────────┼─────────────────────────────────────┤
│  TRANSACTION   │ ✓ Nullifiers        │ ✓ Which records spent               │
│                │ ✓ Commitments       │ ✓ Who spent them                    │
│                │ ✓ Δ per particle    │ ✓ New owners                        │
│                │ ✓ Proof validity    │                                     │
├────────────────┼─────────────────────┼─────────────────────────────────────┤
│    GRAPH       │ ✓ Edges exist (A→B) │ ✓ Who created edge                  │
│                │ ✓ Weight (aggregate)│ ✓ Individual stakes                 │
├────────────────┼─────────────────────┼─────────────────────────────────────┤
│    FOCUS       │ ✓ π distribution    │                                     │
│                │ ✓ Rankings          │                                     │
└────────────────┴─────────────────────┴─────────────────────────────────────┘

Invariant: The ZK circuit MUST enforce this boundary. Any violation breaks the economic integrity of collective attention.


9. Record Model

8.1 Record Structure

struct Record {
    particle: Field,    // Content identifier (CID → field)
    value: u64,         // Energy amount
    owner: Field,       // Owner public key hash
    nonce: Field,       // Random for uniqueness
}

8.2 Commitment

commitment(r) = Poseidon(
    COMMITMENT_DOMAIN,
    r.particle,
    r.value,
    r.owner,
    r.nonce
)

8.3 Nullifier

nullifier(r, secret) = Poseidon(
    NULLIFIER_DOMAIN,
    r.nonce,
    secret
)

Properties:
  - Cannot derive from commitment (needs secret)
  - Cannot derive commitment from nullifier (one-way)
  - Unique per record
  - Deterministic (same record → same nullifier)

10. Authenticated Graph Structures in ZK

9.1 The Core Problem

Inside a ZK circuit, we must prove “this record exists in the UTXO set” while keeping the record private. The naive approach uses Merkle trees:

MERKLE TREE APPROACH (what most systems use)
────────────────────────────────────────────
Structure: Binary tree of hashes, depth 32
Proof: 32 sibling hashes forming path to root
Verification: Hash leaf, then hash with siblings up to root

Cost inside ZK circuit:
  - Each hash: ~300 constraints (Poseidon S-box + MDS)
  - 32 levels: 32 × 300 = 9,600 constraints
  - Per input: 9,600 constraints just for inclusion!
  
For 4 inputs: 38,400 constraints for inclusion alone

9.2 The Insight: Field Ops are Cheap

Inside a ZK circuit, different operations have vastly different costs:

OPERATION COSTS IN ZK CIRCUIT
─────────────────────────────
Field addition:       1 constraint
Field multiplication: 1 constraint
Field comparison:     ~64 constraints
Poseidon hash:        ~300 constraints

Ratio: Hash is 300× more expensive than multiply!

This asymmetry suggests: replace hashes with field operations.

9.3 Polynomial Commitment Solution

Following Goodrich & Tamassia’s authenticated graph structure principles, we represent the UTXO set as a polynomial:

POLYNOMIAL REPRESENTATION
─────────────────────────
Given n commitments {c₀, c₁, ..., c_{n-1}}

Construct polynomial P(x) such that:
  P(0) = c₀
  P(1) = c₁
  ...
  P(n-1) = c_{n-1}

State commitment: C = FRI_commit(P)

Inclusion proof for cᵢ:
  - Prove P(i) = cᵢ using FRI evaluation proof
  - Verification: ~log²(n) field operations
  - Cost: ~1,000 constraints (vs 9,600 for Merkle)

9.4 Why FRI Works Inside ZK

FRI (Fast Reed-Solomon Interactive Oracle Proof) verification consists of:

FRI VERIFICATION STEPS
──────────────────────
1. Receive layer commitments (public input)
2. Derive challenges via Fiat-Shamir (a few hashes, amortized)
3. For each layer:
   - Interpolate between two points (field ops)
   - Check consistency (field comparison)
4. Verify final polynomial is low-degree (field ops)

Total operations: O(log² n) field multiplications
For n = 2³²: log²(32) ≈ 1,000 operations
Cost: ~1,000 constraints

9.5 Comparison

                     │ Merkle Tree    │ Polynomial (FRI)
─────────────────────┼────────────────┼──────────────────
Primary operation    │ Hash           │ Field multiply
Operation cost       │ ~300           │ 1
Operations needed    │ 32             │ ~1,000
Total per proof      │ 9,600          │ ~1,000
4 inputs             │ 38,400         │ ~4,000
─────────────────────┼────────────────┼──────────────────
Improvement          │ baseline       │ ~10× fewer constraints

9.6 Security Properties

Both approaches provide:

  • Binding: Cannot open commitment to different values
  • Hiding: Commitment reveals nothing about values (with blinding)
  • Post-quantum: Hash-based (Poseidon), no pairings

The polynomial approach additionally enables:

  • Batch proofs: Prove multiple inclusions cheaper together
  • Update efficiency: Amortized O(log n) updates vs O(log n) full rehash

11. Transaction Circuit

10.1 Constants

MAX_INPUTS  = 4      // Maximum input records per tx
MAX_OUTPUTS = 4      // Maximum output records per tx
MAX_UTXOS   = 2^32   // Maximum UTXO set size (polynomial degree bound)

10.2 Public Inputs

- state_commitment: Field         // Polynomial commitment to UTXO set
- nullifiers[4]: Field            // Spent record nullifiers
- commitments[4]: Field           // New record commitments
- deltas[8]: (Field, i64)         // Per-particle value changes
- fee: u64                        // Transaction fee

10.3 Private Witness

- input_records[4]: Record        // Records being spent
- input_secrets[4]: Field         // Ownership proofs
- inclusion_proofs[4]: FRIProof   // Polynomial inclusion proofs (replaces Merkle paths)
- output_records[4]: Record       // Records being created
- input_enabled[4]: bool          // Which inputs active
- output_enabled[4]: bool         // Which outputs active

10.4 Circuit Constraints

CORE uses polynomial commitment inclusion proofs instead of Merkle paths inside the ZK circuit. This replaces hash-heavy operations (~300 constraints per hash × 32 levels = 9,600 constraints) with field-operation-heavy polynomial evaluation (~1,000 constraints total).

KEY INSIGHT: AUTHENTICATED GRAPH STRUCTURES IN ZK
────────────────────────────────────────────────
Naive Merkle (what most systems use):
  32 sequential Poseidon hashes
  32 × 300 = 9,600 constraints per inclusion proof
  
Polynomial Commitment (Goodrich-Tamassia style):
  FRI evaluation proof verification
  ~log²(n) field multiplications
  log²(2³²) ≈ 1,000 constraints per inclusion proof
  
Why it works:
  - Hash = ~300 constraints (S-box, MDS matrix)
  - Field multiply = 1 constraint
  - Trade 32 hashes for ~1000 field mults = 9× savings


SECTION 1: INPUT VALIDATION (~7,600 constraints)
────────────────────────────────────────────────
For each of 4 possible inputs:

  Commitment correctness (Poseidon):           ~300 constraints
    hash(particle, value, owner, nonce)
    
  Polynomial inclusion proof (FRI):          ~1,000 constraints  ← KEY CHANGE
    Verify commitment ∈ state polynomial
    ~log²(n) field operations
    
  Ownership verification (Poseidon):           ~300 constraints
    hash(owner_pubkey) = record.owner
    
  Nullifier derivation (Poseidon):             ~300 constraints
    nullifier = hash(nonce, secret)
    
  Per input total:                           ~1,900 constraints
  4 inputs maximum:                          ~7,600 constraints


SECTION 2: OUTPUT VALIDATION (~1,500 constraints)
────────────────────────────────────────────────
For each of 4 possible outputs:
  Commitment correctness:                      ~300 constraints
  Range check (64-bit):                         ~64 constraints
  4 outputs:                                 ~1,456 constraints


SECTION 3: CONSERVATION (~100 constraints)
────────────────────────────────────────────────
  Sum inputs = sum outputs + fee:                ~8 constraints
  Fee non-negative:                             ~64 constraints
  Boolean flags:                                ~16 constraints


SECTION 4: DELTA CONSISTENCY (~300 constraints)
────────────────────────────────────────────────
  Per-particle accounting:                     ~100 constraints
  Delta matching to public values:             ~200 constraints


SECTION 5: UNIQUENESS (~50 constraints)
────────────────────────────────────────────────
  All nullifiers distinct:                      ~24 constraints
  All commitments distinct:                     ~24 constraints


TOTAL: ~10,000 constraints
════════════════════════════════════════════════
With Plonky2/STARK optimizations:   ~7,000 gates
Proof generation time:              ~0.3-0.8 seconds
Proof size:                         ~50-80 KB
Verification time:                  ~1-3 ms


COMPARISON
──────────
                      │ Merkle (old)  │ Polynomial (new)
──────────────────────┼───────────────┼──────────────────
Inclusion proof       │ 9,600         │ 1,000
Per input total       │ 10,500        │ 1,900
4 inputs              │ 42,000        │ 7,600
Full circuit          │ ~44,000       │ ~10,000
Proof generation      │ 1-3 sec       │ 0.3-0.8 sec
Proof size            │ 100-200 KB    │ 50-80 KB

Improvement: 4× fewer constraints, 3× faster proofs, 2× smaller proofs

10.5 Polynomial Inclusion Gadget

def polynomial_inclusion_gadget(
    cs: ConstraintSystem,
    state_commitment: Variable,     # Public: polynomial commitment to all UTXOs
    leaf_value: Variable,           # Private: the record commitment
    index: Variable,                # Private: position in set
    fri_proof: FRIProof,           # Private: evaluation proof
) -> Variable:
    """
    Verify that leaf_value exists in the committed state.
    
    Cost: ~1,000 constraints (vs 9,600 for Merkle path)
    
    The key insight: FRI verification is mostly field operations,
    and field operations cost 1 constraint each, while hashes cost ~300.
    """
    
    # 1. Derive Fiat-Shamir challenges from commitment + proof structure
    #    (~100 constraints for a few hashes, amortized across all inputs)
    challenges = derive_challenges(cs, state_commitment, fri_proof.layer_commits)
    
    # 2. Verify FRI layers - all field operations!
    #    Each layer: interpolate between two points, check consistency
    current_value = leaf_value
    for i, layer in enumerate(fri_proof.layers):
        # Interpolate: ~10 field ops
        alpha = challenges.folding_challenges[i]
        interpolated = cs.add(
            cs.mul(layer.even, cs.sub(Field(1), alpha)),
            cs.mul(layer.odd, alpha)
        )
        
        # Check consistency with next layer commitment
        cs.assert_equal(interpolated, layer.next_value)
        current_value = interpolated
    
    # 3. Final consistency check
    cs.assert_equal(current_value, fri_proof.final_value)
    
    # 4. Verify final value matches claimed evaluation
    #    (polynomial evaluates to leaf_value at index)
    
    return True  # Valid inclusion
 
 
# Why this works:
# ───────────────
# Merkle: prove H(H(H(...H(leaf)...))) = root
#         Each H costs ~300 constraints
#         32 levels = 9,600 constraints
#
# FRI:    prove P(index) = leaf_value where commit(P) = state_commitment  
#         Verification is ~log²(n) field operations
#         Field ops cost 1 constraint each
#         log²(2³²) ≈ 1,000 constraints

10.6 Transaction Types

TRANSFER (Standard)
  PURPOSE: Move energy between particles
  INPUTS: 1-4 records
  OUTPUTS: 1-4 records
  CONSTRAINT: Σ inputs = Σ outputs + fee

MINT (Genesis / Mining Reward)
  PURPOSE: Create new energy at a particle
  INPUTS: 0 records
  OUTPUTS: 1 record
  CONSTRAINT: Special proof of work OR genesis authority
  PUBLIC: mint_amount added to particle

BURN (Fee Destruction)
  PURPOSE: Remove energy from circulation
  INPUTS: 1-4 records
  OUTPUTS: 0-3 records
  CONSTRAINT: fee = Σ inputs - Σ outputs

SPLIT
  PURPOSE: Divide one record into multiple
  INPUTS: 1 record
  OUTPUTS: 2-4 records (same particle, same owner)
  CONSTRAINT: Conservation at single particle

MERGE
  PURPOSE: Combine multiple records
  INPUTS: 2-4 records (same particle, same owner)
  OUTPUTS: 1 record
  CONSTRAINT: Conservation at single particle

Part IV: BBG — Big Badass Graph

A naive graph database stores edges and answers queries. But “I don’t have any edges matching your query” is indistinguishable from “I’m hiding edges from you.” Traditional systems require trust: you believe the database operator is honest. Distributed systems require consensus: everyone agrees on the complete state. Neither scales.

The BBG (Big Badass Graph) solves this through unified polynomial commitments. One primitive handles everything: membership proofs, completeness proofs, indexes, state. No Merkle trees. No separate accumulators. No mixed bag of data structures with different security properties and implementations.

Edges are stored once but indexed by multiple dimensions—creator, source particle, target particle. Each index is a sorted polynomial commitment enabling range proofs: not just “this edge exists” but “these are ALL edges in this namespace.” When you sync your namespace, you receive cryptographic proof that nothing was withheld. The graph cannot exist without its indexes being consistent and complete—this is structural, not policy.

A deliberate choice: BBG uses polynomial commitments everywhere rather than mixing hash-based structures (Merkle trees, NMTs) with polynomial structures. One primitive means one security analysis, one implementation, one mental model. The same FRI-based machinery that makes UTXO proofs cheap (~1,000 constraints vs ~9,600 for Merkle) also handles graph completeness proofs. Edges are sorted by namespace within the polynomial, enabling range proofs: “first edge with namespace N is at index i, last is at j, nothing outside this range matches N.”

This makes “sync only my namespace” not a feature but a mathematical property. A light client tracking one particle downloads only edges touching that particle, with proof that the response is complete. A neuron syncing its own edges receives proof of its complete history. No trust in the data provider required.

12. BBG Structure

The BBG is multi-indexed from genesis. Edges are stored once but indexed by multiple dimensions, each with polynomial commitment completeness proofs.

╔═══════════════════════════════════════════════════════════════════════════╗
║                    BBG: BIG BADASS GRAPH STRUCTURE                         ║
╠═══════════════════════════════════════════════════════════════════════════╣
║                                                                            ║
║  LAYER 0: Edge Store (content-addressed, stored ONCE)                     ║
║  ──────────────────────────────────────────────────────────────           ║
║    edge_store : H(edge) → edge                                            ║
║    where edge = Cell(neuron, Cell(from, Cell(to, Cell(w, t))))           ║
║    No duplication. Identity = hash. Immutable.                            ║
║                                                                            ║
║  LAYER 1: Neuron Index (completeness by creator)                          ║
║  ───────────────────────────────────────────────────                      ║
║    by_neuron : PolynomialCommitment                                       ║
║    - Sorted by (neuron_id, edge_hash)                                     ║
║    - Range proof: "All edges where edge.neuron = n"                       ║
║    - Completeness via sorted range bounds                                 ║
║                                                                            ║
║  LAYER 2: Particle Index (completeness by endpoint)                       ║
║  ────────────────────────────────────────────────────                     ║
║    by_particle : PolynomialCommitment                                     ║
║    - Sorted by (particle_hash, edge_hash)                                 ║
║    - Range proof: "All edges where from=p OR to=p"                        ║
║    - Completeness via sorted range bounds                                 ║
║                                                                            ║
║  LAYER 3: Focus & Balance                                                 ║
║  ────────────────────────                                                 ║
║    focus   : PolynomialCommitment over (neuron_id, F_p) pairs            ║
║    balance : PolynomialCommitment over (neuron_id, F_p) pairs            ║
║                                                                            ║
║  LAYER 4: UTXO State (for privacy layer)                                  ║
║  ──────────────────────────────────────────────                           ║
║    commitment_poly  : PolynomialCommitment  (UTXO set as polynomial)      ║
║    nullifier_set    : PolynomialCommitment  (spent records, sorted)       ║
║    particle_energy  : PolynomialCommitment  (public aggregates)           ║
║                                                                            ║
║  UNIFIED PRIMITIVE: All indexes use polynomial commitments                ║
║    - Membership proof: FRI evaluation, O(log² n), ~1,000 constraints      ║
║    - Completeness proof: Sorted range bounds, O(log² n)                   ║
║    - One primitive, one security analysis, one implementation             ║
║                                                                            ║
║  GRAPH ROOT                                                               ║
║  ──────────                                                               ║
║    BBG_root = H(                                                            ║
║      by_neuron.commit  ‖                                                  ║
║      by_particle.commit ‖                                                 ║
║      focus.commit ‖                                                       ║
║      balance.commit ‖                                                     ║
║      commitment_poly.commit ‖                                             ║
║      nullifier_set.commit                                                 ║
║    )                                                                       ║
║                                                                            ║
╚═══════════════════════════════════════════════════════════════════════════╝

13. Index Consistency Invariant

INVARIANT (enforced by STARK on every state transition)
───────────────────────────────────────────────────────

For every edge e = (neuron, from, to, weight, time):
  
  1. H(e) ∈ by_neuron at position for namespace=neuron
  2. H(e) ∈ by_particle at position for namespace=from
  3. H(e) ∈ by_particle at position for namespace=to
  
  Multiplicity:
    If from ≠ to: H(e) appears in exactly 3 index positions
    If from = to: H(e) appears in exactly 2 index positions (self-link)

Cross-index consistency provable via polynomial identity testing:
  - Same edge hash appears in multiple sorted polynomials
  - FRI proofs demonstrate membership in each
  - STARK proves all memberships consistent

Proof size: O(log² n). Verification: O(log² n) field operations.

14. Namespace Sync Protocol

NAMESPACE SYNC (Polynomial Range Proof)
───────────────────────────────────────

To sync namespace ns (neuron_id or particle_hash):

  1. REQUEST
     Client → Responder: "Give me namespace ns"
     
  2. RESPONSE  
     Responder → Client:
       - Range bounds (i, j) in sorted polynomial
       - FRI proofs for P(i-1), P(i), P(j), P(j+1)
       - Edge data { e | index i ≤ position ≤ j }
       
  3. VERIFY
     Client checks:
       a) P(i-1).namespace < ns (or i = 0)
       b) P(i).namespace = ns
       c) P(j).namespace = ns  
       d) P(j+1).namespace > ns (or j = end)
       e) Received edges hash to claimed values
       f) All FRI proofs valid against BBG_root
       
  4. GUARANTEE
     If verification passes:
       "I have ALL edges in namespace ns. Nothing hidden."
     
     Proof is mathematical, not trust-based.

Cost: O(|my_edges|) data + O(log² |G|) proof overhead

Part V: STARK Verification

15. Why STARKs

Property          │ SNARK         │ STARK
──────────────────┼───────────────┼─────────────────
Trusted setup     │ Required      │ NOT REQUIRED
Quantum resistant │ No            │ Yes
Proof size        │ ~200 bytes    │ ~100-200 KB
Security basis    │ Discrete log  │ Hash only
Field compatible  │ Specific      │ Any (Goldilocks)

16. Self-Verification Property

THEOREM: The STARK verifier for CORE is expressible as a CORE program.

STARK verification requires:
  1. Field arithmetic (patterns 5, 7, 8)
  2. Hash computation (pattern 15)
  3. Polynomial evaluation (patterns + recursion)
  4. Merkle verification (pattern 15 + conditionals)

All are CORE-native. QED.

CONSEQUENCE:
  verify(proof) can itself be proven
  This enables recursive proof composition
  O(1) verification regardless of computation size

17. Verifier Complexity

STARK VERIFIER COMPONENTS:
  1. Parse proof: ~1,000 patterns
  2. Fiat-Shamir challenges: ~30,000 patterns
  3. Merkle verification: ~500,000 patterns
  4. Constraint evaluation: ~10,000 patterns
  5. FRI verification: ~50,000 patterns

TOTAL: ~600,000 pattern applications

This cost is CONSTANT regardless of what was proven.

18. Recursive Composition

Level 0: Prove computation C → proof π₀
Level 1: Prove verify(π₀) → proof π₁ (~100-200 KB)
Level 2: Prove verify(π₁) → proof π₂ (same size)

AGGREGATION:
  N transactions → N proofs
  Verify all N in one CORE program
  Prove that verification → single proof
  
  Result: O(1) on-chain verification for O(N) transactions

Part VI: Focus Dynamics

19. Focus: The Universal Resource

Focus is a single conserved quantity that serves three roles:

RoleMechanism
AttentionHigh-focus computations scheduled first
FuelComputation consumes focus
Consensus weightFocus distribution = agreement signal

20. Conservation Laws

FOCUS CONSERVATION
──────────────────
Σᵢ focus(i) = 1   (always, enforced structurally)

Focus can:
  ✓ Flow between neurons (transfer)
  ✓ Be consumed (computation)
  ✓ Regenerate (from pool, proportional to balance)
  
Focus cannot:
  ✗ Be created from nothing
  ✗ Be destroyed (only redistributed)
  ✗ Exceed 1 in total


BALANCE CONSERVATION  
────────────────────
Σᵢ balance(i) = B_total   (for non-minting transactions)

Enforced by polynomial commitment structure.
Invalid conservation → invalid state transition → rejected.


ENERGY CONSERVATION (Privacy Layer)
───────────────────────────────────
Σ(record values) = initial + minted - burned

Enforced by ZK circuit constraints.

21. Focus Flow Equation

CONTINUOUS FORM (for analysis)
──────────────────────────────
∂f/∂t = -∇·(D∇f) + R - C

  f = focus distribution vector
  D = diffusion tensor (derived from weights × balances)
  R = regeneration rate
  C = consumption rate

DISCRETE FORM (for implementation)
──────────────────────────────────
f'ᵢ = Σⱼ Pᵢⱼ · fⱼ + rᵢ - cᵢ

  Pᵢⱼ = wᵢⱼ · bⱼ / Σₖ wₖⱼ · bₖ
  
  wᵢⱼ = edge weight from i to j
  bⱼ  = balance of neuron j
  rᵢ  = regeneration for neuron i
  cᵢ  = consumption by neuron i

22. Convergence Theorem

Theorem: Focus dynamics converge to a unique stationary distribution π.

Proof: The transition matrix P is:

  • Stochastic (rows sum to 1)
  • Irreducible (graph is strongly connected by assumption)
  • Aperiodic (self-loops or odd cycles exist)

By Perron-Frobenius theorem, there exists a unique π where: πP = π Σᵢ πᵢ = 1 πᵢ > 0 for all i

All initial distributions converge to π geometrically fast. ∎

Convergence rate: Determined by spectral gap λ = 1 - |λ₂| ‖f^(t) - π‖ ≤ C · (1-λ)


Part VII: State Management

23. World State

WORLD STATE W
─────────────

W = (BBG, edge_store, privacy_state)

where BBG = Big Badass Graph commitment:
  BBG_root = H(
    by_neuron.commit ‖
    by_particle.commit ‖  
    focus.commit ‖
    balance.commit ‖
    commitment_poly.commit ‖
    nullifier_set.commit
  )

and edge_store = content-addressed storage:
  edge_store : H(edge) → edge

and privacy_state = UTXO state:
  particle_energy : PolynomialCommitment
  commitment_poly : PolynomialCommitment
  nullifier_set   : PolynomialCommitment
  total_energy    : u64

24. State Transitions

TRANSITION: W × Transaction → W' | ⊥

TRANSACTION TYPES
─────────────────
1. Cyberlink: Add edge to graph
   tx = (neuron, from_particle, to_particle, weight, signature)
   
2. Transfer: Move balance between neurons (public)
   tx = (from_neuron, to_neuron, amount, signature)

3. PrivateTransfer: Move energy between records (ZK)
   tx = (nullifiers, commitments, deltas, fee, proof)
   
4. Computation: Execute CORE reduction
   tx = (neuron, subject, formula, budget, signature)


VALIDITY CONDITIONS
───────────────────
1. Authorization: signature valid OR ZK proof valid
2. Balance: sufficient balance for any transfers
3. Focus: sufficient focus for any computation
4. Conservation: Σ focus' = 1, Σ balance' = B_total, energy conserved
5. Consistency: all indexes updated correctly
6. Availability: all referenced content retrievable
7. Double-spend: nullifiers not in nullifier_set


PROOF OF VALID TRANSITION
─────────────────────────
STARK proves:
  1. All validity conditions hold
  2. New state correctly derived from old state + tx
  3. All indexes (by_neuron, by_particle) updated consistently
  4. ZK proofs verified (for private transactions)

Proof size: O(log |W|)
Verification: O(log |W|)

Part VIII: Security Properties

25. Guarantees

SOUNDNESS:
  Invalid transactions rejected with probability ≥ 1 - 2^(-128)

PRIVACY:
  Cannot distinguish transactions with same public structure

CONSERVATION:
  Σ(energy) = initial + minted - burned (mathematically enforced)

QUANTUM RESISTANCE:
  Hash-based security only
  ~128-bit post-quantum (Grover limit)

26. Attack Resistance

Attack          │ Defense
────────────────┼─────────────────────────────────────────────
Double Spend    │ Nullifier set prevents reuse
Inflation       │ Circuit enforces conservation
Front-Running   │ Privacy hides transaction contents
Sybil           │ Focus proportional to stake
DoS             │ Focus-based metering limits computation
Eclipse         │ Namespace completeness proofs
Replay          │ Nonces and nullifiers ensure uniqueness
Forgery         │ ZK proofs unforgeable without witness

Part IX: Implementation Architecture

27. Implementation Layers

╔═══════════════════════════════════════════════════════════════════════════╗
║                      IMPLEMENTATION LAYERS                                 ║
╠═══════════════════════════════════════════════════════════════════════════╣
║                                                                            ║
║  LAYER 1: SEMANTIC CORE (this specification)                              ║
║    16 patterns, value tower, structural hash                              ║
║    Multi-indexed graph, polynomial commitments throughout                 ║
║    Privacy model, ZK circuit specification                                ║
║    Defines: CORRECTNESS                                                   ║
║                                                                            ║
║  LAYER 2: REFERENCE EVALUATOR                                             ║
║    Direct implementation, sequential, no caching                          ║
║    ~2k lines. Defines: ORACLE for testing                                 ║
║                                                                            ║
║  LAYER 3: OPTIMIZED EVALUATOR                                             ║
║    Parallel reduction, memoization, jets                                  ║
║    ~20k lines. Defines: PERFORMANCE                                       ║
║    INVARIANT: Must match Layer 2 exactly on all inputs                    ║
║                                                                            ║
║  LAYER 4: PROOF SYSTEM                                                    ║
║    STARK prover (~50k lines)                                              ║
║    STARK verifier (~7.5k lines, expressible in CORE)                      ║
║    ZK circuit prover (Plonky2)                                            ║
║    Defines: VERIFIABILITY                                                 ║
║                                                                            ║
║  LAYER 5: STORAGE                                                         ║
║    Content-addressed store: Hash → Content                                ║
║    Sorted polynomial indexes, commitment maintenance                      ║
║    UTXO set, nullifier set                                                ║
║    Defines: PERSISTENCE                                                   ║
║                                                                            ║
║  LAYER 6: NETWORK                                                         ║
║    Namespace-aware content discovery                                      ║
║    Proof propagation, gossip protocol                                     ║
║    Erasure shard distribution, DAS sampling                               ║
║    Defines: DISTRIBUTION                                                  ║
║                                                                            ║
║  LAYER 7: CONSENSUS                                                       ║
║    BFT protocol, finality rules, fork choice                              ║
║    DA sampling enforcement, validator set management                      ║
║    Defines: AGREEMENT                                                     ║
║    Status: PLUGGABLE (not specified by CORE)                              ║
║                                                                            ║
╚═══════════════════════════════════════════════════════════════════════════╝

28. Current Implementation Status

IMPLEMENTED:
  ✓ Python interpreter (all 16 patterns)
  ✓ Rust interpreter (all 16 patterns)
  ✓ Focus-based cost metering
  ✓ Content-addressed cells

NEXT:
  □ CORE-in-CORE interpreter
  □ Poseidon as CORE program
  □ Transaction circuit (Plonky2)
  □ STARK prover/verifier
  □ Recursive composition
  □ Privacy layer integration

29. Roadmap

Phase 1 (Complete): Specification + native interpreters
Phase 2: Self-hosting (CORE-in-CORE)
Phase 3: Cryptographic library (Poseidon, Merkle)
Phase 4: Privacy circuit implementation
Phase 5: STARK infrastructure
Phase 6: Network layer
Phase 7: Testnet → Mainnet

Part X: Collective Intelligence

30. Cybergraph Structure

STRUCTURE:
  - Particles: content-addressed nodes (CIDs)
  - Edges: weighted, timestamped links
  - Neurons: agents with stake and identity
  - Energy: value locked on particles
  - Records: private energy containers

INDEXES:
  - by_source: edges from particle
  - by_target: edges to particle
  - by_neuron: edges by creator

PRIVACY BOUNDARY:
  PUBLIC: Edge existence, aggregate energy, focus distribution
  PRIVATE: Who owns what, who created edges

31. Collective Focus Theorem

FOCUS DISTRIBUTION π:

  p_ij = (w_ij × t_j) / Σ_k(w_ik × t_k)

where:
  - w_ij = edge weight i→j
  - t_j = total energy on particle j

THEOREM: For strongly connected graph with positive weights,
unique stationary distribution π exists where:

  π_j = Σ_i (π_i × p_ij)

PRIVACY-PRESERVING:
  Focus computable from PUBLIC aggregates only.
  No individual ownership revealed.

32. Focus as Universal Resource

THREE ROLES:
  1. ATTENTION SIGNAL — higher π = more network attention
  2. COMPUTATIONAL FUEL — operations consume focus
  3. CONSENSUS WEIGHT — voting power proportional to focus

CONSERVATION: Σ_i π_i = 1 (always)

Part XI: Formal Properties

33. Core Theorems

31.1 Turing Completeness

Theorem: CORE is Turing-complete.

Proof: Construct encoding of arbitrary Turing machine M via patterns 0-4, 9. ∎

31.2 Confluence

Theorem: CORE is confluent.

Proof: Orthogonal rewrite system by Huet-Lévy (1980). ∎

31.3 Cost Determinism

Theorem: Cost is identical across all reduction orders and implementations.

Proof: By structural induction on formula. ∎

31.4 Focus Conservation

Theorem: Σᵢ focus(i) = 1 for all valid states.

Proof: All operations preserve sum; invalid transitions rejected by verification. ∎

31.5 Privacy Soundness

Theorem: A valid ZK proof implies all circuit constraints are satisfied with probability ≥ 1 - 2^(-128).

Proof: By STARK/Plonky2 soundness. ∎

31.6 Double-Spend Prevention

Theorem: Same record cannot be spent twice.

Proof:

  1. Each record has unique (nonce, owner_secret) pair
  2. Nullifier = H(nonce, owner_secret) is deterministic
  3. Same record → same nullifier
  4. Nullifier set is append-only
  5. Transaction rejected if nullifier already in set ∎

Part XII: Appendices

A. Field Reference

p = 2^64 - 2^32 + 1 = 18446744069414584321
Primitive root: 7
2^32-th root of unity: 1753635133440165772

Efficient reduction:
  a mod p = a_lo - a_hi × (2^32 - 1) + correction

B. Test Vectors

add(1, 2) = 3
mul(p-1, p-1) = 1
inv(2) = 9223372034707292161

reduce([1,2], [5 [[0 2] [0 3]]], 100) = (3, 96)
  // add(axis 2, axis 3) = add(1, 2) = 3

C. Cost Examples

Simple addition: 4 patterns
  [5 [[0 2] [0 3]]]
  Cost: 1 (add) + 2 (axis) + overhead = ~4

Poseidon hash: ~300 patterns
  [15 [0 1]]
  Cost: 300

Merkle verification (32 levels): ~10,000 patterns
  32 × (hash + conditional) ≈ 32 × 310

D. Complete Specification Summary

╔═══════════════════════════════════════════════════════════════════════════╗
║                              C O R E                                       ║
║            Conserved Observable Reduction Equilibrium                      ║
║                           Version 0.9                                      ║
╠═══════════════════════════════════════════════════════════════════════════╣
║                                                                            ║
║  FIELD                                                                     ║
║  p = 2^64 - 2^32 + 1 (Goldilocks)                                         ║
║                                                                            ║
║  VALUE TOWER                                                               ║
║  field : F_p element [0, p)           — arithmetic                        ║
║  word  : F_p element [0, 2^64)        — bitwise                           ║
║  hash  : 4 × F_p = 256 bits           — identity                          ║
║                                                                            ║
║  NOUNS                                                                     ║
║  Atom : field | word | hash                                               ║
║  Cell : (Noun, Noun)                                                      ║
║                                                                            ║
║  STRUCTURAL HASH                                                           ║
║  H(Atom a)    = HASH(0x00 ‖ type(a) ‖ encode(a))                          ║
║  H(Cell(l,r)) = HASH(0x01 ‖ H(l) ‖ H(r))                                  ║
║                                                                            ║
║  PATTERNS                                                                  ║
║  [0 a]           axis(s,a)                    k₀ = 1/level                ║
║  [1 c]           c                            k₁ = 1                      ║
║  [2 [x y]]       reduce(reduce(s,x),reduce(s,y))  k₂ = 2                  ║
║  [3 [a b]]       Cell(reduce(s,a),reduce(s,b))    k₃ = 2                  ║
║  [4 [t [y n]]]   if t=0 then y else n (lazy)      k₄ = 2                  ║
║  [5 [a b]]       (a + b) mod p               k₅ = 1                       ║
║  [6 [a b]]       (a - b) mod p               k₆ = 1                       ║
║  [7 [a b]]       (a × b) mod p               k₇ = 1                       ║
║  [8 a]           a^(p-2) mod p               k₈ = 64                      ║
║  [9 [a b]]       0 if a=b else 1             k₉ = 1                       ║
║  [10 [a b]]      0 if a<b else 1             k₁₀ = 1                      ║
║  [11 [a b]]      a ⊕ b                       k₁₁ = 1                      ║
║  [12 [a b]]      a ∧ b                       k₁₂ = 1                      ║
║  [13 a]          ¬a (64-bit)                 k₁₃ = 1                      ║
║  [14 [a n]]      a << n                      k₁₄ = 1                      ║
║  [15 a]          H(a)                        k₁₅ = 300                    ║
║                                                                            ║
║  FAILURES                                                                  ║
║  Halt           budget exhausted             (retry with more)            ║
║  ⊥_error        type/semantic error          (fix formula)                ║
║  ⊥_unavailable  content not found            (fetch, resume)              ║
║                                                                            ║
║  PRIVACY MODEL                                                             ║
║  Record = { particle, value, owner, nonce }                               ║
║  Commitment = Poseidon(DOMAIN, particle, value, owner, nonce)             ║
║  Nullifier  = Poseidon(DOMAIN, nonce, secret)                             ║
║  Circuit    = ~10,000 constraints (polynomial inclusion proofs)           ║
║                                                                            ║
║  BBG: BIG BADASS GRAPH                                                    ║
║  edge = Cell(neuron, Cell(from, Cell(to, Cell(weight, time))))           ║
║  by_neuron   : PolynomialCommitment (sorted, completeness by creator)    ║
║  by_particle : PolynomialCommitment (sorted, completeness by endpoint)   ║
║  focus       : PolynomialCommitment (neuron_id → F_p)                    ║
║  balance     : PolynomialCommitment (neuron_id → F_p)                    ║
║  commitment_poly : PolynomialCommitment (UTXO set)                       ║
║  nullifier_set   : PolynomialCommitment (spent records, sorted)          ║
║  BBG_root = H(by_neuron ‖ by_particle ‖ focus ‖ balance ‖ ...)          ║
║                                                                            ║
║  PROOFS (unified polynomial primitive)                                    ║
║  Membership    : FRI evaluation proof, O(log² n)                          ║
║  Completeness  : Sorted range proof, O(log² n)                            ║
║  Computation   : STARK over execution trace, O(log n) verify              ║
║  Privacy       : ZK proof of valid transaction, ~10K constraints          ║
║  Recursive     : STARK of STARK verification, O(1) final size             ║
║                                                                            ║
║  CONSERVATION                                                              ║
║  Σ focus = 1        (always)                                              ║
║  Σ balance = B_total (non-minting tx)                                     ║
║  Σ energy = initial + minted - burned                                     ║
║                                                                            ║
║  SYNC                                                                      ║
║  Request namespace ns → receive edges + range proof + FRI proofs          ║
║  Verify: proofs against BBG_root, edges match claimed range               ║
║  Guarantee: complete view of namespace ns                                 ║
║                                                                            ║
║  LAYERS                                                                    ║
║  1. Semantic Core      5. Storage                                         ║
║  2. Reference Eval     6. Network                                         ║
║  3. Optimized Eval     7. Consensus (pluggable)                           ║
║  4. Proof System                                                           ║
║                                                                            ║
╚═══════════════════════════════════════════════════════════════════════════╝

E. References

  1. Merkle, R. “A Digital Signature Based on a Conventional Encryption Function.” CRYPTO 1987.
  2. Goodrich, M.T., Tamassia, R. “Efficient Authenticated Data Structures.” Algorithmica 2002.
  3. Huet, G. “Confluent Reductions: Abstract Properties and Applications.” JACM 1980.
  4. Lafont, Y. “Interaction Nets.” POPL 1990.
  5. Al-Bassam, M. et al. “Fraud and Data Availability Proofs.” FC 2019.
  6. Grassi, L. et al. “Poseidon: A New Hash Function.” USENIX 2021.
  7. Taelin. “HVM: A Parallel Evaluator for Interaction Combinators.” 2022.
  8. Chiusano, P., Bjarnason, R. “Unison: A Friendly Programming Language.” 2019.
  9. Necula, G. “Proof-Carrying Code.” POPL 1997.
  10. Ben-Sasson, E. et al. “Scalable, Transparent Arguments of Knowledge.” CRYPTO 2018.
  11. Hopwood, D. et al. “Zcash Protocol Specification.” 2014-2024.
  12. Master. “Collective Focus Theorem.” 2024.
  13. Master. “Focus Flow Computation.” 2024.

CORE v0.9

Six paradigms. Sixteen patterns. Multi-indexed graph. Privacy-native.

Content-addressed. Namespace-native. Parallel-confluent.

Focus-conserved. Proof-carrying. Sync-complete. Self-verifying.

The substrate for planetary collective intelligence.

“The network doesn’t simulate thinking. The network IS thinking.”