Knowledge and reasoning 2

Similar documents
Principles of Intelligent Systems: Situation Calculus

Propositional Logic: Logical Agents (Part I)

Artificial Intelligence Knowledge Representation I

First Order Logic (FOL)

Artificial Intelligence Chapter 7: Logical Agents

Propositional Logic: Logical Agents (Part I)

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

Logical Agents. Santa Clara University

Propositional and First-Order Logic

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

CS 771 Artificial Intelligence. Propositional Logic

Introduction to Intelligent Systems

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

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

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

Logical Agent & Propositional Logic

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

Logical Agents (I) Instructor: Tsung-Che Chiang

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence

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

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

Introduction to Intelligent Systems

Logic & Logic Agents Chapter 7 (& background)

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

Kecerdasan Buatan M. Ali Fauzi

Class Assignment Strategies

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

Artificial Intelligence. Propositional logic

Price: $25 (incl. T-Shirt, morning tea and lunch) Visit:

Propositional Logic: Review

Knowledge Representation Logic and Inference Propositional Logic First-order logic Vumpus World

Logical Agent & Propositional Logic

Intelligent Agents. Pınar Yolum Utrecht University

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

First-order logic. First-order logic. Logics in general. Outline. Syntax of FOL: Basic elements. Pros and cons of propositional logic

CS 4700: Foundations of Artificial Intelligence

First-order logic. Chapter 8. Chapter 8 1

Lecture 8: (Predicate) First Order Logic

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

7.5.2 Proof by Resolution

AI Programming CS S-09 Knowledge Representation

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

CS 380: ARTIFICIAL INTELLIGENCE FIRST ORDER LOGIC. Santiago Ontañón

Overview. Knowledge-Based Agents. Introduction. COMP219: Artificial Intelligence. Lecture 19: Logic for KR

Logical Agents. Chapter 7

Foundations of Artificial Intelligence

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

7. Propositional Logic. Wolfram Burgard and Bernhard Nebel

Introduction to Artificial Intelligence. Logical Agents

Guest Speaker. CS 416 Artificial Intelligence. First-order logic. Diagnostic Rules. Causal Rules. Causal Rules. Page 1

Section Summary. Section 1.5 9/9/2014

INF5390 Kunstig intelligens. Logical Agents. Roar Fjellheim

Logical Agents. Chapter 7

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

COMP3702/7702 Artificial Intelligence Week 5: Search in Continuous Space with an Application in Motion Planning " Hanna Kurniawati"

Proof Methods for Propositional Logic

CS:4420 Artificial Intelligence

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

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

Propositional Logic: Methods of Proof (Part II)

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

First Order Logic. Philipp Koehn. 8 October 2015

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

Knowledge based Agents

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

Logical Agents. Administrative. Thursday: Midterm 1, 7p-9p. Next Tuesday: DOW1013: Last name A-M DOW1017: Last name N-Z

Knowledge engineering, Situation Calculus

Logic. Stephen G. Ware CSCI 4525 / 5525

Logical Agents. Seung-Hoon Na Chonbuk National University. 1 Department of Computer Science

Introduc)on to Ar)ficial Intelligence

Agents that reason logically

Logic & Logic Agents Chapter 7 (& Some background)

KR: First Order Logic - Intro

First Order Logic (FOL)

Logical Agents. Outline

Lecture 7: Logic and Planning

Propositional and First-Order Logic

COMP9414: Artificial Intelligence First-Order Logic

CS 380: ARTIFICIAL INTELLIGENCE INFERENCE IN PROPOSITIONAL LOGIC

First-Order Logic. Doug Downey Northwestern EECS 348 Intro to AI Based on slides by Stuart Russell

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

CS 520: Introduction to Artificial Intelligence. Review

CS 188: Artificial Intelligence Spring 2007

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

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

Propositional Logic Not Enough

Logic: Propositional Logic (Part I)

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

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

Proving logical equivalencies (1.3)

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

Deliberative Agents Knowledge Representation I. Deliberative Agents

! Predicates! Variables! Quantifiers. ! Universal Quantifier! Existential Quantifier. ! Negating Quantifiers. ! De Morgan s Laws for Quantifiers

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

Logical Agents. September 14, 2004

Logic. (Propositional Logic)

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

Knowledge representation DATA INFORMATION KNOWLEDGE WISDOM. Figure Relation ship between data, information knowledge and wisdom.

Transcription:

Knowledge and reasoning 2 DDC65 Artificial intelligence and Lisp Peter Dalenius petda@ida.liu.se Department of Computer and Information Science Linköping University Knowledge-based agents Inside our agent he real world Knowledge base Percept perceive deduce Action execute 1. How can we represent knowledge? 2. How can we draw conclusions? Logic What is the value? It depends on the interpretation! Is it satisfiable? Can it ever be true? Is it a tautology? Is it always true? P Q P P ruth table Q P Q P Does it entail P Q? Is it correct to draw the conclusion P Q? What is a good argument? In order to prove that it is correct to draw the conclusion S when we know KB, we can do either of the following: Prove KB S(entailment) using either a truth table or reasoning with interpretations Prove KB Susing a sound and complete proof system, e.g. resolution Is it equivalent to P Q? Do these two formulas always have the same value? he Wumpus world Representing the Wumpus world PI here is at least one Wumpus in the cave: PI W 1,1 W 1,2 W 1,3 W 4,4 If there is a breeze in square (x, y) then there is a pit in one of the four adjacent squares: PI B x,y P x,y+1 P x,y-1 P x+1,y P x-1,y his is a template for a number of formulas. here is only one Wumpus: hat s a tricky one to represent 1

We need a more expressive logic! What s new in first order logic? Propositional logic (used so far) Each symbol represents a proposition, a single statement that says something about the world. Several things are hard to formulate. irst order predicate logic An extension to propositional logic. Helps us to formulate more complex statements. We can talk about objects (e.g. the different rooms in the cave) denoted by object constants. Example: A, Room1, John he objects can have properties or relations to each other. hese are called predicates. Example: Empty(Room1), ather(john, Mary) We have functions that can return objects. Example: nextroom(room1), fatherof(mary) We have quantifiers to say general things. means for all and means exists. p.247 Sentences in first order logic Sentences in first order logic A term is an expression that refers to an object, either a constant, a variable, or a function application. Example: Room1, x, motherof(john). Note that a term is not a sentence in itself. An atomic sentence states a fact. It is formed from a predicate symbol followed by a list of terms. Example: Mother(Anna, John), Long(tailOf(Cat56)) A complex sentence is formed by connectives, just like in propositional logic. Example: Shining(Sun) Angry(brother(John)) A quantified sentence says something about an entire collection of objects. x P(x) means that P(x) is true for all objects x P(x) means that P(x) is true for some objects p.248 p.249 More examples of formulas Connections between and he sky is blue and the grass is green Blue(Sky) Green(Grass) Color(Sky, Blue) Color(Grass, Green) John is Mary s father fatherof(mary) = John ather(john, Mary) here are nice people x(people(x) Nice(x)) Everyone has a father x y(ather(y,x)) It is ok to use equality. Nobody likes carrots: x Likes(x, Carrots) x Likes(x, Carrots) Everybody likes ice cream: x Likes(x, IceCream) x Likes(x, IceCream) x Likes(x, IceCream) Move inwards, and the quantifier changes. Compare to DeMorgan. p.252 2

Interpretations in first order logic Sample interpretation N 5 What do first order sentences/formulas actually mean? An interpretation in first order logic consists of four parts: he domain, i.e. the set of objects we are talking about. A definition of all the constant symbols. A definition of all the predicate symbols (properties and relations). A definition of all the function symbols. he domain is {0, 1, 2, 3, 4}. here is one constant symbol: Smallest has the value 0 here are two function symbols: plus(x, y) is defined as addition mod 5 minus(x, y) is defined as subtraction mod 5 here is one predicate symbol: Greater(x, y) is defined as true whenever x is greater than y Working with N 5 Working with N 5 Is the following formula true in N 5? x y(greater(x,y) x = y) he formula actually says that there exists a greatest number. If we let x = 5, is the following formula true? y(greater(x,y) x = y) We can try all possible values of y and see if the inner formula is true (which it is). Which of the following formulas are true in the interpretation N 5? x y Greater(plus(x, y), x) x y z (plus(x, y) = z) (minus(z, y) = x) x y (minus(x, y) = Smallest) Experiences from first order logic 1. Convert to propositional logic Much easier to express knowledge compared to propositional logic. Much more complex interpretations, which makes it harder to draw conclusions (no truth tables). We need a sound and complete proof system! We already have resolution for propositional logic. Can we use that? Yes, we can use resolution if we transform our first order formulas into propositional formulas. his is called propositionalization. Example: Instead of x Car(x) Blue(x) we write Blue(C1) Blue(C2) Blue(C3) if the domain consists of cars C1, C2 and C3. We will soon see a method for doing this p.274 3

2. Matching atomic sentences In propositional logic it s easy to match positive and negative literals. R P P, R R In first order logic, it s not clear how we can match atomic sentences with different inner structure. P(f(a), b) P(x, b), R(x, c) Q(b, c) Unification Atomic sentences with different terms can be matched by unification. his is a form of pattern matching that binds variables to values. he two sentences in the example match if the variable x is bound to the term f(a). his must also be done in the resulting sentence. P(f(a), b) P(x, b), R(x, c)??? {x = f(a)} R(f(a), c) p.275 Resolution in first order logic ransformation Our goal is to transform a first order formula to a propositional formula in CN so we can use resolution. If we know KB, is S a valid conclusion? KB S the same as Is the set of formulas KB { S} unsatisfiable? transformation New set of quantifierfree formulas in CN resoluiion (using unification) 1. Rewrite and according to rules. 2. Move inwards. 3. Standardize variables. 4. Skolemize (drop existential qualifiers). 5. Drop universal quantifiers. 6. Distribute over. If we can prove contradiction, then the answer to our original question is yes! Note that the resulting formula is not equivalent to the original one, but it will be satisfiable if and only if the original one is. p.296 Skolemize with at the beginning Skolemize with inside Assume that the following formula is true x y(greater(x,y) x = y) If there exists and x, we can choose that x and call it a, so the formula can be written y(greater(a,y) a = y) a is called a Skolem constant. Assume that the following formula is true x y(greater(x,y)) x = Smallest When is inside an, we cannot introduce a Skolem constant. he y that x is greater than, might not be the same y for all x. Instead we introduce a Skolem function f, so the formula becomes x(greater(x,f(x))) x = Smallest 4

ransformation example x y(p(x,y) x(q(x,y) P(x,y))) rewrite x y( P(x,y) x(q(x,y) P(x,y))) move inwards x y( P(x,y) x (Q(x,y) P(x,y))) x y( P(x,y) x ( Q(x,y) P(x,y))) standardize variables x y( P(x,y) z ( Q(z,y) P(z,y))) Skolemize x( P(x,f(x)) ( Q(g(x),f(x)) P(g(x),f(x)))) drop universal quantifiers P(x,f(x)) ( Q(g(x),f(x)) P(g(x),f(x))) distribute over ( P(x,f(x)) Q(g(x),f(x))) ( P(x,f(x)) P(g(x),f(x))) set of clauses { P(x,f(x)) Q(g(x),f(x)), P(x,f(x)) P(g(x),f(x))} A complete example rom Horses are animals, it follows that he head of a horse is the head of an animal. Demonstrate that this inference is valid by carrying out the following steps: ranslate the premise and the conclusion to the language of first order logic using the predicates HeadOf(h, x), Horse(x) and Animal(x). Negate the conclusion. Convert the premise and the negated conclusion into CN. Use resolution to show that the conclusion follows from the premise (i.e. deduce a contradiction from the negated conclusion). 1. ormulas in first order logic 2. ransform to CN he premise x(horse(x) Animal(x)) he conclusion x y(headof(y,x) Horse(x) Animal(x)) he premise x(horse(x) Animal(x)) x( Horse(x) Animal(x)) Horse(x) Animal(x) { Horse(x) Animal(x)} convert drop set of clauses 2. ransform to CN he negated conclusion x y(headof(y,x) Horse(x) Animal(x)) convert x y( (HeadOf(y,x) Horse(x)) Animal(x)) move inwards x y ( (HeadOf(y,x) Horse(x)) Animal(x)) x y(headof(y,x) Horse(x) Animal(x)) Skolemize y(headof(y,a) Horse(a) Animal(a)) drop HeadOf(y,a) Horse(a) Animal(a) set of clauses {HeadOf(y,a), Horse(a), Animal(a)} 3. Resolution (using unification) Horse(x) Animal(x) HeadOf(y,a) Horse(a) Animal(a) {x = a} Animal(a) 5

ormal languages Knowledge engineering Language Propositional logic irst order logic emporal logic Probability theory uzzy logic What exists in the world? (Ontological commitment) facts facts, objects, relations facts, objects, relations, times facts facts with degree of truth 0..1 What an agent believes about facts (Epistemological commitment) true/false/unknown true/false/unknown true/false/unknown degree of belief 0..1 known interval value 1. Identify the task. 2. Assemble the relevant knowledge. 3. Decide on a vocabulary of predicates, functions, and constants. 4. Encode general knowledge about the domain. 5. Encode a description of the specific problem instance. 6. Pose queries to the inference procedure and get answers. 7. Debug the knowledge base. p.244 p.261 Situation calculus Situation calculus Both propositional and first order logic by default assumes a static world that does not change. But an intelligent agent has to be able to reason about the result of actions and how they change the world. We will briefly discuss situation calculus, implemented in first order logic, that gives us that possibility. We will use the Wumpus world as example. A situation encode everything there is to know about the world at a given time. he function Result(a, s) names the new situation after doing action a in situation s. luents are functions and predicates that vary from one situation to the next. Example: Holding(G 1, S 0 ) Eternal functions and predicates indicate what is true in all situations. Example: Gold(G 1 ) p.328 Situations Describing actions he simplest way to describe actions is by possibility axioms and effect axioms. Examples of possibility axioms: At(A,x 1,s) Adjacent(x 1,x 2 ) Poss(Go(x 1,x 2 ),s) Gold(g) At(A,x,s) At(g,x,s) Poss(Grab(g),s) Examples of effect axioms: Poss(Go(x 1,x 2 ),s) At(A,x 2,Result(Go(x 1,x 2 ),s)) Poss(Grab(g),s) Holding(g,Result(Grab(g),s)) 6

Example of initial knowledge base Searching for gold At(A,[1,1],S 0 ) agent is at [1,1] At(G 1,[1,2],S 0 ) object G 1 is at [1,2] Gold(G 1 ) object G 1 is the gold Adjacent([1,1],[1,2]) [1,1] is next to [1,2] Adjacent([1,2],[1,1]) [1,2] is next to [1,1] Plus possibility and effect axioms Our first step is Go([1,1],[1,2]) which is possible according to the knowledge base, including possibility and effect axioms. Our next step is Grab(G 1 ) since the gold is in [1,2], but this is not possible! rom the knowledge base and the axioms we cannot deduce that the gold is in [1,2] in the situation S 1 = Result(Go([1,1],[1,2],S 0 ). Intuitively this should be obvious, but it is not stated in our axioms! he frame problem Solving the frame problem he effect axiom says what changes, but they don t say what stays the same (e.g. that the gold is still in [1,2]). his is an example of the frame problem. In the real world, most things stay the same from one situation to another. How can we encode this knowledge? If we have A actions and fluent predicates in our language, we need A frame axioms (where most of them say that a fluent is not affected at all). his seems difficult! p.331 Instead of writing out the effect of each action, we consider how each fluent predicate evolves over time. We use successor-state axioms instead: action is possible (fluent is true in result state action s effect made it true it was true before and action left it alone) Example: Poss(a, s) (At(A,y,Result(a,s)) a = Go(x,y) (At(A,y,s) a Go(y,z))) Problems in situation calculus You should be able to Representational frame problem How can we represent what stays the same? Inferential frame problem How can we find the result of a sequence of n actions in a reasonable time? Ramification problem How can we represent implicit effect, e.g. that the gold moves with the agent when grabbed? Qualification problem What happens if the agent crashes inside the cave? Explain basic concepts (e.g. tautology, satisfiability) ormulate sentences in both propositional and first order logic Decide if a formula is true or false in a given interpretation Use resolution in both propositional and first order logic Briefly discuss advanced concepts (e.g. different kinds of logic) 7