Lab 15
Here’s a simple language of numbers and booleans:
<exp> = <num> |
| true |
| false |
| <exp> + <exp> |
| <exp> ^ <exp> |
Here’s a simple set of types for this program:
<ty> = bool |
| num |
Here are some type inference rules:
|
---------- |
|- n : num |
|
|
|- M : num |- N : num |
---------------------- |
|- M + N : num |
|
|
--------------- |
|- false : bool |
|
|
-------------- |
|- true : bool |
|
|
|- M : bool |- N : bool |
------------------------ |
|- M ^ N : bool |
Develop a define-type for programs.
Develop a define-type for types.
Develop the program type-check, that accepts a program and returns its type (if it’s well-typed) or signals an exception (if it’s not).