Let us consider an arithmetic expression described by a tree constructed from tuples as follows:
1. An integer is described by a tuple int(N), where N is an integer.
2. An addition is described by a tuple add(X Y), where both X and Y are arithmetic expressions. 3. A multiplication is described by a tuple mul(X Y), where both X and Y are arithmetic
expressions.
4. A variable is described by a tuple var(A), where A is an atom giving the variable name.
An environment is a record with a label env and for each variable name there is a feature which corresponds to an integer value. For example, the record env(a:2 b:4) says that the variable "a" has value 2, whereas the variable "b" has value 4 (note that the Oz features should start with a lower- case letter). For example, add(var(a) mul(int(3) var(b))) is an arithmetic expression containing two variables (namely a and b) and its evaluation returns 14.
Give a specification and an Oz implementation of a function Eval that takes as arguments an arithmetic expression and an environment, and returns its value. For example, the call
{Eval add(var(a) mul(int(3) var(b))) env(a:2 b:4)} should return 14.