Help:Tutorial

This is a small tutorial on how to use the JHilbert, the automated proof verifier driving this wiki. We shall prove the statement "two plus two equals four" from a small set of simple axioms.

If you're really, really impatient, you can skip all the preliminary blah blah and jump right to the implementation of some of the Peano axioms.

Why this tutorial?
While JHilbert is a simple piece of software compared with other formal logic suites such as Coq or Isabelle, it is also more complex than most other MediaWiki extensions, so a tutorial to provide a gentle introduction for newcomers seems in order. Besides, most people prefer learning by example (at least initially) to just ingesting the specs.

Prerequisites
In order to reproduce the effects of the JHilbert code in this tutorial, you'll need a MediaWiki installation with the JHilbert extension properly installed and a JHilbert server running on your MediaWiki host. Wikiproofs is such an installation.

Why $$2+2=4$$?
So, why choose the statement "$$2+2=4$$" for a tutorial? For one, because it's simple! At least it seems so at first glance. Almost all, say, eight-year old children with access to formal education know that $$2+2=4$$. On the other hand, it is not natural knowledge. Children have to be taught addition of small integers. It usually doesn't come to them naturally. In this sense,  is a true cultural achievement.

To illustrate how complicated even a trivial statement like $$2+2=4$$ can get, check out Norman Megill's metamath proof of $2+2=4$. His proof database is founded on very general axioms. The advantage of this is that you can formalise virtually all the fancy stuff mathematicians are working with, such as vector spaces and complex numbers. With all the other proofs here to help, the metamath proof of a simple statement like $$2+2=4$$ is reasonably short (ten metamath steps). But if you were to unravel the proof back to the initial axioms, you'd have to untangle 2452 subtheorems totalling 25933 steps. An awe-inspiring demonstration of the human power of abstraction.

For this tutorial, we will, of course, keep things much, much simpler.

What is $$2+2=4$$ anyway?
At the beginning of each formalisation is the question what the stuff we're talking about actually means. Per se, $$2+2=4$$ is just a string of symbols. We recognise four different symbols in this string: $$2$$, $$4$$, $$+$$ and $$=$$.

The first two symbols, $$2$$ and $$4$$, are instances of natural numbers, that is, the numbers $$0,1,2,3,4,5,\ldots$$. (In school, you may have learned that zero does not belong in the natural numbers. While the inclusion of zero implies certain slight variations in the handling of certain definitions, this is effectively just convention. For this tutorial, the natural numbers will contain zero.) Note that this is just one of the simpler explanations for what $$2$$ and $$4$$ should mean. We could just as well have stipulated that $$2$$ and $$4$$ should be complex numbers (which would clearly go beyond the scope of a tutorial). As there are many natural numbers, we need some way to express which ones are $$2$$ and $$4$$.

The next symbol, $$+$$, the symbol for addition, is able to take two natural numbers to make a new one. We might say, $$+$$ is a function which enables us to create the term $$2+2$$ whose value is a natural number. Of course, many such functions exist: multiplication, exponentiation, and so on. So we'll have to make the meaning of $$+$$ precisely clear. Note that $$2+2$$ is by no means a simplest possible term, as $$2$$ and $$4$$ already constitute primitive terms.

The last symbol, $$=$$, the symbol for equality, is also able to take two natural numbers, or, more general, two terms whose values are natural numbers to make something new. However, $$2+2=4$$ is not a term in the sense of arithmetic. Rather, it is a formula: something for which the question "Is it true that …?" makes sense. So, while "Is it true that $$2+2$$?" is not a sensible question to ask, "Is it true that $$2+2=4$$?" is.

So, let's sum up what we need:
 * 1) A formalisation of the natural numbers, and of formulas involving natural numbers (equality is enough for our purposes).
 * 2) A precise description of the natural numbers $$2$$ and $$4$$.
 * 3) A precise definition of the addition operation.

Sounds difficult to formalise? It is! Fortunately, we do not need to rack our brains as someone else has already done it for us.

The Peano axioms

 * Some material in this section was taken from the article Peano axioms from Wikipedia, the free encyclopedia.

In 1889, Italian mathematician Guiseppe Peano found the following nine formal statements to describe the natural numbers and equality. For all natural numbers $$x,y,z$$:


 * 1) $$x=x$$.
 * 2) If $$x=y$$, then $$y=x$$.
 * 3) If $$x=y$$ and $$y=z$$, then $$x=z$$.
 * 4) If $$x=a$$ for some $$a$$, then $$a$$ is a natural number.
 * 5) $$0$$ is a natural number.
 * 6) There is a function $$\mathrm{succ}$$ (the successor function) such that $$\mathrm{succ}(x)$$ is a natural number.
 * 7) $$\mathrm{succ}(x)\neq 0$$.
 * 8) The function $$\mathrm{succ}$$ is injective.
 * 9) If $$A$$ is a set such that $$0\in A$$ and for all $$a\in A$$ we have $$\mathrm{succ}(a)\in A$$, then all natural numbers are contained in $$A$$.

Addition can then be defined for all natural numbers using the induction principle to which the ninth axiom gives rise: $$x+0=x$$ and $$\mathrm{succ}(x+y)=x+\mathrm{succ}(y)$$, and likewise for the left summand. The number $$2$$ is simply the successor of the successor of $$0$$, and $$4$$ is defined likewise.

We are going to teach JHilbert (some of) the Peano axioms in the next section. As you can see, we also need concepts like "If … then", "and", "not" and even set theory to implement these axioms. However, to keep things simple, we will not define these concepts but rather emulate them with JHilbert intrinsics where possible, and drop the axioms for which this is not easily possible. The remaining axioms will be enough to prove that $$2+2=4$$.


 * This tutorial continues in the Interface namespace: Interface:Tutorial