0

I'm working my way through an introduction to lambda calculus, and it seems to start from the premise that TRUE and FALSE (as well as everything else) can be encoded as functions. From this, they define these two functions as:

\begin{align} T & = \lambda a b.a\\ F & = \lambda a b.b \end{align}

Now, I'm not a genius, but it seems like this looks less like 'booleans' and more like 'first' and 'second' (or left and right, if looking at the equation).

Is this just an agreed-upon convention or how is that allowed? For example, what if I had a function that passed the value of 0 or False (or low-voltage or whatever represents zero in the physical world), some examples being:

\begin{align} & False=0 \\ & True=1 \\ & T(False)(False) \\ & T(0)(0) \\ & T(50)(12) \end{align}

Or even passing more than two values to the function, how could one tell where it is True or False?

$$T(2)(3)(4)(5)(6)(7)$$

Maybe I'm missing the boat, but basically I'm curious why what seems to me like such an arbitrary definition of booleans would be allowed in lambda calculus, other than as a convenience where nothing else exists.

David542
  • 221
  • 3
    It is just a convention. – copper.hat May 17 '21 at 21:23
  • Your example is far from clear as the usual representation of numerals like $0$ and $1$ are not the same as the representation of true and false. – Rob Arthan May 17 '21 at 21:24
  • 2
    I would say this is more than just a convention (although other conventions are possible). The canonical use of true and false in a functional programming language is in if-then-else expressions. The standard definitions of true and false that you cite give if-then-else expressions a very simple and natural semantics: "if $c$ then $x$ else $y$" just means $c,x,y$. – Rob Arthan May 17 '21 at 21:27
  • @RobArthan I see, so basically it's a "boolean-for-conditional" definition, if that makes sense? – David542 May 17 '21 at 21:30
  • 1
    Yes that makes some kind of sense.The representations of the logical operators follow from this line of thinking: something that I don't think is made clear in the answers to the relevant question that @JohnDouma has pointed you to. – Rob Arthan May 17 '21 at 21:35
  • This could be seen as a special case of a general way to encode so-called "algebraic data types" (as used commonly in languages such as OCaml and Haskell) into lambda calculus: for example, for the list type, cons x (cons y nil) gets encoded as $\lambda a b.a~x~(a~y~b)$; for the natural type (in unary) with constructors S (successor) and O (zero), $3 = S (S (S O))$ gets encoded as $\lambda a b.a~(a~(a b))$; for the option or Maybe type with constructors Some and None, Some x gets encoded as $\lambda a b.a~x$ and None gets encoded as $\lambda a b.b$; etc. – Daniel Schepler May 17 '21 at 22:06
  • 1
    Quoting from my answer at one of the linked questions: “What does it mean for something to be true or false? In this context we are not concerned with abstract truth or falsity. We just want something that behaves in a certain way: We want true and false to be different, and distinguishable, and we want to have some sort of if-then-else construction so that $\mathbf{if}; b; \mathbf{then}; p ;\mathbf{else}; q$ evaluates to $p$ when $b$ is true, and to $q$ when $b$ is false. There is nothing more to it than that.” – MJD May 18 '21 at 14:50

0 Answers0