I am trying to prove this function in ACL2s/Lisp, but it is returning a stack overflow error, though I can't see the flaw in the code.
(defunc foo (x y)
:input-contract (and (natp x) (natp y))
:output-contract (natp (foo x y))
(cond ((equal 0 x) (+ y 1))
((equal 0 y) (foo (- x 1) 1))
(t (foo (- x 1) (foo x (+ y 1))))))