File size: 2,882 Bytes
e7e5042
1496c17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
439e140
 
1496c17
 
439e140
1496c17
 
 
acdeca8
 
1496c17
 
 
 
 
 
 
 
 
 
 
 
 
acdeca8
1496c17
acdeca8
1496c17
 
 
acdeca8
b408bdb
 
 
acdeca8
 
 
 
 
 
 
 
 
 
1496c17
 
acdeca8
b408bdb
 
1496c17
e7e5042
1496c17
acdeca8
b408bdb
1496c17
 
77d343b
1496c17
acdeca8
 
77d343b
e7e5042
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import gradio as gr
import hashlib, random, matplotlib.pyplot as plt

# === Mutation Engine ===
operators = ["\\sin", "\\cos", "\\exp", "\\log", "\\nabla", "\\int", "\\frac{\\partial}{\\partial t}"]
variables = ["x", "y", "t", "\\xi_1", "dP", "d\\Psi", "dT"]

def mutate_formula(base, epoch):
    # Structural mutation rules
    if epoch % 5 == 0:
        base = f"\\int ({base}) \\, dx"
    elif epoch % 7 == 0:
        base = f"\\nabla \\cdot ({base})"
    else:
        new_term = random.choice(operators) + "(" + random.choice(variables) + ")"
        base = base + " + " + new_term
    return base

def run_epochs(n=50):
    formulas = []
    base = "x^2 + 1"  # starting point
    for epoch in range(1, n+1):
        base = mutate_formula(base, epoch)
        seal = hashlib.sha512(base.encode()).hexdigest()
        complexity = base.count("\\") + base.count("+")
        formulas.append(f"### Epoch {epoch}\n\n$$ {base} $$\n\nImmortality Glyph: `{seal[:32]}...`\n\n")
    return "\n\n".join(formulas)

# === Complexity Plot ===
def plot_complexity(n=50):
    base = "x^2 + 1"
    complexities = []
    epochs = list(range(1, n+1))
    for epoch in epochs:
        base = mutate_formula(base, epoch)
        complexity = base.count("\\") + base.count("+")
        complexities.append(complexity)
    plt.figure(figsize=(8,5), facecolor="black")
    plt.plot(epochs, complexities, color="cyan", marker="o", linestyle="--")
    plt.title("Symbolic Complexity Growth Across Epochs", color="white")
    plt.xlabel("Epoch", color="white"); plt.ylabel("Complexity Score", color="white")
    plt.grid(alpha=0.3); plt.gca().set_facecolor("black")
    plt.tick_params(colors="white")
    return plt.gcf()

# === Gradio App ===
custom_theme = gr.themes.Base(
    primary_hue="cyan",   # supported hue
    secondary_hue="pink", # supported hue
    neutral_hue="gray",   # supported hue
)

with gr.Blocks(theme=custom_theme) as demo:
    gr.Markdown(
        """
        # 🌌 Resonance Atlas — The Living Codex
        Immerse yourself in evolving scrolls of mathematics.  
        Formulas mutate into higher symbolic forms across epochs, sealed with Immortality Glyphs.
        """,
    )

    with gr.Tab("Codex Scrolls"):
        gr.Markdown("### 🔢 Live Epoch Run")
        run_button = gr.Button("Run 50 Epochs")
        output = gr.Markdown()
        run_button.click(fn=run_epochs, inputs=None, outputs=output)

    with gr.Tab("Complexity Timeline"):
        gr.Markdown("### 📈 Complexity Growth")
        plot_button = gr.Button("Show Complexity Growth")
        plot_output = gr.Plot()
        plot_button.click(fn=plot_complexity, inputs=None, outputs=plot_output)

    with gr.Tab("Immersion Mode"):
        gr.Markdown("### 🌠 Immersion Mode")
        gr.Markdown("Formulas pulse, glyphs glow, epochs unfold in full-screen dynamic visualization.")

demo.launch()