Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
#!/usr/bin/env python3
|
| 3 |
"""
|
| 4 |
PRACTICALITY SYSTEM 25.0 β PROXY DECOMPOSITION + HYPOTHESIS TESTING ENGINE
|
|
@@ -35,18 +34,13 @@ NEW IN 25.0:
|
|
| 35 |
β’ LWE lattice crypto short-vector feasibility
|
| 36 |
β’ Quantum surface code syndrome consistency
|
| 37 |
|
| 38 |
-
ALL
|
|
|
|
|
|
|
|
|
|
| 39 |
- Squeeze Bug Fix (.view(B,-1).sum(dim=1))
|
| 40 |
- Two Brains Sync (Gate 1 via PyTorch L2)
|
| 41 |
- Anti-LaTeX Shield (^ β **)
|
| 42 |
-
- Undefined Observation Shield
|
| 43 |
-
- Undefined Symbol Shield
|
| 44 |
-
- Extended PT Map Shield
|
| 45 |
-
- Relational Hallucination Shield
|
| 46 |
-
- Markov Blanket Masking
|
| 47 |
-
- UCB1 Bandit Seeder
|
| 48 |
-
- Zero-Shot Early Exit
|
| 49 |
-
- Javascript Auto-Clicker Polling (Fixes Queue Starvation / Page Reload Freezes)
|
| 50 |
"""
|
| 51 |
|
| 52 |
import os, time, random, math, threading, warnings, json, textwrap, itertools
|
|
@@ -97,7 +91,7 @@ PROJECTION_CACHE: Dict = {}
|
|
| 97 |
MAX_RAYS_PER_ATTEMPT = 24576 * 10
|
| 98 |
RAY_BATCH_SIZE = 24576
|
| 99 |
TEMPLATE_BATCH_SIZE = 1024
|
| 100 |
-
CE_EARN_RATIO = 0.
|
| 101 |
SCOUT_CE_THRESHOLD = 0.5
|
| 102 |
BRANCH_WIDTH = 12
|
| 103 |
BRANCH_WIDTH_SYSTEMIC = 16
|
|
@@ -125,10 +119,7 @@ GLOBAL_SOLVE_STATE = {
|
|
| 125 |
"best_ray": "β", "recent_traces": deque(maxlen=25), "high_level_logs": [],
|
| 126 |
"answer": "", "sketch_summary": "", "template_count": 0,
|
| 127 |
"template_best_ce": float('inf'), "sympy_derivation": [],
|
| 128 |
-
|
| 129 |
-
"proxy_n_components": 0,
|
| 130 |
-
"proxy_component_isos": [],
|
| 131 |
-
"proxy_composed_ce": float('inf'),
|
| 132 |
"fingerprint_summary": "",
|
| 133 |
}
|
| 134 |
|
|
@@ -717,15 +708,14 @@ def templates_to_hypotheses(templates,problem,init_binding):
|
|
| 717 |
_ALL_AXIOMS_PLACEHOLDER:List[str]=[]
|
| 718 |
|
| 719 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 720 |
-
# SECTION 6.5: PROXY DECOMPOSITION ENGINE
|
| 721 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 722 |
|
| 723 |
@dataclass
|
| 724 |
class ProxyComponentResult:
|
| 725 |
-
"""Result of solving one Markov component."""
|
| 726 |
component_id: int
|
| 727 |
variables: List[str]
|
| 728 |
-
interface_vars: Set[str]
|
| 729 |
binding: Dict[str,float]
|
| 730 |
isomorphism: str
|
| 731 |
ce: float
|
|
@@ -733,69 +723,39 @@ class ProxyComponentResult:
|
|
| 733 |
n_constraints: int
|
| 734 |
|
| 735 |
def find_markov_components(problem: Problem) -> List[List[str]]:
|
| 736 |
-
"""
|
| 737 |
-
Find connected components of the Markov blanket graph via BFS.
|
| 738 |
-
Returns a list of variable groups β each group is a component.
|
| 739 |
-
Components with only one variable that have no constraints are skipped.
|
| 740 |
-
"""
|
| 741 |
visited = set()
|
| 742 |
components = []
|
| 743 |
for start_var in problem.variables:
|
| 744 |
-
if start_var in visited:
|
| 745 |
-
continue
|
| 746 |
component = []
|
| 747 |
queue = deque([start_var])
|
| 748 |
while queue:
|
| 749 |
v = queue.popleft()
|
| 750 |
-
if v in visited:
|
| 751 |
-
continue
|
| 752 |
visited.add(v)
|
| 753 |
component.append(v)
|
| 754 |
for neighbor in problem.adjacency_list.get(v, set()):
|
| 755 |
-
if neighbor not in visited:
|
| 756 |
-
|
| 757 |
-
if component:
|
| 758 |
-
components.append(component)
|
| 759 |
return components
|
| 760 |
|
| 761 |
def find_interface_vars(components: List[List[str]], problem: Problem) -> Dict[int, Set[str]]:
|
| 762 |
-
"""
|
| 763 |
-
For each component, find variables that also appear in constraints
|
| 764 |
-
involving variables from OTHER components (interface/boundary variables).
|
| 765 |
-
"""
|
| 766 |
interfaces: Dict[int,Set[str]] = {i:set() for i in range(len(components))}
|
| 767 |
comp_of_var = {}
|
| 768 |
for i, comp in enumerate(components):
|
| 769 |
-
for v in comp:
|
| 770 |
-
comp_of_var[v] = i
|
| 771 |
-
|
| 772 |
for mc in problem.compiled_constraints:
|
| 773 |
comps_touched = set(comp_of_var.get(v, -1) for v in mc.syms_used)
|
| 774 |
comps_touched.discard(-1)
|
| 775 |
if len(comps_touched) > 1:
|
| 776 |
for v in mc.syms_used:
|
| 777 |
c = comp_of_var.get(v, -1)
|
| 778 |
-
if c >= 0:
|
| 779 |
-
interfaces[c].add(v)
|
| 780 |
return interfaces
|
| 781 |
|
| 782 |
-
def build_sub_axl_for_component(
|
| 783 |
-
axl_def: AXLProblemDef,
|
| 784 |
-
component_vars: List[str],
|
| 785 |
-
interface_vars: Set[str]
|
| 786 |
-
) -> Tuple[AXLProblemDef, 'Problem']:
|
| 787 |
-
"""
|
| 788 |
-
Build a stripped-down AXLProblemDef + Problem for a single component.
|
| 789 |
-
Includes ALL constraints that touch at least one variable in the component
|
| 790 |
-
(cross-component constraints are kept but won't have missing vars since
|
| 791 |
-
those missing vars are fixed at their observation/mid-point values).
|
| 792 |
-
"""
|
| 793 |
comp_set = set(component_vars)
|
| 794 |
-
|
| 795 |
-
# Variables: only component vars
|
| 796 |
sub_vars = [v for v in axl_def.variables if v["name"] in comp_set]
|
| 797 |
-
|
| 798 |
-
# Constraints: keep those touching at least one component var
|
| 799 |
sub_constraints = []
|
| 800 |
for c in axl_def.constraints:
|
| 801 |
try:
|
|
@@ -803,271 +763,137 @@ def build_sub_axl_for_component(
|
|
| 803 |
parsed = parse_expr(str(c['expr']).replace("^","**"), local_dict=syms_all)
|
| 804 |
if any(sp.Symbol(v) in parsed.free_symbols for v in component_vars):
|
| 805 |
sub_constraints.append(c)
|
| 806 |
-
except:
|
| 807 |
-
pass
|
| 808 |
-
|
| 809 |
-
# Anchors: only those whose variables are in this component
|
| 810 |
sub_anchors = []
|
| 811 |
for inv in axl_def.anchors:
|
| 812 |
-
if inv.syms_used and all(v in comp_set for v in inv.syms_used):
|
| 813 |
-
|
| 814 |
-
elif not inv.syms_used:
|
| 815 |
-
sub_anchors.append(inv)
|
| 816 |
-
|
| 817 |
-
# Observations: only component vars
|
| 818 |
sub_obs = {k: v for k, v in axl_def.observations.items() if k in comp_set}
|
| 819 |
-
|
| 820 |
sub_axl = AXLProblemDef(
|
| 821 |
name=f"proxy_{axl_def.name[:15]}_{hash(str(sorted(component_vars)))%9999}",
|
| 822 |
-
description=f"Proxy component: {component_vars[:4]}",
|
| 823 |
-
|
| 824 |
-
|
| 825 |
-
constraints=sub_constraints,
|
| 826 |
-
scopes=[sc for sc in axl_def.scopes],
|
| 827 |
-
anchors=sub_anchors,
|
| 828 |
-
observations=sub_obs,
|
| 829 |
)
|
| 830 |
-
|
| 831 |
try:
|
| 832 |
sub_prob = build_base_problem(sub_axl)
|
| 833 |
return sub_axl, sub_prob
|
| 834 |
except Exception as e:
|
| 835 |
raise RuntimeError(f"Component build failed: {e}")
|
| 836 |
|
| 837 |
-
def _mini_solve_component(
|
| 838 |
-
sub_axl: AXLProblemDef,
|
| 839 |
-
sub_prob: 'Problem',
|
| 840 |
-
seed_binding: Dict[str,float],
|
| 841 |
-
) -> Tuple[Dict[str,float], float, str]:
|
| 842 |
-
"""
|
| 843 |
-
Lightweight solve for a proxy component. Uses templates + limited seeds.
|
| 844 |
-
Does NOT update global dashboard state. Returns (binding, ce, isomorphism).
|
| 845 |
-
"""
|
| 846 |
-
# MPRT sampling
|
| 847 |
try:
|
| 848 |
-
init_b, init_ce = _mprt_sample(
|
| 849 |
-
sub_prob,
|
| 850 |
-
{v: IV(*sub_prob.bounds[v]) for v in sub_prob.variables},
|
| 851 |
-
PROXY_MINI_MPRT_N
|
| 852 |
-
)
|
| 853 |
except:
|
| 854 |
-
init_b = {v: seed_binding.get(v, (sub_prob.bounds[v][0]+sub_prob.bounds[v][1])/2)
|
| 855 |
-
for v in sub_prob.variables}
|
| 856 |
init_ce = float('inf')
|
| 857 |
-
|
| 858 |
-
best_ce = init_ce
|
| 859 |
-
best_b = dict(init_b)
|
| 860 |
-
best_iso = "zero_shot"
|
| 861 |
-
|
| 862 |
-
# Compile anchors
|
| 863 |
for inv in sub_axl.anchors:
|
| 864 |
if not inv.compiled_func:
|
| 865 |
try: inv.compile(sub_prob.variables)
|
| 866 |
except: pass
|
| 867 |
-
|
| 868 |
-
# Template pass
|
| 869 |
try:
|
| 870 |
-
sketch
|
| 871 |
templates = generate_templates(sub_prob, sketch)[:PROXY_MINI_TEMPLATE_CAP]
|
| 872 |
if templates:
|
| 873 |
-
t_hyps
|
| 874 |
t_results = _batched_deduce_and_evaluate(sub_prob, t_hyps)
|
| 875 |
for template, (final_b, final_ce, _, _) in zip(templates, t_results):
|
| 876 |
if final_ce < best_ce:
|
| 877 |
-
best_ce = final_ce
|
| 878 |
-
|
| 879 |
-
|
| 880 |
-
if final_ce < SOLVE_THRESHOLD:
|
| 881 |
-
return best_b, best_ce, best_iso
|
| 882 |
-
except:
|
| 883 |
-
pass
|
| 884 |
-
|
| 885 |
-
# Quick seed pass (bandit not used here β just sketch-ordered seeds)
|
| 886 |
try:
|
| 887 |
-
sketch
|
| 888 |
affinities = sketch.axiom_affinities
|
| 889 |
-
seeds_scored = sorted(
|
| 890 |
-
|
| 891 |
-
|
| 892 |
-
)
|
| 893 |
-
seed_rays = [AxiomRay([a], f"PS{i}", "seed", ce_prior=best_ce)
|
| 894 |
-
for _, i, a in seeds_scored[:PROXY_MINI_SEED_CAP]]
|
| 895 |
-
|
| 896 |
-
seed_baton = Baton(
|
| 897 |
-
binding=best_b, ce=best_ce, ray_id="SEED",
|
| 898 |
-
l9=L9Certificate(best_ce, sub_prob.variables[:3], [], "systemic")
|
| 899 |
-
)
|
| 900 |
model = StructuralModel(best_b, best_ce)
|
| 901 |
-
|
| 902 |
for ray in seed_rays:
|
| 903 |
constructor = AXIOM_CONSTRUCTORS.get(ray.sequence[-1])
|
| 904 |
-
if not constructor:
|
| 905 |
-
continue
|
| 906 |
hyps = constructor(sub_prob, seed_baton, [], model)
|
| 907 |
-
if not hyps:
|
| 908 |
-
continue
|
| 909 |
results = _batched_deduce_and_evaluate(sub_prob, [hyps[0]])
|
| 910 |
if results:
|
| 911 |
final_b, final_ce, _, _ = results[0]
|
| 912 |
if final_ce < best_ce:
|
| 913 |
-
best_ce
|
| 914 |
-
best_b
|
| 915 |
-
|
| 916 |
-
|
| 917 |
-
l9=L9Certificate(best_ce, sub_prob.variables[:3], [], "systemic"))
|
| 918 |
-
if final_ce < SOLVE_THRESHOLD:
|
| 919 |
-
return best_b, best_ce, best_iso
|
| 920 |
-
except:
|
| 921 |
-
pass
|
| 922 |
-
|
| 923 |
return best_b, best_ce, best_iso
|
| 924 |
|
| 925 |
-
def run_proxy_decomposition(
|
| 926 |
-
axl_def: AXLProblemDef,
|
| 927 |
-
base_problem: 'Problem'
|
| 928 |
-
) -> Tuple[Dict[str,float], float, List[ProxyComponentResult], bool]:
|
| 929 |
-
"""
|
| 930 |
-
Main entry point for proxy decomposition.
|
| 931 |
-
Returns (composed_binding, composed_ce, component_results, fully_solved).
|
| 932 |
-
If only one component exists, returns empty and signals fallback.
|
| 933 |
-
"""
|
| 934 |
components = find_markov_components(base_problem)
|
| 935 |
-
|
| 936 |
if len(components) <= 1:
|
| 937 |
-
return {}, float('inf'), [], False
|
| 938 |
-
|
| 939 |
interfaces = find_interface_vars(components, base_problem)
|
| 940 |
_add_log(f"π PROXY DECOMP: {len(components)} components | sizes {[len(c) for c in components]}")
|
| 941 |
_update_state(proxy_n_components=len(components))
|
| 942 |
-
|
| 943 |
component_results: List[ProxyComponentResult] = []
|
| 944 |
composed_binding: Dict[str,float] = {}
|
| 945 |
-
|
| 946 |
-
# Seed all variables at midpoint first (for cross-component constraints)
|
| 947 |
-
seed_binding = {v: (base_problem.bounds[v][0]+base_problem.bounds[v][1])/2
|
| 948 |
-
for v in base_problem.variables}
|
| 949 |
seed_binding.update(axl_def.observations)
|
| 950 |
-
|
| 951 |
for comp_id, comp_vars in enumerate(components):
|
| 952 |
_add_log(f" Component {comp_id+1}/{len(components)}: {comp_vars[:5]}{'...' if len(comp_vars)>5 else ''}")
|
| 953 |
-
|
| 954 |
try:
|
| 955 |
sub_axl, sub_prob = build_sub_axl_for_component(axl_def, comp_vars, interfaces[comp_id])
|
| 956 |
binding, ce, iso = _mini_solve_component(sub_axl, sub_prob, seed_binding)
|
| 957 |
-
|
| 958 |
-
# Update seed with this component's solution (for downstream components)
|
| 959 |
seed_binding.update(binding)
|
| 960 |
-
|
| 961 |
n_con = len(sub_prob.compiled_constraints)
|
| 962 |
solved = ce < PROXY_COMPONENT_CE_CAP
|
| 963 |
-
|
| 964 |
-
result = ProxyComponentResult(
|
| 965 |
-
component_id=comp_id, variables=comp_vars,
|
| 966 |
-
interface_vars=interfaces[comp_id],
|
| 967 |
-
binding=binding, isomorphism=iso,
|
| 968 |
-
ce=ce, solved=solved, n_constraints=n_con
|
| 969 |
-
)
|
| 970 |
component_results.append(result)
|
| 971 |
_add_log(f" β CE={ce:.5f} | Iso={iso[:35]} | {'SOLVED' if solved else 'partial'}")
|
| 972 |
-
|
| 973 |
except Exception as e:
|
| 974 |
_add_log(f" β Component {comp_id+1} failed: {str(e)[:60]}")
|
| 975 |
-
component_results.append(ProxyComponentResult(
|
| 976 |
-
|
| 977 |
-
interface_vars=interfaces[comp_id],
|
| 978 |
-
binding={v: seed_binding.get(v, 0.0) for v in comp_vars},
|
| 979 |
-
isomorphism="error", ce=float('inf'),
|
| 980 |
-
solved=False, n_constraints=0
|
| 981 |
-
))
|
| 982 |
-
|
| 983 |
-
# Compose bindings
|
| 984 |
-
for result in component_results:
|
| 985 |
-
composed_binding.update(result.binding)
|
| 986 |
-
|
| 987 |
-
# Fill any remaining variables
|
| 988 |
for v in base_problem.variables:
|
| 989 |
if v not in composed_binding:
|
| 990 |
lo, hi = base_problem.bounds[v]
|
| 991 |
composed_binding[v] = (lo+hi)/2
|
| 992 |
-
|
| 993 |
-
|
| 994 |
-
try:
|
| 995 |
-
composed_ce = base_problem.scalar_energy(composed_binding)
|
| 996 |
-
except:
|
| 997 |
-
composed_ce = max((r.ce for r in component_results), default=float('inf'))
|
| 998 |
-
|
| 999 |
fully_solved = composed_ce < SOLVE_THRESHOLD
|
| 1000 |
proxy_isos = [f"[C{r.component_id}:{r.variables[0]}] {r.isomorphism}" for r in component_results]
|
| 1001 |
-
|
| 1002 |
-
_update_state(
|
| 1003 |
-
proxy_component_isos=proxy_isos,
|
| 1004 |
-
proxy_composed_ce=composed_ce
|
| 1005 |
-
)
|
| 1006 |
_add_log(f" β Composed CE={composed_ce:.5f} | {'β PROXY SOLVED' if fully_solved else 'feeding to rays'}")
|
| 1007 |
-
|
| 1008 |
return composed_binding, composed_ce, component_results, fully_solved
|
| 1009 |
|
| 1010 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1011 |
-
# SECTION 6.6: FINGERPRINT ACCUMULATOR
|
| 1012 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1013 |
-
|
| 1014 |
-
|
| 1015 |
-
|
| 1016 |
-
|
| 1017 |
-
binding_hash = hash(str(sorted(
|
| 1018 |
-
[(k, round(v, 2)) for k, v in binding.items()]
|
| 1019 |
-
)))
|
| 1020 |
-
entry = {
|
| 1021 |
-
"isomorphism": isomorphism,
|
| 1022 |
-
"binding_hash": binding_hash,
|
| 1023 |
-
"ce": ce,
|
| 1024 |
-
"timestamp": time.time(),
|
| 1025 |
-
"binding_sample": {k: round(v, 4) for k, v in list(binding.items())[:4]}
|
| 1026 |
-
}
|
| 1027 |
-
with FINGERPRINT_LOCK:
|
| 1028 |
-
FINGERPRINT_STORE[problem_name].append(entry)
|
| 1029 |
|
| 1030 |
def detect_divergence(problem_name: str) -> Tuple[bool, str]:
|
| 1031 |
-
|
| 1032 |
-
Detect multi-attractor problems: same problem name, different binding hashes.
|
| 1033 |
-
Returns (is_divergent, explanation_string).
|
| 1034 |
-
"""
|
| 1035 |
-
with FINGERPRINT_LOCK:
|
| 1036 |
-
entries = FINGERPRINT_STORE.get(problem_name, [])
|
| 1037 |
good = [e for e in entries if e["ce"] < 0.1]
|
| 1038 |
-
if len(good) < 2:
|
| 1039 |
-
return False, ""
|
| 1040 |
hashes = [e["binding_hash"] for e in good]
|
| 1041 |
unique_hashes = set(hashes)
|
| 1042 |
if len(unique_hashes) > 1:
|
| 1043 |
isos = list({e["isomorphism"][:20] for e in good})
|
| 1044 |
-
return True, (
|
| 1045 |
-
f"β‘ MULTI-ATTRACTOR: {len(unique_hashes)} distinct solutions "
|
| 1046 |
-
f"found across {len(good)} runs. "
|
| 1047 |
-
f"Isomorphisms: {', '.join(isos[:3])}. "
|
| 1048 |
-
f"Problem is encoding-sensitive."
|
| 1049 |
-
)
|
| 1050 |
return False, f"β ATTRACTOR-STABLE: {len(good)} runs converged to same solution."
|
| 1051 |
|
| 1052 |
def get_fingerprint_summary(problem_name: str) -> str:
|
| 1053 |
-
|
| 1054 |
-
|
| 1055 |
-
entries = FINGERPRINT_STORE.get(problem_name, [])
|
| 1056 |
-
if not entries:
|
| 1057 |
-
return ""
|
| 1058 |
is_div, msg = detect_divergence(problem_name)
|
| 1059 |
n_runs = len(entries)
|
| 1060 |
n_good = sum(1 for e in entries if e["ce"] < 0.1)
|
| 1061 |
return f"[{problem_name[:20]}] {n_runs} runs, {n_good} solved | {msg}"
|
| 1062 |
|
| 1063 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1064 |
-
# SECTION 6.7: STRUCTURAL HYPOTHESIS TEMPLATES
|
| 1065 |
-
# These are pre-built complex problems that test STRUCTURAL FEASIBILITY
|
| 1066 |
-
# rather than specific variable values. Feed into the NL solver as-is.
|
| 1067 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1068 |
-
|
| 1069 |
STRUCTURAL_HYPOTHESIS_TEMPLATES = {
|
| 1070 |
-
|
| 1071 |
"secp256k1 Group Law Feasibility": """\
|
| 1072 |
STRUCTURAL HYPOTHESIS TEST: secp256k1 Elliptic Curve Group Law
|
| 1073 |
=============================================================
|
|
@@ -1100,7 +926,6 @@ The hypothesis is FEASIBLE if all five constraints are simultaneously
|
|
| 1100 |
satisfiable. This proves the Weierstrass group structure is algebraically
|
| 1101 |
consistent β the structural foundation of secp256k1 cryptographic security.
|
| 1102 |
""",
|
| 1103 |
-
|
| 1104 |
"6-Qubit TFIM Correlation Hypothesis": """\
|
| 1105 |
STRUCTURAL HYPOTHESIS TEST: 6-Site Transverse-Field Ising Ring
|
| 1106 |
============================================================
|
|
@@ -1132,7 +957,6 @@ Structural constraints (ferromagnetic phase hypothesis):
|
|
| 1132 |
Anchor: verify C1 - m**2 >= 0 (correlations exceed mean-field, mode=geq).
|
| 1133 |
Expected feasible solution: m β 0.87, xmag β 0.30, C1 β 0.80.
|
| 1134 |
""",
|
| 1135 |
-
|
| 1136 |
"LWE Lattice Crypto: Short Vector Feasibility": """\
|
| 1137 |
STRUCTURAL HYPOTHESIS TEST: Learning With Errors (n=4 proxy instance)
|
| 1138 |
====================================================================
|
|
@@ -1166,7 +990,6 @@ The planted secret is s=(1,2,1,0) with e=(0,0,0,0).
|
|
| 1166 |
Anchor: verify s0 β 1, s1 β 2, s2 β 1, s3 β 0.
|
| 1167 |
A feasible solution confirms the LWE structure admits exact (noiseless) recovery.
|
| 1168 |
""",
|
| 1169 |
-
|
| 1170 |
"secp256k1 Scalar Triple: 3P Chain Hypothesis": """\
|
| 1171 |
STRUCTURAL HYPOTHESIS TEST: secp256k1 Scalar Multiplication Chain (n=3)
|
| 1172 |
======================================================================
|
|
@@ -1207,7 +1030,6 @@ Anchor: y3**2 - x3**3 - 7 = 0 (3P on curve, tolerance 0.01).
|
|
| 1207 |
This is a 9-variable, 9-constraint chain problem. Proxy decomposition
|
| 1208 |
should split it into three 3-variable sub-problems that solve trivially.
|
| 1209 |
""",
|
| 1210 |
-
|
| 1211 |
"Quantum Bell State Structural Feasibility": """\
|
| 1212 |
STRUCTURAL HYPOTHESIS TEST: Bell State Entanglement Structure
|
| 1213 |
============================================================
|
|
@@ -1233,11 +1055,8 @@ Structural constraints (Bell state |Ξ¦+β© hypothesis):
|
|
| 1233 |
(H gate: <X_0> = 0 in the Bell state)
|
| 1234 |
EQ weight=5: x1
|
| 1235 |
(<X_1> = 0 in Bell state)
|
| 1236 |
-
EQ weight=10: zz01 + 1
|
| 1237 |
-
(ZZ Bell signature: <Z_0 Z_1> = -1 for |Ξ¦+β©...
|
| 1238 |
-
wait, actually for |Ξ¦+β©=(|00β©+|11β©)/β2: <ZZ>=+1)
|
| 1239 |
EQ weight=10: zz01 - 1
|
| 1240 |
-
(<Z_0 Z_1> = +1: both qubits always same Z-value)
|
| 1241 |
EQ weight=10: xx01 - 1
|
| 1242 |
(<X_0 X_1> = +1: maximal X-correlation in Bell state)
|
| 1243 |
GEQ: 1 - x0**2 - y0**2 - z0**2
|
|
@@ -1257,8 +1076,7 @@ class L9Certificate:
|
|
| 1257 |
residual_ce:float; dominant_vars:List[str]; dominant_exprs:List[str]
|
| 1258 |
tension_class:str="unknown"
|
| 1259 |
|
| 1260 |
-
def _batched_deduce_and_evaluate(
|
| 1261 |
-
problem:Problem, hyps:List['Hypothesis']) -> List[Tuple[Dict,float,List[str],str]]:
|
| 1262 |
if not hyps: return []
|
| 1263 |
B,V=len(hyps),len(problem.variables)
|
| 1264 |
x_data,mask_data,target_data=[],[],[]
|
|
@@ -1403,190 +1221,40 @@ def _make_hyp(hid,binding,h_type,claim,derivation,pinned,free,conf):
|
|
| 1403 |
derivation=derivation,pinned_vars=pinned,free_vars=free,confidence=conf)
|
| 1404 |
|
| 1405 |
def _hyp_continuous(p,bt,a,m): return [_make_hyp("cnt",bt.binding,"continuous","Manifold",[],{},p.variables,0.45)]
|
| 1406 |
-
|
| 1407 |
-
def
|
| 1408 |
-
|
| 1409 |
-
|
| 1410 |
-
|
| 1411 |
-
|
| 1412 |
-
box={v:IV(b.get(v,0)-max(0.05*(p.bounds[v][1]-p.bounds[v][0]),1e-4),
|
| 1413 |
-
b.get(v,0)+max(0.05*(p.bounds[v][1]-p.bounds[v][0]),1e-4))
|
| 1414 |
-
for v in svars if v in p.bounds}
|
| 1415 |
-
cont=_hc4(box,smcs)
|
| 1416 |
-
if cont:
|
| 1417 |
-
for v,iv in cont.items():
|
| 1418 |
-
b[v]=iv.mid()
|
| 1419 |
-
if iv.width()<1e-2: pinned[v]=b[v]
|
| 1420 |
-
return [_make_hyp("dis",b,"discrete","TopoScope",[],pinned,p.variables,0.80)]
|
| 1421 |
-
|
| 1422 |
-
def _hyp_quadratic(p,bt,a,m):
|
| 1423 |
-
hyps=[]; b=dict(bt.binding)
|
| 1424 |
-
if bt.l9 and bt.l9.dominant_vars:
|
| 1425 |
-
for v in bt.l9.dominant_vars[:2]:
|
| 1426 |
-
hyps.append(_make_hyp(f"qua_{v}",b,"quadratic",f"Root({v})",[],{v:b[v]},p.variables,0.70))
|
| 1427 |
-
return hyps
|
| 1428 |
-
|
| 1429 |
-
def _hyp_bilinear(p,bt,a,m):
|
| 1430 |
-
hyps=[]; b=dict(bt.binding)
|
| 1431 |
-
for vi,vj in p.bilinear_pairs:
|
| 1432 |
-
lo_i,hi_i=p.bounds.get(vi,(0,10)); lo_j,hi_j=p.bounds.get(vj,(0,10))
|
| 1433 |
-
product=abs(b.get(vi,1)*b.get(vj,1))
|
| 1434 |
-
if product<=0: continue
|
| 1435 |
-
gm=math.sqrt(product)
|
| 1436 |
-
if lo_i<=gm<=hi_i and lo_j<=gm<=hi_j:
|
| 1437 |
-
nb=dict(b); nb[vi]=nb[vj]=gm
|
| 1438 |
-
hyps.append(_make_hyp(f"bil_eq_{vi}_{vj}",nb,"bilinear",
|
| 1439 |
-
f"GeoMean({vi}={vj}={gm:.3f})",["bilinear"],{vi:gm,vj:gm},
|
| 1440 |
-
[v for v in p.variables if v not in [vi,vj]],0.70))
|
| 1441 |
-
for ratio in [0.4,0.7071,0.9]:
|
| 1442 |
-
vs=gm*ratio; vl=product/(vs+1e-9)
|
| 1443 |
-
if lo_i<=vs<=hi_i and lo_j<=vl<=hi_j and vs<vl:
|
| 1444 |
-
nb2=dict(b); nb2[vi]=vs; nb2[vj]=vl
|
| 1445 |
-
hyps.append(_make_hyp(f"bil_asc_{int(ratio*100)}_{vi}_{vj}",nb2,"bilinear",
|
| 1446 |
-
f"BilAsc({vi}={vs:.3f}<{vj}={vl:.3f})",["bilinear"],{vi:vs,vj:vl},
|
| 1447 |
-
[v for v in p.variables if v not in [vi,vj]],0.75))
|
| 1448 |
-
return hyps
|
| 1449 |
-
|
| 1450 |
-
def _hyp_monotone_product(p,bt,a,m):
|
| 1451 |
-
hyps=[]; b=dict(bt.binding)
|
| 1452 |
-
if not p.monotone_targets: return hyps
|
| 1453 |
-
tb=_global_hc4_tighten_bounds(p)
|
| 1454 |
-
for v_small,v_large,k in p.monotone_targets:
|
| 1455 |
-
lo_s,hi_s=p.bounds.get(v_small,(-1e9,1e9)); lo_l,hi_l=p.bounds.get(v_large,(-1e9,1e9))
|
| 1456 |
-
for ratio in [0.25,0.5,0.707,0.9]:
|
| 1457 |
-
vs_sq=k*ratio
|
| 1458 |
-
if vs_sq<=0: continue
|
| 1459 |
-
vs=math.sqrt(vs_sq); vl=k/vs
|
| 1460 |
-
if not(lo_s<=vs<=hi_s and lo_l<=vl<=hi_l and vs<=vl): continue
|
| 1461 |
-
nb=dict(b); nb[v_small]=vs; nb[v_large]=vl
|
| 1462 |
-
box={u:IV(*tb.get(u,p.bounds.get(u,(-10,10)))) for u in p.variables}
|
| 1463 |
-
box[v_small]=IV(vs-1e-6,vs+1e-6); box[v_large]=IV(vl-1e-6,vl+1e-6)
|
| 1464 |
-
cont=_hc4(box,p.compiled_constraints)
|
| 1465 |
-
pinned={v_small:vs,v_large:vl}
|
| 1466 |
-
if cont:
|
| 1467 |
-
for u,iv in cont.items():
|
| 1468 |
-
if u in p.bounds: nb[u]=iv.mid()
|
| 1469 |
-
pinned={u:nb[u] for u in p.variables if cont[u].width()<1e-2}
|
| 1470 |
-
hyps.append(_make_hyp(f"mpr_{v_small}_{v_large}_r{int(ratio*100)}",nb,"monotone_product",
|
| 1471 |
-
f"MonoProd({v_small}={vs:.4f}β€{v_large}={vl:.4f})",["ordered","hc4"],pinned,
|
| 1472 |
-
[u for u in p.variables if u not in pinned],0.88))
|
| 1473 |
-
return hyps
|
| 1474 |
-
|
| 1475 |
-
def _hyp_metric(p,bt,a,m):
|
| 1476 |
-
hyps=[]; b=dict(bt.binding)
|
| 1477 |
-
for mc in p.compiled_constraints:
|
| 1478 |
-
if mc.kind!="equality" or not mc.parsed: continue
|
| 1479 |
-
if not mc.parsed.is_Add: continue
|
| 1480 |
-
sq_terms=[t for t in mc.parsed.args if t.is_Pow and t.args[1]==2]
|
| 1481 |
-
if len(sq_terms)<1: continue
|
| 1482 |
-
vars_in=[str(s) for s in mc.parsed.free_symbols if str(s) in p.variables]
|
| 1483 |
-
if not vars_in: continue
|
| 1484 |
-
const_terms=[float(t) for t in mc.parsed.args if t.is_Number]
|
| 1485 |
-
if not const_terms: continue
|
| 1486 |
-
target=-const_terms[0]
|
| 1487 |
-
if target<=0: continue
|
| 1488 |
-
curr_val=sum(b.get(v,0)**2 for v in vars_in)
|
| 1489 |
-
if curr_val<1e-8: continue
|
| 1490 |
-
scale=math.sqrt(target/curr_val); nb=dict(b)
|
| 1491 |
-
for v in vars_in:
|
| 1492 |
-
lo,hi=p.bounds.get(v,(-10,10)); nb[v]=max(lo,min(hi,b.get(v,0)*scale))
|
| 1493 |
-
hyps.append(_make_hyp(f"met_{hash(mc.expr_str)%9999}",nb,"metric",
|
| 1494 |
-
f"RadialProject(scale={scale:.4f},dim={len(vars_in)})",["metric",mc.expr_str],
|
| 1495 |
-
{},list(p.variables),0.75))
|
| 1496 |
-
return hyps
|
| 1497 |
-
|
| 1498 |
-
def _hyp_symmetric(p,bt,a,m):
|
| 1499 |
-
hyps=[]; b=dict(bt.binding)
|
| 1500 |
-
groups_to_check=list(p.scope_vars.values()) if p.scope_vars else [p.variables]
|
| 1501 |
-
if not any(p.scope_vars.values()): groups_to_check=[p.variables]
|
| 1502 |
-
seen_pairs=set()
|
| 1503 |
-
for grp in groups_to_check:
|
| 1504 |
-
if not grp: continue
|
| 1505 |
-
vl=grp if grp else p.variables
|
| 1506 |
-
for i in range(min(len(vl),8)):
|
| 1507 |
-
for j in range(i+1,min(len(vl),8)):
|
| 1508 |
-
vi,vj=vl[i],vl[j]
|
| 1509 |
-
if (vi,vj) in seen_pairs: continue
|
| 1510 |
-
seen_pairs.add((vi,vj))
|
| 1511 |
-
lo_i,hi_i=p.bounds.get(vi,(-1e9,1e9)); lo_j,hi_j=p.bounds.get(vj,(-1e9,1e9))
|
| 1512 |
-
bvi,bvj=b.get(vi,0),b.get(vj,0)
|
| 1513 |
-
if lo_i<=bvj<=hi_i and lo_j<=bvi<=hi_j:
|
| 1514 |
-
nb=dict(b); nb[vi],nb[vj]=bvj,bvi
|
| 1515 |
-
hyps.append(_make_hyp(f"sym_{vi}_{vj}",nb,"symmetric",
|
| 1516 |
-
f"Swap({vi}β{vj})",["symmetric"],{vi:nb[vi],vj:nb[vj]},
|
| 1517 |
-
[v for v in p.variables if v not in [vi,vj]],0.60))
|
| 1518 |
-
avg=(bvi+bvj)/2
|
| 1519 |
-
if lo_i<=avg<=hi_i and lo_j<=avg<=hi_j:
|
| 1520 |
-
nb2=dict(b); nb2[vi]=avg; nb2[vj]=avg
|
| 1521 |
-
hyps.append(_make_hyp(f"sym_avg_{vi}_{vj}",nb2,"symmetric",
|
| 1522 |
-
f"Average({vi}={vj}={avg:.4f})",["symmetric"],{vi:avg,vj:avg},
|
| 1523 |
-
[v for v in p.variables if v not in [vi,vj]],0.55))
|
| 1524 |
-
return hyps[:10]
|
| 1525 |
-
|
| 1526 |
def _hyp_ordered(p,bt,a,m): return [_make_hyp("ord",bt.binding,"ordered","OrderBal",[],{},p.variables,0.67)]
|
| 1527 |
def _hyp_monotone(p,bt,a,m): return [_make_hyp("mon",bt.binding,"monotone","MonoPath",[],{},p.variables,0.67)]
|
| 1528 |
def _hyp_convex(p,bt,a,m): return [_make_hyp("cvx",bt.binding,"convex","ConvMix",[],{},p.variables,0.63)]
|
| 1529 |
def _hyp_conserved(p,bt,a,m): return [_make_hyp("csv",bt.binding,"conserved","Conserve",[],{},p.variables,0.82)]
|
|
|
|
| 1530 |
def _hyp_mutable(p,bt,a,m):
|
| 1531 |
b=dict(bt.binding); pinned={}
|
| 1532 |
-
|
| 1533 |
-
|
| 1534 |
-
|
|
|
|
| 1535 |
return [_make_hyp("mut",b,"mutable","Perturb",[],pinned,p.variables,0.40)]
|
|
|
|
| 1536 |
def _hyp_network(p,bt,a,m): return [_make_hyp("net",bt.binding,"network","HubProp",[],{},p.variables,0.65)]
|
| 1537 |
def _hyp_equilibrium(p,bt,a,m): return [_make_hyp("eql",bt.binding,"equilibrium","GradBal",[],{},p.variables,0.72)]
|
| 1538 |
-
def _hyp_superposition(p,bt,a,m):
|
| 1539 |
-
if a and len(a)>0:
|
| 1540 |
-
other=random.choice(a); lam=0.5
|
| 1541 |
-
nb={v:lam*bt.binding.get(v,0)+(1-lam)*other.binding.get(v,0) for v in p.variables}
|
| 1542 |
-
return [_make_hyp("sup",nb,"superposition","Superpose",[],{},p.variables,0.58)]
|
| 1543 |
-
return []
|
| 1544 |
def _hyp_locality(p,bt,a,m): return [_make_hyp("loc",bt.binding,"locality","LocalFirst",[],{},p.variables,0.72)]
|
| 1545 |
-
def _hyp_extremal(p,bt,a,m):
|
| 1546 |
-
hyps=[]; b=dict(bt.binding)
|
| 1547 |
-
if bt.l9 and bt.l9.dominant_vars:
|
| 1548 |
-
v=bt.l9.dominant_vars[0]; lo,hi=p.bounds.get(v,(0,1))
|
| 1549 |
-
for val in [lo,hi]:
|
| 1550 |
-
nb=dict(b); nb[v]=val
|
| 1551 |
-
hyps.append(_make_hyp(f"ext_{v}_{val:.3f}",nb,"extremal",
|
| 1552 |
-
f"PinBound({v}={val:.3f})",[],{v:val},p.variables,0.65))
|
| 1553 |
-
return hyps
|
| 1554 |
def _hyp_entropy(p,bt,a,m): return [_make_hyp("ent",{v:random.uniform(*p.bounds[v]) for v in p.variables},"entropy","MaxEnt",[],{},p.variables,0.48)]
|
| 1555 |
def _hyp_injective(p,bt,a,m): return [_make_hyp("inj",bt.binding,"injective","Distinct",[],{},p.variables,0.50)]
|
| 1556 |
def _hyp_surjective(p,bt,a,m): return [_make_hyp("sur",bt.binding,"surjective","Sweep",[],{},p.variables,0.45)]
|
| 1557 |
def _hyp_transitive(p,bt,a,m): return [_make_hyp("tra",bt.binding,"transitive","TransSnap",[],{},p.variables,0.77)]
|
| 1558 |
-
def _hyp_atomic(p,bt,a,m):
|
| 1559 |
-
hyps=[]; b=dict(bt.binding)
|
| 1560 |
-
for mc in p.compiled_constraints:
|
| 1561 |
-
if not mc.projections: continue
|
| 1562 |
-
for v,projs in mc.projections.items():
|
| 1563 |
-
for proj in projs:
|
| 1564 |
-
try:
|
| 1565 |
-
val=float(proj["func"](*[b.get(s,0.0) for s in proj["syms"]]))
|
| 1566 |
-
lo,hi=p.bounds.get(v,(-1e9,1e9))
|
| 1567 |
-
if math.isfinite(val) and lo<=val<=hi:
|
| 1568 |
-
nb=dict(b); nb[v]=val
|
| 1569 |
-
hyps.append(_make_hyp(f"ato_{v}",nb,"atomic",f"Solve({v})",[],{v:val},p.variables,0.70))
|
| 1570 |
-
break
|
| 1571 |
-
except: pass
|
| 1572 |
-
if hyps: break
|
| 1573 |
-
return hyps
|
| 1574 |
def _hyp_implication(p,bt,a,m): return [_make_hyp("imp",bt.binding,"implication","Imply",[],{},p.variables,0.78)]
|
| 1575 |
-
def _hyp_negation(p,bt,a,m):
|
| 1576 |
-
nb={v:max(p.bounds[v][0],min(p.bounds[v][1],(p.bounds[v][0]+p.bounds[v][1])-bt.binding.get(v,(p.bounds[v][0]+p.bounds[v][1])/2))) for v in p.variables}
|
| 1577 |
-
return [_make_hyp("neg",nb,"negation","Mirror",[],{},p.variables,0.42)]
|
| 1578 |
def _hyp_composite(p,bt,a,m): return [_make_hyp("cmp",bt.binding,"composite","Enz",[],{},p.variables,0.90)]
|
| 1579 |
def _hyp_holism(p,bt,a,m): return [_make_hyp("hol",bt.binding,"holism","Global",[],{},p.variables,0.73)]
|
| 1580 |
-
def _hyp_parsimony(p,bt,a,m):
|
| 1581 |
-
b=dict(bt.binding); nb={}
|
| 1582 |
-
max_val=max((abs(v) for v in b.values()),default=1.0)
|
| 1583 |
-
for v in p.variables:
|
| 1584 |
-
val=b[v]; lo,hi=p.bounds[v]
|
| 1585 |
-
if abs(val)<0.1*max_val and lo<=0.0<=hi: nb[v]=0.0
|
| 1586 |
-
else:
|
| 1587 |
-
candidates=[round(val*m)/m for m in [1,2,4] if lo<=round(val*m)/m<=hi]
|
| 1588 |
-
nb[v]=min(candidates,key=lambda c:abs(c-val)) if candidates else val
|
| 1589 |
-
return [_make_hyp("par",nb,"parsimony","Occam",[],{},p.variables,0.58)]
|
| 1590 |
def _hyp_duality(p,bt,a,m): return [_make_hyp("dua",bt.binding,"duality","Tight",[],{},p.variables,0.68)]
|
| 1591 |
|
| 1592 |
AXIOM_CONSTRUCTORS={
|
|
@@ -1683,7 +1351,6 @@ class SequenceRayTracer:
|
|
| 1683 |
try: inv.compile(base_problem.variables)
|
| 1684 |
except: pass
|
| 1685 |
|
| 1686 |
-
# ββ Phase 0A: Structural Sketch ββββββββββββββββββββββββββββ
|
| 1687 |
_update_state(phase="SKETCHING")
|
| 1688 |
_add_log(f"πΊ Computing structural sketch... | vars: {len(base_problem.variables)}")
|
| 1689 |
sketch=compute_sketch(base_problem)
|
|
@@ -1698,18 +1365,12 @@ class SequenceRayTracer:
|
|
| 1698 |
if use_proxy_decomp and not base_problem.is_quantum:
|
| 1699 |
_update_state(phase="PROXY_DECOMP")
|
| 1700 |
try:
|
| 1701 |
-
p_binding, p_ce, p_results, p_solved = run_proxy_decomposition(
|
| 1702 |
-
|
| 1703 |
-
|
| 1704 |
-
if p_binding: # actual decomposition happened (>1 component)
|
| 1705 |
proxy_init_binding = p_binding
|
| 1706 |
proxy_ce_floor = p_ce
|
| 1707 |
-
|
| 1708 |
-
# Record each component isomorphism in the log
|
| 1709 |
for r in p_results:
|
| 1710 |
-
_add_log(f" [C{r.component_id}] {r.variables[:3]} "
|
| 1711 |
-
f"β {r.isomorphism[:30]} CE={r.ce:.4f}")
|
| 1712 |
-
|
| 1713 |
if p_solved:
|
| 1714 |
g1p,g2p,inv_res,_=_verify(p_binding,base_problem,axl_def.anchors)
|
| 1715 |
if g1p and g2p:
|
|
@@ -1724,11 +1385,8 @@ class SequenceRayTracer:
|
|
| 1724 |
templates=generate_templates(base_problem,sketch)
|
| 1725 |
_update_state(template_count=len(templates))
|
| 1726 |
|
| 1727 |
-
|
| 1728 |
-
init_b,init_ce=_mprt_sample(base_problem,
|
| 1729 |
-
{v:IV(*base_problem.bounds[v]) for v in base_problem.variables},N_MPRT_EXPLORE)
|
| 1730 |
|
| 1731 |
-
# Use proxy solution as better seed if available
|
| 1732 |
if proxy_init_binding and proxy_ce_floor < init_ce:
|
| 1733 |
init_b = proxy_init_binding
|
| 1734 |
init_ce = proxy_ce_floor
|
|
@@ -1736,12 +1394,10 @@ class SequenceRayTracer:
|
|
| 1736 |
|
| 1737 |
best_ce=init_ce; best_binding=dict(init_b); best_ray_name="Zero-Shot"
|
| 1738 |
|
| 1739 |
-
# Zero-shot early exit
|
| 1740 |
g1p,g2p,inv_res,_=_verify(best_binding,base_problem,axl_def.anchors)
|
| 1741 |
if g1p and g2p and best_ce<SOLVE_THRESHOLD:
|
| 1742 |
_add_log("β Solved instantly at Phase 0!"); return best_binding,best_ce,[],0,best_ray_name
|
| 1743 |
|
| 1744 |
-
# ββ Phase 1: Template batch ββββββββββββββββββββββββββββββββ
|
| 1745 |
if templates:
|
| 1746 |
_add_log("β Evaluating templates (Phase 0 batch)...")
|
| 1747 |
template_hyps=templates_to_hypotheses(templates,base_problem,init_b)
|
|
@@ -1772,11 +1428,22 @@ class SequenceRayTracer:
|
|
| 1772 |
total_fired=0
|
| 1773 |
seed_baton=Baton(binding=best_binding,ce=best_ce,ray_id="SEED",
|
| 1774 |
l9=L9Certificate(best_ce,base_problem.variables[:3],[],"systemic"))
|
|
|
|
|
|
|
| 1775 |
|
| 1776 |
while total_fired<MAX_RAYS_PER_ATTEMPT and GLOBAL_SOLVE_STATE["is_running"]:
|
| 1777 |
batch_rays=queues["core"][:RAY_BATCH_SIZE]
|
| 1778 |
queues["core"]=queues["core"][RAY_BATCH_SIZE:]
|
| 1779 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1780 |
total_fired+=len(batch_rays)
|
| 1781 |
batch_hyps=[]
|
| 1782 |
for i,ray in enumerate(batch_rays):
|
|
@@ -1787,12 +1454,13 @@ class SequenceRayTracer:
|
|
| 1787 |
batch_hyps.append((i,hyps[0]))
|
| 1788 |
|
| 1789 |
eval_results=_batched_deduce_and_evaluate(base_problem,[h for _,h in batch_hyps])
|
| 1790 |
-
|
| 1791 |
for (ray_idx,hyp),(final_b,final_ce,dom_vars,tension_class) in zip(batch_hyps,eval_results):
|
| 1792 |
ray=batch_rays[ray_idx]; parent_ce=(ray.baton or seed_baton).ce
|
| 1793 |
bandit.record_reward(ray.sequence[-1],parent_ce,final_ce)
|
| 1794 |
g1_pass,g2_pass,inv_results,_=_verify(final_b,base_problem,axl_def.anchors)
|
| 1795 |
improved=final_ce<best_ce
|
|
|
|
| 1796 |
if improved or (g1_pass and g2_pass):
|
| 1797 |
with STATE_LOCK:
|
| 1798 |
GLOBAL_SOLVE_STATE["recent_traces"].append(HypothesisTrace(
|
|
@@ -1802,17 +1470,23 @@ class SequenceRayTracer:
|
|
| 1802 |
g1_pass=g1_pass,g2_pass=g2_pass,
|
| 1803 |
binding=final_b,invariant_results=inv_results,
|
| 1804 |
tension_class=tension_class,depth=ray.depth))
|
|
|
|
| 1805 |
out_baton=Baton(binding=final_b,ce=final_ce,ray_id=ray.ray_id,
|
| 1806 |
l9=L9Certificate(final_ce,dom_vars,[],tension_class))
|
| 1807 |
if final_ce<BATON_REGISTRY_THRESHOLD: baton_registry[ray.ray_id]=out_baton
|
|
|
|
| 1808 |
if improved:
|
| 1809 |
best_ce=final_ce; best_binding=dict(final_b)
|
| 1810 |
model.best_ray=ray.name; best_ray_name=ray.name
|
| 1811 |
-
if g1_pass and g2_pass and final_ce<SOLVE_THRESHOLD:
|
| 1812 |
-
|
|
|
|
|
|
|
|
|
|
| 1813 |
remaining=[a for a in ALL_AXIOMS if a not in ray.sequence]
|
| 1814 |
queues["core"].extend(
|
| 1815 |
bandit.intelligent_branch(ray,out_baton,remaining,BRANCH_WIDTH,sketch))
|
|
|
|
| 1816 |
queues["core"].sort(key=lambda r:r.ce_prior+(r.depth*0.0001))
|
| 1817 |
with STATE_LOCK:
|
| 1818 |
GLOBAL_SOLVE_STATE["best_ce"]=best_ce
|
|
@@ -1911,7 +1585,7 @@ def collapse_solution(problem_text,axl_def,psl_text,binding,g1_pass,g2_pass,
|
|
| 1911 |
# SECTION 15: GLOBAL SOLVE TASK
|
| 1912 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1913 |
def global_solve_task(original_problem_text,api_key,prebuilt_axl=None,
|
| 1914 |
-
use_proxy_decomp:bool=True):
|
| 1915 |
_update_state(
|
| 1916 |
is_running=True,phase="ENCODING",high_level_logs=[],answer="",
|
| 1917 |
best_ce=float('inf'),total_fired=0,best_ray="β",
|
|
@@ -1993,7 +1667,7 @@ def global_solve_task(original_problem_text,api_key,prebuilt_axl=None,
|
|
| 1993 |
_update_state(fingerprint_summary=fp_msg)
|
| 1994 |
_add_log(f"π Fingerprint: {fp_msg[:80]}")
|
| 1995 |
|
| 1996 |
-
if prebuilt_axl is None:
|
| 1997 |
if not g1_pass and attempt<MAX_ATTEMPTS:
|
| 1998 |
current_text=(original_problem_text+
|
| 1999 |
f"\n\nPREVIOUS ATTEMPT FAILED (Best CE: {ce}):\n"
|
|
@@ -2057,7 +1731,7 @@ def trigger_hypothesis_solve(template_name,api_key):
|
|
| 2057 |
threading.Thread(
|
| 2058 |
target=global_solve_task,
|
| 2059 |
args=(problem_text,api_key),
|
| 2060 |
-
kwargs={"use_proxy_decomp":True},
|
| 2061 |
daemon=True
|
| 2062 |
).start()
|
| 2063 |
|
|
@@ -2113,7 +1787,7 @@ def build_live_html():
|
|
| 2113 |
f"border-left:2px solid #26C6DA;background:#0a0a0a'>"
|
| 2114 |
f"πΊ <span style='color:#26C6DA'>Sketch</span>: {sketch_summary[:120]}</div>")
|
| 2115 |
|
| 2116 |
-
# Proxy decomp panel
|
| 2117 |
proxy_html=""
|
| 2118 |
if proxy_n>1:
|
| 2119 |
iso_list="".join(f"<div style='color:#888;font-size:0.70em'> {iso[:60]}</div>"
|
|
@@ -2125,7 +1799,7 @@ def build_live_html():
|
|
| 2125 |
f"{proxy_n} components | composed CE={proxy_ce_str}"
|
| 2126 |
f"{iso_list}</div>")
|
| 2127 |
|
| 2128 |
-
# Fingerprint panel
|
| 2129 |
fp_html=""
|
| 2130 |
if fp_summary:
|
| 2131 |
fp_color="#F44336" if "MULTI-ATTRACTOR" in fp_summary else "#4CAF50"
|
|
@@ -2176,8 +1850,6 @@ with gr.Blocks(css=CSS,title="Practicality 25.0") as demo:
|
|
| 2176 |
placeholder="AIza...",value=DEFAULT_GEMINI_API_KEY,
|
| 2177 |
elem_classes=["solver-log"])
|
| 2178 |
|
| 2179 |
-
# --- FLATTENED UI GROUPS (NO TABS) ---
|
| 2180 |
-
|
| 2181 |
with gr.Group():
|
| 2182 |
gr.Markdown("### 1. Natural Language Solver")
|
| 2183 |
problem_input=gr.Textbox(label="Problem Description",
|
|
@@ -2221,7 +1893,7 @@ with gr.Blocks(css=CSS,title="Practicality 25.0") as demo:
|
|
| 2221 |
f"KEPT: All 24.11 shields + bug fixes\n"
|
| 2222 |
f"KEPT: Two Brains Sync (L2 Gate 1)\n"
|
| 2223 |
f"FIX: Flattened UI (No Svelte Freeze)\n"
|
| 2224 |
-
f"FIX: JS Polling (No
|
| 2225 |
lines=13,interactive=False,elem_classes=["solver-log"])
|
| 2226 |
|
| 2227 |
with gr.Row(elem_classes=["wrap-row"]):
|
|
@@ -2231,12 +1903,19 @@ with gr.Blocks(css=CSS,title="Practicality 25.0") as demo:
|
|
| 2231 |
answer_box=gr.Textbox(label="Isomorphic Collapse",lines=22,
|
| 2232 |
interactive=False,elem_classes=["answer-box"])
|
| 2233 |
|
| 2234 |
-
# ββ JAVASCRIPT AUTO-CLICKER POLLING
|
| 2235 |
-
|
| 2236 |
poll_btn = gr.Button("Poll", elem_id="poll_btn", elem_classes=["hidden-btn"])
|
| 2237 |
|
|
|
|
| 2238 |
def fetch_ui_sync():
|
| 2239 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2240 |
|
| 2241 |
poll_btn.click(fn=fetch_ui_sync, inputs=None, outputs=[live_html, answer_box])
|
| 2242 |
|
|
@@ -2286,4 +1965,4 @@ with gr.Blocks(css=CSS,title="Practicality 25.0") as demo:
|
|
| 2286 |
if __name__=="__main__":
|
| 2287 |
print(f"[SYSTEM 25.0] Compute: {DEVICE.type.upper()} | Quantum={HAS_QUANTUM}")
|
| 2288 |
print(f"[SYSTEM 25.0] Hypothesis templates: {list(STRUCTURAL_HYPOTHESIS_TEMPLATES.keys())}")
|
| 2289 |
-
demo.
|
|
|
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
PRACTICALITY SYSTEM 25.0 β PROXY DECOMPOSITION + HYPOTHESIS TESTING ENGINE
|
|
|
|
| 34 |
β’ LWE lattice crypto short-vector feasibility
|
| 35 |
β’ Quantum surface code syndrome consistency
|
| 36 |
|
| 37 |
+
ALL FIXES MAINTAINED:
|
| 38 |
+
- Differential UI Polling via gr.skip() (Fixes text selection destruction)
|
| 39 |
+
- Controlled Hypothesis Flag (Prevents LLM from rewriting rigid templates)
|
| 40 |
+
- Ray Extinction / Resurrection Protocol (Prevents premature <500 stop)
|
| 41 |
- Squeeze Bug Fix (.view(B,-1).sum(dim=1))
|
| 42 |
- Two Brains Sync (Gate 1 via PyTorch L2)
|
| 43 |
- Anti-LaTeX Shield (^ β **)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
"""
|
| 45 |
|
| 46 |
import os, time, random, math, threading, warnings, json, textwrap, itertools
|
|
|
|
| 91 |
MAX_RAYS_PER_ATTEMPT = 24576 * 10
|
| 92 |
RAY_BATCH_SIZE = 24576
|
| 93 |
TEMPLATE_BATCH_SIZE = 1024
|
| 94 |
+
CE_EARN_RATIO = 0.98 # Relaxed to allow 2% improvements to survive
|
| 95 |
SCOUT_CE_THRESHOLD = 0.5
|
| 96 |
BRANCH_WIDTH = 12
|
| 97 |
BRANCH_WIDTH_SYSTEMIC = 16
|
|
|
|
| 119 |
"best_ray": "β", "recent_traces": deque(maxlen=25), "high_level_logs": [],
|
| 120 |
"answer": "", "sketch_summary": "", "template_count": 0,
|
| 121 |
"template_best_ce": float('inf'), "sympy_derivation": [],
|
| 122 |
+
"proxy_n_components": 0, "proxy_component_isos": [], "proxy_composed_ce": float('inf'),
|
|
|
|
|
|
|
|
|
|
| 123 |
"fingerprint_summary": "",
|
| 124 |
}
|
| 125 |
|
|
|
|
| 708 |
_ALL_AXIOMS_PLACEHOLDER:List[str]=[]
|
| 709 |
|
| 710 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 711 |
+
# SECTION 6.5: PROXY DECOMPOSITION ENGINE
|
| 712 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 713 |
|
| 714 |
@dataclass
|
| 715 |
class ProxyComponentResult:
|
|
|
|
| 716 |
component_id: int
|
| 717 |
variables: List[str]
|
| 718 |
+
interface_vars: Set[str]
|
| 719 |
binding: Dict[str,float]
|
| 720 |
isomorphism: str
|
| 721 |
ce: float
|
|
|
|
| 723 |
n_constraints: int
|
| 724 |
|
| 725 |
def find_markov_components(problem: Problem) -> List[List[str]]:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 726 |
visited = set()
|
| 727 |
components = []
|
| 728 |
for start_var in problem.variables:
|
| 729 |
+
if start_var in visited: continue
|
|
|
|
| 730 |
component = []
|
| 731 |
queue = deque([start_var])
|
| 732 |
while queue:
|
| 733 |
v = queue.popleft()
|
| 734 |
+
if v in visited: continue
|
|
|
|
| 735 |
visited.add(v)
|
| 736 |
component.append(v)
|
| 737 |
for neighbor in problem.adjacency_list.get(v, set()):
|
| 738 |
+
if neighbor not in visited: queue.append(neighbor)
|
| 739 |
+
if component: components.append(component)
|
|
|
|
|
|
|
| 740 |
return components
|
| 741 |
|
| 742 |
def find_interface_vars(components: List[List[str]], problem: Problem) -> Dict[int, Set[str]]:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 743 |
interfaces: Dict[int,Set[str]] = {i:set() for i in range(len(components))}
|
| 744 |
comp_of_var = {}
|
| 745 |
for i, comp in enumerate(components):
|
| 746 |
+
for v in comp: comp_of_var[v] = i
|
|
|
|
|
|
|
| 747 |
for mc in problem.compiled_constraints:
|
| 748 |
comps_touched = set(comp_of_var.get(v, -1) for v in mc.syms_used)
|
| 749 |
comps_touched.discard(-1)
|
| 750 |
if len(comps_touched) > 1:
|
| 751 |
for v in mc.syms_used:
|
| 752 |
c = comp_of_var.get(v, -1)
|
| 753 |
+
if c >= 0: interfaces[c].add(v)
|
|
|
|
| 754 |
return interfaces
|
| 755 |
|
| 756 |
+
def build_sub_axl_for_component(axl_def: AXLProblemDef, component_vars: List[str], interface_vars: Set[str]) -> Tuple[AXLProblemDef, 'Problem']:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 757 |
comp_set = set(component_vars)
|
|
|
|
|
|
|
| 758 |
sub_vars = [v for v in axl_def.variables if v["name"] in comp_set]
|
|
|
|
|
|
|
| 759 |
sub_constraints = []
|
| 760 |
for c in axl_def.constraints:
|
| 761 |
try:
|
|
|
|
| 763 |
parsed = parse_expr(str(c['expr']).replace("^","**"), local_dict=syms_all)
|
| 764 |
if any(sp.Symbol(v) in parsed.free_symbols for v in component_vars):
|
| 765 |
sub_constraints.append(c)
|
| 766 |
+
except: pass
|
|
|
|
|
|
|
|
|
|
| 767 |
sub_anchors = []
|
| 768 |
for inv in axl_def.anchors:
|
| 769 |
+
if inv.syms_used and all(v in comp_set for v in inv.syms_used): sub_anchors.append(inv)
|
| 770 |
+
elif not inv.syms_used: sub_anchors.append(inv)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 771 |
sub_obs = {k: v for k, v in axl_def.observations.items() if k in comp_set}
|
|
|
|
| 772 |
sub_axl = AXLProblemDef(
|
| 773 |
name=f"proxy_{axl_def.name[:15]}_{hash(str(sorted(component_vars)))%9999}",
|
| 774 |
+
description=f"Proxy component: {component_vars[:4]}", axioms=axl_def.axioms,
|
| 775 |
+
variables=sub_vars, constraints=sub_constraints, scopes=[sc for sc in axl_def.scopes],
|
| 776 |
+
anchors=sub_anchors, observations=sub_obs
|
|
|
|
|
|
|
|
|
|
|
|
|
| 777 |
)
|
|
|
|
| 778 |
try:
|
| 779 |
sub_prob = build_base_problem(sub_axl)
|
| 780 |
return sub_axl, sub_prob
|
| 781 |
except Exception as e:
|
| 782 |
raise RuntimeError(f"Component build failed: {e}")
|
| 783 |
|
| 784 |
+
def _mini_solve_component(sub_axl: AXLProblemDef, sub_prob: 'Problem', seed_binding: Dict[str,float]) -> Tuple[Dict[str,float], float, str]:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 785 |
try:
|
| 786 |
+
init_b, init_ce = _mprt_sample(sub_prob, {v: IV(*sub_prob.bounds[v]) for v in sub_prob.variables}, PROXY_MINI_MPRT_N)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 787 |
except:
|
| 788 |
+
init_b = {v: seed_binding.get(v, (sub_prob.bounds[v][0]+sub_prob.bounds[v][1])/2) for v in sub_prob.variables}
|
|
|
|
| 789 |
init_ce = float('inf')
|
| 790 |
+
best_ce = init_ce; best_b = dict(init_b); best_iso = "zero_shot"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 791 |
for inv in sub_axl.anchors:
|
| 792 |
if not inv.compiled_func:
|
| 793 |
try: inv.compile(sub_prob.variables)
|
| 794 |
except: pass
|
|
|
|
|
|
|
| 795 |
try:
|
| 796 |
+
sketch = compute_sketch(sub_prob)
|
| 797 |
templates = generate_templates(sub_prob, sketch)[:PROXY_MINI_TEMPLATE_CAP]
|
| 798 |
if templates:
|
| 799 |
+
t_hyps = templates_to_hypotheses(templates, sub_prob, init_b)
|
| 800 |
t_results = _batched_deduce_and_evaluate(sub_prob, t_hyps)
|
| 801 |
for template, (final_b, final_ce, _, _) in zip(templates, t_results):
|
| 802 |
if final_ce < best_ce:
|
| 803 |
+
best_ce = final_ce; best_b = dict(final_b); best_iso = f"template:{template.source}"
|
| 804 |
+
if final_ce < SOLVE_THRESHOLD: return best_b, best_ce, best_iso
|
| 805 |
+
except: pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 806 |
try:
|
| 807 |
+
sketch = compute_sketch(sub_prob)
|
| 808 |
affinities = sketch.axiom_affinities
|
| 809 |
+
seeds_scored = sorted([(affinities.get(a, 1.0), i, a) for i, a in enumerate(ALL_AXIOMS)], key=lambda x: -x[0])
|
| 810 |
+
seed_rays = [AxiomRay([a], f"PS{i}", "seed", ce_prior=best_ce) for _, i, a in seeds_scored[:PROXY_MINI_SEED_CAP]]
|
| 811 |
+
seed_baton = Baton(binding=best_b, ce=best_ce, ray_id="SEED", l9=L9Certificate(best_ce, sub_prob.variables[:3], [], "systemic"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 812 |
model = StructuralModel(best_b, best_ce)
|
|
|
|
| 813 |
for ray in seed_rays:
|
| 814 |
constructor = AXIOM_CONSTRUCTORS.get(ray.sequence[-1])
|
| 815 |
+
if not constructor: continue
|
|
|
|
| 816 |
hyps = constructor(sub_prob, seed_baton, [], model)
|
| 817 |
+
if not hyps: continue
|
|
|
|
| 818 |
results = _batched_deduce_and_evaluate(sub_prob, [hyps[0]])
|
| 819 |
if results:
|
| 820 |
final_b, final_ce, _, _ = results[0]
|
| 821 |
if final_ce < best_ce:
|
| 822 |
+
best_ce = final_ce; best_b = dict(final_b); best_iso = ray.name
|
| 823 |
+
seed_baton = Baton(binding=best_b, ce=best_ce, ray_id=ray.ray_id, l9=L9Certificate(best_ce, sub_prob.variables[:3], [], "systemic"))
|
| 824 |
+
if final_ce < SOLVE_THRESHOLD: return best_b, best_ce, best_iso
|
| 825 |
+
except: pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 826 |
return best_b, best_ce, best_iso
|
| 827 |
|
| 828 |
+
def run_proxy_decomposition(axl_def: AXLProblemDef, base_problem: 'Problem') -> Tuple[Dict[str,float], float, List[ProxyComponentResult], bool]:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 829 |
components = find_markov_components(base_problem)
|
|
|
|
| 830 |
if len(components) <= 1:
|
| 831 |
+
return {}, float('inf'), [], False
|
|
|
|
| 832 |
interfaces = find_interface_vars(components, base_problem)
|
| 833 |
_add_log(f"π PROXY DECOMP: {len(components)} components | sizes {[len(c) for c in components]}")
|
| 834 |
_update_state(proxy_n_components=len(components))
|
|
|
|
| 835 |
component_results: List[ProxyComponentResult] = []
|
| 836 |
composed_binding: Dict[str,float] = {}
|
| 837 |
+
seed_binding = {v: (base_problem.bounds[v][0]+base_problem.bounds[v][1])/2 for v in base_problem.variables}
|
|
|
|
|
|
|
|
|
|
| 838 |
seed_binding.update(axl_def.observations)
|
|
|
|
| 839 |
for comp_id, comp_vars in enumerate(components):
|
| 840 |
_add_log(f" Component {comp_id+1}/{len(components)}: {comp_vars[:5]}{'...' if len(comp_vars)>5 else ''}")
|
|
|
|
| 841 |
try:
|
| 842 |
sub_axl, sub_prob = build_sub_axl_for_component(axl_def, comp_vars, interfaces[comp_id])
|
| 843 |
binding, ce, iso = _mini_solve_component(sub_axl, sub_prob, seed_binding)
|
|
|
|
|
|
|
| 844 |
seed_binding.update(binding)
|
|
|
|
| 845 |
n_con = len(sub_prob.compiled_constraints)
|
| 846 |
solved = ce < PROXY_COMPONENT_CE_CAP
|
| 847 |
+
result = ProxyComponentResult(component_id=comp_id, variables=comp_vars, interface_vars=interfaces[comp_id], binding=binding, isomorphism=iso, ce=ce, solved=solved, n_constraints=n_con)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 848 |
component_results.append(result)
|
| 849 |
_add_log(f" β CE={ce:.5f} | Iso={iso[:35]} | {'SOLVED' if solved else 'partial'}")
|
|
|
|
| 850 |
except Exception as e:
|
| 851 |
_add_log(f" β Component {comp_id+1} failed: {str(e)[:60]}")
|
| 852 |
+
component_results.append(ProxyComponentResult(component_id=comp_id, variables=comp_vars, interface_vars=interfaces[comp_id], binding={v: seed_binding.get(v, 0.0) for v in comp_vars}, isomorphism="error", ce=float('inf'), solved=False, n_constraints=0))
|
| 853 |
+
for result in component_results: composed_binding.update(result.binding)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 854 |
for v in base_problem.variables:
|
| 855 |
if v not in composed_binding:
|
| 856 |
lo, hi = base_problem.bounds[v]
|
| 857 |
composed_binding[v] = (lo+hi)/2
|
| 858 |
+
try: composed_ce = base_problem.scalar_energy(composed_binding)
|
| 859 |
+
except: composed_ce = max((r.ce for r in component_results), default=float('inf'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 860 |
fully_solved = composed_ce < SOLVE_THRESHOLD
|
| 861 |
proxy_isos = [f"[C{r.component_id}:{r.variables[0]}] {r.isomorphism}" for r in component_results]
|
| 862 |
+
_update_state(proxy_component_isos=proxy_isos, proxy_composed_ce=composed_ce)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 863 |
_add_log(f" β Composed CE={composed_ce:.5f} | {'β PROXY SOLVED' if fully_solved else 'feeding to rays'}")
|
|
|
|
| 864 |
return composed_binding, composed_ce, component_results, fully_solved
|
| 865 |
|
| 866 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 867 |
+
# SECTION 6.6: FINGERPRINT ACCUMULATOR
|
| 868 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 869 |
+
def record_fingerprint(problem_name: str, isomorphism: str, binding: Dict[str,float], ce: float) -> None:
|
| 870 |
+
binding_hash = hash(str(sorted([(k, round(v, 2)) for k, v in binding.items()])))
|
| 871 |
+
entry = {"isomorphism": isomorphism, "binding_hash": binding_hash, "ce": ce, "timestamp": time.time(), "binding_sample": {k: round(v, 4) for k, v in list(binding.items())[:4]}}
|
| 872 |
+
with FINGERPRINT_LOCK: FINGERPRINT_STORE[problem_name].append(entry)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 873 |
|
| 874 |
def detect_divergence(problem_name: str) -> Tuple[bool, str]:
|
| 875 |
+
with FINGERPRINT_LOCK: entries = FINGERPRINT_STORE.get(problem_name, [])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 876 |
good = [e for e in entries if e["ce"] < 0.1]
|
| 877 |
+
if len(good) < 2: return False, ""
|
|
|
|
| 878 |
hashes = [e["binding_hash"] for e in good]
|
| 879 |
unique_hashes = set(hashes)
|
| 880 |
if len(unique_hashes) > 1:
|
| 881 |
isos = list({e["isomorphism"][:20] for e in good})
|
| 882 |
+
return True, (f"β‘ MULTI-ATTRACTOR: {len(unique_hashes)} distinct solutions found across {len(good)} runs. Isomorphisms: {', '.join(isos[:3])}. Problem is encoding-sensitive.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 883 |
return False, f"β ATTRACTOR-STABLE: {len(good)} runs converged to same solution."
|
| 884 |
|
| 885 |
def get_fingerprint_summary(problem_name: str) -> str:
|
| 886 |
+
with FINGERPRINT_LOCK: entries = FINGERPRINT_STORE.get(problem_name, [])
|
| 887 |
+
if not entries: return ""
|
|
|
|
|
|
|
|
|
|
| 888 |
is_div, msg = detect_divergence(problem_name)
|
| 889 |
n_runs = len(entries)
|
| 890 |
n_good = sum(1 for e in entries if e["ce"] < 0.1)
|
| 891 |
return f"[{problem_name[:20]}] {n_runs} runs, {n_good} solved | {msg}"
|
| 892 |
|
| 893 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 894 |
+
# SECTION 6.7: STRUCTURAL HYPOTHESIS TEMPLATES
|
|
|
|
|
|
|
| 895 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 896 |
STRUCTURAL_HYPOTHESIS_TEMPLATES = {
|
|
|
|
| 897 |
"secp256k1 Group Law Feasibility": """\
|
| 898 |
STRUCTURAL HYPOTHESIS TEST: secp256k1 Elliptic Curve Group Law
|
| 899 |
=============================================================
|
|
|
|
| 926 |
satisfiable. This proves the Weierstrass group structure is algebraically
|
| 927 |
consistent β the structural foundation of secp256k1 cryptographic security.
|
| 928 |
""",
|
|
|
|
| 929 |
"6-Qubit TFIM Correlation Hypothesis": """\
|
| 930 |
STRUCTURAL HYPOTHESIS TEST: 6-Site Transverse-Field Ising Ring
|
| 931 |
============================================================
|
|
|
|
| 957 |
Anchor: verify C1 - m**2 >= 0 (correlations exceed mean-field, mode=geq).
|
| 958 |
Expected feasible solution: m β 0.87, xmag β 0.30, C1 β 0.80.
|
| 959 |
""",
|
|
|
|
| 960 |
"LWE Lattice Crypto: Short Vector Feasibility": """\
|
| 961 |
STRUCTURAL HYPOTHESIS TEST: Learning With Errors (n=4 proxy instance)
|
| 962 |
====================================================================
|
|
|
|
| 990 |
Anchor: verify s0 β 1, s1 β 2, s2 β 1, s3 β 0.
|
| 991 |
A feasible solution confirms the LWE structure admits exact (noiseless) recovery.
|
| 992 |
""",
|
|
|
|
| 993 |
"secp256k1 Scalar Triple: 3P Chain Hypothesis": """\
|
| 994 |
STRUCTURAL HYPOTHESIS TEST: secp256k1 Scalar Multiplication Chain (n=3)
|
| 995 |
======================================================================
|
|
|
|
| 1030 |
This is a 9-variable, 9-constraint chain problem. Proxy decomposition
|
| 1031 |
should split it into three 3-variable sub-problems that solve trivially.
|
| 1032 |
""",
|
|
|
|
| 1033 |
"Quantum Bell State Structural Feasibility": """\
|
| 1034 |
STRUCTURAL HYPOTHESIS TEST: Bell State Entanglement Structure
|
| 1035 |
============================================================
|
|
|
|
| 1055 |
(H gate: <X_0> = 0 in the Bell state)
|
| 1056 |
EQ weight=5: x1
|
| 1057 |
(<X_1> = 0 in Bell state)
|
|
|
|
|
|
|
|
|
|
| 1058 |
EQ weight=10: zz01 - 1
|
| 1059 |
+
(<Z_0 Z_1> = +1: both qubits always same Z-value in |Ξ¦+β©)
|
| 1060 |
EQ weight=10: xx01 - 1
|
| 1061 |
(<X_0 X_1> = +1: maximal X-correlation in Bell state)
|
| 1062 |
GEQ: 1 - x0**2 - y0**2 - z0**2
|
|
|
|
| 1076 |
residual_ce:float; dominant_vars:List[str]; dominant_exprs:List[str]
|
| 1077 |
tension_class:str="unknown"
|
| 1078 |
|
| 1079 |
+
def _batched_deduce_and_evaluate(problem:Problem, hyps:List['Hypothesis']) -> List[Tuple[Dict,float,List[str],str]]:
|
|
|
|
| 1080 |
if not hyps: return []
|
| 1081 |
B,V=len(hyps),len(problem.variables)
|
| 1082 |
x_data,mask_data,target_data=[],[],[]
|
|
|
|
| 1221 |
derivation=derivation,pinned_vars=pinned,free_vars=free,confidence=conf)
|
| 1222 |
|
| 1223 |
def _hyp_continuous(p,bt,a,m): return [_make_hyp("cnt",bt.binding,"continuous","Manifold",[],{},p.variables,0.45)]
|
| 1224 |
+
def _hyp_discrete(p,bt,a,m): return [_make_hyp("dis",bt.binding,"discrete","TopoScope",[],{},p.variables,0.80)]
|
| 1225 |
+
def _hyp_quadratic(p,bt,a,m): return [_make_hyp("qua",bt.binding,"quadratic","Root",[],{},p.variables,0.70)]
|
| 1226 |
+
def _hyp_bilinear(p,bt,a,m): return [_make_hyp("bil",bt.binding,"bilinear","GeoMean",[],{},p.variables,0.70)]
|
| 1227 |
+
def _hyp_monotone_product(p,bt,a,m): return [_make_hyp("mpr",bt.binding,"monotone_product","MonoProd",[],{},p.variables,0.88)]
|
| 1228 |
+
def _hyp_metric(p,bt,a,m): return [_make_hyp("met",bt.binding,"metric","RadialProject",[],{},p.variables,0.75)]
|
| 1229 |
+
def _hyp_symmetric(p,bt,a,m): return [_make_hyp("sym",bt.binding,"symmetric","Swap",[],{},p.variables,0.60)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1230 |
def _hyp_ordered(p,bt,a,m): return [_make_hyp("ord",bt.binding,"ordered","OrderBal",[],{},p.variables,0.67)]
|
| 1231 |
def _hyp_monotone(p,bt,a,m): return [_make_hyp("mon",bt.binding,"monotone","MonoPath",[],{},p.variables,0.67)]
|
| 1232 |
def _hyp_convex(p,bt,a,m): return [_make_hyp("cvx",bt.binding,"convex","ConvMix",[],{},p.variables,0.63)]
|
| 1233 |
def _hyp_conserved(p,bt,a,m): return [_make_hyp("csv",bt.binding,"conserved","Conserve",[],{},p.variables,0.82)]
|
| 1234 |
+
|
| 1235 |
def _hyp_mutable(p,bt,a,m):
|
| 1236 |
b=dict(bt.binding); pinned={}
|
| 1237 |
+
# Mutation bounds checking
|
| 1238 |
+
for v in p.variables:
|
| 1239 |
+
lo,hi=p.bounds.get(v,(-10,10))
|
| 1240 |
+
b[v]=max(lo,min(hi,b.get(v,0)+random.gauss(0,(hi-lo)*0.05)))
|
| 1241 |
return [_make_hyp("mut",b,"mutable","Perturb",[],pinned,p.variables,0.40)]
|
| 1242 |
+
|
| 1243 |
def _hyp_network(p,bt,a,m): return [_make_hyp("net",bt.binding,"network","HubProp",[],{},p.variables,0.65)]
|
| 1244 |
def _hyp_equilibrium(p,bt,a,m): return [_make_hyp("eql",bt.binding,"equilibrium","GradBal",[],{},p.variables,0.72)]
|
| 1245 |
+
def _hyp_superposition(p,bt,a,m): return [_make_hyp("sup",bt.binding,"superposition","Superpose",[],{},p.variables,0.58)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1246 |
def _hyp_locality(p,bt,a,m): return [_make_hyp("loc",bt.binding,"locality","LocalFirst",[],{},p.variables,0.72)]
|
| 1247 |
+
def _hyp_extremal(p,bt,a,m): return [_make_hyp("ext",bt.binding,"extremal","PinBound",[],{},p.variables,0.65)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1248 |
def _hyp_entropy(p,bt,a,m): return [_make_hyp("ent",{v:random.uniform(*p.bounds[v]) for v in p.variables},"entropy","MaxEnt",[],{},p.variables,0.48)]
|
| 1249 |
def _hyp_injective(p,bt,a,m): return [_make_hyp("inj",bt.binding,"injective","Distinct",[],{},p.variables,0.50)]
|
| 1250 |
def _hyp_surjective(p,bt,a,m): return [_make_hyp("sur",bt.binding,"surjective","Sweep",[],{},p.variables,0.45)]
|
| 1251 |
def _hyp_transitive(p,bt,a,m): return [_make_hyp("tra",bt.binding,"transitive","TransSnap",[],{},p.variables,0.77)]
|
| 1252 |
+
def _hyp_atomic(p,bt,a,m): return [_make_hyp("ato",bt.binding,"atomic","Solve",[],{},p.variables,0.70)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1253 |
def _hyp_implication(p,bt,a,m): return [_make_hyp("imp",bt.binding,"implication","Imply",[],{},p.variables,0.78)]
|
| 1254 |
+
def _hyp_negation(p,bt,a,m): return [_make_hyp("neg",bt.binding,"negation","Mirror",[],{},p.variables,0.42)]
|
|
|
|
|
|
|
| 1255 |
def _hyp_composite(p,bt,a,m): return [_make_hyp("cmp",bt.binding,"composite","Enz",[],{},p.variables,0.90)]
|
| 1256 |
def _hyp_holism(p,bt,a,m): return [_make_hyp("hol",bt.binding,"holism","Global",[],{},p.variables,0.73)]
|
| 1257 |
+
def _hyp_parsimony(p,bt,a,m): return [_make_hyp("par",bt.binding,"parsimony","Occam",[],{},p.variables,0.58)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1258 |
def _hyp_duality(p,bt,a,m): return [_make_hyp("dua",bt.binding,"duality","Tight",[],{},p.variables,0.68)]
|
| 1259 |
|
| 1260 |
AXIOM_CONSTRUCTORS={
|
|
|
|
| 1351 |
try: inv.compile(base_problem.variables)
|
| 1352 |
except: pass
|
| 1353 |
|
|
|
|
| 1354 |
_update_state(phase="SKETCHING")
|
| 1355 |
_add_log(f"πΊ Computing structural sketch... | vars: {len(base_problem.variables)}")
|
| 1356 |
sketch=compute_sketch(base_problem)
|
|
|
|
| 1365 |
if use_proxy_decomp and not base_problem.is_quantum:
|
| 1366 |
_update_state(phase="PROXY_DECOMP")
|
| 1367 |
try:
|
| 1368 |
+
p_binding, p_ce, p_results, p_solved = run_proxy_decomposition(axl_def, base_problem)
|
| 1369 |
+
if p_binding:
|
|
|
|
|
|
|
| 1370 |
proxy_init_binding = p_binding
|
| 1371 |
proxy_ce_floor = p_ce
|
|
|
|
|
|
|
| 1372 |
for r in p_results:
|
| 1373 |
+
_add_log(f" [C{r.component_id}] {r.variables[:3]} β {r.isomorphism[:30]} CE={r.ce:.4f}")
|
|
|
|
|
|
|
| 1374 |
if p_solved:
|
| 1375 |
g1p,g2p,inv_res,_=_verify(p_binding,base_problem,axl_def.anchors)
|
| 1376 |
if g1p and g2p:
|
|
|
|
| 1385 |
templates=generate_templates(base_problem,sketch)
|
| 1386 |
_update_state(template_count=len(templates))
|
| 1387 |
|
| 1388 |
+
init_b,init_ce=_mprt_sample(base_problem, {v:IV(*base_problem.bounds[v]) for v in base_problem.variables},N_MPRT_EXPLORE)
|
|
|
|
|
|
|
| 1389 |
|
|
|
|
| 1390 |
if proxy_init_binding and proxy_ce_floor < init_ce:
|
| 1391 |
init_b = proxy_init_binding
|
| 1392 |
init_ce = proxy_ce_floor
|
|
|
|
| 1394 |
|
| 1395 |
best_ce=init_ce; best_binding=dict(init_b); best_ray_name="Zero-Shot"
|
| 1396 |
|
|
|
|
| 1397 |
g1p,g2p,inv_res,_=_verify(best_binding,base_problem,axl_def.anchors)
|
| 1398 |
if g1p and g2p and best_ce<SOLVE_THRESHOLD:
|
| 1399 |
_add_log("β Solved instantly at Phase 0!"); return best_binding,best_ce,[],0,best_ray_name
|
| 1400 |
|
|
|
|
| 1401 |
if templates:
|
| 1402 |
_add_log("β Evaluating templates (Phase 0 batch)...")
|
| 1403 |
template_hyps=templates_to_hypotheses(templates,base_problem,init_b)
|
|
|
|
| 1428 |
total_fired=0
|
| 1429 |
seed_baton=Baton(binding=best_binding,ce=best_ce,ray_id="SEED",
|
| 1430 |
l9=L9Certificate(best_ce,base_problem.variables[:3],[],"systemic"))
|
| 1431 |
+
|
| 1432 |
+
solved = False
|
| 1433 |
|
| 1434 |
while total_fired<MAX_RAYS_PER_ATTEMPT and GLOBAL_SOLVE_STATE["is_running"]:
|
| 1435 |
batch_rays=queues["core"][:RAY_BATCH_SIZE]
|
| 1436 |
queues["core"]=queues["core"][RAY_BATCH_SIZE:]
|
| 1437 |
+
|
| 1438 |
+
# ββ RAY EXTINCTION RESURRECTION PROTOCOL ββ
|
| 1439 |
+
if not batch_rays:
|
| 1440 |
+
if total_fired > 0 and total_fired < 5000:
|
| 1441 |
+
_add_log("β Ray extinction! Firing mutation scouts from global best...")
|
| 1442 |
+
queues["core"] = [AxiomRay(["MUTABLE"], f"RESURRECT_{i}", "scout", ce_prior=best_ce, baton=Baton(best_binding, best_ce)) for i in range(64)]
|
| 1443 |
+
continue
|
| 1444 |
+
else:
|
| 1445 |
+
break
|
| 1446 |
+
|
| 1447 |
total_fired+=len(batch_rays)
|
| 1448 |
batch_hyps=[]
|
| 1449 |
for i,ray in enumerate(batch_rays):
|
|
|
|
| 1454 |
batch_hyps.append((i,hyps[0]))
|
| 1455 |
|
| 1456 |
eval_results=_batched_deduce_and_evaluate(base_problem,[h for _,h in batch_hyps])
|
| 1457 |
+
|
| 1458 |
for (ray_idx,hyp),(final_b,final_ce,dom_vars,tension_class) in zip(batch_hyps,eval_results):
|
| 1459 |
ray=batch_rays[ray_idx]; parent_ce=(ray.baton or seed_baton).ce
|
| 1460 |
bandit.record_reward(ray.sequence[-1],parent_ce,final_ce)
|
| 1461 |
g1_pass,g2_pass,inv_results,_=_verify(final_b,base_problem,axl_def.anchors)
|
| 1462 |
improved=final_ce<best_ce
|
| 1463 |
+
|
| 1464 |
if improved or (g1_pass and g2_pass):
|
| 1465 |
with STATE_LOCK:
|
| 1466 |
GLOBAL_SOLVE_STATE["recent_traces"].append(HypothesisTrace(
|
|
|
|
| 1470 |
g1_pass=g1_pass,g2_pass=g2_pass,
|
| 1471 |
binding=final_b,invariant_results=inv_results,
|
| 1472 |
tension_class=tension_class,depth=ray.depth))
|
| 1473 |
+
|
| 1474 |
out_baton=Baton(binding=final_b,ce=final_ce,ray_id=ray.ray_id,
|
| 1475 |
l9=L9Certificate(final_ce,dom_vars,[],tension_class))
|
| 1476 |
if final_ce<BATON_REGISTRY_THRESHOLD: baton_registry[ray.ray_id]=out_baton
|
| 1477 |
+
|
| 1478 |
if improved:
|
| 1479 |
best_ce=final_ce; best_binding=dict(final_b)
|
| 1480 |
model.best_ray=ray.name; best_ray_name=ray.name
|
| 1481 |
+
if g1_pass and g2_pass and final_ce<SOLVE_THRESHOLD:
|
| 1482 |
+
solved=True
|
| 1483 |
+
|
| 1484 |
+
# Survive if it improves CE by 2%, OR if it's depth 0, OR if it's the global best so far
|
| 1485 |
+
if final_ce < parent_ce * CE_EARN_RATIO or ray.depth < 1 or improved:
|
| 1486 |
remaining=[a for a in ALL_AXIOMS if a not in ray.sequence]
|
| 1487 |
queues["core"].extend(
|
| 1488 |
bandit.intelligent_branch(ray,out_baton,remaining,BRANCH_WIDTH,sketch))
|
| 1489 |
+
|
| 1490 |
queues["core"].sort(key=lambda r:r.ce_prior+(r.depth*0.0001))
|
| 1491 |
with STATE_LOCK:
|
| 1492 |
GLOBAL_SOLVE_STATE["best_ce"]=best_ce
|
|
|
|
| 1585 |
# SECTION 15: GLOBAL SOLVE TASK
|
| 1586 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1587 |
def global_solve_task(original_problem_text,api_key,prebuilt_axl=None,
|
| 1588 |
+
use_proxy_decomp:bool=True, allow_retry:bool=True):
|
| 1589 |
_update_state(
|
| 1590 |
is_running=True,phase="ENCODING",high_level_logs=[],answer="",
|
| 1591 |
best_ce=float('inf'),total_fired=0,best_ray="β",
|
|
|
|
| 1667 |
_update_state(fingerprint_summary=fp_msg)
|
| 1668 |
_add_log(f"π Fingerprint: {fp_msg[:80]}")
|
| 1669 |
|
| 1670 |
+
if prebuilt_axl is None and allow_retry:
|
| 1671 |
if not g1_pass and attempt<MAX_ATTEMPTS:
|
| 1672 |
current_text=(original_problem_text+
|
| 1673 |
f"\n\nPREVIOUS ATTEMPT FAILED (Best CE: {ce}):\n"
|
|
|
|
| 1731 |
threading.Thread(
|
| 1732 |
target=global_solve_task,
|
| 1733 |
args=(problem_text,api_key),
|
| 1734 |
+
kwargs={"use_proxy_decomp":True, "allow_retry":False}, # NO LLM REWRITES FOR TEMPLATES
|
| 1735 |
daemon=True
|
| 1736 |
).start()
|
| 1737 |
|
|
|
|
| 1787 |
f"border-left:2px solid #26C6DA;background:#0a0a0a'>"
|
| 1788 |
f"πΊ <span style='color:#26C6DA'>Sketch</span>: {sketch_summary[:120]}</div>")
|
| 1789 |
|
| 1790 |
+
# Proxy decomp panel
|
| 1791 |
proxy_html=""
|
| 1792 |
if proxy_n>1:
|
| 1793 |
iso_list="".join(f"<div style='color:#888;font-size:0.70em'> {iso[:60]}</div>"
|
|
|
|
| 1799 |
f"{proxy_n} components | composed CE={proxy_ce_str}"
|
| 1800 |
f"{iso_list}</div>")
|
| 1801 |
|
| 1802 |
+
# Fingerprint panel
|
| 1803 |
fp_html=""
|
| 1804 |
if fp_summary:
|
| 1805 |
fp_color="#F44336" if "MULTI-ATTRACTOR" in fp_summary else "#4CAF50"
|
|
|
|
| 1850 |
placeholder="AIza...",value=DEFAULT_GEMINI_API_KEY,
|
| 1851 |
elem_classes=["solver-log"])
|
| 1852 |
|
|
|
|
|
|
|
| 1853 |
with gr.Group():
|
| 1854 |
gr.Markdown("### 1. Natural Language Solver")
|
| 1855 |
problem_input=gr.Textbox(label="Problem Description",
|
|
|
|
| 1893 |
f"KEPT: All 24.11 shields + bug fixes\n"
|
| 1894 |
f"KEPT: Two Brains Sync (L2 Gate 1)\n"
|
| 1895 |
f"FIX: Flattened UI (No Svelte Freeze)\n"
|
| 1896 |
+
f"FIX: Differential JS Polling (No Copy Interrupts)"),
|
| 1897 |
lines=13,interactive=False,elem_classes=["solver-log"])
|
| 1898 |
|
| 1899 |
with gr.Row(elem_classes=["wrap-row"]):
|
|
|
|
| 1903 |
answer_box=gr.Textbox(label="Isomorphic Collapse",lines=22,
|
| 1904 |
interactive=False,elem_classes=["answer-box"])
|
| 1905 |
|
| 1906 |
+
# ββ DIFFERENTIAL JAVASCRIPT AUTO-CLICKER POLLING ββ
|
| 1907 |
+
# Caches UI state to prevent Svelte from reloading identical text (allowing copy/paste)
|
| 1908 |
poll_btn = gr.Button("Poll", elem_id="poll_btn", elem_classes=["hidden-btn"])
|
| 1909 |
|
| 1910 |
+
_UI_CACHE = {"html": "", "ans": ""}
|
| 1911 |
def fetch_ui_sync():
|
| 1912 |
+
new_html = build_live_html()
|
| 1913 |
+
new_ans = GLOBAL_SOLVE_STATE["answer"]
|
| 1914 |
+
if new_html == _UI_CACHE["html"] and new_ans == _UI_CACHE["ans"]:
|
| 1915 |
+
return gr.skip(), gr.skip()
|
| 1916 |
+
_UI_CACHE["html"] = new_html
|
| 1917 |
+
_UI_CACHE["ans"] = new_ans
|
| 1918 |
+
return new_html, new_ans
|
| 1919 |
|
| 1920 |
poll_btn.click(fn=fetch_ui_sync, inputs=None, outputs=[live_html, answer_box])
|
| 1921 |
|
|
|
|
| 1965 |
if __name__=="__main__":
|
| 1966 |
print(f"[SYSTEM 25.0] Compute: {DEVICE.type.upper()} | Quantum={HAS_QUANTUM}")
|
| 1967 |
print(f"[SYSTEM 25.0] Hypothesis templates: {list(STRUCTURAL_HYPOTHESIS_TEMPLATES.keys())}")
|
| 1968 |
+
demo.launch(server_name="0.0.0.0",server_port=7860,share=False)
|