4
내 familyTree.pl 파일에 아래의 코드가 있다고 가정쿼리 두 사람 사이의 관계 프롤로그 패밀리 트리
: 나는 같은 질문에 대한 답을 얻으려면 지금male(tom).
male(bob).
female(lisa).
female(emily).
parent(tom, bob).
parent(lisa, bob).
morethanfriends(emily, bob).
father(X,Y) :- male(X), parent(X,Y).
mother(X,Y) :- female(X), parent(X,Y).
girlfriend(X,Y) :- female(X), (morethanfriends(X,Y); morethanfriends(Y,X)).
boyfriend(X,Y) :- male(X), (morethanfriends(X,Y); morethanfriends(Y,X)).
을
What is the relationship between Tom and Bob ?
What is the relationship between Lisa and Emily ?
어떻게 위의 질문을 프롤로그로 할 수 있습니까?
내가 말할 수있는 유일한 해결책은 (Tom, Bob) 또는 (Lisa, Emily)를 paremeter로 제공하는 알려진 관계 유형을 반복하고 어느 것이 true를 반환하는지 확인하는 것이 었습니다. 그러나; 이 해결책은 알려진 관계 유형의 수가 적고 주어진 두 사람 사이에 연쇄 관계가있는 시간 낭비로 보인다 (예 : Lisa and Emily : Lisa는 Emily의 남자 친구의 어머니 임).
안녕하세요. [this] (http://stackoverflow.com/questions/32770849/given-values-x-and-y-return-rule-name-if-it-is-true?noredirect=1#)에서 살펴볼 수 있습니까? comment53381490_32770849) 제발? – Pranav
장면 뒤에서 일어나는 일을 설명 할 수 있습니까? 현재의 대답은 예상되는 결과를 제공하지만 이해하기가 어렵습니다. –