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 / sec / s3s4 / fold-guard-rolled.om

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