علمتني الثلوج أن أكون كبياض الثلج لا يحمل قلبي غير الحب والعطف والرحمة لا أسيئ الظن بالأخرين ولا أحكم عليهم من مظهرهم فإذا لم تعاشرهم فأنت تجهلهم !

Slides:



Advertisements
Similar presentations
© Johan Bos Logic Programming About the course –Taught in English –Tuesday: mostly theory –Thursday: practical work [lab] Teaching material –Learn Prolog.
Advertisements

Chapter 3: Lists, Operators, Arithmetic Part 1. Outline Representation of lists Some operations in lists Operator notation Arithmetic.
Logic Programming Lecture 1: Getting started. Getting started We’ll use SICStus Prolog Free for UofE students Available on all DICE machines
Lecturer: Dr. Abeer Mahmoud Logic Programming in Prolog.
Lecturer: Dr. Abeer Mahmoud Logic Programming in Prolog.
Prolog.
Introduction to PROLOG ME 409 Lab - 1. Introduction to PROLOG.
LING 388: Language and Computers Sandiway Fong Lecture 5: 9/8.
1 Logic Programming. 2 A little bit of Prolog Objects and relations between objects Facts and rules. Upper case are variables. parent(pam, bob).parent(tom,bob).
2. Syntax and Meaning. Contents Data Objects Matching Declarative meaning of Prolog Procedural meaning Example: monkey and banana Order of clauses and.
About prolog  History  Symbolic Programming Language  Logic Programming Language  Declarative Programming Language.
For Friday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
C Programming Language 4 Developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories 4 Used to rewrite the UNIX operating system 4 Widely used on UNIX.
© Patrick Blackburn, Johan Bos & Kristina Striegnitz Logic Programming About the course –Taught in English –Tuesday: mostly theory –Thursday: practical.
© Patrick Blackburn, Johan Bos & Kristina Striegnitz Lecture 2 Theory –Unification –Unification in Prolog –Proof search Exercises –Correction exercises.
Discrete Math Lecture 5: Counting
PROLOG KAIST Gunwoo Park 1. What’s Prolog? 2  General purpose logic programming language  Declarative, which means that the program logic is.
Formal Models of Computation Part II The Logic Model
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
CSC 270 – Survey of Programming Languages Prolog Lecture 1 – Facts, Rules, and Queries.
1 Visual Prolog Programs LabLecture # 3 Lecturer : Sheriff Nafisa TA : Mubarakah Otbi, Duaa al Ofi, Huda al Hakami.
Agile Software Development Lab 2008 Dr. Günter Kniesel, Daniel Speicher, Tobias Rho, Pascal Bihler Spring 2008 R O O T S Prolog - Part 1 Alexis Raptarchis.
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
30/09/04 AIPP Lecture 3: Recursion, Structures, and Lists1 Recursion, Structures, and Lists Artificial Intelligence Programming in Prolog Lecturer: Tim.
ARTIFICIAL INTELLIGENCE Lecture 3 Predicate Calculus.
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.
CSC 270 – Survey of Programming Languages Prolog Lecture 2 – Unification and Proof Search.
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:
CS346 Javascript -3 Module 3 JavaScript Variables.
PROLOG SYNTAX AND MEANING Ivan Bratko University of Ljubljana Faculty of Computer and Info. Sc. Ljubljana, Slovenia.
1 homework Due today: hw #1 (mailing list printout) readings to date: chapter 1 and chapter read appendix B (3 pages on DOS) and and.
By: Cory Canter CSC 415 Programming Languages. History  Created by Alain Colmerauer, Phillipe Roussel and Robert Kowalski in 1971  Started as a natural.
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).
Introduction to Prolog. Outline What is Prolog? Prolog basics Prolog Demo Syntax: –Atoms and Variables –Complex Terms –Facts & Queries –Rules Examples.
Introduction to Prolog
Introduction to Prolog © Patrick Blackburn, Johan Bos & Kristina Striegnitz.
1 Knowledge Based Systems (CM0377) Lecture 6 (last modified 20th February 2002)
Introduction to Objective Caml. General comments ML is a purely functional language--there are (almost) no side effects There are two basic dialects of.
Programming Language Concepts Lecture 17 Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Logic Programming.
Knowledge Based Information System
Artificial Intelligence CS370D
C H A P T E R N I N E Logic Programming Part 2 Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
Prolog Fundamentals. 2 Review Last Lecture A Prolog program consists of a database of facts and rules, and queries (questions). –Fact:.... –Rule:... :-....
A Sample Program #include using namespace std; int main(void) { cout
Instructor :Bayan Ghozlan الاستاذه : بيان غزلان.  البرولوغ Prolog هي لغة برمجة منطقية. وتعني برمجه المنطق programing language  تم اختراع اللغة بواسطة.
1 Artificial Intelligence CS370D Prolog programming Declarative meaning of Prolog programs and Lists representation.
Lesson 4 String Manipulation. Lesson 4 In many applications you will need to do some kind of manipulation or parsing of strings, whether you are Attempting.
Pengenalan Prolog Disampaikan Oleh : Yusuf Nurrachman, ST, MMSI.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
Section 16.5, 16.6 plus other references
Chapter 6 JavaScript: Introduction to Scripting
For Friday No reading Prolog handout 3 Chapter 9, exercises 9-11.
For Wednesday Read “lectures” 7-10 of Learn Prolog Now:
Variables and Primative Types
PROLOG.
Prolog programming Introduction to Prolog (part2)
Please use speaker notes for additional information!
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
CEV208 Computer Programming
Chapter Two: Syntax and Meaning of Prolog Programs
Introduction to Prolog
Chapter 2: Introduction to C++.
Notes on SQL This slide show will introduce SQL using Access. It assumes only an introductory level of knowledge about Access.
Introduction to PROLOG
Lexical Elements & Operators
Introduction to MATLAB
Representations & Reasoning Systems (RRS) (2.2)
PROLOG.
Function Notation.
Presentation transcript:

