Rating : ⭐⭐⭐⭐⭐
Price : \$10.99
Language:EN
Pages: 2

# Can match the right side the top rule

http://www.cs.nps.navy.mil/people/faculty/rowe/book/im.html

substitution([X,transition],[X,change]) :-
member(X,[will,must,should,can,might,perhaps,always,never]).

will succeed as it should, as will
?- a(r,r).

But the query
?- a(r,u).

http://www.cs.nps.navy.mil/people/faculty/rowe/book/im.html

rhymes([fufu,rufu,nufu,pufu]). onerhymes([bo,go,toe,joe,moe]).

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).

How It Works