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 (13th Edition) (What's New in Computer Science)
- In This Assignment, You Need To Solve The Following Problems Using Prolog 1. Design Rules To Find Out If A Value Is A Member Of A List. The Predicate Should Be In The Format: Mymember(value, List). For Example, Mymember(X, [1, 2, 3, 4]) Should Return X = 1. 2. Design Rules To Check If An Integer Is An Even Number Or Not. The Predicates ... This problem has been solved! See the answer Description:In this assignment, you need to solve the following problems using Prolog. 1. Design rules to find out if a value is a member of a list. The predicate should be in the format: mymember(value, list). For example, mymember(X, [1, 2, 3, 4]) should return X = 1.2. Design rules to check if an integer is an even number or not. The predicates should be in the format: myeven(a_number).3. Design rules to find out the number of even values in a list of integers. The predicates should be in the format: myevennumber(a_number, list). For example, myevennumber(X, [1, 2, 3, 4, 5, 6]) should return X = 3.4.…arrow_forwardDefine a Prolog predicate project/3 that selects elements from a list by their position and collects them in a result list. For example, the goal of project( [2,4],[a,b,c,d],L) should produce the answer L=[b,d]. You can assume that the numbers in the first list are strictly increasing, that is, your implementation does not have to care about situations like project([1,1,2],..) or project([2,5,3],.).arrow_forwardDevelop a system/application in Prolog that will allow grader to: load a set of student’s grades (see samples from the Table C below) query student’s final letter grade (A, B, C, etc.) by a given student’s name. query student(s) whose grade matches to the input letter grade (e.g., A). For example, show student(s) whose final letter grade is A. There are 3 types of grades for each student—HWs, Exams, and Project, with a weight of 20%, 40% and 40%, respectively, to the 100-point final. Table A and B show how the final grades (in points and letter) are computed. Table C shows samples of students’ grades. You will define the execution instructions to answer the following questions so that grader can test out your application in Prolog: how to load your source code to Prolog runtime/compiler how to load students’ grades to Prolog runtime/compiler how to query student’s letter grade how to query student(s) whose letter grade matches to an input letter grade Please DO NOT hard code any…arrow_forward
- Write 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_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_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_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_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_forwardI 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_forward
- 2For this assignment you need to implement 2 DFA’s using prolog. 1. First DFA needs to take a number and process it digit by digit and accept it if it is divisible by 7. To do this you will need 7 states (0,1,2,3,4,5,6) and your alphabet needs to be the 10 possible digits.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_forwardPlease ASAP, it's important Design a CFG which recognizes the language L={ w | all the letters on the first half of w are the same, and the second half is a substring where no consecutive letters are the same } over the alphabet Σ={0,1,2}. Explain your derivation rules. Note: consecutive means two letters which follow each other, " no consecutive letters are the same" means you can't repeat letters, so you can't have "00", "11" or "22" on the second half.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