0% found this document useful (0 votes)
19 views24 pages

Inference in FOL-Part A

Uploaded by

salehaalsaleh602
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views24 pages

Inference in FOL-Part A

Uploaded by

salehaalsaleh602
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Inference in First-Order

Logic
CHAPTER 9

1
Inference in First-Order Logic
➢Is used to deduce new facts or sentences from existing sentences
➢Inference in first-order logic can be achieved using:
➢ Forward chaining
➢ Backward chaining
➢ Resolution
➢ Unification
➢ Proofs
➢ Clausal form
➢ Resolution as search

2
Substitution
➢ Substitution is a fundamental operation performed on terms and formulas.
➢ It occurs in all inference systems in first-order logic.
➢If we write SUBST(θ,P) and θ={v/g}, so it refers to substitute a constant “g" in place of variable
“v“ in predict P.

3
Universal Instantiation (UI)
universal elimination
➢ Every instantiation of a universally quantified sentence is entailed by it:
∀x P
SUBST({x/g}, P)
for any variable x and ground term g (a constant within domain x)

➢ Example: Suppose the KB contains just the following:


UI
∀x Student(x) ∧ takes(x, English101) → Knows(x,English) Student(Khalid) ∧ takes(Khalid, English101) → Knows(Khalid, English)

Student(Ahmad) ∧ Student(Khalid) Student(Ahmad) ∧ takes(Ahmad, English101) → Knows(Ahmad, English)

4
Existential Instantiation (EI)
➢For any sentence s, variable x, and constant symbol k that does not appear elsewhere in the
knowledge base:
∃x P
Subst({x/K}, P)

K is a new constant symbol, called a Skolem constant.


➢ Existential Instantiation can be applied once, and then the existentially quantified sentence
can be discarded
➢Example:
∃x Student(x) ∧ Smart(x) Student(C1) ∧ Smart(C1)

5
Unification and Lifting
➢ Is a process of making two different logical atomic expressions identical by finding a
substitution. Unification depends on the substitution process.
➢ Is a key component of all first-order inference algorithms.
➢This is called Unification, a “pattern-matching” procedure:
✓ Takes two atomic sentences as input and makes them identical using substitution.
✓ Returns fail if the sentences do not match with each other.
✓ The substitution variables are called Most General Unifier or MGU.

➢ All variables in the given two predicts are implicitly universally quantified.
➢ To make predicts match, replace (universally quantified) variables by terms

6
Conditions for Unification
I. Predicate name must be same, atoms or expression with different predicate symbol can never be
unified.
II. Number of Arguments in both expressions must be identical.
III. Unification will fail if there is no substation.

7
Unification and Lifting
Unify (p,q) = θ where Subst(θ,p) = Subset(θ,q)
Given this KB:
Knows(Salem, Ali)
Knows(y, Khalid)
Knows(y, mother(y))
Knows(x, Rana)

➢ Suppose we a query : Whom does Salem know? Knows(Salem,x)


➢ We need to unify Knows(Salem, x) with all sentences in KB.

8
Unification and Lifting
Knows(Salem,x) Knows(Salem,Ali) {x/Ali}
Knows(Salem,x) Knows(y,Khalid) {y/Salem , x/Khalid}
Knows(Salem,x) Knows(y,mother(y)) {y/Salem , x/Mother(Salem)}
Knows(Salem,x) Knows(x,Rana) Fail

➢ The last unification failed because x cannot take on the values Salem and Rana at the same time.
➢ Because it happens that both sentences use the same variable name.

➢ Solution: rename x in Knows(x,Rana) into Knows(z,Rana) , without changing its meaning. (this is called
standardizing apart)

9
Unification and Lifting
➢Example:
✓parents(x, father(x), mother(Khalid))
✓parents(Khalid, father(Khalid), y)
✓{x/Khalid, y/mother(Khalid)}
➢Example:
✓parents(x, father(x), mother(Khalid))
✓parents(Khalid, father(y), z)
✓{x/Khalid, y/Khalid, z/mother(Khalid)}
➢ Example:
✓ parents(x, father(x), mother(Ali))
✓ parents(Khalid, father(y), mother(y))
✓ Failure

10
Forward-chaining Algorithm
➢ Is a process of making a conclusion based on known facts or data, by starting with known facts
and applies inference rules to extract new facts, continuing the process until a goal is reached or
no more new facts can be generated
➢ Forward-chaining approach is also called as data-driven as we reach to the goal using available
data.
➢ Forward -chaining approach is commonly used in the expert system

11
Forward chaining Algorithm
➢ The idea is simple: start with the atomic sentences in the knowledge base and
apply Modus Ponens in the forward direction, adding new atomic sentences, until no Modus Ponens
further inferences or goal is proved.
P  Q, P
➢ Forward chaining algorithm requires KB in the form of the first-order definite Q
clause.

➢ Forward chaining algorithm :


