You are on page 1of 18

Artificial Intelligence (AI)

Part - 2, Lecture – 10&11

Inference in First-order logic


Lecturer: Dr. Md Akhtaruzzaman
Assistant Professor, CSE, MIST
akhter900@gmail.com

June 10, 2021, MIST, Dhaka.


 Recap

 Inference in FoL
 FoL inference rules for quantifier
 Exercise

akhter900@gmail.com 2
 knowledge-engineering
 Knowledge-engineering Process
1. Identify the task
2. Assemble the relevant knowledge
3. Decide on vocabulary
4. Encode general knowledge about the domain
5. Encode the specific problem instance
6. Pose queries to inference procedure and get answers
7. Debug the knowledge-base (KB)

akhter900@gmail.com 3
Inference in First-Order Logic is
used to deduce new facts or
sentences from existing
sentences.

akhter900@gmail.com 4
 Basic terminologies:
◦ Substitution: It is a fundamental operation performed on terms
and formulas.
 It occurs in all inference systems in first-order logic.
 The substitution is complex in the presence of quantifiers in FoL.
 Ex.: if 𝑭[𝒂/𝒙], it refers to substitute a constant "𝒂" in place of variable
"𝒙".

◦ Equality: Besides predicate and terms FoL also uses equality. For
this, equality symbol is used, specify that the two terms refer to the
same object.
 Ex.: 𝑺𝒊𝒔𝒕𝒆𝒓 (𝑨𝒑𝒑𝒍𝒆) = 𝑳𝒊𝒄𝒉𝒊.
 Equality symbol can also be used with negation (are not the same).
 Ex.: ¬(𝒙 = 𝒚) which is equivalent to 𝒙 ≠ 𝒚.
akhter900@gmail.com 5
 some basic inference rules in FoL:

◦ Universal Generalization (UG)


◦ Universal Instantiation (UI)
◦ Existential Instantiation (EI)
◦ Existential introduction/Generalization (EG)

akhter900@gmail.com 6
 Universal Generalization
◦ If premise 𝑷(𝒄) is true for any arbitrary element 𝒄 in the
universe of discourse, then ∀𝒙 𝑷(𝒙) is true.
𝑷 𝒄
◦ Can be represented as,
∀𝒙 𝑷 𝒙
◦ This rule can be used if every element has a similar property.
◦ In this rule, 𝒙 must not appear as a free variable.

◦ Ex.:
 𝑷(𝒄): “A byte contains 8 bits” is true, So, ∀ 𝒙 𝑷(𝒙): “All bytes
contain 8 bits.” will also be true.

akhter900@gmail.com 7
 Universal Instantiation (UI) (Universal Elimination)
◦ Valid inference rule and can be applied multiple times to add
new sentences.
◦ The new KB is logically equivalent to the previous KB.
◦ Any sentence can be obtained by substituting a ground term
for the variable.
◦ The UI rule state that any sentence 𝑷(𝒄) by substituting a
ground term 𝒄 (a constant within domain 𝑥) from ∀ 𝒙 𝑷(𝒙)
for any object in the universe of discourse.
∀𝒙 𝑷 𝒙
◦ Can be presented as:
𝑷 𝒄

akhter900@gmail.com 8
 Universal Instantiation (UI)…
◦ Ex. 1:
 IF "Every person like ice-cream" ∀𝒙 𝑷(𝒙), so, "John likes ice-
cream" 𝑷(𝒄)

◦ Ex. 2:
 All students in the class understand logic. Apple is a student in
the class. So, Apple understands logic.
 Let’s assume, 𝑷 𝒙 is “x is a student in the class.” and 𝑸 𝒙 is “x
understand logic.”
1. ∀𝑥 𝑃 𝑥 → 𝑄 𝑥 Premesis-1
2. 𝑃 𝐴𝑝𝑝𝑙𝑒 Premesis-2
3. 𝑃 𝐴𝑝𝑝𝑙𝑒 → 𝑄 𝐴𝑝𝑝𝑙𝑒 (1), UI
4. 𝑄 𝐴𝑝𝑝𝑙𝑒 (2) & (3), MP

akhter900@gmail.com 9
 Exercise-1:
