24
1 Have some fun Checker: Checker: http://www.cs.caltech.edu/~vhuang/cs 20/c/applet/more.html 1 Local Beam Search Run multiple searches to find the Run multiple searches to find the solution The best K states are selected. Like parallel hill climbing from different start points but: 2 Advantage: They communicate to localize the search Drawback: may miss the global optima

Have some fun - University of Southern Californiacsci561b/slides/session10_11_KR_short.pdfHave some fun Checker: http ... of the truth table. Example: XOR function PQ RESULT 34 T T

  • Upload
    lynga

  • View
    215

  • Download
    2

Embed Size (px)

Citation preview

1

Have some fun

Checker:Checker: http://www.cs.caltech.edu/~vhuang/cs20/c/applet/more.html

1

Local Beam Search

Run multiple searches to find theRun multiple searches to find the solution

The best K states are selected.

Like parallel hill climbing from different start points but:

2

pAdvantage: They communicate to localize the searchDrawback: may miss the global optima

2

Stochastic Beam Search

Instead of selecting the best KInstead of selecting the best K successors, use probability to select.

3

Online SearchExplore the environment like MarsRoverExplore the environment like MarsRoverAgent knows:

ACTIONS(s): list of possible actionsStep cost c(s,a,s’): cost of going from s to s’ taking action aGOAL-TEST(s)

4

Competitive ratio: path cost using exploration/optimal path cost Optimal path cost = off-line planning knowing the map

3

Online Search (II)

Competitive ratio:Competitive ratio: Can be infinite if there are dead ends

Assumption:

5

Assumption:Safely explorable: there are paths from each reachable state to goal.

Online Search (III)

DFS is acceptable methodDFS is acceptable method

Hill climbing is doable too

6

LRTA*: Learning Real-Time A*

4

Knowledge and reasoning

Knowledge representationKnowledge representationLogic and representationPropositional (Boolean) logicNormal formsI f i iti l l i

7

Inference in propositional logicWumpus world example

Knowledge-Based Agent

Knowledge Base

Inference engine

Domain independent algorithms

TELL

ASK

8

Domain specific content

5

Generic knowledge-based agent

9

1. TELL KB what was perceived

2. ASK KB what to do.

Wumpus world example

10

6

Wumpus world characterization

Deterministic?Deterministic?

Accessible?

Static?

11

Discrete?

Episodic?

Let’s play a game☺

http://www cogsci rpi edu/Otter/Wumphttp://www.cogsci.rpi.edu/Otter/Wumpus/

12

7

Exploring a Wumpus world

A= AgentB= BreezeS= SmellP= PitW= WumpusOK = SafeV = VisitedG Gli

13

G = Glitter

Other tight spots

14

8

Another example solution

15

No perception 1,2 and 2,1 OK

Move to 2,1

B in 2,1 2,2 or 3,1 P?

1,1 V no P in 1,1

Move to 1,2 (only option)

Let’s try blindedhttp://www.cogsci.rpi.edu/Otter/Wumpus/

Geeky games: Office environmenthttp://gpf-comics.com/games/wumpus/Dark environmentBlack holes suck you in (you feel slight breeze)Trudy with big mallet to smash you (you will feel her perfume)You have to find the check and your way back to the starting pointPay check can be in Trudy or black hole cubical.

16

Trudy can be in the black hole cubicalComputer wants to find your check too

Nick is conservativeKi is taking chance once or twiceFooker is an aggressive one.

9

Logic in general

17

Types of logic

18

10

The Semantic Wall

Physical Symbol System World+BLOCKA+

+BLOCKB+

+BLOCKC+

P (IS ON +BLOCKA+ +BLOCKB+)

19

