Vous êtes sur la page 1sur 103

INGENIERA DEL CONOCIMIENTO

Msc. Jorge Espinosa


jeespinosa@elpoli.edu.co
Horas y correo de contacto Lunes y Martes 10-12 m

P19 211 C Ext 492

Medelln 2013

Motivation

Vision of the Future

Que es el test de Turing!!!

The mind beaten by the machine?

Is chess playing a proof of intelligent behaviour?


4

MARIANA
http://www.uca.edu.ar/uca/index.php/ingreso/index/es/universidad/ing resantes/ingreso-buenos-aires/

Other examples of success:


Chatbot - Alice: http://www.alicebot.org/

Clever Bot http://www.cleverbot.com/

Siri

http://www.youtube.com/watch?v=0ubSbju9u68&feature=watch_response

Existor

www.existor.com

Are Mariana/Alice/Clever Bot/Siri/Existor intelligent?

ABSOLUTELY NOT !
+ some pattern matching + some knowledge + some randomness

~ 50000 fairly trivial input-response rules.

NO reasoning component BUT: demonstrates human-like behaviour.


Won the turing award

10

Data mining: An application of Machine Learning techniques


It solves problems that humans can not solve, because the data involved is too large ..

Detecting cancer risk molecules is one example.

11

EE.UU. inicia prueba de un ao con "automviles inteligentes"

Many other applications:


Computer vision:

In language and speech processing:

In robotics:

14

About intelligence ... When would we consider a program intelligent ?

When do we consider a creative activity of humans to require intelligence ?


Default answers : Never? / Always?

15

What is Turing test!!!

The long term goal:

The Turing Test

17

The meta-Turing test


The meta-Turing test counts a thing as intelligent if it seeks to devise and apply Turing tests to objects of its own creation. -- Lew Mammel, Jr.

18

Artificial Intelligence vs. Natural Flight

19

To some extent, we DO simulate: Artificial Neural Nets:


A VERY ROUGH imitation of a brain structure

Work very well for learning, classifying and pattern matching. Very robust and noise-resistant.
20

Which applications are easy ?


For very specialized, specific tasks: AI

Example: ECG-diagnosis

For tasks requiring common sense: AI


21

Modeling Knowledge and managing it .


The LENAT experiment: 15 years of work by 15 to 30 people, trying to model the common knowledge in the word !!!! Knowledge should be learned, not engineered.

AI: are we only dreaming ????

22

But at the end What is Artificial Intelligence? Well, Artificial Intelligence is ...

In Engineering and Computer Science:


The development and the study of advanced computer applications, aimed at solving tasks that - for the moment - are still better preformed by humans.

23

INGENIERA DEL CONOCIMIENTO


Msc. Jorge Espinosa
jeespinosa@elpoli.edu.co Horas y correo de contacto Lunes y Martes 10-12 m

P19 211 C Ext 492

Medelln 2013

State-Space representation and Production Systems


Introduction: what is State-space representation? What are the important trade-offs?

(E.Rich, Chapt.2)
Basis search methods.

(Winston, Chapt.4 + Russel&Norvig)


Optimal-path search methods.

(Winston, Chapt.5 + Russel&Norvig)


Advanced properties and variants.

(Rich, Chapt.3 + Russel&Norvig + Nilsson) Game Playing (Winston, Chapt.6 + Rich + Russel&Norvig )

25

26

State-space representation: Introduction and trade-offs

What is state-space representation? Which are the technical issues that arise in that context? What are the alternatives that the paradigm offers to solve a problem in the state-space representation?

Example: the 8-puzzle.


Given: a board situation for the 8-puzzle:

1 3

2
5

7
4 6

Problem: find a sequence of moves (allowed under the rules of the 8-puzzle game) that transform this board situation in a desired goal situation:

1 8 7

2 6

3 4 5

http://mypuzzle.org/sliding

http://www.permadi.com/java/puzzle8/puzzle8a.html

State-space representation: general outline:


Select some way to represent states in the problem in an unambiguous way. Formulate all actions that can be performed in states: including their preconditions and effects

== PRODUCTION RULES
Represent the initial state (s). Formulate precisely when a state satisfies the goal of our problem. Activate the production rules on the initial state and its descendants, until a goal state is reached.

Initial issues to solve:


How to represent states? (repr.1)

