proposi/onal logic, first- order logic CS 4100/5100 Founda/ons of AI

Similar documents
CS 771 Artificial Intelligence. Propositional Logic

Proof Methods for Propositional Logic

Outline. Logic. Knowledge bases. Wumpus world characteriza/on. Wumpus World PEAS descrip/on. A simple knowledge- based agent

Class Assignment Strategies

Intelligent Agents. Pınar Yolum Utrecht University

Logic. Introduction to Artificial Intelligence CS/ECE 348 Lecture 11 September 27, 2001

CS 7180: Behavioral Modeling and Decision- making in AI

Logical Agents. Chapter 7

Knowledge Based Systems: Logic and Deduction

Outline. Logical Agents. Logical Reasoning. Knowledge Representation. Logical reasoning Propositional Logic Wumpus World Inference

Logical Agent & Propositional Logic

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

Logical Agent & Propositional Logic

Artificial Intelligence Chapter 7: Logical Agents

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

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

Logical Agents (I) Instructor: Tsung-Che Chiang

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

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

AI Programming CS S-09 Knowledge Representation

Logical Agents. Outline

Inference in First-Order Predicate Calculus

Logical Agents. Chapter 7

Artificial Intelligence

Artificial Intelligence

Revised by Hankui Zhuo, March 21, Logical agents. Chapter 7. Chapter 7 1

Introduction to Intelligent Systems

Propositional Logic: Logical Agents (Part I)

INF5390 Kunstig intelligens. Logical Agents. Roar Fjellheim

Introduction to Intelligent Systems

The Wumpus Game. Stench Gold. Start. Cao Hoang Tru CSE Faculty - HCMUT

7.5.2 Proof by Resolution

7. Logical Agents. COMP9414/ 9814/ 3411: Artificial Intelligence. Outline. Knowledge base. Models and Planning. Russell & Norvig, Chapter 7.

Lecture Overview [ ] Introduction to Artificial Intelligence COMP 3501 / COMP Lecture 6. Motivation. Logical Agents

Outline. Logical Agents. Logical Reasoning. Knowledge Representation. Logical reasoning Propositional Logic Wumpus World Inference

TDT4136 Logic and Reasoning Systems

CSCI-495 Artificial Intelligence. Lecture 17

Logical agents. Chapter 7. Chapter 7 1

Logical Agents. Santa Clara University

7 LOGICAL AGENTS. OHJ-2556 Artificial Intelligence, Spring OHJ-2556 Artificial Intelligence, Spring

Chương 3 Tri th ức và lập luận

Artificial Intelligence. Propositional logic

Logic & Logic Agents Chapter 7 (& background)

Logical Agents: Propositional Logic. Chapter 7

Logic. proof and truth syntacs and semantics. Peter Antal

Propositional Logic: Logical Agents (Part I)

Propositional Logic: Methods of Proof (Part II)

Introduction to Artificial Intelligence. Logical Agents

CS 331: Artificial Intelligence Propositional Logic I. Knowledge-based Agents

Knowledge-based Agents. CS 331: Artificial Intelligence Propositional Logic I. Knowledge-based Agents. Outline. Knowledge-based Agents

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

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

Logic & Logic Agents Chapter 7 (& Some background)

Lecture 7: Logic and Planning

Lecture 7: Logical Agents and Propositional Logic

CS 380: ARTIFICIAL INTELLIGENCE

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

Logical Agents. Course material: Artificial Intelligence: A Modern Approach, 3 rd Edition, Chapter 7

CS 380: ARTIFICIAL INTELLIGENCE PREDICATE LOGICS. Santiago Ontañón

Kecerdasan Buatan M. Ali Fauzi

CS 730/830: Intro AI. 1 handout: slides. Wheeler Ruml (UNH) Lecture 11, CS / 15. Propositional Logic. First-Order Logic

7. Propositional Logic. Wolfram Burgard and Bernhard Nebel

CS 4700: Artificial Intelligence

Logical Agents. Outline

