0

私はプロローグを学び始めたばかりです。私は CS 2300 クラスのためにそれを学んでいます。私は今、基礎を学ぼうとしています。述語を .pl ファイルに追加するにはどうすればよいですか? .pl ファイルに述語を追加しようとしています。私はこれをやっています:

married(X,Y) :- married(Y,X).

そして、私はエラーを受け取ります:

ERROR: Undefined procedure: (:-)/2
ERROR: Rules must be loaded from a file
ERROR: See FAQ at http://www.swi-prolog.org/FAQ/ToplevelMode.tx

どういうわけかこれを有効にすることになっていますか?

これは与えられた.plファイルです:

% File FAMILY.PL
% Part of a family tree expressed in Prolog
% In father/2, mother/2, and parent/2,
% first arg. is parent and second arg. is child.

father(michael,cathy).
father(michael,sharon).
father(charles_gordon,michael).
father(charles_gordon,julie).
father(charles,charles_gordon).
father(jim,melody).
father(jim,crystal).
father(elmo,jim).
father(greg,stephanie).
father(greg,danielle).

mother(melody,cathy).
mother(melody,sharon).
mother(hazel,michael).
mother(hazel,julie).
mother(eleanor,melody).
mother(eleanor,crystal).
mother(crystal,stephanie).
mother(crystal,danielle).

parent(X,Y) :- father(X,Y).
parent(X,Y) :- mother(X,Y).
4

2 に答える 2

3

すべての述語の前に単語の述語を使用して、述語とは何かを記述する必要があります。

述語、句はプロローグのキーワードです。そのキーワードも使用する必要があります。

家族関係プログラムについては、このリンクを参照できます。

http://www.dailyfreecode.com/Code/prolog-find-relations-family-3025.aspx

プロローグが初めての場合。

predicates 
father (symbol,symbol).
clauses 
father(michael,cathy).

このコードを試してください。

于 2013-09-13T04:30:59.040 に答える