Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need this in prolog pleaase: Objective This lab explains how to use compound queries with multiple variables, Facts containing variables and Rules in prolog

I need this in prolog pleaase:

image text in transcribedimage text in transcribedimage text in transcribed

Objective This lab explains how to use compound queries with multiple variables, Facts containing variables and Rules in prolog Current Lab Learning Outcomes (LLO) Students should get familiar with: How to execute Compound queries with multiple variables Facts containing variables Rules in prolog with suitable examples Outline Compound queries with multiple variables Facts containing variables Rules Examples Exercise Lab Requirements PROLOG Lab Description Compound queries with multiple variables: To find persons who like more than one game: likes (Person, G1), likes (Person, G2), GIG2. To find games liked by more than one person: likes (P1,Game), likes(P2,Game), P1P2. Facts containing variables: Assume we add the drinks facts to the likes database as follows: PREDICATES drinks (symbol, symbol) CLAUSES drinks (ali, pepsi). drinks (samir, lemonada). drinks (ahmad, milk). To add the fact that all persons drink water: drinks (Everyone, water). + If we put a goal like: drinks (samy, water) The answer will be: yes drinks (ahmad, water) X 0 Visual Prolog Licensed to Javier Enriquez File Edit Project Purchase Web Options Window Help @OROG F Indent noname.pro 11:22 Insert PREDICATES drinks (ymool, symbol) CLAUSES drinka (ali, pepsi). drinks (aarir, lemonada). drinks (ahrrad, nill). online drinka (Everyone, water). Buy VISA GOAL drinka (aamy, water). Output: X Inactive C:\Users Shuaib AppData\LocalTempgoal000.exe] yes Rules: Rules are used to infer new facts from existing ones. A rule consists of two parts: head and body separated by the symbol :-.. To represent the rule that expresses the facts that two persons are friends if they both like the same game: friends (P1.P2):- likes (P1,G), likes (P2, G), P1P2. (Here P1 and P2 are friends, due to P1 and P2 likes the Body of the rule Lab Assessinent Exercise: 1) Declare your own predicates, clauses and write a complete prolog program to implement the rule given below. friends (P1.P2):- likes (P1,G), likes (P2,G), P1P2. (Hint: find all friends.) 2) Assume the following "likes" facts knowledge base likes (ali, football). likes (ali, tennis). likes (ahmad, tennis). likes (ahmad, handball). likes (samir, handball). likes (samir, swimming). likes (khaled, horseriding). Find all the people who like more than one game. Solution...??? Objective This lab explains how to use compound queries with multiple variables, Facts containing variables and Rules in prolog Current Lab Learning Outcomes (LLO) Students should get familiar with: How to execute Compound queries with multiple variables Facts containing variables Rules in prolog with suitable examples Outline Compound queries with multiple variables Facts containing variables Rules Examples Exercise Lab Requirements PROLOG Lab Description Compound queries with multiple variables: To find persons who like more than one game: likes (Person, G1), likes (Person, G2), GIG2. To find games liked by more than one person: likes (P1,Game), likes(P2,Game), P1P2. Facts containing variables: Assume we add the drinks facts to the likes database as follows: PREDICATES drinks (symbol, symbol) CLAUSES drinks (ali, pepsi). drinks (samir, lemonada). drinks (ahmad, milk). To add the fact that all persons drink water: drinks (Everyone, water). + If we put a goal like: drinks (samy, water) The answer will be: yes drinks (ahmad, water) X 0 Visual Prolog Licensed to Javier Enriquez File Edit Project Purchase Web Options Window Help @OROG F Indent noname.pro 11:22 Insert PREDICATES drinks (ymool, symbol) CLAUSES drinka (ali, pepsi). drinks (aarir, lemonada). drinks (ahrrad, nill). online drinka (Everyone, water). Buy VISA GOAL drinka (aamy, water). Output: X Inactive C:\Users Shuaib AppData\LocalTempgoal000.exe] yes Rules: Rules are used to infer new facts from existing ones. A rule consists of two parts: head and body separated by the symbol :-.. To represent the rule that expresses the facts that two persons are friends if they both like the same game: friends (P1.P2):- likes (P1,G), likes (P2, G), P1P2. (Here P1 and P2 are friends, due to P1 and P2 likes the Body of the rule Lab Assessinent Exercise: 1) Declare your own predicates, clauses and write a complete prolog program to implement the rule given below. friends (P1.P2):- likes (P1,G), likes (P2,G), P1P2. (Hint: find all friends.) 2) Assume the following "likes" facts knowledge base likes (ali, football). likes (ali, tennis). likes (ahmad, tennis). likes (ahmad, handball). likes (samir, handball). likes (samir, swimming). likes (khaled, horseriding). Find all the people who like more than one game. Solution

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

Students also viewed these Databases questions