will succeed as it should, as will
But the query
But the same fact can also match this new rule too with D=0. So we
can prove the fact bottom(3,1,7,0). We have exhausted the first fact, so
we now consider this new fact. It can match the right side of the "top"
rule, so a new fact top(0,7,3) is proved. We now consider the only
remaining fact, data(3,2,1), the second of the original two facts. This
can match the original "bottom" rule, giving:
bottom(A,B,7,2) :- data(A,0,B).
But data(3,2,1) can also match the first-listed rule above, giving a new fact bottom(3,1,7,2). This then matches the right side of the "top" rule giving the final new fact top(2,7,3).