◦ Justify that if ∀𝑥 𝑃 𝑥 → 𝑄 𝑥 and ∀𝑥 𝑄 𝑥 → 𝑅 𝑥 are
true, then ∀𝑥 𝑃 𝑥 → 𝑅 𝑥 is true, where the domain of all
quantifiers are same.
◦ Solution:
 Let 𝑐 be the arbitrary element
1. ∀𝑥 𝑃 𝑥 → 𝑄 𝑥 Premesis-1
2. ∀𝑥 𝑄 𝑥 → 𝑅 𝑥 Premesis-2
3. 𝑃 𝑐 →𝑄 𝑐 UI in (1)
4. 𝑄 𝑐 →𝑅 𝑐 UI in (2)
5. 𝑃 𝑐 → 𝑅(𝑐) hypothetical Syllogism from (3) & (4)
6. ∀𝑥 𝑃 𝑥 → 𝑅 𝑥 UG in (5)

akhter900@gmail.com 10
 Existential Instantiation (Existential Elimination)
◦ Valid inference rule and can be applied only once to replace
the existential sentence.
◦ The new KB is not logically equivalent to old KB, but it will be
satisfiable if old KB is satisfiable.
◦ This rule states that one can infer 𝑷(𝒄) from the formula
given in the form of ∃𝒙 𝑷(𝒙) for a new constant symbol 𝒄.
◦ The restriction with this rule is that 𝒄 used in the rule must
be a new term for which 𝑷(𝒄) is true.
∃𝒙 𝑷 𝒙
◦ Can be presented as,
𝑷 𝒙

akhter900@gmail.com 11
 Existential Instantiation…

◦ Ex.: “Apple has a kind of watch on his wrist”.

 It is presented as: ∃𝒙 𝑾𝒂𝒕𝒄𝒉(𝒙) ∧ 𝑶𝒏𝑾𝒓𝒊𝒔𝒕(𝒙, 𝑨𝒑𝒑𝒍𝒆)


 So, 𝑾𝒂𝒕𝒄𝒉(𝑲) ∧ 𝑶𝒏𝑯𝒂𝒏𝒅(𝑲, 𝑨𝒑𝒑𝒍𝒆), as 𝑲 does not appear in
the knowledge base.

 The 𝑲 is a constant symbol, which is called Skolem constant.


 The EI is a special case of Skolemization process.

akhter900@gmail.com 12
 Existential Introduction (existential generalization)
◦ Valid inference rule.
◦ If there is some element 𝒄 in the universe of discourse which
has a property 𝑷, then there exists something in the universe
which has the property 𝑷.
𝑷 𝒄
◦ It can be represented as:
∃𝒙 𝑷 𝒙
◦ Ex.: Let's say that “Apple got good marks in AI“
"Therefore, someone got good marks in AI“.
 Statement 1: 𝐺𝑜𝑜𝑑 𝑔 ∧ 𝑆𝑢𝑏𝑗𝑒𝑐𝑡 𝐴𝐼 ∧ 𝑀𝑎𝑟𝑘𝑠 𝑔, 𝐴𝐼 ∧ 𝐺𝑟𝑎𝑑𝑒(𝑔, 𝐴𝑝𝑝𝑙𝑒)
 Statement 2: ∃𝑥 𝐺𝑜𝑜𝑑 𝑔 ∧ 𝑆𝑢𝑏𝑗𝑒𝑐𝑡 𝐴𝐼 ∧ 𝑀𝑎𝑟𝑘𝑠 𝑔, 𝐴𝐼 ∧ 𝐺𝑟𝑎𝑑𝑒 𝑔, 𝑥

akhter900@gmail.com 13
 Generalized Modus Ponens Rule
