Title: Logical Agents (pt 2)
1Logical Agents (pt 2)
2Logical Agents
REVIEW
- Logical agents apply inference to a knowledge
base to derive new information and make
decisions - Basic concepts of logic
- syntax formal structure of sentences
- semantics truth of sentences with respect to
models
- entailment necessary truth of one sentence given
another
- inference deriving sentences from other
sentences
- soundness derivations produce only entailed
sentences
- completeness derivations can produce all
entailed sentences
3Logic
REVIEW
- Logics are formal languages for representing
information such that conclusions can be drawn
- Syntax defines the sentences in the language
- Semantics define the "meaning" of sentences
- i.e., define truth of a sentence in a world
- Entailment means that one thing follows from
another
- KB a
- Knowledge base KB entails sentence a if and only
if a is true in all worlds where KB is true
4Models
REVIEW
- m is a model of a sentence a if a is true in m
- M(a) is the set of all models of a
- KB a iff M(KB) ? M(a)
5Inference Procedures
REVIEW
- KB i a sentence a can be derived
from KB by procedure i
- Soundness
- i is sound if whenever KB i a,it is also true
that KB a
- unsound procedures make things up
- Completeness
- i is complete if whenever KB a,it is also true
that KB i a
- incomplete procedures miss things
6Propositional Logic Syntax
REVIEW
- Propositional logic is the simplest logic
- aka Boolean logic
- illustrates basic ideas
- less expressive than first-order logic (next
chapter)
- The proposition symbols P1, P2 etc are sentences
- If S is a sentence, ?S is a sentence (negation)
- If S1 and S2 are sentences, S1 ? S2 is a sentence
(conjunction)
- If S1 and S2 are sentences, S1 ? S2 is a sentence
(disjunction)
- If S1 and S2 are sentences, S1 ? S2 is a sentence
(implication)
- If S1 and S2 are sentences, S1 ? S2 is a sentence
(biconditional)
7Propositional Logic Semantics
REVIEW
- Each model specifies true/false value for each
proposition symbol
- E.g. P1,2 is false, P2,2 is true, P3,1 is false
- With these symbols, 8 possible models, could be
enumerated automatically.
- Rules for evaluating truth with respect to a
model m
- ?S is true iff S is false
- S1 ? S2 is true iff S1 is true and S2 is true
- S1 ? S2 is true iff S1is true or S2 is true
- S1 ? S2 is true iff S1 is false or S2 is true
- S1 ? S2 is true iff S1?S2 is true and S2?S1 is
true
- Simple recursive process evaluates an arbitrary
sentence, e.g., - ?P1,2 ? (P2,2 ? P3,1) true ? (true ? false)
true ? true true
8Truth Tables for Connectives
REVIEW
9Wumpus World Example
- Situation after detecting nothing in 1,1,
moving right, breeze in 2,1
10Wumpus World KB
- Propositions
- Let Pi,j be true if there is a pit in i, j.
- Let Bi,j be true if there is a breeze in i, j.
- Knowledge Base
- R1 P1,1
- R2 B1,1 ? (P1,2 ? P2,1)
- R3 B2,1 ? (P1,1 ? P2,2 ? P3,1)
- R4 B1,1
- R5 B2,1
R1, R2, R3 are true in all wumpus worlds
R4, R5 result from percepts in current wumpus
world
11Inference by Truth Table
a1 P1,2
possible models are enumerated by listing all
possible values for the 7 propositions
KB a1?
12Inference by Truth Table
KB R1 ? R2 ? R3 ? R4 ? R5 (all sentences
must be true)
KB is true onlyin three models
13Inference by Truth Table
in all models where KB is true, a1 P1,2 is
also true,therefore, KB a1 (there is no pit in
1,2)
14Inference by enumeration
- Depth-first enumeration of all models is sound
and complete
- For n symbols, time complexity is O(2n), space
complexity is O(n)
15Logical Equivalence
- Two sentences are logically equivalent if they
are true in the same set of models - a ß iff a ß and ß a
- Equivalence can be determined using truth tables
P Q P ? Q Q ? P
false false false false
false true false false
true false false false
true true true true
16Standard Equivalences
17Validity
- A sentence is valid if it is true in all models
- The following sentences are valid
- True
- A ??A
- A ? A
- (A ? (A ? B)) ? B
- Valid sentences are also called tautologies
- Deduction Theorem
- (KB a) if and only if (KB ? a) is valid
-
18Satisfiability
- A sentence is satisfiable if it is true in some
model - The following are satisfiable
- A? B
- R1 ? R2 ? R3 ? R4 ? R5 (in the wumpus example)
- A sentence is unsatisfiable if it is true in no
models - The following is unsatisfiable
- A??A
- Satisfiability can be checked by enumerating
possible models until one is found in which
sentence is true (NP-complete)
satisfiability is the first problem that was
proven to be NP-complete.
19Satisfiability
- Results
- a is valid iff ?a is unsatisfiable
- ?a is satisfiable iff a is not valid
- KB a if and only if (KB ??a) is unsatisfiable
- Proving that a ß by checking the
unsatisfiability of (a ?? ß) is the standard
proof technique of reductio ad absurdum (aka
refutation or proof by contradiction) - assume ß is false and show that this leads to a
contradiction with some axiom a
20Proof Methods
- Proof methods divide into (roughly) two kinds
- Application of inference rules
- Legitimate (sound) generation of new sentences
from old
- Proof a sequence of inference rule
applicationsCan use inference rules as operators
in a standard search algorithm
- Typically requires transformation of sentences
into a normal form - Model checking
- truth table enumeration (always exponential in n)
- improved backtracking, e.g., DPLL
- heuristic search in model space (sound but
incomplete) - e.g., min-conflicts-like hill-climbing
algorithms
21Wumpus World KB
- Propositions
- Let Pi,j be true if there is a pit in i, j.
- Let Bi,j be true if there is a breeze in i, j.
- Knowledge Base
- R1 P1,1
- R2 B1,1 ? (P1,2 ? P2,1)
- R3 B2,1 ? (P1,1 ? P2,2 ? P3,1)
- R4 B1,1
- R5 B2,1
R1, R2, R3 are true in all wumpus worlds
R4, R5 result from percepts in current wumpus
world
22Wumpus World Inference
- R1 P1,1
- R2 B1,1 ? (P1,2 ? P2,1)
- R3 B2,1 ? (P1,1 ? P2,2 ? P3,1)
- R4 B1,1
- R5 B2,1
- R6 B1,1 ? (P1,2 ? P2,1) ? (P1,2 ? P2,1) ?
B1,1 (from R2) - R7 (P1,2 ? P2,1) ? B1,1 (from R6)
- R8 B1,1 ? (P1,2 ? P2,1) (from R7)
- R9 (P1,2 ? P2,1) (from R8 and R4)
- R10 P1,2 ? P2,1 (from R9)
- neither 1,2 nor 2,1 contains a pit