Spaces:
Runtime error
Runtime error
GitHub Copilot
commited on
Commit
Β·
ad814f5
1
Parent(s):
771b1f3
Complete rebuild: Premium LOGOS v1.0 Space with Log Polar Cone, MTL Interpreter, Genesis Block
Browse files
app.py
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import numpy as np
|
| 3 |
import plotly.graph_objects as go
|
| 4 |
import sympy
|
| 5 |
-
import
|
| 6 |
import os
|
| 7 |
import sys
|
| 8 |
-
|
|
|
|
| 9 |
|
| 10 |
# Ensure logos package is importable
|
| 11 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
@@ -13,419 +24,453 @@ if current_dir not in sys.path:
|
|
| 13 |
sys.path.insert(0, current_dir)
|
| 14 |
|
| 15 |
# --- LOGOS CORE IMPORTS ---
|
|
|
|
| 16 |
try:
|
| 17 |
from logos.mtl.interpreter import MTLInterpreter
|
| 18 |
-
from logos.memory.prime_db import PrimeTokenDB
|
| 19 |
MTL_AVAILABLE = True
|
| 20 |
-
print("[LOGOS] MTL Interpreter loaded
|
| 21 |
except ImportError as e:
|
| 22 |
-
MTL_AVAILABLE = False
|
| 23 |
print(f"[LOGOS] MTL not available: {e}")
|
| 24 |
|
| 25 |
-
|
| 26 |
-
from logos.dsp_bridge import DSPBridge
|
| 27 |
-
from logos.logos_core import PRIME_MODULO
|
| 28 |
-
print(f"[LOGOS] Successfully imported DSPBridge")
|
| 29 |
-
except ImportError:
|
| 30 |
-
DSPBridge = None
|
| 31 |
-
PRIME_MODULO = 9973
|
| 32 |
-
|
| 33 |
-
# --- PROTOCOL 26: START NEURAL ROUTER ---
|
| 34 |
-
import threading
|
| 35 |
-
import subprocess
|
| 36 |
-
|
| 37 |
def start_neural_router():
|
| 38 |
-
print("[SYSTEM] Igniting Neural Router (Port 5000)...")
|
| 39 |
try:
|
| 40 |
-
|
| 41 |
-
[sys.executable, "-m", "logos.server"],
|
| 42 |
env={**os.environ, "PYTHONPATH": current_dir},
|
| 43 |
-
stdout=subprocess.
|
| 44 |
-
stderr=subprocess.
|
| 45 |
-
text=True,
|
| 46 |
-
bufsize=1
|
| 47 |
)
|
| 48 |
-
print(
|
| 49 |
-
|
| 50 |
-
def stream_logs(p):
|
| 51 |
-
for line in iter(p.stdout.readline, ''):
|
| 52 |
-
print(f"[ROUTER] {line.strip()}")
|
| 53 |
-
|
| 54 |
-
threading.Thread(target=stream_logs, args=(process,), daemon=True).start()
|
| 55 |
-
|
| 56 |
except Exception as e:
|
| 57 |
-
print(f"[
|
| 58 |
|
| 59 |
threading.Thread(target=start_neural_router, daemon=True).start()
|
| 60 |
|
| 61 |
-
#
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
def execute_mtl(code: str) -> str:
|
| 71 |
-
"""Execute MTL code and return result."""
|
| 72 |
if not MTL_AVAILABLE:
|
| 73 |
-
return "MTL Interpreter not available
|
| 74 |
-
|
|
|
|
| 75 |
try:
|
| 76 |
-
|
| 77 |
-
result =
|
| 78 |
-
return f"
|
| 79 |
except Exception as e:
|
| 80 |
return f"Error: {str(e)}"
|
| 81 |
|
| 82 |
-
def
|
| 83 |
-
"""Run a demonstration of MTL capabilities."""
|
| 84 |
if not MTL_AVAILABLE:
|
| 85 |
return "MTL not available"
|
| 86 |
|
| 87 |
try:
|
| 88 |
mtl = MTLInterpreter()
|
| 89 |
-
|
| 90 |
|
| 91 |
-
|
|
|
|
|
|
|
| 92 |
|
| 93 |
-
#
|
| 94 |
-
|
| 95 |
r = mtl.execute('(mult [2] [3])')
|
| 96 |
-
|
|
|
|
| 97 |
|
| 98 |
-
# Logic
|
| 99 |
-
|
| 100 |
r = mtl.execute('(or [2] [3])')
|
| 101 |
-
|
| 102 |
r = mtl.execute('(and [6] [10])')
|
| 103 |
-
|
| 104 |
|
| 105 |
# Factorial
|
| 106 |
-
|
| 107 |
-
mtl.execute('(defun
|
| 108 |
-
r = mtl.execute('(
|
| 109 |
-
|
| 110 |
|
| 111 |
# Synapse
|
| 112 |
-
|
| 113 |
r = mtl.execute('(relate [17] [19])')
|
| 114 |
-
|
|
|
|
| 115 |
|
| 116 |
-
|
|
|
|
|
|
|
| 117 |
|
| 118 |
-
return "\n".join(
|
| 119 |
except Exception as e:
|
| 120 |
-
return f"
|
| 121 |
|
| 122 |
-
#
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
- Special lanes: mod 1, 3, 7, 9 (prime-generating residues)
|
| 128 |
-
"""
|
| 129 |
-
import math
|
| 130 |
fig = go.Figure()
|
| 131 |
|
| 132 |
-
#
|
| 133 |
-
all_nums = list(range(1, max_n))
|
| 134 |
-
|
| 135 |
-
# Color by mod 10 residue class
|
| 136 |
-
residue_colors = {
|
| 137 |
-
1: '#00ffea', # Cyan - Prime lane
|
| 138 |
-
3: '#ff00ff', # Magenta - Prime lane
|
| 139 |
-
7: '#ffff00', # Yellow - Prime lane
|
| 140 |
-
9: '#00ff00', # Green - Prime lane
|
| 141 |
-
0: '#333333', # Gray - Even decade
|
| 142 |
-
2: '#333333', 4: '#333333', 5: '#333333',
|
| 143 |
-
6: '#333333', 8: '#333333'
|
| 144 |
-
}
|
| 145 |
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
# Log polar coordinates
|
| 151 |
-
# r = log10(n) gives concentric rings per decade
|
| 152 |
-
# theta = (n mod 10) * 36 degrees + offset for spread
|
| 153 |
-
r = [math.log10(n) if n > 0 else 0 for n in nums_in_class]
|
| 154 |
-
theta = [(n % 100) * 3.6 for n in nums_in_class] # Spread within decade
|
| 155 |
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
colors = [residue_colors[residue] if p else '#555555' for p in is_prime]
|
| 160 |
|
| 161 |
fig.add_trace(go.Scatterpolar(
|
| 162 |
-
r=r,
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
marker=dict(
|
| 166 |
-
color=colors,
|
| 167 |
-
size=sizes,
|
| 168 |
-
line=dict(color='white', width=0.3),
|
| 169 |
-
opacity=0.8
|
| 170 |
-
),
|
| 171 |
-
text=[f"{n} (mod10={residue})" for n in nums_in_class],
|
| 172 |
hoverinfo='text',
|
| 173 |
name=f'Mod {residue}'
|
| 174 |
))
|
| 175 |
|
| 176 |
-
#
|
| 177 |
-
for
|
| 178 |
-
r_ring = math.log10(decade)
|
| 179 |
-
theta_ring = list(range(0, 360, 10))
|
| 180 |
fig.add_trace(go.Scatterpolar(
|
| 181 |
-
r=[
|
| 182 |
-
theta=
|
| 183 |
mode='lines',
|
| 184 |
-
line=dict(color='rgba(255,255,255,0.
|
| 185 |
showlegend=False
|
| 186 |
))
|
| 187 |
|
| 188 |
fig.update_layout(
|
| 189 |
-
template="plotly_dark",
|
| 190 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 191 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 192 |
showlegend=True,
|
| 193 |
-
legend=dict(font=dict(color='white')),
|
| 194 |
polar=dict(
|
| 195 |
-
radialaxis=dict(
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
gridcolor='rgba(255,255,255,0.1)'
|
| 201 |
-
),
|
| 202 |
-
angularaxis=dict(
|
| 203 |
-
visible=True,
|
| 204 |
-
gridcolor='rgba(255,255,255,0.1)'
|
| 205 |
-
),
|
| 206 |
-
bgcolor='rgba(11,15,25,0.9)'
|
| 207 |
),
|
| 208 |
-
margin=dict(l=
|
| 209 |
-
height=
|
| 210 |
-
title=dict(
|
| 211 |
-
text="LOGOS Log Polar Cone (Mod 10 Rings)",
|
| 212 |
-
font=dict(color='white')
|
| 213 |
-
)
|
| 214 |
)
|
| 215 |
return fig
|
| 216 |
|
| 217 |
-
def
|
| 218 |
-
"""
|
| 219 |
-
genesis =
|
| 220 |
-
2
|
| 221 |
-
|
| 222 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
|
| 224 |
-
|
|
|
|
|
|
|
| 225 |
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
x=labels,
|
| 231 |
-
y=primes,
|
| 232 |
-
marker=dict(
|
| 233 |
-
color=primes,
|
| 234 |
-
colorscale='Plasma',
|
| 235 |
-
),
|
| 236 |
-
text=primes,
|
| 237 |
-
textposition='auto',
|
| 238 |
))
|
| 239 |
|
| 240 |
fig.update_layout(
|
| 241 |
-
template="plotly_dark",
|
| 242 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 243 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
height=
|
|
|
|
| 248 |
)
|
| 249 |
return fig
|
| 250 |
|
| 251 |
-
#
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
def fetch_manifold_diagnostics():
|
| 256 |
-
"""Polls the router for live physics state."""
|
| 257 |
-
import requests
|
| 258 |
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
<div style=
|
| 275 |
-
<div
|
| 276 |
-
<div
|
| 277 |
</div>
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
graph_html = "<div style='padding:20px; color:#666;'>Manifold Active</div>"
|
| 282 |
-
return status_html, graph_html
|
| 283 |
-
|
| 284 |
-
except Exception as e:
|
| 285 |
-
status_html = f"""
|
| 286 |
-
<div style='display: flex; gap: 20px; align-items: center;'>
|
| 287 |
-
<div style='background: rgba(255,165,0,0.1); padding: 10px; border: 1px solid orange; border-radius: 5px;'>
|
| 288 |
-
<div style='font-size: 10px; color: #888;'>SYSTEM STATUS</div>
|
| 289 |
-
<div style='font-size: 16px; color: orange; font-weight: bold;'>STANDALONE</div>
|
| 290 |
</div>
|
| 291 |
-
<div style=
|
| 292 |
-
<div
|
| 293 |
-
<div
|
| 294 |
</div>
|
| 295 |
</div>
|
| 296 |
-
"""
|
| 297 |
-
return status_html, "<div style='padding:20px; color:#666;'>Router not connected - MTL available for direct use</div>"
|
| 298 |
-
|
| 299 |
-
# --- APP LAYOUT ---
|
| 300 |
-
with gr.Blocks(theme=gr.themes.Soft(), css=load_css(), title="LOGOS: Arithmetic OS") as demo:
|
| 301 |
-
|
| 302 |
-
# 1. HERO HEADER
|
| 303 |
-
with gr.Row(elem_classes=["header-row"]):
|
| 304 |
-
gr.Markdown(f"""
|
| 305 |
-
# {PROTOCOL_NAME}
|
| 306 |
-
**{SUBTITLE}**
|
| 307 |
-
|
| 308 |
-
*Intelligence through structural mathematics, not statistical probability.*
|
| 309 |
""")
|
| 310 |
-
|
| 311 |
-
# 2. LIVE TELEMETRY
|
| 312 |
-
with gr.Row():
|
| 313 |
-
status_panel = gr.HTML(value="Initializing Telemetry...")
|
| 314 |
|
| 315 |
-
#
|
| 316 |
with gr.Tabs():
|
| 317 |
|
| 318 |
-
# TAB
|
| 319 |
-
with gr.
|
| 320 |
with gr.Row():
|
| 321 |
-
with gr.Column(scale=
|
| 322 |
-
|
| 323 |
label="MTL Code",
|
| 324 |
-
|
| 325 |
-
|
|
|
|
| 326 |
)
|
| 327 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
examples=[
|
| 329 |
["(mult [2] [3])"],
|
| 330 |
["(or [17] [19])"],
|
| 331 |
["(and [6] [10])"],
|
| 332 |
["(relate [17] [19])"],
|
| 333 |
["(fractran [[5 2] [5 3]] 72)"],
|
|
|
|
| 334 |
],
|
| 335 |
-
inputs=
|
|
|
|
| 336 |
)
|
| 337 |
-
|
| 338 |
-
with gr.Column(scale=
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
mtl_demo_output = gr.Textbox(label="Demo Output", lines=15)
|
| 342 |
|
| 343 |
-
|
| 344 |
-
|
| 345 |
|
| 346 |
-
# TAB
|
| 347 |
-
with gr.
|
| 348 |
with gr.Row():
|
| 349 |
with gr.Column(scale=2):
|
| 350 |
-
|
| 351 |
with gr.Column(scale=1):
|
| 352 |
gr.Markdown("""
|
| 353 |
### The Root Manifold
|
| 354 |
|
| 355 |
-
| Prime | Concept |
|
| 356 |
-
|
| 357 |
-
| [2] | MECHANISM |
|
| 358 |
-
| [3] | RESULT |
|
| 359 |
-
| [5] | CHOICE |
|
| 360 |
-
| [7] | PERSIST |
|
| 361 |
-
| [11] | WHY |
|
| 362 |
-
| [13] | RELATE |
|
| 363 |
-
| [17] | IMAGE |
|
| 364 |
-
| [19] | TEXT |
|
| 365 |
-
| [23] | AUDIO |
|
| 366 |
-
| [29] | SIGNAL |
|
|
|
|
|
|
|
| 367 |
|
| 368 |
-
|
|
|
|
|
|
|
|
|
|
| 369 |
""")
|
| 370 |
|
| 371 |
-
# TAB
|
| 372 |
-
with gr.
|
| 373 |
with gr.Row():
|
| 374 |
-
with gr.Column():
|
| 375 |
-
|
| 376 |
-
with gr.Column():
|
| 377 |
gr.Markdown("""
|
| 378 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
|
| 380 |
-
|
| 381 |
|
| 382 |
-
**
|
| 383 |
-
- **Cyan (1)**: Numbers ending in 1
|
| 384 |
-
- **Magenta (3)**: Numbers ending in 3
|
| 385 |
-
- **Yellow (7)**: Numbers ending in 7
|
| 386 |
-
- **Green (9)**: Numbers ending in 9
|
| 387 |
|
| 388 |
-
|
| 389 |
|
| 390 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 391 |
""")
|
| 392 |
|
| 393 |
-
# TAB
|
| 394 |
-
with gr.
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
msg = gr.Textbox(label="Message", placeholder="Ask LOGOS...")
|
| 398 |
-
clear = gr.Button("Clear")
|
| 399 |
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 422 |
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
|
|
|
|
|
|
| 426 |
|
| 427 |
-
#
|
| 428 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 429 |
|
|
|
|
| 430 |
if __name__ == "__main__":
|
| 431 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
LOGOS v1.0 - Logarithmic Ordering Generation Operating Software
|
| 3 |
+
Hugging Face Space Application
|
| 4 |
+
|
| 5 |
+
A structural AI framework where:
|
| 6 |
+
- Every concept is a Prime
|
| 7 |
+
- Every file is a Number
|
| 8 |
+
- Computing = Routing
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
import gradio as gr
|
| 12 |
import numpy as np
|
| 13 |
import plotly.graph_objects as go
|
| 14 |
import sympy
|
| 15 |
+
import math
|
| 16 |
import os
|
| 17 |
import sys
|
| 18 |
+
import threading
|
| 19 |
+
import subprocess
|
| 20 |
|
| 21 |
# Ensure logos package is importable
|
| 22 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
| 24 |
sys.path.insert(0, current_dir)
|
| 25 |
|
| 26 |
# --- LOGOS CORE IMPORTS ---
|
| 27 |
+
MTL_AVAILABLE = False
|
| 28 |
try:
|
| 29 |
from logos.mtl.interpreter import MTLInterpreter
|
|
|
|
| 30 |
MTL_AVAILABLE = True
|
| 31 |
+
print("[LOGOS] MTL Interpreter loaded")
|
| 32 |
except ImportError as e:
|
|
|
|
| 33 |
print(f"[LOGOS] MTL not available: {e}")
|
| 34 |
|
| 35 |
+
# --- NEURAL ROUTER (Background) ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
def start_neural_router():
|
|
|
|
| 37 |
try:
|
| 38 |
+
subprocess.Popen(
|
| 39 |
+
[sys.executable, "-m", "logos.server"],
|
| 40 |
env={**os.environ, "PYTHONPATH": current_dir},
|
| 41 |
+
stdout=subprocess.DEVNULL,
|
| 42 |
+
stderr=subprocess.DEVNULL
|
|
|
|
|
|
|
| 43 |
)
|
| 44 |
+
print("[LOGOS] Neural Router started on port 5000")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
except Exception as e:
|
| 46 |
+
print(f"[LOGOS] Router failed: {e}")
|
| 47 |
|
| 48 |
threading.Thread(target=start_neural_router, daemon=True).start()
|
| 49 |
|
| 50 |
+
# =============================================================================
|
| 51 |
+
# CUSTOM CSS - Premium Dark Theme
|
| 52 |
+
# =============================================================================
|
| 53 |
+
CUSTOM_CSS = """
|
| 54 |
+
:root {
|
| 55 |
+
--primary: #00ffea;
|
| 56 |
+
--secondary: #ff0055;
|
| 57 |
+
--accent: #9d4edd;
|
| 58 |
+
--bg-dark: #0a0e17;
|
| 59 |
+
--bg-card: #111827;
|
| 60 |
+
--text: #e5e7eb;
|
| 61 |
+
--text-dim: #6b7280;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
.gradio-container {
|
| 65 |
+
background: linear-gradient(135deg, #0a0e17 0%, #1a1f2e 100%) !important;
|
| 66 |
+
font-family: 'Inter', -apple-system, sans-serif !important;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
.header-title {
|
| 70 |
+
background: linear-gradient(90deg, #00ffea, #9d4edd, #ff0055);
|
| 71 |
+
-webkit-background-clip: text;
|
| 72 |
+
-webkit-text-fill-color: transparent;
|
| 73 |
+
font-size: 2.5rem !important;
|
| 74 |
+
font-weight: 800 !important;
|
| 75 |
+
text-align: center;
|
| 76 |
+
margin-bottom: 0.5rem;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
.header-subtitle {
|
| 80 |
+
color: #6b7280;
|
| 81 |
+
text-align: center;
|
| 82 |
+
font-size: 1rem;
|
| 83 |
+
margin-bottom: 1.5rem;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
.status-card {
|
| 87 |
+
background: linear-gradient(145deg, #111827, #1f2937);
|
| 88 |
+
border: 1px solid rgba(0, 255, 234, 0.2);
|
| 89 |
+
border-radius: 12px;
|
| 90 |
+
padding: 1rem;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
.metric-value {
|
| 94 |
+
font-size: 1.5rem;
|
| 95 |
+
font-weight: 700;
|
| 96 |
+
color: #00ffea;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
.metric-label {
|
| 100 |
+
font-size: 0.75rem;
|
| 101 |
+
color: #6b7280;
|
| 102 |
+
text-transform: uppercase;
|
| 103 |
+
}
|
| 104 |
|
| 105 |
+
.genesis-table td, .genesis-table th {
|
| 106 |
+
padding: 8px 16px;
|
| 107 |
+
border-bottom: 1px solid rgba(255,255,255,0.1);
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
.genesis-table th {
|
| 111 |
+
color: #00ffea;
|
| 112 |
+
font-weight: 600;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
.code-output {
|
| 116 |
+
background: #0d1117 !important;
|
| 117 |
+
border: 1px solid #30363d !important;
|
| 118 |
+
border-radius: 8px;
|
| 119 |
+
font-family: 'JetBrains Mono', 'Fira Code', monospace !important;
|
| 120 |
+
}
|
| 121 |
+
"""
|
| 122 |
+
|
| 123 |
+
# =============================================================================
|
| 124 |
+
# MTL INTERPRETER FUNCTIONS
|
| 125 |
+
# =============================================================================
|
| 126 |
def execute_mtl(code: str) -> str:
|
|
|
|
| 127 |
if not MTL_AVAILABLE:
|
| 128 |
+
return "Error: MTL Interpreter not available"
|
| 129 |
+
if not code.strip():
|
| 130 |
+
return "Enter MTL code to execute"
|
| 131 |
try:
|
| 132 |
+
mtl = MTLInterpreter()
|
| 133 |
+
result = mtl.execute(code)
|
| 134 |
+
return f">>> {result}"
|
| 135 |
except Exception as e:
|
| 136 |
return f"Error: {str(e)}"
|
| 137 |
|
| 138 |
+
def run_full_demo() -> str:
|
|
|
|
| 139 |
if not MTL_AVAILABLE:
|
| 140 |
return "MTL not available"
|
| 141 |
|
| 142 |
try:
|
| 143 |
mtl = MTLInterpreter()
|
| 144 |
+
lines = []
|
| 145 |
|
| 146 |
+
lines.append("=" * 50)
|
| 147 |
+
lines.append(" LOGOS MTL DEMONSTRATION")
|
| 148 |
+
lines.append("=" * 50)
|
| 149 |
|
| 150 |
+
# Arithmetic
|
| 151 |
+
lines.append("\n[1] TENSOR ARITHMETIC")
|
| 152 |
r = mtl.execute('(mult [2] [3])')
|
| 153 |
+
lines.append(f" (mult [2] [3]) = {r}")
|
| 154 |
+
lines.append(f" MECHANISM x RESULT = FLIP")
|
| 155 |
|
| 156 |
+
# Logic Gates
|
| 157 |
+
lines.append("\n[2] LOGIC GATES")
|
| 158 |
r = mtl.execute('(or [2] [3])')
|
| 159 |
+
lines.append(f" (or [2] [3]) = {r} (LCM - Superposition)")
|
| 160 |
r = mtl.execute('(and [6] [10])')
|
| 161 |
+
lines.append(f" (and [6] [10]) = {r} (GCD - Intersection)")
|
| 162 |
|
| 163 |
# Factorial
|
| 164 |
+
lines.append("\n[3] RECURSIVE FUNCTION")
|
| 165 |
+
mtl.execute('(defun fact (n) (if (lt? n 2) 1 (mult n (fact (sub n 1)))))')
|
| 166 |
+
r = mtl.execute('(fact 5)')
|
| 167 |
+
lines.append(f" (fact 5) = {r} (5! = 120)")
|
| 168 |
|
| 169 |
# Synapse
|
| 170 |
+
lines.append("\n[4] KNOWLEDGE GRAPH")
|
| 171 |
r = mtl.execute('(relate [17] [19])')
|
| 172 |
+
lines.append(f" (relate [17] [19]) = {r}")
|
| 173 |
+
lines.append(f" IMAGE x TEXT x RELATE = Synapse")
|
| 174 |
|
| 175 |
+
lines.append("\n" + "=" * 50)
|
| 176 |
+
lines.append(" TURING COMPLETENESS VERIFIED")
|
| 177 |
+
lines.append("=" * 50)
|
| 178 |
|
| 179 |
+
return "\n".join(lines)
|
| 180 |
except Exception as e:
|
| 181 |
+
return f"Error: {str(e)}"
|
| 182 |
|
| 183 |
+
# =============================================================================
|
| 184 |
+
# VISUALIZATIONS
|
| 185 |
+
# =============================================================================
|
| 186 |
+
def create_log_polar_cone(max_n=300):
|
| 187 |
+
"""LOGOS Log Polar Cone - Mod 10 Topology"""
|
|
|
|
|
|
|
|
|
|
| 188 |
fig = go.Figure()
|
| 189 |
|
| 190 |
+
colors = {1: '#00ffea', 3: '#ff00ff', 7: '#ffff00', 9: '#00ff00'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
|
| 192 |
+
for residue in [1, 3, 7, 9]:
|
| 193 |
+
nums = [n for n in range(1, max_n) if n % 10 == residue]
|
| 194 |
+
r = [math.log10(n) for n in nums]
|
| 195 |
+
theta = [(n % 100) * 3.6 for n in nums]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
|
| 197 |
+
is_prime = [sympy.isprime(n) for n in nums]
|
| 198 |
+
sizes = [14 if p else 5 for p in is_prime]
|
| 199 |
+
cols = [colors[residue] if p else '#333' for p in is_prime]
|
|
|
|
| 200 |
|
| 201 |
fig.add_trace(go.Scatterpolar(
|
| 202 |
+
r=r, theta=theta, mode='markers',
|
| 203 |
+
marker=dict(color=cols, size=sizes, opacity=0.85),
|
| 204 |
+
text=[f"{n}" for n in nums],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
hoverinfo='text',
|
| 206 |
name=f'Mod {residue}'
|
| 207 |
))
|
| 208 |
|
| 209 |
+
# Decade rings
|
| 210 |
+
for d in [10, 100]:
|
|
|
|
|
|
|
| 211 |
fig.add_trace(go.Scatterpolar(
|
| 212 |
+
r=[math.log10(d)] * 36,
|
| 213 |
+
theta=list(range(0, 360, 10)),
|
| 214 |
mode='lines',
|
| 215 |
+
line=dict(color='rgba(255,255,255,0.15)', width=1, dash='dot'),
|
| 216 |
showlegend=False
|
| 217 |
))
|
| 218 |
|
| 219 |
fig.update_layout(
|
|
|
|
| 220 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 221 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 222 |
showlegend=True,
|
| 223 |
+
legend=dict(font=dict(color='white', size=10), x=0.85, y=0.95),
|
| 224 |
polar=dict(
|
| 225 |
+
radialaxis=dict(visible=True, range=[0, 2.5],
|
| 226 |
+
ticktext=['1', '10', '100'], tickvals=[0, 1, 2],
|
| 227 |
+
gridcolor='rgba(255,255,255,0.08)', color='#666'),
|
| 228 |
+
angularaxis=dict(visible=True, gridcolor='rgba(255,255,255,0.08)'),
|
| 229 |
+
bgcolor='rgba(17,24,39,0.95)'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
),
|
| 231 |
+
margin=dict(l=30, r=30, t=50, b=30),
|
| 232 |
+
height=480,
|
| 233 |
+
title=dict(text="Log Polar Cone (Mod 10)", font=dict(color='#00ffea', size=14))
|
|
|
|
|
|
|
|
|
|
| 234 |
)
|
| 235 |
return fig
|
| 236 |
|
| 237 |
+
def create_genesis_chart():
|
| 238 |
+
"""Genesis Block Bar Chart"""
|
| 239 |
+
genesis = [
|
| 240 |
+
(2, "MECHANISM", "#00ffea"),
|
| 241 |
+
(3, "RESULT", "#00d4aa"),
|
| 242 |
+
(5, "CHOICE", "#00aa88"),
|
| 243 |
+
(7, "PERSIST", "#ff0055"),
|
| 244 |
+
(11, "WHY", "#ff3377"),
|
| 245 |
+
(13, "RELATE", "#9d4edd"),
|
| 246 |
+
(17, "IMAGE", "#7c3aed"),
|
| 247 |
+
(19, "TEXT", "#6366f1"),
|
| 248 |
+
(23, "AUDIO", "#3b82f6"),
|
| 249 |
+
(29, "SIGNAL", "#0ea5e9"),
|
| 250 |
+
]
|
| 251 |
|
| 252 |
+
primes = [g[0] for g in genesis]
|
| 253 |
+
labels = [g[1] for g in genesis]
|
| 254 |
+
colors = [g[2] for g in genesis]
|
| 255 |
|
| 256 |
+
fig = go.Figure(go.Bar(
|
| 257 |
+
x=labels, y=primes,
|
| 258 |
+
marker=dict(color=colors, line=dict(width=0)),
|
| 259 |
+
text=primes, textposition='auto', textfont=dict(color='white', size=12)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
))
|
| 261 |
|
| 262 |
fig.update_layout(
|
|
|
|
| 263 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 264 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 265 |
+
xaxis=dict(tickfont=dict(color='#9ca3af', size=10), gridcolor='rgba(255,255,255,0.05)'),
|
| 266 |
+
yaxis=dict(tickfont=dict(color='#9ca3af'), gridcolor='rgba(255,255,255,0.05)', title='Prime Value'),
|
| 267 |
+
margin=dict(l=50, r=20, t=40, b=60),
|
| 268 |
+
height=350,
|
| 269 |
+
title=dict(text="Genesis Block Axioms", font=dict(color='#9d4edd', size=14))
|
| 270 |
)
|
| 271 |
return fig
|
| 272 |
|
| 273 |
+
# =============================================================================
|
| 274 |
+
# BUILD THE APP
|
| 275 |
+
# =============================================================================
|
| 276 |
+
with gr.Blocks(css=CUSTOM_CSS, title="LOGOS - Arithmetic OS", theme=gr.themes.Base()) as demo:
|
|
|
|
|
|
|
|
|
|
| 277 |
|
| 278 |
+
# HEADER
|
| 279 |
+
gr.HTML("""
|
| 280 |
+
<div style="text-align: center; padding: 2rem 0 1rem 0;">
|
| 281 |
+
<h1 class="header-title">LOGOS</h1>
|
| 282 |
+
<p class="header-subtitle">Logarithmic Ordering Generation Operating Software</p>
|
| 283 |
+
<p style="color: #4b5563; font-size: 0.85rem;">
|
| 284 |
+
Intelligence through structural mathematics β’ Computing = Routing
|
| 285 |
+
</p>
|
| 286 |
+
</div>
|
| 287 |
+
""")
|
| 288 |
+
|
| 289 |
+
# STATUS BAR
|
| 290 |
+
with gr.Row():
|
| 291 |
+
gr.HTML(f"""
|
| 292 |
+
<div style="display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; padding: 0.5rem;">
|
| 293 |
+
<div class="status-card" style="min-width: 120px; text-align: center;">
|
| 294 |
+
<div class="metric-label">MTL Engine</div>
|
| 295 |
+
<div class="metric-value">{'ONLINE' if MTL_AVAILABLE else 'OFFLINE'}</div>
|
| 296 |
</div>
|
| 297 |
+
<div class="status-card" style="min-width: 120px; text-align: center;">
|
| 298 |
+
<div class="metric-label">Version</div>
|
| 299 |
+
<div class="metric-value" style="color: #9d4edd;">1.0</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
</div>
|
| 301 |
+
<div class="status-card" style="min-width: 120px; text-align: center;">
|
| 302 |
+
<div class="metric-label">Protocol</div>
|
| 303 |
+
<div class="metric-value" style="color: #ff0055;">SPCW</div>
|
| 304 |
</div>
|
| 305 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
|
| 308 |
+
# MAIN TABS
|
| 309 |
with gr.Tabs():
|
| 310 |
|
| 311 |
+
# TAB 1: MTL INTERPRETER
|
| 312 |
+
with gr.TabItem("MTL Interpreter", id="mtl"):
|
| 313 |
with gr.Row():
|
| 314 |
+
with gr.Column(scale=3):
|
| 315 |
+
mtl_code = gr.Code(
|
| 316 |
label="MTL Code",
|
| 317 |
+
language="lisp",
|
| 318 |
+
value="(mult [2] [3])",
|
| 319 |
+
lines=4
|
| 320 |
)
|
| 321 |
+
with gr.Row():
|
| 322 |
+
run_btn = gr.Button("Execute", variant="primary", size="lg")
|
| 323 |
+
demo_btn = gr.Button("Run Demo", variant="secondary")
|
| 324 |
+
|
| 325 |
+
gr.Examples(
|
| 326 |
examples=[
|
| 327 |
["(mult [2] [3])"],
|
| 328 |
["(or [17] [19])"],
|
| 329 |
["(and [6] [10])"],
|
| 330 |
["(relate [17] [19])"],
|
| 331 |
["(fractran [[5 2] [5 3]] 72)"],
|
| 332 |
+
["(not [6] [6] [42])"],
|
| 333 |
],
|
| 334 |
+
inputs=mtl_code,
|
| 335 |
+
label="Quick Examples"
|
| 336 |
)
|
| 337 |
+
|
| 338 |
+
with gr.Column(scale=2):
|
| 339 |
+
mtl_result = gr.Textbox(label="Result", lines=2, elem_classes=["code-output"])
|
| 340 |
+
demo_output = gr.Textbox(label="Demo Output", lines=18, elem_classes=["code-output"])
|
|
|
|
| 341 |
|
| 342 |
+
run_btn.click(execute_mtl, inputs=mtl_code, outputs=mtl_result)
|
| 343 |
+
demo_btn.click(run_full_demo, outputs=demo_output)
|
| 344 |
|
| 345 |
+
# TAB 2: GENESIS BLOCK
|
| 346 |
+
with gr.TabItem("Genesis Block", id="genesis"):
|
| 347 |
with gr.Row():
|
| 348 |
with gr.Column(scale=2):
|
| 349 |
+
gr.Plot(value=create_genesis_chart(), label="Prime Axioms")
|
| 350 |
with gr.Column(scale=1):
|
| 351 |
gr.Markdown("""
|
| 352 |
### The Root Manifold
|
| 353 |
|
| 354 |
+
| Prime | Concept | Domain |
|
| 355 |
+
|:------|:--------|:-------|
|
| 356 |
+
| **[2]** | MECHANISM | Operator |
|
| 357 |
+
| **[3]** | RESULT | Operand |
|
| 358 |
+
| **[5]** | CHOICE | Branch |
|
| 359 |
+
| **[7]** | PERSIST | Memory |
|
| 360 |
+
| **[11]** | WHY | Query |
|
| 361 |
+
| **[13]** | RELATE | Link |
|
| 362 |
+
| **[17]** | IMAGE | Visual |
|
| 363 |
+
| **[19]** | TEXT | Linguistic |
|
| 364 |
+
| **[23]** | AUDIO | Acoustic |
|
| 365 |
+
| **[29]** | SIGNAL | Raw |
|
| 366 |
+
|
| 367 |
+
---
|
| 368 |
|
| 369 |
+
**Composite Domains:**
|
| 370 |
+
- `[6] = 2Γ3` β FLIP (Action)
|
| 371 |
+
- `[42] = 2Γ3Γ7` β DEEP STORAGE
|
| 372 |
+
- `[323] = 17Γ19` β VISUAL TEXT
|
| 373 |
""")
|
| 374 |
|
| 375 |
+
# TAB 3: PRIME TOPOLOGY
|
| 376 |
+
with gr.TabItem("Prime Topology", id="topology"):
|
| 377 |
with gr.Row():
|
| 378 |
+
with gr.Column(scale=2):
|
| 379 |
+
gr.Plot(value=create_log_polar_cone(), label="Log Polar Cone")
|
| 380 |
+
with gr.Column(scale=1):
|
| 381 |
gr.Markdown("""
|
| 382 |
+
### Log Polar Cone Topology
|
| 383 |
+
|
| 384 |
+
**Concentric Rings = Decades (Mod 10)**
|
| 385 |
+
|
| 386 |
+
**Prime Lanes:**
|
| 387 |
+
- π΅ **Mod 1** - Numbers ending in 1
|
| 388 |
+
- π£ **Mod 3** - Numbers ending in 3
|
| 389 |
+
- π‘ **Mod 7** - Numbers ending in 7
|
| 390 |
+
- π’ **Mod 9** - Numbers ending in 9
|
| 391 |
|
| 392 |
+
---
|
| 393 |
|
| 394 |
+
**Key Insight:**
|
|
|
|
|
|
|
|
|
|
|
|
|
| 395 |
|
| 396 |
+
All primes > 5 end in **1, 3, 7, or 9**.
|
| 397 |
|
| 398 |
+
These are the only residue classes coprime to 10.
|
| 399 |
+
|
| 400 |
+
The topology reveals prime distribution patterns through modular arithmetic.
|
| 401 |
+
|
| 402 |
+
---
|
| 403 |
+
|
| 404 |
+
*Large dots = Primes*
|
| 405 |
+
*Small dots = Composites*
|
| 406 |
""")
|
| 407 |
|
| 408 |
+
# TAB 4: DOCS
|
| 409 |
+
with gr.TabItem("Documentation", id="docs"):
|
| 410 |
+
gr.Markdown("""
|
| 411 |
+
# LOGOS Architecture
|
|
|
|
|
|
|
| 412 |
|
| 413 |
+
## The Five Imperatives
|
| 414 |
+
|
| 415 |
+
1. **Erasure of Statistical Probability** β Structural certainty via dissolution
|
| 416 |
+
2. **Solving the Amnesia Crisis** β Matroska topology for context isolation
|
| 417 |
+
3. **Structural Fidelity via Baking** β SSIM-based meaning preservation
|
| 418 |
+
4. **Optimal Agentic Digestion** β Agent Flow for tree-of-atoms optimization
|
| 419 |
+
5. **Self-Stabilizing Transport** β SPCW protocol with Delta Heat tracking
|
| 420 |
+
|
| 421 |
+
---
|
| 422 |
+
|
| 423 |
+
## Core Axiom
|
| 424 |
+
|
| 425 |
+
> **Computing a value IS routing it.**
|
| 426 |
+
|
| 427 |
+
A standard OS checks `if (condition)` then executes a jump.
|
| 428 |
+
LOGOS calculates `GCD(State, Filter)` and the result IS the address.
|
| 429 |
+
|
| 430 |
+
---
|
| 431 |
+
|
| 432 |
+
## Verified Components
|
| 433 |
+
|
| 434 |
+
| Module | Status | Function |
|
| 435 |
+
|:-------|:-------|:---------|
|
| 436 |
+
| MTL Interpreter | β
| Turing Complete |
|
| 437 |
+
| Genesis Kernel | β
| Agent Flow Lifecycle |
|
| 438 |
+
| SPCW Transceiver | β
| Binary Transport |
|
| 439 |
+
| Harmonizer | β
| Resonance Filter |
|
| 440 |
+
| Dissolution Engine | β
| Type Detection |
|
| 441 |
+
|
| 442 |
+
---
|
| 443 |
+
|
| 444 |
+
## MTL Quick Reference
|
| 445 |
+
|
| 446 |
+
```lisp
|
| 447 |
+
; Arithmetic
|
| 448 |
+
(mult [2] [3]) ; β 6
|
| 449 |
+
(div [6] [2]) ; β 3
|
| 450 |
+
|
| 451 |
+
; Logic Gates
|
| 452 |
+
(or [2] [3]) ; β 6 (LCM)
|
| 453 |
+
(and [6] [10]) ; β 2 (GCD)
|
| 454 |
+
(not [6] [6] [42]) ; β 42 (Steering)
|
| 455 |
+
|
| 456 |
+
; Knowledge Graph
|
| 457 |
+
(relate [17] [19]) ; β 4199 (Synapse)
|
| 458 |
+
(trace 4199 [17]) ; β 17 (Traceability)
|
| 459 |
|
| 460 |
+
; Recursion
|
| 461 |
+
(defun fact (n) (if (lt? n 2) 1 (mult n (fact (sub n 1)))))
|
| 462 |
+
(fact 5) ; β 120
|
| 463 |
+
```
|
| 464 |
+
""")
|
| 465 |
|
| 466 |
+
# FOOTER
|
| 467 |
+
gr.HTML("""
|
| 468 |
+
<div style="text-align: center; padding: 2rem 0 1rem 0; color: #4b5563; font-size: 0.8rem;">
|
| 469 |
+
<p>LOGOS v1.0 β’ Arithmetic is Architecture β’
|
| 470 |
+
<a href="https://github.com/ANXLOG" style="color: #00ffea;">GitHub</a></p>
|
| 471 |
+
</div>
|
| 472 |
+
""")
|
| 473 |
|
| 474 |
+
# LAUNCH
|
| 475 |
if __name__ == "__main__":
|
| 476 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|