Write predicates to compare Peano numbers. In this system, \(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 predicates that need to be written are:
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\)p_exp(A,B,C)
iff \(A^B = C\) , do not include \(0^0\). Because \(0^0\), is a mathematical expression with no agreed-upon value1.Note that all Peano numbers are positive, to implement p_sub/3
you may limit the definition to positive integers. Try to use p_mul/3
to divide, does that work?