Advertisement
Guest User

Untitled

a guest
Sep 5th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. theory Ex31
  2. imports Main
  3. begin
  4. type_synonym vname = string
  5. datatype aexp = N int | V vname | Plus aexp aexp
  6.  
  7. fun optimal :: "aexp ⇒ bool" where
  8. "optimal (N n) = true" |
  9. "optimal (V x) = true" |
  10. "optimal (Plus a1 a2) =
  11. (case (a1,a2) of
  12. (N n1, N n2) ⇒ false |
  13. (b1,b2) ⇒ optimal b1 ∧ optimal b2)"
  14.  
  15.  
  16. fun asimp_const :: "aexp ⇒ aexp" where
  17. "asimp_const (N n) = N n" |
  18. "asimp_const (V x) = V x" |
  19. "asimp_const (Plus a1 a2) =
  20. (case (asimp_const a1, asimp_const a2) of
  21. (N n1, N n2) ⇒ N(n1+n2) |
  22. (b1,b2) ⇒ Plus b1 b2)"
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement