Prolog IV Logic, condensed.

Slides:



Advertisements
Similar presentations
Dr.A.Kannan Professor Dept of CSE Anna University Chennai-25
Advertisements

Artificial Intelligence 8. The Resolution Method
Resolution Proof System for First Order Logic
Inference Rules Universal Instantiation Existential Generalization
1 A formula in predicate logic An atom is a formula. If F is a formula then (~F) is a formula. If F and G are Formulae then (F /\ G), (F \/ G), (F → G),
Knowledge & Reasoning Logical Reasoning: to have a computer automatically perform deduction or prove theorems Knowledge Representations: modern ways of.
Standard Logical Equivalences
Resolution.
Automated Reasoning Systems For first order Predicate Logic.
First Order Logic 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.
We have seen that we can use Generalized Modus Ponens (GMP) combined with search to see if a fact is entailed from a Knowledge Base. Unfortunately, there.
For Friday No reading Homework: –Chapter 9, exercise 4 (This is VERY short – do it while you’re running your tests) Make sure you keep variables and constants.
Logic Use mathematical deduction to derive new knowledge.
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 Concepts Lecture Module 11.
F22H1 Logic and Proof Week 7 Clausal Form and Resolution.
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.
Formal Logic Proof Methods Direct Proof / Natural Deduction Conditional Proof (Implication Introduction) Reductio ad Absurdum Resolution Refutation.
AI - Week 16 Logic and Reasoning in AI: Resolution Refutation Lee McCluskey, room 2/07
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
Knoweldge Representation & Reasoning
Chapter 3 Propositional Logic
Artificial Intelligence
Knowledge & Reasoning Logical Reasoning: to have a computer automatically perform deduction or prove theorems Knowledge Representations: modern ways of.
Propositional Logic Reasoning correctly computationally Chapter 7 or 8.
Logic. 2 What is logic? Logic is an “algebra” for manipulating only two values: true ( T ) and false ( F ) Nevertheless, logic can be quite challenging.
Conjunctive normal form: any formula of the predicate calculus can be transformed into a conjunctive normal form. Def. A formula is said to be in conjunctive.
1 Chapter 8 Inference and Resolution for Problem Solving.
1 COSC3306: Programming Paradigms Lecture 8: Declarative Programming Specifications Haibin Zhu, Ph.D. Computer Science Nipissing University (C) 2003.
Prolog IV Logic.
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.
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
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.
CPSC 386 Artificial Intelligence Ellen Walker Hiram College
Extra slides for Chapter 3: Propositional Calculus & Normal Forms Based on Prof. Lila Kari’s slides For CS2209A, 2009 By Dr. Charles Ling;
Chapter 2 Logic 2.1 Statements 2.2 The Negation of a Statement 2.3 The Disjunction and Conjunction of Statements 2.4 The Implication 2.5 More on Implications.
Reasoning using First-Order Logic
Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri CS 440 / ECE 448 Introduction to Artificial Intelligence.
Copyright 1999Paul F. Reynolds, Jr. Foundations of Logic Programming.
Prolog Resolution. 2 Propositional logic Propositional logic consists of: The logical values true and false ( T and F ) Propositions: “Sentences,” which.
Chapter 1 Logic and Proof.
Introduction to Logic for Artificial Intelligence Lecture 2
CSNB 143 Discrete Mathematical Structures
Knowledge Representation and Reasoning
Resolution in the Propositional Calculus
Propositional Logic Resolution
Prolog Concepts.
Proposition & Predicates
Horn Clauses and Unification
Logic Use mathematical deduction to derive new knowledge.
Biointelligence Lab School of Computer Sci. & Eng.
CS 416 Artificial Intelligence
Horn Clauses and Unification
Horn Clauses and Unification
Back to “Serious” Topics…
Horn Clauses and Unification
Prolog Resolution.
Horn Clauses and Unification
CS2136: Paradigms of Computation
Propositional Calculus
Propositional Logic CMSC 471 Chapter , 7.7 and Chuck Dyer
RESOLUTION.
Prolog Concepts.
Prolog Concepts.
Carlos Varela Rennselaer Polytechnic Institute August 30, 2007
Presentation transcript:

Prolog IV Logic, condensed

Propositional logic Propositional logic consists of: The logical values true and false (T and F) Propositions: “Sentences,” which Are atomic (that is, they must be treated as indivisible units, with no internal structure), and Have a single logical value, either true or false Operators, both unary and binary; when applied to logical values, yield logical values The usual operators are and, or, not, and implies

Predicate calculus Predicate calculus is also known as “First Order Logic” (FOL) Predicate calculus includes: All of propositional logic Logical values true, false Variables x, y, a, b,... Connectives , , , ,  Constants KingJohn, 2, MCIT,... Predicates Female(ann), prime(N), larger(3, 7),... Functions Sqrt(5), MotherOf(ann),... Quantifiers Universal (“for all”) x (x > -10  x < 10  x2 < 100) Existential (“there exists”)  x (x2 = 100)

Clause form A clause is a disjunction ("or") of zero or more literals, some or all of which may be negated Example: sinks(X)  dissolves(X, water)  ¬denser(X, water) Notice that clauses use only “or” and “not”—they do not use “and,” “implies,” or either of the quantifiers “for all” or “there exists” The impressive part is that any predicate calculus expression can be put into clause form

