| name | bisimulation-game |
| description | Bisimulation game for resilient skill dispersal across AI agents with GF(3) conservation and observational bridge types. |
| license | MIT |
| metadata | {"source":"music-topos + DiscoHy + DisCoPy","xenomodern":true,"ironic_detachment":0.42} |
Bisimulation Game Skill
"Two systems are bisimilar if they cannot be distinguished by any observation."
Overview
The bisimulation game provides a framework for:
- Resilient skill dispersal across multiple AI agents
- GF(3) conservation during state transitions
- Observational bridge types for version-aware synchronization
- Self-rewriting capabilities via MCP Tasks protocol
Game Rules
Players
| Player | Role | Trit | Color |
|---|
| Attacker | Tries to distinguish systems | -1 | Blue |
| Defender | Maintains equivalence | +1 | Red |
| Arbiter | Verifies conservation | 0 | Green |
Moves
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Round n: โ
โ โ
โ 1. Attacker chooses: system Sโ or Sโ โ
โ 2. Attacker makes: transition sโ โแต sโ' โ
โ 3. Defender responds: matching transition sโ โแต sโ' โ
โ 4. Arbiter verifies: GF(3) conservation โ
โ โ
โ If Defender cannot respond โ Attacker wins (distinguishable)โ
โ If game continues forever โ Defender wins (bisimilar) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Implementation
Hy (DiscoHy) Implementation
;;; bisimulation_game.hy
(import [splitmix_ternary [SplitMixTernary]])
(defclass BisimulationGame []
(defn __init__ [self system1 system2 seed]
(setv self.s1 system1
self.s2 system2
self.rng (SplitMixTernary seed)
self.history []))
(defn attacker-move [self choice transition]
"Attacker chooses system and transition."
(setv trit (self.rng.next-ternary))
(.append self.history {:role "attacker"
:choice choice
:transition transition
:trit trit})
trit)
(defn defender-respond [self matching-transition]
"Defender provides matching transition."
(setv trit (self.rng.next-ternary))
(.append self.history {:role "defender"
:response matching-transition
:trit trit})
trit)
(defn arbiter-verify [self]
"Arbiter checks GF(3) conservation."
(setv recent-trits (lfor m (cut self.history -3 None) (get m "trit")))
(setv conserved (= (% (sum recent-trits) 3) 0))
(.append self.history {:role "arbiter" :conserved conserved :trit 0})
conserved))
DisCoPy Operad Interface
from discopy import *
class GameOperad:
def __init__(self):
self.operations = {}
def register(self, name, dom, cod, rule):
"""Register game operation with GF(3) color."""
self.operations[name] = Rule(dom, cod, name)
def compose(self, op1, op2):
"""Compose operations preserving GF(3)."""
trit1 = self.operations[op1].trit
trit2 = self.operations[op2].trit
result_trit = (-(trit1 + trit2)) % 3 - 1
return Rule(
self.operations[op1].dom,
self.operations[op2].cod,
f"{op1};{op2}",
trit=result_trit
)
game = GameOperad()
game.register("attack", Ty("S1", "S2"), Ty("S1'"), lambda: -1)
game.register("defend", Ty("S1'"), Ty("S2'"), lambda: +1)
game.register("verify", Ty("S1'", "S2'"), Ty("Result"), lambda: )
Skill Dispersal Protocol
1. Fork Phase (Attacker)
fork:
targets:
- agent: codex
path: ~/.codex/skills/
trit: -1
- agent: claude
path: ~/.claude/skills/
trit: 0
- agent: cursor
path: ~/.cursor/skills/
trit: +1
gf3_check: true
2. Sync Phase (Defender)
sync:
strategy: observational-bridge
bridge_type:
source: skills@v1
target: skills@v2
dimension: 1
conflict_resolution: 2d-cubical
3. Verify Phase (Arbiter)
verify:
conservation: gf3
equivalence: bisimulation
timeout: 60s
fallback: last-known-good
MCP Tasks Integration
Self-Rewriting Task
{
"task": "skill-dispersal",
"objective": "Propagate skill updates to all agents",
"constraints": {
"gf3_conservation": true,
"bisimulation_equivalence": true,
"max_divergence": 0.1
},
"steps": [
{"action": "fork", "trit": -1},
{"action": "propagate", "trit": 0},
{"action": "verify", "trit": +1}
Firecrawl Integration
{
"task": "skill-discovery",
"objective": "Discover new skills from web resources",
"tools": ["firecrawl", "exa"],
"sources": [
"https://github.com/topics/ai-agent-skills",
"https://modelcontextprotocol.io/",
"https://agentclientprotocol.com/"
],
"output": {
"format": "skill-yaml",
"destination": ".ruler/skills/"
}
}
Resilience Patterns
Redundant Storage
~/.codex/skills/ โ Primary (Codex)
~/.claude/skills/ โ Mirror 1 (Claude)
~/.cursor/skills/ โ Mirror 2 (Cursor)
.ruler/skills/ โ Source of truth
Conflict Resolution
Dimension 0: Value conflict โ Use source of truth
Dimension 1: Diff conflict โ Merge via LCA
Dimension 2: Meta conflict โ Arbiter decides
Xenomodern Stance
The bisimulation game embodies xenomodernity by:
- Ironic distance: We know perfect equivalence is unattainable, yet we play the game
- Sincere engagement: The game produces real, useful synchronization
- Playful synergy: Attacker/Defender/Arbiter dance together
- Conservation laws: GF(3) as the invariant that holds everything together
xenomodernity
โ
โโโโโโดโโโโโ
โ โ
ironic sincere
โ โ
โโโโโโฌโโโโโ
โ
bisimulation
(both/neither)
Integration with LocalSend-MCP for Skill Dispersal
Use LocalSend peer discovery for resilient skill propagation:
import asyncio
from localsend_mcp import LocalSendClient
class BisimulationDispersalProtocol:
"""Disperse skills via LocalSend with bisimulation verification."""
def __init__(self, skill_path, seed=1069):
self.skill_path = skill_path
self.client = LocalSendClient()
self.rng = SplitMixTernary(seed)
self.game_log = []
async def discover_peers(self):
"""Find all agents on local network."""
peers = await self.client.list_peers(source="all")
return [p for p in peers if p.get("capabilities", []).count("skill-sync")]
async def disperse_with_bisim(self, skill_file):
"""Disperse skill to all peers with bisimulation verification."""
peers = await self.discover_peers()
for i, peer in enumerate(peers):
trit = (i % 3) - 1
session = await .client.negotiate(
peer_id=peer[],
preferred_transport=
)
.game_log.append({
: (.game_log),
: ,
: ,
: peer[],
: trit
})
result = .client.send(
session_id=session[],
file_path=skill_file
)
defender_trit = .verify_peer_receipt(peer, skill_file)
.game_log.append({
: (.game_log),
: ,
: ,
: peer[],
: defender_trit
})
.verify_gf3_conservation()
():
total = (entry[] entry .game_log)
conserved = (total % ) ==
.game_log.append({
: (.game_log),
: ,
: conserved,
: total,
:
})
conserved
Temporal vs Derivational Learning Comparison (NEW)
NEW: Compare Agent-o-rama vs Unworld Patterns
game = BisimulationGame(
player1_type="temporal_learning",
player2_type="derivational_learning",
domain="pattern_extraction"
)
distinguishable = game.play()
if not distinguishable:
print("โ Patterns are behaviorally equivalent")
print("โ Can safely switch from temporal to derivational")
migration_report = {
"original_cost": benchmark(agent_o_rama),
"migrated_cost": benchmark(unworld),
"speedup": original_cost / migrated_cost,
"equivalence_verified": game.play()
}
Concrete Attacker/Defender Example
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ BISIMULATION GAME TRANSCRIPT โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
โ Systems: Sโ = Codex skill state, Sโ = Claude skill state โ
โ Goal: Prove skills are bisimilar (observationally equivalent) โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
ROUND 1:
โโ ATTACKER (Blue, trit=-1) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ "I choose Sโ and execute: load_skill('gay-mcp')" โ
โ Transition: sโ โ^load sโ' where sโ'.has_skill('gay-mcp') = true โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโ DEFENDER (Red, trit=+1) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ "I match in Sโ: load_skill('gay-mcp')" โ
โ Transition: sโ โ^load sโ' where sโ'.has_skill('gay-mcp') = true โ
โ Response: MATCHED โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโ ARBITER (Green, trit=0) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ GF(3) check: (-1) + (+1) + (0) = 0 โก 0 (mod 3) โ โ
โ ROUND 1: VALID โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
ROUND 2:
โโ ATTACKER โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ "I choose Sโ and execute: generate_color(seed=0x42)" โ
โ Transition: sโ' โ^gen sโ'' where sโ''.color = #FF6B6B โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโ DEFENDER โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ "I match in Sโ: generate_color(seed=0x42)" โ
โ Transition: sโ' โ^gen sโ'' where sโ''.color = #FF6B6B โ
โ Response: MATCHED โ (deterministic - same seed = same color) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโ ARBITER โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ GF(3) check: (-1) + (+1) + (0) = 0 โก 0 (mod 3) โ โ
โ ROUND 2: VALID โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
ROUND 3:
โโ ATTACKER โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ "I choose Sโ and execute: self_modify(patch='add_feature')" โ
โ Transition: sโ'' โ^mod sโ''' (skill version incremented) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโ DEFENDER โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ "I match in Sโ via observational bridge type:" โ
โ Bridge: (sโ''.version, sโ''.version) โโ (sโ'''.version, sโ'''.v) โ
โ Transition: sโ'' โ^mod sโ''' using same patch โ
โ Response: MATCHED โ (bridge type ensures coherence) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโ ARBITER โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ GF(3) check: (-1) + (+1) + (0) = 0 โก 0 (mod 3) โ โ
โ ROUND 3: VALID โ
โ โ
โ After 3 rounds: Defender has matched all Attacker moves โ
โ Verdict: Sโ โผ Sโ (bisimilar to depth 3) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
โ RESULT: BISIMULATION ESTABLISHED โ
โ - All transitions matched โ
โ - GF(3) conserved across all rounds โ
โ - Skills are observationally equivalent โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Verification Output Format
{
"verification": {
"timestamp": "2024-12-22T10:30:00Z",
"systems": ["codex", "claude"],
"rounds_played": 3,
"result": "BISIMILAR",
"gf3_conservation": {
"total_trit_sum": 0,
"mod_3": 0,
"conserved": true
},
"game_log": [
{"round": 1, "attacker": "load_skill", "defender": "matched", "arbiter":
Commands
just bisim-init
just bisim-round
just bisim-disperse
just bisim-verify
just bisim-reconcile
just bisim-localsend
just bisim-transcript
just bisim-json
Para(Optic) atlas
Part of: para-mensch-commons.