ANXLOG commited on
Commit
1d5510c
·
verified ·
1 Parent(s): 23f5b34

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +69 -77
app.py CHANGED
@@ -4,14 +4,14 @@ import plotly.graph_objects as go
4
  import sympy
5
  import networkx as nx
6
 
7
- # --- MODULE 1: PRIME POTENTIALITY MATRIX (Mod 10 Waterfall) ---
8
- def generate_potentiality_matrix(sequence_length, persistence_threshold):
9
  """
10
  Visualizes the "Prime Potentiality" by aligning the integer stream to Mod 10.
11
- This reveals the 1, 3, 7, 9 'rivers' of potentiality vs the Composite 'banks'.
12
  """
13
- # 1. Create the Integer Stream (The Canvas)
14
- # We use a standard integer range because Primes exists *within* this potential
15
  integers = np.arange(sequence_length)
16
 
17
  # 2. Mod 10 Alignment (The "Natural" Width)
@@ -23,19 +23,16 @@ def generate_potentiality_matrix(sequence_length, persistence_threshold):
23
  padded_ints = np.pad(integers, (0, padded_len - len(integers)), mode='constant')
24
 
25
  # 3. Calculate "Potentiality" (The Heat)
26
- # We want to highlight Primes and their Residues
27
  matrix_values = np.zeros(padded_len)
28
 
29
  for i, val in enumerate(padded_ints):
30
- if sympy.isprime(int(val)):
31
- # Active Prime = High Heat (Visualized as distinct energy)
32
- matrix_values[i] = 1.0
33
  elif val % 2 == 0 or val % 5 == 0:
34
- # Structurally Composite (0, 2, 4, 5, 6, 8) = Persistence/Ground
35
- matrix_values[i] = 0.0
36
  else:
37
- # Composite but in a Prime Lane (e.g. 9, 21, 27) = "Potential"
38
- matrix_values[i] = 0.3
39
 
40
  # Reshape to Mod 10 Grid
41
  grid = matrix_values.reshape(rows, width)
@@ -45,16 +42,16 @@ def generate_potentiality_matrix(sequence_length, persistence_threshold):
45
  z=grid,
46
  x=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], # Explicit Mod 10 Columns
47
  colorscale=[
48
- [0.0, "#000000"], # Black: Ground State (Even/5s)
49
- [0.3, "#2A2A5A"], # Blue: Potential (Odd Composites)
50
- [1.0, "#00FFEA"] # Cyan: Kinetic Prime (The Signal)
51
  ],
52
  showscale=False,
53
  hoverinfo='x+y+z'
54
  ))
55
 
56
  fig.update_layout(
57
- title=f"Prime Potentiality Matrix (Mod 10 alignment)",
58
  xaxis_title="Modulus 10 Residue (Last Digit)",
59
  yaxis_title="Sequence Depth (Time)",
60
  template="plotly_dark",
@@ -63,97 +60,92 @@ def generate_potentiality_matrix(sequence_length, persistence_threshold):
63
  )
64
  return fig
65
 
66
- # --- MODULE 2: NESTED MATROSKA NETWORK (Hexagonal Shells) ---
67
- def visualize_matroska_network(shells, show_connectors):
68
  """
69
- Constructs the Matroska Network using Hexagonal Tiling.
70
- Each shell represents a Prime Modulo Domain.
71
  """
72
  fig = go.Figure()
73
 
74
- # Colors for the "Heat" of each shell
75
- colors = ["#FF0000", "#FF7F00", "#FFFF00", "#00FF00", "#0000FF", "#4B0082", "#9400D3"]
76
-
77
- for layer in range(1, shells + 1):
78
- # Hexagonal Geometry Logic
79
- # A layer N in a hex grid has 6*N nodes
80
- nodes_in_layer = 6 * layer
81
- radius = layer * 10 # Spacing between shells
82
-
83
- # Generating the Hexagon path for this layer
84
- # We plot the "Wireframe" of the shell
85
- t = np.linspace(0, 2*np.pi, 7) # 7 points to close the loop
86
- hex_x = radius * np.cos(t)
87
- hex_y = radius * np.sin(t)
88
 
89
- # 1. Draw the Shell Boundary (The Domain)
90
  fig.add_trace(go.Scatter(
91
- x=hex_x, y=hex_y,
 
92
  mode='lines',
93
- line=dict(color=colors[(layer-1) % 7], width=2, dash='solid'),
94
- name=f"Domain Shell {layer}"
 
95
  ))
96
-
97
- # 2. Draw the Nodes (The Data Atoms)
98
- # Distributed along the perimeter
99
- node_angles = np.linspace(0, 2*np.pi, nodes_in_layer, endpoint=False)
100
- node_x = radius * np.cos(node_angles)
101
- node_y = radius * np.sin(node_angles)
 
 
102
 
103
  fig.add_trace(go.Scatter(
104
- x=node_x, y=node_y,
105
- mode='markers',
106
- marker=dict(size=6, color=colors[(layer-1) % 7]),
 
107
  showlegend=False
108
  ))
109
 
110
- # 3. Draw "Nested" Connectors (Inter-Domain Links)
111
- # This visualizes the "Dissolution" flow from Outer -> Inner
112
- if show_connectors and layer > 1:
113
- prev_radius = (layer - 1) * 10
114
- # Connect every X nodes to previous layer to show hierarchy
115
- for k in range(0, nodes_in_layer, layer):
116
- # Simple radial connection logic for demo
117
  fig.add_trace(go.Scatter(
118
- x=[node_x[k], (prev_radius * np.cos(node_angles[k]))],
119
- y=[node_y[k], (prev_radius * np.sin(node_angles[k]))],
120
- mode='lines',
121
- line=dict(color='#333', width=1),
122
  showlegend=False
123
  ))
124
 
125
  fig.update_layout(
126
- title="Modular Concentric Prime Matroska (Nested Domains)",
127
- showlegend=True,
128
  template="plotly_dark",
129
  xaxis=dict(showgrid=False, zeroline=False, visible=False),
130
  yaxis=dict(showgrid=False, zeroline=False, visible=False),
131
- width=800, height=800
 
132
  )
133
  return fig
134
 
135
  # --- THE INTERFACE ---
136
  with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
137
- gr.Markdown("# LOGOS: Modular Concentric Prime Matroska Network")
138
- gr.Markdown("Interactive architectural validation for **Mod 10 Potentiality** and **Nested Domains**.")
139
 
140
- with gr.Tab("Prime Potentiality Matrix"):
141
- gr.Markdown("Visualizing the 1, 3, 7, 9 Prime Avenues vs Composite Persistence.")
142
- with gr.Row():
143
- seq_len = gr.Slider(100, 10000, value=2000, step=100, label="Sequence Depth")
144
-
145
- matrix_plot = gr.Plot(label="Mod 10 Waterfall")
146
  btn_matrix = gr.Button("Generate Matrix")
147
  btn_matrix.click(generate_potentiality_matrix, inputs=[seq_len], outputs=matrix_plot)
148
 
149
- with gr.Tab("Matroska Topology"):
150
- gr.Markdown("Visualizing the concentric dissolution of high-heat data into prime-stable domains.")
151
  with gr.Row():
152
- shells_slider = gr.Slider(1, 20, value=6, step=1, label="Domain Depth (Shells)")
153
- show_links = gr.Checkbox(value=True, label="Show Inter-Domain Links")
154
 
155
- matroska_plot = gr.Plot(label="Network Topology")
156
- btn_net = gr.Button("Build Network")
157
- btn_net.click(visualize_matroska_network, inputs=[shells_slider, show_links], outputs=matroska_plot)
158
 
159
  demo.launch()
 
4
  import sympy
5
  import networkx as nx
6
 
7
+ # --- MODULE 1: PRIME POTENTIALITY MATRIX (The Stream) ---
8
+ def generate_potentiality_matrix(sequence_length):
9
  """
10
  Visualizes the "Prime Potentiality" by aligning the integer stream to Mod 10.
11
+ 1, 3, 7, 9 are the 'Active Lanes' (Rivers).
12
  """
13
+ # 1. Create the Integer Stream
14
+ # We go deep (up to 5000+) to show the river effect
15
  integers = np.arange(sequence_length)
16
 
17
  # 2. Mod 10 Alignment (The "Natural" Width)
 
23
  padded_ints = np.pad(integers, (0, padded_len - len(integers)), mode='constant')
24
 
25
  # 3. Calculate "Potentiality" (The Heat)
26
+ # 0 = Composite Ground, 0.5 = Potential Lane, 1.0 = Kinetic Prime
27
  matrix_values = np.zeros(padded_len)
28
 
29
  for i, val in enumerate(padded_ints):
30
+ if sympy.isprime(int(val)) and val > 5:
31
+ matrix_values[i] = 1.0 # Kinetic Signal (Prime)
 
32
  elif val % 2 == 0 or val % 5 == 0:
33
+ matrix_values[i] = 0.0 # Ground State (Composite)
 
34
  else:
35
+ matrix_values[i] = 0.2 # Potential Energy (Odd Composite in Prime Lane)
 
36
 
37
  # Reshape to Mod 10 Grid
38
  grid = matrix_values.reshape(rows, width)
 
42
  z=grid,
43
  x=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], # Explicit Mod 10 Columns
44
  colorscale=[
45
+ [0.0, "#0a0a0a"], # Pitch Black: Ground State
46
+ [0.2, "#1a1a40"], # Deep Blue: Potential Lane
47
+ [1.0, "#00ffea"] # Cyan Neon: Kinetic Prime
48
  ],
49
  showscale=False,
50
  hoverinfo='x+y+z'
51
  ))
52
 
53
  fig.update_layout(
54
+ title=f"Prime Potentiality Rivers (Mod 10)",
55
  xaxis_title="Modulus 10 Residue (Last Digit)",
56
  yaxis_title="Sequence Depth (Time)",
57
  template="plotly_dark",
 
60
  )
61
  return fig
62
 
63
+ # --- MODULE 2: MATROSKA TOPOLOGY (The Machine) ---
64
+ def visualize_prime_matroska(shells, show_feed):
65
  """
66
+ Constructs the Radial Prime-Indexed Topology.
67
+ Concentric Shells (Domains) intersected by Mod 10 Prime Vectors.
68
  """
69
  fig = go.Figure()
70
 
71
+ # 1. Draw the "Prime Vectors" (Spokes)
72
+ # These are the rails the data travels on
73
+ max_radius = shells * 10
74
+ for i in range(10):
75
+ angle = (2 * np.pi * i) / 10
76
+ # Color logic: 1,3,7,9 are "Hot" (Prime capable), others are "Cold"
77
+ is_prime_lane = i in [1, 3, 7, 9]
78
+ color = "#00ffea" if is_prime_lane else "#333"
79
+ width = 2 if is_prime_lane else 1
 
 
 
 
 
80
 
 
81
  fig.add_trace(go.Scatter(
82
+ x=[0, max_radius * np.cos(angle)],
83
+ y=[0, max_radius * np.sin(angle)],
84
  mode='lines',
85
+ line=dict(color=color, width=width),
86
+ name=f"Mod {i} Vector" if i == 0 else None,
87
+ showlegend=(i==0)
88
  ))
89
+
90
+ # 2. Draw the Concentric Shells (Domains)
91
+ # These are the Matroska Layers
92
+ for layer in range(1, shells + 1):
93
+ radius = layer * 10
94
+ t = np.linspace(0, 2*np.pi, 100)
95
+ x = radius * np.cos(t)
96
+ y = radius * np.sin(t)
97
 
98
  fig.add_trace(go.Scatter(
99
+ x=x, y=y,
100
+ mode='lines',
101
+ line=dict(color='#555', dash='dot'),
102
+ name=f"Shell {layer}",
103
  showlegend=False
104
  ))
105
 
106
+ # 3. Simulate "Data Atoms" residing in the shell
107
+ # They only land on the Prime Vectors (1, 3, 7, 9)
108
+ if show_feed:
109
+ for p_mod in [1, 3, 7, 9]:
110
+ p_angle = (2 * np.pi * p_mod) / 10
 
 
111
  fig.add_trace(go.Scatter(
112
+ x=[radius * np.cos(p_angle)],
113
+ y=[radius * np.sin(p_angle)],
114
+ mode='markers',
115
+ marker=dict(size=6, color='#ff0055'), # Red = Hot Data
116
  showlegend=False
117
  ))
118
 
119
  fig.update_layout(
120
+ title="Radial Prime-Indexed Matroska Network",
 
121
  template="plotly_dark",
122
  xaxis=dict(showgrid=False, zeroline=False, visible=False),
123
  yaxis=dict(showgrid=False, zeroline=False, visible=False),
124
+ width=800, height=800,
125
+ showlegend=False
126
  )
127
  return fig
128
 
129
  # --- THE INTERFACE ---
130
  with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
131
+ gr.Markdown("# LOGOS: Prime-Indexed Topology")
132
+ gr.Markdown("Visualizing the **Mod 10 Potentiality Rivers** and the **Radial Matroska Network**.")
133
 
134
+ with gr.Tab("Prime Potentiality (Mod 10)"):
135
+ gr.Markdown("The vertical 'Rivers' of prime potential (1, 3, 7, 9) vs the Composite banks.")
136
+ seq_len = gr.Slider(100, 10000, value=2500, label="Stream Depth")
137
+ matrix_plot = gr.Plot(label="Potentiality Matrix")
 
 
138
  btn_matrix = gr.Button("Generate Matrix")
139
  btn_matrix.click(generate_potentiality_matrix, inputs=[seq_len], outputs=matrix_plot)
140
 
141
+ with gr.Tab("Matroska Network (Radial)"):
142
+ gr.Markdown("The Destination Topology: Concentric Shells indexed by Prime Moduli.")
143
  with gr.Row():
144
+ shells_slider = gr.Slider(1, 20, value=5, step=1, label="Domain Depth (Shells)")
145
+ feed_toggle = gr.Checkbox(value=True, label="Show Active Atoms (Feed)")
146
 
147
+ matroska_plot = gr.Plot(label="Radial Topology")
148
+ btn_net = gr.Button("Build Topology")
149
+ btn_net.click(visualize_prime_matroska, inputs=[shells_slider, feed_toggle], outputs=matroska_plot)
150
 
151
  demo.launch()