I am having troubles understanding what is happening in this example
Learn Prolog Now - Chapter 3 - Example 3: Successor
numeral(0).
numeral(succ(X)) :- numeral(X).
When questioned numeral(X), it will firstly give 0 for X, then continue with succ(0), incrementing the succ(0) part by one in this manner until it runs out of space:
X = 0 ?
X = succ(0) ? ;
X = succ(succ(0)) ? ;
X = succ(succ(succ(0))) ? ;
X = succ(succ(succ(succ(0)))) ?
I am struggling to understand why it increments succ(0)?
I know that prolog will firstly find a fact and match it, hence the first 0. Then it will backtrack to see if there are any other solutions and it will "see" the rule. In the rule, it will use the instantiated X to 0. Where I fail, is to see why it keeps incrementing succ(0). Does X become succ(0), as opposed to just 0?
My apologies for the silly brain.