Normalization


Normalization

Three kinds of rules that we can use for the simplification process


Expressivity of Normalization Rules

Example

Consider the program:

type letters = a | b | c.

pred on: letters * letters.
     on (a, b).
     on (b, c).

pred above: letters * letters.
     above (X, Y) :- on (X, Y).
     above (X, Y) :- above (X, Z), on (Z, Y).

solve above (a, a).
     ... infinite loop ...

solve above (a, c).
     ... infinite loop ...

With normalization we can reach a result:

pred on: letters * letters.
     on (a, b).
     on (b, c).

pred above: letters * letters.
     above (X, Y) :- on (X, Y).
     above (X, Y) :- above (X, Z), on (Z, Y).

norm ~ above (X, X).
norm ~ above (X, Y) :- above (Y, X).

solve above (a, a).
>     false.

solve above (a, c).
>     false.

The technique of normalization is also useful to handle equations between constructors, that cannot be handled by pure narrowing. The next example defined the function less-than-or-equal-to over integer numbers with a predecessor constructor:

type nat = 0 | succ nat | pre nat.

fun leq : nat -> nat -> bool.
    leq 0 0.
  ~ leq 0 (pre 0).
    leq 0 (succ X) :- leq 0 X.
  ~ leq 0 (pre X) :- ~ leq 0 X.
    leq (succ X) Y = leq X (pre Y).
    leq (pre X) Y = leq X (succ Y).

norm succ (pre X) = X.
norm pre (succ X) = X.


Normalization - Implementation -

Narrowing strategy

Translation to PROLOG

Normalization was present in the SLOG interpreter Fribourg 84, 85

Abstract Machine Implementation

WAM extension: A-WAM for the ALF language
A preprocessor transforms programs into two groups of conditional equations, for narrowing steps and rewriting steps, respectively.
The abstract machine performs: Rewriting is supported by a separate mechanism.
The combination of normalization into PROLOG has been studied in Fribourg, Cheong 91, but it is more difficult because the functional structure is not known.

Go to index