これは単純な問題かもしれませんが、別の方法で行う必要があります。問題は、プロローグで飛行機の可能なルートを見つけなければならないことです。私はこのナレッジベースを持っています
from_to(fresno,seattle).
from_to(fresno,albany).
from_to(albany,dallas).
from_to(fresno,boston).
from_to(dallas,seattle).
from_to(dallas,albany).
from_to(seattle,dallas).
from_to(seattle,omaha).
from_to(atlanta,albany).
from_to(atlanta,dallas).
from_to(atlanta,boston).
from_to(omaha,atlanta).
from_to(omaha,albany).
from_to(albany,seattle).
そして、X から Y に移動できるかどうかをチェックする述語 route(X,Y) を作成する必要があります。
route(X,Y):-from_to(X,Y).
route(X,Y):-from_to(X,Z), route(Z,Y).
しかし、グラフは循環的であるため、機能しません。私はインターネットで検索しましたが、誰もがリストを使用して訪問したパスを確認することだけを言いました。しかし、私はリストを使用することはできません! リストを使用せずに述語ルート (X,Y) を作成する必要があります。リストを使用せずにこれを行うにはどうすればよいですか? ありがとうございました