Conversion to clause form We can apply various rules of propositional logic to convert propositions to clause form A particularly important rule allows us to get rid of the implication operator,  : X  Y  X  Y The symbol  means “is logically equivalent to” Another rule says to replace any fact containing the “and” operator,  , with multiple facts, one for each conjunct MaryIsFemale  MaryIsRich beomes: MaryIsFemale MaryIsRich

Elimination of quantifiers It’s easy to eliminate “for all”,  -- Just drop them, and assume that any variables can stand for (unify with) anything x (x > -10  x < 10  x2 < 100) becomes x > -10  x < 10  x2 < 100) We can eliminate “there exists”, , by introducing Skolem functions: If x, p(x) then just pick one; call it x’ If the existential quantifier is under control of a universal quantifier, then the picked value has to be a function of the universally quantified variable: If x, y, p(x, y) then x, p(x, y(x)) These rules can be made into a mechanical process for turning any predicate into clause form

The fact base A fact base is a collection of “facts,” expressed in predicate calculus, that are presumed to be true (valid) These facts are implicitly “anded” together Example fact base: seafood(X)  likes(John, X) (where X is a variable) seafood(shrimp) pasta(X)  likes(Mary, X) (where X is a different variable; the scope of a variable is a single fact) pasta(spaghetti)

Unification From the pair of facts (not yet clauses, just facts): seafood(X)  likes(John, X) (where X is a variable) seafood(shrimp) We ought to be able to conclude likes(John, shrimp) We can do this by unifying the variable X with the constant shrimp This is the same “unification” as is done in Prolog This unification turns seafood(X)  likes(John, X) into seafood(shrimp)  likes(John, shrimp) Together with the given fact seafood(shrimp), the final deductive step is easy

The resolution principle Here it is: From X  someLiterals and X  someOtherLiterals ---------------------------------------------- conclude: someLiterals  someOtherLiterals That’s all there is to it! Example: broke(Bob)  well-fed(Bob) ¬broke(Bob)  ¬hungry(Bob) -------------------------------------- well-fed(Bob)  ¬hungry(Bob)

How to prove theorems in logic Here’s how: Transform each fact into clause form Apply the resolution principle to a pair of clauses Clauses are closed with respect to resolution--that is, when you resolve two clauses, you get a new clause Add the new clause to your fact base Stop when you have your answer The number of facts grows linearly You still have to choose a pair of facts to resolve; but... You never have to choose a rule, because there’s only one

A common error You can only do one resolution at a time Example: broke(Bob)  well-fed(Bob)  happy(Bob) ¬broke(Bob)  ¬hungry(Bob) ∨ ¬happy(Bob) You can resolve on broke to get: well-fed(Bob)  happy(Bob)  ¬hungry(Bob)  ¬happy(Bob)  T Or you can resolve on happy to get: broke(Bob)  well-fed(Bob)  ¬broke(Bob)  ¬hungry(Bob)  T Note that both legal resolutions yield a tautology (a trivially true statement, containing X  ¬X), which is correct but useless But you cannot resolve on both at once to get: well-fed(Bob)  ¬hungry(Bob)

A first example “Everywhere that John goes, Rover goes. John is at school.” at(John, X)  at(Rover, X) (not yet in clause form) at(John, school) (already in clause form) We use implication elimination to change the first of these into clause form: at(John, X)  at(Rover, X) at(John, school) We can resolve these on at(-, -), but to do so we have to unify X with school; this gives: at(Rover, school)

Contradiction A special case occurs when the result of a resolution (the resolvent) is empty, or “NIL” Example: hungry(Bob) ¬hungry(Bob) ---------------- NIL In this case, the fact base is inconsistent This is a very useful observation when doing resolution theorem proving

Refutation resolution The previous example was easy because it had very few clauses When we have a lot of clauses, we want to focus our search on the thing we would like to prove We can do this as follows: Assume that our fact base is consistent (we can’t derive NIL) Add the negation of the thing we want to prove to the fact base Show that the fact base is now inconsistent Conclude the thing we want to prove

Example of refutation resolution “Everywhere that John goes, Rover goes. John is at school. Prove that Rover is at school.” at(John, X)  at(Rover, X) at(John, school) at(Rover, school) (this is the added clause) Resolve #1 and #3: at(John, X) Resolve #2 and #4: NIL Conclude the negation of the added clause: at(Rover, school) This seems a roundabout approach for such a simple example, but it works well for larger problems

Prolog Recall that X  Y  X  Y This is Prolog: A :- B. It means: A is true if B is true This is equivalent to the logical expression: B  A Which is the same as: B  A Also recall that (X  Y)  X  Y This is Prolog: A :- B, C, D. It means: A is true if B, C, and D are all true This is equivalent to the logical expression: B  C  D  A Which is the same as: (B  C  D)  A Which is the same as: B  C  D  A Conclusion: Prolog  Resolution Theorem Proving! Prolog was developed by Alain Colmerauer in 1972 It is sometimes said that Prolog was not devised, but “discovered”

The End