Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Using Predicate Logic

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 86

Chapter 5

Using Predicate Logic


Knowledge Representation Techniques
• How this knowledge can be represented so that a machine can
make sense of it. One has to keep in mind that there are
numerous ways to achieve this, and no method is perfect and
has its own disadvantages.
Conti.
• Logical Representation
• It is the most basic form of representing knowledge to
machines where a well-defined syntax with proper rules is
used.
• This syntax needs to have no ambiguity in its
meaning and must deal with prepositions.
• Thus, this logical form of presentation acts as communication
rules and is why it can be best used when representing facts to
a machine.
• Logical representation can be categorised into mainly two
logics:
 Propositional Logics
 Predicate logics
Conti.
Logical Representation can be of two types-
 Propositional Logic: This type of logical representation is also known as
propositional calculus or statement logic. This works in a Boolean, i.e., True or
False method.
e.g. the sun rises from west. (false preposition)
it is sunday.
5 is a prime number.
3+3 = 7. (false preposition)
 First-order Logic: This type of logical representation is also known as the First
Order Predicate Calculus Logic (FOPL). This logical representation represents the
objects in quantifiers and predicates and is an advanced version of propositional
logic.
Prdicates like relation, constant, variable, function, connectives(and, or, not etc.),
equality etc.
e.g. some humans are intelligent.
Conti.
Logical Representation
Advantages:
 Logical representation helps to perform logical reasoning
 This representation is the basis for the programming languages.
Disadvantages:
 Logical representations have some restrictions
and are challenging to work with
 This technique may not be very natural and inference may
not be very efficient.
Conti.
Semantic Networks
 In this form, a graphical representation conveys how the objects
are connected and are often used with a data network.
 The Semantic networks consist of node/block (the objects)
and arcs/edges (the connections) that explain how the objects
are connected. This form of representation is also known as an
alternative to the FOPL form of representation.
 The relationships found in the Semantic Networks can be of two
types – IS-A and instance (KIND-OF). This form of
representation is more natural than logical. It is simple to
understand however suffers from being computationally
expensive and do not have the equivalent of quantifiers found
in the logical representation.
Conti.
• A knowledge representation that represents relationships
between concepts and ideas in the form of a network. It is
generally shown as a graph where concepts/ideas are “nodes”
and relationships are “edges” or arrows
Conti.
Advantages:
 Semantic networks are a natural representation of knowledge
 It conveys meaning in a transparent manner
 These networks are simple and easy to understand
Disadvantages:
 Semantic networks takes more computational time at runtime
 These are inadequate as they do not have any equivalent
quantifiers.
 These networks are not intelligent and depends
on the creator of the system.
Conti.
Frame Representation
• It is a collection of attributes and values linked to it. This AI-
specific data structure uses slots and fillers (i.e., slot values,
which can be of any data type and shape).
• It has a similar concept to how information is stored in a typical
DBMS. These slots and fillers form a structure – a frame. The
slots here have the name (attributes), and knowledge related
to it is stored in the fillers.
• The biggest advantage of this form of representation is that due
to its structure, similar data can be combined in groups as
frame representation can divide the knowledge in structures
and then further into sub-structures. Also, being like any typical
data structure can be understood, visualized, manipulated
easily, and typical concepts such as adding, removing, deleting
slots can be done effortlessly.
Conti.
• E.g.

Slots Fillers Slots Fillers

Name Peter Title Artificial


Intelligence
Profession Doctor Genr Computer Science
e
Age 25
Auth Peter Norvig
Marital Status Single or
Editio Third Edition
Weight 78 n
Year 1996
Page 1152
Conti.
Advantages:
 It makes the programming easier by grouping the related data.
 Frame representation is easy to understand and visualize.
 It is very easy to add slots for new attributes and relations
also it is easy to include default data and search for missing
values.
Disadvantages:
 In frame system inference, the mechanism can not be easily
processed.
 The inference mechanism can not be smoothly
processed by frame representation.
 It is very generalized approach.
Conti.
Production Rules
• It is among the most common ways in which knowledge is
represented in AI systems. In the simplest form, it can be
understood as a simple if-else rule-based system and, in a way,
is the combination of Propositional and FOPL logics.
• This system comprises a set of production rules, rule applier,
working memory, and a recognize act cycle. For every input,
conditions are checked from the set of a production rule, and
upon finding a suitable rule, an action is committed. This cycle
of selecting the rule based on some conditions and
consequently acting to solve the problem is known as a
recognition and act cycle, which takes place for every input.
Conti.
Advantages:
 Expressed in natural language
 Production rules are highly modular and can
be easily removed or modified.
Disadvantages:
 It does not exhibit any learning capabilities and does not
store the result of the problem for future uses.
 During the execution of program many rules may
be active. Thus rule based
production systems are inefficient.
Logical Representation-
Propositional Logic
• Propositional Logic- One of the simplest method for
representing knowledge
• A statement can be defined as a declarative sentence, or part of
a sentence, that is capable of having a truth-value, such as being
true or false. So Propositions can be either true or false, but it
cannot be both.
e.g.
• Paris is the capital of France.
• Everyone born on Monday has purple hair.
• Sometimes, a statement can contain one or more other
statements as parts.
Logical Representation-
Propositional Logic
Atomic Proposition: Atomic propositions are the simple propositions. It consists
of a single proposition symbol. These are the sentences which must be
either true or false.
e.g.
• 2+2 is 4, it is an atomic proposition as it is a true fact.
• "The Sun is cold" is also a proposition as it is a false fact.
Compound Proposition: Compound propositions are constructed by combining
simpler or atomic propositions, using parenthesis and logical connectives.
• e.g.
• "It is raining today, and street is wet."
• "Ankit is a doctor, and his clinic is in Mumbai."
• “Paris is the capital of France and Paris has a population of over two
million."
Logical Representation-
Propositional Logic
• Propositional logic is also called Boolean logic as it works on 0
and 1.
• In propositional logic, we use symbolic variables to represent
the logic, and we can use any symbol for a representing a
proposition, such A, B, C, P, Q, R, etc.
• Propositional logic consists of an object and logical
connectives. These connectives are also called logical
operators.
• The propositions and connectives are the basic elements of
the propositional logic.
• Connectives can be said as a logical operator which connects
two sentences.
Logical Connectives
• Logical connectives are used to connect two simpler propositions or
representing a sentence logically. We can create compound propositions with
the help of logical connectives. There are mainly five connectives, which are
given as follows:
Negation: A sentence such as ¬P is called negation of P. A literal can be either
Positive literal or negative literal.

Conjunction: A sentence which has 𝖠 connective such as, P 𝖠Q is called a


conjunction.
Example: Rohan is intelligent and hardworking. It can be written as,
P= Rohan is intelligent, Q= Rohan is hardworking. → P 𝖠Q.
Disjunction: A sentence which has ∨ connective, such as P ∨ Q. is called
disjunction, where P and Q are the propositions.
Example: Ritika is a doctor or Engineer
P= Ritika is Doctor, Q= Ritika is Engineer → P ∨ Q.
Logical Connectives
Implication: A sentence such as P → Q, is called an
implication. Implications are also known as if-then rules.
It can be represented as
Example: If it is raining, then the street is wet.
P= It is raining, Q= Street is wet :- P → Q
Biconditional: A sentence such as P⇔Q is a Biconditional
sentence,
Example: If I am breathing, then I am alive
P= I am breathing, Q= I am alive, it can be represented as P ⇔
Q.
Logical Connectives

• Truth
Table
Logical Connectives
• Truth
Table
Propositional Logic
• For propositional logic, a row in the truth table is
one interpretation
Logical Connectives
• Truth table with three
propositions:

• Logical
equivalence:
Example
• Translation
Example
• Translation
Formalizing English Sentences
• Let’s consider a propositional language where p means ”Priti is happy”, q
means ” Priti paints a picture”, and r means ”Renzo is happy”.
• Formalize the following sentences:
 ”if Priti is happy and paints a picture then Renzo isn’t happy”
• p 𝖠 q → ¬r
 ”if Priti is happy, then she paints a picture”
• p→q
 ” Priti is happy only if she paints a picture”
