Tutorial


 * This is the continuation of Interface:Tutorial

The proof of $$2+2=4$$
Ready to prove $$2+2=4$$, the statement you ever since your childhood wondered whether it was really, really true, from our Peano axioms? Well, then, first, we need to load all that stuff we did in Interface:Tutorial:  import (NAT Interface:Tutorial ) 

Let's go straight to the proof then:  thm (2+2=4  (((2) + (2)) = (4)) (  As you can see, the  command looks just like a   command, except that it doesn't stop after the consequent. That single open bracket is crying for a proof. Proofs are maintained using a proof stack of expressions. The proof stack starts out empty, so let's push something onto it:  (2) addzero  So, first we push the expression  on the stack. The next item in the list is not an expression but the name of a statement, namely. The consequent of  is   and there are no hypotheses in this statement. As we have mentioned before, each variable can actually take any expression of the correct kind. To know which expression is the desired one,  looks on the stack, finds the , pops it from the stack and substitutes it for. So now, we have  on the stack. Great! We have proven that $$2=2+0$$. To reach $$4=2+2$$, we bump up that equation with the successor function:  succfunc  The  statement requires one hypothesis,. So it pops one element from the stack and finds:. That's a perfect match if we substitute  for   and   for. This process is called unification. Note that  does not look on the stack any further despite depending on two variables because these two variables have already been determined by the unification. So now we have on the stack:. Note that  is just. So we need  just once more to reach. First, however, we must use  to move the annoying successor function deeper into the brackets:  (2) (0) addsucc eqtransitive  The first line pushes the expression  on the stack. So we have now two expressions on the stack: This means we have proved these two expressions, and they look like they could be combined to the single expression  (with   already simplified to  ). That's just what  does: it needs two expressions, the two on the stack match, so they are popped. Unification determines all variables, so we get the combined expression on the stack. Now we just need to do the same thing once more to go from  to  :  succfunc (2) (1) addsucc eqtransitive  This time, we have of course to instantiate  with   for , as otherwise   would not be able to properly unify the stack contents with its hypotheses. Now we're practically done, for we have  on the stack. At the end of the proof, the stack must contain exactly one element which matches the consequent of the theorem. We do have only one element, but the consequent is. So all that is left to do is to flip the equation:  eqsymmetric # 2 + 2 = 4 )) 

That's it!

What next?
You can find another example of explaining proofs, with some exercises, at Help:Tau day. To find things to contribute to, browse Category:Pages needing cleanup. Feel free to ask questions at WP:TEA.