Question: Logic Programming Assignment In this assignment, you are asked to write simple logic programs. 1. Complete the following exercise in terms of the given relations
Logic Programming Assignment In this assignment, you are asked to write simple logic programs.
1. Complete the following exercise in terms of the given relations parent(X,Y), female(X) and male(X) . Test your code with some facts for parent, female and male relations. However, your solutions should be general enough to work with any sets of such facts.
a. Define a mother predicate so that mother(X,Y) says that X is the mother of Y.
b. Define a father predicate so that father(X,Y) says that X is the father of Y.
c. Define a sister predicate so that sister(X,Y) says that X is a sister of Y. Caution: A person cannot be her own sister. In Prolog, X \= Y is true if and only if X is not the same as Y.
d. Define a grandson predicate so that grandson(X,Y) says that X is a grandson of Y. e. Define a descendant predicate so that descendant(X,Y) says that X is a descendant of Y. The following is an example set of facts.
parent(adam,bill). parent(bill,carl). parent(bill,mary). parent(bill,peter). parent(bill,kathy). parent (anne,carl). parent (anne,peter). parent(anne,mary). parent(anne,kathy). male(adam). male(bill). male(carl). male(peter). female(anne). female(mary). female(kathy).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
