Module 3 and 4
Module 3 and 4
• We will represent the sentences using two different logics, They are,
➢ Propositional Logic (or) Boolean logic
➢ Predicate logic (or) First order logic
P Q ¬P PΛQ PVQ P ⇒Q P⇔ Q
False False True False False True True
False True True False True True False
True False False False True False False
True True False True True True True
3
Page
• The Knowledge Base: The agent percepts are converted into sentences and entered into
the knowledge base, with some valid sentences that are entailed by the percept sentences
• From the above figure we can perceive the following percept sentences and it is added to
the knowledge base.
• Finding the wumpus as, We can prove that the Wumpus is in (1, 3) using the four
rules given.
o Apply Modus Ponens with S1 1 and R1:
▪ W1 1 W1 2 W2 1
o Apply And-Elimination to this, yielding three sentences:
▪ W1 1, W1 2, W2 1
o Apply Modus Ponens to S21 and R2, then apply And-elimination:
▪ W2 2, W2 1, W3 1
o Apply Modus Ponens to S12 and R4 to obtain:
▪ W1 3 W1 2 W2 2 W1 1
o Apply Unit resolution on (W1 3 W1 2 W2 2 W1 1) and W1 1:
▪ W1 3 W1 2 W2 2
o Apply Unit Resolution with (W1 3 W1 2 W2 2) and W2 2:
▪ W1 3 W1 2
o Apply Unit Resolution with (W1 3 W1 2) and W1 2:
▪ W1 3
Programming languages:
• Programming languages like C++ or Java are the largest class of formal languages
in common use.
Disadvantages:
• Programming languages lack is any general mechanism for deriving facts from
other facts; each update to a data structure is done by a domain-specific procedure
whose details are derived by the programmer from his or her own knowledge of
the domain.
• A second drawback of data structures in programs is the lack of any easy way to
say
• For Example, “There is a Pit in [2,2] or [3,1]” or “If the Wumpus is in [I,I]
then he is not in [2,2]”.
• It also has sufficient expressive power to deal with partial information, using
disjunction and negation.
5
Page
• It also has compositionality that is desirable in representation languages
namely compositionality.
• It would be very strange if “S1,4” meant that there is a stench in square [1,4] and
“S1,2” meant that there is a stench in square [1,2], but “S1,4 Λ S1,2” meant that
France and Poland drew 1-1 in last week’s ice hockey qualifying match.
• Clearly, non Compositionality makes life much more difficult for the
reasoning system.
Advantages:
• Declarative
• Context-Independent
• Unambiguous
Disadvantages:
• For Example, it is forced to write a separate rule about breezes and pits for each
square, such as B1, 1 (P1, 2 V P2, 1).
Natural Languages:
• A moments thought suggests that natural languages like English are very
expressive indeed.
• When a speaker points and says, “Look!” the listener comes to know that, say,
Superman has finally appeared over the rooftops.
• The meaning of the above sentence depends both on the sentence itself and on
the context in which the sentence was spoken.
6
Disadvantages:
Page
• It is difficult to understand how the context can be represented.
• This is because one could not store a sentence such as “Look!” in knowledge base
and expect to recover its meaning without also storing a representation of the
context.
• They suffer from ambiguity, which would cause difficulties for thinking.
• For Example, when people think about spring, they are not confused as to whether
they are thinking about a season or something that goes boing-and if one word
can correspond to two thoughts, thoughts can’t be words.
• It is also either includes or forms the foundation of many other representation languages.
• FOL adopts the foundation of propositional logic with all its advantages to build a more
expressive logic on that foundation, borrowing representational ideas from natural
language while avoiding its drawbacks
• Some of these relations are functions-relations in which there is only one “Value” for
a given “input”.
• For Example,
Objects: People, houses, numbers
Relations: These can be unary relations or properties such as red, round,
• Indeed, almost any assertion can be thought of as referring to objects and properties or
relations
• Where,
Page
Objects: One, Two, Three, One plus Two
Relations: equals
Function: plus
Advantages:
• It can also express facts about some or all of the objects in the universe.
• It enables one to represent general laws or rules, such as the statement “Squares
neighboring the wumpus are smelly”.
• Models for propositional logic are just sets of truth values for the proposition symbols.
• The domain of a model is the set of objects it contains; these objects are sometimes called
domain elements.
• The objects in the model may be related in various ways, In the figure Richard and
John are brothers.
• Formally speaking, a relation is just the set of tuples of objects that are related.
• The crown is on King John’s head, so the “on head” relation contains just one
tuple, (the crown, King John).
• The relation can be binary relation relating pairs of objects (Ex:- “Brother”) or
unary relation representing a common object (Ex:- “Person” representing both
Richard and John)
9
Page
• Certain kinds of relationships are best considered as functions that relates an
object to exactly one object.
• For Example:- each person has one left leg, so the model has a unary “left leg”
function that includes the following mappings
• The basic syntactic elements of first-order logic are the symbols that stand for
objects, relations and functions
❖ Kinds of Symbols
✓ OnHead refers to the “on head” relation that holds between the crown and
King John; Person, King and Crown refer to the set of objects that are
persons, kings and crowns.
✓ Leftleg refers to the “left leg” function, that is, the mapping given in
{(Richard the Lionheart, King John),(King John, Richard the
10
Lionheart)}
Page
• There are many other possible interpretations relating these symbols to this
particular model.
• The truth of any sentence is determined by a model and an interpretation for the
sentence symbols.
| Quantifier Variable,…Sentence
| - Sentence
AtomicSentence Predicate (Term…) | Term = Term
Term Function (Term,….)
| Constatnt
| Variable
Variable a|x|s|…
• Where,
Λ Logical Conjunction
V Logical disjunction
∀ Universal Quantification
∃ Existential Quantification
- Material Equivalence
⇒ Material Implication
❖ Terms:
Where
• For Example:- suppose the LeftLeg function symbol refers to the function is,
John refers to King John, then LeftLeg (John) refers to king Johns left leg.
❖ Atomic Sentences:-
• This states that Richard the Lionheart is the brother of King John.
• Atomic Sentences can have complex terms as arguments.
• Thus, Married(Father(Richard), Mother(John)) states that Richard the
Lionheart’s father is married to King John’s mother
• An atomic sentence is true in a given model, under a given interpretation, if the relation
referred to by the predicate symbol holds among the objects referred to by the
arguments.
❖ Complex Sentences:-
The semantics of sentences formed with logical connectives is identical to that in the
propositional case.
Page
¬ Brother (LeftLeg (Richard), John)
❖ Quantifiers:-
✓ Universal
✓ Existential
• ∀ is usually pronounced “For all….”, Thus the sentences says , “For all x, if x is a
king, then x is a person”.
• The symbol x is called a variable.
• A variable is a term all by itself, and as such can also serve as the argument of a
function-for example, LeftLeg(x).
• A term with no variables is called a ground term.
• Based on our model, we can extend the interpretation in five ways,
sentences
Page
• Applying the semantics says that at least one of the following assertion is true,
• Now an implication is true if both premise and conclusion are true, or if its
premise is false.
❖ Nested Quantifiers:-
• Consecutive quantifiers of the same type can be written as one quantifier with
several variables.
• For Example:- to say that siblinghood is a symmetric relationship as
• On the other hand , to say “There is someone who is loved by everyone”, we can
write as
• Going one step further: “Everyone likes ice cream” means that there os no one
who does not like ice cream:
∀x ¬ P ≡ ¬ ∃ x P ¬ P Λ ¬ Q ≡ ¬ (P V Q)
¬ ∀x P ≡ ∃x ¬ P ¬ (P Λ Q) ≡ ¬ P V ¬ Q
∀x P ≡ ¬ ∃ x ¬ P P Λ Q ≡ ¬ (¬ P V ¬ Q)
∃x P ≡ ¬ ∀ x ¬ P P V Q ≡ ¬ (¬ P Λ ¬ Q )
❖ Equality:-
• First – order logic includes one more way of using equality symbol to make
atomic sentences.
• Use of equality symbol
✓ The equality symbol can be used to make statements to the effect that two
terms refer to the same object.
✓ For Example: - Father (John) = Henry says that the object referred to by
Father (John) and the object referred to by Henry are the same.
✓ Determining the truth of an equality sentence is simply a matter of seeing
that the referents of the two terms are the same object.
15
✓ The equality symbol can be used to state facts about a given function
Page
✓ It can also be used with negation to insist that two terms are not the same
object.
✓ For Example:- To say that Richard has at least two brothers, write as
The best way to learn about FOL is through examples. In Knowledge representation, a
domain is just some part of the world about which some knowledge is to be expressed.
❖ Assertions:-
❖ Substitution/Binding List:-
❖ Axioms:-
❖ Theorems:-
❖ Numbers:-
• Numbers are perhaps the most brilliant example of how a large theory can be built
up from a tiny heart of axioms.
• Requirements
• Peano Axioms:-
NatNum (0)
∀n NatNum (n) ⇒ NatNum (S(n))
❖ Sets:-
✓ The only sets are the empty set and those made by adjoining something to
a set
¬ ∃x, s {x/s} = { }
✓ The only members of a set are the elements that were connected into it.
This can be expressed recursively, saying that x is a member of s if and
only if s is equal to some set S2 connected with some element y, where
either y is the same as x or x is a member of S2
✓ A set is subset of another set if and only if all of the first sets members are
members of the second set
✓ Two sets are equal if and only if each is a subset of the other
❖ Lists:-
• The first order axioms of wumpus world are more concise, capturing in a natural
way what exactly we want to represent the concept.
• Here the more interesting question is “how an agent should organize what it
knows in order to take the right actions”.
• For this purpose we will consider three agent architectures:
• The first step of wumpus world agent construction is to define the interface
between the environment and the agent.
• The percept sentence must include both the percept and the time at which it
occurred, to differentiate between the consequent percepts.
• For Example:-
• In this sentence
Page
Percept - predicate
Stench, Breeze, Glitter - Constants
3 - Integer to represent to time.
• The agents action are,
Turn (Right)
Turn (Left)
Forward
Shoot
Grab
Release
Climb
• To determine which is best, the agent program constructs a query such as
∃a BestActions(a,5)
• ASK solves this query and returns a binding list such as {a/Grab}.
• The agent program then calls TELL to record the action which was taken to
update the Knowledge base KB.
❖ Types of Sentences:-
• There are two kinds of synchronic rules that could allow to capture the necessary
information for deductions are,
✓ Diagnostic rules
✓ Casual rules
o If all squares adjacent to a given square are pitless, the square will not be
breezy
o System that reason with casual rules are called model-based reasoning
systems, because the casual rules from a model of how the environment
operates.
•
21
The seven step process is explained with the domain of ELECTRONIC CIRCUITS
DOMAIN.
Page
✓ Identify the task: -
o Analyse the circuit functionality, does the circuit actually add
properly? (Circuit Verification).
✓ Assemble the relevant knowledge: -
o The circuit is composed of wire and gates.
o The four types of gates (AND, OR, NOT, XOR) with two input
terminals and one output terminal knowledge is collected.
✓ Decide on a vocabulary: -
o The functions, predicates and constants of the domain are
identified.
o Functions are used to refer the type of gate.
Type (x1) = XOR,
where x1 ---- Name of the gate and Type ----- function
o The same can be represented by either binary predicate (or)
individual type predicate.
Type (x1, XOR) – binary predicate
XOR (x1) – Individual type
o A gate or circuit can have one or more terminals. For x1, the
terminals are x1In1, x1In2 and x1 out1
Where x1 In1 ------ 1st input of gate x1
x1 In2 ----- 2nd input of gate x1
x1 out1 ----- output of gate x1
o Then the connectivity between the gates represented by the
predicate connected. (i.e.) connected (out(1, x1), In(1,x2)).
o Finally the possible values of the output terminal C1, as true or
false, represented as a signal with 1 or 0.
✓ Encode general knowledge of the domain:-
o This example needs only seven simple rules to describe
everything need to know about circuits
o If two terminals are connected, then they have the same signal:
▪ t Signal(t) = 1 Signal(t) = 0
Page
▪ 1≠0
o Connected is a commutative predicate
▪ g Type(g) = OR Signal(Out(1,g)) = 1 n
Signal(In(n,g)) = 1
Type(O1) = OR
Connected(Out(1,X1),In(1,X2)) Connected(In(1,C1),In(1,X1))
Connected(Out(1,X1),In(2,A2)) Connected(In(1,C1),In(1,A1))
Connected(Out(1,A2),In(1,O1)) Connected(In(2,C1),In(2,X1))
Connected(Out(1,A1),In(2,O1)) Connected(In(2,C1),In(2,A1))
Connected(Out(1,X2),Out(1,C1)) Connected(In(3,C1),In(2,X2))
Connected(Out(1,O1),Out(2,C1)) Connected(In(3,C1),In(1,A2))
o The answers are substitutions for the variables i1,i2 and i3 Such that
the resulting sentence is entailed by the knowledge base.
o What are the possible sets of values of all the terminals for the
adder circuit?
v α / SUBST( {v/g}, α)
24
Example:-
x likes (x, Icecream) is a sentence α.
Page
SUBST ({x/John}, α) is a substitution Ө = John
Likes (John, Icecream) – Inferred sentence
• Existential Elimination :- For any sentence α variable v, and constant symbol k that
does not appear elsewhere in the Knowledge base:
v α / SUBST( {v/k}, α)
Example:-
x Kill (x, Victim) – α
SUBST({x/Murderer, Victim}, α) where Ө = Murderer
Kill (Murderer, Victim) – Inferred Sentence
• Existential Introduction :- For any sentence α, variable v that does not occur in α, and
ground term g that does occur in α
α / v SUBST( {g/v}, α)
Example:-
Likes (John, Icecream) – α
x Likes (x, Icecream) – Inferred Sentence
• An application of inference rule is matching their premise patterns to the sentences in the
KB and then adding their conclusion patterns to the KB.
• Task: - For the given situation described in English, Convert it into its equivalent FOL
representation and prove that “West is a Criminal”.
• Situation: - The law says that it is a crime for an American to sell weapons to hostile nations.
The country Nono, an enemy of America, has some missiles, and all of its missiles were
sold to it by Colonel West, who is American.
• Solution: - The given description is splitted into sentences and is converted into its
corresponding FOL representation.
American(West)
✓ Nono, is a nation
Nation (Nono)
✓ Nono, an enemy of America
Enemy (Nono, America)
✓ America is nation
Nation (America)
✓ The above discussed inference processes are not directed towards solving any
particular problem: for this reason it is called a data-driven or data-directed
procedure.
✓ In this problem, no new inferences are possible because every sentence concluded
by forward chaining is already exist in the KB. Such a KB is called a fixed point of
the inference process.
✓ FOL-FC-ASK function is sound and complete.
✓ Every inference is an application of generalized modus ponens, which is sound.
✓ Then it is complete for definite clauses KB (i.e.) it answers every query whose
27
• For Example:-
P – Sells (x,M1, y)
Page
SUBST (Ө2, SUBST (Ө1, p))
SUBST (Ө2, SUBST (x/West, p)) i.e. (Ө1 = x/west)
SUBST ((y/Nono), (x/West, p)) i.e. (Ө2 = y/Nono)
Therefore p – Sells (West, M1, Nono)
• The following table shows the backward chaining algorithm,
• The following graph shows the proof tree to infer that west is a criminal,
• The process of finding all legal substitutions that make logical expressions look identical
and
• Unification is a "pattern matching" procedure that takes two atomic sentences, called
literals, as input, and returns "failure" if they do not match and a substitution list, Theta,
if they do match.
• Theta is called the most general unifier (mgu)
• All variables in the given two literals are implicitly universally quantified
• To make literals match, replace (universally-quantified) variables by terms
• The unification routine, UNIFY is to take two atomic sentences p and q and returns α
substitution that would make p and q look the same
UNIFY (p, q) = θ where SUBST (θ, p) = SUBST (θ, q)
θ = Unifier of two sentences
• For example:-
p – S1(x, x) q
– S1(y, z)
Assume θ = y
p – S1(y, y) – x/y (Substituting y for x)
q – S1(y, y) – z/y (Substituting y for z)
• In the above two sentences (p, q), the unifier of two sentences (i.e.) θ = y is substituted
in both the sentences, which derives a same predicate name, same number of arguments
and same argument names.
• Therefore the given two sentences are unified sentences.
• The function UNIFY will return its result as fail, for two different types of criteria’s
as follows,
✓ If the given two atomic sentences (p, q) are differs in its predicate name then
the UNIFY will return failure as a result
For Example: - p – hate (M, C), q – try (M, C)
✓ If the given two atomic sentences (p, q) are differs in its number of arguments
then the UNIFY will return failure as a result
For Example: - p – try (M, C), q – try (M, C, R)
31
• For Example: - The Query is Knows (John, x) whom does John Know?
Page
• Some answers to the above query can be found by finding all sentences in the KB that
unify with knows (John, x)
• Assume the KB has as follows,
Knows (John, John)
Knows (y, Leo)
Knows (y, Mother(y))
Knows (x, Elizabeth)
• The results of unification are as follows,
UNIFY (knows (john, x), knows (John, Jane)) = {x/Jane}
UNIFY (knows (john, x), knows (y, Leo)) = {x/Leo, y/John}
UNIFY (knows (john, x), knows (y, Mother(y)) = {y/John, x/Mother (John)}
UNIFY (knows (john, x), knows (x, Elizabeth)) = fail
• x cannot take both the values John and Elizabeth at the same time.
• Knows (x, Elizabeth) means “Everyone knows Elizabeth” from this we able to infer
that John knows Elizabeth.
• This can be avoided by using standardizing apart one of the two sentences being
unified (i.e.) renaming is done to avoid name clashes.
• For Example:-
UNIFY (Knows (john, x), knows (x1, Elizabeth)) = {x/Elizabeth, x1/John}
• UNIFY should return a substitution that makes the two arguments look the same, but
there may be a chance of more than one unifier.
• For Example:-
UNIFY (knows (john, x), knows (y, z)) = {y/John, x/z} or {y/John, x/John, z/John}
• The result of applying 1st unifier is knows (John, z) and the 2nd unifier is knows (John,
John).
• Here the first unifier result is more general than the second one, because it places less
restriction on the values of the variables.
• This indicates that every unifiable pair of expressions, a single MGU is exist until
renaming of variables.
• The following table shows the unification algorithm,
• The following are the steps to be done for unification of two sentences p and q is
given below,
✓ Recursively explore the two expressions simultaneously along with unifier
returns failure if two corresponding points in the structure do not match.
Therefore the time complexit y is O(n2) in the size of the expressions being
unified.
✓ When the variable is matched against a complex term, one must check,
whether the variable itself occurs, if it is true then returns failure (consistent
32
Employs (x, y)
2.10 Resolution:-
• Resolution is a complete inference procedure for first order logic
• Any sentence a entailed by KB can be derived with resolution
34
o Resolution inference rule – two disjunctions of any length, if one of disjunct in the
class (pj) unifies with the negation of the disjunct in the other class, then infer the
disjunction of all the disjuncts except for those two,
o Using disjunctions:- For literals pi and qi, where UNIFY (pj, ¬qk) = θ
o Using implications:- For atoms pi, qi, ri, si where UNIFY (pj, qk) = θ
• Resolution Proof:- A set of inference rules and resolution rules can be used to derive
a conclusion from the KB.
• Resolution with refutation (or) proof by contradiction (or) reduction and
absurdum:- One complete inference procedure using resolution is refutation. The idea
is to prove P, we assume P is false (i.e. add P to KB) and prove a contradiction, that
is the KB implies P.
(KB P False) (KB P)
• Example:
1. Prove that S(A) ts true from KB1 of CNF and INF representation using
✓ Resolution Proof
✓ Resolution with refutation
(a) Resolution Using INF representation:-
Given (KB1):-
1. P(w) Q(w)
2. True P(x) R(x)
3. Q(y) S(y)
4. R(z) S(z)
• The following diagram shows the proof that S(A) from KB1 using resolution
P(w) Q(w) Q(y) S(y)
{y/w}
(Step1 & Step3)
{w/x}
Step 2
True S(A)
• Therefore S(A) is true is proved using resolution technique for CNF representation.
• The following diagram shows the proof that S(A) from KB1 using resolution.
{w/x}
Step 2
S(A) S(A)
S(A)
37
Page
C. Resolution with refutation Proof using INF representation:-
Given (KB1):-
1. P(w) Q(w)
2. True P(x) R(x)
3. Q(y) S(y)
4. R(z) S(z)
• Resolution rule:- In this step transitive implication is applied,
,
• Substitution of one predicate in the other. (i.e.) P(x) S(x) is substituted in True
P(x) S(x) that is instead of P(x), S(x) is substituted.
• Substitution of one predicate in the other. (i.e.) R(x) S(x) is substituted in True
S(x) R(x) that is instead of R(x), S(x) is substituted, which derives True S(x)
S(x) is equivalent to True S(x)
• To prove using refutation, negation of given proof is added to the KB and derives a
contradiction, then the given statement is true otherwise it is false.
• Therefore in step 4, we assume S(A) False, derives a contradiction True False.
• Therefore S(A) is true is proved using refutation technique in INF representation.
• The following diagram shows the proof that S(A) from KB1 using resolution with
refutation in INF representation.
{w/x}
Step 2
• To prove using refutation, the negation of the given statement to be proved is added to
the KB and it derives a empty set, represents that the statement is True in the KB.
• Therefore S(A) is True is proved using resolution with refutation in CNF
representation.
• The following diagram shows the proof that S(A) from KB1 using resolution with
refutation in CNF representation.
{w/x}
Step 2
Negation
{ }
39
Page
2.10. 3 Resolution technique (From FOL Representation):-
• In the previous section we learned how to prove the given fact using two different types of
resolution techniques (Resolution proof, Resolution with refutation proof) from the given
KB representation (CNF, INF).
• Suppose if the KB is given as a English description, to prove a fact , then how to derive the
conclusion? What are the sequence of steps to be done? Are discussed one by one,
o The given KB description is converted into FOL Sentences
o FOL sentences are converted to INF (or) CNF representation without changing the
meaning of it (using conversion to normal form procedure)
o Apply one of the resolution technique (Resolution proof (or) Resolution with
refutation proof), to resolve the conflict.
o Derive the fact to be proved or declare it as a incomplete solution.
1. Eliminate Implications:-
Eliminate Implication by the corresponding disjunctions,
(i.e.) p q is the same as p q
2. Move inwards :-
Negations are allowed only on atoms in CNF and not at all in INF. Therefore eliminate
negations with, Demorgan’s laws, the quantifier equivalences and double negation.
Demorgans Law
( p q) becomes p q
( p q) becomes p q
Quantifier equivalences
xp becomes xp
xp becomes xp
Double Negation
p becomes p Double negation
3. Standardize variables:-
If the sentence consists of same variable name twice, change the name of one of the
variable. This avoids confusion later when we drop the quantifiers,
(i.e.) (xp(x)) (xQ(x)) is changed into (xp(x)) (yQ( y))
4. Move quantifiers left:-
The quantifiers in the middle of the sentence to be moved to the left, without changing
the meaning of the sentence
(i.e.) p xq becomes x p q , which is true because p here is guaranteed
not to contain x.
5. Skolimize:-
Negation Step b
~P ~Q P
Step a
~Q ~T Q
Step c
~T T
Step d
{}
• The negation of the given statements (R False) derives a contradiction (True False).
• Therefore it is proved that R is True (i.e. Taken assumption is wrong)
• The following diagram shows the proof of Resolution with refutation using INF.
P Q R P
(Step a & b)
T Q Q R
(Step c)
T R T
(Step d)
R R False
Negation
False
42
Page
• 2. For Example: - Convert the given sentences (KB2) into its equivalent FOL representation
and then convert it into its CNF and INF representation and solve the task using resolution
with refutation proof.
o Given KB2:-
▪ Marcus was a man
▪ Marcus was a Pompeian
▪ All pompeians were romans
▪ Caesar was a ruler
▪ All romans were either loyalto Caesar or hated him
▪ Everyone is loyal to someone
▪ People only try to assassinate rulers they are not loyal to.
▪ Marcus tried to assassinate Caesar
▪ All man are people
o Task: - Did Marcus hate Caesar?
o Solution:-
✓ FOL Representation:
1. Man (Marcus)
2. Pompeian (Marcus)
3. x Pompeian (x) Roman (x)
4. Ruler (Caesar)
5. x Roman (x) Loyalto (x, Caesar) Hate (x, Caesar)
6. x y Loyalto (x, y)
7. x y Person(x) Ruler(y) Trytoassassinate(x, y) Loyalto(x, y)
8. Trytoassassinate (Marcus, Caesar)
9. x Man (x) Person (x)
✓ INF Representation:
1. Man (Marcus)
2. Pompeian (Marcus)
3. Pompeian (x) Roman (x)
4. Ruler (Caesar)
5. Roman (x) Loyalto (x, Caesar) Hate (x, Caesar)
6. Loyalto (x, y)
7. Person(x) Ruler(y) Trytoassassinate(x, y) Loyalto(x, y)
8. Trytoassassinate (Marcus, Caesar)
9. Man (x) Person (x)
✓ CNF Representation :
1. Man (Marcus)
2. Pompeian (Marcus)
3. ~Pompeian (x) Roman (x)
4. Ruler (Caesar)
5. ~Roman (x) Loyalto (x, Caesar) Hate (x, Caesar)
6. Loyalto (x, y)
7. ~Person(x) ~Ruler(y) ~Trytoassassinate(x, y) ~Loyalto(x, y)
8. Trytoassassinate (Marcus, Caesar)
9. ~Man (x) Person (x)
43
Page
• To prove the given fact, we assumed the negation of it (i.e.) Hate(Marcus, Caesar) False and
using inference rules we derive a contradiction False, which means that the assumption must
be false, and Hate(Marcus, Caesar) is True.
• Therefore it is proved that Hate (Marcus, Caesar) is True using INF Representation.
• The following diagram shows the proof of Resolution with refutation using INF
representation.
10
Hate (Marcus, Caesar) Hate (Marcus, Caesar)
False
Negation
False
• To prove the given fact, we assumed that the negation of it (i.e.) ~ Hate (Marcus, Caesar) and
using inference rules, we derive a contradiction as empty set, which means that the
assumption must be false, and Hate (Marcus, Caesar) is true in the given KB.
• Therefore it is proved that Hate (Marcus, Caesar) is true using CNF representation.
• The following diagram shows the proof of Resolution with refutation using CNF
representation.
~Hate (Marcus, Caesar) ~Roman (x) Loyalto (x, Caesar) Hate (x, Caesar)
(Negation & 5) {x/Marcus}
7
~Man(x) Person (x) ~Person(Marcus) ~Ruler (Caesar)
~Trytoassassinate (Marcus, Caesar)
{x/Marcus}
9
{}
.10.4 Dealing with equality:-
• The unification algorithm is used to find a equality between variables with other terms (i.e.)
p(x) unifies with p(A), but p(A) and p(B) fails to unify, even if the sentence A=B in the KB.
• The unification does only a syntactic test based on the appearance of the argument terms, not
a true semantic test (meaning) based on the objects they represent.
• To solve this problem, one of the way is, the properties can be followed as,
1. x x=x - Reflexive
2. x, y x = y y = x - Symmetric
3. x, y, z x = y y = z x= z - Transitive
w = y x = z (F 2(w, x) = F 2( y, z))
• The other way to deal with equality is demodulation rule. For any terms x, y and z where
UNIFY (x, z) = , defined as :
x = y,(......z ..... )
(.....SUBST ( , y) .... )
• A more powerful rule named paramodulation deals with the case where we do not know
x = y , but we do know x = y p(x) .
• A strategy which is used to guide the search towards a proof of the resolution inference rule.
Different types of strategies are as follows,
✓ Unit Preferences:-
This strategy prefers a sentence with single literal, to produce a very short sentence
For Example:- P and P Q R derives the sentence Q R .
✓ Set of support:-
A subset of the sentence are identified (set of support) and resolution combines a set
of support with another sentence and adds the resolvent into the set off support, which
reduces the size of a sentence in the KB.
Disadvantage: - Bad choice for the set of support will make the algorithm incomplete.
46
Page
Advantage: - Goal directed proof trees are generated
✓ Input resolution:-
This strategy combines one of the input sentences (from the KB or the query)
with some other sentence.
For Example:- Resolution proof, Resolution with refutation proof.
Input resolution is complete for KB that are in Horn form, but incomplete in
the general case.
✓ Linear resolution:-
Two predicates are resolved (P and Q), if either P is in the original KB or if P is an
ancestor of Q in the proof tree.
✓ Subsumption:-
A strategy which eliminate all sentences that are more specific than the
existing sentence.
For example:- if P(x) is in the KB, then there is no sense in adding P(A) to
KB.
• Theorem provers use resolution or some other inference procedure to prove sentences in full
first order logic, often used for mathematical and scientific reasoning tasks.
Choice of writing sentences in different form Does not affects the execution order derives
with same meaning affects the execution order the same conclusion
• An example for theorem prover is: OTTER=> Organized Techniques for Theorem proving
and Effective Research, with particular attention to its control strategy.
• To prepare a problem for OTTER, the user must divide the knowledge into four parts;
1. SetOfSupport (SOS): A set of clauses, which defines the important facts about the
47
problem. Resolution step resolves the member of SOS with another axiom.
Page
2. Usable axioms: - A set of axioms that are outside the set of support, provides background
knowledge about the problem area. The boundary between SOS and the axiom is up to the
user’s judgement.
3. Rewrites (or) Demodulators :- A set of equations evaluated or reduced from left-to-right
order (i.e.) x + 0 = x in which x + 0 should be replaced by the term x.
4. A set of parameters and clauses that defines the control strategy that is,
a. Heuristic function :- to control the search
b. Filtering function :- eliminates some subgoals which are uninteresting
2.10.7 Execution:-
• Resolution takes place by combining the element of SOS with useful axiom, generally prefers
unit strategy.
• The process continuous until a reputation is found or there are no more clauses in the SOS.
• The following shows the algorithm of execution,
Algorithm:-
• Theorem prover can be build using prolog compiler as a base and a sound complete reasoned
of full first order logic is done using PTTP.
•
48
Prolog PTTP
Depth First Search Iterative deepening search
Not possible like a PTTP implementation Negated literals are allowed (i.e.) in the
implementation P, P can be derived using
two separate routines
Locking is not allowed Locking is allowed (i.e.) A clause with n atoms
is stored as n different rules. Example:-
A B X is equivalent to
B X A, X B A
Inference is not complete Inference is complete since refutation is
allowed
Unification is less efficient Unification is more eficient
Drawback of PTTP:-
• Each inference rule is used by the system both in its original form and contrapositive form
Example:- ( f (x, y) = f (a,b)) (x = a) ( y = b)
• Prolog proves that two f terms are equal, But PTTP would also generate the contrapositive
(x a) ( f (x, y) f (a, b)) ( y = b)
• This is a wasteful way to prove that any two terms x and a are different.