Introduction to Prolog What is Prolog? Application Areas of Prolog How does Prolog work? (Syntax of Prolog) Program Structure.

Slides:



Advertisements
Similar presentations
Introduction to PROLOG ME 409 Lab - 1. Introduction to PROLOG.
Advertisements

1 Introduction to Prolog References: – – Bratko, I., Prolog Programming.
1 Logic Programming School of Informatics, University of Edinburgh Transformations Specification-Program An introduction to moving between Prolog and First.
1 CHAPTER 4 RELATIONAL ALGEBRA AND CALCULUS. 2 Introduction - We discuss here two mathematical formalisms which can be used as the basis for stating and.
Answer Set Programming Overview Dr. Rogelio Dávila Pérez Profesor-Investigador División de Posgrado Universidad Autónoma de Guadalajara
Logic.
Introductory Lecture. What is Discrete Mathematics? Discrete mathematics is the part of mathematics devoted to the study of discrete (as opposed to continuous)
CSE 425: Logic Programming I Logic and Programs Most programs use Boolean expressions over data Logic statements can express program semantics –I.e., axiomatic.
For Friday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
CPSC 322 Introduction to Artificial Intelligence September 15, 2004.
Declarative Languages. Declarative languages In an imperative programming language, a program specifies how to solve a problem In a declarative language,
Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 26: Introduction to Logic Programming with Prolog COMP 144 Programming Language.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 15 Logic Programming Q: How many legs does.
ANSWERING CONTROLLED NATURAL LANGUAGE QUERIES USING ANSWER SET PROGRAMMING Syeed Ibn Faiz.
Logic Programming Languages
Formal Models of Computation Part II The Logic Model
1 Visual Prolog Programs LabLecture # 3 Lecturer : Sheriff Nafisa TA : Mubarakah Otbi, Duaa al Ofi, Huda al Hakami.
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
Evolution of Programming Languages Generations of PLs.
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.
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
F28PL1 Programming Languages Lecture 16: Prolog 1.
Discrete Structures for Computing
Logic Programming Module 2AIT202 Website Lecturer: Dave Sharp Room: AG15
Getting Started with Visual Prolog
15/11/04 AIPP Lecture 14: Database Manipulation1 Database Manipulation Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 14 15/11/04.
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.
1 Prolog and Logic Languages Aaron Bloomfield CS 415 Fall 2005.
Programming Languages. A Logic Programming Language: Prolog This lesson describes the basic structures and functions of the logic programming language:
PROLOG SYNTAX AND MEANING Ivan Bratko University of Ljubljana Faculty of Computer and Info. Sc. Ljubljana, Slovenia.
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?
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
Dr. Muhammed Al-Mulhem ICS An Introduction to Logical Programming.
Logic Programming Languages Session 13 Course : T Programming Language Concept Year : February 2011.
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.
Programming Language Concepts Lecture 17 Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Logic Programming.
Logic Programming Tarik Booker. What will we cover?  Introduction  Definitions  Predicate Calculus  Prolog  Applications.
ISBN Chapter 16 Logic Programming Languages.
Invitation to Computer Science, Java Version, Second Edition 1 Logic Programming Logic programming  Various facts are asserted to be true  On the basis.
Knowledge Based Information System
Artificial Intelligence CS370D
1-1 An Introduction to Logical Programming Sept
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.
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
Done By :- -Nesreen Basem -Sara nabil -Rawan Prolog Program.
Prolog Fundamentals. 2 Review Last Lecture A Prolog program consists of a database of facts and rules, and queries (questions). –Fact:.... –Rule:... :-....
Artificial Intelligence Knowledge Representation.
1 Artificial Intelligence CS370D Prolog programming Declarative meaning of Prolog programs and Lists representation.
Introductory Lecture. What is Discrete Mathematics? Discrete mathematics is the part of mathematics devoted to the study of discrete (as opposed to continuous)
1 Artificial Intelligence CS370D Prolog programming Introduction to Prolog.
Pengenalan Prolog Disampaikan Oleh : Yusuf Nurrachman, ST, MMSI.
By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology
CHAPTER 1 Introduction BIC 3337 EXPERT SYSTEM.
CSE 341, S. Tanimoto Logic Programming -
For Wednesday Read “lectures” 7-10 of Learn Prolog Now:
Introduction to Prolog
Tests, Backtracking, and Recursion
Prolog fundamentals Module 14.2 COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez.
Logic Programming Languages
KNOWLEDGE REPRESENTATION
TA : Mubarakah Otbi, Duaa al Ofi , Huda al Hakami
Programming Languages 2nd edition Tucker and Noonan
Chapter 2: Prolog (Introduction and Basic Concepts)
Representations & Reasoning Systems (RRS) (2.2)
PROLOG.
Presentation transcript:

Introduction to Prolog What is Prolog? Application Areas of Prolog How does Prolog work? (Syntax of Prolog) Program Structure

2 June 2015Created By Zaman A N K2 What is Prolog? Prolog is a logical and a declarative programming language. The name itself, Prolog, is short for PROgramming in LOGic. Prolog is a Programming Language for symbolic, non- numeric computation. Prolog is the major example of a fourth generation programming language.

2 June 2015Created By Zaman A N K3 Application Areas of Prolog The main applications of the language can be found in the area of Artificial Intelligence; but PROLOG is being used in other areas in which symbol manipulation is of prime importance as well. Some application areas are: Natural-language processing; Compiler construction; The development of expert systems; Work in the area of computer algebra; The development of (parallel) computer architectures; Game Development; Database systems.

2 June 2015Created By Zaman A N K4 How does Prolog work? Prolog is based on ‘Horn Clauses' or ‘clauses’ (Rules, Facts and Queries.) Horn Clauses are a subset of ‘Predicate Logic’ Predicate logic is a way of simply defining how reasoning gets done in logic terms. Predicate Logic is a syntax for easily reading and writing Logical ideas.

2 June 2015Created By Zaman A N K5 Predicate Logic... To transform an English sentence to Predicate Logic, we remove unnecessary terms. This leaves only the relationship and the entities involved, known as arguments. Ex: An elephant is bigger than a horse = bigger (elephant, horse). The relation is ‘bigger’, the relation’s arguments are ‘elephant and horse’. In Prolog, we call the relation’s name (e.g. “bigger”) the ‘Functor’. A relation may include many arguments after the functor.

2 June 2015Created By Zaman A N K6 Example A Prolog Program consists of clauses and each clause terminates with a full stop. bigger(elephant, horse). bigger(horse, donkey). bigger(donkey, dog). bigger(donkey, monkey).

2 June 2015Created By Zaman A N K7 Example Cont… After compilation we can query the prolog system-

2 June 2015Created By Zaman A N K8 Rules in Prolog Rules enable us to define new relationships in terms of existing relationships. Rules consists of a head and a body separated by ‘:-’. The head of a rule is true if all predicates in the body can be improved to be true. For example- is_bigger(X,Y):- bigger(X,Y). is_bigger(X,Y):- bigger(X,Z), bigger(Z,Y).

2 June 2015Created By Zaman A N K9 Example is_bigger(X,Y):- bigger(X,Y). is_bigger(X,Y):- bigger(X,Z), bigger(Z,Y). bigger(elephant, horse). bigger(horse, donkey). bigger(donkey, dog). bigger(donkey, monkey).

2 June 2015Created By Zaman A N K10 Example Cont..

2 June 2015Created By Zaman A N K11 Example Cont..

2 June 2015Created By Zaman A N K12 Prolog Queries Based on the Rules and Facts, Prolog can answer questions we ask it This is known as querying the system. We may want to ask, “What is bigger than a donkey?” In Prolog syntax, we ask: is_bigger(X,donkey). Note: capital X on what

2 June 2015Created By Zaman A N K13 Parts of a Prolog program All programs written in Prolog usually contain 4 parts: DOMAINS PREDICATES CLAUSES GOALS

2 June 2015Created By Zaman A N K14 What is DOMAIN? The section of code where we define the legal values for any type that is not defined as a standard type. This may include aliasing of types (renaming). Domain declarations can also be used to define structures that are not defined by the standard domains.

2 June 2015Created By Zaman A N K15 What are PREDICATES? The PREDICATES section is where we define predicates to be used in the CLAUSES section and define the domains for their arguments. Symbolic name of a relation We found it best to think of predicate declarations as function prototypes. Ex: bigger(symbol,symbol).; age(string, integer).

2 June 2015Created By Zaman A N K16 What are CLAUSES Clauses are the heart of the program. A clause is an instance of a predicate, followed by a period. Clauses are of two types: Facts Rules

2 June 2015Created By Zaman A N K17 What are GOALS? Part of program where queries are made. Can be singular or compound. Each part of a compound goal is known as a subgoal. To satisfy a compound goal (or query) each subgoal must itself be satisfied by the system.

2 June 2015Created By Zaman A N K18 Resources Book- Prolog Programming for Artificial Intelligence By Ivan Bratko Pearson Education Online