Question

Write the following facts/clause in prolog: 1) John is taking Comp42 with Professor Mora 2) If...

Write the following facts/clause in prolog:

1) John is taking Comp42 with Professor Mora
2) If sky is blue, everyone likes it.
3) If Joe final score is 90 or above in COMP42, Joe has an “A” in COMP42.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

domain
student_name=symbol.
subject=symbol.
prof_name=symbol.
marks=integer.
color=symbol.
grade=symbol.
person=symbol.
predicates
std_sub_Prof(student_name,subject,prof_name).
std_result(student_name,subject,marks,grade).
sky(color).
like(person).
clauses
std_sub_Prof(john,Comp42,Mora).
like(X):-sky(blue).
std_result(joe,Comp42,X,A):-if X>=90.

if you still have any Problem regarding this question please comment and if you like my code please appreciate me by thumbs up thank you.........

Add a comment
Answer #2

1) John is taking Comp42 with Professor Mora .

subject ( John , Comp42 ) , Professor ( Mora , Comp42 ) .

The above clause can be read as John opted subject Comp42 and Mora is the professor of the subject Comp42.

2) If sky is blue, everyone likes it.

likes ( X , sky ) :- sky ( blue ) .

The above clause can be read as X likes sky if the sky is blue. Here, X is a variable and it can take any value if the condition holds true.

3) If Joe final score is 90 or above in COMP42, Joe has an “A” in COMP42.

grade(Score,Grade) :- Score >= 90, Grade = 'A'.

grade(Score,Grade) :- Score >= 80, Score < 90, Grade = 'B'.

grade(Score,Grade) :- Score >= 70, Score < 80, Grade = 'C'.

grade(Score,Grade) :- Score >= 60 , Score < 70, Grade = 'D'.

grade(Score,Grade) :- Score >= 40 , Score < 60, Grade = 'E'.

grade(Score,Grade) :- Score < 40, Grade = 'F'.

marks(Joe,Comp42,Score) : grade(Score,Grade) ,

format('~w -> ~w\n', [Score, Grade]). // format of output

Ex :- The usage of this clause is shown below :

?- marks(Joe,Comp42,60).

60-> D

Yes

Here we first defined clauses for grade based on score i.e., grade(Score,Grade) where Score is given as input and grade is yielded.

marks(Joe,Comp42,Score) is a clause in which grade of a student is yielded as output based on the score provided. This cluase internally calls the grade(Score,Grade) clause where Grade is a variable. It's value is displayed on successfull execution of query.

