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

Similar documents
Constraint Satisfaction

What we will try to do...

CS 771 Artificial Intelligence. First Order Logic Inference

Introduction to Artificial Intelligence 2 nd semester 2016/2017. Chapter 9: Inference in First-Order Logic

Constraint Satisfaction [RN2] Sec [RN3] Sec Outline

7.5.2 Proof by Resolution

Outline What are CSPs? Standard search and CSPs Improvements. Constraint Satisfaction. Introduction. Introduction

First Order Logic (FOL)

Outline. Reducing first-order inference to propositional inference Unification. Forward chaining Backward chaining

First order logic (FOL) Chapters 8 & 9

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

CS 4700: Artificial Intelligence

CS 730/730W/830: Intro AI

Set 8: Inference in First-order logic. ICS 271 Fall 2013 Chapter 9: Russell and Norvig

Inference in first-order logic

Section Summary. Section 1.5 9/9/2014

CSC242: Intro to AI. Lecture 12. Tuesday, February 26, 13

CSC242: Intro to AI. Lecture 13. Thursday, February 28, 13

Chapter 8 First Order Logic

Set 8: Inference in First-order logic. ICS 271 Fall 2017 Chapter 9: Russell and Norvig

First-Order Logic. Peter Antal

Introduction to Artificial Intelligence Propositional Logic & SAT Solving. UIUC CS 440 / ECE 448 Professor: Eyal Amir Spring Semester 2010

Logic. Stephen G. Ware CSCI 4525 / 5525

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

Inference in First-Order Logic

Inference in Propositional Logic

Logic III. Introduction to Artificial Intelligence CSE 150

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

First Order Logic (FOL)

Logic and Inferences

J Propositional logic is declarative J Propositional logic is compositional: q meaning of B 1,1 P 1,2 is derived from meaning of B 1,1 and of P 1,2

3/29/2017. Logic. Propositions and logical operations. Main concepts: propositions truth values propositional variables logical operations

Nathan Sturtevant FOL

First-Order Logic. Michael Rovatsos. University of Edinburgh R&N: February Informatics 2D

Artificial Intelligence Chapter 9: Inference in First-Order Logic

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

Logic: Propositional Logic (Part I)

473 Topics. Knowledge Representation III First-Order Logic. Logic-Based KR. Propositional. Logic vs. First Order

Predicate Logic & Quantification

Thinking of Nested Quantification

AI Programming CS S-09 Knowledge Representation

COMP9414: Artificial Intelligence First-Order Logic

COMP Intro to Logic for Computer Scientists. Lecture 11

First order Logic ( Predicate Logic) and Methods of Proof

CS 188: Artificial Intelligence Spring 2007

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

Nathan Sturtevant FOL

First-Order Logic. Propositional logic. First Order logic. First Order Logic. Logics in General. Syntax of FOL. Examples of things we can say:

Logic Programming (PLP 11) Predicate Calculus, Horn Clauses, Clocksin-Mellish Procedure


Proof Methods for Propositional Logic

CS 1571 Introduction to AI Lecture 14. First-order logic. CS 1571 Intro to AI. Midterm

Outline. First-order logic. Atomic sentences. Intelligent Systems and HCI D7023E. Syntax of FOL: Basic elements. Pros and cons of propositional logic

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

Description Logics. Foundations of Propositional Logic. franconi. Enrico Franconi

First-Order Logic. Chapter 8

Logical Agents. Outline

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

Predicates, Quantifiers and Nested Quantifiers

First-Order Logic. Chapter 8

Comp487/587 - Boolean Formulas

Inference in first-order logic

Knowledge based Agents

Artificial Intelligence. Propositional logic

