Docsity

COSC 3015 HW 17: Unification Algorithm with Product Type - Prof. James L. Caldwell, Assignments of Computer Science

Toggle sidebar
bg1
HW 17 Prof. Caldwell
Due: 11 November 2008 COSC 3015
In class we started to present the unification algorithm. I have provided an implementation and
some tests (in comments at the end.) Your assignment is to extend the code by adding a product
type constructor to the datatype Type and then to extend the rest of the functions to handle this
new type. Note that this include all functions that do pattern matching on the type constructors
for datatype Type.
Recall:
Definition 0.1. Type terms t1and t2are unifiable if there is a substitution σsuch that σt1=σt2.
Thus, a unifier is a substitution that makes the terms equal.
The algorithm is specified as follows:
i.) A variable (say x) unifies with any term (say t) as long as x6∈ FV (t).
ii.) If terms t1and t2are not variables, they unify if they have the same constructor, and if their
subterms unify.
1

Partial preview of the text

Download COSC 3015 HW 17: Unification Algorithm with Product Type - Prof. James L. Caldwell and more Assignments Computer Science in PDF only on Docsity!

HW 17 Prof. Caldwell Due: 11 November 2008 COSC 3015

In class we started to present the unification algorithm. I have provided an implementation and some tests (in comments at the end.) Your assignment is to extend the code by adding a product type constructor to the datatype Type and then to extend the rest of the functions to handle this new type. Note that this include all functions that do pattern matching on the type constructors for datatype Type. Recall:

Definition 0.1. Type terms t 1 and t 2 are unifiable if there is a substitution σ such that σt 1 = σt 2.

Thus, a unifier is a substitution that makes the terms equal. The algorithm is specified as follows:

i.) A variable (say x) unifies with any term (say t) as long as x 6 ∈ F V (t).

ii.) If terms t 1 and t 2 are not variables, they unify if they have the same constructor, and if their subterms unify.