Write a predicate modulo/3
that calculates the modulo of two Peano numbers.
In the system of the Peano numbers, \(0\) is presented by 0
, \(1\) by s(1)
, \(2\) by s(s(0))
, and so on.
To be precise, \(n\) is represented by taking 0
and wrapping it \(n\) times with s/1
.
The following predicates are assumed to be defined.
p_add(A,B,C)
iff \(A + B = C\)p_sub(A,B,C)
iff \(A - B = C\)p_mul(A,B,C)
iff \(A \cdot B = C\) (The version in Dodona allows you to use it to divide, does your implementation do that? Why?)p_exp(A,B,C)
iff \(A^B = C\)less_strict(X,Y)
: X
is strictly less than Y
greater_strict/2
: X
is strictly larger than Y
less_or_eq(X,Y)
: X
is less or equal to Y
greater_or_eq/2
: X
is larger or equal to Y
This exercise can be solved with and without using recursion. Try them both.