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 / sec / s3s4 / unroll-sum-rolled.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note TWIN of unroll-sum.om with every unroll removed (contract section 4 line 91): OM-2 |
| 3 | note unit, same expected stdout. Line numbers are those of unroll-sum.om plus one. |
| 4 | note Contract section 4 lines 87-92: for i T K unroll emits the body K times with i bound to 0..K-1, |
| 5 | note and removing unroll leaves behaviour unchanged (twin unroll-sum-rolled.om, same expectation). |
| 6 | note K = 1 (uint), 4 (uchar), 64 (ulong). Each loop folds i into an order-sensitive accumulator and |
| 7 | note the K = 64 loop also writes a[i] of a 65-element array, so K-1 or K+1 copies, a wrong binding of i |
| 8 | note or a reordering changes the printed lines (a K+1 copy writes a[64], read back below, never out of |
| 9 | note range). Expected stdout: oracle/s3s4/exp/unroll-sum.out (python3, oracle/s3s4/oracle.py). |
| 10 | om2 |
| 11 | fn main to int |
| 12 | h = ulong 7 |
| 13 | for i uint 1 |
| 14 | h = add mul h 1000003 add ulong i 11 |
| 15 | end |
| 16 | pu h |
| 17 | s = ulong 0 |
| 18 | for i uchar 4 |
| 19 | s = add mul s 131 add ulong i 3 |
| 20 | end |
| 21 | pu s |
| 22 | a = new uchar 65 0 |
| 23 | t = ulong 0 |
| 24 | c = ulong 0 |
| 25 | for i ulong 64 |
| 26 | t = add mul t 6364136223846793005 add i 1442695040888963407 |
| 27 | c = add c 1 |
| 28 | put a i uchar and add mul i 37 5 255 |
| 29 | end |
| 30 | pu t |
| 31 | pu c |
| 32 | q = ulong 0 |
| 33 | for k ulong 65 |
| 34 | q = add mul q 257 ulong get a k |
| 35 | end |
| 36 | pu q |
| 37 | ret 0 |
| 38 | end |