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 / ce-view.om

68 lines · 1883 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note Contract section 4 lines 105-108 and section 6 line 170, errata E2: every index into an UNSIZED view
3note keeps its run-time check (trap 3), also when it is a constant after unrolling or inlining. b holds
4note 1 10 100 ... 10^7; the callee sees a part of b (or the 4-element a4 = b[0..4), E2) and reads one
5note element past its length, which in b is a defined neighbour: a compiler that drops the check prints
6note it and exits 0 instead of trapping. One stdin byte selects:
7note A sumv part b 0 4 (unrolled 5 reads): 1 11 111 1111, trap 3 exit 103
8note B sumv a4 (sized array to view ulong *, E2): 1 11 111 1111, trap 3 exit 103
9note C sumi part b 0 4 (sumv inlined): 1 11 111 1111, trap 3 exit 103
10note D getc part b 0 4 (constant get v 6, no unroll): trap 3 exit 103
11note E sumv part b 0 5 (in range): 1 11 111 1111 11111, then 11111 exit 0
12note F sumv part b 3 4: 1000 11000 111000 1111000, trap 3 exit 103
13note Twin ce-view-plain.om (unroll and inline removed) has the same expectations; OM-1 approximation
14note ce-view-om1.om uses sized views. Expected: oracle/s3s4/exp/ce-view-*.out (python3).
15om2
16fn sumv v view ulong * to ulong
17s = ulong 0
18for i ulong 5 unroll
19s = add s get v i
20pu s
21end
22ret s
23end
24fn sumi v view ulong * to ulong inline
25s = ulong 0
26for i ulong 5 unroll
27s = add s get v i
28pu s
29end
30ret s
31end
32fn getc v view ulong * to ulong
33ret get v 6
34end
35fn main to int
36sb = new uchar 1 0
37r = read 0 sb 0 1
38k = get sb 0
39b = new ulong 8 0
40a4 = new ulong 4 0
41p = ulong 1
42for j ulong 8
43put b j p
44p = mul p 10
45end
46for j ulong 4
47put a4 j get b j
48end
49if eq k 65
50pu sumv part b 0 4
51end
52if eq k 66
53pu sumv a4
54end
55if eq k 67
56pu sumi part b 0 4
57end
58if eq k 68
59pu getc part b 0 4
60end
61if eq k 69
62pu sumv part b 0 5
63end
64if eq k 70
65pu sumv part b 3 4
66end
67ret 0
68end