Graph Reduction - Motivation

Motivation

A simple example of evaluating an arithmetic expression follows:


\begin{align}
& {} \qquad ((2+2)+(2+2))+(3+3) \\
& {} =((2+2)+(2+2))+ 6 \\
& {} =((2+2)+ 4)+6 \\
& {} =(4+4)+6 \\
& {} =8+6 \\
& {} =14
\end{align}

The above reduction sequence employs a strategy known as outermost tree reduction. The same expression can be evaluated using innermost tree reduction, yielding the reduction sequence:


\begin{align}
& {} \qquad ((2+2)+(2+2))+(3+3) \\
& {} = ((2+2)+4)+(3+3) \\
& {} = (4+4)+(3+3) \\
& {} = (4+4)+6 \\
& {} = 8+6 \\
& {} = 14
\end{align}

Notice that the reduction order is made explicit by the addition of parentheses. This expression could also have been simply evaluated right to left, because addition is an associative operation.

Represented as a tree, the expression above looks like this:

This is where the term tree reduction comes from. When represented as a tree, we can think of innermost reduction as working from the bottom up, while outermost works from the top down.

The expression can also be represented as a graph, allowing sub-expressions to be shared:

As for trees, outermost and innermost reduction also applies to graphs. Hence we have graph reduction.

Now evaluation with outermost graph reduction can proceed as follows:

Notice that evaluation now only requires four steps. Outermost graph reduction is referred to as lazy evaluation and innermost graph reduction is referred to as eager evaluation.

Read more about this topic:  Graph Reduction

Famous quotes containing the word motivation:

    Self-determination has to mean that the leader is your individual gut, and heart, and mind or we’re talking about power, again, and its rather well-known impurities. Who is really going to care whether you live or die and who is going to know the most intimate motivation for your laughter and your tears is the only person to be trusted to speak for you and to decide what you will or will not do.
    June Jordan (b. 1939)