Você está na página 1de 16

UNIT II

REPRESENTATION OF KNOWLEDGE
Game playing - Knowledge representation, Knowledge representation using Predicate logic,
Introduction to predicate calculus, Resolution, Use of predicate calculus, Knowledge
representation using other logic-Structured representation of knowledge.
GAME PLAYING:
GAME PLAYING AND AI
Games are well-defined problems that are generally interpreted as requiring intelligence to play
well. Introduces uncertainty since opponents moves can not be determined in advance.
Search spaces can be very large. For chess: -Branching factor: 35 -Depth: 50 moves each player
-Search tree: 35100 nodes (~1040 legal positions)
Despite this, human players do quite well without doing much explicit search. They seem to rely
on remembering many patterns.
Good test domain for search methods and development of pruning methods that ignore portions
of the search tree that do not affect the outcome.
GAME PLAYING PROBLEM
Instance of the general search problem.
States where the game has ended are called terminal states.
A utility (payoff) function determines the value of terminal states, e.g. win=+1, draw=0, lose=1.
In two-player games, assume one is called MAX (tries to maximize utility) and one is called
MIN (tries to minimize utility).
In the search tree, first layer is move by MAX, next layer by MIN, and alternate to terminal
states.
Each layer in the search is called a ply.
SAMPLE GAME TREE (TIC-TAC-TOE)

MINIMAX ALGORITHM

General method for determining optimal move.


Generate complete game tree down to terminal states.
Compute utility of each node bottom up from leaves toward root.
At each MAX node, pick the move with maximum utility.
At each MIN node, pick the move with minimum utility (assumes opponent always acts
correctly to minimize utility).
When reach the root, optimal move is determined.

MINIMAX COMPUTATION

Can be performed using a depth-rst search


function MINIMAX-DECISION(game) returns an operator
for each op in OPERATORS[game] do
VALUE[op]
MINIMAX-VALUE(APPLY(op, game), game)
end
return the op with the highest VALUE[op]
function MINIMAX-VALUE(state, game) returns a utility value
if TERMINAL-TEST[game](state) then
return UTILITY[game](state)
else if MAX is to move in state then
return the highest MINIMAX-VALUE of SUCCESSORS(state)
else
return the lowest MINIMAX-VALUE of SUCCESSORS(state)
Imperfect Decisions
Generating the complete game tree for all but the simplest games is intractable.
Instead, cut off search at some nodes and estimate expected utility using a heuristic
evaluation function.
Ideally, a heuristic measures the probability that MAX will win given a position
characterized by a given set of features.
Sample chess evaluation function based on materadvantage: pawn=1, knight/bishop=3,
rook=5, queen=9

Determining Cutoff
Search to a uniform depth (ply) d.
Use iterative deepening to continue search to deeper levels until time runs out (anytime
algorithm).
Could end in states that are very dynamic (not quiesent) in which evaluation could
change quickly, as in (d) below.

Continue quiescence search at dynamic states to improve utility estimate.


Horizon problem: Inevitable problems can be pushed over the search boundary.
Example: Delay inevitable queening move by pawn by exploring checking moves.

Alpha-Beta Pruning
Frequently, large parts of the search space are irrelevant to the nal decision and can be
pruned.
No need to explore options that are already denitely worse than the current best option.

Alpha-Beta General Principle


Consider a node n where it is Players choice of moving to that node. If Player has a
better choice m at either the parent node of n or at any choice point further up, then n will
never be reached in actual play.
Maintain two parameters in depth-rst search, a, the value of the best (highest) value
found so far for MAX along any path; and , the best (lowest) value found along any path
for MIN. Prune a subtree once it is known to be worse than the current a or .
Alpha-Beta Algorithm
function MAX-VALUE(state, game, , ) returns the minimax value of state
inputs: state, current state in game
game, game description
, the best score for MAX along the path to state
, the best score for MIN along the path to state
if CUTOFF-TEST(state) then return EVAL(state)
for each s in SUCCESSORS(state) do
MAX(, MIN-VALUE(s, game, , ))
if
then return
end
return
function MIN-VALUE(state, game, , ) returns the minimax value of state
if CUTOFF-TEST(state) then return EVAL(state)
for each s in SUCCESSORS(state) do
MIN( , MAX-VALUE(s, game, , ))
if
then return
end
return
Effectiveness of Alpha-Beta
Amount of pruning depends on the order in which siblings are explored.
In optimal case where the best options are explored rst, time complexity reduces from
O(b 13d) to O(bd/2), a dramatic improvement. But entails knowledge of best move in
advance!
With successors randomly ordered, assymptotic bound is O((b/logb)d) which is not much
help but only accurate for b>1000. More realistic expectation is something likeO(b3d/4).
Fairly simple ordering heuristic can produce closer to optimal results than random results
(e.g. check captures & threats rst).
Theoretical analysis makes unrealistic assumptions such as utility values distributed
randomly across leaves and therefore experimental results are necessary.

