interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / train / omega-llm / tools / combined / experiment / test_rewrites.py

31 lines · 1246 bytes Raw Blame History
1"""Exercise both emitted programs and reject a contradictory inactive tail."""
2from pathlib import Path
3import sys
4import tempfile
5
6import fixture
7from engines import Engines
8
9
10def main(kit):
11 for family,mask in (("adjacent-add",1),("anchor-add",2)):
12 task=next(t for t in fixture.tasks("dev") if t["family"]==family and t["k"]==3)
13 inputs=[(n,*a) for n in (0,1,4,8) for a in
14 [(7,7,2,2,9,1,3,3),((1<<64)-1,1,0,2,1,7,5,8)]]
15 rows=[(x,fixture.ref(task,x)) for x in inputs]
16 with tempfile.TemporaryDirectory() as d:
17 eng=Engines(kit,d,task["prompt"])
18 def generate(cases):
19 spec=eng.examples_spec(cases)+f"rewrites {mask}\n".encode()
20 return eng.symbolic("om_sketch",spec)
21 body=generate(rows)
22 assert body and eng.predict(body,inputs)==[y for _,y in rows]
23 invalid=rows.copy()
24 x,y=invalid[0]
25 invalid[0]=(x,(*y[:-1],y[-1]^1))
26 assert generate(invalid) is None, "an empty active prefix cannot change the tail"
27 print("PASS both emitted rewrites on empty, partial, repeated, wrapping and full vectors; changed tail rejected")
28
29
30if __name__=="__main__":
31 main(Path(sys.argv[1]))