In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction.

Slides:



Advertisements
Similar presentations
Artificial Intelligence: Natural Language and Prolog
Advertisements

© Patrick Blackburn, Johan Bos & Kristina Striegnitz Lecture 10: Cuts and Negation Theory –Explain how to control Prolog`s backtracking behaviour with.
AI/ES (Artificial Intelligence / Expert System) Visual Prolog: Part 2
Some Prolog Prolog is a logic programming language
Chapter 11 :: Logic Languages
LING 388: Language and Computers Sandiway Fong Lecture 5: 9/5.
Introduction to Prolog, cont’d Lecturer: Xinming (Simon) Ou CIS 505: Programming Languages Fall 2010 Kansas State University 1.
Prolog The language of logic. History Kowalski: late 60’s Logician who showed logical proof can support computation. Colmerauer: early 70’s Developed.
1 Introduction to Prolog References: – – Bratko, I., Prolog Programming.
CS 330 Programming Languages 12 / 02 / 2008 Instructor: Michael Eckmann.
MB: 2 March 2001CS360 Lecture 31 Programming in Logic: Prolog Prolog’s Declarative & Procedural Semantics Readings: Sections
CSE 425: Logic Programming I Logic and Programs Most programs use Boolean expressions over data Logic statements can express program semantics –I.e., axiomatic.
CS 330 Programming Languages 12 / 12 / 2006 Instructor: Michael Eckmann.
For Friday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 27: Prolog’s Resolution and Programming Techniques COMP 144 Programming Language.
LING 388 Language and Computers Lecture 2 9/04/03 Sandiway FONG.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Formal Aspects of Computer Science – Week 12 RECAP Lee McCluskey, room 2/07
(9.1) COEN Logic Programming  Logic programming and predicate calculus  Prolog statements  Facts and rules  Matching  Subgoals and backtracking.
DEDUCTIVE DATABASE.
Sequence Control Chapter 6. 2 l Control structures: the basic framework within which operations and data are combined into programs. Sequence control.
Formal Models of Computation Part II The Logic Model
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
1 Lecture 15: Introduction to Logic Programming with Prolog (Section 11.3) A modification of slides developed by Felix Hernandez-Campos at UNC Chapel Hill.
CS 403: Programming Languages Lecture 19 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
14/10/04 AIPP Lecture 7: The Cut1 Controlling Backtracking: The Cut Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 7 14/10/04.
30/09/04 AIPP Lecture 3: Recursion, Structures, and Lists1 Recursion, Structures, and Lists Artificial Intelligence Programming in Prolog Lecturer: Tim.
Getting Started with Visual Prolog
Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search.
For Wednesday Read “lectures” 7-10 of Learn Prolog Now Chapter 9, exs 4 and 6. –6 must be in Horn clause form Prolog Handout 2.
Introduction Prolog program consists of clauses which are facts and rules. Predicate is the name given to the relation likes(bill, tennis) predicate name.
1 Knowledge Based Systems (CM0377) Lecture 3 (Last modified 5th February 2001)
CT214 – Logical Foundations of Computing Lecture 8 Introduction to Prolog.
Programming Languages. A Logic Programming Language: Prolog This lesson describes the basic structures and functions of the logic programming language:
Programming Languages Tucker and Noonan – 2e Chapter 15 – Part 1 Logic Programming “Q: How many legs does a dog have if you call its tail a leg? A: Four.
CS4026 Formal Models of Computation Part II The Logic Model Lecture 2 – Prolog: History and Introduction.
Prolog Kyle Marcotte. Outline What is Prolog? Origins of Prolog (History) Basic Tutorial TEST!!! (sort of…actually not really at all) My example Why Prolog?
Logic Programming CSC 358/ Outline Pattern matching Unification Logic programming.
Lecture 9b: Prolog Heshaam Faili University of Tehran The language of logic Concepts Examples.
Prolog Program Style (ch. 8) Many style issues are applicable to any program in any language. Many style issues are applicable to any program in any language.
The AI War LISP and Prolog Basic Concepts of Logic Programming
Rules Statements about objects and their relationships Expess ◦ If-then conditions  I use an umbrella if there is a rain  use(i, umbrella) :- occur(rain).
Logic Programming Languages Session 13 Course : T Programming Language Concept Year : February 2011.
Logic Programming and Prolog Goal: use formalism of first-order logic Output described by logical formula (theorem) Input described by set of formulae.
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
Lab Lecture#4 Lecturer : Sheriff Nafisa TA : Mubarakah Otbi, Duaa al Ofi, Huda al Hakami.
Introduction to Prolog. Outline What is Prolog? Prolog basics Prolog Demo Syntax: –Atoms and Variables –Complex Terms –Facts & Queries –Rules Examples.
© Kenneth C. Louden, Chapter 12 - Logic Programming Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
Logic Programming Dr. Yasser Nada Fall 2010/2011 Lecture 1 1 Logic Programming.
Logic Programming Tarik Booker. What will we cover?  Introduction  Definitions  Predicate Calculus  Prolog  Applications.
For Friday No reading Prolog Handout 2. Homework.
Prolog 3 Tests and Backtracking 1. Arithmetic Operators Operators for arithmetic and value comparisons are built-in to Prolog = always accessible / don’t.
07/10/04 AIPP Lecture 5: List Processing1 List Processing Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 5 07/10/04.
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
Prolog Fundamentals. 2 Review Last Lecture A Prolog program consists of a database of facts and rules, and queries (questions). –Fact:.... –Rule:... :-....
Copyright 1999Paul F. Reynolds, Jr. Foundations of Logic Programming.
Logic Programming Lecture 2: Unification and proof search.
The portion of a Prolog interpreter that executes queries (goals) is known as the inference engine. An inference engine is a kind of theorem prover, using.
Section 16.5, 16.6 plus other references
Prolog a declarative language
Prolog Concepts.
Tests, Backtracking, and Recursion
Prolog a declarative language
Prolog a declarative language
Prolog a declarative language
SECTION 2-4 : SOLVING EQUATIONS WITH THE VARIABLE ON BOTH SIDES
Relational Operators.
Prolog Concepts.
Prolog Concepts.
Presentation transcript:

In The Name Of Allah Lab 03 1Tahani Aldweesh

objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction. Conjunction. 2Tahani Aldweesh

Searching for the solution’s Consider the query : is there a person who likes both reading and swimming? 3Tahani Aldweesh

cont Likes(Person, reading) likes(Person, Swimming). The solution are found through searching, matching and backtracking. 4Tahani Aldweesh

Declaration in visual prolog Predicate and their argument must be declared. They are declared in predicate section. Clauses for the predicate are given in clauses section. Dynamic facts can be given in the facts section. Execution starts in the Goal section. 5Tahani Aldweesh

Query: true / false In natural language we ask you : Does Bill Like Cindy? In prolog syntax, we ask prolog : Likes(bill, cindy). Given this query, prolog would answer : Yes. 6Tahani Aldweesh

Queries : getting answers We could ask you in natural language : What does bill like ? In prolog syntax, we ask prolog : Likes ( bill, What). Prolog will return : What=cindy What=dog 2 Solutions 7Tahani Aldweesh

Examples 8Tahani Aldweesh

Using Underscore as a variable The anonymous can be used in place of any other variable. The difference is that the anonymous variable will never get set to value : GOAL Parent(Parent, _ ). But it can also be used in facts! owns(_, shoes). GOAL owns(bill,shoes). GOAL owns(gane,shoes). 9Tahani Aldweesh

Comments 10Tahani Aldweesh

Prolog Concepts Unification : passing parameter,dealing with assignment, Case selection,etc. Search principle: Searching for success (or failure). Top-down, right to left. Backtracking : Providing multiple solutions. Non-determisme, determinism and cut. Recursion. 11Tahani Aldweesh

Unification Unification is performed when a goal or sub-goal Is matched against a suitable fact or left hand side of rule. Unification is made between : The 1 st parameter in the goal (sub-goal). And 1 st parameter in fact/rule-head. “=“ means Unification. 12Tahani Aldweesh

Unification and matching Identical values match each other: Parent(joe,tammy)matches parent(joe,tammy). A free variable can match with any value: Parent(joe, X)matches parent(joe,tammy). A bound variable matched only with it is bound to : X=tammy, Parent(joe,X)matches parent(joe,tammy). Two free variable s unifies each other: Parent(joe,X)matches parent(joe,Y). 13Tahani Aldweesh

Unification Examples 14Tahani Aldweesh

Unification and calculation Visual Prolog support the most know used mathematical functions. They can be tried out by : Unifying a free variable with various calculation,for example: GOAL X=sqrt(4)*7+1 Visual Prolog support logical expressions like: GOAL not(2<=4). 15Tahani Aldweesh

Disjunction “or” – “;” 16Tahani Aldweesh

Conjunction “and” – “,” 17Tahani Aldweesh

Steps for create new project 1)- Open prolog program. 2)- project  new Tahani Aldweesh18

Tahani Aldweesh19 3)- Build  Build. 4)- Build  Execute. 5)- Look at the project tree a file is created named “same name your proj.pro”, double click on it and put your code.

Tahani Aldweesh20 Double click Class Facts Class Predicates Run Statement

Application in this lecture Tahani Aldweesh21

Execute the program Tahani Aldweesh22

Any Question 23Tahani Aldweesh

24Tahani Aldweesh