State of the Art Game Programs


Chess: DeepBlue beat world champion
-Customized parallel hardware
-Highly-tuned evaluation function developed with expert
-Comprehensive opening and end-game databases
Checkers:
-Samuels learning program eventually beat developer.
-Chinook is world champion, previous champ held title for 40 years had to
withdraw for health reasons.
Othello: Programs best players (e.g. Iago).
Backgammon: Neural-net learning program TD Gammon one of worlds top 3 players.
Go: Branching factor of ~360 kills most search methods. Best programs still mediocre.
KNOWLEDGE REPRESENTATION
Knowledge representation (KR) is an important issue in both cognitive science and
artificial intelligence.
In cognitive science, it is concerned with the way people store and process
information and
In artificial intelligence (AI), main focus is to store knowledge so that programs
can process it and achieve human intelligence.
There are different ways of representing knowledge e.g.
predicate logic,
semantic networks,
extended semantic net,
frames,
conceptual dependency etc.
In predicate logic, knowledge is represented in the form of rules and facts as is done in
Prolog.
Knowledge is the information about a domain that can be used to solve problems in that
domain. To solve many problems requires much knowledge, and this knowledge must be
represented in the computer. As part of designing a program to solve problems, we must
define how the knowledge will be represented.
A representation scheme is the form of the knowledge that is used in an agent.
A representation of some piece of knowledge is the internal representation of the

knowledge. A representation scheme specifies the form of the knowledge. A knowledge


base is the representation of all of the knowledge that is stored by an agent.
Differenttypesofknowledgerequiredifferentkindsofrepresentation.TheKnowledgeRepresent
ationmodels/mechanismsareoftenbasedon:
Logic

Rules

Frames

SemanticNet

Knowledge and Representation

Problem solving requires large amount of knowledge and some mechanism for
manipulating that knowledge.

The Knowledge and the Representation are distinct entities, play a central but
distinguishable roles in intelligent system.
Knowledge is a description of the world;
it determines a system's competence by what it knows.
Representation is the way knowledge is encoded;
it defines the system's performance in doing something.
In simple words:
need to know about things we want to represent, and
need some means by which things we can manipulate.
Knowledge Representation Schemes
There are four types of Knowledge representation:
Relational, Inheritable, Inferential, and Declarative/Procedural.
Relational Knowledge:
provides a framework to compare two objects based on equivalent attributes.
any instance in which two different objects are compared is a relational type
of knowledge.
Inheritable Knowledge
is obtained from associated objects.

it prescribes a structure in which new objects are created which may inherit all
or a subset of attributes from existing objects.
Inferential Knowledge
is inferred from objects through relations among objects.
e.g.,a word alone is a simple syntax, but with the help of other words in phrase
the reader may infer more from a word; this inference with in linguistic is
called semantics.
Declarative Knowledge
a statement in which knowledge is specified, but the use to which that
knowledge is to be put is not given.
e.g. laws, people's name; these are facts which can stand alone, not dependent
on other knowledge;
Procedural Knowledge
are presentation in which the control information, to use the knowledge, is
embedded in the knowledge itself.
e.g. computer programs, directions, and recipes; these indicate specific use or
implementation;
Issues in Knowledge Representation
The

fundamental
goal of Knowledge
Representation
facilitate inference (conclusions) from knowledge.

is

to

The issues that arise while using KR techniques are many. Some of these are
explained below.
Important Attributes:
Any attribute of objects so basic that they occur in almost every problem domain?
Relationship among attributes:
Any important relationship that exists among object attributes?
Choosing Granularity:
At what level of detail should the knowledge be represented?

