Artificial Intelligence Practice with Prolog Write a PROLOG program that impleme
ID: 3867162 • Letter: A
Question
Artificial Intelligence
Practice with Prolog
Write a PROLOG program that implements a family database for your family. Save it as an ordinary text file named family.pro. Your program should implement the following facts for your immediate family, grandparents, and great-grandparents.
That is, your database should consist of a number of facts about who is the parent_of of who, about which individuals are male and about which individuals are female. For example:
All other predicates should be implemented as rules -- i.e., as predicates involving variables and logical implication (:-). For example, the rules for father_of and daughter_of would be:
Define the following predicates for your database. Your database should be rich enough to test all of these predicates. For example, if you are only child, you may have to make up fictitious siblings to test the sibling_of predicate.
Some of these predicates may be defined in terms of other predicates. For example, a sister is a female sibling and a grandparent is the parent of a parent. The ancestor_of predicate can be defined recursively to handle ancestors from any generation.
Explanation / Answer
Given below are the predicates for the question. Please rate the answer if it helped. Thank you.
father_of(X,Y) :- parent_of(X,Y),male(X).
mother_of(X,Y) :- parent_of(X,Y),female(X).
son_of(X,Y) :- parent_of(Y,X),male(X).
daughter_of(X,Y) :- parent_of(Y,X),female(X).
sibling_of(X,Y) :- parent_of(Z,X),parent_of(Z,Y).
brother_of(X,Y) :- sibling_of(X,Y), male(X).
sister_of(X,Y) :- sibling_of(X,Y), female(X).
grandparent_of(X,Y) :- parent_of(X,Z),parent_of(Z,Y).
ancestor_of(X,Y) :- parent_of(X,Y).
ancestor_of(X,Y) :- parent_of(X,Z),ancestor_of(Z,Y).
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.