Example 313 Recall the earlier example If M λx xx then the β reduction of MM

Example 313 recall the earlier example if m λx xx

This preview shows page 4 - 7 out of 8 pages.

Example 3.1.3. Recall the earlier example. If M = ( λx · xx ), then the β -reduction of MM does not terminate. Suppose we have a projection function P = ( λxy · x ), that projects out one of the arguments alone, then we know that the reduction PMM terminates in M . You can use these two observations to construct two reduction sequences for the following expression, one which terminates, and another which does not. ( λxyz · xz ( yz )) PMM. So the answer to even our second question is no. 3.2 Church-Rosser Theorem However, we could ask for a simpler requirement. If two reduction sequences terminate, do they terminate in the same normal form? The following is a classical result in λ -calculus. Theorem 3.2.1. If M * -→ M 1 and M * -→ N 1 , then there exists a P such that M 1 * -→ P and N 1 * -→ P . That is, there is at most one normal form of any λ -term. Of course, some terms may not have normal forms at all, as discussed in the previous subsection. We omit the proof of this theorem. 4
Image of page 4

Subscribe to view the full document.

4 Abstract Data Types We now see how to implement some abstract data types in λ -calculus. 4.1 Numbers One encoding of the numbers we consider is the following. True = 0 λxy.y n = λxy.M = n + 1 λxy.x ( M ) Thus 1 λxy · x ( y ) 2 λxy · x ( x ( y )) 3 λxy · x ( x ( x ( y ))) and so on. One way to think about this encoding is that it is the unary representation of natural numbers. Consider the expression 0 xy = y . This can be thought of as a “blank board”. The expression nxy can be thought of as one obtained by making n number of x marks on the blank board. This notation makes it possible for us to do arithmetic operations. Successor is defined to satisfy Successor(n) = n+1. This can be encoded as the function ( λnxy · x ( nxy )) Verify that Successor( n ) is a representation of n + 1. Addition of two numbers m and n should return m + n . ( λmnxy · mx ( nxy ) ) . Multiplication of two numbers m and n should return their product. ( λmnx · m ( nx )) . 4.2 Booleans Define False to be ( λxy · y ). We denote this by the reserved term F . Note that False has the same representation as 0. True is defined as ( λxy · x ). We denote it consistently by T . Now, it is possible to encode conditional blocks in the λ -calculus. An if block, of the form [ if E is true then M else N] can be encoded as ( λemn · emn ) . Verify that ( λemn · emn ) T = m and ( λemn · emn ) F = n . 5
Image of page 5
4.3 Lists We define the empty list to be nil = ( λxy · y ). Again, this is the same representation as that of 0 and of False. A list is essentially a pair of values. The first is a “head” element of the list. The second element is the “tail” of the list, which is the list without the first element. Cons, the list constructor, is defined as follows. Cons = ( λv‘f · fv‘ ) . For example, Cons a nil = ( λf · f a nil ) Cons b ( Cons a nil ) = ( λf · f b ( Cons a nil )) .
Image of page 6

Subscribe to view the full document.

Image of page 7
  • Fall '19
  • Satyadev Nandakumar

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes