Spaces:
Runtime error
Runtime error
GitHub Copilot
commited on
Commit
·
771b1f3
1
Parent(s):
6d3aa82
Fix: LOGOS Log Polar Cone Topology (mod 10 rings, 1/3/7/9 lanes)
Browse files
app.py
CHANGED
|
@@ -120,37 +120,97 @@ def run_mtl_demo() -> str:
|
|
| 120 |
return f"Demo Error: {str(e)}"
|
| 121 |
|
| 122 |
# --- PHYSICS VISUALIZERS ---
|
| 123 |
-
def get_prime_topology(max_n=
|
| 124 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
fig = go.Figure()
|
| 126 |
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
theta = [n * 2.39996 for n in primes] # Golden Angle
|
| 130 |
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
fig.update_layout(
|
| 143 |
template="plotly_dark",
|
| 144 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 145 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 146 |
-
showlegend=
|
|
|
|
| 147 |
polar=dict(
|
| 148 |
-
radialaxis=dict(
|
| 149 |
-
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
),
|
| 152 |
-
margin=dict(l=
|
| 153 |
-
height=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
)
|
| 155 |
return fig
|
| 156 |
|
|
@@ -312,17 +372,20 @@ with gr.Blocks(theme=gr.themes.Soft(), css=load_css(), title="LOGOS: Arithmetic
|
|
| 312 |
with gr.Tab("Prime Topology"):
|
| 313 |
with gr.Row():
|
| 314 |
with gr.Column():
|
| 315 |
-
prime_plot = gr.Plot(value=get_prime_topology(), label="
|
| 316 |
with gr.Column():
|
| 317 |
gr.Markdown("""
|
| 318 |
-
###
|
|
|
|
|
|
|
| 319 |
|
| 320 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
|
| 322 |
-
**
|
| 323 |
-
- Ulam spiral structures
|
| 324 |
-
- Twin prime clustering
|
| 325 |
-
- Gap distribution
|
| 326 |
|
| 327 |
*Arithmetic is Architecture.*
|
| 328 |
""")
|
|
|
|
| 120 |
return f"Demo Error: {str(e)}"
|
| 121 |
|
| 122 |
# --- PHYSICS VISUALIZERS ---
|
| 123 |
+
def get_prime_topology(max_n=500):
|
| 124 |
+
"""
|
| 125 |
+
LOGOS Concentric Log Polar Cone Topology.
|
| 126 |
+
- Each ring = mod 10 (decade layer)
|
| 127 |
+
- Special lanes: mod 1, 3, 7, 9 (prime-generating residues)
|
| 128 |
+
"""
|
| 129 |
+
import math
|
| 130 |
fig = go.Figure()
|
| 131 |
|
| 132 |
+
# Generate numbers and categorize by mod 10
|
| 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 |
+
# Build traces for each residue class
|
| 147 |
+
for residue in [1, 3, 7, 9]: # Prime-generating lanes only
|
| 148 |
+
nums_in_class = [n for n in all_nums if n % 10 == residue]
|
| 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 |
+
# Mark primes
|
| 157 |
+
is_prime = [sympy.isprime(n) for n in nums_in_class]
|
| 158 |
+
sizes = [12 if p else 4 for p in is_prime]
|
| 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 |
+
theta=theta,
|
| 164 |
+
mode='markers',
|
| 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 |
+
# Add ring labels for decades
|
| 177 |
+
for decade in [10, 100]:
|
| 178 |
+
r_ring = math.log10(decade)
|
| 179 |
+
theta_ring = list(range(0, 360, 10))
|
| 180 |
+
fig.add_trace(go.Scatterpolar(
|
| 181 |
+
r=[r_ring] * len(theta_ring),
|
| 182 |
+
theta=theta_ring,
|
| 183 |
+
mode='lines',
|
| 184 |
+
line=dict(color='rgba(255,255,255,0.2)', width=1, dash='dot'),
|
| 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 |
+
visible=True,
|
| 197 |
+
range=[0, 3],
|
| 198 |
+
ticktext=['1', '10', '100', '1000'],
|
| 199 |
+
tickvals=[0, 1, 2, 3],
|
| 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=40, r=40, t=40, b=40),
|
| 209 |
+
height=550,
|
| 210 |
+
title=dict(
|
| 211 |
+
text="LOGOS Log Polar Cone (Mod 10 Rings)",
|
| 212 |
+
font=dict(color='white')
|
| 213 |
+
)
|
| 214 |
)
|
| 215 |
return fig
|
| 216 |
|
|
|
|
| 372 |
with gr.Tab("Prime Topology"):
|
| 373 |
with gr.Row():
|
| 374 |
with gr.Column():
|
| 375 |
+
prime_plot = gr.Plot(value=get_prime_topology(), label="Log Polar Cone")
|
| 376 |
with gr.Column():
|
| 377 |
gr.Markdown("""
|
| 378 |
+
### LOGOS Log Polar Cone Topology
|
| 379 |
+
|
| 380 |
+
**Concentric rings = Mod 10 decades**
|
| 381 |
|
| 382 |
+
**Prime Lanes (Mod 10 residues):**
|
| 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 |
+
Large dots = **Primes** (only end in 1,3,7,9)
|
|
|
|
|
|
|
|
|
|
| 389 |
|
| 390 |
*Arithmetic is Architecture.*
|
| 391 |
""")
|