![Computer Science: An Overview (12th Edition)](https://www.bartleby.com/isbn_cover_images/9780133760064/9780133760064_largeCoverImage.gif)
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”...
![Check Mark](/static/check-mark.png)
Want to see the full answer?
Check out a sample textbook solution![Blurred answer](/static/blurred-answer.jpg)
Chapter 6 Solutions
Computer Science: An Overview (12th Edition)
- Write 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 Prolog predicate that sees if the list has duplicate numbers. (Course: Programming languages). note: PLEASE DON'T SOLVE IT WITH CODING LIKE(PYTHON, JAVA..ETC) JUST PROLOG PREDICATE. and please help...asaparrow_forwardOnly answer if you know this, otherwise you will get a downvote. No Spamming please!! Explain Prolog search strategy. Make use of the following figure in your explanations.arrow_forward
- Write 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_forwardFor this assignment you need to implement 2 DFA’s using prolog. DFA needs to take any lowercase string and check if it contains your first name. The string can contain any number of characters before and after your name. As long as the string contains your first name it needs to be accepted.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_forward
- The language composed of all strings over the alphabet {a,b} of the form: zero or more a's followed by zero or more b's, i.e., {"", a, b, aa, ab, bb, aaa, aab, abb, bbb, ...}, where "" is the empty string, is a regular language: show why this is. Note that you may use any line of argument on regular languages, e.g., by showing that it can be constructed using the properties ("Regular Language: a formal definition"), or by drawing the finite state automaton (FSA), or giving its description.arrow_forwardImplement Thirsty problem using semaphore. Write the code in C/C++ Scenario: To drink, a thirsty person must have three things; water, ice and a glass. There are three thirsty people, each having a different one (and only one) of the three required items. A fourth person, a server has unlimited supply of all three items. If nobody is drinking, the server places two of the three items (chosen at random) onto table. Thirsty person who can make a drink from those two items will pick them up and drink a glass of ice water. When done, thirsty person will notify the server and the process will repeat.arrow_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
- PROLOG LANGUAGE We flatten a list L by first removing all lists within L and replacing them with their members. Write a Prolog rule flattenit/2 which flattens a list. Note: there is a built-in called flatten - you should not use that in your answer. For example: :- flattenit([a,b,c,[d,e],f,[c, a, b]], [a,b,c,d,e,f,c,a,b]). :- flattenit([1,2,3,4,[5,6,[7,8]]], [1,2,3,4,5,6,7,8]). :- flattenit([1,2,[3,4,[5,6],7],8,[2,4,5,8]], [1,2,3,4,5,6,7,8,2,4,5,8]).arrow_forwardSuppose a Prolog database exists that gives information about the parts in an automobile engine. Predicates of big, small, and partof are included.a. Write a query to find all small items that are part of other items.b. Write a query to find all big items that have small subitems.c. Formulate a recursive rule to define componentof.arrow_forwardPrint the given statement in prolog. "Currently learning module 1 of prolog".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
![Text book image](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)