1 cs 385 fall 2006 part 2 artificial intelligence as representation and search

40
1 CS 385 Fall 2006 Part 2 Artificial Intelligence as Representation and Search

Upload: frank-chase

Post on 29-Dec-2015

213 views

Category:

Documents


1 download

TRANSCRIPT

1

CS 385 Fall 2006Part 2

Artificial Intelligence as Representation and Search

2

Representation and Search

Another reasonable description of AI: – the study of representation and search through which intelligent

activity can be enacted on a mechanical device

Goal of a representation scheme: – capture essential features of a problem and make available to

problem solving procedure

Abstraction: tool for managing complexity– what abstractions do you find useful?

– goal: only what you need, but make sure there is enough.

Expressiveness versus efficiency

3

Representation and Search (cont)

Good discussion in text of floating point numbers

Traditional formalisms such as arrays have not been very useful in AI

Critique using an array of pixels for the digitized chromosome image (p. 39)

4

Languages for AI

BASIC, FORTRAN, and C++: – represent symbolic knowledge well

– too quantitative, not qualitative

Goals for an AI representation language:1. Handle qualitative knowledge

2. Allow new knowledge to be inferred from a set of facts and rules.

3. Allow representations of general principles as well as specific situations

4. Capture complex semantic meaning

5

Blocks World

A classic AI example

What information is here?

How would you represent it?

ba

c

6

Blocks World using Predicates

clear(c).

clear(a).

ontable(a).

ontable(b).

on(c,b).

cube(b).

cube(a).

pyramid(c).

ba

c

1. Handle qualitative knowledge

2. Allow new knowledge to be inferred from a set of facts and rules.

Did we need to state that a and c are clear?

Equivalent: nothing on top of them: “X is clear if there is no Y such that on (Y,X)”

X Y on(Y,X) → clear(X)

clear(X) :- not on(Y,X). (Prolog)

7

Blocks World using Predicates

clear(c).

clear(a).

ontable(a).

ontable(b).

on(c,b).

cube(b).

cube(a).

pyramid(c).

ba

c

3. Allow representations of general principles as well as specific situations

on(Y,X)→ under(X,Y) on(Y,Z) under(X,Z) → under(X,Y)

In PROLOG: under(X,Y ):- on(Y,X). under(X,Y):- on(Y,Z), under(X,Z).

4. Capture complex semantic meaning?

8

Goal 4: Capture Complex Semantic Meaning

Example: Bluebirds “a bluebird is a small blue-colored bird and a bird is a feathered flying vertebrate.”

Predicates:isabird(bluebird)

hassize(bluebird, small)

hascolor(bluebird, blue)

flies(bird)

isavertibrate(bird)

hasfeathers(bird)

9

Semantic Nets

Another way to represent semantic meaning.

vertibrate

bird

blue bird

flies

blue

feathers

small

hascovering hasproperty

hassize hascolor

isa

isa

Can you represent this in a way other than predicates?

10

State Space Search: Tic-Tac ToeState: a board configuration

State space: all paths from the empty board to the end of the game

x x x

x x x

x

x o x o

x x

11

Tic-Tac-Toe

How many states?

How many paths?

Is there a winning strategy?

Is there a way to make this more efficient?

Does a solution to tic-tac-toe qualify as AI?

Will this work for chess?– Will need to add heuristics

• Rules of thumb

• A way to add intelligence to state-space search

– Can you think of any?

– E.g protect the queen, some of the standard opening moves

12

x x

x

x o x o x

o

x

o

x

o

Tic-Tac-Toe with Reduced State Space

13

Chapter 2 Predicate Calculus

Foundation for AI representation:– Formal semantics

– Inference rules

We come to the full possession of our power of drawing

inferences, the last of our faculties, for it is not so much a

natural gift as a long and difficult art.

