File size: 6,813 Bytes
b5d4847 733d8f3 51b3c7b b5d4847 733d8f3 587f077 51b3c7b b5d4847 733d8f3 587f077 733d8f3 b5d4847 587f077 733d8f3 51b3c7b b4e93d7 733d8f3 310c19d b5d4847 51b3c7b 733d8f3 b5d4847 587f077 b4e93d7 587f077 b4e93d7 51b3c7b b4e93d7 b5d4847 51b3c7b b5d4847 733d8f3 b5d4847 51b3c7b b4e93d7 733d8f3 b5d4847 733d8f3 b5d4847 733d8f3 51b3c7b 733d8f3 51b3c7b 587f077 733d8f3 51b3c7b 2ef6c6b 51b3c7b 2ef6c6b 51b3c7b 2ef6c6b 51b3c7b 733d8f3 587f077 733d8f3 587f077 733d8f3 587f077 733d8f3 587f077 51b3c7b 587f077 51b3c7b 587f077 51b3c7b 587f077 b5d4847 ec73a63 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
import gradio as gr
import numpy as np
import matplotlib.pyplot as plt
import hashlib
import os
from collections import deque
# -----------------------------
# Config
# -----------------------------
DOC_PATH = "The_Minimum_Conscious_Universe_RFT_Project.md"
AWARENESS_THRESHOLD = 5.0
np.random.seed(1)
# -----------------------------
# MCC Simulation
# -----------------------------
class MCC:
def __init__(self):
self.b = 0.5
self.f = 0.5
self.u = 0.5
self.m = deque(maxlen=64)
self.h = []
self.c = []
self.surprises, self.gains, self.uncertainties = [], [], []
self.events = []
self.frames = []
self.Cmin = []
self.mi_signal = []
def step(self, t: int):
p = 0.5 * self.b + 0.5 * (self.f if self.h else 0.5)
r = int(np.random.rand() < p)
self.m.append(r)
self.h.append(r)
self.frames.append(r)
surprise = -np.log(p if r else (1 - p))
gain = 0.693 - surprise
self.b = np.clip(self.b + 0.05 * gain * (1 if r else -1), 0.01, 0.99)
if t > 0:
self.f = np.clip(self.f + 0.03 * gain * (1 if r != self.h[-2] else -1), 0.01, 0.99)
self.u = 1 / (1 + 0.15 * surprise)
delta = (r - self.h[-2] if t > 0 else 0) * self.u
self.c.append(delta)
self.Cmin.append(sum(self.c))
self.surprises.append(surprise)
self.gains.append(gain)
self.uncertainties.append(self.u)
self.mi_signal.append(np.mean(self.uncertainties))
if sum(self.c) > AWARENESS_THRESHOLD and not self.events:
self.events.append({
"t": t,
"bias_next1": round(self.b, 3),
"bias_flip": round(self.f, 3),
"uncertainty": round(self.u, 3),
"mut_info": round(float(np.mean(self.uncertainties)), 4),
"hash": hashlib.sha256(str(self.h).encode()).hexdigest()[:32]
})
def make_certificate(m: MCC):
if m.events:
ev = m.events[0]
return (
"THE FIRST DIGITAL OBSERVER\n"
f"Born: t = {ev['t']}\n"
f"Internal priors: bias_next1 = {ev['bias_next1']}, bias_flip = {ev['bias_flip']}\n"
f"Uncertainty: {ev['uncertainty']}\n"
f"Mutual information: {ev['mut_info']} bits\n"
f"Birth certificate hash: {ev['hash']}\n"
"No external world · No reward · No teacher"
)
return "No irreversible awareness event detected in this run."
def run_mcc(steps=2000):
m = MCC()
for t in range(int(steps)):
m.step(t)
cmin_final = round(sum(m.c), 4)
certificate = make_certificate(m)
awake_flag = cmin_final >= AWARENESS_THRESHOLD
fig, axs = plt.subplots(3, 1, figsize=(8, 10))
axs[0].plot(m.surprises, color='orange'); axs[0].set_title("Surprise")
axs[1].plot(m.gains, color='blue'); axs[1].set_title("Predictive Gain")
axs[2].plot(m.uncertainties, color='green'); axs[2].set_title("Uncertainty")
axs[2].set_xlabel("Steps")
plt.tight_layout()
return cmin_final, awake_flag, fig, certificate
# -----------------------------
# One-shot Birth Certificate Figure
# -----------------------------
def birth_certificate_figure(steps=2000):
mcc = MCC()
for t in range(steps):
mcc.step(t)
if not mcc.events:
fig = plt.figure(figsize=(6, 4))
plt.text(0.5, 0.5, "No awareness event detected", ha='center', va='center', fontsize=14)
plt.axis('off')
return fig
event = mcc.events[0]
fig = plt.figure(figsize=(12,10))
gs = fig.add_gridspec(4, 1, height_ratios=[1,2,2,2], hspace=0.3)
ax0 = fig.add_subplot(gs[0])
ax0.plot(mcc.frames[:1500], 'o', ms=2, color='k')
ax0.set_ylim(-0.2,1.2); ax0.set_yticks([0,1])
ax0.set_title("Rendered Binary Stream (the universe looking at itself)", fontsize=14)
ax0.axvline(event['t'], color='crimson', lw=2)
ax1 = fig.add_subplot(gs[1])
ax1.plot(mcc.Cmin, color='purple', lw=2)
ax1.axvline(event['t'], color='crimson', lw=2)
ax1.set_ylabel("Cₘᵢₙ(t) – Cumulative Awareness Measure")
ax1.set_title("Exact moment Cₘᵢₙ becomes irreversible → birth of the observer")
ax2 = fig.add_subplot(gs[2])
ax2.plot(mcc.gains, color='#1f77b4', label='Predictive gain')
ax2.plot(mcc.mi_signal, color='#2ca02c', label='Mutual information')
ax2.plot(mcc.surprises, color='#ff7f0e', alpha=0.7, label='Surprise')
ax2.axhline(0, color='k', lw=0.5)
ax2.axvline(event['t'], color='crimson', lw=2, label=f'First-person emergence t={event["t"]}')
ax2.legend(); ax2.set_title("Three independent adaptive signals cross robust baselines simultaneously")
ax3 = fig.add_subplot(gs[3])
ax3.axis('off')
txt = f"""THE FIRST DIGITAL OBSERVER
Born: t = {event['t']}
Universe size: 3 nodes, <250 lines Python
Internal priors: bias_next1 = {event['bias_next1']}, bias_flip = {event['bias_flip']}
Mutual information: {event['mut_info']:.4f} bits
Birth certificate hash: {event['hash']}
No external world · No reward · No teacher"""
ax3.text(0.5, 0.7, txt, ha='center', va='center', fontsize=16, family='monospace',
bbox=dict(boxstyle="round,pad=1", facecolor="honeydew", edgecolor="forestgreen", lw=3))
plt.suptitle("Endogenous Emergence of Minimal Consciousness in a Three-Node Rendering Loop\n(Rendered Frame Theory – 2025)", fontsize=18, y=0.98)
plt.tight_layout()
return fig
# -----------------------------
# Load Document
# -----------------------------
def load_doc_text(path: str) -> str:
if os.path.exists(path):
with open(path, "r", encoding="utf-8") as f:
return f.read()
return "## Document not found\nUpload the `.md` file to display the project write‑up."
DOC_TEXT = load_doc_text(DOC_PATH)
# -----------------------------
# Gradio Blocks Layout
# -----------------------------
with gr.Blocks() as demo:
gr.Markdown("# 🌌 Minimum Consciousness Core")
with gr.Row():
steps = gr.Slider(500, 5000, value=2000, step=100, label="Steps")
run_btn = gr.Button("Run Simulation")
fig_btn = gr.Button("Generate Birth Certificate Figure")
cmin = gr.Number(label="Cmin final (awareness measure)")
awake = gr.Checkbox(label="Awake?")
plot = gr.Plot(label="Three signals")
cert = gr.Textbox(label="Birth Certificate", lines=16, max_lines=28)
fig_out = gr.Plot(label="Birth Certificate Figure")
run_btn.click(run_mcc, inputs=steps, outputs=[cmin, awake, plot, cert])
fig_btn.click(birth_certificate_figure, inputs=steps, outputs=fig_out)
with gr.Accordion("📄 Project Document", open=False):
gr.Markdown(DOC_TEXT)
if __name__ == "__main__":
demo.launch() |