Ex.:

1 3 8 2 7 5 4 6

using a 3 X 3 matrix

How to formulate production rules? (repr. 2) Ex.: express how/when squares may be moved? Or: express how/when the blank space is moved? When is a rule applicable to a state? (matching) How to formulate when the goal criterion is satified and how to verify that it is? How/which rules to activate? (control)

The (implicit) search tree

Each state-space representation defines a search tree:


1 3 8 2 7 5 4 6
9!/2 nodes!

1 3 8 2 7 5 4 6

1 8 2 3 7 5 4 6

1 3 8 2 7 5 4 6

1 3 2 4 5

8 7 6

goal
8 puzzle= 181.444 15 Puzzle = 650.000.000 24 Puzzle = 5000.000.000.000.000.000.0000.000

The (implicit) search tree

Each state-space representation defines a search tree:


1 3 8 2 7 5 4 6
9!/2 nodes!

1 3 8 2 7 5 4 6

1 8 2 3 7 5 4 6

1 3 8 2 7 5 4 6

1 3 2 4 5

8 7 6

goal
But this tree is only IMPLICITLY available !!

A second example: Chess

Problem: develop a program that plays chess (well).


1. A way to represent board situations in an unambiguous way:

Ex.:
8 List: (( king_black, 8, C), ( knight_black, 7, B), ( pawn_black, 7, G), ( pawn_black, 5, F), ( pawn_white, 2, H), ( king_white, 1, E))

7
6 5 4 3 2 1

A B C D E F G H

34

Chess (2):

2. Describe the rules that represent allowed moves:


Ex.:
4
3 2 1

A B C D E F G H
( (pawn_white,2,x) , (blank, 3, x), (blank, 4, x) )
add( ( pawn_white, 4, x) ), remove( (pawn_white, 2, x) )
35

Chess (3):

3. Provide a way to check whether a rule is applicable to some state:


Ex.:
8 7 6 5 4 3 2 1

List: (( king_black, 8, C), ( knight_black, 7, B), ( pawn_black, 7, G), ( pawn_black, 5, F), ( pawn_white, 2, H), ( king_white, 1, E))

A B C D E F G H
( (pawn_white,2,x) , (blank, 3, x), (blank, 4, x) ) add( ( pawn_white, 4, x) ), remove( (pawn_white, 2, x) )
Matching mechanism !!

Chess (4):

4. How to specify a state in which the goal is reached (= a winning state):


Ex.:
win( black ) attacked( king_white ) and no_legal_move( king_white )

+ similar definitions for:


attacked( Piece ) no_legal_move( Piece ) ...

37

Chess (5):

5. A way to verify whether a winning state is reached.


Ex.:
?- win( black ). win( black ) attacked( king_white ) and no_legal_move( king_white )

Need a theorem prover ( e.g. Prolog) to verify that the state is a winning one.

Chess (6).

6. The initial state.


A program that is ABLE to play chess.

7. A mechanism that selects in each state an appropriate rule to apply.

The control problem !

Main focus of this entire chapter of the course !!

Chess (7).
Implicit search tree ~15 Move 1

2 ~ (15)

Move 2

~ (15)

Move 3

Need very efficient search techniques to find good paths in such combinatorial trees.

Very many issues and trade-offs:


1. How to choose the rules? 2. Should we search through the implicit tree or through an implicit graph?

3. Do we need an optimal solution, or just any solution?


optimal path problems 4. Can we decompose states into components on which simple rules can in an independent way? Problem reduction or decomposability 5. Should we search forwards from the initial state, or backwards from a goal state?

41

1. Choice of the rules

Example: The water jugs problem:


Given: 2 jugs:
4l
3l

Problem: fill the 4 l jug with 2 l of water.


Representation: a state:

[content of large jug, content of small jug]


initial state:

[ 0, 0 ]
goal state:

[ 2, x ]
42

Rules for the jugs example:


Fill large: [ x, y ] and x < 4 Fill small: [ x, y ] and y < 3

[ 4, y ]

[ x, 3 ]

Empty large:
[ x, y ] and x > 0 [ 0, y ]

Remove some from large: [ x, y ] and x > d > 0

[ x - d, y ]

Rules for the jugs example (2):

Fill large from small: [ x, y ] and x + y 4 and y > 0

[ 4, y-(4-x)]

Empty Small in large.


[ x, y ] and x + y 4 and y > 0 [ x + y , 0 ]

44

Part of the state space:


[ 0, 0 ] [ 4, 0 ] [ 0, 0 ] [ 0, 3-d1] [ 0, 0] [ 0, 3-d1-d2] [ 3-d1, 0] [ 4, 3-d1] [ 4, 2 ]

Fill small
[ 0, 3 ]

*
[ 4, 3]

Empty small in large


[ 3, 0 ]

Fill small
[ 3, 3 ]

Redundant subspace !

Fill large from small

[ 0, 2 ]

Empty large

[ 2, 0 ]

Empty small in large


45

Rules for the jugs example:

Fill large:
[ x, y ] and x < 4

[ 4, y ]

Fill small:
[ x, y ] and y < 3 [ x, 3 ]

Empty large:
[ x, y ] and x > 0 [ 0, y ]

Remove some from large:


[ x, y ] and x > d > 0 [ x - d, y ]

Empty (remove some from) small.

Part of the state space:


[ 0, 0 ]

Fill small
[ 0, 3 ]

Empty small in large


[ 3, 0 ]

[ 0, 0 ]

Fill small
[ 0, 3 ] LOOP ! [ 0, 0 ] [ 4, 2 ] [ 0, 2 ] [ 3, 3 ]

Fill large from small

Empty large

[ 2, 0 ]

Empty small in large


47

2. Avoiding loops: search in trees or graphs ?


[ 0, 0 ] [ 4, 0 ] [ 0, 3 ]

[ 1, 3 ]

[ 4, 3 ]

[ 3, 0 ]

[ 1, 0 ]

[ 3, 3 ]

...
Avoids generating loops: but needs to keep track of ALL the nodes.
48

3. Any path, versus shortest path, versus best path:

Ex.: 8-puzzle: any or shortest path problem. Ex.: Traveling salesperson problem:
Boston

3000

SanFrancisco

250
1450
NewYork

1700

2900 3300 1500 1700


Dallas

1200
Miami

1600

Find a sequence of cities ABCDEA such that the total distance is MINIMAL.

Best path problem

State: the list of cities that are already visited Ex.: ( NewYork, Boston ) Initial state: Ex.: ( NewYork ) Rules: add 1 city to the list that is not yet a member add the first city if you already have 5 members Goal criterion: first and last city are equal
Boston NewYork SanFrancisco

State space representation:

Miami

Dallas

50

( NewYork )
250
250

1200
1200

1500

2900

1500

2900

( NewYork, Boston ) 1450


1700

( NewYork, Miami )

( NewYork, Dallas )

( NewYork, Frisco ) 3300


6200

( NewYork, Boston, Miami )

( NewYork, Frisco, Miami )

Keep track of accumulated costs in each state if you want to be sure to get the best path.

51

4. Problem reduction or problem decomposition:

Ex.: Computing symbolic integrals: State: the integral to compute Rules: integration reduction rules Goal: all integrals have been eliminated x2 + 3x + sin2x . cos2x dx
AND

x2 dx
x3/3 3 xdx

3xdx

sin2x . cos2x dx

((sin2x)/2)2dx
... ...

(1 - cos2x).cos2x dx
... AND-OR-tree search ...

Necessary for decomposition: independence of states:

Ex.: Blocks world problem. Initially: C is on A and B is on the table. Rules: to move any free block to another or to the table Goal: A is on B and B is on C.
C A

AND-OR-tree?
B

Goal: A on B and B on C

AND
C A B C A B

Goal: A on B

Goal: B on C
53

AND
C A B C A B

Goal: A on B

Goal: B on C

Goal: A on B

B C A

A B

But: branches cannot be combined


54

5. Forward versus backward reasoning:


Initial states

Goal states
Forward reasoning (or forward chaining): from initial states to goal states.
55

5. Forward versus backward reasoning:


Initial states

Goal states
Backward reasoning (or backward chaining): from goal states to initial states.

Criteria:
Sometimes equivalent: (Ex.: 8-puzzle:)

1 3 2 5

8 7

1 8 7

2 6

3 4 5

4 6

Branching factor (Ex.: see previous slide) Sometimes: no way to start from the goal states because there are too many (Ex.: chess) because you cant (easily) formulate the rules in 2 directions.
57

