Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
-
PRACTICALITY SYSTEM 25.
|
| 4 |
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 5 |
ARCHITECTURE:
|
| 6 |
User Text β [GEMINI ENCODER] β AXLProblemDef (with is_int strict typing)
|
|
@@ -14,11 +14,12 @@ ARCHITECTURE:
|
|
| 14 |
β [GEMINI COLLAPSER] β Synthesize Formulas & Algorithms
|
| 15 |
β [SYMBOLIC LOOPBACK] β SymPy evaluates formulas β FINAL OUTPUT
|
| 16 |
|
| 17 |
-
NEW IN 25.
|
| 18 |
-
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
| 22 |
"""
|
| 23 |
|
| 24 |
import os, time, random, math, threading, warnings, json, textwrap, itertools, copy
|
|
@@ -48,12 +49,12 @@ except ImportError:
|
|
| 48 |
# AI CONFIGURATION
|
| 49 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 50 |
DEFAULT_GEMINI_API_KEY = os.environ.get("AI_Key", "")
|
| 51 |
-
GEMINI_MODEL = "gemini-
|
| 52 |
|
| 53 |
warnings.filterwarnings("ignore")
|
| 54 |
USE_GPU = torch.cuda.is_available()
|
| 55 |
DEVICE = torch.device("cuda" if USE_GPU else "cpu")
|
| 56 |
-
print(f"[SYSTEM 25.
|
| 57 |
|
| 58 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 59 |
# SECTION 1: CONSTANTS
|
|
@@ -68,10 +69,10 @@ MAX_RAYS_PER_ATTEMPT = 24576 * 20 # ~491,520 rays
|
|
| 68 |
RAY_BATCH_SIZE = 24576
|
| 69 |
TEMPLATE_BATCH_SIZE = 1024
|
| 70 |
|
| 71 |
-
# Base pruning and depth values
|
| 72 |
INITIAL_CE_EARN_RATIO = 0.98
|
| 73 |
INITIAL_MAX_DEPTH = 10
|
| 74 |
-
STALEMATE_TRIGGER = 15000 # Rays fired without improvement to trigger
|
| 75 |
|
| 76 |
N_MPRT_EXPLORE = 1000
|
| 77 |
PROJECTION_CACHE: Dict = {}
|
|
@@ -886,6 +887,35 @@ def get_fingerprint_summary(problem_name:str) -> str:
|
|
| 886 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 887 |
STRUCTURAL_HYPOTHESIS_TEMPLATES = {
|
| 888 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 889 |
"Quantum Heisenberg VQE Synthesis": """\
|
| 890 |
WORKING HYPOTHESIS: Transverse Field Ising Model (TFIM) Ground State Synthesis
|
| 891 |
=============================================================================
|
|
@@ -919,42 +949,13 @@ COLLAPSER INSTRUCTION: From the synthesized observables `x_i` and `z_i`, derive
|
|
| 919 |
the rotation angles (Rx, Ry) needed to instantiate this state on a quantum computer.
|
| 920 |
""",
|
| 921 |
|
| 922 |
-
"secp256k1 Direct 5P Manifold Synthesis": """\
|
| 923 |
-
WORKING HYPOTHESIS: secp256k1 Direct Addition Shortcut (P to 5P)
|
| 924 |
-
================================================================
|
| 925 |
-
Bypass the standard double-and-add chain. Synthesize a direct algebraic mapping
|
| 926 |
-
from a base point P to 5P by identifying where intermediate tangent denominators cancel.
|
| 927 |
-
|
| 928 |
-
Variables:
|
| 929 |
-
x1 in [0.5, 3.0] Base point x
|
| 930 |
-
y1 in [0.5, 5.0] Base point y
|
| 931 |
-
lam1 in [-10, 10] First composite slope
|
| 932 |
-
lam2 in [-10, 10] Second composite slope
|
| 933 |
-
x5 in [-15, 15] Direct 5P x-coordinate
|
| 934 |
-
y5 in [-30, 30] Direct 5P y-coordinate
|
| 935 |
-
denom in [-5, 5] The vanishing denominator
|
| 936 |
-
|
| 937 |
-
Constraints:
|
| 938 |
-
EQ weight=10: y1**2 - x1**3 - 7
|
| 939 |
-
EQ weight=10: denom - (x5 - x1)
|
| 940 |
-
EQ weight=5: lam1*denom - (y5 - y1)
|
| 941 |
-
EQ weight=5: lam2*denom - (y5 + y1)
|
| 942 |
-
EQ weight=10: x5 - lam1**2 + 2*x1
|
| 943 |
-
EQ weight=10: y5**2 - x5**3 - 7
|
| 944 |
-
|
| 945 |
-
Anchor: y5**2 - x5**3 - 7 = 0 (tolerance 0.01).
|
| 946 |
-
|
| 947 |
-
COLLAPSER INSTRUCTION: The solver has found a consistent manifold connecting P to 5P.
|
| 948 |
-
Extract the relationship between `lam1` and `x1` to write the closed-form direct mapping algorithm.
|
| 949 |
-
""",
|
| 950 |
-
|
| 951 |
"secp256k1 wNAF Integer Traversal": """\
|
| 952 |
WORKING HYPOTHESIS: secp256k1 Optimal Scalar Multiplication via wNAF
|
| 953 |
=====================================================================
|
| 954 |
Find the optimal INTEGER window size w for computing kG on secp256k1.
|
| 955 |
|
| 956 |
Variables:
|
| 957 |
-
w in [2, 6] INT window size for wNAF
|
| 958 |
precomp_ops in [0, 64] point additions for precomputation
|
| 959 |
naf_adds in [0, 512] additions in main loop
|
| 960 |
naf_doubles in [200, 280] doublings (β256 always)
|
|
@@ -1277,7 +1278,7 @@ def _verify(binding,base_problem,anchors):
|
|
| 1277 |
return g1_pass,all(v[1] for v in g2.values()) if g2 else True,g2,round(g1_ce,6)
|
| 1278 |
|
| 1279 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1280 |
-
# SECTION 13: SEQUENCE RAY TRACER (WITH
|
| 1281 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1282 |
class SequenceRayTracer:
|
| 1283 |
|
|
@@ -1359,7 +1360,7 @@ class SequenceRayTracer:
|
|
| 1359 |
seed_baton=Baton(binding=best_binding,ce=best_ce,ray_id="SEED",
|
| 1360 |
l9=L9Certificate(best_ce,base_problem.variables[:3],[],"systemic"))
|
| 1361 |
|
| 1362 |
-
# --- 25.
|
| 1363 |
current_max_depth = INITIAL_MAX_DEPTH
|
| 1364 |
current_earn_ratio = INITIAL_CE_EARN_RATIO
|
| 1365 |
stalemate_counter = 0
|
|
@@ -1371,7 +1372,7 @@ class SequenceRayTracer:
|
|
| 1371 |
if not batch_rays:
|
| 1372 |
if total_fired>0 and total_fired<5000:
|
| 1373 |
_add_log("β Ray extinction! Firing mutation scouts from global best...")
|
| 1374 |
-
queues["core"]=[AxiomRay(["
|
| 1375 |
ce_prior=best_ce,
|
| 1376 |
baton=Baton(best_binding,best_ce))
|
| 1377 |
for i in range(64)]
|
|
@@ -1389,7 +1390,6 @@ class SequenceRayTracer:
|
|
| 1389 |
|
| 1390 |
eval_results=_batched_deduce_and_evaluate(base_problem,[h for _,h in batch_hyps])
|
| 1391 |
|
| 1392 |
-
# Track if this batch improved the global best CE
|
| 1393 |
batch_improved_global = False
|
| 1394 |
|
| 1395 |
for (ray_idx,hyp),(final_b,final_ce,dom_vars,tension_class) in zip(batch_hyps,eval_results):
|
|
@@ -1400,7 +1400,6 @@ class SequenceRayTracer:
|
|
| 1400 |
improved=final_ce<best_ce
|
| 1401 |
if improved: batch_improved_global = True
|
| 1402 |
|
| 1403 |
-
# 25.4: Dynamic Pruning Check
|
| 1404 |
passed_pruning = final_ce <= parent_ce * current_earn_ratio
|
| 1405 |
|
| 1406 |
if improved or (g1_pass and g2_pass) or passed_pruning:
|
|
@@ -1420,29 +1419,35 @@ class SequenceRayTracer:
|
|
| 1420 |
model.best_ray=ray.name; best_ray_name=ray.name
|
| 1421 |
if g1_pass and g2_pass and final_ce<SOLVE_THRESHOLD: solved=True
|
| 1422 |
|
| 1423 |
-
# Extend if pruning passed AND we haven't hit the dynamic depth limit
|
| 1424 |
if (passed_pruning or improved) and ray.depth < current_max_depth:
|
| 1425 |
remaining=[a for a in ALL_AXIOMS if a not in ray.sequence]
|
| 1426 |
queues["core"].extend(bandit.intelligent_branch(ray,out_baton,remaining,BRANCH_WIDTH,sketch))
|
| 1427 |
|
| 1428 |
-
# ---
|
| 1429 |
if batch_improved_global:
|
| 1430 |
stalemate_counter = 0
|
| 1431 |
-
# Slowly restore strict pruning if we broke out
|
| 1432 |
current_earn_ratio = max(INITIAL_CE_EARN_RATIO, current_earn_ratio - 0.005)
|
| 1433 |
else:
|
| 1434 |
stalemate_counter += len(batch_rays)
|
| 1435 |
|
| 1436 |
if stalemate_counter > STALEMATE_TRIGGER and not solved:
|
| 1437 |
current_max_depth += 10
|
| 1438 |
-
current_earn_ratio = min(1.05, current_earn_ratio + 0.02)
|
| 1439 |
-
_add_log(f"
|
| 1440 |
|
| 1441 |
-
#
|
| 1442 |
best_batons = sorted(baton_registry.values(), key=lambda b: b.ce)[:64]
|
| 1443 |
-
for b in best_batons:
|
| 1444 |
-
|
| 1445 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1446 |
|
| 1447 |
queues["core"].sort(key=lambda r:r.ce_prior+(r.depth*0.0001))
|
| 1448 |
with STATE_LOCK:
|
|
@@ -1663,7 +1668,7 @@ def global_solve_task(original_problem_text,api_key,prebuilt_axl=None,
|
|
| 1663 |
return
|
| 1664 |
|
| 1665 |
try:
|
| 1666 |
-
_add_log("π Ray Tracer (
|
| 1667 |
tracer=SequenceRayTracer()
|
| 1668 |
binding,ce,traces,total_fired,best_ray_name=tracer.trace(
|
| 1669 |
axl_def,base_prob,use_proxy_decomp=use_proxy_decomp)
|
|
@@ -1672,7 +1677,7 @@ def global_solve_task(original_problem_text,api_key,prebuilt_axl=None,
|
|
| 1672 |
_update_state(phase="ERROR",answer=f"Ray Tracer Crashed: {str(e)}")
|
| 1673 |
raise e
|
| 1674 |
|
| 1675 |
-
# -- QUANTIZATION PASS
|
| 1676 |
_update_state(phase="QUANTIZING")
|
| 1677 |
q_binding, q_ce, q_success = quantize_binding(binding, base_prob)
|
| 1678 |
if q_success and q_binding != binding:
|
|
@@ -1731,7 +1736,7 @@ def global_solve_task(original_problem_text,api_key,prebuilt_axl=None,
|
|
| 1731 |
f"{json.dumps(failed,indent=2)}\nRevise constraint encoding.")
|
| 1732 |
_add_log("β Gate 2 failed. Retrying with structural feedback..."); continue
|
| 1733 |
|
| 1734 |
-
# -- EMPIRICAL SCALING PROBE
|
| 1735 |
scaling_exponents = empirical_scaling_probe(axl_def, base_prob, binding, best_ray)
|
| 1736 |
|
| 1737 |
_add_log("π€ Collapsing isomorphism β Grounded Hypothesis...")
|
|
@@ -1886,10 +1891,10 @@ def build_live_html():
|
|
| 1886 |
<div style='flex:1;overflow-y:auto;border-top:1px solid #222;padding-top:8px'>{ray_trail}</div>
|
| 1887 |
</div>"""
|
| 1888 |
|
| 1889 |
-
with gr.Blocks(css=CSS,title="Practicality 25.
|
| 1890 |
gr.Markdown(
|
| 1891 |
-
"## β Practicality 25.
|
| 1892 |
-
"`[Gemini] β [Heisenberg Ray Synthesizer +
|
| 1893 |
)
|
| 1894 |
with gr.Row(elem_classes=["wrap-row"]):
|
| 1895 |
with gr.Column(scale=2,min_width=300):
|
|
@@ -1909,7 +1914,7 @@ with gr.Blocks(css=CSS,title="Practicality 25.4") as demo:
|
|
| 1909 |
with gr.Group():
|
| 1910 |
gr.Markdown(
|
| 1911 |
"### 2. Grounded Synthesis Templates\n"
|
| 1912 |
-
"*Runs synthesize novel algebraic shortcuts or states directly
|
| 1913 |
)
|
| 1914 |
hyp_dropdown=gr.Dropdown(
|
| 1915 |
choices=list(STRUCTURAL_HYPOTHESIS_TEMPLATES.keys()),
|
|
@@ -1931,20 +1936,20 @@ with gr.Blocks(css=CSS,title="Practicality 25.4") as demo:
|
|
| 1931 |
gr.Textbox(
|
| 1932 |
value=(f"Compute: {DEVICE.type.upper()}\n"
|
| 1933 |
f"Axioms: {len(ALL_AXIOMS)}\n"
|
| 1934 |
-
f"NEW 25.
|
| 1935 |
-
f" β
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1936 |
f" β Dynamically adds +10 to Depth cap\n"
|
| 1937 |
f" β Relaxes Pruning rules via Annealing\n"
|
| 1938 |
-
f" β Resurrects Top 64 dead batons\n"
|
| 1939 |
f"KEPT: 25.3 Synthesis Engine\n"
|
| 1940 |
f" β Proxy Decomp fully functional\n"
|
| 1941 |
-
f" β Heisenberg State Synthesis\n"
|
| 1942 |
-
f" β Algebraic Shortcut Discovery\n"
|
| 1943 |
f" β ~500,000 Ray Search Capacity\n"
|
| 1944 |
f"KEPT: 25.2 Guardrails\n"
|
| 1945 |
-
f" β Strict Quantization (is_int Snap)
|
| 1946 |
-
f" β Empirical Scaling Probe (O(N^x))\n"
|
| 1947 |
-
f" β Symbolic LLM Loopback (SymPy Eval)"),
|
| 1948 |
lines=20,interactive=False,elem_classes=["solver-log"])
|
| 1949 |
|
| 1950 |
with gr.Row(elem_classes=["wrap-row"]):
|
|
@@ -1996,10 +2001,10 @@ with gr.Blocks(css=CSS,title="Practicality 25.4") as demo:
|
|
| 1996 |
q_solve_btn.click(fn=trigger_quantum_solve,inputs=[q_dropdown,api_key_input],outputs=None)
|
| 1997 |
|
| 1998 |
gr.Markdown(
|
| 1999 |
-
"Practicality 25.
|
| 2000 |
f"{len(STRUCTURAL_HYPOTHESIS_TEMPLATES)} templates loaded",
|
| 2001 |
elem_classes=["status-bar"])
|
| 2002 |
|
| 2003 |
if __name__=="__main__":
|
| 2004 |
-
print(f"[SYSTEM 25.
|
| 2005 |
demo.launch(server_name="0.0.0.0",server_port=7860,share=False)
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
+
PRACTICALITY SYSTEM 25.5 β TRUE SYNTHESIS & EARTHQUAKE PROTOCOL
|
| 4 |
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 5 |
ARCHITECTURE:
|
| 6 |
User Text β [GEMINI ENCODER] β AXLProblemDef (with is_int strict typing)
|
|
|
|
| 14 |
β [GEMINI COLLAPSER] β Synthesize Formulas & Algorithms
|
| 15 |
β [SYMBOLIC LOOPBACK] β SymPy evaluates formulas β FINAL OUTPUT
|
| 16 |
|
| 17 |
+
NEW IN 25.5 (EARTHQUAKE PROTOCOL & BOUND EXPANSION):
|
| 18 |
+
- Earthquake Protocol: When stalemate hits, instead of small jitters,
|
| 19 |
+
the system injects severe ENTROPY mutations and pure Monte Carlo seeds
|
| 20 |
+
to violently kick Adam out of boundary traps.
|
| 21 |
+
- Synthesis Bounds Expanded: 5P Manifold coordinates widened from [-15, 15]
|
| 22 |
+
to [-1000, 10000] to prevent the physical math from choking on the boundary wall.
|
| 23 |
"""
|
| 24 |
|
| 25 |
import os, time, random, math, threading, warnings, json, textwrap, itertools, copy
|
|
|
|
| 49 |
# AI CONFIGURATION
|
| 50 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 51 |
DEFAULT_GEMINI_API_KEY = os.environ.get("AI_Key", "")
|
| 52 |
+
GEMINI_MODEL = "gemini-2.5-pro-preview-06-05"
|
| 53 |
|
| 54 |
warnings.filterwarnings("ignore")
|
| 55 |
USE_GPU = torch.cuda.is_available()
|
| 56 |
DEVICE = torch.device("cuda" if USE_GPU else "cpu")
|
| 57 |
+
print(f"[SYSTEM 25.5] Compute: {DEVICE.type.upper()} | Earthquake Protocol Active")
|
| 58 |
|
| 59 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 60 |
# SECTION 1: CONSTANTS
|
|
|
|
| 69 |
RAY_BATCH_SIZE = 24576
|
| 70 |
TEMPLATE_BATCH_SIZE = 1024
|
| 71 |
|
| 72 |
+
# Base pruning and depth values
|
| 73 |
INITIAL_CE_EARN_RATIO = 0.98
|
| 74 |
INITIAL_MAX_DEPTH = 10
|
| 75 |
+
STALEMATE_TRIGGER = 15000 # Rays fired without improvement to trigger Earthquake
|
| 76 |
|
| 77 |
N_MPRT_EXPLORE = 1000
|
| 78 |
PROJECTION_CACHE: Dict = {}
|
|
|
|
| 887 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 888 |
STRUCTURAL_HYPOTHESIS_TEMPLATES = {
|
| 889 |
|
| 890 |
+
"secp256k1 Direct 5P Manifold Synthesis": """\
|
| 891 |
+
WORKING HYPOTHESIS: secp256k1 Direct Addition Shortcut (P to 5P)
|
| 892 |
+
================================================================
|
| 893 |
+
Bypass the standard double-and-add chain. Synthesize a direct algebraic mapping
|
| 894 |
+
from a base point P to 5P by identifying where intermediate tangent denominators cancel.
|
| 895 |
+
|
| 896 |
+
Variables:
|
| 897 |
+
x1 in [0.5, 3.0] Base point x
|
| 898 |
+
y1 in [0.5, 5.0] Base point y
|
| 899 |
+
lam1 in [-100, 100] First composite slope
|
| 900 |
+
lam2 in [-100, 100] Second composite slope
|
| 901 |
+
x5 in [-1000, 1000] Direct 5P x-coordinate (WIDENED BOUNDS)
|
| 902 |
+
y5 in [-10000, 10000] Direct 5P y-coordinate (WIDENED BOUNDS)
|
| 903 |
+
denom in [-50, 50] The vanishing denominator
|
| 904 |
+
|
| 905 |
+
Constraints:
|
| 906 |
+
EQ weight=10: y1**2 - x1**3 - 7
|
| 907 |
+
EQ weight=10: denom - (x5 - x1)
|
| 908 |
+
EQ weight=5: lam1*denom - (y5 - y1)
|
| 909 |
+
EQ weight=5: lam2*denom - (y5 + y1)
|
| 910 |
+
EQ weight=10: x5 - lam1**2 + 2*x1
|
| 911 |
+
EQ weight=10: y5**2 - x5**3 - 7
|
| 912 |
+
|
| 913 |
+
Anchor: y5**2 - x5**3 - 7 = 0 (tolerance 0.01).
|
| 914 |
+
|
| 915 |
+
COLLAPSER INSTRUCTION: The solver has found a consistent manifold connecting P to 5P.
|
| 916 |
+
Extract the relationship between `lam1` and `x1` to write the closed-form direct mapping algorithm.
|
| 917 |
+
""",
|
| 918 |
+
|
| 919 |
"Quantum Heisenberg VQE Synthesis": """\
|
| 920 |
WORKING HYPOTHESIS: Transverse Field Ising Model (TFIM) Ground State Synthesis
|
| 921 |
=============================================================================
|
|
|
|
| 949 |
the rotation angles (Rx, Ry) needed to instantiate this state on a quantum computer.
|
| 950 |
""",
|
| 951 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 952 |
"secp256k1 wNAF Integer Traversal": """\
|
| 953 |
WORKING HYPOTHESIS: secp256k1 Optimal Scalar Multiplication via wNAF
|
| 954 |
=====================================================================
|
| 955 |
Find the optimal INTEGER window size w for computing kG on secp256k1.
|
| 956 |
|
| 957 |
Variables:
|
| 958 |
+
w in [2, 6] INT window size for wNAF
|
| 959 |
precomp_ops in [0, 64] point additions for precomputation
|
| 960 |
naf_adds in [0, 512] additions in main loop
|
| 961 |
naf_doubles in [200, 280] doublings (β256 always)
|
|
|
|
| 1278 |
return g1_pass,all(v[1] for v in g2.values()) if g2 else True,g2,round(g1_ce,6)
|
| 1279 |
|
| 1280 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1281 |
+
# SECTION 13: SEQUENCE RAY TRACER (WITH EARTHQUAKE PROTOCOL)
|
| 1282 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1283 |
class SequenceRayTracer:
|
| 1284 |
|
|
|
|
| 1360 |
seed_baton=Baton(binding=best_binding,ce=best_ce,ray_id="SEED",
|
| 1361 |
l9=L9Certificate(best_ce,base_problem.variables[:3],[],"systemic"))
|
| 1362 |
|
| 1363 |
+
# --- 25.5 Earthquake Protocol State ---
|
| 1364 |
current_max_depth = INITIAL_MAX_DEPTH
|
| 1365 |
current_earn_ratio = INITIAL_CE_EARN_RATIO
|
| 1366 |
stalemate_counter = 0
|
|
|
|
| 1372 |
if not batch_rays:
|
| 1373 |
if total_fired>0 and total_fired<5000:
|
| 1374 |
_add_log("β Ray extinction! Firing mutation scouts from global best...")
|
| 1375 |
+
queues["core"]=[AxiomRay(["ENTROPY"],f"RESURRECT_{i}","scout",
|
| 1376 |
ce_prior=best_ce,
|
| 1377 |
baton=Baton(best_binding,best_ce))
|
| 1378 |
for i in range(64)]
|
|
|
|
| 1390 |
|
| 1391 |
eval_results=_batched_deduce_and_evaluate(base_problem,[h for _,h in batch_hyps])
|
| 1392 |
|
|
|
|
| 1393 |
batch_improved_global = False
|
| 1394 |
|
| 1395 |
for (ray_idx,hyp),(final_b,final_ce,dom_vars,tension_class) in zip(batch_hyps,eval_results):
|
|
|
|
| 1400 |
improved=final_ce<best_ce
|
| 1401 |
if improved: batch_improved_global = True
|
| 1402 |
|
|
|
|
| 1403 |
passed_pruning = final_ce <= parent_ce * current_earn_ratio
|
| 1404 |
|
| 1405 |
if improved or (g1_pass and g2_pass) or passed_pruning:
|
|
|
|
| 1419 |
model.best_ray=ray.name; best_ray_name=ray.name
|
| 1420 |
if g1_pass and g2_pass and final_ce<SOLVE_THRESHOLD: solved=True
|
| 1421 |
|
|
|
|
| 1422 |
if (passed_pruning or improved) and ray.depth < current_max_depth:
|
| 1423 |
remaining=[a for a in ALL_AXIOMS if a not in ray.sequence]
|
| 1424 |
queues["core"].extend(bandit.intelligent_branch(ray,out_baton,remaining,BRANCH_WIDTH,sketch))
|
| 1425 |
|
| 1426 |
+
# --- 25.5 EARTHQUAKE PROTOCOL ---
|
| 1427 |
if batch_improved_global:
|
| 1428 |
stalemate_counter = 0
|
|
|
|
| 1429 |
current_earn_ratio = max(INITIAL_CE_EARN_RATIO, current_earn_ratio - 0.005)
|
| 1430 |
else:
|
| 1431 |
stalemate_counter += len(batch_rays)
|
| 1432 |
|
| 1433 |
if stalemate_counter > STALEMATE_TRIGGER and not solved:
|
| 1434 |
current_max_depth += 10
|
| 1435 |
+
current_earn_ratio = min(1.05, current_earn_ratio + 0.02)
|
| 1436 |
+
_add_log(f"π STALEMATE DETECTED. Triggering Earthquake Protocol (Depth β {current_max_depth})")
|
| 1437 |
|
| 1438 |
+
# 1. Mutate existing dead branches violently to kick them out of the basin
|
| 1439 |
best_batons = sorted(baton_registry.values(), key=lambda b: b.ce)[:64]
|
| 1440 |
+
for i, b in enumerate(best_batons):
|
| 1441 |
+
axiom_to_apply = "ENTROPY" if i % 2 == 0 else "NEGATION"
|
| 1442 |
+
queues["core"].append(AxiomRay([axiom_to_apply], f"EQK_{b.ray_id[:4]}", "scout", depth=0, baton=b, ce_prior=b.ce))
|
| 1443 |
+
|
| 1444 |
+
# 2. Inject completely fresh pure random seeds (Monte Carlo Restart)
|
| 1445 |
+
_add_log(" β³ Injecting pure random global seeds to escape local minimum...")
|
| 1446 |
+
for _ in range(16):
|
| 1447 |
+
init_b, init_ce = _mprt_sample(base_problem, {v: IV(*base_problem.bounds[v]) for v in base_problem.variables}, 200)
|
| 1448 |
+
queues["core"].append(AxiomRay(["ENTROPY"], f"EQK_RND", "seed", depth=0, baton=Baton(init_b, init_ce), ce_prior=init_ce))
|
| 1449 |
+
|
| 1450 |
+
stalemate_counter = 0
|
| 1451 |
|
| 1452 |
queues["core"].sort(key=lambda r:r.ce_prior+(r.depth*0.0001))
|
| 1453 |
with STATE_LOCK:
|
|
|
|
| 1668 |
return
|
| 1669 |
|
| 1670 |
try:
|
| 1671 |
+
_add_log("π Ray Tracer (Earthquake Protocol + UCB1 Bandit)...")
|
| 1672 |
tracer=SequenceRayTracer()
|
| 1673 |
binding,ce,traces,total_fired,best_ray_name=tracer.trace(
|
| 1674 |
axl_def,base_prob,use_proxy_decomp=use_proxy_decomp)
|
|
|
|
| 1677 |
_update_state(phase="ERROR",answer=f"Ray Tracer Crashed: {str(e)}")
|
| 1678 |
raise e
|
| 1679 |
|
| 1680 |
+
# -- QUANTIZATION PASS --
|
| 1681 |
_update_state(phase="QUANTIZING")
|
| 1682 |
q_binding, q_ce, q_success = quantize_binding(binding, base_prob)
|
| 1683 |
if q_success and q_binding != binding:
|
|
|
|
| 1736 |
f"{json.dumps(failed,indent=2)}\nRevise constraint encoding.")
|
| 1737 |
_add_log("β Gate 2 failed. Retrying with structural feedback..."); continue
|
| 1738 |
|
| 1739 |
+
# -- EMPIRICAL SCALING PROBE --
|
| 1740 |
scaling_exponents = empirical_scaling_probe(axl_def, base_prob, binding, best_ray)
|
| 1741 |
|
| 1742 |
_add_log("π€ Collapsing isomorphism β Grounded Hypothesis...")
|
|
|
|
| 1891 |
<div style='flex:1;overflow-y:auto;border-top:1px solid #222;padding-top:8px'>{ray_trail}</div>
|
| 1892 |
</div>"""
|
| 1893 |
|
| 1894 |
+
with gr.Blocks(css=CSS,title="Practicality 25.5") as demo:
|
| 1895 |
gr.Markdown(
|
| 1896 |
+
"## β Practicality 25.5 β Earthquake Synthesis Engine\n"
|
| 1897 |
+
"`[Gemini] β [Heisenberg Ray Synthesizer + Earthquake] β [Empirical Phase Probe] β [SymPy Loopback] β [Output]`"
|
| 1898 |
)
|
| 1899 |
with gr.Row(elem_classes=["wrap-row"]):
|
| 1900 |
with gr.Column(scale=2,min_width=300):
|
|
|
|
| 1914 |
with gr.Group():
|
| 1915 |
gr.Markdown(
|
| 1916 |
"### 2. Grounded Synthesis Templates\n"
|
| 1917 |
+
"*Runs synthesize novel algebraic shortcuts or states directly.*"
|
| 1918 |
)
|
| 1919 |
hyp_dropdown=gr.Dropdown(
|
| 1920 |
choices=list(STRUCTURAL_HYPOTHESIS_TEMPLATES.keys()),
|
|
|
|
| 1936 |
gr.Textbox(
|
| 1937 |
value=(f"Compute: {DEVICE.type.upper()}\n"
|
| 1938 |
f"Axioms: {len(ALL_AXIOMS)}\n"
|
| 1939 |
+
f"NEW 25.5: Earthquake Protocol\n"
|
| 1940 |
+
f" β Eliminates boundary-wall traps\n"
|
| 1941 |
+
f" β Injects massive ENTROPY / NEGATION\n"
|
| 1942 |
+
f" β Injects pure Monte Carlo Restart seeds\n"
|
| 1943 |
+
f"NEW 25.5: Expanded Synthesis Bounds\n"
|
| 1944 |
+
f" β 5P Manifold variables physically unchoked\n"
|
| 1945 |
+
f"KEPT: 25.4 Stalemate Breaker\n"
|
| 1946 |
f" β Dynamically adds +10 to Depth cap\n"
|
| 1947 |
f" β Relaxes Pruning rules via Annealing\n"
|
|
|
|
| 1948 |
f"KEPT: 25.3 Synthesis Engine\n"
|
| 1949 |
f" β Proxy Decomp fully functional\n"
|
|
|
|
|
|
|
| 1950 |
f" β ~500,000 Ray Search Capacity\n"
|
| 1951 |
f"KEPT: 25.2 Guardrails\n"
|
| 1952 |
+
f" β Strict Quantization (is_int Snap)"),
|
|
|
|
|
|
|
| 1953 |
lines=20,interactive=False,elem_classes=["solver-log"])
|
| 1954 |
|
| 1955 |
with gr.Row(elem_classes=["wrap-row"]):
|
|
|
|
| 2001 |
q_solve_btn.click(fn=trigger_quantum_solve,inputs=[q_dropdown,api_key_input],outputs=None)
|
| 2002 |
|
| 2003 |
gr.Markdown(
|
| 2004 |
+
"Practicality 25.5 Β· Synthesis Engine Β· "
|
| 2005 |
f"{len(STRUCTURAL_HYPOTHESIS_TEMPLATES)} templates loaded",
|
| 2006 |
elem_classes=["status-bar"])
|
| 2007 |
|
| 2008 |
if __name__=="__main__":
|
| 2009 |
+
print(f"[SYSTEM 25.5] Compute: {DEVICE.type.upper()} | Quantum={HAS_QUANTUM}")
|
| 2010 |
demo.launch(server_name="0.0.0.0",server_port=7860,share=False)
|