Advertisement
Guest User

Untitled

a guest
Aug 14th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Inductive op :=
  2.   | Add
  3.  
  4. Inductive expr :=
  5.   | Const int
  6.   | BinOP op expr expr
  7.  
  8. eval : expr -> int
  9. eval Const(i)         := i
  10. eval BinOp(Add,e1,e2) := eval e1 + eval e2
  11.  
  12.  
  13. compile Const(i)         := gen.Const(i)
  14. compile BinOp(Add,e1,e2) := compile e1; compile e2; compile.Add
  15.  
  16.  
  17. check Const(i)         := true
  18. check BinOp(Add,e1,e2) := check e1 && check e2
  19.  
  20.  
  21. main :=
  22.   let p := (BinOp(Add, BinOp(Add, Const 5, Const 3), Const 2) in
  23.   check p
  24.   eval p
  25.   compile p
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement