Skip to content

Latest commit

 

History

History
 
 

peano

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Peano arithmetics

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.