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
omega-mv / seed / qualification / om2 / fixtures / oracle / obligations.py
| 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 |
| 5 | import sys |
| 6 | M64 = (1 << 64) - 1 |
| 7 | def 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 |
| 16 | XS = [0, 1, 1 << 31, (1 << 32) - 1] + [z >> 32 for z in splitmix(748, 8)] |
| 17 | M = M64 |
| 18 | SL = [(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)] |
| 21 | if sys.argv[1] == "xs": |
| 22 | print("\n".join(str(x) for x in XS + [-1])) |
| 23 | sys.exit(0) |
| 24 | rows = [l.split() for l in open(sys.argv[2])] |
| 25 | dup = [list(map(int, r[1:])) for r in rows if r[0] == "dup32"] |
| 26 | sl = [list(map(int, r[1:])) for r in rows if r[0] == "slice"] |
| 27 | assert [r[0] for r in dup] == XS and len(sl) == len(SL) |
| 28 | for 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 |
| 31 | for (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) |
| 34 | assert sl[0][3:] == [1, 0], "issue #748 witness: wrapped (o+k) <= n TRUE, k <= n-o FALSE" |
| 35 | print("PASS %d dup32 rows, %d slice rows; issue witness wrapped=1 exact=0" % (len(dup), len(sl))) |