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.om

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