علمتني الثلوج أن أكون كبياض الثلج لا يحمل قلبي غير الحب والعطف والرحمة لا أسيئ الظن بالأخرين ولا أحكم عليهم من مظهرهم فإذا لم تعاشرهم فأنت تجهلهم !

الذكاء الاصطناعي Artificial Intelligence ( AI) comp323 Lab (2)

Knowledge Base 3 happy(vincent). listensToMusic(butch). playsAirGuitar(vincent):- listensToMusic(vincent), happy(vincent). playsAirGuitar(butch):- happy(butch). playsAirGuitar(butch):- listensToMusic(butch). how many clauses in the KB3 ? What does this rule mean?

if we posed the query ?- playsAirGuitar(vincent). ?- playsAirGuitar(butch).

playsAirGuitar(butch):- happy(butch). playsAirGuitar(butch):- listensToMusic(butch). We could replace the pair of rules given above by the single rule playsAirGuitar(butch):- happy(butch); listensToMusic(butch).

Knowledge Base 4 woman(mia). woman(jody). woman(yolanda). loves(vincent,mia). loves(marcellus,mia). loves(pumpkin,honey_bunny). loves(honey_bunny,pumpkin).

for the first time we’re going to make use of variables ?- woman(X).

Let’s try a more complicated query, namely ?- loves(marcellus,X),woman(X).

Knowledge Base 5 loves(vincent,mia). loves(marcellus,mia). loves(pumpkin,honey_bunny). loves(honey_bunny,pumpkin). jealous(X,Y) :- loves(X,Z),loves(Y,Z).

Suppose we pose the query: ?- jealous(marcellus,W).

Prolog Syntax what are facts, rules, and queries built out of? The answer is terms, and there are four kinds of terms in Prolog: atoms, numbers, variables, and complex terms (or structures). Atoms and numbers are lumped together under the heading constants, and constants and variables together make up the simple terms of Prolog.

Atoms 1. A string of characters made up of upper-case letters, lower-case letters, digits, and the underscore character, that begins with a lower- case letter. For example: butch, big_kahuna_burger, and m_monroe2.

Atoms 2. An arbitrary sequence of character enclosed in single quotes. For example ’Vincent’, ’The Gimp’, ’Five_Dollar_Shake’, &*’, and ’ ’. The character between the single quotes is called the atom name.

Atoms 3. A string of special characters. For and ====> and ; and :- are all atoms. As we have seen, some of these atoms, such as ; and :- have a pre-defined meaning

Numbers integers (that is:... -2, -1, 0, 1, 2, 3,...) are useful for such tasks as counting the elements of a list

Variables A variable is a string of upper-case letters, lower-case letters, digits and underscore characters that starts either with an upper- case letter or with underscore. For example, X, Y, Variable, _tag, X_526, and List, List24, _head, Tail, _input and Output are all Prolog variables.

Complex terms Complex terms are build out of a functor followed by a sequence of arguments. The arguments are put in ordinary brackets, separated by commas, and placed after the functor. The functor must be an atom. That is, variables cannot be used as functors. On the other hand, arguments can be any kind of term.

For example, playsAirGuitar(jody) its functor is playsAirGuitar and its argument is jody The number of arguments that a complex term has is called its arity

arity Arity is important to Prolog. Prolog would be quite happy for us to define two predicates with the same functor but with a different number of arguments

it is usual to use a suffix / followed by a number to indicate the predicate’s arity To return to KB2 listensToMusic/1 happy/1 playsAirGuitar/1

Practical Session 1 ?- listing. command is to display the contents of the current knowledge base ?- listing(playsAirGuitar).

References Prolog note

H.W ( group ) Exercise 1.1 – 1,2,3,6,9 Exercise 1.2 – 1,2,3 Exercise 1.3 Exercise 1.4 – 2,3 Exercise 1.5 – 2,5,7