Question: We represent non-negative integers with the following Lambda expressions: Suppose you have defined the function if and the operations add, pred and isZero. Consider the

We represent non-negative integers with the following Lambda expressions: Suppose you have defined the function if and the operations add, pred and isZero. Consider the follow- ing recursive (and hence not valid) definition for the multiplication times-ni . ??2 . ?f (?sZero ni ) 0 (add n2 (times (pred n1) n2)) If we abstract the name times, we get the new expression: t-M . Anl . ??2 . if (isZero ni ) 0 (add n2 (f (pred n1) n2)) By the FP theorem we know that (Y t) is a non-recursive equivalent of the above times definition. The exercise: write down the reduction sequence to demonstrate that We represent non-negative integers with the following Lambda expressions: Suppose you have defined the function if and the operations add, pred and isZero. Consider the follow- ing recursive (and hence not valid) definition for the multiplication times-ni . ??2 . ?f (?sZero ni ) 0 (add n2 (times (pred n1) n2)) If we abstract the name times, we get the new expression: t-M . Anl . ??2 . if (isZero ni ) 0 (add n2 (f (pred n1) n2)) By the FP theorem we know that (Y t) is a non-recursive equivalent of the above times definition. The exercise: write down the reduction sequence to demonstrate that
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
