Introduction to Prolog

Slides:



Advertisements
Similar presentations
Chapter 11 :: Logic Languages
Advertisements

Prolog The language of logic. History Kowalski: late 60’s Logician who showed logical proof can support computation. Colmerauer: early 70’s Developed.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
Prolog The language of logic. History Kowalski: late 60’s Logician who showed logical proof can support computation. Colmerauer: early 70’s Developed.
Prolog OR (disjunction) “;” is same as a logical OR “;” is same as a logical OR It is also equivalent to using separate clauses... It is also equivalent.
Propositional Calculus A propositional calculus formula is composed of atomic propositions, which area simply statements that are either true or false.
ISBN Chapter 1 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Figure 1.1 The von Neumann computer architecture.
©Brooks/Cole, 2001 Chapter 2 Introduction to The C Language.
CSE 221: Probabilistic Analysis of Computer Systems Topics covered: Statistical inference (Sec. )
CSE (c) S. Tanimoto, 2005 Logic Programming 1 Logic Programming Outline: Motivation Examples: The Grandmother relation Formulation in Prolog Logic,
“Mother to Son” by Langston Hughes.
Words + picturesPicturesWords Day Day
Cs7120 (Prasad)L16-Meaning1 Procedural and Declarative Meaning of Prolog
CSE S. Tanimoto Horn Clauses and Unification 1 Horn Clauses and Unification Propositional Logic Clauses Resolution Predicate Logic Horn Clauses.
1Lecture 12 Introduction to Prolog Logic Programming Prolog.
CS 603: Programming Languages Lecture 25 Spring 2004 Department of Computer Science University of Alabama Joel Jones.
CSE 341, S. Tanimoto Wrapup - 1 Wrapup Programming Languages as systems for specifying computation Comparing Lisp, Java and Perl The future.
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)
CSE (c) S. Tanimoto, 2008 Predicate Calculus II 1 Predicate Calculus 2 Outline: Unification: definitions, algorithm Formal interpretations and satisfiability.
CS 403: Programming Languages Lecture 18 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
CSE 341, S. Tanimoto Logic Programming Intro - 1 Logic Programming Introduction Motivation. Sample logic programs.
Logic Programming Tarik Booker. What will we cover?  Introduction  Definitions  Predicate Calculus  Prolog  Applications.
Functional Programming Languages Logic Programming Languages
La Llorona From La Llorona From:
CPS120 Introduction to Computer Science High Level Language: Paradigms.
CSE (c) S. Tanimoto, 2001 Logic Programming
By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology
CSE 341, S. Tanimoto Logic Programming -
My Family Tree 2018.
Horn Clauses and Unification
Chapter 1 Preliminaries.
Mobile Development Workshop
List Manipulation in Prolog
Introduction to Logic Programming and Prolog
Copyright © 2004 The McGraw-Hill Companies, Inc. All rights reserved.
Horn Clauses and Unification
Horn Clauses and Unification
Introduction to Logic Programming and Prolog
Horn Clauses and Unification
My Family Tree 2017.
List Manipulation in Prolog
CSE S. Tanimoto Comparing Languages
Copyright © 2012, Elsevier Inc. All rights Reserved.
Who’s in your Family?.
The University of Adelaide, School of Computer Science
CSE (c) S. Tanimoto, 2004 Logic Programming
Introduction to Prolog
CSE (c) S. Tanimoto, 2002 Logic Programming
Horn Clauses and Unification
The University of Adelaide, School of Computer Science
Copyright © 2013 Elsevier Inc. All rights reserved.
Copyright © 2012, Elsevier Inc. All rights Reserved.
The University of Adelaide, School of Computer Science
Copyright © 2004 The McGraw-Hill Companies, Inc. All rights reserved.
Copyright © 2012, Elsevier Inc. All rights Reserved.
Copyright © 2013 Elsevier Inc. All rights reserved.
The University of Adelaide, School of Computer Science
Introduction to Logic Programming and Prolog
The University of Adelaide, School of Computer Science
The University of Adelaide, School of Computer Science
Modeling Functionality with Use Cases
Introduction to Logic Programming and Prolog
Copyright © 2012, Elsevier Inc. All rights Reserved.
The University of Adelaide, School of Computer Science
Copyright © 2012, Elsevier Inc. All rights Reserved.
Copyright © 2013 Elsevier Inc. All rights reserved.
Copyright © 2012, Elsevier Inc. All rights Reserved.
Copyright © 2004 The McGraw-Hill Companies, Inc. All rights reserved.
Chapter 77 Cervical Cancer: Burden of Disease
Presentation transcript:

Introduction to Prolog Motivation Sample problem Example program: grandmother.pl Sample session A question about logic and programming What is a program? CSE 341 -- S. Tanimoto Introduction to Prolog

CSE 341 -- S. Tanimoto Introduction to Prolog Motivation 1. Reduce the programming burden. 2. System should simply accept the necessary information and the objective (goal), and then figure out its own solution. 3. Have a program that looks more like its own specification. 4. Take advantage of logical inference to automatically get many of the consequences of the given information. CSE 341 -- S. Tanimoto Introduction to Prolog

CSE 341 -- S. Tanimoto Introduction to Prolog Sample Problem For someone (call him or her X) to be the grandmother of someone else (call him or her Y), X must be the mother of someone (call him or her Z) who is a parent of Y. Someone is a parent of another person, if that someone is either the mother or the father of the other person. Mary is the mother of Stan. Gwen is the mother of Alice. Valery is the mother of Gwen. Stan is the father of Alice. The question: Who is a grandmother of Alice? CSE 341 -- S. Tanimoto Introduction to Prolog

Sample Prolog Program: grandmother.pl grandmother(X, Y) :- mother(X, Z), parent(Z, Y). parent(X, Y) :- mother(X, Y). parent(X, Y) :- father(X, Y). mother(mary, stan). mother(gwen, alice). mother(valery, gwen). father(stan, alice). CSE 341 -- S. Tanimoto Introduction to Prolog

CSE 341 -- S. Tanimoto Introduction to Prolog Sample Session Welcome to SWI-Prolog (Version 3.3.2) Copyright (c) 1990-2000 University of Amsterdam. All rights reserved. For help, use ?- help(Topic). or ?- apropos(Word). ?- [grandmother]. % grandmother compiled 0.00 sec, 1,312 bytes Yes ?- grandmother(X, alice). X = mary ; X = valery ; No ?- CSE 341 -- S. Tanimoto Introduction to Prolog

A Question about Logic & Programming Q: Is a logical description of a problem actually a program? CSE 341 -- S. Tanimoto Introduction to Prolog

CSE 341 -- S. Tanimoto Introduction to Prolog What is a program? A specification for a computation. The specification must be effective -- interpretable by some identified computer language processor. CSE 341 -- S. Tanimoto Introduction to Prolog