Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
|
pp:lambda [2019/04/08 13:46] georgem [Intuition] |
pp:lambda [2019/04/08 21:33] (current) dmihai [Step 1: reduction] fix examples |
||
|---|---|---|---|
| Line 39: | Line 39: | ||
| * $math[\lambda x.\lambda y.x] (resp. $math[\lambda x.\lambda y.y]) - **selector** functions, which are expected to be called with two parameters (curried), and return the first (resp. second) one. | * $math[\lambda x.\lambda y.x] (resp. $math[\lambda x.\lambda y.y]) - **selector** functions, which are expected to be called with two parameters (curried), and return the first (resp. second) one. | ||
| - | In the Lambda Calculus, the **naming scheme** for the variables is unimportant. For instance, $math[\lambda x.x] and $math[\lambda y.y] stand for the same identity function. Similarly, $math[\lambda x.\lambda x.x] and $math[\lambda x.\lambda y.y] also stand for the same function which, called - returns the identity function. | + | In the Lambda Calculus, the **naming scheme** for the variables is unimportant. For instance, $math[\lambda x.x] and $math[\lambda y.y] stand for the same identity function. Similarly, $math[\lambda x.\lambda x.x] and $math[\lambda x.\lambda y.y] also stand for the same function which, called - r |
| + | eturns the identity function. | ||
| ===== The semantics of the Lambda Calculus ===== | ===== The semantics of the Lambda Calculus ===== | ||
| Line 63: | Line 64: | ||
| Examples: | Examples: | ||
| - | * $ (\lambda x.(x\;y)\;y)[z/x] = (\{\lambda x.(x\;y)\}[z/x]\; y[z/x])=$\\ $ = (\lambda x.(x\;y)[z/x]\;y) = (\lambda x.(x[z/x]\;y[z/x])\;y)=(\lambda x.(z\;x)\;y)$ | + | * $ (\lambda x.(x\;y)\;y)[z/x] = (\{\lambda x.(x\;y)\}[z/x]\; y[z/x])=$\\ $ = (\lambda x.(x\;y)[z/x]\;y) = (\lambda x.(x[z/x]\;y[z/x])\;y)=(\lambda x.(z\;y)\;y)$ |
| * $ \{\lambda x.\lambda x.x\}[z/x] = \lambda x.\lambda x.z $ | * $ \{\lambda x.\lambda x.x\}[z/x] = \lambda x.\lambda x.z $ | ||
| - | The second example from the previous list illustrates a conceptual problem with point c. from our definition. Suppose we would like to reduce: | + | These examples illustrate a conceptual problem with point c. from our definition. Suppose we would like to reduce: |
| $$ (\lambda x.\lambda x.x\; y)$$ | $$ (\lambda x.\lambda x.x\; y)$$ | ||
| Line 126: | Line 127: | ||
| To solve this, we should: | To solve this, we should: | ||
| * rename all $math[y]s in the function body $math[\lambda y.x] by a **new, unused** variable. The result is: $math[ \lambda y.(\lambda x \lambda z.x\;y) $ | * rename all $math[y]s in the function body $math[\lambda y.x] by a **new, unused** variable. The result is: $math[ \lambda y.(\lambda x \lambda z.x\;y) $ | ||
| - | * next, we can proceed with c1. as before. | + | * next, we can proceed w |
| + | ith c1. as before. | ||
| To capture this, we replace c1 by: | To capture this, we replace c1 by: | ||