A brief introduction to Logic. (slides from

The only sets are the empty set and those made by adjoining something to a set: s: Set(s) s = Ø x, s 2 : Set(s 2 ) s = { x s 2 }.

Logical Agents. Knowledge based agents. Knowledge based agents. Knowledge based agents. The Wumpus World. Knowledge Bases 10/20/14

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

[1] Describe with examples, the three inference rules involving quantifiers

COMP4418: Knowledge Representation and Reasoning First-Order Logic

Propositional and First-Order Logic

Logic Programming (PLP 11) Predicate Calculus Clocksin-Mellish Procedure Horn Clauses

Tautologies, Contradictions, and Contingencies

cse541 LOGIC FOR COMPUTER SCIENCE

First-Order Logic. Chapter 8

Propositional Logic Not Enough

Tecniche di Verifica. Introduction to Propositional Logic

Propositional Logic Basics Propositional Equivalences Normal forms Boolean functions and digital circuits. Propositional Logic.

Logical Agents. CITS3001 Algorithms, Agents and Artificial Intelligence. 2018, Semester 2

Propositional logic II.

CS:4420 Artificial Intelligence

Advanced Topics in LP and FP

Logical Agents. Chapter 7

Propositional Logic and Semantics

Title: Logical Agents AIMA: Chapter 7 (Sections 7.4 and 7.5)

Math.3336: Discrete Mathematics. Nested Quantifiers

ITS336 Lecture 6 First-Order Logic

Intelligent Agents. Pınar Yolum Utrecht University

Introduction to Artificial Intelligence. Logical Agents

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

Introduction. Predicates and Quantifiers. Discrete Mathematics Andrei Bulatov

Introduction to Sets and Logic (MATH 1190)

CS560 Knowledge Discovery and Management. CS560 - Lecture 3 1

Inference in first-order logic

Predicate Calculus - Syntax

Logical Agents. Chapter 7

Propositional Logic: Review

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

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence

Transcription:

First-order Logic CS 486/686 Sept 25, 2008 University of Waterloo Outline First-order logic Syntax and semantics Inference Propositionalization with ground inference Lifted resolution 1 2 Introduction Propositional logic provides a general language to encode deterministic domain knowledge. While the encoding is precise and well defined it is often tedious or complicated. Simple English sentences often lead to long logical formula. Can we make propositional logic more concise and more natural? 1 2 3 4 Recall: 4-Queens problem 1 2 3 4 At least one queen in row 1: Q 11 Q 12 Q 13 Q 14 At most one queen in row 1: Q 11 Q 12 Q 13 Q 14 Q 12 Q 11 Q 13 Q 14 Q 13 Q 11 Q 12 Q 14 Q 14 Q 11 Q 12 Q 13 Repeat for every row, column and diagonal. This is too tedious! Can we be more concise? 3 4 First-order Logic First-order Logic Syntax World consist of objects and relations Has many objects First-order logic: Natural: use predicates to encode relations and constants to encode objects Concise: use quantifiers (e.g.,, ) to talk about many objects simultaneously Sentence Predicate(Term, ) Term = Term (Sentence Connective Sentence) Quantifier Variable, Sentence Sentence Term Function(Term, ) Constant Variable Connective Quantifier Constant A X 1 John Variable a x s Predicate Before HasColor Raining Function Mother LeftLeg 5 6 1

Example: kinship domain Symbols Elizabeth is the mother of Charles Mother(Elizabeth,Charles) Charles is the father of William Father(Charles,William) One s grandmother is the mother of one s parent x,z y Grandmother(x,z) Mother(x,y) Parent(y,z) Constant symbols: objects E.g. William, Elizabeth, Charles Predicate symbols: relationships Binary: Mother(, ), Grandmother(, ) Unary: Female( ) Predicates have a truth value Function symbols: functions Denote an object E.g.: MotherOf(William) = Elizabeth 7 8 Quantifiers Nested Quantifiers Universal quantifier: For all x P(x) P(const1) P(const2) Existential quantifier: There exists x P(x) P(const1) P(const2) Order of identical quantifiers doesn t matter Brothers are siblings x y Brother(x,y) siblings(x,y) y x Brother(x,y) siblings(x,y) Similarly for existential quantifiers x y P(x,y) y x P(x,y) 9 10 Nested Quantifiers Order of different quantifiers matters x y Loves(x,y) Everyone loves someone Conjunction of disjunctions (CNF) x y Loves(x,y) There is a person that loves everyone Disjunction of conjunction (DNF) Connections between and We only need one of the quantifiers De Morgan s rule x P x P P Q (P Q) x P x P (P Q) P Q x P x P P Q ( P Q) x P x P P Q ( P Q) 11 12 2

Special relation Equality We could define an Equality predicate x = y Equality(x,y) True: when x and y are the same False: otherwise Practice: 4-Queens problem 4-queens problem in first-order logic Predicates: Queen(, ) Constants: 1, 2, 3, 4 (column and row numbers) Column constraints: i,j 1,j 2 Queen(i,j 1 ) j 1 j 2 Queen(i,j 2 ) i j Queen(i,j) 13 14 Practice: street puzzle Practice: street puzzle Predicates: House(), Person( ), Color( ), Drink( ), Job( ), Animal( ) Attr(, ) (attribute of) Constants: 1, 2, 3, 4, 5 (house number) English, Spaniard, Japanese, Italian, Norwegian Red, Green, White, Yellow, Blue Tea, Coffee, Milk, Juice, Water Painter, Sculptor, Diplomat, Violinist, Doctor Dog, Snails, Fox, Horse, Zebra Function: Left(x): number of the house to the immediate left of x The Spaniard has a dog x House(x) (Attr(x,Spaniard) Attr(x,Dog)) the green house is on the immediate left of the red house Attr(1,Red) Attr(5,Green) x House(x) x 1 (Attr(x,Red) Attr(Left(x),Green)) 15 16 Propositional vs first-order logic Propositional logic: variables First-order logic: Quantifiers, predicates, constants, functions Syntactically different! Are they equally expressive? Prop logic 1 st -order logic: 1 st -order logic prop logic: yes yes (finite domains) no (infinite domains) Propositional first-order logic Variables predicates Indices constants 4-queens problem: Q 11 Q 12 Q 13 Q 14 Q(1,1) Q(1,2) Q(1,3) Q(1,4) 17 18 3

First-order propositional logic Quantifiers conjunction disjunction Predicates variables Constants indices Functions of constants functions of indices First-order propositional logic x House(x) x 1 (Attr(x,Red) Attr(Left(x),Green)) x House x x 1 (Attr x,red Attr Left(x),Green ) (House 1 1 1 (Attr 1,Red Attr Left(1),Green )) (House 2 2 1 (Attr 2,Red Attr Left(2),Green )) (House 3 3 1 (Attr 3,Red Attr Left(3),Green )) (House 4 4 1 (Attr 4,Red Attr Left(4),Green )) (House 5 5 1 (Attr 5,Red Attr Left(5),Green )) 19 20 Inference Lifted Inference Propositionalize KB Run favorite ground inference algorithm (e.g., backtracking (DPLL), resolution Efficient? No: propositionalizing may yield an exponentially large formula x y z P(x,y,z) conjunction of disjunctions of conjunctions O(n m ) where n is # of constants and m is # of quantifiers Alternative: lifted inference Work directly with first-order formula First-order logic: Quantifiers allow us to characterize several objects simultaneously Lifted inference: Do inference by reasoning about several terms simultaneously Ground terms only when necessary Hope: determine truth value of goal formula without grounding all terms 21 22 Lifted Resolution Reduction to Lifted CNF Two phases 1. Reduce to lifted conjunctive normal form 2. Resolution with unification Six steps 1. Eliminate implications 2. Move negations inwards 3. Standardize variables 4. Skolemize 5. Drop universal quantifiers 6. Distribute over 23 24 4

Reduction to Lifted CNF Example: x [ y Animal(y) Loves(x,y)] [ y Loves(y,x)] 1. Eliminate implications x [ y Animal(y) Loves(x,y)] [ y Loves(y,x)] 2. Move negations inwards (apply DeMorgan s rules) x [ y ( Animal(y) Loves(x,y))] [ y Loves(y,x)] x [ y Animal(y) Loves(x,y)] [ y Loves(y,x)] x [ y Animal(y) Loves(x,y)] [ y Loves(y,x)] Reduction to Lifted CNF x [ y Animal(y) Loves(x,y)] [ y Loves(y,x)] 3. Standardize variables (use different names) x [ y Animal(y) Loves(x,y)] [ z Loves(z,x)] 4. Skolemize (replace existential variables by new constants or functions) x [Animal(F(x)) Loves(x,F(x))] [Loves(G(x),x)] 25 26 Skolemization Skolemization x P(x) There is at least one term x that satisfies P(x) We don t care what that term is Idea: create a new constant Let A be a new constant which could correspond to any object, but since we don t care what that object is, just denote it by this new constant. x P(x) P(A) x y P(x,y) For each x, there is at least one term y that satisfies P(x,y) We don t care what that term is but it may be different for different x Idea: create a new function Let f be a new function that denotes the satisfying term for each x x y P(x,y) P(x,f(x)) 27 28 Reduction to Lifted CNF Resolution with Unification x [Animal(F(x)) Loves(x,F(x))] [Loves(G(x),x)] 5. Drop universal quantifiers (since all remaining variables are universally quantified) [Animal(F(x)) Loves(x,F(x))] [Loves(G(x),x)] 6. Distribute over (to get a CNF) [Animal(F(x)) Loves(G(x),x)] [ Loves(x,F(x)) Loves(G(x),x)] Recall Unit resolution: A (A B) = B A ( A B) = B General resolution: (A B) (B C) = (A C) ( A B) ( B C) = ( A C) Lifted resolution: terms may not match exactly because of variables 29 30 5

Unification Variables are like wild cards that can be anything Find unifier: Unify Knows(John,x) and Knows(John,Jane) Knows(John,Jane) {x/jane} Unify Knows(John,x) and Knows(y,Bill) Knows(John,Bill) {x/bill, y/john} Unify Knows(John,x) and Knows(y,Mother(y)) Knows(John,Mother(John)) {x/mother(john), y/john} Most General Unifier Find unifier that is as general as possible (i.e., preserves as many variables as possible) Find most general unifier: Unify Knows(John,x) and Knows(y,Mother(z)) Knows(John,Mother(z)) {y/john, x/mother(z)} 31 32 Resolution with Unification Next class Find clauses with positive and negative terms that can be unified Eliminate unifying terms and perform substitutions in remaining terms according to most general unifier Reasoning under uncertainty Russell and Norvig, Chapter 13 Unit resolution: A(f(x),x)) [ A(y,g(z)) B(y,z)] = B(f(g(z)),z) {x/g(z),y/f(g(z))} General resolution: [ A(x,y) B(y,f(z))] [ B(u,v) C(v,w)] = [ A(x,y) C(f(z),w)] {u/y,v/f(z)} 33 34 6