0% found this document useful (0 votes)
81 views16 pages

AI Lecture2 B

The document discusses using predicate calculus to model a "blocks world" scenario with blocks on a table that can be moved by a robot arm. It provides examples of predicate calculus expressions to represent attributes of blocks like their location and whether they are clear. It introduces inference rules like modus ponens that can be used to infer new true expressions based on known ones. For example, it shows how modus ponens can be used to infer that "Socrates is mortal" from the statements "all men are mortal" and "Socrates is a man".
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views16 pages

AI Lecture2 B

The document discusses using predicate calculus to model a "blocks world" scenario with blocks on a table that can be moved by a robot arm. It provides examples of predicate calculus expressions to represent attributes of blocks like their location and whether they are clear. It introduces inference rules like modus ponens that can be used to infer new true expressions based on known ones. For example, it shows how modus ponens can be used to infer that "Socrates is mortal" from the statements "all men are mortal" and "Socrates is a man".
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 16

‫ اسعد نوري هاشم‬.‫د‬.

‫إعداد م‬ ‫محاضرات في الذكاء االصطناعي‬

A "Blocks World" Example of Semantic Meaning


We conclude this section by giving an extended example of a truth value
assignment to a set of predicate calculus expressions. Suppose we want to model
the blocks world of Figure 1 to design, for example, a control algorithm for a robot
arm. We can use predicate calculus sentences to represent the qualitative
relationships in the world: does a given block have a clear top surface? can we pick
up block a? etc. Assume that the computer has knowledge of the location of each
block and the arm and is able to keep track of these locations (using three-
dimensional coordinates) as the hand moves blocks about the table.
We must be very precise about what we are proposing with this "blocks
example. First, we are creating a set of predicate calculus expressions that is to
represent a static snapshot of the blocks world problem domain. As we will see in
Section 2.3, this set of blocks offers an interpretation and a possible model for the
set of predicate calculus expressions.
Second, the predicate calculus is declarative, that is, there is no assumed
timing or order for considering each expression. Nonetheless, in the planning
section of this book, Section 8.4, we will add a "procedural semantics", or a clearly
specified methodology for evaluating these expressions over time. A concrete
example of a procedural semantics for predicate calculus expressions is PROLOG.
To pick up a block and stack it on another block, both blocks must be clear. In
Figure 2.3, block a is not clear. Because the arm can move blocks, it can change the
state of the world and clear a block. Suppose it removes block c from block a and
updates the knowledge base to reflect this by deleting the assertion on(c,a). The
program needs to be me to infer that block a has become clear. The following rule
describes when a block is clear:  X(~  Y on(Y,X) → clear(X)).

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.

 X  Y ((hand_empty /\ clear(X) /\ clear(Y) /\ pick_up(X) /\ put_down(X,Y)) → stack(X,Y))

Using Inference Rules to Produce Predicate Calculus Expressions

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
‫ اسعد نوري هاشم‬.‫د‬.‫إعداد م‬ ‫محاضرات في الذكاء االصطناعي‬

rules provide a computationally feasible way to determine when an expression, a


component of an interpretation, logically follows for that interpretation. The
concept "logically follows" provides a formal basis for proofs of the soundness and
correctness of inference rules.
An inference rule is essentially a mechanical means of producing new
predicate calculus sentences from other sentences. That is, inference rules produce
new sentences based on the syntactic form of given logical assertions. When every
sentence X produced by an inference rule operating on a set S of logical
expressions logically follows from S, me inference rule is said to be sound.
If the inference rule is able to produce every expression that logically follows
from S, then it is said to be complete. Modus ponens, to be introduced below, and
resolution, are examples of inference rules that are sound and, when used with
certain appropriate strategies, complete. Logical inference systems generally use
sound rules of inference, although later chapters examine heuristic reasoning and
commonsense reasoning, both of which relax this requirement.

DEFIINITION

MODUS PONENS, MODUS TOLLENS, AND ELIMINATION, AND


INTRODUCTION, and UNIVERSAL INSTANTIATION

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

To apply inference rules such as modus ponens, an inference system must be


able to determine when two expressions are the same or match. In propositional
calculus, this is trivial: two expressions match if and only if they are syntactically
identical. In predicate calculus, the process of matching two sentences is
complicated by the existence of variables in the expressions. Universal instantiation
allows universally quantified variables to be replaced by terms from the domain.
This requires a decision process for determining the variable substitutions under
which two or more expressions can be made identical (usually for the purpose of
applying inference rules).
Unification is an algorithm for determining the substitutions needed to make
two predicate calculus expressions match. We have already seen this done in the
previous subsection, where Socrates in man(socrates) was substituted for X in
 x(man(X) → mortal(X))
