| import gradio as gr |
| import numpy as np |
| import matplotlib.pyplot as plt |
| import hashlib |
| import os |
| from collections import deque |
|
|
| |
| |
| |
| DOC_PATH = "The_Minimum_Conscious_Universe_RFT_Project.md" |
| AWARENESS_THRESHOLD = 5.0 |
| np.random.seed(1) |
|
|
| |
| |
| |
| 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 |
|
|
| |
| |
| |
| 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 |
|
|
| |
| |
| |
| 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) |
|
|
| |
| |
| |
| 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() |