# Turing-Tape Games Competition

To celebrate the 100th anniversary of Alan Turing’s birth, we* are running the Turing-Tape Games competition.

The competition is about solving solitaire-like games played on a Turing tape (a one-dimensional tape divided into squares as used in Turing machines). We think the games are very appropriate to celebrating Turing’s legacy because they combine mathematics (polynomial arithmetic) with algorithmics (finding the most effective way to solve the games).

The competition has a number of rounds. Round 0 (familiarisation) began on April 1. It will be followed by 5 practice rounds which continue until July. During the practice rounds we will be publishing top scores so that participants can compare their solutions with those obtained by others. The final begins at the end of August and lasts for 3 weeks. It’s possible to join in the competition at any time.

There are 4 categories of participant: pre-university, undergraduate, postgraduate and other. The games are challenging to solve but are feasible for all categories. The current (round 0) top-scorer is an undergraduate from Ningbo.

Students registered at a UK educational institution are eligible to compete for cash and other prizes. All competitors (whether or not a UK student) will be entitled to a discount of 20 per cent on the purchase price of the book Algorithmic Problem Solving by Roland Backhouse, courtesy of the publishers John Wiley & Sons, Inc.

The final begins on 26th August, 2012 and ends on 16th September, 2012. Winners will be announced on 30th September, 2012.

* Roland Backhouse, Wei Chen, João F. Ferreira and Alexandra Mendes

# On Peirce’s law and the law of the excluded middle

A few days ago I found a video on YouTube explaining how to use CoqIde, the IDE for the Coq proof assistant. The proof that was used to illustrate the IDE was the equivalence between Peirce’s law and the excluded middle law, that is, the equivalence between the two following laws:

$\mleq{(0)} {((p{\Rightarrow}q){\Rightarrow}p)\Rightarrow p}$

and
$\mleq{(1)} {\neg{p} \vee p}$

After watching the video, I wrote a goal-oriented, calculational proof of the equivalence between (0) and (1). In this short note, I describe the design of my proof.

## A calculational proof

A useful rule of thumb is to start with the most complicated side, for it is usually easier to simplify expressions than to complicate them. With this in mind, let us try to manipulate (0) so that it becomes (1).

Looking at the shapes of (0) and (1), we immediately see that $q$ occurs in (0), but not in (1). So, if we start with (0), we will have to eliminate the occurence of $q$. This suggests that we have to use laws that involve the elimination of variables. Two elementary rules that are of this kind are the so-called absorption rules for conjunction and disjunction:

$\mleq{(2)}{(p \wedge q) \vee p ~\equiv~ p}$

$\mleq{(3)}{(p \vee q) \wedge p ~\equiv~ p}$

At a first sight, these rules may not seem very useful, because they involve only conjunction and disjunction and we want to eliminate a variable from a formula involving implication. But we know that implication can be written in terms of negation and disjunction:

$\mleq{(4)} {{p{\Rightarrow}q} ~\equiv~ {\neg{p} \vee q}}$

These observations, together with the De Morgan rule, allow us to write a goal-oriented, calculational proof of the equivalence between (0) and (1):

$\beginproof \pexp{((p{\Rightarrow}q){\Rightarrow}p)\Rightarrow p} \hint{=}{rewrite the two leftmost \Rightarrow using (4)} \pexp{{\neg{(\neg{p} \vee q)} \vee p} ~\Rightarrow~ p} \hint{=}{De Morgan rule, that is, \neg{(\neg{p} \vee q)} ~\equiv~ (p \wedge \neg{q})} \pexp{{(p \wedge \neg{q}) \vee p} ~\Rightarrow~ p} \hint{=}{absorption (2)} \pexp{p{\Rightarrow}p} \hint{=}{rewrite \Rightarrow using (4)} \pexp{\neg{p} \vee p ~~.} \endproof$

## The video

The video that I mentioned is shown below. It would be unfair to compare the proofs, since the main goal of the video is to illustrate Coq’s IDE and not to show how to design proofs. Nevertheless, I would like to invite the reader to comment on the use of automated/interactive theorem provers to design proofs. Thanks for reading.

# An improved proof of the handshaking lemma

In 2009, I posted a calculational proof of the handshaking lemma, a well-known elementary result on undirected graphs. I was very pleased about my proof because the amount of guessing involved was very small (especially when compared with conventional proofs). However, one of the steps was too complicated and I did not know how to improve it.

In June, Jeremy Weissmann read my proof and he proposed a different development. His argument was well structured, but it wasn’t as goal-oriented as I’d hoped for. Gladly, after a brief discussion, we realised that we were missing a great opportunity to use the trading rule (details below)!

I was so pleased with the final outcome that I decided to record and share the new proof.

## Problem statement

In graph theory, the degree of a vertex $A$, $\fapp{d}{A}$, is the number of edges incident with the vertex $A$, counting loops twice. So, considering Graph 0 below, we have $\fapp{d}{A}=3$, $\fapp{d}{B}=3$, $\fapp{d}{C}=1$, $\fapp{d}{D}=3$, and $\fapp{d}{E}=2$.

Graph 0: Example of an undirected graph with five vertices

A well-known property is that every undirected graph contains an even number of vertices with odd degree. The result first appeared in Euler’s 1736 paper on the Seven Bridges of Königsberg and is also known as the handshaking lemma (that’s because another way of formulating the property is that the number of people that have shaken hands an odd number of times is even).

As we can easily verify, Graph 0 satisfies this property. There are four vertices with odd degree ($A$,$B$, $C$, and $D$), and 4, of course, is an even number.

Although the proof of this property is simple, all the conventional proofs that I know of are not goal-oriented. My goal is to show you a development of a goal-oriented proof. Also, my proof is completely guided by the shape of the formulae involved, which helps reducing the amount of guessing involved.