Prolog Concepts.

Slides:



Advertisements
Similar presentations
Artificial Intelligence 8. The Resolution Method
Advertisements

CS4026 Formal Models of Computation Part II The Logic Model Lecture 1 – Programming in Logic.
Some Prolog Prolog is a logic programming language
Resolution Proof System for First Order Logic
Knowledge & Reasoning Logical Reasoning: to have a computer automatically perform deduction or prove theorems Knowledge Representations: modern ways of.
Standard Logical Equivalences
Resolution.
Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and.
Models and Propositional Logic In propositional logic, a model in general simply fixes the truth value – true or false – for every proposition symbol.
13 Automated Reasoning 13.0 Introduction to Weak Methods in Theorem Proving 13.1 The General Problem Solver and Difference Tables 13.2 Resolution.
Logic.
CS 330 Programming Languages 12 / 02 / 2008 Instructor: Michael Eckmann.
1 Prolog II. 2 The Notion of Unification Unification is when two things “become one” Unification is kind of like assignment Unification is kind of like.
Prolog IV Logic, condensed. 2 Propositional logic Propositional logic consists of: The logical values true and false ( T and F ) Propositions: “Sentences,”
Outline Recap Knowledge Representation I Textbook: Chapters 6, 7, 9 and 10.
11-Jun-15 Prolog II Unification and clause order.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description.
1 Automated Reasoning Introduction to Weak Methods in Theorem Proving 13.1The General Problem Solver and Difference Tables 13.2Resolution Theorem.
Inference and Resolution for Problem Solving
Formal Aspects of Computer Science – Week 12 RECAP Lee McCluskey, room 2/07
CSE (c) S. Tanimoto, 2005 Logic Programming 1 Logic Programming Outline: Motivation Examples: The Grandmother relation Formulation in Prolog Logic,
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 15 Logic Programming Q: How many legs does.
Knowledge & Reasoning Logical Reasoning: to have a computer automatically perform deduction or prove theorems Knowledge Representations: modern ways of.
ISBN Chapter 16 Logic Programming Languages.
Logic Programming Languages
1 Knowledge Based Systems (CM0377) Lecture 4 (Last modified 5th February 2001)
1 Chapter 8 Inference and Resolution for Problem Solving.
Chapter 16 Logic Programming Languages. Copyright © 2012 Addison-Wesley. All rights reserved.1-2 Chapter 16 Topics Introduction A Brief Introduction to.
1-1 Introduction Logic programming languages, sometimes called declarative programming languages Express programs in a form of symbolic logic Use a logical.
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
CSE S. Tanimoto Horn Clauses and Unification 1 Horn Clauses and Unification Propositional Logic Clauses Resolution Predicate Logic Horn Clauses.
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.
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
Dr. Muhammed Al-Mulhem ICS An Introduction to Logical Programming.
Logic Programming Languages Session 13 Course : T Programming Language Concept Year : February 2011.
Logic Programming and Prolog Goal: use formalism of first-order logic Output described by logical formula (theorem) Input described by set of formulae.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Automated Reasoning Early AI explored how to automate several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Reasoning using First-Order Logic
Propositional Logic Predicate Logic
Prolog Unification and clause order. The notion of Unification Unification is when two things “become one” Unification is kind of like assignment Unification.
Logic Programming. Formal Logics- Recap Formulas – w/out quantifiers Free Variables Bound Variables Assignments and satisfaction Validity and satisfiability.
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.
23-Feb-16 Prolog II Unification and clause order.
Propositional Logic. Assignment Write any five rules each from two games which you like by using propositional logic notations.
By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology
Introduction to Logic for Artificial Intelligence Lecture 2
CSE 341, S. Tanimoto Logic Programming -
Prolog Concepts.
Horn Clauses and Unification
Logic Programming Languages
Logic Programming Languages
Carlos Varela Rensselaer Polytechnic Institute November 10, 2017
Unification and clause order
Horn Clauses and Unification
Prolog IV Logic, condensed.
Horn Clauses and Unification
Horn Clauses and Unification
Logic Programming Language
Prolog Resolution.
CSE (c) S. Tanimoto, 2004 Logic Programming
CSE (c) S. Tanimoto, 2002 Logic Programming
Programming Languages 2nd edition Tucker and Noonan
Horn Clauses and Unification
RESOLUTION.
Prolog Concepts.
Resolution Preliminaries
Presentation transcript:

Prolog Concepts

A declarative language Most programming languages are imperative—you tell the computer what to do to solve a problem Prolog is declarative—you give it the data it needs, and it solves the problem for you Consider: append([], List, List). append([Head | Tail], List, [Head | More]) :- append(Tail, List, More). This defines what it means append lists You can use it to append two lists You can use it to find what to append to a list to get another list You can use it to find what list to append to to get another list You can test whether the relation holds between three lists

A constraint satisfaction language Prolog is also one of a number of constraint satisfaction languages You tell it the constraints on a problem (e.g. the solution must be someone who is both female and rich), and it finds a solution that satisfies those constraints A “logic puzzle” is nothing more than a set of constraints (e.g. every man has a different tie)

A homoiconic language Prolog is homoiconic—that is, there is no distinction between “statements” in the language and the “data” that the languages processes When you provide “input” to a Prolog program (e.g. for an adventure game), you use the same syntax as when you write the program We haven’t emphasized homoiconicity in Prolog, because it is more important in some of the other languages we will be studying

Prolog does backtracking You don’t have to implement backtracking in Prolog; the language does it for you The only other “language” I know of that does this is Regular Expressions, which are a “sublanguage” of most modern programming languages loves(chuck, X) female(X) rich(X) call fail exit redo

Prolog uses unification The basic rules of unification are: Any value can be unified with itself A variable can be unified with another variable A variable can be unified with any value Two different structures can be unified if their constituents can be unified Lists are a particularly important kind of structure A variable can be unified with a structure containing that same variable Unification is reflexive, symmetric, and transitive Parameter transmission is by unification, not assignment

Prolog is a theorem prover Prolog is an implementation of resolution theorem proving in a programming language Because it is based on logic, there is very little that is ad hoc or arbitrary about Prolog

Resolution Here is the resolution principle: A clause is a disjunction (“or”) of zero or more literals, some or all of which may be negated sinks(X)  dissolves(X, water)  ¬denser(X, water) Any expression in the predicate calculus can be put into clause form X  Y can be rewritten as X  Y Conjunctions (“ands”) can be rewritten as separate clauses The existential quantifier  can be replaced by a Skolem function If the existential quantifier is under control of a universal quantifier, replace it with a function of the universally quantified variable Otherwise, just replace with a constant (whose value need not be known) Universal quantifiers, , can be dropped Here is the resolution principle: From X  someLiterals and X  someOtherLiterals ---------------------------------------------- conclude: someLiterals  someOtherLiterals Clauses are closed under resolution

The End