In this case: even the same rules !!

Criteria (2):
The ratio of initial states versus goal states:

Ex.: finding your way to some destination Providing explanation facilities: (Ex.: expert systems with user interaction)

Backward reasoning!

Other possibility: middle-out reasoning.


58

Production-rule systems: Definition:


Programs that implement approaches to search problems using the state space representation.
Consist of: A rule base, a working memory, containing the state(s) that have currently been reached, a control strategy for selecting the rules to apply next to the states in the working memory (including techniques for matching, verifying preconditions and whether a goal state has been reached)

INGENIERA DEL CONOCIMIENTO Intro to Graph and trees


Msc. Jorge Espinosa
jeespinosa@elpoli.edu.co
Horas y correo de contacto Mircoles de 9 a 11 a.m. y Jueves de 8 a 9 a.m.

P19 211 C Ext 492

Medelln 2013

Aim of these slides


Introduce the technical language of graphs and trees. Motivation:
divide and conquer: become familiar with the jargon of graphs before trying to learn about search

Graphs
Graphs are the mathematical and computer science abstraction that capture many shared and common concepts of real-life objects such as
networks, e.g.
water electricity internet

mazes road maps timetabling IA Games Theory

Graphs
Many problems in CS/AI can be reduced to problems in graph theory,
gives a good way to share results, methods & implementations across many areas

Graph Theory has its own jargon; but it is worth becoming familiar with it
e.g. in discussions of network topology, social networks,

Terminology of Graphs
Just giving the ideas. Exact mathematical definitions not needed for this course, and are available in many textbooks, wikipedia, etc. A Graph consists of a set V of nodes, and a set E of edges Node
has a unique label for identification

Edge
connects two nodes any two nodes have at most one edge between them usually forbid self-edges : edges from a node back to itself can be a
directed edge: e.g. from A to B a one-way street undirected edge: e.g. between A and B a standard street

Graph Example
This is not a map! The positions of the nodes do not matter, only their interconnections E.g. London Underground Map gives interconnections, but not true locations

B A F D C

Mapas

Mapas

Mapa

Graph Example
Crossing of edges (arcos,aristas) has no meaning
A-D and B-E cross in the picture but they do not interconnect
A B D E G F C

These two pictures are the same graph

F D A E B

Terminology of Graphs
B D C E G

Path connected sequence of edges (arcos-aristas): e.g. A to B to F to C to G usually not allowed to use the same node (or edge) twice if the edges are directed then the path has to follow the directions of the edges. E.g. follow the one-way streets on a map

Reachable
Node B is said to be reachable from node A if and only if there is a path from A to B
Relevance to real-world: many search problems are questions about whether or not some goal is reachable from some start node part of maintaining the internet topology is ensuring that any node (site) is reachable from any other site a design factor in the internet was that nodes stay reachable even if some links are broken e.g. in the event of nuclear war

Connected Graphs
Connected Graph. Definition:
for any two nodes there is a path between them i.e. any node is reachable from any other node

E.g. this graph is connected

B F

D
C E G

Connected Graphs
E.g. this graph is disconnected There is no path from A to B

B F

D
C E G

Cycles
Definition: a cycle is a path that goes in a loop from a node back to itself, and without using the same node twice E.g. A-B-E-A in
A B F D

C E G

Tree
A tree is a graph
that is connected but becomes disconnected if you remove any edge (cut the edge)

Matches nature
real trees are connected cut any branch then the tree falls into two pieces

Tree: Example
This is a tree

B F D I

C
J

Acyclic Graphs
Defn: An acyclic graph has no cycles Alternative definition: A tree is a graph that is
connected, and acyclic

Trees
Question: Why is a acyclic equivalent to becomes disconnected on any cut?
A B F D C E G

Suppose we cut edge A-B Graph stays connected

Trees

A Tree is connected: given any two nodes A and B there exists at least one path between them Question: Given a tree, and any two nodes A and B, is the path between them unique? or might there be pairs of nodes that have more than one path between them? Suppose nodes E and F have two distinct paths P1 and P2 between them: Using P1 followed by reverse(P2), we would be able to construct a cycle. But trees are acyclic, hence, paths between nodes of a tree must be unique B D B D E B

E
A

P1(E,F) F

P1(E,F) U P2(F,E)

D
E P2(E,F)

