Question: LAB-02: Prolog Programming Concepts Objectives: - Introduction to Predicates and Queries (Goals). - Practice how to apply querier (with/without variables) and compound queries in prolog.

 LAB-02: Prolog Programming Concepts Objectives: - Introduction to Predicates and Queries(Goals). - Practice how to apply querier (with/without variables) and compound queriesin prolog. - Explains how to use compound queries with multiple variables,Facts containing variables and Rules in prolog. Lab Outcomes: Students should get

LAB-02: Prolog Programming Concepts Objectives: - Introduction to Predicates and Queries (Goals). - Practice how to apply querier (with/without variables) and compound queries in prolog. - Explains how to use compound queries with multiple variables, Facts containing variables and Rules in prolog. Lab Outcomes: Students should get familiar with: - How to write prolog program - How to execute compound prolog queries - How to execute compound queries with multiple variables - Facts containing variables - Rules in prolog with suitable examples Lab Requirements - SWISH-Prolog offers a comprehensive free Prolog environment . - Visual PROLOG (optional) - Uploaded in blackboard VProlog 6. Also you can download the latest version from: https://www.visual-prolog.com/download.htm To represent the "likes" facts: likes (ali,football). likes (ali,tennis). likes (ahmad,tennis). likes (ahmad,handball). likes (samir,handball). likes (samir,swimming). likes (khaled,horseriding). Queries with variables: - To know all sports that Ali likes: likes (ali, What). Or likes (ali, X).X is a variable. - To know which person likes tenis: likes (Who,tennis). - To know who likes what (i.e all likes facts) likes (Who, What). Or likes (X,Y). where X is "Who" and Y is "What". Variable must be in upper case or first letter of variable must be in upper case. Compound queries with one variable: - To list persons who like tennis and football, the goal will be likes(Person, tennis), likes (Person, football). - To list games liked by ali and ahmad. likes (ali,Game), likes (ahmad, Game). Compound queries with two variable: - To find persons who like more than one game: likes(Person, G1), likes (Person, G2), not(G1==G32). - To find games liked by more than one person: likes(P1,Game), likes(P2,Game), P1 P2. Facts containing variables: Assume we add the drinks facts to the likes database as follows: drinks (ali, pepsi). drinks (samir, lemonada). drinks (ahmad, milk). - To add the fact that all persons drink water: drinks (Everyone, water). 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: (Here P1 and P2 are friends, due to P1 and P2 likes the same Game.) Extra (supplementary) Materials Prolog Programming for artificial Intelligence by Ivan Bratko, 4th edition - chapter 1&2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To enhance the initial answer with more detail heres a revised version Introduction to Prolog Programming Concepts Prolog is a logic programming langu... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!