• p⇔q
Formalizing English Sentences
• Let A= ” Angelo comes to the party”,
B= ”Bruno comes to the party”,
C= ”Carlo comes to the party”, and
D =”Davide comes to the party”.
1. ”If Davide comes to the party then Bruno and Carlo come too”
2. ”Carlo comes to the party only if Angelo and Bruno do not come”
3. ”If Davide comesto the party, then, if Carlo doesn’t come then Angelo
comes”
4. ”Carlo comes to the party provided that Davide doesn’t come, but, if
Davide comes, then Bruno doesn’t come”
5. ”A necessary condition for Angelo coming to the party, is that, if Bruno
and Carlo aren’t coming, Davide comes”
6. ”Angelo, Bruno and Carlo come to the party if and only if Davide doesn’t
come, but, if neither Angelo nor Bruno come, then Davide comes only if
Carlo comes”
Formalizing English Sentences
• Let A = ”Angelo comes to the party”,
B = ”Bruno comes to the party”,
C = ”Carlo comes to the party”, and
D = ”Davide comes to the party”.
1. ”If Davide comes to the party then Bruno and Carlo come too”
D→B𝖠C
2. ”Carlo comes to the party only if Angelo and Bruno do not come”
C → ¬A 𝖠 ¬B
3. ”If Davide comes to the party, then, if Carlo doesn’t come then Angelo
comes”
D → (¬C → A)
Formalizing English Sentences
• Let A = ”Angelo comes to the party”,
B = ”Bruno comes to the party”,
C = ”Carlo comes to the party”, and
D = ”Davide comes to the party”.
4. ”Carlo comes to the party provided that Davide doesn’t come, but, if Davide
comes, then Bruno doesn’t come”
(C → ¬D) 𝖠 (D → ¬B)
5. ”A necessary condition for Angelo coming to the party, is that, if Bruno
and Carlo aren’t coming, Davide comes”
A → (¬B 𝖠 ¬C → D)
6. ”Angelo, Bruno and Carlo come to the party if and only if Davide doesn’t
come, but, if neither Angelo nor Bruno come, then Davide comes only if
Carlo comes”
(A 𝖠 B 𝖠 C ↔ ¬D) 𝖠 (¬A 𝖠 ¬B → (D → C))
Contradiction and Tautology
• Some composite sentences may always (under any
interpretation) evaluate to a single truth value:
Rules of Inference
• Inference: In artificial intelligence, we need intelligent
computers which can create new logic from old logic or by
evidence, so generating the conclusions from evidence and
facts is termed as Inference.
• Inference rules are the templates for generating valid
arguments. Inference rules are applied to derive proofs in AI,
and the proof is a sequence of the conclusion that leads to the
desired goal.
Following are some terminologies related to inference rules:
• Implication: It is one of the logical connectives which can be
represented as P → Q. It is a Boolean expression.
• Converse: The converse of implication, which means the right-
hand side proposition goes to the left-hand side and vice-versa.
It can be written as Q → P.
Rules of Inference
• Contrapositive: The negation of converse is termed as
contrapositive, and it can be represented as ¬ Q → ¬ P.
• Inverse: The negation of implication is called inverse. It can be
represented as
¬ P → ¬ Q.
From the above term some of the compound statements are
equivalent to each other, which we can prove using truth table:
Types of Inference Rules
• Modus Ponens: if P and P → Q is true, then we can infer that Q will be
true.
• Example
• Statement-1: "If I am sleepy then I go to bed" ==>
P→ Q Statement-2: "I am sleepy" ==> P
• Conclusion: "I go to bed." ==> Q.
• Hence, we can say that, if P→ Q is true and P is
true then Q will be true.
• Proof by Truth table:
Types of Inference Rules
• Modus Tollens: The Modus Tollens rule state that if P→ Q is
true and ¬ Q is true, then ¬ P will also true.

• Statement-1: "If I am sleepy then I go to


bed" ==> P→ Q Statement-2: "I do not go
to the bed."==> ~Q Statement-3: Which
infers that "I am not sleepy" => ~P
• Proof by Truth table:
Types of Inference Rules
• Hypothetical Syllogism: The Hypothetical Syllogism rule state that if P→R is
true whenever P→Q is true, and Q→R is true.
Statement-1: If you have my home key then you can unlock
my home. P→Q
Statement-2: If you can unlock my home then you can take my
money. Q→R
Conclusion: If you have my home key then you can take my
money. P→R
• Proof by Truth table:
Types of Inference Rules
• Disjunctive Syllogism: The Disjunctive syllogism rule state
that if P∨Q is true, and ¬P is true, then Q will be true.
• Example
• Statement-1: Today is Sunday or
Monday. ==>P∨Q Statement-2:
Today is not Sunday. ==> ¬P
Conclusion: Today is Monday. ==> Q
• Proof by Truth table:
Types of Inference Rules
• Addition: The Addition rule is one the common
inference rule, and it states that If P is true, then
P∨Q will be true.
• Example:
• Statement: I have a vanilla ice-cream. ==> P
• Statement-2: I have Chocolate ice-cream.
• Conclusion: I have vanilla or chocolate ice-cream. ==> (P∨Q)
• Proof by Truth table:
Types of Inference Rules
• Simplification: The simplification rule state that if P𝖠Q is true,
then Q or P will also be true. It can be represented as:

• Resolution: The Resolution rule state that if P∨Q and ¬ P𝖠R is


true, then Q∨R will also be true. It can be represented as
Logical Representation-
Propositional Logic
• In order to draw conclusions, facts are represented in a more
convenient way as,
1. Marcus is a man.
 man(Marcus)
2. Plato is a man.
 man(Plato)
3. All men are mortal.
 mortal(men)
• Caesar was a ruler
 ruler(Caesar )
Limitations of Propositional logic
• We cannot represent relations like ALL, some, or none with
propositional logic.
E.g.
 All the girls are intelligent.
 Some apples are sweet.
• Propositional logic has limited expressive power.
• In propositional logic, we cannot describe
statements in terms of their
properties or logical relationships.
Limitations of Propositional Logic
• Propositional logic cannot express general-purpose
knowledge briefly
• Difficult to identify specific individuals (Mary, among 3)
• Generalizations, patterns, regularities difficult to represent
(all triangles have 3 sides)
• Can’t directly talk about properties of individuals or
relations between individuals (e.g., “Bill is tall”)
Propositional Logic VS
Predicate Logic
Propositional Logic Predicate Logic
Propositional logic is the logic that deals Predicate logic is an expression consisting
with a collection of declarative statements of variables with a specified domain. It
which have a truth value, true or false. consists of objects, relations and functions
between the objects.

It is the basic and most widely used logic. It is an extension of propositional


Also known as logic covering
Boolean logic. predicates and quantification.

A proposition has a specific truth value, A predicate’s truth value depends on


either true or false. the variables’ value.
Predicate logic helps analyze the scope of
Scope analysis is not done in propositional the subject over the predicate.
logic.

Propositions are combined with Logical


Operators or Logical Connectives like Predicate Logic adds by introducing
Negation(¬), Disjunction(∨), quantifiers to the existing proposition.
Conjunction(𝖠), Exclusive OR(⊕),
Implication(⇒), Bi- Conditional or Double
Implication(⇔).
Predicate Logic / First order Logic
First-Order Logic
• In propositional logic, we can only represent the facts, which are
either true or false. The propositional logic has very limited
expressive power. Consider the following sentence, which we
cannot represent using PL logic.
• "Some humans are intelligent"
• To represent the above statements, PL logic is not sufficient, so
we required some more powerful logic, such as first-order logic.
• First-order logic is an extension to propositional logic.
• FOL is sufficiently expressive to represent the natural language
statements in a concise way.
First-Order Predicate Calculus
• First-order logic (like natural language) does not only assume
that the world contains facts like propositional logic but also
assumes the following things in the world:
• First-Order Logic includes:
– Objects: peoples, numbers, places, ideas (atoms)
– Relations: relationships between objects (predicates, T/F
value)
• Example: father(fred, mary)
• Properties: properties of atoms (predicates, T/F
value) Example: red(ball)
– Functions: father-of(mary), next(3), (any value in
range)
• Constant: function with no parameters, MARY
Logics in General
• Ontological Commitment:
– What exists in the world — TRUTH
– PL : facts hold or do not hold.
– FOL : objects with relations between them that hold or
do not hold
• Epistemological Commitment:
– What an agent believes about facts — BELIEF
Syntax of FOL: Basic elements
• Constant Symbols:
– Stand for objects
– e.g., KingJohn, 2, UCI,...

• Predicate Symbols
– Stand for relations
– E.g., Brother(Richard, John),
greater_than(3,2)...

