Question

In: Computer Science

• Write a complete prolog with your own facts using the relation: – Like(Person,Food). • Define...

• Write a complete prolog with your own facts using the relation: – Like(Person,Food).

• Define the following rule: –

Two persons are friends if they like the same food.

• Now find:

– All people who like more than one food.

– All food liked by two people – All friends

• likes(sarah, pizza).

• likes(sarah, saleeg)

. • likes(sarah, bread)

. • likes(farah, rice).

• likes(rana, burger)

. • likes(rana, saleeg).

Solutions

Expert Solution

Given relation is

likes(Person, Food). it can be read as "Person likes Food".

For example: If the given fact for given relation is "likes(sarah, pizza)." then it means that sarah likes pizza.

Rule for "Two persons are friends if they like the same food." will be

friends(Person1, Person2) :- likes (Person1, Food), likes (Person2, Food).

It means Person1 and Person2 both are friends if Person1 like Food and Person2 likes the same Food.

Given facts are:

  • likes(sarah, pizza).
  • likes(sarah, saleeg).
  • likes(sarah, bread).
  • likes(farah, rice).
  • likes(rana, burger).
  • likes(rana, saleeg).

In the given facts there are three Person: sarah, farah and rana

and there are 5 types of Food: pizza, saleeg, bread, rice and burger

From the given facts we can say that

  1. sarah likes pizza, saleeg and bread.
  2. farah likes rice.
  3. rana likes burger, saleeg.

– All people who like more than one food: sarah, rana.

– All food liked by two people: saleeg.

– All friends: As sarah and rana have a common food saleeg. So, sarah and rana are friends.

If you're still having any doubt then please feel free to ask in the comment section.


Related Solutions

`DIRECTIONS: Write an answer to each question legible, using complete sentences and your own words as...
`DIRECTIONS: Write an answer to each question legible, using complete sentences and your own words as much as possible. 6.           What information is needed to directly determine the range of a projectile without using the equations of uniformly accelerated motion? 7.           At what point in its motion does an ideal projectile stop accelerating? 8.           Do two projectiles launched at complementary angles always yield the same range? Explain. 9.           When someone says that all measurement of motion is relative, what is...
Can you write in your own words a few paragraphs that desbribe how the trade relation...
Can you write in your own words a few paragraphs that desbribe how the trade relation between China and The United States has affected a specific company in the past or present?
Using a simple relation of your own choice and example, explain Entity Integrity and Referential Integrity.
Using a simple relation of your own choice and example, explain Entity Integrity and Referential Integrity.
Solve the below questions using your own words PLEASE!! Make sure to write by your own...
Solve the below questions using your own words PLEASE!! Make sure to write by your own words or paraphrase 1. What is the difference between Windows and Linux server 2. Give some advantages and disadvantages Windows and Linux Operating System
In your own word please explain and write in complete sentences. 1. What is diabetes and...
In your own word please explain and write in complete sentences. 1. What is diabetes and what causes it? 2. List and explain the different types of diabetes. 3. How do you care for diabetes? 4. Explain what causes a person to faint?
you can discuss ""religion and society "in your own words? please write whatever, using your own...
you can discuss ""religion and society "in your own words? please write whatever, using your own idea, any idea of ​​yours will be correct! 1 page
in your own words Define ideal partner profile in business and write the importance of Ideal...
in your own words Define ideal partner profile in business and write the importance of Ideal partner profile
As an ENTREPRENEUR, write a business plan of your own company using the components of a...
As an ENTREPRENEUR, write a business plan of your own company using the components of a business plan.
// ==== Challenge 1: Write your own closure ==== // Write a closure of your own...
// ==== Challenge 1: Write your own closure ==== // Write a closure of your own creation. // Keep it simple! Remember a closure is just a function // that manipulates variables defined in the outer scope. // The outer scope can be a parent function, or the top level of the script. /* STRETCH PROBLEMS, Do not attempt until you have completed all previous tasks for today's project files */ // ==== Challenge 2: Implement a "counter maker" function...
In your own word please explain and write in complete sentences. How do you care for...
In your own word please explain and write in complete sentences. How do you care for bleeding injury? What is shock? How do you care for it? What is asthma? How do you care for it? What is anaphylaxis? How do you care for it?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT