Prolog programming Introduction to Prolog

Slides:



Advertisements
Similar presentations
4. Using Structures: Example Programs. Contents l Retrieving structured information from a database l Doing data abstraction l Simulating a non-deterministic.
Advertisements

1. An Overview of Prolog.
Introduction to PROLOG ME 409 Lab - 1. Introduction to PROLOG.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
1 Introduction to Prolog References: – – Bratko, I., Prolog Programming.
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).
Prolog Programming for Artificial Intelligence Three edition 2001
Introduction to Prolog Language Presented by San Myint.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Introduction to Prolog Notes for CSCE 330 Based on Bratko and Van Emden Marco.
Prolog programming Introduction to Prolog (part4) CS 370 – CS461.
Prolog programming Introduction to Prolog
About prolog  History  Symbolic Programming Language  Logic Programming Language  Declarative Programming Language.
MB: 2 March 2001CS360 Lecture 31 Programming in Logic: Prolog Prolog’s Declarative & Procedural Semantics Readings: Sections
Introduction to Prolog Proof Procedures. Exercise parent(mark, alex). parent(di, alex). brother(brian, mark). sister(cathy, di). wife(susan, brian). husband(brad,
For Friday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
Introduction to Prolog What is Prolog? Application Areas of Prolog How does Prolog work? (Syntax of Prolog) Program Structure.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Introduction to Prolog Notes for Ch.1 of Bratko For CSCE 580 Sp03 Marco Valtorta.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Introduction to Prolog Notes for CSCE 330 Based on Bratko and Van Emden Marco.
Copyright © 2003 Bolton Institute Logical Analysis and Problem Solving, (LAPS) Programming in Prolog.
1 Artificial Intelligence CSC 361 Prof. Mohamed Batouche Department of Computer Science CCIS – King Saud University Riyadh, Saudi Arabia
Prolog programming Introduction to Prolog CS370d - CS 461.
DEDUCTIVE DATABASE.
1 Software Development Topic 2 Software Development Languages and Environments.
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
COSC 2P93 Logic Programming Instructor: Brian Ross Instructor: Brian Ross Texts: Texts: Prolog Programming for Artificial Intelligence,4e, Ivan Bratko,
1 Lecture 6 Logic Programming introduction to Prolog, facts, rules Ras Bodik Shaon Barman Thibaud Hottelier Hack Your Language! CS164: Introduction to.
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
Logic Programming Module 2AIT202 Website Lecturer: Dave Sharp Room: AG15
Artificial Intelligence LECTURE 2 ARTIFICIAL INTELLIGENCE LECTURES BY ENGR. QAZI ZIA 1.
For Wednesday No new reading Prolog handout 2 Chapter 9, exercise 4.
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 to Prolog Facts, Questions & Rules Atoms & Variables.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 22 A First Course in Database Systems.
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:
CS 603: Programming Languages Lecture 25 Spring 2004 Department of Computer Science University of Alabama Joel Jones.
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?
For Monday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
© Enn Tyugu1 Algorithms of Artificial Intelligence Lecture 2: Knowledge E. Tyugu Spring 2003.
Introduction to Prolog. Outline What is Prolog? Prolog basics Prolog Demo Syntax: –Atoms and Variables –Complex Terms –Facts & Queries –Rules Examples.
Negation Chapter 5. Stating Negative Conditions n Sometimes you want to say that some condition does not hold n Prolog allows this –not/1this is a predicate.
MB: 26 Feb 2001CS Lecture 11 Introduction Reading: Read Chapter 1 of Bratko Programming in Logic: Prolog.
Invitation to Computer Science, Java Version, Second Edition 1 Logic Programming Logic programming  Various facts are asserted to be true  On the basis.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Introduction to Prolog Notes for CSCE 330 Based on Bratko, Poole, and Van Emden.
Knowledge Based Information System
Artificial Intelligence CS370D
Artificial Intelligence CIS 342 The College of Saint Rose David Goldschmidt, Ph.D.
For Friday No reading Prolog Handout 2. Homework.
For Wednesday No reading Prolog handout 2 Chapter 9, exercise 4.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Introduction to Logic Programming: Prolog Notes for CSCE 190 Based on Bratko,
Logic Programming Logic programming Candidates should be familiar with the concept of logic programming for declaring logical relationships.
6/11/2016 Linear Resolution and Introduction to First Order Logic Michael Leuschel Softwaretechnik und Programmiersprachen Lecture 5.
1 Artificial Intelligence CS370D Prolog programming Introduction to Prolog.
By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology
ece 720 intelligent web: ontology and beyond
PROLOG – PROgamming in LOGic Early 1970s- programming language.
For Friday No reading Prolog handout 3 Chapter 9, exercises 9-11.
For Wednesday Read “lectures” 7-10 of Learn Prolog Now:
Prolog programming Introduction to Prolog (part2)
Prolog Primarily for Symbolic (nonnumeric) Computation
Prolog programming Introduction to Prolog
Prolog programming Introduction to Prolog (part3)
CPSC 322 Introduction to Artificial Intelligence
Horn Clauses and Unification
Chapter Two: Syntax and Meaning of Prolog Programs
Prolog programming Introduction to Prolog (part4)
How To Think Like a Prolog ?
Developing Programs for Family Trees
Chapter 2: Prolog (Introduction and Basic Concepts)
Presentation transcript:

Prolog programming Introduction to Prolog CS 370

What is Prolog programming? Prolog, which stands for PROgramming in LOGic, is the most widely available language in the logic programming paradigm. Prolog is a programming language for symbolic , non-numeric commutation. a program consists of a database of facts and logical relationships (rules) describing the relationships which hold for the given application.

How Prolog program is running? Rather than running a program to obtain a solution, the user asks a question. When asked a question, the run-time system searches through the database of facts and rules to determine the answer by logical deduction.

Example:

Defining relations by facts The fact that Tom is a parent of Bob can be written in prolog as: parent(tom, bob). tom and bob are objects (atoms). parent(tom, bob) is a relation between these objects.

Defining relations by facts The whole family tree can be described by the following facts: pam tom bob liz ann pat jim

Defining relations by facts The whole family tree can be described by the following facts: parent(pam,bob). parent(tom,bob). parent(tom,liz). parent(bob,ann). parent(bob,pat). parent(pat,jim). pam tom bob liz ann pat jim

Defining relations by facts We can also add information about the sex of the people by the following facts: female(pam). male(tom). male(bob). female(liz). female(pat). female(ann). male(jim).

Defining relations by facts female(pam) is a Unary relation parent(bob,pat) is a Binary relation. Think about this relation: sex(pam, feminist).

Questions in prolog. Prolog can posed questions about any relation. So, we can ask a question about Parent relation, For example : Is bob a parent of Pat? ?- parent(bob,pat). The answer will be : true.

Questions in prolog. Another question can be asked: Who is Liz’s parent? ?- parent(X, liz). The answer here will not be Yes/No, rather, prolog will find the value of X. So the answer is : X= tom. pam tom bob liz ann pat jim

Class exercise(1) Who are bob’s children? pam tom bob liz ann pat jim

Class exercise(2) Who is parent of whom? pam tom bob liz ann pat jim

Questions in prolog. In prolog, we can ask more complicated questions such as: Who is a grandparent of jim? ?- parent(Y,jim) , parent( X,Y). The answer will be: Y = pat, X = bob. X Parent grandparent Parent Y jim

Class exercise(3) Who are Tom’s grandchildren?

Questions in prolog. Who is bob’s mother? Who is bob’s sister? Do ann and pat have a common parents?

Some important points A prolog program consists of clauses, each clause ends with a full stop. The arguments of relation can be concrete objects, constant objects (such as bob and pat) or general object (such as X and Y). Questions in prolog consist of one or more goals. ?-parent(X,ann),parent(X,pat) . means the conjunctions of the goals: X is parent of ann , and X is parent of Pat.