• Function Symbols
– Stand for functions
– E.g., Sqrt(3), LeftLegOf(John),...
Syntax of FOL: Basic elements
• Constants (KingJohn, 2, UCI,...)
• Predicates (Brother, >,... Sqrt)
• Functions (LeftLegOf,...)
• Variables (x, y, a, b,...)
• Connectives (, , , , )
• Equality (=)
• Quantifiers (, )
Free and Bound Variables
• The quantifiers interact with variables which appear in a
suitable way. There are two types of variables in First-order
logic:

Free Variable: A variable is said to be a free variable in


a formula if it occurs outside the scope of the quantifier.
e.g. ∀x ∃(y): [P (x, y, z)], where z is a free variable.

Bound Variable: A variable is said to be a bound variable in


a formula if it occurs within the scope of the quantifier.
e.g.∀x ∀y: [A (x) V B( y)], here x and y are the bound
variables.
Syntax: First-Order Logic
• Atomic sentences:
• Atomic sentences are the most basic sentences of first-order
logic. These sentences are formed from a predicate symbol
followed by a parenthesis with a sequence of terms.
• We can represent atomic sentences as
Predicate(term1,term2,......, term n).
Example: Chinky is a cat: => cat (Chinky).
• Complex Sentences:
• Complex sentences are made by combining atomic
sentences using connectives.
Syntax: First-Order Logic
• First-order logic statements can be divided into two parts:
• Subject: Subject is the main part of the statement.
• Predicate: A predicate can be defined as a relation, which
binds two atoms together in a statement.
A predicate is a property that is affirmed or denied about
the subject (in logic, we say “variable” or “argument”) of a
statement
e.g. "x is an integer.", it consists of two parts, the first part x
is the subject of the statement and second part "is an
integer," is known as a predicate.
“x is greater than 3”
x |subject is greater than 3 | predicate
Syntax: First-Order Logic
 We introduce a (functional) symbol for the predicate, and put
the subject as an argument (to the functional symbol): P(x)
 Examples:
• Father(x): unary predicate
• Brother(x,y): binary predicate
• Sum(x,y,z): ternary predicate
• P(x,y,z,t): n-ary predicate
Syntax: First-Order Logic
• Quantifiers in First-order logic
• A predicate becomes a proposition when we assign it fixed
values. However, another way to make a predicate into a
proposition is to quantify it. That is, the predicate is true (or
false) for all possible values in the universe of discourse or
for some value(s) in the universe of discourse
• These are the symbols that permit to determine or identify
the range and scope of the variable in the logical
expression. There are two types of quantifier:
– Universal Quantifier, (for all, everyone, everything)
– Existential quantifier, (for some, at least one).
Syntax: First-Order Logic
• Universal Quantifier
• Universal quantifier is a symbol of logical representation,
which specifies that the statement within its range is true for
everything or every instance of a particular thing.
• The Universal quantifier is represented by a symbol ∀,
which resembles an inverted A.
• If x is a variable, then ∀x is read as:
– For all x
– For each x
– For every x.
• E.g. All man drink coffee. ∀x man(x) → drink (x, coffee).
Syntax: First-Order Logic
• Existential Quantifier
• Existential quantifiers are the type of quantifiers, which
express that the statement within its scope is true for at
least one instance of something.
• It is denoted by the logical operator ∃, When it is used
with a predicate variable then it is called as an existential
quantifier.
• If x is a variable, then existential quantifier will be ∃x or
∃(x). And it will be read as:
– There exists a 'x.'
– For some 'x.'
– For at least one 'x.'
• E.g. Some boys are intelligent. ∃x: boys(x) 𝖠 intelligent(x)
Syntax: First-Order Logic
Well Formed Formula (wff):
• A well-formed formula is obtained by composing atoms
with logical connectives and quantifiers. Therefore, a well-
formed formula is a predicate with the following properties:
 All atomic formulas (atoms) are well-formed formulas.
 Combines using propositional connectives such a
conjunction, disjunction and negation.
 If x is a variable and F is a well formed formula function, then
both quantifiers are well formed formulas.
 A well-formed formula (wff) is a sentence containing no
“free” variables. That is, all variables are “bound” by universal
or existential quantifiers.
Syntax: First-Order Logic
• The Syntactic Rules (Individual terms are just the individual
constants and individual variables)
 If P is an n-place predicate, and t1, t2, …, tn are terms,
then P(t1, t2, …, tn) is a wff
 If ϕ and ψ are wff, then ¬ϕ, (ϕ 𝖠 ψ), (ϕ ∨ ψ), (ϕ → ψ), (ϕ
↔ ψ) are wffs
 If ϕ is a wff and x is an individual variable, then ∀x ϕ and ∃x
ϕ are wffs
 Nothing else is a wff
Syntax: First-Order Logic
• Well Formed Formula: A well-formed formula (wff) is a
sentence containing no “free” variables. That is, all variables are
“bound” by universal or existential quantifiers.
• Quantifiers
 Universal quantification :- (∀x)P(x) means that P holds
for all values of x in the domain associated with that
variable
E.g., (∀x) dolphin(x) → mammal(x)
 Existential quantification :- (∃ x)P(x) means that P holds
for some value of x in the domain associated with that
variable
E.g., (∃x) mammal(x) 𝖠 lays-eggs(x)
Syntax: First-Order Logic
• Properties of Quantifiers:
 In universal quantifier, ∀x∀y is similar to ∀y∀x.
 In Existential quantifier, ∃x∃y is similar to ∃y∃x.
∃x∀y is not similar
to ∀y∃x. Why?
Example:
• 1) ∀x∃y: For
every x there
exists a y (such
that...)
Everyone is married to someone (ie. For every person
there exists a person to whom he/she is married)
• 2) ∃y∀x: There exists a y (such that) for every x...
Syntax: First-Order Logic
• Some Predicate Calculus Equivalence
Examples
• No human enjoys golf
 x [ H u m a n ( x )   E n jo y s ( x ,
G o lf )
• Some professor that is not a historian writes programs
 x [ P r o fe s s o r ( x )   H is to r ia n ( x ) 
W r ite s ( x , P r o g r a m s ) ]
• All birds fly.
∀x bird(x) →fly(x).
• Every man respects his parent.
∀x man(x) → respects (x, parent).
• Some boys play cricket.
∃x boys(x) ^ play(x, cricket).
• Not all students like both Mathematics and Science.
¬∀ (x) * student(x) → like(x, Mathematics) 𝖠 like(x,
Science)].
Unification
• Unification is a process of making two different logical atomic
expressions identical by finding a substitution. Unification
depends on the substitution process.
• It takes two literals as input and makes them identical using
substitution.
• Let Ψ1 and Ψ2 be two atomic sentences and 𝜎 be a unifier
such that, Ψ1𝜎
= Ψ2𝜎, then it can be expressed as UNIFY(Ψ1, Ψ2).
• Example: Let Ψ1 = King(x), Ψ2 = King(John),
• Substitution θ = {John/x} is a unifier for these atoms and
applying this substitution, and both expressions will be
identical.
Unification
• The UNIFY algorithm is used for unification,
which takes two atomic sentences and returns a
unifier for those sentences (If any exist).
• Unification is a key component of all first-order inference
algorithms.
• It returns fail if the expressions do not match with each other.
• The substitution variables are called Most General Unifier or
MGU.
 E.g. Let's say there are two different expressions, P(x, y), and
P(a, f(z)).
• Substitute x with a, and y with f(z) in the first expression,
and it will be represented as a/x and f(z)/y.
• With both the substitutions, the first expression will be
identical to the second expression and the substitution set will
be: [a/x, f(z)/y].
Unification
• Conditions for Unification:
 Predicate symbol must be same, atoms or expression
with different predicate symbol can never be unified.
 Number of Arguments in both expressions must be
identical.
 Unification will fail if there are two similar variables present in
the same expression.
Unification Algorithm
1. Initial predicate symbols must match.
2. For each pair of predicate arguments:
 different constants cannot match.
 a variable may be replaced by a constant.
 a variable may be replaced by another variable.
 a variable may be replaced by a function as long as the
