Prolog or: How I Learned to Stop Worrying and Love the Search.

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

CS4026 Formal Models of Computation Part II The Logic Model Lecture 8 – Search and conclusions.
© Patrick Blackburn, Johan Bos & Kristina Striegnitz Lecture 10: Cuts and Negation Theory –Explain how to control Prolog`s backtracking behaviour with.
Structures. Procedural (Imperative) Languages Procedural languages work on the basis of explicitly telling the computer ‘how to do something’; by using.
Prolog Nonmonotonic logic.
Inference Rules Universal Instantiation Existential Generalization
Computational Models The exam. Models of computation. –The Turing machine. –The Von Neumann machine. –The calculus. –The predicate calculus. Turing.
Prolog.
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).
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
Reasoning Forward and Backward Chaining Andrew Diniz da Costa
Methods of Proof Chapter 7, Part II. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound) generation.
Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Logic.
Formal Logic Mathematical Structures for Computer Science Chapter 1 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFormal Logic.
Intelligent systems Lecture 6 Rules, Semantic nets.
Theoretical Probability Distributions We have talked about the idea of frequency distributions as a way to see what is happening with our data. We have.
Algorithm Strategies Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Key Words for Inequalities
Proof methods Proof methods divide into (roughly) two kinds: –Application of inference rules Legitimate (sound) generation of new sentences from old Proof.
10-Jun-15 Just Enough Java. Variables A variable is a “box” that holds data Every variable has a name Examples: name, age, address, isMarried Variables.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 27: Prolog’s Resolution and Programming Techniques COMP 144 Programming Language.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Controlling Backtracking Notes for Ch.5 of Bratko For CSCE 580 Sp03 Marco Valtorta.
Methods of Proof Chapter 7, second half.
Copyright © 2003 Bolton Institute Logical Analysis and Problem Solving, (LAPS) Programming in Prolog.
Prolog Ross (Tate). Filling in the Blanks Rather than reverse((a,b)) returns (b,a) Rather than reverse((a,b)) returns (b,a) What X makes reverse((a,b),
Heuristic Search Heuristic - a “rule of thumb” used to help guide search often, something learned experientially and recalled when needed Heuristic Function.
ISBN Chapter 16 Logic Programming Languages.
Logic Programming Languages
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
OCaml The PL for the discerning hacker.. Hello. I’m Zach, one of Sorin’s students.
FATIH UNIVERSITY Department of Computer Engineering Controlling Backtracking Notes for Ch.5 of Bratko For CENG 421 Fall03.
AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,
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.
Chapter 16 Logic Programming Languages. Copyright © 2012 Addison-Wesley. All rights reserved.1-2 Chapter 16 Topics Introduction A Brief 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.
Logical Inference 2 rule based reasoning
Logic Programming Module 2AIT202 Website Lecturer: Dave Sharp Room: AG15
Logical Agents Logic Propositional Logic Summary
Introduction To PROLOG World view of imperative languages. World view of relational languages. A PROLOG program. Running a PROLOG program. A PROLOG.
Prolog Programming in Logic. 2 SWI-Prolog SWI-Prolog is a good, standard Prolog for Windows and Linux Can be installed on Macintosh with a little more.
CT214 – Logical Foundations of Computing Lecture 8 Introduction to Prolog.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 1 Simple Python Programs Using Print, Variables, Input.
By: Cory Canter CSC 415 Programming Languages. History  Created by Alain Colmerauer, Phillipe Roussel and Robert Kowalski in 1971  Started as a natural.
CS 363 Comparative Programming Languages Logic Programming Languages.
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.
Knowledge Based Information System
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
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.
Fahiem Bacchus © 2005 University of Toronto 1 CSC384: Intro to Artificial Intelligence Search II ● Announcements.
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
Prolog Fundamentals. 2 Review Last Lecture A Prolog program consists of a database of facts and rules, and queries (questions). –Fact:.... –Rule:... :-....
Logic Programming Logic programming Candidates should be familiar with the concept of logic programming for declaring logical relationships.
Learning Javascript From Mr Saem
The portion of a Prolog interpreter that executes queries (goals) is known as the inference engine. An inference engine is a kind of theorem prover, using.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology
Forward Chaining (propositional) Recursive stack-based version of Back-chaining using Propositional Logic could be modified to handle... variables.
3.5 Programming paradigms
Using variables, for..loop and functions to help organize your code
Chapter 10: Algorithm Design Techniques
Programming Paradigms and Languages
Methods of Proof Chapter 7, second half.
Just Enough Java 17-May-19.
PROLOG.
Function Notation.
Presentation transcript:

Prolog or: How I Learned to Stop Worrying and Love the Search

Hello. I’m Zach, one of Sorin’s students.

Search Any cycles?

Search How about now?

Search And now?

Search Reach from stopping by ?

Search is Fundamental Natural way to phrase problems: Is there an X such that Y? Ubiquitous in Computer Science:

Prolog: Interface to Search Search is declarative say what you want not how to get it Often radical simplification shorter, clearer programs less development effort fewer bugs SEARCH

Prolog Anatomy 101 Prolog programs do three things: 1.Declare Facts known points in the search space 2. Declare Rules add new points to search space based on old ones 3. Query over Search Space search for a point

Prolog Anatomy 101 Facts : known points Rules : add new points from old points Query: is reachable? Rules Facts Query

Prolog 1.Basic Syntax 2.Backtracking Search 3.Examples in the toplevel: A.Variables in Queries B.Negation C.Search Order

Basic Syntax Declare Facts: parent(homer, bart). parent(marge, bart). parent(mona, homer). Known points in search space Basis of all we can conclude

Basic Syntax Simple Query: ?- parent(homer, bart). true. ?- parent(mona, bart). false. Ask if a particular point is in search space

Basic Syntax Declare Rules: grandparent(GP, GC) :- parent(GP, P), parent(P, GC). ADD THIS NEW POINT IF YOU FIND THESE OLD POINTS VARIABLES

Atoms vs. Variables Atom starts with lowercase letter particular individual object only equal to self Variable starts with uppercase letter “hole” replaceable by atom

grandparent(GP, GC) can be added to search space If you find 3 atoms GP, P, GC Such that both parent(GP, P) and parent(P, GC) Basic Syntax grandparent(GP, GC) :- parent(GP, P), parent(P, GC).

Basic Syntax Query that requires Rule: ?- grandparent(mona, bart). true. ?- grandparent(homer, bart). false. Q: Which query takes longer?

Prolog 1.Basic Syntax 2.Backtracking Search 3.Examples in the toplevel: A.Variables in Queries B.Negation C.Search Order

Backtracking Search Query : is in search space? Prolog searches for backward: Start at Look for path back to Facts using Rules Top-down approach since Bottom-up is too inefficient

Backtracking Search Search( ) 1. in search space? Success! 2. For each rule R that could add : For each old node R requires : If Search( ) fails, try next rule. All old nodes found. Success! 3. Not in space, no rule can add. Fail.

Prolog 1.Basic Syntax 2.Backtracking Search 3.Examples in the toplevel: A.Variables in Queries B.Negation C.Search Order