◦ It is lifted version of Modus ponens.
◦ It can be summarized as, "P implies Q and P is asserted to be
true, therefore Q must be True."
◦ For atomic sentences 𝑝𝑖, 𝑝𝑖′, 𝑞, and a substitution 𝜽 such that
𝑺𝑼𝑩𝑺𝑻(𝜽, 𝒑𝒊′) = 𝑺𝑼𝑩𝑺𝑻(𝜽, 𝒑𝒊), it can be represented as:
𝑃1′ , 𝑃2′ , … , 𝑃𝑛′ 𝑃1 ∧ 𝑃2 ∧ ⋯ ∧ 𝑃𝑛 → 𝑄
𝑆𝑈𝐵𝑆𝑇 𝜃, 𝑄
◦ Ex.: For some 𝑥 such that 𝑥 is 𝑘𝑖𝑛𝑔, and 𝑥 is 𝑔𝑟𝑒𝑒𝑑𝑦 so it can
be inferred that 𝑥 is evil.
 𝑝1′ is 𝐾𝑖𝑛𝑔(𝐽𝑜ℎ𝑛) 𝑝1 is 𝐾𝑖𝑛𝑔(𝑥)
 𝑝2′ is 𝐺𝑟𝑒𝑒𝑑𝑦(𝑦) 𝑝2 is 𝐺𝑟𝑒𝑒𝑑𝑦(𝑥)
 𝜃 is {𝑥/𝐽𝑜ℎ𝑛, 𝑦/𝐽𝑜ℎ𝑛} 𝑞 is 𝐸𝑣𝑖𝑙(𝑥)
 𝑆𝑈𝐵𝑆𝑇(𝜃, 𝑞) is 𝑬𝒗𝒊𝒍(𝑱𝒐𝒉𝒏)
akhter900@gmail.com 14
 Exercise 2:
◦ Construct a valid argument to show that “Mohesh has four
legs” which is a consequence of the premises “Every cow has
four legs” and “Mohesh is a cow”.
◦ Solution:
 𝐶(𝑥) indicates x is a cow
 𝐿(𝑥) indicates x has four legs
1. ∀𝑥 𝐶 𝑥 → 𝐿 𝑥 Premises – 1
2. 𝐶(𝑚𝑜ℎ𝑒𝑠ℎ) Premises – 2
3. 𝐶 𝑚𝑜ℎ𝑒𝑠ℎ → 𝐿(𝑚𝑜ℎ𝑒𝑠ℎ) from (1) by applying UI rule
4. 𝐿(𝑚𝑜ℎ𝑒𝑠ℎ) from (2) and (3) by using MP rule

akhter900@gmail.com 15
 Exercise 3:
◦ By using rule of inference in FoL, construct a valid argument
showing that the conclusion is “Some one who passed AI has
not read the book” where two premises are: “A student in AI
class has not read the book” and “Everyone in AI class passed
the subject”.
◦ Solution:
 Finding the subjects, predicates, and generate valid syntaxes.
 𝑆𝑡𝑢𝑑𝑒𝑛𝑡𝑠𝐴𝐼(𝑥) 𝑥 is a student of 𝐴𝐼 class
 𝑅𝑒𝑎𝑑𝑏𝑜𝑜𝑘(𝑥) 𝑥 read the book
 𝑃𝑎𝑠𝑠(𝑥) 𝑥 passed the class
 ∃𝑥 𝑆𝑡𝑢𝑑𝑒𝑛𝑡𝐴𝐼 𝑥 ∧ ¬𝑅𝑒𝑎𝑑𝑏𝑜𝑜𝑘 𝑥 Premises-1
 ∀𝑥 𝑆𝑡𝑢𝑑𝑒𝑛𝑡𝑠𝐴𝐼 𝑥 → 𝑃𝑎𝑠𝑠 𝑥 Premises-2
 Need to proof:
akhter900@gmail.com 16
 Solution…
 Premises are: “A student in AI class has not read the book” and
“Everyone in AI class passed the subject”.
 Need to proof: “Some one who passed AI has not read the book”
which is ∃𝑥 (𝑃𝑎𝑠𝑠 𝑥 → ¬𝑅𝑒𝑎𝑑(𝑥))
1. ∃𝑥 (𝑆 𝑥 ∧ ¬𝑅 (𝑥)) Premises – 1
2. ∀𝑥 (𝑆 𝑥 → 𝑃(𝑥)) Premises – 2
3. 𝑆 𝑎 ∧ ¬𝑅(𝑎) (1) using EI
4. 𝑆(𝑎) (3) using Simplification
5. ¬𝑅(𝑎) (3) using Simplification
6. 𝑆 𝑎 → 𝑃(𝑎) (2) using UI
7. 𝑃(𝑎) (4), (6) using MP
8. 𝑃 𝑎 ∧ ¬𝑅(𝑎) (5), (7) using Conjunctive law
9. ∃𝑥 𝑃 𝑥 ∧ ¬𝑅 𝑥 (8) using EG

akhter900@gmail.com 17
Understand before act,
as what is seen may not be the actual
reflection of a state.

Thank You
18

You might also like