COMP4418: Knowledge Representation and Reasoning First-Order Logic

Similar documents
COMP9414: Artificial Intelligence First-Order Logic

Artificial Intelligence: Methods and Applications Lecture 3: Review of FOPL

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

Outline. Logic. Definition. Theorem (Gödel s Completeness Theorem) Summary of Previous Week. Undecidability. Unification

06 From Propositional to Predicate Logic

Propositional Logic Not Enough

Computational Logic Automated Deduction Fundamentals

Logic as a Tool Chapter 4: Deductive Reasoning in First-Order Logic 4.4 Prenex normal form. Skolemization. Clausal form.

CSC384: Intro to Artificial Intelligence Knowledge Representation II. Required Readings: 9.1, 9.2, and 9.5 Announcements:

1 Introduction to Predicate Resolution

Strong AI vs. Weak AI Automated Reasoning

3. The Logic of Quantified Statements Summary. Aaron Tan August 2017

Proseminar on Semantic Theory Fall 2013 Ling 720 First Order (Predicate) Logic: Syntax and Natural Deduction 1

8 General first order representation

2. Use quantifiers to express the associative law for multiplication of real numbers.

Syntax. Notation Throughout, and when not otherwise said, we assume a vocabulary V = C F P.

Convert to clause form:

CS 730/830: Intro AI. 3 handouts: slides, asst 6, asst 7. Wheeler Ruml (UNH) Lecture 12, CS / 16. Reasoning.

CS 730/730W/830: Intro AI

Predicate Logic. CSE 191, Class Note 02: Predicate Logic Computer Sci & Eng Dept SUNY Buffalo

G52DOA - Derivation of Algorithms Predicate Logic

AAA615: Formal Methods. Lecture 2 First-Order Logic

Logic. Stephen G. Ware CSCI 4525 / 5525

GS03/4023: Validation and Verification Predicate Logic Jonathan P. Bowen Anthony Hall

First-Order Predicate Logic. Basics

Agenda Artificial Intelligence. Let s Talk About the Wumpus Instead? Let s Talk About Blocks, Baby...

Automated Reasoning Lecture 5: First-Order Logic

Logic and Modelling. Introduction to Predicate Logic. Jörg Endrullis. VU University Amsterdam

7.5.2 Proof by Resolution

Knowledge based Agents

CS1021. Why logic? Logic about inference or argument. Start from assumptions or axioms. Make deductions according to rules of reasoning.

Introduction to Logic in Computer Science: Autumn 2007

Syntax of FOL. Introduction to Logic in Computer Science: Autumn Tableaux for First-order Logic. Syntax of FOL (2)

2/2/2018. CS 103 Discrete Structures. Chapter 1. Propositional Logic. Chapter 1.1. Propositional Logic

First-Order Logic. Resolution

CogSysI Lecture 8: Automated Theorem Proving

Lecture overview. Knowledge-based systems in Bioinformatics, 1MB602. Reasoning. Reasoning cont. Inference in propositional logic.

Logical Structures in Natural Language: First order Logic (FoL)

03 Review of First-Order Logic

Predicate Calculus. Lila Kari. University of Waterloo. Predicate Calculus CS245, Logic and Computation 1 / 59

Section Summary. Predicate logic Quantifiers. Negating Quantifiers. Translating English to Logic. Universal Quantifier Existential Quantifier

Logic and Reasoning. Foundations of Computing Science. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

2-4: The Use of Quantifiers

Proposi'onal Logic Not Enough

Predicate Calculus - Syntax

Resolution for Predicate Logic

CS156: The Calculus of Computation Zohar Manna Winter 2010

cse 311: foundations of computing Fall 2015 Lecture 6: Predicate Logic, Logical Inference

Motivation. CS389L: Automated Logical Reasoning. Lecture 10: Overview of First-Order Theories. Signature and Axioms of First-Order Theory

Introduction to first-order logic:

Computational Logic. Recall of First-Order Logic. Damiano Zanardini

Predicate Logic. Predicates. Math 173 February 9, 2010

Semantics I, Rutgers University Week 3-1 Yimei Xiang September 17, Predicate logic

Predicate Calculus lecture 1

Logic and Inferences

Predicate Logic: Sematics Part 1

University of Aberdeen, Computing Science CS2013 Predicate Logic 4 Kees van Deemter

Section Summary. Section 1.5 9/9/2014

System f2lp Computing Answer Sets of First-Order Formulas

Agenda. Artificial Intelligence. Reasoning in the Wumpus World. The Wumpus World

6.825 Techniques in Artificial Intelligence. Logic Miscellanea. Completeness and Incompleteness Equality Paramodulation

CS 4700: Artificial Intelligence

Lecture 3 : Predicates and Sets DRAFT

Introduction to Sets and Logic (MATH 1190)

Ling 130 Notes: Predicate Logic and Natural Deduction

First-Order Logic (FOL)

Comp487/587 - Boolean Formulas

Philosophy 240 Symbolic Logic Russell Marcus Hamilton College Fall 2014

3. Only sequences that were formed by using finitely many applications of rules 1 and 2, are propositional formulas.

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms

Outline First-order logic. First-order Logic. Introduction. Recall: 4-Queens problem. First-order Logic. First-order Logic Syntax.

First-Order Logic First-Order Theories. Roopsha Samanta. Partly based on slides by Aaron Bradley and Isil Dillig

Artificial Intelligence

Logic. Knowledge Representation & Reasoning Mechanisms. Logic. Propositional Logic Predicate Logic (predicate Calculus) Automated Reasoning

4 Predicate / First Order Logic

Logic and Mathematics:

Logic: First Order Logic (Part I)

Section Summary. Predicate logic Quantifiers. Negating Quantifiers. Translating English to Logic. Universal Quantifier Existential Quantifier

Interpretations of PL (Model Theory)

Predicate Calculus. Formal Methods in Verification of Computer Systems Jeremy Johnson

Proseminar on Semantic Theory Fall 2013 Ling 720 Propositional Logic: Syntax and Natural Deduction 1

Computing logical consequences

First-Order Logic. Chapter Overview Syntax

Reasoning. Inference. Knowledge Representation 4/6/2018. User

Knowledge base (KB) = set of sentences in a formal language Declarative approach to building an agent (or other system):

ECE 479/579 Principles of Artificial Intelligence Part I Spring Dr. Michael Marefat

Section Summary. Predicates Variables Quantifiers. Negating Quantifiers. Translating English to Logic Logic Programming (optional)

Chapter 16. Logic Programming. Topics. Logic Programming. Logic Programming Paradigm

Logic and Computation

CSE 311: Foundations of Computing. Lecture 6: More Predicate Logic

CS 220: Discrete Structures and their Applications. Predicate Logic Section in zybooks

First Order Logic (FOL) 1 znj/dm2017

README - Syntax. Skolemization. Skolemization - Example 1. Skolemization - Example 1. Skolemization - Example 1. Skolemization - Example 2

Gödel s Incompleteness Theorems

First Order Logic: Syntax and Semantics

13. APPENDIX 1: THE SYNTAX OF PREDICATE LOGIC

ITS336 Lecture 6 First-Order Logic

Computer-Aided Verification

Logic. Foundations of First Order Logic. franconi. Enrico Franconi

Resolution for Predicate Logic

Transcription:

COMP4418: Knowledge Representation and Reasoning First-Order Logic Maurice Pagnucco School of Computer Science and Engineering University of New South Wales NSW 2052, AUSTRALIA morri@cse.unsw.edu.au COMP4418 c UNSW, 2017

COMP4418, Wednesday 2 August, 2017 First-Order Logic 1 First-Order Logic First-order logic furnishes us with a much more expressive knowledge representation language than propositional logic We can directly talk about objects, their properties, relations between them, etc.... Here we discuss first-order logic and resolution However, there is a price to pay for this expressiveness in terms of decidability References: Ivan Bratko, Prolog Programming for Artificial Intelligence, Addison-Wesley, 2001. (Chapter 15) Stuart J. Russell and Peter Norvig, Artificial Intelligence: A Modern Approach, Prentice-Hall International, 1995. (Chapter 6)

COMP4418, Wednesday 2 August, 2017 First-Order Logic 2 Overview Syntax of First-Order Logic Semantics of First-Order Logic Conjunctive Normal Form Unification First-Order Resolution Soundness and Completeness Decidability Conclusion

COMP4418, Wednesday 2 August, 2017 First-Order Logic 3 Syntax of First-Order Logic Constant Symbols: a, b,..., Mary (objects) Variables: x, y,... Function Symbols: f, mother o f, sine,... Predicate Symbols: Mother, likes,... Quantifiers: (universal); (existential) Terms: constant, variable, functions applied to terms (refer to objects) Atomic Sentences: predicate applied to terms (state facts) Ground (closed) term: a term with no variable symbols

COMP4418, Wednesday 2 August, 2017 First-Order Logic 4 Syntax of First-Order Logic Sentence ::= AtomicSentence Sentence Connective Sentence Quantifier Variable Sentence Sentence ( Sentence ) AtomicSentence ::= Predicate ( Term ) Term ::= Function ( Term ) Constant Variable Connective ::= Quantifier ::= Constant ::= a John... Variable ::= x men... Predicate ::= P Red Between... Function ::= f Father...

