Consider the following type to represent natural numbers:
type nat = Z | S of nat
Write the following functions:
iseven : nat -> bool
detects if a number is even.
halve : nat -> nat
divides a natural number by two (note: this is the integer division, where \eg 3 divided by 2 equals 1).
add : nat -> nat -> nat
adds two numbers.
mul : nat -> nat -> nat
multiplies two numbers.
equals : nat -> nat -> bool
checks equality.
leq : nat -> nat -> bool
checks if a number is less than or equal to another one.