Inference in first-order logic

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

CS:4420 Artificial Intelligence

CS 4700: Foundations of Artificial Intelligence

Knowledge- Based Agents. Logical Agents. Knowledge Base. Knowledge- Based Agents 10/7/09

CS 771 Artificial Intelligence. First Order Logic Inference

Logical Agents. Soleymani. Artificial Intelligence: A Modern Approach, 3 rd Edition, Chapter 7

Outline. Inference in first- order logic: just a taste. Universal instan8a8on (UI) Inference with Quan8fiers. Reduc8on to proposi8onal inference

Inf2D 06: Logical Agents: Knowledge Bases and the Wumpus World

First Order Logic (FOL) and Inference

Logical Agents. Soleymani. Artificial Intelligence: A Modern Approach, 3 rd Edition, Chapter 7

Last update: March 4, Logical agents. CMSC 421: Chapter 7. CMSC 421: Chapter 7 1

Adversarial Search & Logic and Reasoning

Inference in first-order logic

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

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence

Logical Inference. Artificial Intelligence. Topic 12. Reading: Russell and Norvig, Chapter 7, Section 5

CS 188: Artificial Intelligence Spring 2007

Inference in first-order logic

CS 380: ARTIFICIAL INTELLIGENCE LOGICAL AGENTS. Santiago Ontañón

Inference in First-Order Logic

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

First Order Logic (FOL)

Date Topic Readings Due 11/18 First-order logic Ch. 9 HW 6 11/25 First-order inference, Ch. 10 HW7 (Othello) 12/2 Planning. Chs. 11 & 12 HW8.

Rational Agents. Paolo Turrini. Introduction to Artificial Intelligence 2nd Part. Department of Computing, Imperial College London

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

CSCI 5582 Artificial Intelligence. Today 9/28. Knowledge Representation. Lecture 9

Propositional Logic: Methods of Proof. Chapter 7, Part II

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

Agents that reason logically

Foundations of Artificial Intelligence

Propositional Logic: Methods of Proof (Part II)

Propositional and First-Order Logic

Introduc)on to Ar)ficial Intelligence

Lecture 6: Knowledge 1

Transcription:

proposi/onal logic, first- order logic CS 4100/5100 Founda/ons of AI

Announcements Assignment 1 out Due September 27 th, 6pm Piazza Blackboard Reading Responses

PROPOSITIONAL LOGIC

Knowledge- Based Agents Understanding of the World if it is raining then the ground is wet if the sprinkler is on then the ground is wet if the sprinkler is on then it isn t raining

Knowledge- Based Agents Understanding of the World if it is raining then the ground is wet if the sprinkler is on then the ground is wet if the sprinkler is on then it isn t raining Percepts the sprinkler is on

Knowledge- Based Agents Understanding of the World if it is raining then the ground is wet if the sprinkler is on then the ground is wet if the sprinkler is on then it isn t raining Percepts the sprinkler is on Updated Understanding of the World it isn t raining the ground is wet

ProposiDonal Logic Understanding of the World raining - > ground_wet sprinkler - > ground_wet sprinkler - > not raining

ProposiDonal Logic Understanding of the World raining - > ground_wet sprinkler - > ground_wet sprinkler - > not raining Percepts sprinkler

ProposiDonal Logic Understanding of the World raining - > ground_wet sprinkler - > ground_wet sprinkler - > not raining Percepts sprinkler Updated Understanding of the World not raining ground_wet

Possible Worlds sprinkler raining ground_wet raining - > ground_wet sprinkler - > ground_wet sprinkler - > not raining T T T T T F T T F F F F T F T T T T T F F T F T F T T T T T F T F F T T F F T T T T F F F T T T

Possible Worlds Perceive Sprinkler sprinkler raining ground_wet raining - > ground_wet sprinkler - > ground_wet sprinkler - > not raining T T T T T F T T F F F F T F T T T T T F F T F T F T T T T T F T F F T T F F T T T T F F F T T T

Possible Worlds sprinkler raining ground_wet raining - > ground_wet sprinkler - > ground_wet sprinkler - > not raining T T T T T F T T F F F F T F T T T T T F F T F T F T T T T T F T F F T T F F T T T T F F F T T T

Possible Worlds perceive ground wet sprinkler raining ground_wet raining - > ground_wet sprinkler - > ground_wet sprinkler - > not raining T T T T T F T T F F F F T F T T T T T F F T F T F T T T T T F T F F T T F F T T T T F F F T T T

Theorem Proving with Logical Inference Faster than model checking Checking for entailed sentences through proofs

Tautology Sentences that are necessarily true P v ~P Sentences that must be true are valid

DeducDon Theorem A entails B iff the sentence A - > B is valid.

SaDsfiability A sentence X is sadsfiable if there exists a model such that X is true. A sentence X is unsadsfiable if there exists no model such that X is true.

Proof by ContradicDon KB entails A iff the sentence ~A ^ KB is unsadsfiable

Proof by ContradicDon Understanding of the World if it is raining then the ground is wet if the sprinkler is on then the ground is wet if the sprinkler is on then it isn t raining Percepts the sprinkler is on Claim: the ground is not wet

Proof by ContradicDon Understanding of the World if it is raining then the ground is wet if the sprinkler is on then the ground is wet if the sprinkler is on then it isn t raining Percepts the sprinkler is on Claim: the ground is not wet ContradicDon: if the sprinkler is on then the ground is wet

Proof by ContradicDon Understanding of the World if it is raining then the ground is wet if the sprinkler is on then the ground is wet if the sprinkler is on then it isn t raining Percepts the sprinkler is on Claim: the ground is not wet ContradicDon: if the sprinkler is on then the ground is wet Conclusion: the ground is wet

Logical Equivalence

Modus Ponens if a - > b and a is true, then b is true KB0: raining - > ground_wet. KB1: raining.

Modus Ponens if a - > b and a is true, then b is true KB0: raining - > ground_wet. KB1: raining. Conclusion: ground_wet.

Modus Tollens if a - > b is true and b is false, then a is false. KB0: raining - > ground_wet. KB1: not ground_wet.

Modus Tollens if a - > b is true and b is false, then a is false. KB0: raining - > ground_wet. KB1: not ground_wet. Conclusion: not raining.

And- EliminaDon if a ^ b is true, then a is true and b is true KB: sprinkler and warm. Conclusion: sprinkler. warm.

Back to Wumpus World Environment 4x4 grid agent starts at [1, 1] Squares adjacent to wumpus are smelly Squares adjacent to pit are breezy Gli`er iff gold is in the same square Shoo/ng kills wumpus if you face it Shoo/ng uses the only arrow Grabbing picks up gold in the same square Climbing exits the cave if at [1,1] AcDons: Forward, TurnLeb, TurnRight, Grab, Shoot, Climb Percepts: Stench, Breeze, Gli`er, Bump, Scream

Wumpus World: ProposiDon Symbols World Representa/on: P x,y W x,y Agent Percep/on: S x,y B x,y

Wumpus Inference Example 1. ~P 1,1 %percept 2. B 1,1 <- > (P 1,2 v P 2,1 ) %rule 3. B 2,1 <- > (P 1,1 v P 2,2 v P 3,1 ) %rule 4. ~B 1,1 %percept 5. B 2,1 %percept Prove that there is no pit in [1,2].

Logical Equivalence

ResoluDon Applies to two clauses in which there are complementary literals A v B v C ~C v D v E

ResoluDon Applies to two clauses in which there are complementary literals A v B v C ~C v D v E

ResoluDon Applies to two clauses in which there are complementary literals A v B v C ~C v D v E A v B v D v E

Proof by ResoluDon 1. P v Q 2. ~P v R 3. ~Q v R Prove R.

ResoluDon Resolu/on on its own is enough for inferring all sentences from a knowledge base. but it s only good for disjunc/ve clauses

ResoluDon Resolu/on on its own is enough for inferring all sentences from a knowledge base. but it s only good for conjunc/ons. Every sentence can be converted to conjuncdve normal form.

ConjuncDve Normal Form A sentence expressed purely as a conjunc/on of disjunc/ve clauses. (A v B v C) ^ (D v E v ~A) ^ (A v C v E)

Logical Equivalence

AcDvity: ConverDng to CNF 1. P v Q - > R ^ S? 2. B 1,1 <- > (P 1,2 v P 2,1 )?

AcDvity: Unicorns If the unicorn is mythical, then it is immortal. But if the unicorn is not mythical, then it is a mortal mammal. If the unicorn is either immortal or a mammal then it is horned. The unicorn is magical if it is horned. Can you prove the unicorn is mythical? Magical? Horned?

Horn Clauses: A Special Case Horn clause: a clause with at most one posi/ve literal ~A v ~B v ~C v ~D Definite clause: a Horn clause with exactly one posi/ve literal ~A v ~B v C v ~D

Chaining Horn clauses are closed under resoludon (~A v B v ~C) (~B v ~D v ~E v F) ~A v ~C v ~D v ~E v F

Forward Chaining Start with known facts and derive new knowledge to add to the knowledge base Agent can derive conclusions from incoming percepts Data- driven approach

Forward Chaining Horn clauses: C1: ~P 1 v ~P 2 v P 4 (P 1 ^ P 2 - > P 4 ) C2: ~P 4 v P 5 (P 4 - > P 5 ) Facts: P 1, P 2

Forward Chaining Horn clauses: C1: ~P 1 v ~P 2 v P 4 (P 1 ^ P 2 - > P 4 ) C2: ~P 4 v P 5 (P 4 - > P 5 ) Facts: P 1, P 2 Percepts P 1 and P 2 resolve with C1 to get P 4

Forward Chaining Horn clauses: C1: ~P 1 v ~P 2 v P 4 (P 1 ^ P 2 - > P 4 ) C2: ~P 4 v P 5 (P 4 - > P 5 ) Facts: P 1, P 2 Percepts P 1 and P 2 resolve with C1 to get P 4 Resolve P 4 with C2 to get P 5

Backward Chaining Goal- driven reasoning Work backwards to see if query is true If inconclusive, query is false Efficient: only touches relevant facts or rules

Backward Chaining Horn clauses: C1: ~P 1 v ~P 2 v P 4 (P 1 ^ P 2 - > P 4 ) C2: ~P 4 v P 5 (P 4 - > P 5 ) Facts: P 1, P 2 Goal: P 5 Subgoal: prove P 4

Backward Chaining Horn clauses: C1: ~P 1 v ~P 2 v P 4 (P 1 ^ P 2 - > P 4 ) C2: ~P 4 v P 5 (P 4 - > P 5 ) Facts: P 1, P 2 Goal: P 5 Subgoal: prove P 4 Sub- sub goal: prove P 2 Sub- sub goal: prove P 1

FIRST- ORDER LOGIC

More Flexibility Objects Rela/ons Func/ons (special kind of rela/on)

Some examples Squares neighboring the wumpus are smelly. Objects: Wumpus, squares Rela/ons: Smelly (property), neighboring

Some examples The father of Gillian is John. Objects: Gillian, John Rela/ons: father (also a func/on) John is an engineer. Objects: John Rela/ons: engineer (property)

Some examples Founda/ons of AI is a fun class! Objects:? Rela/ons:? Boston is cold in the winter and warm in the summer. Objects:? Rela/ons:?

Ontological Commitments What is the nature of reality? Objects with rela/onships that do not change with /me Rela/onships are true or false (or no opinion) Other kinds of languages Temporal logic Fuzzy logic Higher order logic Probability theory

First Order Logic - Syntax Constants john, gillian, mary Predicates president(america, obama) Func/ons father(gillian) = john Variables X, Y, Z Connec/ves ^ v ~ - > Quantifiers,

ConverDng English to First Order Logic Stephen and Jeremy are friends. Sarah is a computer scien/st. If a person is a computer scien/st, then Stephen is friends with them.

ConverDng English to First Order Logic Stephen and Jeremy are friends. friends(stephen, jeremy). Sarah is a computer scien/st. If a person is a computer scien/st, then Stephen is friends with them.

ConverDng English to First Order Logic Stephen and Jeremy are friends. friends(stephen, jeremy). Sarah is a computer scien/st. computerscien/st(sarah). If a person is a computer scien/st, then Stephen is friends with them.

ConverDng English to First Order Logic Stephen and Jeremy are friends. friends(stephen, jeremy). Sarah is a computer scien/st. computerscien/st(sarah). If a person is a computer scien/st, then Stephen is friends with them. computerscien/st(x) - > friends(stephen, X)

ConverDng English to First Order Logic The enemy of my enemy is my friend. All dogs go to heaven. There is a nice person in class.

ConverDng English to First Order Logic The enemy of my enemy is my friend. enemy(x, Y) ^ enemy(y, Z) - > friend(x, Z) All dogs go to heaven. There is a nice person in class.

ConverDng English to First Order Logic The enemy of my enemy is my friend. enemy(x, Y) ^ enemy(y, Z) - > friend(x, Z) All dogs go to heaven. x dog(x) -> afterlife(heaven, x) There is a nice person in class.

ConverDng English to First Order Logic The enemy of my enemy is my friend. enemy(x, Y) ^ enemy(y, Z) - > friend(x, Z) All dogs go to heaven. x dog(x) -> afterlife(heaven, x) There is a nice person in class. x classmate(x) ^ nice(x)

reasoning with first order logic PROLOG

Prolog Logic programming language Use cases: Expert systems Natural language processing Backward chaining

Programming with Prolog Facts monster(zombie). connected(hallway, kitchen). sleepy(student). likes(peanuts, elephant). Rules common_interest(x, Y) :- likes(z, X), likes(z, Y). scary(x) :- monster(x).

UnificaDon Look through knowledge base for sentence that matches the query, unify variables Find the unifier (θ) of unify(a, b) a b θ knows(john, X) knows(y, elizabeth) X/elizabeth, Y/john knows(x, Y) knows(sarah, Y) X/sarah, Y ungrounded knows(john, X) knows(sarah, Y) fail

DerivaDon Trees The law says that it is a crime for an American to sell weapons to hos/le na/ons. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by Colonel West, an American. Is Colonel West a criminal?

DerivaDon Trees criminal(c) american(c) weapon(w) sell (C, W, N) hosdle(n) UnificaDon: {} Goal: criminal(west). Rule: criminal(c) :- american(c), weapon(w), sell(c, W, N), hos/le(n).

DerivaDon Trees criminal(west) american(west) weapon(w) sell (west, W, N) hosdle(n) UnificaDon: {C/west} Goal: criminal(west). Rule: criminal(c) :- american(c), weapon(w), sell(c, W, N), hos/le(n).

DerivaDon Trees criminal(west) american(west) weapon(missile) sell (west, missile, N) hosdle(n) UnificaDon: {C/west, W/missile} Goal: criminal(west). Rule: criminal(c) :- american(c), weapon(w), sell(c, W, N), hos/le(n).

DerivaDon Trees criminal(west) american(west) weapon(missile) sell (west, missile, nono) hosdle(n) UnificaDon: {C/west, W/missile, N/nono} Goal: criminal(west). Rule: criminal(c) :- american(c), weapon(w), sell(c, W, N), hos/le(n).

DerivaDon Trees criminal(west) american(west) weapon(missile) sell (west, missile, nono) hosdle(nono) UnificaDon: {C/west, W/missile, N/nono} Goal: criminal(west). Rule: criminal(c) :- american(c), weapon(w), sell(c, W, N), hos/le(n).

More Prolog Arithme/c Lists There is a great tutorial linked in the assignment!

Assignment 1 Make an adventure game in prolog