This allowed the application of modus ponens and the conclusion
mortal(socrates). Another example of unification was seen previously when dummy
variables were discussed. Because p(X) and p(Y) are equivalent, Y may be
substituted for X to make the sentences match.

32
‫ اسعد نوري هاشم‬.‫د‬.‫إعداد م‬ ‫محاضرات في الذكاء االصطناعي‬

Unification and inference rules such as modus ponens allow us to make


inferences on a set of logical assertions. To do this, the logical database must be
expressed in an appropriate form. An essential aspect of this form is the
requirement that all variables be universally quantified. This allows full freedom in
computing substitutions. Existentially quantified variables may be eliminated from
sentences in the database by replacing them with the constants that make the
sentence true. For example,
X parent(X, tom) .could be replaced by the expression parent(bob, tom) or
parent(mary, tom), assuming that bob and mary are tom's parents under the
interpretation.
The process of eliminating existentially quantified variables is complicated by
the fact that the value of these substitutions may depend on the value of other
variables in the expression. For example, in the expression X  Y mother(X,Y),
the value of the existentially quantified variable Y depends on the value of X.
Skolemtzation replaces each existentially quantified variable with a function that
returns the appropriate constant as a function of some or all of the other variables in
the sentence. In the above example, because the value of Y depends on X, Y could
he replaced by a skolem function, f, of X. This yields the predicate
X mother(X,f(X)). Skolemization, a process that can also bind universally
quantified variables to constants, is discussed in more detail later .
Once the existentially quantified variables have been removed from a logical
database, unification may be used to match sentences in order to apply inference
rules such as modus ponens. Unification is complicated by the fact that a variable
may be replaced by any term, including other variables and function expressions of
arbitrary complexity. These expressions may themselves contain variables. For

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) ).

generated by legal substitutions are given below:

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.

2. Working memory contains a description of the current state of the world in


a reasoning process. This description is a pattern that is matched against the
condition part of a production to select appropriate problem-solving actions. When
the condition element of a rule is matched by the contents of working memory, the
action associated with that condition may then be performed. The actions of
production rules are specifically designed to alter the contents of working memory.

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:-

Fig.: A semantic net corresponding to the predicate Likes(X, Y)

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
‫ اسعد نوري هاشم‬.‫د‬.‫إعداد م‬ ‫محاضرات في الذكاء االصطناعي‬

Fig: Representation of instance-of (jim, Boy).

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:

Fig.: A semantic net, representing a ternary predicate


It is thus clear from above fig. that a predicate of arity >2 can be represented by a
number of predicates, each of arity 2, and then the resulting predicates can be
represented by a semantic net. For instance, the ternary predicate:-

40
‫ اسعد نوري هاشم‬.‫د‬.‫إعداد م‬ ‫محاضرات في الذكاء االصطناعي‬

Gave(john, the-beggar, 10$)


has been represented in the above fig. as a collection of 4 predicates given by:-
Agent (john, event)
Beneficiary (the-beggar, event)
Object (10$, event)
Instance-of (give, event).
It may be added here that the representation of a higher-arity predicate in binary
form is not unique; consequently, the semantic net of predicates of arity > 2 is also
not unique.

Fig.: A semantic net to represent


Instance-of(X,Child) /\ Instance-of(Y,sweet) →Likes(X,Y)

Another important issue of discussion on semantic nets is its capability of


representation of quantifiers. For example, suppose we like to represent the
following predicate:
 XY (Child(X) /\Sweet(Y) →Likes(X,Y))
This can be transformed into the following forms of binary predicates:

41
‫ اسعد نوري هاشم‬.‫د‬.‫إعداد م‬ ‫محاضرات في الذكاء االصطناعي‬

 X  Y(Instance-of(X,Child) /\Instance-of(Y,sweet) →Likes(X,Y))

Consequently, we represent the above clause by a semantic net (vide above


fig.).The semantic net shown in the above fig. describes a mapping from
relationships Instance-of (X, child) and Instance-of (sweet, Y) to relationships
Likes (X, Y). To represent the given clause by an alternative form of semantic nets,
we, for example, first express it in the following:
 X  Y(~Instance-of(X,Child) V~ Instance-of(Y,sweet) V Likes(X,Y))

Fig .: A representation of:

 X  Y(~Instance-of(X,Child) V~ Instance-of(Y,sweet) V Likes(X,Y))


Semantic nets can be partitioned into modules, where one or more modules
are subsets of the others. Such modular structure helps reasoning in a hierarchical
fashion and thus is more time efficient.

42

You might also like