Logic Programming Dr. Yasser Nada Fall 2010/2011 Lecture 1 1 Logic Programming.

Slides:



Advertisements
Similar presentations
Getting started with Prolog
Advertisements

Logic Programming Lecture 1: Course orientation; Getting started with Prolog.
Logic Programming Lecture 1: Getting started. Getting started We’ll use SICStus Prolog Free for UofE students Available on all DICE machines
Software Development Languages and Environments. Programming languages High level languages are problem orientated contain many English words are easier.
Prolog.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
Lecture 2 Introduction to C Programming
Introduction to C Programming
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
CSE Spring 2015 INTERMEDIATE PROGRAMMING
For Friday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
CPSC 322, Lecture 23Slide 1 Logic: TD as search, Datalog (variables) Computer Science cpsc322, Lecture 23 (Textbook Chpt 5.2 & some basic concepts from.
CPSC 322, Lecture 23Slide 1 Logic: TD as search, Datalog (variables) Computer Science cpsc322, Lecture 23 (Textbook Chpt 5.2 & some basic concepts from.
CS 331 / CMPE 334 – Intro to AI CS 531 / CMPE AI Course Outline.
Alternative Programming Paradigms
COP4020/CGS5426 Programming languages Syllabus. Instructor Xin Yuan Office: 168 LOV Office hours: T, H 10:00am – 11:30am Class website:
New experiences with teaching Java as a second programming language Ioan Jurca “Politehnica” University of Timisoara/Romania
Introducing Java.
DEDUCTIVE DATABASE.
1 Software Development Topic 2 Software Development Languages and Environments.
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.
CSc 2310 Principles of Programming (Java) Dr. Xiaolin Hu.
Logic Programming Programming Lecture 1: Getting started with Prolog.
Expert System Development Tools Sean Lydon Daniel Nelson Emily Schwarz.
1 Software Systems Development CEN Spring 2011 TR 12:30 PM – 1:45 PM ENB 116 Instructor:Dr. Rollins Turner Dept. of Computer Science and Engineering.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
CS 140 Computer Programming (I) Second semester (3 credits) Imam Mohammad bin Saud Islamic University College of Computer Science and Information.
F28PL1 Programming Languages Lecture 16: Prolog 1.
Introduction to Data Structures
Artificial Intelligence Programming in Prolog Lecture 1: An Introduction 23/09/04.
Artificial Intelligence LECTURE 2 ARTIFICIAL INTELLIGENCE LECTURES BY ENGR. QAZI ZIA 1.
Course Objectives Discuss fundamental concepts of information technology Show how computers are used as practical tools for solving personal, business,
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
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.
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:
Logical and Functional Programming
Introduction to Prolog. Outline What is Prolog? Prolog basics Prolog Demo Syntax: –Atoms and Variables –Complex Terms –Facts & Queries –Rules Examples.
CS 337 Programming Languages Logic Programming I (Logic, Intro to Prolog)
Logic Programming Dr. Yasser Ahmed Nada Fall 2010/2011 Lecture 2 1 Logic Programming.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
Knowledge Based Information System
Dr. Sajib Datta CSE Spring 2016 INTERMEDIATE PROGRAMMING.
In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction.
Artificial Intelligence CIS 342 The College of Saint Rose David Goldschmidt, Ph.D.
For Friday No reading Prolog Handout 2. Homework.
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
COP4020 INTRODUCTION FALL COURSE DESCRIPTION Programming Languages introduces the fundamentals of the design and implementation of programming languages.
Dr. Sajib Datta Jan 15,  Instructor: Sajib Datta ◦ Office Location: ERB 336 ◦ Address: ◦ Web Site:
Logic Programming Logic programming Candidates should be familiar with the concept of logic programming for declaring logical relationships.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Introduction to Artificial Intelligence Heshaam Faili University of Tehran.
CS101 Computer Programming I
CSc 1302 Principles of Computer Science II
Chapter 2 - Introduction to C Programming
CSC 135 section 60 or CSC Fall 2017.
For Friday No reading Prolog handout 3 Chapter 9, exercises 9-11.
For Wednesday Read “lectures” 7-10 of Learn Prolog Now:
CS 326 Programming Languages, Concepts and Implementation
PROLOG.
Artificial Intelligence (CS 461D)
Artificial Intelligence (CS 370D)
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Dr. Yasser Nada Fall 2010/2011 Lecture 1
Chapter 2 - Introduction to C Programming
Chapter 2: Prolog (Introduction and Basic Concepts)
Presentation transcript:

Logic Programming Dr. Yasser Nada Fall 2010/2011 Lecture 1 1 Logic Programming

Text Book Prolog Programming, A First Course, by Paula Brna, 2001 References: – Leon Starling and Ehud Shapiro, The art of Prolog – Ivan Brotko, Prolog Programming for Artificial Intelligence Logic Programming

Course Description This course will introduce the theory and concepts of logic programming. Prolog will be studied as a logic programming approach for declarative logic programming. 3 Logic Programming

Course Objectives Upon completion of the course, student should: – Knowledge of concepts and theories of logic programming. – Become familiar with Prolog language syntax. – Be able to solve problems in Prolog. – Be able to use knowledge in a suitable form to be used in Prolog language.. 4 Logic Programming

Course Policy Students are expected to participate and attend the class in time. Students are responsible to submit assignments in time. Exams will be a combination of lectures in class and homework assignments. Late homework submission will be subject to penalties. If an assignment is submitted late, a penalty of 10 percent of that assignment's grade will be assessed for each day it is late. A homework paper will not be accepted after graded papers have been returned, after a solution has been distributed, or after the final examination. 5 Logic Programming

Absence Policy Students absent that exceeds (25% lectures) are being considered dropped from the course. After 3 lectures absent a warning is issued for the student. After another 3 lectures absent student will be dropped from the class. 6 Logic Programming

Examination There will be no makeup exams except under emergencies. If a student cannot attend the exam, then student must make arrangement with the instructor prior to the planned absence. The emergency makeup exam will be either written or oral. 7 Logic Programming

Grading 8 Logic Programming Assignment10% Attendance10% Midterm30% Final50%

9 Logic Programming

What is Logic Programming Two types of programming languages: – Imperative languages (C, C++, VB, C#, Java, …). – Declarative languages (prolog, lisp, …). Logic programming is a type of programming called declarative programming. 10 Logic Programming

Imperative Languages They are also called procedural languages. Programmer gives all steps to solve a problem. He must know an algorithm to solve a problem. Example: find average of list of numbers: Input total Input number Average = total/number Print Average 11 Logic Programming

Declarative Languages Programmer describe the problem without the control flow, then the system will solve the problem. Programmer must know the relations between objects to solve the problem. Programmer does not need to know an algorithm to solve the problem. Declarative languages consists of: – Program or theory. – Computation which is deduction. 12 Logic Programming

First Order Predicate Represent relation between objects: own(ahmed, car). friend(ali, ahmed). father(sami, ali). brother(kareem, ali). 13 Logic Programming

It is a declarative language (not completely declarative) based on first order logic. Prolog means Programming in Logic. It consists of: – Facts. – Rules. – Goal Used in AI: NLP, expert systems, games, automated answering system, …. 14 Prolog Logic Programming

Prolog Program consist of: – Facts: asserts a property to an object, or relation between two or more objects: parent(ali, salem). own(ali, car). – Rules: allow to infer a relationship or a property based on a precondition: parent(X,Y) :- father(F,X), father(P,Y). – Goal: Query or questions asked by user. parent(ali, Y). 15 Prolog Logic Programming

Atom is – a sequence of alphanumeric characters – usually starting with lower case letter – or, a string enclosed in single quotes – They represent constants. Examples: – ali, salem, a, b, c, a1, a2, b3, c5, … – ‘Mr. Ali’, ’Dr. Sultan’ 16 Atoms Logic Programming

A variable is a sequence of alphanumeric characters usually starting with an uppercase letter Examples: X, Y, Z, Parent, Child, Foo, X1, Y1, X2, X5, X6, …. 17 Variables Logic Programming

A predicate has the form – p(t1,...,tn) – where p is an atom and t1...tn are variables or atoms. – n is the number of arguments of predicate p (written as p/n which represents the signature of predicate). – Predicates can be of 0-arg, 1-arg, 2-arg, … Examples: – father(ali, ahmed). 18 Predicates Logic Programming

like(ali, car). like(ahmed, car). father(salem, ali). father(salem, ahmed). brother(X,Y) :- father(P,X), father(P,Y). friend(X,Y) :- like(X,C), like(Y,C). 19 Prolog Program Example Logic Programming Predicate name Predicate arguments Predicate End if and

A goal is a conjunction of predicates – p(X,Y),q(Y,Z),t(Z,W). – A goal is the question or query asked by the user. Prolog will try to find an answer for the goal. 20 Goals Logic Programming

Given a goal, Prolog searches for answer(s): – “yes” (possibly with answer substitution) – “no” (if no answer or no more answer found). – Substitutions are bindings of variables that make goal true. 21 Answers Logic Programming

?- father(X,ali). – X = salem ? ; – no ?- father(X,Y), brother(Y,Z). – X = salem, Y = ali, Z = ahmed – yes – ? ; – X = salem, Y=ahmed, Z=ali – Yes – ? ; – no 22 Examples Logic Programming male(ali). male(ahmed). male(salem). father(salem, ali). father(salem, ahmed). brother(X,Y) :- father(P,X), father(P,Y), male(X), male(Y).

A rule is an assertion of the form – p(ts) :- q(ts’),..., r(ts’’). – where ts, ts’, ts’’ are atoms or variables “p(ts) holds if q(ts’) holds and... And r(ts’’) holds” Example: – brother(X,Y) :- father(Z,X), father(Z,Y). 23 Rules Logic Programming

You can try prolog by downloading prolog compiler: – Ciao: – Choose Windows version, For Windows Vista: current version For Windows XP: select version Ciao- 1.10p5Win32.zip 24 Prolog Logic Programming

After downloading ciao-1.10pWin32.zip, extract it in C:\ Then goto C:\Ciao-1.10p5Win32 Double click on the file: install.bat Then type ciaosh at the DOS prompt, the prolog prompt appears: ?- 25 Ciao installation under Windows XP Logic Programming

After downloading CiaoDE XXXX.exe, double click on it to run. At the desktop you will find a file: ciaosh shortcut. Double click on it and the Prolog prompt appears: ?- 26 Ciao installation under Windows Vista Logic Programming

Comments – % single line comment – /* multiple line comment */ To quit Ciao, type – ?- exit. – (or just control-D) 27 Miscellaneous Logic Programming