function does not contain an instance of the variable.
• When attempting to match 2 literals, all substitutions must
be made to the entire literal.
• There may be many substitutions that unify 2 literals, the
most general unifier is always desired.
Unification Examples
• P(x) and P(y): substitution = (x/y) (“substitute x for y”)
• P(x,f(y)) and P(Joe,z):(Joe/x, f(y)/z)
• P(x) V Q(Jane) and P(Bill) V Q(y): Bill/x, Jane/y)
• Man(Marcus) and ¬Man(spot) ((Not unified)
• Man(Marcus) and Man(Marcus, X) (Not unified)
• Man(Marcus) and Man(X) (X is substitute to Marcus so unified)
• Man(hate(X,Y)) and Man(hate(Marcus, spot))
(Marcus/X and spot/Y)
Normal Forms
• Other approaches to inference use syntactic operations on
sentences, often expressed in standardized forms
• Conjunctive Normal Form (CNF)
Conjunction of disjunctions of literals (conjunction of
clauses) e.g. (A v –B) ^ (B v –C v –D)
• Disjunctive Normal Form (DNF)
disjunction of conjunctions of literals (disjunction of
terms)
e.g. (A ^ B) v (A ^ -C) v (A ^ -D) v (-B ^ -C) v (-B ^ -D)
• Horn Form (restricted)
conjunction of Horn clauses (clauses with <= 1 positive
literal) For example, (A v –B) ^ (B v –C v –D)
Often written as a set of
implications: B -> A and (C
^ D) -> B
Convert first-order logic expressions to
normal form
• Why CNF (Conjunctive Normal Form)?
 To make our representation simple.
 In wff, our representation of fact is very complicated.
 In CNF form, simplicity should be there, embedding should
not be there and all quantifiers should not be there.
Example: All Romans who know Markus either hate Ceaser or
think that any one who hates anyone is crazy.
 x: [ roman(x) ^ know(x , Markus) ] -> [hate(x, ceaser) V (  y: ∃
z: hate(y,z)
-> thinkcrazy(x,y) ]
Convert first-order logic expressions to
normal form
• Rules to convert wff to CNF
Step-1: Eliminate biconditionals and
implications:
• Eliminate ⇔, replacing α ⇔ β with (α ⇒ β) 𝖠
(β ⇒ α).
• Eliminate ⇒, replacing α ⇒ β with ¬α ∨ β.
Step-2: Move ¬ inwards:
• ¬(∀ x p) ≡ ∃ x ¬p,
• ¬(∃ x p) ≡ ∀ x ¬p,
• ¬(α ∨ β) ≡ ¬α 𝖠 ¬β,
• ¬(α 𝖠 β) ≡ ¬α ∨ ¬β,
• ¬¬α ≡ α.
Convert first-order logic expressions to
normal form
• Rules to convert wff to CNF
Step-3: Standardize variables apart by renaming them: each
quantifier should use a different variable.
Step-4. Skolemize: each existential variable is replaced by a
Skolem constant or Skolem function of the enclosing universally
quantified variables.
•For instance, ∃x Rich(x) becomes Rich(G1) where G1 is a new
Skolem constant.
• “Everyone has a heart” ∀ x Person(x) ⇒ ∃ y Heart(y) 𝖠 Has(x,
y) becomes
∀ x Person(x) ⇒ Heart(H(x)) 𝖠 Has(x, H(x)), where H is a new
symbol (Skolem function).
Convert first-order logic expressions to
normal form
• Rules to convert wff to CNF
Step-5: Convert to prenex form by moving all universal
quantifiers to the beginning of the wff.
 wff in prenex form = Prefix (string of quantifiers) + Matrix
(quantifier-free formula)
Step-6: Drop universal quantifiers
• For instance, ∀ x Person(x) becomes Person(x).
Step-7. Distribute 𝖠 over ∨: Use distributive laws and
equivalence rules of propositional logic to transform the matrix to
CNF.
• (α 𝖠 β) ∨ γ ≡ (α ∨ γ) 𝖠 (β ∨ γ).
Skolem functions
• ∃ y President(y)
• We replace y with a new function func:
• President(func())
•func is called a
skolem function.
Example:
" ∀ x ∃ y Father(y,x)
create a new function named foo and replace y with the
function. " ∀ x Father(foo(x),x)
Convert first-order logic expressions to
normal form
• Example
∀ x: (¬ literate(x) -> (¬write(x) ^ (¬ ∃y: (read(x,y) ^ book(y)))
 Eliminate implications ⇔⇔, ⇒
∀ x: literate(x) V (¬write(x) ^ ∀y: ¬(read(x,y) ^ book(y))
 Reduce scope of negations:
∀ x: literate(x) V (¬write(x) ^ ∀y: ¬read(x,y) V ¬book(y))
• Standardize variables
skip this step
 Prenex form:
∀ x: ∀y: literate(x) V (¬write(x)) ^ (¬read(x,y) V ¬book(y))
Convert first-order logic expressions to
normal
 Drop universal quantifiers
form
literate(x) V (¬write(x)) ^ (¬read(x,y) V ¬book(y))
• Conjuction and disjunction
A V (B ^ (C VD)) = (A V B) ^ (A V (C V D))
where (C V D) = X
(literate(x) V ¬write(x)) ^ (literate (x) V (¬read(x,y) V ¬book(y)))
Here, A ^ B so A and B both are considered as separate facts.
i) literate(x) V ¬write(x)
ii) literate (x) V (¬read(x,y) V ¬book(y))
Resolution
 Resolution is a procedure to prove a statement.
• Steps for Resolution:
 Conversion of facts into first-order logic.
 Convert FOL statements into CNF
 Negate the statement which needs to prove (proof by
contradiction)
 Draw resolution graph (unification). (From Knowledge base find
out fact/term as negative meaning so both will be elemented)
• Resolvent: From two parent clauses which was
derived is called as resolvent.
Resolution
 Example
• Marcus was a man
• Marcus was a Pompeian
• All Pompeians were Romans
• Caesar was a ruler.
• All Romans were either loyal to Caesar or hated
him.
• Everyone is loyal to someone.
• Men only try to assassinate rulers they are not
loyal to.
• Marcus tried to assassinate Caesar
Knowledge Base in First Order Logic
Knowledge Base in CNF

• Tryassassinate(Marcus
• ,Caesar)
Knowledge Base in CNF
 Query: Does Marcus hate Caesar?
• Negation of Query ¬Hate(Marcus, Caesar)
Resolution
 Does Marcus hate
Caesar?

• So hate(Markus,
ceaser) is true.
Representing Instance and ISA Relationships
• Specific attributes instance and isa play an important role particularly
in a useful form of reasoning called property inheritance.
• The predicates instance and isa explicitly captured the relationships
they used to express, namely class membership and class inclusion.
Representing Instance and ISA Relationships
• The first part of the figure contains, class membership
represented with unary predicates (such as Roman), each of
which corresponds to a class.
• Asserting that P(x) is true is equivalent to asserting that x is
an instance (or element) of P.
• The second part of the figure contains
representations that use the instance predicate explicitly.
• The predicate instance is a binary one, whose first argument is
an object and whose second argument is a class to which the
object belongs.
• But these representations do not use an explicit isa predicate.
• Instead, subclass relationships, such as that between
Pompeians and Romans, described as shown in sentence 3.
Representing Instance and ISA Relationships
• The implication rule states that if an object is an instance of the
subclass Pompeian then it is an instance of the superclass
Roman.
• The third part contains representations that use both the
instance and isa predicates explicitly.
• The use of the isa predicate simplifies the representation of
sentence 3, but it requires that one additional axiom (shown
here as number 6) be provided.
Computable Functions and Predicates
• To express simple facts, such as the following greater-than and
less-than relationships:
• gt(1,O) It(0,1) gt(2,1) It(1,2) gt(3,2) It( 2,3)
• It is often also useful to have computable functions as well as
computable predicates.
• Thus we might want to be able to evaluate the truth of gt(2 +
3,1)
• To do so requires that we first compute the value
of the plus function given the arguments 2 and 3,
and then send the arguments 5 and 1 to gt.
Computable Functions and Predicates
• Consider the following set of facts, again involving
Marcus:
Computable Functions and Predicates
• So, Now suppose we want to answer the question “Is Marcus
alive?”
• The statements suggested here, there may be two ways of
deducing an answer.
• Either we can show that Marcus is dead because he was killed
by the volcano or we can show that he must be dead because
he would otherwise be more than 150 years old, which we
know is not possible.
• Also, As soon as we attempt to follow either of those paths
rigorously, however, we discover, just as we did in the last
example, that we need some additional knowledge. For
example, our statements talk about dying, but they say nothing
that relates to being alive, which is what the question is asking.
Computable Functions and Predicates
• So we add the following facts:

You might also like