File: custom_flow.sail

package info (click to toggle)
sail-ocaml 0.19.1%2Bdfsg5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,008 kB
  • sloc: ml: 75,941; ansic: 8,848; python: 1,342; exp: 560; sh: 474; makefile: 218; cpp: 36
file content (46 lines) | stat: -rw-r--r-- 973 bytes parent folder | download
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
$[sv_module { stdout = true }]
val "print_endline" : string -> unit

val operator <= = {
  coq: "Z.leb",
  lean: "LE.le",
  _: "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",
  lean: "and",
  _: "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)
}