## To Mock a Mockingbird or: How I learned to stop worrying and learned combinatory logic

Yesterday I finished reading one of the most remarkable books I read in my life: “To Mock a Mockingbird and Other Logic Puzzles: Including an Amazing Adventure in Combinatory Logic” by Raymond Smullyan. When I finished reading The Little Schemer that book was listed as one of the suggested further readings. The title was quite intriguing so I got the book and started reading it. That was a year ago and I finished the book yesterday. Why? Because I got stuck and couldn’t understand some of the material. Luckily I now had some time to approach the book once again and grok it.

As the title suggests the book is a collection of logic puzzles. Out of six parts of the book – 25 chapters total – two are devoted to general logic puzzles, many of them about different aspects of truth telling. These can be regarded as a warm-up because in the third part the book makes a sudden turn towards combinatory logic. And this is the moment I found difficult in the book. Of course Smullyan doesn’t expect that readers work with combinators so he camouflages them as singing birds. Having some mathematical background I rejected this cover and tried to approach problems formally. Now, after reading the book, I think this was a major mistake that lead to my failure. I wasn’t able to deal with first 10 puzzles but I was more or less able to follow the solutions. Still I felt that reading solutions without being able to solve puzzles by myself was cheating so I gave up. A few months later I made another approach to the book but the results were exactly the same. Three weeks ago I made a third attempt, but I decided not to give up even if I won’t be able to come up with my own solutions. I figured that being able to only understand given solutions is completely fine. That decision turned out to be a good one. Although at first I wasn’t able to solve puzzles on my own at some point things just clicked. I solved one puzzle, then another and another and I realized that I know how to solve most of the puzzles. From now on the book went quite smoothly. Part four about logical paradoxes and inconsistencies in logical systems gave me some problems and I was afraid that each subsequent part will be equally challenging but it turned out that it was not the case. Part five gives a nice overview of computations using SKI combinators, while part six presents Church encoding of natural numbers and culminates with a proof of GĂ¶del’s theorem.

The book is challenging on the one hand but it is also very rewarding. One of the most satisfying moments was realizing that I am able to write expressions like

$g\tilde{a}\tilde{b}=Z\tilde{a}f(Z\tilde{b}t(g(P\tilde{a})(P\tilde{b})))$

# Summary

To “Mock a Mockingbrd” was a very insightful book and one of the most unusual ones I have read. It presents difficult material in a fun and entertaining way, but don’t be fooled – you will spend hours with pen and paper to complete this book. I highly recommend it to anyone interested in logic and functional programming. What functional programming has to do with it? Unrelated as it may seem I feel that this book has given me knowledge necessary to tackle type-level programming in Haskell. Just three weeks ago this seemed like a complete black magic and now it looks comprehensible.

## Coders at work. A short review

I was visiting my friend before Christmas and on his shelf I found “Coders at Work” by Peter Seibel1. It’s a collection of interviews with fifteen world-known programmers (assuming a programmer can be world-known). Among the names two have caught my eye: Simon Peyton Jones and Guy Steele. I borrowed the book and ended up reading interviews with these two researchers and Donald Knuth. Not surprisingly, interview with Simon Peyton Jones was the one that interested me the most. I found it very enjoyable to read accounts of how these people became programmers in times where computers where huge machines available only at universities. On the other hand I also found some parts of the interviews to be a bit dry, e.g. SPJ goes into the discussion of Software Transactional Memory in Haskell and I think that reader not familiar with STM will not get much out of this. Also, reader familiar with STM will probably not need this discussion.

There are two thoughts that stroke me during the reading. When reading interview with Knuth I realized that there are actually people that are unable to learn programming. I teach at the university and I’ve seen many first year students who completely don’t grasp programming but somehow it never occurred to me that some of them might not ever be able to learn this. Second thought, the more important one, is that all these famous programmers were extremely lucky guys. They all got the chance to develop their talents. I believe that there are even more very talented people who could have had even greater impact on computer science, but they just didn’t get their chance.

One last thing. SPJ mentions that his “Aha!” moment in functional programming was Arthur Norman’s demonstration of implementing double-linked list in a purely functional fashion, that is without any side effects. I tried to google more information on that but with no result. So if anyone has an idea how to implement such a list please tell me. The only thing that comes to my mind are zippers. They do allow traversal of list in both directions and modifying its elements so this might be it.

1. In fact I found Polish edition. []