Explanation of Solution
Extended prolog program:
The prolog program to find the family relationship using the prolog rule is shown below:
%"carol" is a female
female(carol).
%"sue" is a female
female(sue).
%"bill" is a male
male(bill).
%"john" is a male
male(john).
%"john" is parent of "carol"
parent(john, carol).
%"sue" is parent of "carol"
parent(sue, carol).
%This rule for find the mother for given child
mother(X, Y) :- parent(X, Y), female(X).
%This rule for find the father for given child
father(X, Y) :- parent(X, Y), male(X).
%This rule for sibling
%It means that X is Y's sibling if X and Y have a common parent
sibling(X, Y) :- parent(Z, X), parent(Z, Y), X\=Y.
%Rule for find the relationship of uncle
uncle(U,N):- male(U),sibling(U,Z),parent(Z,N).
%Rule for find the relationship of aunt
aunt(X,N):- female(X),sibling(X,Z),parent(Z,N).
%Rule for find the relationship of grandParent
grandParent(G,N):- parent(G,P),parent(P,N).
%Rule for find the relationship of cousin
cousin(X1,X2) :-
parent(Y1,X1),
parent(Y2,X2),
sibling(Y1,Y2).
%Rule for find the parents of Z's.
parents(X, Y, Z):- parent(X, Z), parent(Y, Z).
Prolog Code Explanation:
The given program is used to find the family relationship using prolog rule.
- From the above code, first assign the two females “carol” and “sue” by using prolog rule “female(carol)” and “female(sue)” respectively.
- Then assign the two males “bill” and “john” by using prolog rule “male(bill)” and “male(john)” respectively.
- The rule “parent(john, carol)” implies “john” is parent of “carol”.
- The rule “parent(sue, carol)” implies “sue” is parent of “carol”...
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Computer Science: An Overview (12th Edition)
- Your task for this lab is to write a program in any language you like(c language) to determine the number of rabbits we would have in 24 months. You can check the validity and correctness of your program by testing the count at month 3, 4, and 5 to see if it matches the pair count in the diagram.arrow_forwardWrite a recursive function in Prolog that can be used to determine whether a given number is a prime number or not (for example 7 is a prime number, but 6 isn't).arrow_forwardWrite a single rule in the below Prolog program to have the answer shown in the result window. The comments are provided to give you a better understanding of the program. greater(a,b). /* a is greater than b */ greater(b,c). /* b is greater than c */ /* Need to write a single rule*/ ?- superGreater(a,c). /* is a greater than c? */ /* Result window*/ truearrow_forward
- I don't really know where to start.arrow_forwardWrite this program in C programming language. Please provide proof that its working and make it simple like input-output type only Here is the question: Write a program that determines the total number of campers, if each group camper has 12 members.arrow_forward. avoid plagiarism Write a rule in Prolog called hailstone(x) that, given a positive integer x, returns the number of elements in the hailstone sequence starting with that x. So, for example, for n=35, the function would return 14.arrow_forward
- Prologarrow_forwardQuestion 13 Write a function in Scheme or rules in Prolog called countlt that takes a list of numbers, L. and another number. N. and returns the count of numbers less than N in the list L. Example calls Scheme: (countlt '(6 1 9) 4) -> 1 (countlt '(50 27 13) 1) -> 0 Prolog ?- countlt (I6, 1, 91, 4, X) . X = 1. ?- countlt ( [50, 27, 131, 1, X). X = 0. Edit View Insert Format Tools Table 12pt v Paragraph v В I U ※ 总 !!arrow_forwardEstablish the limits of global and local variables. You should use whole sentences.arrow_forward
- I am trying to learn Prolog and am having a hard time getting this example to work. Could you show me how to write a function in Prolog to check if an element X is occurring N times in a list? For example 'occur(e, [e,e,a,t,f,t,e],3)' would be true, 'occur(a, [e,e,a,t,f,t,e],3)' would be false.arrow_forward2- Write a prolog program to take a nested list and return the number of elements in the list. For instance ?- elements ([b, [a, [d, c], e]], X). X = 5 Please also show tracing model for the above examplearrow_forwardCan someone write a prolog program using prolog facts and rules to solve the following? "A woman points to a portrait of a man, saying: "his brother's father is the only son of my grandfather." What's the relationship of the woman and the man in the portrait? Can you create some facts and one rule to identify the relationship between the woman and the man in the portrait?"arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education