COMP4418, Wednesday 2 August, 2017 First-Order Logic 5 Converting English into First-Order Logic Everyone likes lying on the beach x Beach(x) Someone likes Fido x Likes(x, Fido) No one likes Fido x Likes(x, Fido) Fido doesn t like everyone x Likes(Fido, x) All cats are mammals x (Cat(x) Mammal(x)) Some mammals are carnivorous x(mammal(x) Carnivorous(x))

COMP4418, Wednesday 2 August, 2017 First-Order Logic 6 Nested Quantifiers Note that the order of quantification is very important Everything likes everything x y Likes(x, y) Something likes something x y Likes(x, y) Everything likes something x y Likes(x, y) There is something liked by everything y x Likes(x, y)

COMP4418, Wednesday 2 August, 2017 First-Order Logic 7 Scope of Quantifiers The scope of a quantifier in a formula φ is that subformula ψ of φ of which that quantifier is the main logical operator Variables belong to the innermost quantifier that mentions them Examples: Q(x) y P(x, y) scope of y is P(x, y) z P(z) Q(z) scope of z is P(z) but not Q(z) x(p(x) x P(x)) x(p(x) Q(x)) ( x P(x) x Q(x))

COMP4418, Wednesday 2 August, 2017 First-Order Logic 8 Terminology Free-variable occurrences in a formula All variables in an atomic formula The free-variable occurrences in φ are those in φ The free-variable occurrences in φ ψ are those in φ and ψ for any connective The free-variable occurrences in x Φ and x Φ are those in Φ except for occurrences of x Open formula A formula in which free variables occur Closed formula A formula with no free variables Closed formulae are also known as sentences

COMP4418, Wednesday 2 August, 2017 First-Order Logic 9 Semantics of First-Order Logic A world in which a sentence is true under a particular interpretation is known as a model of that sentence under the interpretation Constant symbols an interpretation specifies which object in the world a constant refers to Predicate symbols an interpretation specifies which relation in the model a predicate refers to Function symbols an interpretation specifies which function in the model a function symbol refers to Universal quantifier is true iff all all instances are true Existential quantifier is true iff one instance is true

COMP4418, Wednesday 2 August, 2017 First-Order Logic 10 Conversion into Conjunctive Normal Form 1. Eliminate implication φ ψ φ ψ 2. Move negation inwards (negation normal form) (φ ψ) φ ψ (φ ψ) φ ψ x φ x φ x φ x φ φ φ 3. Standardise variables ( x P(x)) ( x Q(x)) becomes ( x P(x)) ( y Q(y))

COMP4418, Wednesday 2 August, 2017 First-Order Logic 11 Conversion into Conjunctive Normal Form 4. Skolemise x P(x) P(a) x y P(x, y) x P(x, f(x)) x y z P(x, y, z) x y P(x, y, f(x, y)) 5. Drop universal quantifiers 6. Distribute over (φ ψ) χ (φ χ) (ψ χ) 7. Flatten nested conjunctions and disjunctions (φ ψ) χ φ ψ χ;(φ ψ) χ φ ψ χ (8. In proofs, rename variables in separate clauses standardise apart)

COMP4418, Wednesday 2 August, 2017 First-Order Logic 12 CNF Example 1 x[( y P(x, y)) y(q(x, y) R(x, y))] 1. x[ ( y P(x, y)) y( Q(x, y) R(x, y))] 2. x[( y P(x, y)) y(q(x, y) R(x, y))] 3. x[( y P(x, y)) z(q(x, z) R(x, z))] 4. x[ P(x, f(x)) (Q(x, g(x)) R(x, g(x)))] 5. P(x, f(x)) (Q(x, g(x)) R(x, g(x))) 6. ( P(x, f(x)) Q(x, g(x))) ( P(x, f(x)) R(x, g(x))) 8. P(x, f(x)) Q(x, g(x)) P(y, f(y)) R(y, g(y))

