Write a predicate factorial/2
that calculates the factorial of the 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 value of \(0! = 1\), according to the convention for an empty product. 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\)p_exp(A,B,C)
iff \(A^B = C\)