Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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

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

Students also viewed these Databases questions