0% found this document useful (0 votes)
4 views

unif-rules

The unification algorithm resolves a set of type pairs that are expected to be equal by applying a series of transformations to find a substitution that satisfies the constraints. It includes rules for handling empty sets, equal pairs, variable orientation, decomposition of type constructors, and variable substitution. If none of the rules apply, the algorithm indicates a unification error.

Uploaded by

Helen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

unif-rules

The unification algorithm resolves a set of type pairs that are expected to be equal by applying a series of transformations to find a substitution that satisfies the constraints. It includes rules for handling empty sets, equal pairs, variable orientation, decomposition of type constructors, and variable substitution. If none of the rules apply, the algorithm indicates a unification error.

Uploaded by

Helen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

6 Unification

The unification algorithm takes a set of pairs of types that are supposed to be equal. A system of constraints looks like
the following set
{(s1 , t1 ), (s2 , t2 ), ..., (sn , tn )}
Each pair is called an equation. A (lifted) substitution solves an equation (s, t) if (s) = (t). It solves a constraint
set if (si ) = (ti ) for every (si , ti ) in the constraint set. The unification algorithm will return a substitution that
solves the given constraint set (if a solution exists).
You will remember from lecture that the unification algorithm consists of four transformations. These transforma-
tions can be expressed in terms of how an action on the first element of the unification problem affects the remaining
elements.
Given a constraint set C

1. If C is empty, return the identity substitution.


2. If C is not empty, pick an equation (s, t) 2 C. Let C 0 be C \ {(s, t)}.

(a) Delete rule: If s and t are are equal, discard the pair, and unify C 0 .
(b) Orient rule: If t is a variable, and s is not, then discard (s, t), and unify {(t, s)} [ C 0 .
(c) Decompose rule: If s = TyConst(name,
Sn [s1 ; . . . ; sn ]) and t = TyConst(name, [t1 ; . . . ; tn ]), then
discard (s, t), and unify C 0 [ i=1 {(si , ti )}.
(d) Eliminate rule: If s is a variable, and s does not occur in t, substitute s with t in C 0 to get C 00 . Let be
the substitution resulting from unifying C 00 . Return updated with s 7! (t).
(e) If none of the above cases apply, it is a unification error (your unify function should return the None
option in this case).

In our system, function, integer, list, etc. types are the terms; TyVars are the variables.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy