aboutsummaryrefslogtreecommitdiffstats
path: root/research/experiments/045-proof-compiler/units
diff options
context:
space:
mode:
Diffstat (limited to 'research/experiments/045-proof-compiler/units')
-rw-r--r--research/experiments/045-proof-compiler/units/append.aup7
-rw-r--r--research/experiments/045-proof-compiler/units/arith.aup7
-rw-r--r--research/experiments/045-proof-compiler/units/call.aup11
-rw-r--r--research/experiments/045-proof-compiler/units/mod.aup7
-rw-r--r--research/experiments/045-proof-compiler/units/read-direct.aup14
-rw-r--r--research/experiments/045-proof-compiler/units/read.aup14
6 files changed, 60 insertions, 0 deletions
diff --git a/research/experiments/045-proof-compiler/units/append.aup b/research/experiments/045-proof-compiler/units/append.aup
new file mode 100644
index 0000000..def7fa5
--- /dev/null
+++ b/research/experiments/045-proof-compiler/units/append.aup
@@ -0,0 +1,7 @@
+state t = 0
+input go = message { n: u32 }
+on go {
+ let xs: list of number
+ for i in 0 .. go.n { xs.append(i) }
+ t = xs.count
+}
diff --git a/research/experiments/045-proof-compiler/units/arith.aup b/research/experiments/045-proof-compiler/units/arith.aup
new file mode 100644
index 0000000..76f48dc
--- /dev/null
+++ b/research/experiments/045-proof-compiler/units/arith.aup
@@ -0,0 +1,7 @@
+state t = 0
+input go = message { n: u32 }
+on go {
+ let s = 0
+ for i in 0 .. go.n { s = s + i * 2 }
+ t = s
+}
diff --git a/research/experiments/045-proof-compiler/units/call.aup b/research/experiments/045-proof-compiler/units/call.aup
new file mode 100644
index 0000000..ef31ef6
--- /dev/null
+++ b/research/experiments/045-proof-compiler/units/call.aup
@@ -0,0 +1,11 @@
+state t = 0
+input go = message { n: u32 }
+fn f(x) {
+ if x > 1000000 { return 0 }
+ return x + 1
+}
+on go {
+ let s = 0
+ for i in 0 .. go.n { s = s + f(i) }
+ t = s
+}
diff --git a/research/experiments/045-proof-compiler/units/mod.aup b/research/experiments/045-proof-compiler/units/mod.aup
new file mode 100644
index 0000000..dfb0f98
--- /dev/null
+++ b/research/experiments/045-proof-compiler/units/mod.aup
@@ -0,0 +1,7 @@
+state t = 0
+input go = message { n: u32 }
+on go {
+ let s = 0
+ for i in 0 .. go.n { s = s + i % 1000 }
+ t = s
+}
diff --git a/research/experiments/045-proof-compiler/units/read-direct.aup b/research/experiments/045-proof-compiler/units/read-direct.aup
new file mode 100644
index 0000000..8609a5e
--- /dev/null
+++ b/research/experiments/045-proof-compiler/units/read-direct.aup
@@ -0,0 +1,14 @@
+record R {
+ start = 0
+}
+state ranges: list of R
+state t = 0
+input go = message { n: u32 }
+on go {
+ if ranges.count == 0 {
+ for i in 0 .. 1000 { ranges.append(R { start: i }) }
+ }
+ let s = 0
+ for i in 0 .. go.n { s = s + ranges[i].start }
+ t = s
+}
diff --git a/research/experiments/045-proof-compiler/units/read.aup b/research/experiments/045-proof-compiler/units/read.aup
new file mode 100644
index 0000000..34828e7
--- /dev/null
+++ b/research/experiments/045-proof-compiler/units/read.aup
@@ -0,0 +1,14 @@
+record R {
+ start = 0
+}
+state ranges: list of R
+state t = 0
+input go = message { n: u32 }
+on go {
+ if ranges.count == 0 {
+ for i in 0 .. 1000 { ranges.append(R { start: i }) }
+ }
+ let s = 0
+ for i in 0 .. go.n { s = s + ranges[i % 1000].start }
+ t = s
+}