Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
pp:lambda [2019/04/08 09:46]
dmihai
pp:lambda [2019/04/08 21:33] (current)
dmihai [Step 1: reduction] fix examples
Line 7: Line 7:
 ===== Intuition ====== ===== Intuition ======
  
-At first glance, the Lambda Calculus formalises the fundamental concept of //function application//​ from mathematics. Consider the function $math[f(x) = x + 1]. Then $math[f(2)] denotes the **application** of the function $math[f] to argument $math[2]. In order to compute the result, **all occurrences of variable $math[x] are replaced by the parameter**(here $math[1]), in the body of the function. The result is $math[1+1], which is subsequently computed using the laws of arithmetic.+At first glance, the Lambda Calculus formalises the fundamental concept of //function application//​ from mathematics. Consider the function $math[f(x) = x + 1]. Then $math[f(2)] denotes the **application** of the function $math[f] to argument $math[2]. In order to compute the result, **all occurrences of variable $math[x] are replaced by the parameter** (here $math[2]), in the body of the function. The result is $math[2+1], which is subsequently computed using the laws of arithmetic.
  
 At its core, the Lambda Calculus is not (apriori) designed to describe e.g. addition, or other mathematical operators (however, as we shall further see, it is possible to encode numbers and a subset of arithmetic in t At its core, the Lambda Calculus is not (apriori) designed to describe e.g. addition, or other mathematical operators (however, as we shall further see, it is possible to encode numbers and a subset of arithmetic in t
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 - 
 +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 ​
 +ith c1. as before.
  
 To capture this, we replace c1 by: To capture this, we replace c1 by: