CS 4100 Artificial Intelligence Prof. C. Hafner Class Notes Jan 24, 2012.

Slides:



Advertisements
Similar presentations
First-Order Logic Chapter 8.
Advertisements

Russell and Norvig Chapter 7
Artificial Intelligence
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
Logic Use mathematical deduction to derive new knowledge.
Agents That Reason Logically Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 7 Spring 2004.
Propositional Logic CMSC 471 Chapter , 7.7 and Chuck Dyer
Methods of Proof Chapter 7, Part II. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound) generation.
Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Logic.
Outline Recap Knowledge Representation I Textbook: Chapters 6, 7, 9 and 10.
Logic in general Logics are formal languages for representing information such that conclusions can be drawn Syntax defines the sentences in the language.
Logic. Propositional Logic Logic as a Knowledge Representation Language A Logic is a formal language, with precisely defined syntax and semantics, which.
First-Order Logic Chapter 8.
Logical Agents Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 7 Fall 2005.
1 Problem Solving CS 331 Dr M M Awais Representational Methods Formal Methods Propositional Logic Predicate Logic.
Logical Agents Chapter 7. Why Do We Need Logic? Problem-solving agents were very inflexible: hard code every possible state. Search is almost always exponential.
Logical Agents Chapter 7. Why Do We Need Logic? Problem-solving agents were very inflexible: hard code every possible state. Search is almost always exponential.
Logical Agents Chapter 7.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Lecture 8 Jim Martin.
Methods of Proof Chapter 7, second half.
INTRODUÇÃO AOS SISTEMAS INTELIGENTES Prof. Dr. Celso A.A. Kaestner PPGEE-CP / UTFPR Agosto de 2011.
Knoweldge Representation & Reasoning
Logical Agents Chapter 7 Feb 26, Knowledge and Reasoning Knowledge of action outcome enables problem solving –a reflex agent can only find way from.
Logical Agents Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 7 Spring 2005.
Logical Agents Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 7 Spring 2008.
First-Order Logic Chapter 8. Outline Why FOL? Syntax and semantics of FOL Using FOL Wumpus world in FOL Knowledge engineering in FOL.
Rutgers CS440, Fall 2003 Propositional Logic Reading: Ch. 7, AIMA 2 nd Ed. (skip )
Agents that Reason Logically Logical agents have knowledge base, from which they draw conclusions TELL: provide new facts to agent ASK: decide on appropriate.
Propositional Logic Agenda: Other forms of inference in propositional logic Basics of First Order Logic (FOL) Vision Final Homework now posted on web site.
Knowledge representation methods جلسه سوم. KR is AI bottleneck The most important ingredient in any expert system is knowledge. The power of expert systems.
Logical Agents Chapter 7 (based on slides from Stuart Russell and Hwee Tou Ng)
CS 4100 Artificial Intelligence Prof. C. Hafner Class Notes Jan 19, 2012.
Pattern-directed inference systems
1 Logical Agents CS 171/271 (Chapter 7) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Logical Agents Logic Propositional Logic Summary
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
First-Order Logic Chapter 8. Outline Why FOL? Syntax and semantics of FOL Using FOL Wumpus world in FOL Knowledge engineering in FOL.
An Introduction to Artificial Intelligence – CE Chapter 7- Logical Agents Ramin Halavati
CS 4100 Artificial Intelligence Prof. C. Hafner Class Notes Jan 17, 2012.
Logical Agents Chapter 7. Knowledge bases Knowledge base (KB): set of sentences in a formal language Inference: deriving new sentences from the KB. E.g.:
1 Logical Agents CS 171/271 (Chapter 7) Some text and images in these slides were drawn from Russel & Norvig’s published material.
1 Logical Agents Chapter 7. 2 A simple knowledge-based agent The agent must be able to: –Represent states, actions, etc. –Incorporate new percepts –Update.
Logical Agents Chapter 7. Outline Knowledge-based agents Logic in general Propositional (Boolean) logic Equivalence, validity, satisfiability.
1 Logical Inference Algorithms CS 171/271 (Chapter 7, continued) Some text and images in these slides were drawn from Russel & Norvig’s published material.
1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start  Breeze.
Artificial Intelligence First-Order Logic (FOL). Outline of this Chapter The need for FOL? What is a FOL? Syntax and semantics of FOL Using FOL.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Lecture 11 Jim Martin.
First-Order Logic Chapter 8 (not 8.1). Outline Why FOL? Why FOL? Syntax and semantics of FOL Syntax and semantics of FOL Using FOL Using FOL Wumpus world.
First-Order Logic. Outline Why FOL? Syntax and semantics of FOL Using FOL Knowledge engineering in FOL.
First-Order Logic Reading: C. 8 and C. 9 Pente specifications handed back at end of class.
Dr. Shazzad Hosain Department of EECS North South Universtiy Lecture 04 – Part B Propositional Logic.
Computing & Information Sciences Kansas State University Wednesday, 13 Sep 2006CIS 490 / 730: Artificial Intelligence Lecture 10 of 42 Wednesday, 13 September.
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
1 UNIT-3 KNOWLEDGE REPRESENTATION. 2 Agents that reason logically(Logical agents) A Knowledge based Agent The Wumpus world environment Representation,
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents Chapter 7 Part I. 2 Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic.
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
ECE457 Applied Artificial Intelligence Fall 2007 Lecture #6
Knowledge Representation using First-Order Logic
EA C461 – Artificial Intelligence Logical Agent
Logic Use mathematical deduction to derive new knowledge.
Artificial Intelligence
CS 416 Artificial Intelligence
Knowledge Representation I (Propositional Logic)
Methods of Proof Chapter 7, second half.
Logical Agents Prof. Dr. Widodo Budiharto 2018
Presentation transcript:

CS 4100 Artificial Intelligence Prof. C. Hafner Class Notes Jan 24, 2012

Topics for today Finish discussion of propositional logic – Forms of clauses – Refutation resolution – Forward chaining in PL (review) – Backward chaining in PL Discussion of Homework 2 Review wumpus world model using PL First order logic Wumpus world model using FOL

Disjunctive and Implicative form of clauses ~P1 v ~P2 v... v ~Pn v Q V R – disjunctive form Same as: P1 ^ P2 ^... ^ Pn  Q V R -- implicative form What about: ~P1 v ~P2 v... v ~Pn Implicative form is: P1 ^ P2 ^... ^ Pn  {}{} == False What about Q (single positive literal). Implicative form is: True  Q (or just Q) Any logical sentence can be converted to (one or more) clauses!!

Horn clauses and Definite clauses All Clauses Horn clauses: 0 or 1 positive literals Definite clauses: 1 positive literal

Review: The Resolution Rule for Propositional Logic [P1 v P2 v... Pk ]  [  P1 v Q2 v... Qn ] P2 v... Pk v Q2 v... Qn A generalization of modus ponens: P1  [  P1 v Q] Note: [  P1 v Q] equivalent to P1  Q Q

Refutation Resolution Assert the negation of what you want to prove and resolve with current database to obtain {}. Very useful when we move to FOL A simple example: E  A ~E  B Prove: A v B using refutation resolution

Any KB (i.e., any sentence) can be transformed into an equivalent CNF representation 1.Replace P => Q with  P v Q 2.Replace   P with P 3.Replace  (P v Q) with  P ^  Q 4.Replace  (P ^ Q) with  P v  Q 5. Apply distributive rule replacing: (P ^ Q) v R with (P v R) ^ (Q v R)

Class Exercise Convert the following to CNF (a list of clauses) Convert the CNF clauses to implicative form a)A v B v C b)A ^ B ^ C c)~A v ~B d)~A ^ ~B e)~A v ~B v C v D v E f)(A ^ B) v C g)~(A ^ ~B) v C

Class Exercise (from text) Given the following, can you prove that the unicorn is mythical? Magical? Horned? If the unicorn is mythical, then it is immortal, but if it 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.

Convert to Clause form If the unicorn is mythical, then it is immortal, C1 mythical  ~mortal C1a ~mythical v ~mortal If not mythical, then it is a mortal mammal C2. ~mythical  mortal ^ mammal C2a mythical v mortal C2b mythical v mammal If the unicorn is either immortal or a mammal, then it is horned. C3 (~mortal v mammal)  horned == (mortal ^ ~mammal) v horned C3a mortal v horned C3b ~mammal v horned The unicorn is magical if it is horned. C4 horned  magical C4a ~horned v magical Prove “magical” by refutation

A common error Derive: ~mortal v mortal v horned Does this imply horned ?? NO Why? Because it is true whether horned is T or F

Review: Forward chaining: takes a KB of Horn clauses Basis of forward chaining P  Q is an assertion in the KB P is a new percept Conclude Q Two views of KB – All implications are made explicit vs. – Reasoning on demand “Pure” forward chaining suggests the former

Forward chaining algorithm (KB of Definite Clauses) Notes: 1. An efficient implementation requires an index of the rules by LHS symbols 2. How are infinite loops prevented by this algorithm ? ALGORITHM (recursive): PLForwardChain() uses KBase -- a knowledge base of Horn clauses for each new percept p PLForwardChain1(p) #use a recursive "helper function" PLForwardChain1(percept) if percept is already in KBase, return else add percept to KBase for r in rules where conclusion of r is not already in KBase if percept is a premise of r and all the other premises of r are known PLForwardChain1(conclusion of r)

Review forward chaining algorithm How are infinite loops prevented by this algorithm ? ALGORITHM (recursive): PLForwardChain() uses KBase -- a knowledge base of Horn clauses for each new percept p PLForwardChain1(p) #use a recursive "helper function" PLForwardChain1(percept) if percept is already in KBase, return else add percept to KBase for r in rules where conclusion of r is not already in KBase if percept is a premise of r and all the other premises of r are known PLForwardChain1(conclusion of r)

HW2: Input format for this knowledge base vegetable  edible vegetable ^ green  healthy edible ^ healthy  recommended apple  fruit  edible edible IF vegetable healthy IF vegetable green recommended IF edible healthy fruit IF apple edible Python: tokenlist = line.split() #string  list of strings

Backward chaining: goal driven reasoning triggered by a new percept (fact) Basis of backward chaining P ^ R  Q is an assertion in the KB Q is a query we want to prove (or disprove) Set up P and R as sub-queries, if they are true then Q is proved What if we cannot find Q or a rule that succeeds in proving Q. Then we answer False. This is called negation by failure. (It is not the same as a real logical proof of ~Q). Note: P  ~Q is not a Horn Clause. It normalizes to P V Q, which has two positive literals

Backward chaining: goal-driven reasoning – triggered by a question being asked KB: fruit  edible vegetable  edible edible ^ green  healthy apple  fruit banana  fruit spinach  vegetable spinach  green edible ^ healthy  recommended  apple Consider some queries: ? apple? fruit ? banana ? edible ? healthy

Sketch of Backward Chaining algorithm backwardChain(KB, query) returns Boolean if query is in KB, return True for each rule r in KB such that RHS(r) == query testing = True for each element e of the LHS(r) if backwardChain(KB, e) = False testing = False break if testing = True return True return False NOTE that backward chaining does not update the KB

The Wumpus World in PL What we need to represent: I. Static knowledge The relevant ontology of possible world configurations: locations on a 4 by 4 grid and their properties ex: Pxy means a pit at location x,y Player’s current state (Lxy, has-arrow) The axioms of the world’s configurations L21 ^ Breeze  P22 v P31 Player’s current percepts: Breeze, Stench, etc.

The Wumpus World in PL Additional static world axioms: There is exactly one wumpus: W21 v W31 v... W44 == there is at least one There is at most one: ~(W21 ^ W22) -- one axiom like this for each pair

The Wumpus World in PL (cont) What we need to represent: II. Dynamic knowledge The agent’s possible actions: up, down, left right, grab, shoot The result of the agent’s actions: requires temporal indexing: L110 ^ up0  L one for each location X action X timestep L110 ^ has-arrow0 ^ shoot0  L111 ^ ~has-arrow1 The frame problem requires more: L110 ^ up0  L211 ^ ~L111 But it is even worse: L110 ^ has-arrow0 ^ up0  L211 ^ ~L111 ^ has-arrow1 L110 ^ ~has-arrow0 ^ up0  L211 ^ ~L111 ^ ~has-arrow1 The frame problem arises when we use temporal indexing!!! It causes axioms to multiply almost without limit.

First Order Logic (FOL) Why FOL? Syntax and semantics of FOL Using FOL Wumpus world in FOL Knowledge engineering in FOL

Pros and cons of propositional logic Propositional logic is declarative Propositional logic allows partial/disjunctive/negated information – (unlike most data structures and databases) – (Horn clauses an intermediate form) Propositional logic is compositional: – meaning of B 1,1  P 1,2 is derived from meaning of B 1,1 and of P 1,2 Meaning in propositional logic is context-independent – (unlike natural language, where meaning depends on context)  Propositional logic has very limited expressive power – (unlike natural language) – E.g., cannot say "pits cause breezes in adjacent squares“ except by writing one sentence for each square

First-order logic Whereas propositional logic limits world models to atomic facts such as P12  B22 first-order logic (like natural language) can manipulate world models that include: – Objects: people, houses, numbers, colors, baseball games, wars, … – Relations: red, round, prime, brother of, bigger than, part of, comes between, … – Functions: father, nationality, one more than, plus, … and structured facts such as: Adjacent([x,y], [z,w]) ^ Pit([x,y])  Breeze([z,w])

Syntax of FOL: Basic elements Constant symbolsKingJohn, 2, NU,... Predicate symbolsIsHappy, Likes, >,... Function symbolsSqrt, Nationality,... Variablesx, y, a, b,... Connectives , , , ,  Equality= Quantifiers ,  The constant, predicate and function symbols are called a “logical language”. Given a LL we can then define all the logical sentences that can be expressed.

Atomic sentences Atomic sentence =predicate (term 1,...,term n ) | term 1 = term 2 Term =constant | variable | function (term 1,...,term n ) E.g., Brother(KingJohn,RichardTheLionheart) Greater (AgeOf(Richard), AgeOf(John)) Brother (AgeOf(Richard), AgeOf(John))

Complex sentences Complex sentences are made from atomic sentences using connectives (with the same semantics as propositional logic)  S, S 1  S 2, S 1  S 2, S 1  S 2, S 1  S 2, E.g. Sibling(John,Richard) <  Sibling(Richard,John) >(1,2)  ≤ (1,2) >(1,2)   >(1,2)

Complex sentences (cont.) Additional complex sentences may include quantifiers:  and   var [S]  var [S] Abbreviate:  x  y  z [S] as  x, y, z [S] Abbreviate:  x  y  z [S] as  x, y, z [S]

Meaning and truth in first-order logic Sentences of FOL are true with respect to a model and an interpretation A model for a FOL language is a “world” of objects (domain elements) and relations among them (compare with propositional logic model) Interpretation I specifies referents for constant symbols → objects predicate symbols → relations function symbols →functions An atomic sentence P(term 1,...,term n ) is true iff the objects referred to by term 1,...,term n are in the relation I (P)

Meaning and truth in first-order logic (cont.) Complex sentences: truth is defined using the same truth tables: S 1  S 2 is true iff S 1 is true and S 2 is true.  x [S] is true iff, for any object C in the model S[x/C] is true  x [S] is true iff, for at least one object C in the model S[x/C] is true

Models for FOL: Example symbols: constant relation function