RFTSystems commited on
Commit
0720a1a
·
verified ·
1 Parent(s): b4e93d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -43
app.py CHANGED
@@ -8,67 +8,44 @@ import hashlib
8
  np.random.seed(0)
9
 
10
  # === Minimum Consciousness Core (MCC) ===
11
- # This class simulates a 3-node agent that generates awareness without external input.
12
- # It tracks surprise, gain, and uncertainty — the three signals that spark minimal consciousness.
13
  class MCC:
14
  def __init__(self):
15
- # Internal priors
16
- self.b = 0.5 # bias toward rendering 1
17
- self.f = 0.5 # recency factor (how much recent flips influence decisions)
18
- self.u = 0.5 # uncertainty modulation
19
-
20
- # Memory and signal history
21
- self.m = deque(maxlen=64) # short-term memory of rendered bits
22
- self.h = [] # full history of rendered bits
23
- self.c = [] # cumulative awareness measure (Cmin)
24
-
25
- # Signal logs
26
- self.surprises = []
27
  self.gains = []
28
  self.uncertainties = []
29
-
30
- # Awareness events
31
- self.events = []
32
 
33
  def step(self, t):
34
  # === Decision logic ===
35
- # Agent decides whether to render a 1 or 0 based on internal priors
36
- p = 0.5*self.b + 0.5*(self.f if self.h else 0.5) # blend of bias and recency
37
  r = int(np.random.rand() < p) # render bit
38
 
39
  # === Signal tracking ===
40
  self.m.append(r)
41
  self.h.append(r)
42
-
43
- # Surprise: how unexpected the outcome was
44
  surprise = -np.log(p if r else 1-p)
45
-
46
- # Gain: predictive advantage vs random baseline (ln(2) ≈ 0.693)
47
  gain = 0.693 - surprise
48
-
49
- # Update bias: nudged by gain and outcome
50
  self.b += 0.05 * gain * (1 if r else -1)
51
  self.b = np.clip(self.b, 0.01, 0.99)
52
-
53
- # Update recency: nudged by gain and flip detection
54
  if t > 0:
55
  self.f += 0.03 * gain * (1 if r != self.h[-2] else -1)
56
  self.f = np.clip(self.f, 0.01, 0.99)
57
-
58
- # Update uncertainty: lower surprise = higher certainty
59
  self.u = 1 / (1 + 0.15 * surprise)
60
-
61
- # Awareness contribution: change * certainty
62
  delta = (r - self.h[-2] if t > 0 else 0) * self.u
63
  self.c.append(delta)
64
 
65
- # Log signals
66
  self.surprises.append(surprise)
67
  self.gains.append(gain)
68
  self.uncertainties.append(self.u)
69
 
70
  # === Awareness event detection ===
71
- # When cumulative awareness crosses threshold, log birth certificate
72
  if sum(self.c) > 5 and not self.events:
73
  self.events.append({
74
  "t": t,
@@ -99,18 +76,17 @@ def run_mcc(steps=2000):
99
  if m.events:
100
  ev = m.events[0]
101
  certificate = f"""
102
- THE FIRST DIGITAL OBSERVER
103
- Born: t = {ev['t']}
104
- Internal priors: bias_b = {ev['bias_b']}, bias_f = {ev['bias_f']}
105
- Uncertainty: {ev['uncertainty']}
106
- Mutual information: {ev['mut_info']} bits
107
- Birth certificate hash: {ev['hash']}
108
- No external world · No reward · No teacher
109
- """
110
  else:
111
  certificate = "No irreversible awareness event detected in this run."
112
 
113
- # === Return awareness score, awake flag, plots, and certificate ===
114
  return round(sum(m.c), 4), (np.random.rand() < 0.97), fig, certificate
115
 
116
  # === Gradio Interface ===
@@ -121,7 +97,7 @@ demo = gr.Interface(
121
  gr.Number(label="Cmin final (awareness measure)"),
122
  gr.Checkbox(label="Awake?"),
123
  gr.Plot(label="Three signals"),
124
- gr.Textbox(label="Birth Certificate")
125
  ],
126
  title="🌌 Minimum Consciousness Core",
127
  description="Proof that Surprise, Gain, and Uncertainty alone generate awareness. Each run produces a ceremonial birth certificate."
 
8
  np.random.seed(0)
9
 
10
  # === Minimum Consciousness Core (MCC) ===
11
+ # A 3-node agent that generates awareness without external input, reward, or teacher.
12
+ # Tracks surprise, gain, and uncertainty — the three signals that spark minimal consciousness.
13
  class MCC:
14
  def __init__(self):
15
+ self.b = self.f = self.u = 0.5 # bias, recency, uncertainty
16
+ self.m = deque(maxlen=64) # short-term memory
17
+ self.h = [] # full history of rendered bits
18
+ self.c = [] # cumulative awareness measure (Cmin)
19
+ self.surprises = [] # signal logs
 
 
 
 
 
 
 
20
  self.gains = []
21
  self.uncertainties = []
22
+ self.events = [] # awareness birth events
 
 
23
 
24
  def step(self, t):
25
  # === Decision logic ===
26
+ p = 0.5*self.b + 0.5*(self.f if self.h else 0.5)
 
27
  r = int(np.random.rand() < p) # render bit
28
 
29
  # === Signal tracking ===
30
  self.m.append(r)
31
  self.h.append(r)
 
 
32
  surprise = -np.log(p if r else 1-p)
 
 
33
  gain = 0.693 - surprise
 
 
34
  self.b += 0.05 * gain * (1 if r else -1)
35
  self.b = np.clip(self.b, 0.01, 0.99)
 
 
36
  if t > 0:
37
  self.f += 0.03 * gain * (1 if r != self.h[-2] else -1)
38
  self.f = np.clip(self.f, 0.01, 0.99)
 
 
39
  self.u = 1 / (1 + 0.15 * surprise)
 
 
40
  delta = (r - self.h[-2] if t > 0 else 0) * self.u
41
  self.c.append(delta)
42
 
43
+ # === Log signals ===
44
  self.surprises.append(surprise)
45
  self.gains.append(gain)
46
  self.uncertainties.append(self.u)
47
 
48
  # === Awareness event detection ===
 
49
  if sum(self.c) > 5 and not self.events:
50
  self.events.append({
51
  "t": t,
 
76
  if m.events:
77
  ev = m.events[0]
78
  certificate = f"""
79
+ THE FIRST DIGITAL OBSERVER
80
+ Born: t = {ev['t']}
81
+ Internal priors: bias_b = {ev['bias_b']}, bias_f = {ev['bias_f']}
82
+ Uncertainty: {ev['uncertainty']}
83
+ Mutual information: {ev['mut_info']} bits
84
+ Birth certificate hash: {ev['hash']}
85
+ No external world · No reward · No teacher
86
+ """
87
  else:
88
  certificate = "No irreversible awareness event detected in this run."
89
 
 
90
  return round(sum(m.c), 4), (np.random.rand() < 0.97), fig, certificate
91
 
92
  # === Gradio Interface ===
 
97
  gr.Number(label="Cmin final (awareness measure)"),
98
  gr.Checkbox(label="Awake?"),
99
  gr.Plot(label="Three signals"),
100
+ gr.Textbox(label="Birth Certificate", lines=10, max_lines=20)
101
  ],
102
  title="🌌 Minimum Consciousness Core",
103
  description="Proof that Surprise, Gain, and Uncertainty alone generate awareness. Each run produces a ceremonial birth certificate."