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 / fold-guard.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note Contract section 4 lines 102-104: inside unrolled or inlined bodies only, all-constant operations |
| 3 | note fold with OM-1 arithmetic; an operation that would trap is not folded, so a guarded |
| 4 | note if ne i 0 / div 100 i compiles and behaves as before (no compile error at the i = 0 copy). |
| 5 | note Lines: unsigned div, unsigned rem, signed long div under the guard, and an inlined guard q. |
| 6 | note Twin fold-guard-rolled.om (unroll and inline removed) has the same expected stdout: |
| 7 | note oracle/s3s4/exp/fold-guard.out (python3, oracle/s3s4/oracle.py). |
| 8 | om2 |
| 9 | fn q a ulong b ulong to ulong inline |
| 10 | if eq b 0 |
| 11 | ret 0 |
| 12 | end |
| 13 | ret div a b |
| 14 | end |
| 15 | fn main to int |
| 16 | s = ulong 0 |
| 17 | for i ulong 4 unroll |
| 18 | if ne i 0 |
| 19 | s = add s div 100 i |
| 20 | end |
| 21 | end |
| 22 | pu s |
| 23 | r = ulong 0 |
| 24 | for i ulong 4 unroll |
| 25 | if ne i 0 |
| 26 | r = add r rem 101 i |
| 27 | end |
| 28 | end |
| 29 | pu r |
| 30 | t = long 0 |
| 31 | for i long 4 unroll |
| 32 | if ne i 0 |
| 33 | t = add t div 1000000 i |
| 34 | end |
| 35 | end |
| 36 | pu ulong t |
| 37 | pu q 100 0 |
| 38 | pu q 100 7 |
| 39 | ret 0 |
| 40 | end |