AI3391 Artificial intelligence session 27 inference and unification.pptx
1. AI3391 ARTIFICAL INTELLIGENCE
(II YEAR (III Sem))
Department of Artificial Intelligence and Data
Science
Session 27
by
Asst.Prof.M.Gokilavani
NIET
1/24/2024 Dpaertment of CSE ( AL & ML) 1
2. TEXTBOOK:
• Artificial Intelligence A modern Approach, Third Edition,
Stuart Russell and Peter Norvig, Pearson Education.
REFERENCES:
• Artificial Intelligence, 3rd Edn, E. Rich and K.Knight
(TMH).
• Artificial Intelligence, 3rd Edn, Patrick Henny Winston,
Pearson Education.
• Artificial Intelligence, Shivani Goel, Pearson Education.
• Artificial Intelligence and Expert Systems- Patterson,
Pearson Education.
1/24/2024 Dpaertment of CSE ( AL & ML) 2
3. Topics covered in session 27
• Logical Reasoning: Knowledge-Based Agents
• Propositional Logic
• Propositional Theorem Proving
• Effective Propositional Model Checking
• Agents Based on Propositional Logic
• First order logic
• Syntax and semantics
• Knowledge representation and engineering
• Inference and first order logic
• Forward and backward chaining
• Inference
1/24/2024 Dpaertment of CSE ( AL & ML) 3
4. Propositional vs. First-Order Inference
Propositional logic
• Propositional logic(PL) is a statement made by
propositions.
• It is a simple form of logic.
• Propositions are declarative statements which are
either true or false.
• PL is a technique often used in logical and
mathematical form.
• When we study PL, we usually start with formal
natural language arguments, but they can also be
expressed mathematically.
1/24/2024 4
Dpaertment of CSE ( AL & ML)
5. • Propositional logic is based on formal logic, deductive reason
and Boolean logic.
• We use symbolic variables to represent the logic. Often true
and false can be symbolized by 1 and 0.
• Propositional logic also consists of an object, relations or
function, and logical connectives.
1/24/2024 5
Dpaertment of CSE ( AL & ML)
6. First order logic
1/24/2024 6
Dpaertment of CSE ( AL & ML)
• First-order logic(FOL), Predicate logic or First-order
predicate logic is an extension to propositional logic.
• First-order logic expresses information about objects and
expresses relationships between those objects in a more
functional way in comparison to propositional logic.
• First-order logic is more concise than propositional logic.
• In First-order logic, the statements are divided into two
parts: the subject and the predicate.
• The predicate is not a proposition.
• It is neither true nor false.
• Predicates use variables and objects like people, colors,
numbers, letters or ideas.
• They can also represent relationships and functions
7. • Both syntax and semantics are important to first-
order logic.
• Symbols are the basic syntax of FOL and can be
written in shorthand.
• Syntax is the structure of the logical statements.
Semantics gives meaning to the statements.
Examples:
• Every man has a heart = ∀x man(x) → have (x,
heart).
• Some men are mean = ∃x: man(x) ∧ mean(x).
1/24/2024 7
Dpaertment of CSE ( AL & ML)
8. What is 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).
1/24/2024 8
Dpaertment of CSE ( AL & ML)
9. Example: Find the MGU for Unify{King(x), King(John)}
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.
• 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.
1/24/2024 9
Dpaertment of CSE ( AL & ML)
10. Example: Let's say there are two different
expressions, P(x, y), and P(a, f(z)).
In this example, we need to make both above
statements identical to each other.
For this, we will perform the substitution.
P(x, y)......... (i)
P(a, f(z))......... (ii)
• 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].
1/24/2024 10
Dpaertment of CSE ( AL & ML)
11. Conditions for Unification
Following are some basic 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.
1/24/2024 11
Dpaertment of CSE ( AL & ML)
13. Implementation of the Algorithm
• Step 1: Begin by making the substitute set empty.
Step 2: Unify atomic sentences in a recursive manner:
a. Check for expressions that are identical.
b. If one expression is a variable vΨi, and the other
is a term ti which does not contain variable vi, then:
i. Substitute ti / vi in the existing substitutions
ii. Add ti / vi to the substitution set list.
Iii. If both the expressions are functions, then
function name must be similar, and the number of
arguments must be the same in both the expression.
c. Find the most general unifier for each pair of the
following atomic statements (If exist).
1/24/2024 13
Dpaertment of CSE ( AL & ML)
14. Example 1
Find the MGU of {p(f(a), g(Y)) and p(X, X)}.
Sol: S0 => Here,
• Ψ1 = p(f(a), g(Y)), and
• Ψ2 = p(X, X)
SUBST θ = {f(a) / X}
• S1 => Ψ1 = p(f(a), g(Y)), and Ψ2 = p(f(a), f(a))
SUBST θ = {f(a) / g(y)},
Unification failed.
Unification is not possible for these expressions.
1/24/2024 14
Dpaertment of CSE ( AL & ML)
16. Example 3
Find the MGU of {p (X, X), and p (Z, f(Z))}
Sol: Here, Ψ1 = {p (X, X)
Ψ2 = p (Z, f(Z))
S0 => {p (X, X), p (Z, f(Z))}
SUBST θ= {X/Z}
S1 => {p (Z, Z), p (Z, f(Z))}
SUBST θ= {f(Z) / Z},
Unification Failed.
Therefore, unification is not possible for
these expressions.
1/24/2024 16
Dpaertment of CSE ( AL & ML)