Add a comment
Know the answer?
Add Answer to:
Write the following facts/clause in prolog: 1) John is taking Comp42 with Professor Mora 2) If...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • #s 1-5 in prolog Give an example of "or" relationship. Give an example of "and" relationship. Assume the following facts: parent(a,b). man(a). woman(c) 1. 2. 3. State a clause for...

    #s 1-5 in prolog Give an example of "or" relationship. Give an example of "and" relationship. Assume the following facts: parent(a,b). man(a). woman(c) 1. 2. 3. State a clause for father(a,b) 4. What would be the English meaning for this o prolog clause. o owner(jack, cat(X)) :- fur(X),spots(X) 5. Do the following terms unify? Why? likes(jax, X), and likes(X, jin). Give an example of "or" relationship. Give an example of "and" relationship. Assume the following facts: parent(a,b). man(a). woman(c) 1....

  • 7. For below English sentences write applicable Prolog facts, rules & goals. a) John reads a...

    7. For below English sentences write applicable Prolog facts, rules & goals. a) John reads a book. b) Anyone likes sundevils if he/she is an ASU student. c) Who likes sundevils? d) Jane likes any village if it is small and sparse.

  • For each of the following English statements write a prolog program. % Facts & Rules (1)...

    For each of the following English statements write a prolog program. % Facts & Rules (1) jane is a woman. (2) john is a man. (3) john is healthy. (4) jane is healthy. (5) john is wealthy. (6) anyone is a traveler if he is healthy and wealthy. (7) anyone can travel if he is a traveler. % Goals (queries). (8) Who can travel? (9) Who is healthy and wealthy?

  • CSE 240 Homework 5- Programming with PROLOG Due: Monday, April 22, 11:59 PM A. What This...

    CSE 240 Homework 5- Programming with PROLOG Due: Monday, April 22, 11:59 PM A. What This Assignment Is About: Facts, Rules, Goals Prolog execution model Arithmetic operations . Recursive Rules B. Use the following Guidelines Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc.) Use tabs or spaces to indent code within blocks (code surrounded by braces). This includes classes, methods, and code associated with ifs, switches and loops. Be consistent with the number of...

  • Artificial Intelligence

    1. Facts are given in each of the sub-questions. Translate the following sentences (bold italic) into a Prolog program (rules are required):a. Every mother likes her child if her child is good.mother(ann, lina).mother(annie, sophie).mother(ann, john).mother(annie, jack).mother(maria, anne).mother(maria, harith).good(john).good(anne).good(harith).good(sophie).b. Every woman loves her husband if her husband is helpful.married(ann, king).married(annie, chong).married(maria, kumar).helpful(chong).c. Uncles are brothers of our parents.sibling(ahmad, ali).sibling(annie, chong).sibling(devi, kumar).sibling(sheda, salina).sex(ahmad, male).sex(annie, female).sex(sheda, female).sex(salina, female).sex(devi, male).sex(ali, male).sex(chong, male).sex(kumar, male).d. Aunties are sisters of our parents.sibling(ahmad, ali).sibling(annie, chong).sibling(devi, kumar).sibling(sheda, salina).sex(ahmad, male).sex(annie,...

  • Solve above using prolog!! 3. 2 marks] Write the rule remdup (List1, List2) that takes as input List1 and produces as o...

    Solve above using prolog!! 3. 2 marks] Write the rule remdup (List1, List2) that takes as input List1 and produces as output List2. List2 contains all items that appear in List1, except that repeated or duplicate items are not present in List1. For example: ?- remdup([1,2,3] ,x) ?- remdup([3,1,2,31,x) X=[1, 2, 3]. Note that the order of items in List2 is unspecified: for instance, [3,1,2 is an acceptable result for the second example above. 4. 2 marks Consider a course...

  • 1. A mathematics professor believes that the performance of students taking an elementary calculus course has declined in recent years. The professor decides to reuse a final exam that was first admin...

    1. A mathematics professor believes that the performance of students taking an elementary calculus course has declined in recent years. The professor decides to reuse a final exam that was first administered 10 years ago. At that time the mean score was 81 with s=10, for the 50 students in the section taught by that professor When given to the current class of 53 students, who observed essentially the same set of lectures, the mean is 75 with s=15. If...

  • 1. For your family (or any other real or hypothetical family) write a PROLOG program "family.pro"...

    1. For your family (or any other real or hypothetical family) write a PROLOG program "family.pro" that is based on the following facts: - is male (NAME). is female (NAME). is_parent_of (PARENT, CHILD ). e.g. e.g. e.g. is_male (tom). is_female (ann). is_parent_of (ann, tom). Add to these facts the following inference rules: - mother (MOTHER, CHILD) - father (FATHER, CHILD) sibling1 (NAME1, NAME2) brotheri (NAME1, NAME2) sisteri (NAME1, NAME2) (1 parent in common) (1 parent in common) (1 parent in...

  • In Professor Friedman's economics course the correlation between the students' total scores before the final examination...

    In Professor Friedman's economics course the correlation between the students' total scores before the final examination and their final examination scores is r = 0.66. The pre-exam totals for all students in the course have mean 265 and standard deviation 39. The final exam scores have mean 90 and standard deviation 11. Professor Friedman has lost Julie's final exam but knows that her total before the exam was 320. He decides to predict Julie's final exam score from her pre-exam...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT