4 |

Integers and floating point numbers are built into most programming languages, including Prolog. However, suppose that numbers and arithmetic operations were not available. It is still possible to define numbers in Prolog and to write programs to implement simple arithmetic operations. In the following question, you MUST NOT use any of Prologs built-in arithmetic predicates such as is, <, +, *, etc. (except in part (f)). Also, do not use the cut operation (!) in your program.

A positive integer can be defined as zero or the successor of another
number. Thus, zero can be represented by 0 and a number, such as two, can be
represented by s(s(0)), where two is the successor of the successor of 0.
Thus s(X) can be thought of as X+1. We call numbers written like this
*s-expressions*.

In parts (c) to (f), don't worry about what happens if X (and Y and Z) are not s-expressions. You don't have to cope with this, and in particular, you don't have to check for this.

See also the
Wikipedia entry on the Peano axioms. *This link is just for
interest - the material at the link is not examinable*.