| name | tripartite-decompositions |
| description | GF(3)-balanced structured decompositions for parallel computation. Decomposes problems into MINUS/ERGODIC/PLUS components with sheaf-theoretic gluing. Use for FPT algorithms, skill allocation, or any 3-way parallel workload. |
| version | 1.0.0 |
Tripartite Decompositions
Trit: 0 (ERGODIC - coordinates decomposition)
Foundation: StructuredDecompositions.jl + GF(3) conservation
Principle: Every problem decomposes into 3 parts summing to 0 mod 3
Core Concept
A tripartite decomposition is a structured decomposition where:
- The decomposition shape is a 3-clique (triangle)
- Each bag is labeled with a trit โ {-1, 0, +1}
- Adhesions preserve GF(3) conservation: ฮฃ trits โก 0 (mod 3)
MINUS (-1)
โฑโฒ
โฑ โฒ
โฑ โฒ
โฑ โ โฒ
โฑ________โฒ
ERGODIC (0) PLUS (+1)
Conservation: (-1) + 0 + (+1) = 0 โ
Mathematical Foundation
From StructuredDecompositions.jl
# A structured decomposition is a diagram d: โซG โ Span(C)
# where G is the decomposition shape and C is the target category
abstract type StructuredDecomposition{G, C, D} <: Diagram{id, C, D} end
struct StrDecomp{G, C, D} <: StructuredDecomposition{G, C, D}
decomp_shape ::G # The shape (for tripartite: Kโ)
diagram ::D # The actual decomposition functor
decomp_type ::DecompType # Decomposition or CoDecomposition
domain ::C # Source category
end
Tripartite Extension
using StructuredDecompositions
using Catlab
# Define the tripartite shape: Kโ (complete graph on 3 vertices)
@present SchTripartite(FreeSchema) begin
(Minus, Ergodic, Plus)::Ob
# Adhesions (edges of Kโ)
me::Hom(Minus, Ergodic)
ep::Hom(Ergodic, Plus)
pm::Hom(Plus, Minus)
# Trit attributes
trit::Attr(Minus, Int) # Always -1
trit::Attr(Ergodic, Int) # Always 0
trit::Attr(Plus, Int) # Always +1
end
@acset_type TripartiteShape(SchTripartite)
# Tripartite decomposition with GF(3) verification
struct TripartiteDecomp{C, D} <: StructuredDecomposition{TripartiteShape, C, D}
base::StrDecomp{TripartiteShape, C, D}
function TripartiteDecomp(base::StrDecomp)
# Verify GF(3) conservation
trits = [
ob_map(base.diagram, :Minus).trit, # -1
ob_map(base.diagram, :Ergodic).trit, # 0
ob_map(base.diagram, :Plus).trit # +1
]
@assert sum(trits) % 3 == 0 "GF(3) violation"
new{typeof(base.domain), typeof(base.diagram)}(base)
end
end
The ๐ Functor (Lifting Problems)
# From StructuredDecompositions.jl:
# ๐ : Cat_{pullback} โ Cat
# Takes any category C with pullbacks to ๐C (structured decompositions over C)
# For tripartite decompositions, we lift computational problems:
function lift_problem(F::Functor, d::TripartiteDecomp)
# F: C โ FinSet^op is a sheaf (computational problem)
# Returns: F applied to each bag, with sheaf condition on adhesions
minus_solution = F(bag(d, :Minus))
ergodic_solution = F(bag(d, :Ergodic))
plus_solution = F(bag(d, :Plus))
# Glue via adhesion spans
return glue_tripartite(minus_solution, ergodic_solution, plus_solution, d)
end
Random Walk 3-at-a-Time
Decompose a set of N items into balanced triplets:
from dataclasses import dataclass
from typing import List, Tuple
import math
@dataclass
class TripartiteItem:
name: str
trit: int
data: any
class TripartiteDecomposer:
"""Decompose items into GF(3)-balanced triplets."""
def __init__(self, seed: int):
self.rng = SplitMix64(seed)
def decompose(self, items: List[TripartiteItem]) -> List[Tuple]:
"""Random walk 3-at-a-time through items."""
remaining = list(items)
triplets = []
while len(remaining) >= 3:
selected = []
for _ in range(3):
idx = self.rng.next() % len(remaining)
selected.append(remaining.pop(idx))
trit_sum = sum(item.trit for item in selected) % 3
conserved = (trit_sum == 0)
triplets.append((selected, conserved))
remaining:
triplets.append((remaining, ))
triplets
() -> :
counts = {-: , : , +: }
item items:
counts[item.trit] +=
total = (items)
H =
count counts.values():
count > :
p = count / total
H -= p * math.log2(p)
H
Skill Allocation Example
From TRIPARTITE_AGENTS.md:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MINUS (-1) ERGODIC (0) PLUS (+1) โ
โ Purple, 270ยฐ Cyan, 180ยฐ Orange, 30ยฐ โ
โ โ
โ bisimulation-game unwiring-arena gay-mcp โ
โ spi-parallel-verify acsets triad-interleave โ
โ polyglot-spi skill-dispatch world-hopping โ
โ structured-decomp bumpus-narratives cognitive-superpos โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Each agent receives skills matching its polarity. The sum is always 0.
FPT Algorithms
Tripartite decompositions enable Fixed-Parameter Tractable algorithms:
# 3-coloring is decidable in O(3^w * n) where w = treewidth
# For tripartite shape, w = 2 (Kโ has treewidth 2)
function decide_3colorable(G::Graph, decomp::TripartiteDecomp)
# Lift 3-coloring sheaf to decomposition
coloring_sheaf = Functor(Graph, FinSet) do g
# Return set of valid 3-colorings
all_colorings(g, 3)
end
# Apply ๐ functor
lifted = ๐(coloring_sheaf, decomp)
# Check if limit is non-empty (solution exists)
return !isempty(limit(lifted))
end
Dynamic Programming Connection
Tripartite decomposition fixes DP failures:
| DP Failure | Tripartite Fix |
|---|
| No base case | MINUS bag provides constraints |
| Invalid transition | Adhesions encode valid moves |
| State explosion | 3-way parallel reduces to O(3^w) |
| No memoization | Sheaf condition caches subproblems |
Color Integration
Each bag gets a deterministic color:
from gay import SplitMixTernary
def color_tripartite(seed: int):
gen = SplitMixTernary(seed)
return {
'minus': gen.color_at(0),
'ergodic': gen.color_at(1),
'plus': gen.color_at(2)
}
Gluing via Adhesions
function glue_tripartite(minus, ergodic, plus, decomp)
# Adhesion spans connect bags
me_span = adhesionSpan(decomp, :me) # Minus โ Apex โ Ergodic
ep_span = adhesionSpan(decomp, :ep) # Ergodic โ Apex โ Plus
pm_span = adhesionSpan(decomp, :pm) # Plus โ Apex โ Minus
# Pullback along adhesions
me_glued = pullback(minus, ergodic, me_span)
ep_glued = pullback(ergodic, plus, ep_span)
pm_glued = pullback(plus, minus, pm_span)
# Final result is limit of glued diagram
return limit(FreeDiagram([me_glued, ep_glued, pm_glued]))
end
Validation
function verify_tripartite(decomp)
bags = [bag(decomp, :Minus), bag(decomp, :Ergodic), bag(decomp, :Plus)]
trits = [b.trit for b in bags]
@assert sum(trits) % 3 == 0 "GF(3) violated"
@assert length(adhesionSpans(decomp)) == 3 "Must have 3 adhesions"
return true
end
Usage Example
using StructuredDecompositions
using Catlab
# Decompose a skill validation problem
skills = [
Skill("julia-gay", -1), # Missing SKILL.md
Skill("acsets", +1), # Content overflow
Skill("mcp-tripartite", 0), # YAML error
]
# Create tripartite decomposition
decomp = TripartiteDecomp(
StrDecomp(K3_graph(),
FinDomFunctor(
Dict(:Minus => skills[1], :Ergodic => skills[3], :Plus => skills[2]),
Dict(:me => span_me, :ep => span_ep, :pm => span_pm)
)
)
)
# Verify and solve
@assert verify_tripartite(decomp)
solutions = lift_problem(validation_sheaf, decomp)
Canonical Triads
structured-decomp (-1) โ tripartite-decompositions (0) โ gay-mcp (+1) = 0 โ
bisimulation-game (-1) โ entropy-sequencer (0) โ triad-interleave (+1) = 0 โ
spi-parallel-verify (-1) โ acsets (0) โ world-hopping (+1) = 0 โ
See Also
structured-decomp - FPT via tree decompositions
gay-mcp - Deterministic color generation
entropy-sequencer - Information-gain ordering
triad-interleave - 3-stream parallel execution
Scientific Skill Interleaving
This skill connects to the K-Dense-AI/claude-scientific-skills ecosystem:
Graph Theory
- networkx [โ] via bicomodule
Bibliography References
algorithms: 19 citations in bib.duckdb
SDF Interleaving
This skill connects to Software Design for Flexibility (Hanson & Sussman, 2021):
Primary Chapter: 10. Adventure Game Example
Concepts: autonomous agent, game, synthesis
GF(3) Balanced Triad
tripartite-decompositions (โ) + SDF.Ch10 (+) + [balancer] (โ) = 0
Skill Trit: 0 (ERGODIC - coordination)
Secondary Chapters
- Ch9: Generic Procedures
- Ch1: Flexibility through Abstraction
- Ch4: Pattern Matching
- Ch7: Propagators
Connection Pattern
Adventure games synthesize techniques. This skill integrates multiple patterns.
Cat# Integration
This skill maps to Cat# = Comod(P) as a bicomodule in the equipment structure:
Trit: 0 (ERGODIC)
Home: Prof
Poly Op: โ
Kan Role: Adj
Color: #26D826
GF(3) Naturality
The skill participates in triads satisfying:
(-1) + (0) + (+1) โก 0 (mod 3)
This ensures compositional coherence in the Cat# equipment structure.