COMP4418, Wednesday 2 August, 2017 First-Order Logic 13 CNF Example 2 x y z((p(y) Q(z)) (P(x) Q(x))) x y z( (P(y) Q(z)) (P(x) Q(x))) [Eliminate ] x y z( (P(y) Q(z)) (P(x) Q(x))) [Move inwards] x y z( (P(y) Q(z)) (P(x) Q(x))) [Move inwards] x y z ( (P(y) Q(z)) (P(x) Q(x))) [Move inwards] x y z( (P(y) Q(z)) (P(x) Q(x))) [Move inwards] x y z((p(y) Q(z)) ( P(x) Q(x))) [Move inwards] x((p( f(x)) Q((g(x))) ( P(x) Q(x))) [Skolemise] (P( f(x)) Q((g(x))) P(x) Q(x) [Drop ]

COMP4418, Wednesday 2 August, 2017 First-Order Logic 14 Unification Unification takes two atomic formulae and returns a substitution that makes them look the same Example: {x/a, y/z, w/ f(b, c)} Note: 1. Each variable has at most one associated expression 2. No variable with an associated expression occurs within any associated expression {x/g(y), y/ f(x)} is not a substitution Substitution σ that makes a set of expressions identical known as a unifier Substitution σ 1 is a more general unifier than a substitution σ 2 if for some substitution τ, σ 2 = σ 1 τ.

COMP4418, Wednesday 2 August, 2017 First-Order Logic 15 First-Order Resolution Generalised Resolution Rule: For clauses χ Φ and Ψ ζ χ Φ Ψ ζ (χ ζ).θ Where θ is a unifier for atomic formulae Φ and Ψ χ ζ is known as the resolvent

COMP4418, Wednesday 2 August, 2017 First-Order Logic 16 Resolution Example 1 x(p(x) xp(x)) CNF( x(p(x) xp(x))) x ( P(x) x P(x)) [Drive inwards] x( P(x) x P(x)) [Drive inwards] x(p(x) x P(x)) [Drive inwards] x(p(x) z P(z)) [Standardise Variables] x(p(x) P( f(x))) [Skolemise] P(x) P( f(x)) [Drop ] 1. P(x) [ Conclusion] 2. P( f(y)) [ Conclusion] 3. P( f(y)) [1. {x/ f(y)}] 4. [2, 3. Resolution]

COMP4418, Wednesday 2 August, 2017 First-Order Logic 17 Resolution Example 2 1. P( f(x)) Q(g(x)) [ Conclusion] 2. P(y) [ Conclusion] 3. Q(z) [ Conclusion] 4. P( f(a)) Q(g(a)) [1. {x/a}] 5. P( f(a)) [2. {y/ f(a)}] 6. Q(g(a)) [3. {z/g(a)}] 7. Q(g(a)) [4, 5. Resolution] 8. [6, 7. Resolution]

COMP4418, Wednesday 2 August, 2017 First-Order Logic 18 Resolution Example 3 1. man(marcus) [Premise] 2. Pompeian(Marcus) [Premise] 3. Pompeian(x) Roman(x) [Premise] 4. ruler(caesar) [Premise] 5. Roman(y) loyaltyto(y, Caesar) hate(y, Caesar) [Premise] 6. loyaltyto(z, f(z)) [Premise] 7. man(w) ruler(u) tryassassinate(w, u) loyaltyto(w, u) [Premise] 8. tryassassinate(marcus, Caesar) [Premise] 9. hate(marcus, Caesar) [ Conclusion] 10. Roman(Marcus) loyaltyto(marcus, Caesar) hate(marcus, Caesar) [5. {y/marcus}] 11. Roman(Marcus) loyaltyto(marcus, Caesar) [9, 10. Resolution]

COMP4418, Wednesday 2 August, 2017 First-Order Logic 19 Resolution Example 3 12. Pompeian(Marcus) Roman(Marcus) [3. {x/marcus}] 13. loyaltyto(marcus, Caesar) Pompeian(Marcus) [11, 12. Resolution] 14. loyaltyto(marcus, Caesar) [2, 13. Resolution] 15. man(marcus) ruler(caesar) tryassassinate(marcus, Caesar) loyaltyto(marcus, Caesar) [7. {w/marcus, u/caesar}] 16. man(marcus) ruler(caesar) tryassassinate(marcus, Caesar) [14, 15. Resolution] 17. ruler(caesar) tryassassinate(marcus, Caesar) [1, 16. Resolution] 18. tryassassinate(marcus, Caesar) [4, 17. Resolution] 19. [8, 18. Resolution]

COMP4418, Wednesday 2 August, 2017 First-Order Logic 20 Soundness and Completeness Resolution is sound (if λ ρ, then λ = ρ) complete (if λ = ρ, then λ ρ) Decidability First-order logic is not decidable How would you prove this?

COMP4418, Wednesday 2 August, 2017 First-Order Logic 21 Conclusion First-order logic allows us to speak about objects, properties of objects and relationships between objects It also allows quantification over variables First-order logic is quite an expressive knowledge representation language; much more so than propositional logic However, we do need to add things like equality if we wish to be able to do things like counting We have also traded expressiveness for decidability How much of a problems is this? If we add (Peano) axioms for mathematics, then we encounter Gödel s famous incompleteness theorem (which is beyond the scope of this course)