C.S. Pierce (http://en.wikipedia.org/wiki/Charles_Peirce)

Start with 2.1, Propositional Calculus

14

2.1.1 Symbols and Sentences

Legal sentences or well-formed formulas (WFFs):

1. Symbols:

P, Q, ...

truth symbols: T or true, F or false,

connectives: → ≡

2. Sentences: Prop Calculus Prolog

symbols P, Q

truth symbols true, false true, false

negation of a sentence P not P

conjunction of two sentences (and) P Q P, Q

disjunction of two sentences (or) P Q P; Q

implication P → Q Q :- P

(P = premise or antecedent. Q = conclusion or consequent)

equivalence P ≡ Q P = Q

Now use these rules to build all WFFs

15

2.1.2 Semantics

Interpretation: assignment of truth values to propositional symbols.

Semantics for interpretations (truth assignments): P is T/F when P is F/T

is T only when both conjuncts are T, otherwise F

is T when either conjunct is T, otherwise F

→ is F only when the premise is T and the consequent is F

e.g. (1=3) → (7 = 4) is T

≡ is T when both expressions have the same assignment

Truth tables cover all possible assignments for operands

Proofs in propositional calculus: shown by demonstrating equivalent values in truth tables

16

Truth Table for P QP Q P Q

T T T

T F T

F T T

F F F

( P) ≡ P

P Q ≡ Q → P (contrapositive)

(P Q) ≡ P Q (de Morgan)

(P Q) ≡ P Q (de Morgan)

Commonly used Identities (p. 49)

17

Truth Table for P Q ≡ Q → P

P Q (P Q) ≡

( Q → P)

T T

T F

F T

F F

Start a truth table with all possible values for P and Q.Find assignments for the lhs and rhs of the law:

18

Truth Table for P Q ≡ Q → P

P Q P Q P Q Q → P (P Q) ≡

( Q → P)

T T F F T T F

T F F T F F F

F T T F F F F

F F T T F F F

19

de Morgan

P Q (P Q) P Q (P Q) =( P Q)

T T

T F

F T

F F

20

de Morgan

Filled in:

P Q P Q P Q (P Q) P Q (P Q) =( P Q)

T T F F T F F T

T F F T T F F T

F T T F T F F T

F F T T F T T T

21

2.2 The Predicate Calculus

We need more expressiveness for "All dogs like bones."

Propositional: person(tom) → mortal(tom)

Predicate: person(X) → mortal(X) (X is a variable)

(X is capitalized)

A bit more complicated than, but essentially, add and

X person(X) → mortal(X) (universal quantification)

X person(X) (existential quantification)

22

Predicate Calculus Symbols

Predicates:truth symbols: true and false

constants: first letter is lowercase

variables: first letter is uppercase

functions: parent(tom, mary) arity = # of arguments

(possible confusion in the text which appears to use functions and

predicates interchangeably)

More formally, an atomic sentence is:

a predicate of arity n followed by n terms enclosed in

parentheses and separated by commas

23

Predicate Calculus Sentences

Every atomic sentence

If S, S1, S2 are sentences, so are the propositional calculus sentences:S

S1 S2

S1 S2

S1 → S2

S1 = S2

If X is a variable and S a sentence, so are X S

X S

(atomic sentence versus sentence)

(well-formed expressions)

24

verify_sentence algorithm

25

Is X smart(X) rich(X) happy(X) well-formed?

X smart(X) rich(X) → happy(X)

(form Q X s)

X smart(X) rich(X) → happy(X)

(form s1 op s2)

smart(X) rich(X) → happy(X)

(atomic sentence) (form s1 op s2)

success .....

Why is it useful to have the verify sentence-algorithm?

26

2.2.2 A Semantics for the Predicate Calculus

A fuzzy section. Skip!

Goal: determine the truth of well-formed expressions

Map expressions into {T, F}

Concept of a world (an interpretation) over which predicates are mapped into {T, F}

E.g. likes(mary, apples) maps to T and likes(fred, apples) maps to F in some interpretations

Bottom line: first-order predicate calculus allows quantified

variables and we have ways to assign T/F to predicates

27

2.3 Using Inference Rules to Produce Predicate Calculus Expressions

Given Conclusion

Modus ponens P and P → Q Q

Modus tolens P → Q and ⌐ Q ⌐P

And elimination P Q P, Q

And introduction P, Q P Q

Universal instantiation X p(X) p(a)

Abduction (not true) P → Q, Q P

28

Unification

How do we determine whether two expressions match?

E.g. parent(tom, mary) and parent(tom Y) (match if Y= mary)

Unification: The substitutions needed to make the match. Here: {mary/X}

Making this substitution is called binding

Do parent(X, mary) and parent(tom, Y) unify?Yes under {tom/X, mary/Y}

X is bound to tom

Y is bound to mary

29

Unification (cont.)

If X occurs in any future unifications or uses of X, it is

considered bound to tom.

E. G. given {tom/X}

parent(X,mary ) → happy(X)

becomes

parent(tom,mary ) → happy(tom)

Composition of unifications: {X/Z} {tom/X, mary/Y}. compose to {tom/Z, mary/Y}

Most general unifier: parent(tom,X) and parent(tom,Y) could unify under {fred/X, fred/Y}.

Better: {Z/X, Z/Y}

30

Notation

List syntax: (makes expressions easier to process)

function(var1, var12,... varn) → (function var1 var2 ... varn)

Predicate Calculus List Syntaxsmart(fred) (smart fred)

likes(fred, mother(mary)) (likes fred mother (mary))

parent(father(X), parent(Y,Z)) (parent (father X) (parent Y Z))

siblings(son(X), daughter(X)) ??

?? (family (mother X) father(X) X)

31

Unification Function

unify (first expression, second expression)

E.g.

unify(parents(X, father(X), mother(bill)), parents(bill, father(bill), Y)

first expression second expression

Guess? {bill/X, mother(bill/Y)}

But we need a better way to do this (algorithm on p 69)

32

CASES:

The same constants:unify(tom, tom) → {}

Different constants:unify(tom, fred) → FAIL

One term is a variable that doesn’t occur in the other:unify(X, mortal (socrates) ) → {mortal(socrates)/X}

unify(mortal(socrates),X ) → {mortal(socrates)/X}

One term is a variable that does occur in the other:unify(X, mortal(X)) → FAIL

33

CASES:

Complex term: Unify ist 2 elements and apply substitutions to the rest

Recursively unify the remaining clauses

E.g.

unify((parent tom Y), (parent X mary))

return {}

unify(parent, parent) unify((tom Y), (X mary)

return {tom/X} return {mary/Y}

unify (tom, X) unify(Y, mary)

34

Unify foo(X, friend(Y,X)) and foo(mary, friend(pam, marc))

unify((foo X (friend Y X)), (foo mary (friend pam marc)))

return {}

unify(foo, foo) unify( (X (friend Y X)), (mary (friend pam marc)))

return {mary/X}

unify (X, mary) unify((friend Y mary)), (friend pam marc))

{} return {mother bill/Y}

unify(friend, friend) unify ((Y mary), (pam marc))

return {pam/Y} fail!

unify(Y, pam) unify(mary, marc}

35

Figure 2.5:

36

Figure 2.6:

37

Logic-Based Financial Advisor

Invest in savings or stocks, based on savings and income:Inadequate savings: savings account

Adequate savings and adequate income: stock market

Lower income but adequate savings: split

Predicates:savings_account(adequate)

savings_account(inadequate)

income(adequate)

income(inadequate)

investment(savings)

investment(stocks)

earnings(X, steady)

earnings(X unsteady) {X = amount}

38

What rules can we derive?

1. savings_account(inadequate) → investment(savings)

2. savings_account(adequate) income(adequate)

→ investment(stocks)

3. savings_account(adequate)income(inadequate)

→ investment(combination)

This needs more precisionAdequate savings is 5000 *number of dependents:

minsavings(X) = 5000*XAdequate income is 15K plus 4K per dependent:

minincome(X) = 15000 + 4000*XEarnings are steady or unsteady

39

Logic-Based Financial Advisor Rules

40

Exploiting the Rules

10 and 11 with 7 12. income(inadequate)

9 and 11 with 4 13. savings_account(adequate)

3, 12, and 13. 14. investment(combination)