Convert peano number s(N) to integer in Prolog
问题 I came across this natural number evaluation of logical numbers in a tutorial and it's been giving me some headache: natural_number(0). natural_number(s(N)) :- natural_number(N). The rule roughly states that: if N is 0 it's natural, if not we try to send the contents of s/1 back recursively to the rule until the content is 0 , then it's a natural number if not then it's not. So I tested the above logic implementation, thought to myself, well this works if I want to represent s(0) as 1 and s(s