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 / seed / qualification / om2 / fixtures / oracle / obligations.py

35 lines · 1815 bytes Raw Blame History
1# EXTERNAL ORACLE RECIPE (outside the delivered closure).
2# python3 obligations.py xs x inputs for obligations.bc: 0, 1, 2^31, 2^32-1, then
3# eight seeded values (splitmix64 seed 748, high 32 bits)
4# python3 obligations.py check FILE recompute FILE (bc output) independently; PASS or assert
5import sys
6M64 = (1 << 64) - 1
7def splitmix(seed, count):
8 s, out = seed, []
9 for _ in range(count):
10 s = (s + 0x9E3779B97F4A7C15) & M64
11 z = s
12 z = ((z ^ (z >> 30)) * 0xBF58476D1CE4E5B9) & M64
13 z = ((z ^ (z >> 27)) * 0x94D049BB133111EB) & M64
14 out.append(z ^ (z >> 31))
15 return out
16XS = [0, 1, 1 << 31, (1 << 32) - 1] + [z >> 32 for z in splitmix(748, 8)]
17M = M64
18SL = [(M, M - 1, 4), (M, M - 1, 1), (M, M - 1, 2), (M, M, 0), (M, M, 1), (10, 11, 0), (10, M, 2),
19 (10, 3, 0), (0, 0, 0), (0, 0, 1), (10, 10, 0), (10, 10, 1), (10, 3, 7), (10, 3, 8),
20 (4096, 4095, 1), (4096, 4095, 2)]
21if sys.argv[1] == "xs":
22 print("\n".join(str(x) for x in XS + [-1]))
23 sys.exit(0)
24rows = [l.split() for l in open(sys.argv[2])]
25dup = [list(map(int, r[1:])) for r in rows if r[0] == "dup32"]
26sl = [list(map(int, r[1:])) for r in rows if r[0] == "slice"]
27assert [r[0] for r in dup] == XS and len(sl) == len(SL)
28for x, d, lo, hi, ok in dup:
29 assert d == ((1 << 32) + 1) * x and d <= M64 and lo == d & 0xFFFFFFFF and hi == d >> 32
30 assert lo == x and hi == x and ok == 1
31for (n, o, k, w, e), (n2, o2, k2) in zip(sl, SL):
32 assert (n, o, k) == (n2, o2, k2)
33 assert w == int(((o + k) & M64) <= n) and e == int(o <= n and k <= n - o)
34assert sl[0][3:] == [1, 0], "issue #748 witness: wrapped (o+k) <= n TRUE, k <= n-o FALSE"
35print("PASS %d dup32 rows, %d slice rows; issue witness wrapped=1 exact=0" % (len(dup), len(sl)))