P1:(IS_ON +BLOCKA+ +BLOCKB+)P2:((IS_RED +BLOCKA+)

Truth depends on Interpretation

Representation 1 WorldRepresentation 1 WorldA

BON(A,B) T

20

ON(A,B) F A

B

11

Entailment

21

Logic as a representation of the World

R i Sentails

Refers to (Semantics)

Representation: Sentences Sentence

22

FactsWorld Factfollows

12

Models

23

Inference

24

13

Basic symbols

Expressions only evaluate to either “true” or “false.”p y

P¬PP V QP ^ Q

25

P => QP Q

Propositional logic: syntax

26

14

Propositional logic: semantics

27

Truth tables

Truth value: whether a statement is true or falseTruth value: whether a statement is true or false.Truth table: complete list of truth values for a statement given all possible values of the individual atomic expressions.

Example: P Q P V QT T

28

T TT FF TF F

15

Truth tables for basic connectives

P Q ¬P ¬Q P V Q P ^ Q P=>Q P QP Q ¬P ¬Q P V Q P ^ Q P=>Q P Q

T T F F TT F F T TF T T F T

29

F F T T F

P Implies Q: (X>Y ^ Y>Z) => X>Z

P Q P=>QP Q P=>Q

T T TT F FF T T

30

F F T

16

Propositional logic: basic manipulation rules

¬(¬A) = A Double negation

¬(A ^ B) = (¬A) V (¬B) Negated “and”¬(A V B) = (¬A) ^ (¬B) Negated “or”A ^ (B V C) = (A ^ B) V (A ^ C)

Distributivity of ^ on V

A > B ( A) V B by definition

31

A => B = (¬A) V B by definition¬(A => B) = A ^ (¬B) using negated orA B = (A => B) ^ (B => A) by definition¬(A B) = (A ^ (¬B))V(B ^ (¬A))

using negated and & or

Propositional inference: enumeration method

32

17

Propositional inference: normal forms

33

Deriving expressions from functions

Given a boolean function in truth table form, find a propositional logic expression for it that uses only Vpropositional logic expression for it that uses only V, ^ and ¬.Idea: We can easily do it by disjoining the “T” rows of the truth table.

Example: XOR functionP Q RESULT

34

T T FT F TF T TF F F

18

A more formal approachTo construct a logical expression in disjunctive normal form from a truth table:

Build a “minterm” for each row of the table, where:

For each variable whose value is T in that row, include the variable in the mintermFor each variable whose value is F in that row, include

35

the negation of the variable in the minterm

Link variables in minterm by conjunctionsThe expression consists of the disjunction of all minterms.

Example: adder with carry

Takes 3 variables in: x y and ci (carry in);Takes 3 variables in: x, y and ci (carry-in);

results: sum (s) and carry-out (co).

To get you used to other notations, here we

36

assume T = 1, F = 0, V = OR, ^ = AND, ¬ = NOT.

19

Example: adder with carry

37

co is:

s is:

TautologiesSimplify the logical expressions that are always true.

Examples:TT V AA V (¬A)

38

A V (¬A)¬(A ^ (¬A))A A((P V Q) P) V (¬P ^ Q)(P Q) => (P => Q)

20

Validity and satisfiability

Th

B

Theorem

39

Model of a Formula

assignment a b a => b a^ b ~ (a b)A 0 0 1 0 1B 0 1 1 0 0C 1 0 0 0 0D 1 1 1 1 1

40

a) The assignments A, B and D are models of the formula a => b.b) The assignment D is model of the formula a ^ b.c) The assignments A and D are models of the formula ~(a b).

21

Satisfiability Exampleassignment a b a=>b a^b (a b) (a V b) a V ( a)assignment a b a=>b a^b (a b) ~(a V b) a V (~a)

A 0 0 1 0 1 1 1B 0 1 1 0 0 0 1C 1 0 0 0 0 0 1D 1 1 1 1 1 0 1

41

Proof methods

42

22

Inference Rules

43

Inference Rules

44

23

Wumpus world: example

Facts: Percepts inject (TELL) facts into the KB[stench at 1,1 and 2,1] S1,1 ; S2,1

R l if h h h i h hRules: if square has no stench then neither the square or adjacent square contain the wumpus

R1: !S1,1 ⇒!W1,1 ∧ !W1,2 ∧ !W2,1R2: !S2,1 ⇒!W1,1 ∧!W2,2 ∧ !W2,2 ∧ !W3,1…

I f

45

Inference: KB contains !S1,1 then using Modus Ponens we infer!W1,1 ∧ !W1,2 ∧ !W2,1Using And-Elimination we get: !W1,1 !W1,2 !W2,1…

Limitations of Propositional Logic

1 It is too weak (has very limited expressiveness):1. It is too weak (has very limited expressiveness):

2. 2. It cannot keep track of changes:

46

24

Summary

47

Next time

First order logic: [AIMA] Chapter 7First-order logic: [AIMA] Chapter 7

48