summaryrefslogtreecommitdiff
path: root/tests/lean/Constants.lean
blob: bd3a07b7088991abea734623419267d65f792c69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [constants]
import Base
open Primitives

namespace constants

/- [constants::X0] -/
def x0_body : Result U32 := Result.ret 0#u32
def x0_c : U32 := eval_global x0_body (by simp)

/- [constants::X1] -/
def x1_body : Result U32 := Result.ret core_u32_max
def x1_c : U32 := eval_global x1_body (by simp)

/- [constants::X2] -/
def x2_body : Result U32 := Result.ret 3#u32
def x2_c : U32 := eval_global x2_body (by simp)

/- [constants::incr]: forward function -/
def incr (n : U32) : Result U32 :=
  n + 1#u32

/- [constants::X3] -/
def x3_body : Result U32 := incr 32#u32
def x3_c : U32 := eval_global x3_body (by simp)

/- [constants::mk_pair0]: forward function -/
def mk_pair0 (x : U32) (y : U32) : Result (U32 × U32) :=
  Result.ret (x, y)

/- [constants::Pair] -/
structure Pair (T1 T2 : Type) where
  x : T1
  y : T2

/- [constants::mk_pair1]: forward function -/
def mk_pair1 (x : U32) (y : U32) : Result (Pair U32 U32) :=
  Result.ret { x := x, y := y }

/- [constants::P0] -/
def p0_body : Result (U32 × U32) := mk_pair0 0#u32 1#u32
def p0_c : (U32 × U32) := eval_global p0_body (by simp)

/- [constants::P1] -/
def p1_body : Result (Pair U32 U32) := mk_pair1 0#u32 1#u32
def p1_c : Pair U32 U32 := eval_global p1_body (by simp)

/- [constants::P2] -/
def p2_body : Result (U32 × U32) := Result.ret (0#u32, 1#u32)
def p2_c : (U32 × U32) := eval_global p2_body (by simp)

/- [constants::P3] -/
def p3_body : Result (Pair U32 U32) := Result.ret { x := 0#u32, y := 1#u32 }
def p3_c : Pair U32 U32 := eval_global p3_body (by simp)

/- [constants::Wrap] -/
structure Wrap (T : Type) where
  value : T

/- [constants::Wrap::{0}::new]: forward function -/
def Wrap.new (T : Type) (value : T) : Result (Wrap T) :=
  Result.ret { value := value }

/- [constants::Y] -/
def y_body : Result (Wrap I32) := Wrap.new I32 2#i32
def y_c : Wrap I32 := eval_global y_body (by simp)

/- [constants::unwrap_y]: forward function -/
def unwrap_y : Result I32 :=
  Result.ret y_c.value

/- [constants::YVAL] -/
def yval_body : Result I32 := unwrap_y
def yval_c : I32 := eval_global yval_body (by simp)

/- [constants::get_z1::Z1] -/
def get_z1_z1_body : Result I32 := Result.ret 3#i32
def get_z1_z1_c : I32 := eval_global get_z1_z1_body (by simp)

/- [constants::get_z1]: forward function -/
def get_z1 : Result I32 :=
  Result.ret get_z1_z1_c

/- [constants::add]: forward function -/
def add (a : I32) (b : I32) : Result I32 :=
  a + b

/- [constants::Q1] -/
def q1_body : Result I32 := Result.ret 5#i32
def q1_c : I32 := eval_global q1_body (by simp)

/- [constants::Q2] -/
def q2_body : Result I32 := Result.ret q1_c
def q2_c : I32 := eval_global q2_body (by simp)

/- [constants::Q3] -/
def q3_body : Result I32 := add q2_c 3#i32
def q3_c : I32 := eval_global q3_body (by simp)

/- [constants::get_z2]: forward function -/
def get_z2 : Result I32 :=
  do
    let i  get_z1
    let i0  add i q3_c
    add q1_c i0

/- [constants::S1] -/
def s1_body : Result U32 := Result.ret 6#u32
def s1_c : U32 := eval_global s1_body (by simp)

/- [constants::S2] -/
def s2_body : Result U32 := incr s1_c
def s2_c : U32 := eval_global s2_body (by simp)

/- [constants::S3] -/
def s3_body : Result (Pair U32 U32) := Result.ret p3_c
def s3_c : Pair U32 U32 := eval_global s3_body (by simp)

/- [constants::S4] -/
def s4_body : Result (Pair U32 U32) := mk_pair1 7#u32 8#u32
def s4_c : Pair U32 U32 := eval_global s4_body (by simp)

end constants