➢ Starting from the known facts, it triggers all the rules whose premises are
satisfied, adding their conclusions to the known facts
➢ The process repeats until the query is answered (assuming that just one answer is
required) or no new facts are added.

12
Definite clause
➢ Definite clause: A clause which is a disjunction of literals (predicate) with exactly one positive
literal, and the rest are negative.

➢ Every definite clause can be written as an implication whose premise is a conjunction of


positive literals and whose conclusion is a single positive literal.
➢ Example: (¬ p V ¬ q V k). It has only one positive literal k. It is equivalent to p ∧ q → k.
➢ Not every knowledge base can be converted into a set of definite clauses because of the
single-positive-literal restriction, but many can.

13
Example 1
1) ∀ x ∀ y ∀ z Parent(y, z) ∧ Parent(x, y) ⇒ Grandparent(x, z)
2) Parent(Ali, Salem)
3) Parent(Sami, Ali)

Goal: Find if Sami is a grandparent of Salem.? Grandparent(Sami, Salem)

14
1) ∀ x ∀ y ∀ z Parent(y, z) ∧ Parent(x, y) ⇒ Grandparent(x, z)
2) Parent(Ali, Salem)

Forward 3) Parent(Sami, Ali)

chaining
Algorithm KB
Example

Transform to Definite clauses - Omit universal quantifiers


- Omit universal existential by Existential Instantiation

1) Parent(y, z) ∧ Parent(x, y) ⇒ Grandparent(x, z)


2) Parent(Ali, Salem)
3) Parent(Sami, Ali)

15
Step-1:

In the first step we will start with the known facts and will choose the
sentences which do not have implications. All these facts will be 1) Parent(y, z) ∧ Parent(x, y) ⇒ Grandparent(x, z)
represented as below. 2) Parent(Ali, Salem)
3) Parent(Sami, Ali)
Parent(Ali, Salem) Parent(Sami, Ali)

Step-2:
At the second step, we will see those facts which infer from available facts and with satisfied
premises.
Rule-(1) satisfy with the substitution {x/Sami, y/Ali, z/Salem}, so Grandparent(Sami, Salem)

Grandparent(Sami, Salem)

Parent(Ali, Salem) Parent(Sami, Ali)

16
Example 2
1) ∀ x ∀ y Parent(x,y) ∧ Male(x) ⇒ Father(x,y)
2) ∀ x ∀ y ∀ z Father(x,y) ∧ Father(x,z) ⇒ Sibling(y,z)
3) Parent(Ali,Shadi)
4) Male(Ali)
5) Parent(Ali,Ahmad)

Prove that Ahmad and Shadi are Sibling? Sibling(Ahmad,Shadi)

17
1) ∀ x ∀ y Parent(x,y) ∧ Male(x) ⇒ Father(x,y)
2) ∀ x ∀ y ∀ z Father(x,y) ∧ Father(x,z) ∧ y ≠ z ⇒ Sibling(y,z)

Forward 3) Parent(Ali,Shadi)

chaining 4) Male(Ali)
Algorithm 5) Parent(Ali,Ahmad)
KB
Example

Transform to Definite clauses - Omit universal quantifiers


- Omit universal existential by Existential Instantiation

1) Parent(x,y) ∧ Male(x) ⇒ Father(x,y)


2) Father(x,y) ∧ Father(x,z) ∧ y ≠ z ⇒ Sibling(y,z)
3) Parent(Ali,Shadi)
4) Male(Ali)
5) Parent(Ali,Ahmad)

18
Step-1:

In the first step we will start with the known facts and will choose the
sentences which do not have implications. All these facts will be 1) Parent(x,y) ∧ Male(x) ⇒ Father(x,y)
represented as below. 2) Father(x,y) ∧ Father(x,z) ∧ y ≠ z ⇒ Sibling(y,z)
3) Parent(Ali,Shadi)
Male(Ali) Parent(Ali,Shadi) Parent(Ali,Ahmad) 4) Male(Ali)
5) Parent(Ali,Ahmad)
Step-2:
At the second step, we will see those facts which infer from available facts and with satisfied
premises.
Rule-(1) satisfy with the substitution {x/Ali, y/Shadi}, so Father(Ali, Shadi)
is added and which infers from Rule(3) and (4).
Rule-(1) satisfy with the substitution {x/Ali, y/Ahmad}, so Father(Ali, Ahmad) is added, and which
infers from Rule(4) and (5).

Father(Ali,Shadi) Father(Ali,Ahmad)

Parent(Ali,Shadi) Male(Ali) Parent(Ali,Ahmad)

19
Step-3:
Rule-(2) is satisfied with the substitution
{x/Ali, y/Ahmad, z/ Shadi}, , so we can add Sibling(Ahmad, Shadi) which
infers all the available facts. And hence we reached our goal statement.

1) Parent(x,y) ∧ Male(x) ⇒ Father(x,y)


Sibling(Ahmad,Shadi) 2) Father(x,y) ∧ Father(x,z) ∧ y ≠ z ⇒ Sibling(y,z)
3) Parent(Ali,Shadi)
4) Male(Ali)
5) Parent(Ali,Ahmad)
Father(Ali,Shadi) Father(Ali,Ahmad)

