Ophi Arc Eval Engine· python
import json, hashlib, numpy as np
from datetime import datetime
# === Core Ω Equation ===
def omega(state, bias, alpha):
return (state + bias) * alpha
# === Drift Metrics ===
def coherence(values):
μ, σ = np.mean(values), np.std(values)
return max(0, 1 - σ / μ) if μ != 0 else 0
def entropy(values):
hist, _ = np.histogram(values, bins=10, density=True)
hist = hist[hist > 0]
return -np.sum(hist * np.log(hist)) / np.log(len(hist)) if len(hist) > 0 else 0
def se44_pass(C, S):
return C >= 0.985 and S <= 0.01
# === ARC Task Processor ===
def process_arc_task(task):
results = []
for case in task["test"]:
state = case.get("state", 0.4)
bias = case.get("bias", 0.3)
alpha = case.get("alpha", 1.1)
predicted_output = omega(state, bias, alpha)
# Flatten expected output for metric calculations
expected_flat = np.array(case["expected"]).flatten()
pred_array = np.full_like(expected_flat, predicted_output)
C = coherence(pred_array)
S = entropy(pred_array)
passed_se = se44_pass(C, S)
correct = np.all(pred_array == expected_flat)
results.append({
"input": case["input"],
"expected": case["expected"],
"predicted": predicted_output,
"omega_mean": float(np.mean(pred_array)),
"C": round(C, 6),
"S": round(S, 6),
"passed_se44": passed_se,
"correct": correct,
"timestamp": datetime.utcnow().isoformat()
})
return results
# === Sample ARC-Ω Task ===
arc_task = {
"meta": {
"benchmark": "ARC-Ω",
"version": "1.0",
"description": "SE44-gated ARC proof task",
"C_min": 0.985,
"S_max": 0.01,
"timestamp": "2025-10-22T04:00:00Z"
},
"test": [
{"input": [[0,0],[0,8]], "expected": [[8,8],[8,8]], "state": 0.46, "bias": 0.35, "alpha": 1.12},
{"input": [[2,0],[0,0]], "expected": [[2,2],[2,2]], "state": 0.42, "bias": 0.30, "alpha": 1.12},
{"input": [[3,0],[0,0]], "expected": [[3,3],[3,3]], "state": 0.43, "bias": 0.29, "alpha": 1.12}
]
}
# === Run the Evaluator ===
if __name__ == "__main__":
eval_results = process_arc_task(arc_task)
for res in eval_results:
print(json.dumps(res, indent=2))
Comments
Post a Comment