AI Lecture2 B
AI Lecture2 B
27
اسعد نوري هاشم.د.إعداد م محاضرات في الذكاء االصطناعي
on(c,a)
on(b,d)
ontable(a)
ontable(d)
clear(b)
clearl(c)
hand_empty
Figure 1 A blocks world with its predicate calculus description
.
That is, for all X, X is clear if there does not exist a Y such that Y is on X.
This rule not only defines what it means for a block to be clear but also
provides a basis for determining how to clear blocks that are not. For example,
block d is not dear, because if variable X is given value d, substituting b for Y will
make the statement false. Therefore, to make this definition true, block b must be
removed from block d. This is easily done because the computer has a record of all
the blocks and their locations.
Besides using implications to define when a block is clear, other rules may be
added that describe operations such as stacking one block on top of another. For
example: to stack X on Y, first empty the hand, then clear X, then clear Y, and then
pick_up X and put_down X on Y.
28
اسعد نوري هاشم.د.إعداد م محاضرات في الذكاء االصطناعي
Inference Rules
The semantics of the predicate calculus provides a basis for a formal theory of
logical inference. The ability to infer new correct expressions from a set of true
assertions is an important feature of the predicate calculus. These new expressions
are correct in that they are consistent with all previous interpretations of the original
set of expressions. First we discuss these ideas informally and then we create a set
of definitions to make them precise.
An interpretation that makes a sentence true is said to satisfy that sentence.
An interpretation that satisfies every member of a set of expressions is said to
satisfy the set. An expression X logically follows from a set of predicate calculus
expressions S if every interpretation that satisfies S also satisfies X. This notion
gives us a basis for verifying the correctness of rules of inference: the function of
logical inference is to produce new sentences that logically follow a given set of
predicate calculus sentences.
It is important that the precise meaning of "logically follows" be understood:
for expression X to logically follow S, it must be true for every interpretation that
satisfies the original set of expressions S. This would mean, for example, that any
new predicate calculus expression added to the blocks world of Figure 2.3 must be
true in that world as well as in any other interpretation that that set of expressions
may have.
The term itself, "logically follows," may be a bit confusing, It does not mean
that X is deduced from or even that it is deducible from S. It simply means that X is
true for every (potentially infinite) interpretation that satisfies S. However, because
systems of predicates can have a potentially infinite number of possible
interpretations, it is seldom practical to try all interpretations. Instead, inference
29
اسعد نوري هاشم.د.إعداد م محاضرات في الذكاء االصطناعي
DEFIINITION
If the sentences P and P →Q are known to be true, then modus ponens lets us
infer Q. Under the inference rule modus tollens, if P → Q is known to be true and Q
is known to be false, we can infer ~ P.
And elimination allows us to infer the truth of either of the conjuncts from the
truth of a conjunctive sentence. For instance, P /\ Q lets us conclude P and Q are
30
اسعد نوري هاشم.د.إعداد م محاضرات في الذكاء االصطناعي
true. And introduction lets us infer the truth of a conjunction from the truth of its
conjuncts. For instance, if P and Q are true, then P /\ Q is true.
Universal instantiation states that if any universally quantified variable in a
true sentence is replaced by any appropriate term from the domain, the result is a
true sentence. Thus, if a is from the domain of X, X p(X) lets us infer p(a).
As a simple example of the use of modus ponens in the propositional calculus,
assume the following observations: "if it is raining then the ground will be wet" and
"it is raining." . if P denotes "it is raining" and Q is "the ground is wet" then the first
expression becomes P → Q. Because it is indeed now raining (P is true), our set of
axioms becomes
P→Q
P
Through an application of modus ponens, the fact that the ground is wet (Q)
may be added 1mtrne set of true expressions.
Modus ponens can also be applied to expressions containing variables.
Consider as an example the common syllogism "all men are mortal and Socrates is
a man; therefore Socrates is mortal. "All men are mortal" may be represented in
predicate calculus by
X (man(X) → mortal(X)).
"Socrates is a man" is
man(Socrates).
Because the X in the implication is universally quantified, we may substitute
any value in domain for X and still have a true statement under the inference rule of
universal instantiation. By substituting Socrates for X in the implication, we infer
the expression man(socrates) → mortal(socrates).
31
اسعد نوري هاشم.د.إعداد م محاضرات في الذكاء االصطناعي
We can now apply modus ponens and infer the conclusion mortal(Socrates).
This is added the set of expressions that logically follow from the original
assertions. An algorithm called unification can be used by an automated problem
solver to determine that Socrates my be substituted for X in order to apply modus
ponens.
Unification
32
اسعد نوري هاشم.د.إعداد م محاضرات في الذكاء االصطناعي
33
اسعد نوري هاشم.د.إعداد م محاضرات في الذكاء االصطناعي
example, father(jack) may be substituted for X in man (X) to infer that jack's father
is mortal.
Some instances of the expression
foo(X,a,goo(Y) ).
1) foo(fred,a,goo(Z))
2) foo(W,a,goo(jack))
3)foo(Z,a,goo(moo(Z)) )
In this example, the substitution instances or unifications that would make the
initial expression identical to each of the other three arc written as
1) {fred/X, Z/Y}
2) {W/X, jack/Y}
3}) {Z/X, moo(Z)/Y}
The notation X/Y, ... indicates that X is substituted for the variable Y in the
original expression. Substitutions are also referred to as bindings. A variable is said
to be bound to the value substituted for it.
In defining the unification algorithm that computes the substitutions required
to match me expressions, a number of issues must be taken into account.
A variable cannot be unified with a term containing that variable. X cannot be
replaced by p(X) as this creates an infinite expression: p(p(p(p(...X) ...). The test for
this situation is ,~ the occurs check.
Another important concept is the composition of unification substitutions. If Sand
S' are two substitution sets, then the composition of S and S' (written SS') is
34
اسعد نوري هاشم.د.إعداد م محاضرات في الذكاء االصطناعي
obtained by S' to the elements of S and adding the result to S. Consider the example
of composing the following three sets of substitutions:
{X/Y, W/Z}, {V/X}, {a/V, f(b)/W}.
Composing the third set, (a/V, f(b)/W), with the second, {V/X), produces:
{a/X, a/V, f(b)/W}.
Composing this result with the first set, {X/Y, W/Z), produces the set of
substitutions:
{a/Y, a/X, a/V, f(b)/Z, f(b)/W}.
Composition is the method by which unification substitutions are combined and
returned in the recursive function unify, presented next. Composition is associative
but not commutative. The exercises present these issues in more detail.
A further requirement of the unification algorithm is that the unifier be as
general as possible: that the most general unifier be found. This is important, as will
be seen in the next example, because, if generality is lost in the solution process, it
may lessen the scope of the eventual solution or even eliminate the possibility of a
solution entirely.
For example, in unifying p(X) and p(Y) any constant expression such as
{fred/X, fred/Y) will work. However, fred is not the most general unifier; any
variable would produce a more general expression: {Z/X, ZIY}. The solutions
obtained from the first substitution instance would always be restricted by having
the constant fred limit the resulting inferences; i.e., fred would be a unifier, but it
would lessen the generality of the result.
35
اسعد نوري هاشم.د.إعداد م محاضرات في الذكاء االصطناعي
Production Systems
The production system is a model of computation that has proved particularly
important in AI, both for implementing search algorithms and for modeling human
problem solving. A production system provides pattern-directed control of a
problem-solving process and consists of a set of production rules, a working
memory, and a recognize-act control cycle.
A production system is defined by:
1. The set of production rules. These are often simply called productions. A
production is a condition-action pair and defines a single chunk of problem solving
knowledge. The condition part of the rule is a pattern that determines when that rule
may be applied to a problem instance. The action part defines the associated
problem-solving step.
3. The recognize-act cycle. The control structure for a production system is simple:
working memory is initialized with the beginning problem description. The current
state of the problem-solving is maintained as a set of patterns in working memory.
These patterns are matched against the conditions of the production rules; this
36
اسعد نوري هاشم.د.إعداد م محاضرات في الذكاء االصطناعي
produces a subset of the production rules, called the conflict set, whose conditions
match the patterns in working memory. The
productions in the conflict set are said to be enabled. One of the productions in the
conflict set is then selected (conflict resolution) and the production is fired.
To fire a rule, its action is performed, changing the contents of working
memory. After the selected production rule is fired, the control cycle repeats with
the modified working memory. The process terminates when the contents of
working memory do not match any rule conditions. Conflict resolution chooses
a rule from the conflict set for firing. Conflict resolution strategies may be
simple, such as selecting the first rule whose condition matches the state of the
world, or may involve complex rule selection heuristics. This is an important
way in which a production system allows the addition of heuristic control
to a search algorithm. The pure production system model has no mechanism for
recovering from dead ends in the search; it simply continues until no more
productions are enabled and halts.
Many practical implementations of production systems allow backtracking to a
previous state of working memory in such situations.
Example:-
Production set:
1. ba ab
2. ca ac
3. cb be
37
إعداد م.د .اسعد نوري هاشم محاضرات في الذكاء االصطناعي
38
اسعد نوري هاشم.د.إعداد م محاضرات في الذكاء االصطناعي
Semantic Nets
Semantic nets at the time of its origin were used mainly in understanding
natural language, where the semantics (meaning) of the associated words in a
sentence was extracted by employing such nets. Gradually, semantic nets found a
wider application in reasoning of knowledge based systems. A semantic net
consists of two elementary tuples: events denoted by nodes and relationship
between events, denoted by links / arcs. Generally, a linguistic label is attached to
each link to represent the association between the events. A simple semantic net
that describes a binary predicate: Likes (X, Y) is presented in the following figure:-
Readers should not confuse from the last figure that a semantic net can
represent only a binary predicate, i.e., a predicate having two arguments. It can
represent non-binary predicates as well. For instance, consider the unary predicate
boy (jim). This can be represented by a binary predicate
instance-of (jim, Boy)
and consequently can be represented by the following figure:-
39
اسعد نوري هاشم.د.إعداد م محاضرات في الذكاء االصطناعي
Further, predicates having more than two arguments can also be represented
by semantic nets. For example, consider the ternary predicate:
Gave (john, the-beggar, 10$)
This can be represented by semantic nets, vide following figure:
40
اسعد نوري هاشم.د.إعداد م محاضرات في الذكاء االصطناعي
41
اسعد نوري هاشم.د.إعداد م محاضرات في الذكاء االصطناعي
42