Documente Academic
Documente Profesional
Documente Cultură
BACKWARD CHAINING:
Suppose that we have formulas:[Backward chaining only works for Horn clauses, which have at
most one positive literal.]
A
B
D
A∧B→C
C∧D→E
1. First check whether the desired conclusion is in the database of facts. If so, return True.
2. Otherwise, for each rule that has the desired conclusion (right-hand side), call the
algorithm recursively for each item in the premise (left-hand side). If all of the premises
are true, return True.
3. Otherwise, return False.
In this example, we would know that E is true if we knew that C and D were true; we would
know that C is true if we knew A and B ; A and B are in the database, so C must be true; and D is
in the database, so E is true.
Forward Chaining
From A and B , it is possible to derive C and save it as a new fact; then from C and D , E can be
derived.
This cycle is repeated until activity stops or until the desired fact is added to the database.
Unification Algorithm
The basic unification algorithm is simple. However, it must be implemented with care to ensure
that the results are correct.
We begin by making sure that the two expressions have no variables in common. If there are
common variables, substitute a new variable in one of the expressions. (Since variables are
universally quantified, another variable can be substituted without changing the meaning.)
Imagine moving a pointer left-to-right across both expressions until parts are encountered that
are not the same in both expressions. If one is a variable, and the other is a term not containing
that variable,
Unification Implementation
1. Initialize the substitution set to be empty. We do this with the set ((t . t)). A nil set
indicates failure.
2. Recursively unify expressions:
1. Identical items match.
2. If one item is a variable vi and the other is a term ti not containing that variable,
then:
1. Substitute ti / vi in the existing substitutions.
2. Add ti / vi to the substitution set.
3. If both items are functions, the function names must be identical and all
arguments must unify. Substitutions are made in the rest of the expression as
unification proceeds.
Predicate Logic
The first of these, predicate logic, involves using standard forms of logical symbolism which
have been familiar to philosophers and mathematicians for many decades. Most simple
sentences, for example, ``Peter is generous'' or ``Jane gives a painting to Sam,'' can be
represented in terms of logical formulae in which a predicate is applied to one or more
arguments (the term `argument' as used in predicate logic is similar to, but not identical with, its
use to refer to the inputs to a procedure in POP-11):
PREDICATE ARGUMENTS
generous (peter)
Consider the following sentence: ``Every respectable villager worships a deity.'' A moment's
reflection will reveal that this is ambiguous. Is it saying that there is one single deity to which
each respectable villager offers worship? Or does each worshipper have his or her own deity, to
which a fellow respectable villager may or may not be also praying? With predicate logic it is
easy to reveal the nature of the ambiguity, by a device known as quantification. Quantification
allows one to talk in a general way about all things of a certain class or about some particular but
unspecified thing of a certain class. We can, for instance, express the proposition ``All of Jane's
friends are generous'' in terms of the following formula:
while the sentence ``Jane has at least one friend who is generous'' can be expressed as follows:
The expressions `For any X' and `For some X' are known as quantifiers. We can now use
quantification to exhibit the ambiguity of the sentence about the respectable villagers. The first
reading of it can be represented as