Module 2 - AI
Module 2 - AI
Representing the propositional logic is easy because it is simple to deal with and a decision
procedure for it exists.
Resolution:
Problem :
All Romans who know Marcus either hate Caesar or think that anyone who hates anyone is
crazy.
Example:
1. Eliminate "
2. Reduce scope of
3. Standardize Variables.
4. Move quantifiers.
becomes
Resolution procedure is a simple iterative process: at each step, two clauses, called the parent clauses,
are compared (resolved), yielding a new clause that has been inferred from them.
This means that both clauses must be true. One of winter and winter will be true at any point. If
winter is true, then cold must be true to guarantee the truth of the second clause. If winter is true,
then summer must be true to guarantee the truth of the first clause. From these two clauses we can
deduce
Herbrand’s Theorem
To show that a set of clauses S is unsatisfiable, it is necessary to consider only
interpretations over a particular set, called the Herbrand universe of S.
A set of clauses S is unsatisfiable if and only if a finite subset of ground instances (in
which all bound variables have had a value substituted for them) of S is unsatisfiable.
In propositional logic, the procedure for producing a proof by resolution of proposition P with respect to
a set of axioms F in the following:
2. Negate P and convert the result to clause form. Add it to the set of clauses obtained in step 1.
(b) Resolve them together. The resulting clause, called the resolvent, will be the disjunction of all of the
literals of both of the parent clauses with the following exception: If there are any pairs of literals L and
¬L such that one of the parent clauses contains L and the other contains ¬L, then select one such pair
and eliminate both L and ¬L from the resolvent.
(c) If the resolvent is the empty clause, then a contradiction has been found. If it is not, then add it to
the set of clauses available to the procedure.
Unification:
In propositional logic, it is easy to determine that two literals cannot be true at the same time.
Finding General Substitutions
Given :
We could produce:
(b) Else if L1 is a variable, then if L1 occurs in L2 then return {FAIL}, else return (L2/L1).
(c) Else if L2 is a variable then if L2 occurs in L1 then return {FAIL}, else return (L1/L2).
2. If the initial predicate symbols in L1 and L2 are not identical, then return {FAIL).
(a) Call Unify with the /th argument of L1 and the ith argument of L2, putting result in S.
6. Return SUBST.
Algorithm : Resolution
2. Negate P and convert the result to clause form. Add it to the set of clauses obtained in 1.
3. Repeat until either a contradiction is found, no progress can be made, or a predetermined amount of
effort has been expended.
(b) Resolve them together. The resolvent will be the disjunction of all the literals of both parent
clauses with appropriate substitutions performed and with the following exception: If there is
one pair of literals T1 and ¬T2 such that one of the parent clauses contains T2 and the other
contains T1 and if T1 and T2 are unifiable, then neither T1 nor T2 should appear in the resolvent.
If there is more than one pair of complimentary literals, only one pair should be omitted from
the resolvent.
(c) If the resolvent is the empty clause, then a contradiction has been found. If it is not, then add it
to the set of clauses available to the procedure.
A Resolution Proof
MODULE 2: Chapter 6: Representing Knowledge using Rules.
Procedural versus Declarative Knowledge
A declarative representation is one in which knowledge is specified, but the use to which that
knowledge is to be put is not given. To use declarative representation, the program should be
specified with what is to be done with the knowledge and how.
A procedural representation is one in which the control information that is necessary to use the
knowledge is considered to be embedded in the knowledge itself.
To use a procedural representation, we need to augment it with aninterpreter that follows the
instructions given in the knowledge.
The difference between the declarative and the procedural views of knowledge lies in where
control information resides.
Logic Programming:
Logic programming is a programming language paradigm in whichlogical assertions are viewed
as programs, e.g : PROLOG
The fact that PROLOG programs are composed only of Horn Clauses and not of arbitrary logical
expressions has two important consequences.
A PROLOG program is composed of a set of Horn clauses. A Horn Clause is a clause that has at
most one positive literal.
Examples :
There are several superficial, syntactic differences between the logic and the PROLOG
representations, including:
1. In logic, variables are explicitly quantifies. In PROLOG, quantification is provided
implicitly by the way the variables are interpreted.
2. In logic, there are explicit symbols for and (^) and or (V). In PROLOG, there is explicit
symbol for and (,), but there is none for or.
3. In logic, implications of the form “p implies q” are written as p -> q. In PROLOG, the
same implication is written “backward ”, as q: - p.
The objective of any search is to find a path through a problem spacefrom the initial to
the final one.
A Sample of the Rules for Solving the 8-Puzzle
An Examples :
Start Goal
Forward
Backward
8-square problem
To reason backwards, the right sides are matched against the current node and the left
sides are used to generate new nodes.
.
Are there more possible start states or goal states? We would like to go from smaller set
of states to larger set of states.
In which direction is the branching factor (the average number of nodes that can be
reached directly from a single node) greater? We would like to proceed in the direction
with the lower branching factor.
Will the program be asked to justify its reasoning process to the user? It so, it is important
to proceed in the direction that corresponds more closely with the way user will think.
Forward Rules: which encode knowledge about how to respond tocertain input configurations.
Matching
Till now we have used search to solve the problems as the application of appropriate
rules.
We applied them to individual problem states to generate new states to which the rules
can then be applied, until a solution is found.
We suggest that a clever search involves choosing from among the rules that can be
applied at a particular point, but we do not talk about how to extract from the entire
collection of rules those that can be applied at a given point.
Indexing
Do a simple search through all the rules, comparing eachone’s precondition to the current state
and extracting all the ones that match. But this has two problems
In order to solve very interesting problems , it will be necessary to use a large number of rules,
scanning through all of them at every step of the search would be hopelessly inefficient.
It is not always immediately obvious whether a rule’s preconditions are satisfied by a particular
state.
To solve the first problem, use simple indexing. Eg. In Chess, combine all moves at a particular
board state together.
Matching with Variables
The problem of selecting applicable rules is made more difficult when preconditions are
not stated as exact descriptions of particular situations but rather describe properties that
the situations must have.
Then we need to match a particular situation and the preconditions of a given situation.
In many rules based systems, we need to compute the whole set of rules
that match the current state description. Backward Chaining Systems usually use depth-
first backtracking to select individual rules, but forward chaining systems use Conflict
Resolution Strategies.
An even more complex matching process is required if rules should be applied if their
preconditions approximately match the current situation. Example of listening to a
recording of a telephonic conversation.
For some problems, almost all the action is in the matching of the
rulesto the problem state. Once that is done, so few rules apply that theremaining search
is trivial. Example ELIZA
Conflict Resolution
The result of the matching process is a list of rules whose antecedents have matched the current
state description along with whatever variable binding were generated by the matching process.
It is the job of the search method to decide on the order in which the rules will be applied. But
sometimes it is useful to incorporate some of the decision making into the matching process.
This phase is called conflict resolution.
There are three basic approaches to the problem of conflict resolution in the production system
Assign a preference based on the action that the matched rule would perform.