next up previous contents
Next: Theorem Up: Reduction strategies Previous: Reduction strategies   Contents

Theorem

The outermost strategy for reduction terminates with a value whenever the innermost strategy does.


The example of power shows that there are expressions where the innermost strategy does not terminate with a value while the outermost strategy does. We should not assume that ``values'' are always sensible. It is debatable, mathematically, whether power (7.0/0) 0 should evaluate to 1. All we are discussing is the relative power of the two reduction strategies.

The reduction we saw for square (4+3) suggests that outermost reduction involves wasteful recomputation--in this case, (4+3) is evaluated twice. In fact, Haskell uses an optimization of outermost reduction called graph reduction. Graph reduction maintains only one copy of each unreduced expression and a pointer to this copy from each occurrence in the main expression. Thus, if the same subexpression occurs multiple times in an expression, the expression will have multiple pointers to the location containing the subexpression. The first time this subexpression is encountered, it will be reduced. Whenever the subexpression is encountered subsequently, the pointer will reveal that it has already been reduced.


next up previous contents
Next: Theorem Up: Reduction strategies Previous: Reduction strategies   Contents
Madhavan Mukund 2004-04-29