-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcCompiler.pi
More file actions
46 lines (38 loc) · 866 Bytes
/
Copy pathcCompiler.pi
File metadata and controls
46 lines (38 loc) · 866 Bytes
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
module Compile_benchmark where
import Nat
import List
import HList
import Compiler
getResult : ValueStack (Cons N Nil) -> Nat
getResult = \ s . case s of
HCons [_] h [_] _ -> h
runInterpreter : Exp N -> Nat
runInterpreter = \ e . denoteExp [N] e
runCompiler : Exp N -> Nat
runCompiler = \ e . getResult (denoteProgram [Nil] [Cons N Nil] (compile [N] [Nil] e) HNil)
one : Nat
one = Succ Zero
two : Nat
two = Succ one
three : Nat
three = Succ two
four : Nat
four = Succ three
five : Nat
five = Succ four
six : Nat
six = Succ five
eight : Nat
eight = plus two six
nine : Nat
nine = Succ eight
ten : Nat
ten = Succ nine
factorial : Nat -> Exp N
factorial = \ n . case n of
Zero -> NConst Zero
Succ n' -> Binop [N] (NConst n') [N] (factorial n') Times
e : Exp N
e = factorial eight
kickFact : nat_eq (runInterpreter e) (runCompiler e) = True
kickFact = Refl