summaryrefslogtreecommitdiff
path: root/test/c/custom_flow.sail
blob: 43c980d6bff72ea4598e9abd87fabe3ebb1810c0 (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
val "print_endline" : string -> unit

val operator <= = {
  coq: "Z.leb",
  _: "lteq"
} : forall 'n 'm. (int('n), int('m)) -> bool('n <= 'm)

function test1 forall 'n 'm. (n: int('n), m: int('m)) -> unit = {
  if n <= m then {
    _prove(constraint('n <= 'm));
    print_endline("1");
  } else {
    print_endline("2");
    _prove(constraint('n > 'm));
  }
}

val and_bool = {
  coq: "andb",
  _: "and_bool"
} : forall ('p: Bool) ('q: Bool). (bool('p), bool('q)) -> bool('p & 'q)

overload operator & = {and_bool}

function test2 forall 'n 'm. (n: int('n), m: int('m)) -> unit = {
  let x = n <= m & n <= 20;
  if x then {
    _prove(constraint('n <= 20));
    _prove(constraint('n <= 'm));
    print_endline("3")
  } else {
    _prove(constraint('n > 'm | 'n > 20));
    print_endline("4")
  }
}

function main((): unit) -> unit = {
  test1(1, 2);
  test1(2, 1);
  test2(1, 2);
  test2(2, 1);
  test2(21, 0)
}