Reduction is a term from the lambda calculus which involves a semantics-preserving transformation that replaces one term with an equivalent term. For the examples you've given, the most important kind of reductions are
- Replacement of a name by its definition (an instance of substituting equals for equals).
- Beta-reduction of a function application.
Beta-reduction is the fundamental rule in the lambda calculus, and in a pure, lazy language like Haskell, it always preserves semantics. The beta rule is the one that says:
(\x. e) m
can be replaced by e
with m
substituted for x
. (The substitution must avoid "capturing" free instances of x
in m
.)
It's quite possible that your instructor wants you to combine reductions as follows:
- Find a function application where the function being applied is a name.
- Replace the name with its definition, which will be a lambda abstraction.
- Beta-reduce the application.
- Do this all in one step.
Notice you often have a choice about which application to reduce; for example, in the term you give, there are two applications of square
and one of fst
that could be reduced in this fashion. (The application of + can also be reduced, but reduction involving constants requires different rules.)
From the questions I see that your instructor wants you to reduce each term repeatedly until it reaches a normal form and that your instructor wants you to demonstrate your understanding of different reduction strategies. The word "source" in "source reduce" is superfluous; reduction means manipulation of source terms in some language. I would have phrased the questions as follows:
Using the reduction strategy that corresponds to Haskell's lazy evaluation, reduce the following expression to weak head normal form. Show each step in the sequence of reductions.
Using the reduction strategy that corresponds to evaluation in a strict functional language, reduce the following expression to head normal form.
I probably would have chosen to be less coy and just name the reduction strategies: a call-by-need reduction strategy and a call-by-value reduction strategy.