Question: PLEASE DONT SOLVE UNLESS YOURE SOLVING THE WHOLE THING % male(P) is true when P is male male(james1). male(charles1). male(charles2). male(james2). male(george1). % female(P) is
PLEASE DONT SOLVE UNLESS YOURE SOLVING THE WHOLE THING
% male(P) is true when P is male male(james1).
male(charles1).
male(charles2).
male(james2).
male(george1).
% female(P) is true when P is female female(catherine).
female(elizabeth).
female(sophia).
% parent(C,P) is true when C has a parent called P parent(charles1, james1).
parent(elizabeth, james1).
parent(charles2, charles1). parent(catherine, charles1).
parent(james2, charles1).
parent(sophia, elizabeth).
parent(george1, sophia).
7 male(P) is true when P 18 male male (jamesi). male (charlesi). male (charles 2 ). mie (jamesti). male (georgel). 3. female (P) is true when P is fenale female (catherine). fertale (elizabeth). female (sophia). 3 parent (C,P) is true when C has a parent celled p parent (charles1, Jartesi). parent (elizabeth, jamesi). parent (charles2, charlesi). parent (catherine, charlesi). parent(james2, charlesil. parent (sophia, elizabeth). parent(georgei, sophia). Start a new file in your text editor (call it "family.pl"), and copy and paste the above program into it We can now formulate some queries (try entering these yourself): - Was George I tbe parent of Charles I? Query: parent (charles1, george1). - Who was Charles I's parent? Query: parent (charlesl, Parent). - Who were the children of Charles I? Query: parentichild. charlesil. Try adding the following rules to the program, and check the results: - M is the mother of P if she is a parent of P and is female - F is the father of P if he is a parent of P and is male - X is a sibling of Y if they both have the same parent. Remember that "and" in Prolog is represented using a comma. Also, the connection between predicates should be made by sharing variables (and not by embedding one predicate insido another)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