Trees
A tree is a graph that:
1. is connected but becomes disconnected on removing any edge 2. is connected and acyclic 3. has precisely one path between any two nodes

The above 3 definitions are equivalent Suggestion: become comfortable enough with the definitions for this equivalence to be self-evident

Rooted Trees
Often in trees have a special node called the root E.g.
A B F D I H E G J C

Rooted Trees
Often in trees have a special node called the root Usually also give edges a direction away from the root e.g.

B F D I

C
J

Rooted Trees
Often, on making a picture of a tree Pick up the tree by the root
let it hang, and shake it a bit
B A B F D I H E G J A I C H E G J C

But in practice

you dont usually get the pretty version programs have to use messy representations

Rooted Trees: Jargon


The nodes directly below a node are called its children
e.g. H and E are children of B B is the parent of H H and E are siblings B

Children, children of children, etc are descendents


D is a descendent of B

Parents,parents of parents, etc are ancestors


B is an ancestor of D

A node without children is called a leaf node (or terminal node)


e.g. G is a leaf node

Rooted Tree : Example


File systems are rooted trees (Suggestion: When thinking/studying search and it becomes too abstract, then filesystems provide a concrete example that might make it easier to understand)

DOS/Windows C:\ is the root (of the C drive)


Unix / is the root
there is even a root user the one that has enough privileges to modify the root directory (and all others)

Rooted Tree : Example


File systems are rooted trees
nodes = files or folders (a.k.a. directories) edges = links from a folder to the files/folders that it contains links are addresses on the hard drive
\B

\J

\B\H

\B\E

\B\E\A

\B\E\I

Rooted Tree : Example


Actual layout on hard drive will be a mess

\J

\B

\B\H

\B\E

\B\E\A

\B\E\I

Rooted Tree : Example


Note: there might be a lot of data on the hard drive that has no valid link to it
removing a file means just remove the link to it can still be on the hard-drive but you cannot reach it by following links from the root directory scanning the hard drive for a string does not tell you whether the string occurs in the filesystem E.g. del \B\E\A (or unix rm /B/E/A) gives

\J

\B

\B\H

\B\E

\B\E\A

\B\E\I

Software for Recovery

Trees: Branching factor


The branching factor of a node is just the number of branches emerging from it its number of children Branching factor of the tree itself is (usually): largest branching factor of any node (Might also read about an effective branching factor some form of average over the nodes)

Trees: b=2
If the largest branching factor is two then we have a binary tree
F

Trees: b=1
If the largest branching factor is one then we have a linked list These are often used in programming as a container: a way to store a collection of objects
F

Aside: Doubly Linked Lists


Take a linked list and also add edges from each (non-root) node to its parent Used in programming as a container:
can easily walk in both directions
A

Trees: Depth
The depth, d, of a node is just the number of edges it is away from the root node The depth of a tree is the depth of the deepest node
in this case, depth=4
A I d=3 d=0

d=1

d=2

d=4

Tree Sizes
Suppose we have a tree with
branching factor b depth d

What is the maximum number of nodes does it can have?

Sizes of Trees: Branching Factor Increasing b rapidly increases the tree size:
d 0 1 2 3 4 5 6 nodes at d, b=2, 2d 1 2 4 8 16 32 64 nodes at d, b=3, 3d 1 3 9 27 81 243 729

Sizes of Trees
Pattern seen in binary tree: nodes at d or less = nodes at d+1 1 = 2d+1-1 = O(2d) The number of nodes grows exponentially Another manifestation of the Combinatorial Explosion Similarly, for a general tree number of nodes is O(bd) but, remember big O gives an upper bound, real trees might have a lot fewer nodes Trees are generally very leaf-heavy a large fraction of the nodes are leaves e.g. on your file system you probably have far more files than folders

Effects of Tree Sizes


If possible try to work with trees with
smaller branching factor smaller depth

Be careful when programming that your memory requirements do not explode

Summary
Definitions of
graphs path connected cycles, and acyclic tree, and rooted tree

Trees grow exponentially with depth

Exercise
Given a tree with Branching factor of 4, how many nodes are acumulated at level 5(d=5)? If the b= 5, how many nodes are acumulated at level 6 (d=6)??

Questions?

Puuufff!!

Then See U Next Week

Be Nice!!!

Vous aimerez peut-être aussi