Set of objects:
How sets of objects be represented?
Finding Right structure:
Given a large amount of knowledge stored, how can relevant parts be accessed?

KNOWLEDGE REPRESENTATION USING PREDICATE LOGIC


Logic:
Logic is concerned with the truth of statements about the world. Generally each statement
is either TRUE or FALSE.
Logic includes: Syntax ,Semantic sand Inference Procedure.
Syntax:
Specifies the symbols in the language about how they can be combined to form sentences.
The facts about the world are represented as sentences in logic.
Semantic:
Specifies how to assign a truth value to a sentence based on its meaning in the world. It
Specifies what facts a sentence refers to. A fact is a claim about the world, and it may be
TRUE or FALSE.
Inference Procedure:
Specifies methods for computing new sentences from the existing sentences.
Logic Representation
Logic can be used to represent simple facts.
The facts are claims about the world that are True or False.
To build a Logic-based representation:

User defines a set of primitive symbols and the associated semantics.

Logic defines ways of putting symbols together so that user can define
legal sentences in the language that represent TRUE facts.

Logic defines ways of inferring new sentences from existing ones.

Sentences- either TRUE or false but not both are called propositions.

A declarative sentence expresses a statement with a proposition as content;


example: the declarative "snow is white" expresses that snow is white;
further," snow is white" expresses that snow is white is TRUE.

PREDICATE LOGIC
Predicate logic satisfies the requirements of a language.

Predicate logic is powerful enough for expression and reasoning.


Predicate logic is built upon the ideas of propositional logic.
Predicate:
Every complete "sentence" contains two parts: a "subject" and a "predicate".
The subject

is what (or whom) the sentence is about. The predicate tells

something about the subject;


Example:
A sentence "Judy {runs}".
The subject

is Judy

and

the predicate is runs.

Predicate, always includes verb, tells something about the subject.


Predicate is a verb phrase template that describes a property of objects,
or a relation among objects represented by the variables.
Example:
The car Tom is driving is blue"; "The sky is blue";
"The cover of this book is blue"
Predicate is is blue", describes property. Predicates are given names; Let B is
name for predicate "is_blue". Sentence is represented s"B(x)", read a "x is
blue"; Symbol x representsan arbitrary Object.
First Order Logic
Constants are objects: john, apples
Predicates are properties and relations:

likes(john, apples)

Functions transform objects:

likes(john, fruit_of(apple_tree))

Variables represent any object: likes(X, apples)


Quantifiers qualify values of variables

True for all objects (Universal):

X. likes(X, apples)

Exists at least one object (Existential): X. likes(X, apples)

Example: FOL Sentence


On Mondays and Wednesdays I go to Johns house for dinner

Higher Order Logic


More expressive than first order
Functions and predicates are also objects

Described by predicates: binary(addition)

Transformed by functions: differentiate(square)

Can quantify over both

E.g. define red functions as having zero at 17

RESOLUTION
Resolution is a procedure used in proving that arguments which are expressible in
predicate logic are correct.
Resolution
is
contradiction.

procedure

that

produces proofs by refutation or

Resolution lead to refute a theorem- proving technique for sentences in propositional


logic and first-order logic.

Resolution is a rule of inference.

Resolution is a computerized theorem prover.

Resolution is so far only defined for Propositional Logic. The strategy is that
the Resolution techniques of Propositional logic be adopted in Predicate Logic.

Types of rules:
Three types of rules are mostly used in the Rule-based production systems.
Knowledge Declarative Rules:

These rules state all the facts and relationships about a problem.
Example:
IF inflation rate declines
THEN the price of gold goes down.
These rules are a part of the knowledge base.
Inference Procedural Rules
These rules advise on how to solve a problem, while certain facts
are known.
Example:
IF the data needed is not in the system THEN request it from the user.
These rules are part of the inference engine.
Meta rules
These are rules for making rules. Meta-rules reason about which rule should be
considered for firing.
Example:
IF

the rules which dont mention the current goal in their premise,

AND there are rules which do mention the current goal in their premise,
THEN the former rule should be used in preference to the latter.
Meta-rules
direct
reasoning
rather
than
actually
performing reasoning.
Meta rules specify which rules should be considered and in which order they
should be invoked.

KNOWLEDGE REPRESENTATION USING OTHER LOGIC