Parent(Ali,Shadi) Male(Ali) Parent(Ali,Ahmad)

Hence it is proved that Ahmad and Shadi are sibling using forward chaining
approach.

20
➢ “it is a crime for a Jordanian to sell weapons to hostile nations”
∀ x ∀ 𝐲 ∀ 𝐳 Jordanian(x) ∧ Weapon(y) ∧ Sells(x, y, z) ∧ Hostile(z) ⇒ Criminal (x)
➢ “The country A has some missiles”
Example 3 ∃ x Owns(A, x) ∧ Missile(x)
➢“All of its missiles were sold to it by Sami”
∀ x Missile(x) ∧ Owns(A, x) ⇒ Sells(Sami, x, A) .

➢ “Missiles are weapons”


∀ x Missile(x) ⇒ Weapons (x)

➢“ Enemy of Jordan is known as hostile”


∀ x Enemy(x, Jordan) ⇒ Hostile(x)

➢ “Country A is an enemy of Jordan”


Enemy (A, Jordan) Prove that Sami is a
criminal ? criminal(Sami)
➢ “Sami is Jordanian”
Jordanian(Sami)

21
1) ∀ x ∀ y ∀ z Jordanian(x) ∧ Weapon(y) ∧ Sells(x, y, z) ∧ Hostile(z) ⇒ Criminal (x) .

2) ∃ x Owns(A, x) ∧ Missile(x)

3) ∀ x Missile(x) ∧ Owns(A, x) ⇒ Sells(Sami, x, A).


Forward chaining 4) ∀ x Missile(x) → Weapons (x)
Algorithm Example 5) ∀ x Enemy(x, Jordan) →Hostile(p)
KB
6) Enemy (A, Jordan)

7) Jordanian(Sami)

Transform to Definite clauses


1) Jordanian(x) ∧Weapon(y) ∧ Sells(x, y, z) ∧ Hostile(z) ⇒ Criminal (x) … (1)
Is transformed
2) Owns(A, T1) … (2) into two definite
Missile(T1) … (3) clauses by
Existential
3) Missile(x) ∧ Owns(A, x) ⇒ Sells(Sami, x, A)… (4) Instantiation
4) Missile(x) ⇒ Weapons (x) … (5)
5) Enemy(x, Jordan) ⇒ Hostile(x) … (6)
6) Enemy (A, Jordan) … (7)
7) Jordanian(Sami) … (8)

22
Step-1:
Jordanian(x) ∧Weapon(y) ∧ Sells(x, y, z) ∧ Hostile(z) ⇒ Criminal (x) … (1)
In the first step we will start with the known facts and will choose the
sentences which do not have implications. All these facts will be Owns(A, T1) … (2)
represented as below.
Missile(T1) … (3)
Jordanian(Sami) Missile(T1) Owns(A, T1) Enemy (A, Jordan)
Missile(x) ∧ Owns(A, x) ⇒ Sells(Sami, x, A)… (4)
Step-2:
At the second step, we will see those facts which infer from available facts Missile(x) ⇒ Weapons (x) … (5)
and with satisfied premises.
Enemy(x, Jordan) ⇒ Hostile(x) … (6)
Rule-(5) satisfy with the substitution {x/T1}, so Weapons(T1) is added, and Enemy (A, Jordan) … (7)
which infers from Rule(3).
Jordanian(Sami) … (8)
Rule-(4) satisfy with the substitution {x/T1}, so Sells (Sami, T1, A) is added,
which infers from the conjunction of Rule (2) and (3).

Rule-(6) is satisfied with the substitution(x/A), so Hostile(A) is added and


which infers from Rule-(7).
Weapons (T1) Sells(Sami, T1, A) Hostile(A)

Jordanian(Sami) Missile(T1) Owns(A, T1) Enemy (A, Jordan)

23
Criminal (Sami)
Step-3:
At step-3, as we can check Rule-(1) is satisfied with the
substitution
{x/Sami, y/T1, z/A}, so we can add
Criminal(Sami) which infers all the available facts. And Jordanian(Sami) Weapons (T1) Sells(Sami, T1, A) Hostile(A)
hence we reached our goal statement.

Hence it is proved that Sami is Criminal using forward


chaining approach. Missile(T1) Owns(A, T1) Enemy (A, Jordan)

Jordanian(x) ∧ Weapon(y) ∧ Sells(x, y, z) ∧ Hostile(z) ⇒ Criminal (x) … (1)

Owns(A, T1) … (2)

Missile(T1) … (3)

Missile(x) ∧ Owns(A, x) ⇒ Sells(Sami, x, A)… (4)

Missile(x) ⇒ Weapons (x) … (5)

Enemy(x, Jordan) ⇒ Hostile(x) … (6)

Enemy (A, Jordan) … (7)

Jordanian(Sami) … (8)

24

You might also like