Spaces:
Sleeping
Sleeping
| """ | |
| Quark-Arranged Skyrms Walker Personality Model | |
| Five walkers. Ten bosons. Quark confinement. Settlement to Nash equilibrium. | |
| A personality is not what you are. It is what you are not. | |
| The void boundary -- the accumulated rejections across five dimensions | |
| of irreversible choice -- IS the person. | |
| Hot off Lean 4. Zero sorry. | |
| """ | |
| import gradio as gr | |
| import numpy as np | |
| import matplotlib | |
| matplotlib.use("Agg") | |
| import matplotlib.pyplot as plt | |
| from dataclasses import dataclass, field | |
| import json | |
| # ─── AeonOS Dark Theme ────────────────────────────────────────────────────── | |
| DARK_RC = { | |
| "figure.facecolor": "#09090b", "axes.facecolor": "#111114", | |
| "axes.edgecolor": "#1f1f23", "axes.labelcolor": "#a1a1aa", | |
| "text.color": "#fafafa", "xtick.color": "#71717a", "ytick.color": "#71717a", | |
| "grid.color": "#1f1f23", "grid.alpha": 0.3, "figure.dpi": 100, | |
| "savefig.facecolor": "#09090b", "font.family": "sans-serif", | |
| } | |
| WALKER_NAMES = ["Try", "Choose", "Commit", "LetGo", "Learn"] | |
| WALKER_COLORS = ["#3b82f6", "#22c55e", "#a855f7", "#ef4444", "#f59e0b"] | |
| PRIMITIVES = ["Fork", "Race", "Fold", "Vent", "Interfere"] | |
| PARAMS = ["eta", "temperature", "commitGain", "decayRate", "feedbackGain"] | |
| BOSON_PAIRS = [ | |
| (0,1,"Try↔Choose"), (0,2,"Try↔Commit"), (0,3,"Try↔LetGo"), (0,4,"Try↔Learn"), | |
| (1,2,"Choose↔Commit"), (1,3,"Choose↔LetGo"), (1,4,"Choose↔Learn"), | |
| (2,3,"Commit↔LetGo"), (2,4,"Commit↔Learn"), (3,4,"LetGo↔Learn"), | |
| ] | |
| PRESETS = { | |
| "Explorer": [0.9, 0.4, 0.3, 0.7, 0.8], | |
| "Builder": [0.4, 0.7, 0.9, 0.2, 0.6], | |
| "Creative": [0.8, 0.3, 0.4, 0.8, 0.9], | |
| "Anxious": [0.3, 0.2, 0.7, 0.1, 0.5], | |
| "Balanced": [0.5, 0.5, 0.5, 0.5, 0.5], | |
| "Custom": [0.6, 0.6, 0.6, 0.6, 0.6], | |
| } | |
| # ─── Core Model ────────────────────────────────────────────────────────────── | |
| def compute_bosons(walkers): | |
| """Compute ten boson tensions (|w_a - w_b| for all pairs).""" | |
| bosons = [] | |
| for a, b, _ in BOSON_PAIRS: | |
| bosons.append(abs(walkers[a] - walkers[b])) | |
| return np.array(bosons) | |
| def system_energy(bosons): | |
| """Total system energy = sum of all boson tensions.""" | |
| return float(np.sum(bosons)) | |
| def is_confined(walkers): | |
| """All walkers must be present (> 0). The sliver guarantees this.""" | |
| return all(w > 0 for w in walkers) | |
| def complement_distribution(void_boundary, eta=3.0): | |
| """Compute complement target from void boundary (rejection counts).""" | |
| weights = np.array([max(1, total - rej + 1) for total, rej in | |
| zip([sum(void_boundary)] * len(void_boundary), void_boundary)], dtype=float) | |
| # Softmax with eta | |
| exp_w = np.exp(eta * (weights / max(weights.max(), 1e-8) - 0.5)) | |
| return exp_w / exp_w.sum() | |
| def settle_personality(initial_walkers, max_rounds=100, epsilon=0.001): | |
| """Settle five walkers to Skyrms Nash equilibrium via rejection.""" | |
| walkers = np.array(initial_walkers, dtype=float) | |
| walkers = np.clip(walkers, 0.01, 0.99) # the sliver | |
| # Per-walker void boundaries (20 levels each) | |
| resolution = 20 | |
| voids = [np.zeros(resolution) for _ in range(5)] | |
| history = [walkers.copy()] | |
| energies = [system_energy(compute_bosons(walkers))] | |
| gaits = [["stand"] * 5] | |
| for round_idx in range(max_rounds): | |
| new_walkers = walkers.copy() | |
| round_gaits = [] | |
| for i in range(5): | |
| # Propose new value from complement distribution | |
| dist = complement_distribution(voids[i]) | |
| proposal_idx = np.random.choice(resolution, p=dist) | |
| proposal = (proposal_idx + 0.5) / resolution | |
| # Would this reduce energy? | |
| test = new_walkers.copy() | |
| test[i] = proposal | |
| old_energy = system_energy(compute_bosons(walkers)) | |
| new_energy = system_energy(compute_bosons(test)) | |
| if new_energy < old_energy: | |
| # Accept: update walker | |
| new_walkers[i] = proposal | |
| gait = "gallop" if (old_energy - new_energy) > 0.1 else "trot" | |
| else: | |
| # Reject: update void boundary | |
| reject_idx = min(int(walkers[i] * resolution), resolution - 1) | |
| voids[i][reject_idx] += 1 | |
| gait = "stand" | |
| round_gaits.append(gait) | |
| walkers = np.clip(new_walkers, 0.01, 0.99) | |
| bosons = compute_bosons(walkers) | |
| energy = system_energy(bosons) | |
| history.append(walkers.copy()) | |
| energies.append(energy) | |
| gaits.append(round_gaits) | |
| # Convergence check | |
| if len(energies) > 2 and abs(energies[-1] - energies[-2]) < epsilon: | |
| break | |
| return { | |
| "walkers": walkers.tolist(), | |
| "bosons": compute_bosons(walkers).tolist(), | |
| "energy": system_energy(compute_bosons(walkers)), | |
| "confined": is_confined(walkers), | |
| "rounds": len(history) - 1, | |
| "history": [h.tolist() for h in history], | |
| "energies": energies, | |
| "gaits": gaits, | |
| "voids": [v.tolist() for v in voids], | |
| } | |
| # ─── Visualization ────────────────────────────────────────────────────────── | |
| def plot_walkers(result): | |
| """Radar chart of final walker values.""" | |
| with plt.rc_context(DARK_RC): | |
| fig, ax = plt.subplots(figsize=(6, 6), subplot_kw=dict(projection='polar')) | |
| angles = np.linspace(0, 2 * np.pi, 5, endpoint=False).tolist() | |
| angles += angles[:1] | |
| values = result["walkers"] + [result["walkers"][0]] | |
| ax.plot(angles, values, 'o-', color='#06b6d4', linewidth=2, markersize=8) | |
| ax.fill(angles, values, alpha=0.15, color='#06b6d4') | |
| ax.set_xticks(angles[:-1]) | |
| ax.set_xticklabels([f"{n}\n({p})" for n, p in zip(WALKER_NAMES, PRIMITIVES)], size=9) | |
| ax.set_ylim(0, 1) | |
| ax.set_title("Five Walkers (Settled)", pad=20, fontsize=14, color='#fafafa') | |
| ax.grid(True, alpha=0.2) | |
| fig.tight_layout() | |
| return fig | |
| def plot_bosons(result): | |
| """Bar chart of ten boson tensions.""" | |
| with plt.rc_context(DARK_RC): | |
| fig, ax = plt.subplots(figsize=(10, 4)) | |
| labels = [bp[2] for bp in BOSON_PAIRS] | |
| values = result["bosons"] | |
| colors = ['#ef4444' if v > 0.3 else '#f59e0b' if v > 0.15 else '#22c55e' for v in values] | |
| bars = ax.bar(range(10), values, color=colors, alpha=0.8, edgecolor='#1f1f23') | |
| ax.set_xticks(range(10)) | |
| ax.set_xticklabels(labels, rotation=45, ha='right', fontsize=7) | |
| ax.set_ylabel("Tension |w_a - w_b|") | |
| ax.set_title(f"Ten Bosons (Energy = {result['energy']:.3f})", fontsize=12) | |
| ax.set_ylim(0, 1) | |
| ax.axhline(y=0.3, color='#ef4444', linestyle='--', alpha=0.3, label='High tension') | |
| fig.tight_layout() | |
| return fig | |
| def plot_convergence(result): | |
| """Energy convergence over settlement rounds.""" | |
| with plt.rc_context(DARK_RC): | |
| fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 4)) | |
| # Energy | |
| ax1.plot(result["energies"], color='#06b6d4', linewidth=2) | |
| ax1.set_xlabel("Round") | |
| ax1.set_ylabel("System Energy") | |
| ax1.set_title(f"Settlement ({result['rounds']} rounds)", fontsize=12) | |
| ax1.grid(True, alpha=0.2) | |
| # Walker trajectories | |
| history = np.array(result["history"]) | |
| for i in range(5): | |
| ax2.plot(history[:, i], color=WALKER_COLORS[i], linewidth=1.5, label=WALKER_NAMES[i]) | |
| ax2.set_xlabel("Round") | |
| ax2.set_ylabel("Walker Value") | |
| ax2.set_title("Walker Trajectories", fontsize=12) | |
| ax2.legend(loc='upper right', fontsize=8) | |
| ax2.set_ylim(0, 1) | |
| ax2.grid(True, alpha=0.2) | |
| fig.tight_layout() | |
| return fig | |
| def format_summary(result): | |
| """Text summary of the settled personality.""" | |
| w = result["walkers"] | |
| lines = [ | |
| "QUARK-ARRANGED SKYRMS WALKER PERSONALITY", | |
| "=" * 50, "", | |
| f"Settlement: {result['rounds']} rounds | Energy: {result['energy']:.4f} | Confined: {result['confined']}", | |
| "", | |
| "FIVE WALKERS (settled values):", | |
| ] | |
| for i, (name, prim, param) in enumerate(zip(WALKER_NAMES, PRIMITIVES, PARAMS)): | |
| bar = "█" * int(w[i] * 20) | |
| lines.append(f" {name:8s} ({prim:10s}) = {w[i]:.3f} {bar}") | |
| lines.extend(["", "TEN BOSONS (pairwise tensions):"]) | |
| for i, (a, b, label) in enumerate(BOSON_PAIRS): | |
| v = result["bosons"][i] | |
| indicator = "🔴" if v > 0.3 else "🟡" if v > 0.15 else "🟢" | |
| lines.append(f" {indicator} {label:20s} = {v:.3f}") | |
| lines.extend(["", "THEOREMS (all proved in Lean 4, zero sorry):", | |
| " THM-FIVE-MAP-TO-FIVE: walkers = primitives = hyperparameters", | |
| " THM-NO-FREE-QUARKS: cannot remove one walker (confinement)", | |
| " THM-GAUGE-WALKER-AGREE: gauge field peak = walker peak", | |
| f" THM-WIREFRAME-IS-VACUUM: all equal → energy = 0 (balanced = {result['energy'] < 0.01})", | |
| ]) | |
| # Dominant personality interpretation | |
| dominant = WALKER_NAMES[np.argmax(w)] | |
| weakest = WALKER_NAMES[np.argmin(w)] | |
| lines.extend(["", f"INTERPRETATION:", | |
| f" Dominant axis: {dominant} (strongest pull)", | |
| f" Shadow axis: {weakest} (most rejected, deepest void)", | |
| f" The void boundary of {weakest} contains the most information.", | |
| ]) | |
| return "\n".join(lines) | |
| # ─── Gradio App ────────────────────────────────────────────────────────────── | |
| def run_settlement(preset, try_v, choose_v, commit_v, letgo_v, learn_v, max_rounds): | |
| if preset != "Custom": | |
| vals = PRESETS[preset] | |
| try_v, choose_v, commit_v, letgo_v, learn_v = vals | |
| result = settle_personality( | |
| [try_v, choose_v, commit_v, letgo_v, learn_v], | |
| max_rounds=int(max_rounds), | |
| ) | |
| return ( | |
| plot_walkers(result), | |
| plot_bosons(result), | |
| plot_convergence(result), | |
| format_summary(result), | |
| try_v, choose_v, commit_v, letgo_v, learn_v, | |
| ) | |
| CSS = """ | |
| .gradio-container { max-width: 1100px !important; margin: 0 auto !important; } | |
| .gradio-container, .dark { background: #09090b !important; } | |
| footer { display: none !important; } | |
| """ | |
| with gr.Blocks(css=CSS, theme=gr.themes.Base(primary_hue="cyan", neutral_hue="zinc"), | |
| title="Quark Personality") as demo: | |
| gr.HTML(""" | |
| <div style="text-align:center; padding:2rem 0 1rem"> | |
| <h1 style="font-size:2.2rem; font-weight:300; color:#fafafa; margin:0"> | |
| Quark-Arranged <span style="color:#06b6d4">Skyrms Walker</span> Personality | |
| </h1> | |
| <p style="color:#71717a; font-size:.9rem; margin-top:.5rem; line-height:1.6"> | |
| Five walkers. Ten bosons. Quark confinement. Settlement to Nash equilibrium.<br> | |
| A personality is not what you are. It is what you are not.<br> | |
| The void boundary -- accumulated rejections across five dimensions of irreversible choice -- IS the person.<br> | |
| Hot off Lean 4. Zero sorry. | |
| </p> | |
| </div> | |
| """) | |
| with gr.Row(): | |
| preset = gr.Dropdown(choices=list(PRESETS.keys()), value="Explorer", label="Preset", scale=1) | |
| max_rounds = gr.Slider(10, 500, value=100, step=10, label="Max settlement rounds", scale=1) | |
| run_btn = gr.Button("Settle Personality", variant="primary", scale=1) | |
| with gr.Row(): | |
| try_v = gr.Slider(0.01, 0.99, value=0.9, step=0.01, label="Try (Fork)") | |
| choose_v = gr.Slider(0.01, 0.99, value=0.4, step=0.01, label="Choose (Race)") | |
| commit_v = gr.Slider(0.01, 0.99, value=0.3, step=0.01, label="Commit (Fold)") | |
| letgo_v = gr.Slider(0.01, 0.99, value=0.7, step=0.01, label="LetGo (Vent)") | |
| learn_v = gr.Slider(0.01, 0.99, value=0.8, step=0.01, label="Learn (Interfere)") | |
| with gr.Row(): | |
| walker_plot = gr.Plot(label="Five Walkers") | |
| boson_plot = gr.Plot(label="Ten Bosons") | |
| convergence_plot = gr.Plot(label="Settlement Convergence") | |
| with gr.Accordion("Full Analysis", open=False): | |
| summary = gr.Textbox(lines=30, show_label=False, interactive=False) | |
| def on_preset(p): | |
| vals = PRESETS.get(p, PRESETS["Custom"]) | |
| return vals | |
| preset.change(on_preset, [preset], [try_v, choose_v, commit_v, letgo_v, learn_v]) | |
| run_btn.click( | |
| run_settlement, | |
| [preset, try_v, choose_v, commit_v, letgo_v, learn_v, max_rounds], | |
| [walker_plot, boson_plot, convergence_plot, summary, try_v, choose_v, commit_v, letgo_v, learn_v], | |
| ) | |
| demo.load( | |
| run_settlement, | |
| [preset, try_v, choose_v, commit_v, letgo_v, learn_v, max_rounds], | |
| [walker_plot, boson_plot, convergence_plot, summary, try_v, choose_v, commit_v, letgo_v, learn_v], | |
| ) | |
| gr.HTML(""" | |
| <div style="text-align:center; padding:2rem 0; border-top:1px solid #1f1f23; margin-top:2rem; font-size:.8rem; color:#52525b"> | |
| <p style="color:#a1a1aa; margin-bottom:.5rem"> | |
| THM-FIVE-MAP-TO-FIVE · THM-NO-FREE-QUARKS · THM-GAUGE-WALKER-AGREE · THM-WIREFRAME-IS-VACUUM | |
| </p> | |
| <p> | |
| <a href="https://forkracefold.com/" style="color:#06b6d4; text-decoration:none">Whitepaper</a> · | |
| <a href="https://huggingface.co/spaces/forkjoin-ai/the-void" style="color:#06b6d4; text-decoration:none">The Void</a> · | |
| <a href="https://huggingface.co/spaces/forkjoin-ai/glossolalia" style="color:#06b6d4; text-decoration:none">Glossolalia</a> · | |
| <a href="https://huggingface.co/spaces/forkjoin-ai/metacog" style="color:#06b6d4; text-decoration:none">Metacog</a> · | |
| <a href="https://huggingface.co/spaces/forkjoin-ai/five-bules" style="color:#06b6d4; text-decoration:none">Five Bules</a> · | |
| <a href="https://huggingface.co/spaces/forkjoin-ai/void-attention" style="color:#06b6d4; text-decoration:none">Void Attention</a> | |
| </p> | |
| <p style="margin-top:.5rem">φ² = φ + 1</p> | |
| <p style="margin-top:.5rem">Copyright 2026 forkjoin.ai</p> | |
| </div> | |
| """) | |
| if __name__ == "__main__": | |
| demo.launch(server_name="0.0.0.0", server_port=7860) | |