Formal logic
o Computer languages have been written which incorporate (part of) the reasoning
mechanisms to be found in formal logic.
o The most important is Prolog.
o The result is a declarative programming language

a language that can (sometimes) be left to work out the solutions to


problems itself.

Its only necessary to provide a description of the problem.

This is radically different to a conventional programming language where,


unless you incorporate an algorithm, the program is quite incapable of
solving the problem.

o Example of logic, used for knowledge representation: Kowalski's project to


represent the British Nationality Act in PROLOG.

Procedural versus Declarative Knowledge


These two types of knowledge
Procedural Knowledge: knowing' how to do'
Includes: rules, strategies, agendas, procedures, models. These explains what to
do in order to reach a certain conclusion. Example
Rule: To determine if Peter or Robert is older, first find their ages.
It is knowledge about 'how to do' something. It manifests itself in the doing of
something, e.g.,manual or mental skills can not reduce to words. It is held by
individuals in a way which does not allow it to be communicated directly too the
individuals.
Accepts a description of the steps of a task or procedure. It Looks similar to
declarative knowledge, except that tasks or methods are being described instead
of facts or things.
Declarative Knowledge: knowing 'what', knowing 'that'
Includes: concepts, objects, facts, propositions, assertions, models.
It is knowledge about facts and relationships ,that
can be expressed in simple and clear statements,
can be added and modified without difficulty.
Examples: A car has four tyres;
Peter is older than Robert.
Declarative knowledge and explicit knowledge are articulated knowledge and

may be treated as synonyms for most practical purposes.


Advantages of logic Programming:

Programmer need only specify rules and facts since a search engine is built directly in to
the language.

Disadvantages of LP:

Search control is fixed.

Advantages of PROLOG:

PROLOG allow control of search through a non-logical operator called cut.

PROLOG programs composed of a restricted set of logical operators.

A cut can be inserted into a rule to specify a point that may not be backtracked over.

Disadvantages of PROLOG:

PROLOG code can be written that uses search strategies other than depth.

It is difficult to apply domain knowledge to constrain a search.

KNOWLEDGE REPRESENTATION USING STRUCTURED OBJECTS


KINDS OF KNOWLEDGE
Cognitive Psychologists identify different categories of knowledge:
Declarative: A symbolic expression of competence. Declarative knowledge is abstract.
Declarative knowledge is used to communicate and to reason.
Procedural: A series of steps to solve a problem. A compiled expression of knowledge
Reactive: stimulus - response.
Structure Knowledge Representations were explored as a general representation for
symbolic representation of declarative knowledge. One of the results was a theory for Schema
Systems
Structured objects are:

Knowledge representation formalisms whose components are essentially similar


to the nodes and arcs found in graphs.

In contrast to production rules and formal logic.

An attempt to incorporate certain desirable features of human memory


organisation into knowledge representations.

Implicit representations are simpler and slightly more efficient in computing and
memory. Explicit representations allows a system to reason about relations. This is yet another
example of the power of representing program as data.
Frame: A Structured Representation to provide context for focusing visual interpretation of
scenes. Frames provide visual context to guide scene interpretation. A Frame tells the program
what to look for and where to look for it.

SCRIPTS
A script is a data structure used to represent a sequence of events. Scripts are used for
interpreting stories. Popular examples have been script driven systems that can interpret and
extract facts from Newspaper Stories.
Scripts have been used to
1) Interpret, understand and reason about stories,
2) Understand and reason about observed events
3) Reason about observed actions
4) Plan actions to accomplish tasks.
A script is composed of
1) A scene
2) Props (objects manipulated in the script)
3) The actors (agents that can change the state of the world).
4) Events
5) Acts: A set of actions by the actors.
SEMANTIC NETS

Semantic nets are networks of words with rich sets of relations. Because words are
related in a network and not a strict hierarch, a semantic net leads to circular definitions if used
to "define" words.
Fundamental problems with structures.
Some Fundamental Problem with all schema systems.
1) Knowledge acquisition: Learning a schema system is long, tedious, and ad hoc process.
2) Context Recognition (The Frame problem): Many problems are easily solved when the
context is known. Recognizing the correct context can be very difficult.
Solution to both of these can be obtained from probabilistic techniques for learning
and recognition.

Você também pode gostar