Trying to implement commutativity in Prolog

后端 未结 1 1347
情书的邮戳
情书的邮戳 2021-01-28 16:43

I am trying to create a knowledge base. My problem has terminal/1 and connected/2 and I have defined the following rule:

connected(X,Y)         


        
相关标签:
1条回答
  • 2021-01-28 17:33

    I managed to figure this out.

    I changed this:

    connected(X, Y) :- is_connected(Y, X) /\ is_connected(X, Y).
    is_connected(X, Y) :- terminal(X) /\ terminal(Y) /\ connected(X , Y).
    

    to:

    is_connected(X, Y) :- connected(Y, X); connected(X, Y).
    

    As it turns out, I also need to be asking the corrected question. Instead of asking connected(X,Y), I will now be asking is_connected(X,Y).

    0 讨论(0)
提交回复
热议问题