You are on page 1of 20

Artificial Intelligence

First Order Logic

1 10/30/2018
Five types of Logic
Type of knowledge
Type of logic Reference to real world
known by Agent

Degree of belief [0, 1]

Probability Theory Facts
(certainty factor)
Truth values Confidence level [0, 1]
Fuzzy Logic
(degree of truth) (certainty factor)

2 10/30/2018
Representation, reasoning, and logic
The object of knowledge representation is to express
knowledge in a computer-tractable form, so that agents can
perform well.

A knowledge representation language is defined by:

– its syntax, which defines all possible sequences of symbols that
constitute sentences of the language.
– its semantics, which determines the facts in the world to which
the sentences refer.

3 10/30/2018
Sentences and Facts

• Semantics maps sentences in logic to facts in the world.

• The property of one fact following from another is mirrored by the
property of one sentence being entailed by another.

4 10/30/2018
First Order Logic

6 10/30/2018 Convolutional Neural Network

First-Order Logic
Propositional logic represents facts
– Useful --- but has Limited Expressive Power

First-order logic gives

– Objects
 (people, houses, colors, …)
– Relations: how objects relate to each other
 (brother of, bigger than, part of, ...)
– Properties: features of an object
 (red, circle, …)
– Functions: output an object, given others
 (father of, best friend, …)

7 10/30/2018
Sentence  AtomicSentence
| Sentence Connective Sentence
| Quantifier Variable, … Sentence
|  Sentence
| (Sentence)

AtomicSentence  Predicate(Term,…) | Term = Term

Term  Function(Term,…)
| Constant
| Variable

Connective   |  |  | 
Quantifier   | 
Constant  A | X1 | John | …
Variable  a | x | s | …
Predicate  Before | HasColor | Raining | …
Function  MotherOf | LeftLegOf | …
8 10/30/2018
Syntax and Semantics: Term
Constant Symbols
 𝐵𝑜𝑜𝑘, 𝐹𝑟𝑒𝑑, 𝐴𝑙𝑖, etc.

Variables Symbols:
 𝑥, 𝑦, 𝑎, etc.

Predicate Symbols :
 𝐵𝑟𝑜𝑡ℎ𝑒𝑟 𝐹𝑎ℎ𝑚𝑖, 𝐺𝑎𝑙𝑖ℎ ; 𝑀𝑜𝑡ℎ𝑒𝑟(𝐴𝑛𝑛, 𝑆𝑢𝑒) ;
 𝐹𝑎𝑡ℎ𝑒𝑟 𝐿𝑢𝑘𝑒, 𝐷𝑎𝑟𝑡ℎ𝑉𝑎𝑑𝑒𝑟 ; etc.

Function Symbols:
 𝑆ℎ𝑜𝑒𝑠𝑂𝑓 𝐶𝑎𝑐𝑎 ; 𝐿𝑒𝑓𝑡𝐿𝑒𝑔𝑂𝑓 𝐽𝑜ℎ𝑛 ; etc.

9 10/30/2018
Syntax and Semantics: Sentences
Atomic Sentences
 𝐺𝑖𝑣𝑒𝑠 𝐸𝑘𝑜, 𝐷𝑎𝑛𝑢, 𝐶ℎ𝑜𝑐𝑜𝑙𝑎𝑡𝑒𝐶𝑎𝑘𝑒
 𝐵𝑟𝑜𝑡ℎ𝑒𝑟𝑂𝑓 𝐹𝑎ℎ𝑚𝑖 = 𝐵𝑢𝑑𝑖
 𝑆𝑖𝑏𝑙𝑖𝑛𝑔𝑠 𝑆𝑜𝑛𝑂𝑓 𝐹𝑟𝑒𝑑 , 𝐷𝑎𝑢𝑔ℎ𝑡𝑒𝑟𝑂𝑓 𝐹𝑟𝑒𝑑

Complex Sentences
 𝐵𝑟𝑜𝑡ℎ𝑒𝑟𝑠 𝐹𝑎ℎ𝑚𝑖, 𝐺𝑎𝑙𝑖ℎ  𝐺𝑖𝑣𝑒𝑠 𝐹𝑎ℎ𝑚𝑖, 𝐺𝑎𝑙𝑖ℎ, 𝐶ℎ𝑜𝑐𝑜𝑙𝑎𝑡𝑒
 ¬𝐼𝑡𝑠𝑅𝑎𝑛𝑖𝑛𝑔 𝑇𝑜𝑑𝑎𝑦
 𝑇𝑜𝑑𝑎𝑦 𝑀𝑜𝑛𝑑𝑎𝑦 ∨ 𝑇𝑜𝑑𝑎𝑦 𝑇𝑢𝑒𝑠𝑑𝑎𝑦

10 10/30/2018
Universal Quantifiers
“For all, For Every” : ∀
– ∀𝑥 𝐶𝑎𝑡 𝑥 ⇒ 𝑀𝑎𝑚𝑚𝑎𝑙 𝑥
– ∀𝑥 𝐶ℎ𝑖𝑙𝑑 𝑥 ⇒ 𝐿𝑖𝑘𝑒𝑠 𝑥, 𝐶𝑎𝑛𝑑𝑦
 This sentence is true iff all these sentence is true
– 𝐶ℎ𝑖𝑙𝑑 𝐴𝑛𝑑𝑖 ⇒ 𝐿𝑖𝑘𝑒𝑠 𝐴𝑛𝑑𝑖, 𝐶𝑎𝑛𝑑𝑦 ∧ 𝐶ℎ𝑖𝑙𝑑 𝐴𝑛𝑡𝑜 ⇒
𝐿𝑖𝑘𝑒𝑠 𝐴𝑛𝑡𝑜, 𝐶𝑎𝑛𝑑𝑦 ∧ 𝐶ℎ𝑖𝑙𝑑 𝐵𝑢𝑑𝑖 ⇒ 𝐿𝑖𝑘𝑒𝑠 𝐵𝑢𝑑𝑖, 𝐶𝑎𝑛𝑑𝑦 ∧ ⋯

Usually use ⇒ with ∀

– Common mistake to use ∧
 ∀𝑥 𝑆𝑡𝑢𝑑𝑒𝑛𝑡 𝑥, 𝑇𝑒𝑙𝑘𝑜𝑚 ∧ 𝑆𝑚𝑎𝑟𝑡(𝑥)

11 10/30/2018
Existential Quantifiers
“There Exists”: ∃
– ∃𝑥 𝑆𝑡𝑢𝑑𝑒𝑛𝑡 𝑥, 𝑇𝑒𝑙𝑘𝑜𝑚 ∧ 𝑆𝑚𝑎𝑟𝑡 𝑥
– ∃𝑥 𝑀𝑎𝑚𝑚𝑎𝑙 𝑥 ∧ 𝐶𝑎𝑟𝑛𝑖𝑣𝑜𝑟𝑒 𝑥

Usually use ∧ with ∃

– Common mistake to use ⇒
 ∃𝑥 𝐶ℎ𝑖𝑙𝑑 𝑥 ⇒ 𝐿𝑖𝑘𝑒𝑠(𝑥, 𝐶𝑎𝑛𝑑𝑦)

12 10/30/2018
Properties of quantifiers
∀𝑥 ∀𝑦 same as ∀𝑦 ∀𝑥

∃𝑥 ∃𝑦 same as ∃𝑦 ∃𝑥

∃𝑥 ∀𝑦 not the same as ∀𝑦 ∃𝑥

– ∀𝑦 ∃𝑥 𝐹𝑎𝑣𝑜𝑟𝑖𝑡𝑒𝐹𝑜𝑜𝑑(𝑦, 𝑥)
– ∃𝑥 ∀𝑦 𝐹𝑎𝑣𝑜𝑟𝑖𝑡𝑒𝐹𝑜𝑜𝑑 𝑦, 𝑥

13 10/30/2018
Connections between ∀ and ∃
∀𝑥 ¬𝐿𝑖𝑘𝑒𝑠(𝑥, 𝐼𝑐𝑒𝐶𝑟𝑒𝑎𝑚) is equivalent to
¬∃𝑥 𝐿𝑖𝑘𝑒𝑠(𝑥, 𝐼𝑐𝑒𝐶𝑟𝑒𝑎𝑚)
De Morgan Rule
– ∀𝑥 ¬𝑃 ≡ ¬∃𝑥 𝑃 ¬ 𝑃∨𝑄 ≡ ¬𝑃 ∧ ¬𝑄
– ∀𝑥 𝑃 ≡ ∃𝑥 ¬𝑃 ¬ 𝑃∧𝑄 ≡ ¬𝑃 ∨ ¬𝑄
– ∀𝑥 𝑃 ≡ ¬∃𝑥 ¬𝑃 𝑃∧𝑄 ≡ ¬ ¬𝑃 ∨ ¬𝑄
– ∃𝑥 𝑃 ≡ ¬∀𝑥 ¬𝑃 𝑃∨𝑄 ≡ ¬ ¬𝑃 ∧ ¬𝑄

14 10/30/2018
Inference in First-Order Logic
Uses 7 rules from Propositional Logic
With three additional rules for more complex case
regarding to the quantifier
– Universal Instantiation or Universal Elimination
– Existential Instantiation or Existential Elimination
– Existential Introduction or Existential Generalization

15 10/30/2018
Example: Avunculate marriage
Avunculate marriage is illegal and prohibited
– marriage between an uncle and a niece or between an
aunt and a nephew (second-degree relative).

Case:
– W married to A
– W is biological daughter of B, where A and B is a twin

Prove that A and W’s marriage is invalid

– Using FOL

16 10/30/2018
Example: Avunculate marriage
∀𝑥, 𝑦 𝑁𝑖𝑒𝑐𝑒𝑂𝑓 𝑥, 𝑦 ∧ 𝑀𝑎𝑟𝑟𝑖𝑒𝑑 𝑥, 𝑦 ⇒ ¬𝑉𝑎𝑙𝑖𝑑 𝑀𝑎𝑟𝑟𝑖𝑒𝑑 𝑥, 𝑦 (1)

𝑀𝑎𝑟𝑟𝑖𝑒𝑑 𝑊, 𝐴 (2)

𝐷𝑎𝑢𝑔ℎ𝑡𝑒𝑟𝑂𝑓 𝑊, 𝐵 (3)

𝑇𝑤𝑖𝑛𝑠 𝐵, 𝐴 (4)

∀𝑥, 𝑦, 𝑧 𝐷𝑎𝑢𝑔ℎ𝑡𝑒𝑟𝑂𝑓 𝑥, 𝑦 ∧ 𝑆𝑖𝑏𝑙𝑖𝑛𝑔𝑠 𝑦, 𝑧 ⇒ 𝑁𝑖𝑒𝑐𝑒𝑂𝑓(𝑥, 𝑧) (6)

17 10/30/2018
Example: Avunculate marriage
𝑀𝑎𝑟𝑟𝑖𝑒𝑑 𝑊, 𝐴 ∧ 𝐷𝑎𝑢𝑔ℎ𝑡𝑒𝑟𝑂𝑓 𝑊, 𝐵 ∧ 𝑇𝑤𝑖𝑛𝑠 𝐵, 𝐴

Universal Elimination of (5)

• ∀𝑥, 𝑦 𝑇𝑤𝑖𝑛𝑠 𝑥, 𝑦 ⇒ 𝑆𝑖𝑏𝑙𝑖𝑛𝑔𝑠 𝑥, 𝑦
• 𝑇𝑤𝑖𝑛𝑠 𝐵, 𝐴 ⇒ 𝑆𝑖𝑏𝑙𝑖𝑛𝑔𝑠 𝐵, 𝐴 (7)

Modus Ponens of (4) and (7)

• 𝑆𝑖𝑏𝑙𝑖𝑛𝑔𝑠 𝐵, 𝐴 (8)

18 10/30/2018
Example: Avunculate marriage
𝑀𝑎𝑟𝑟𝑖𝑒𝑑 𝑊, 𝐴 ∧ 𝐷𝑎𝑢𝑔ℎ𝑡𝑒𝑟𝑂𝑓 𝑊, 𝐵 ∧ 𝑇𝑤𝑖𝑛𝑠 𝐵, 𝐴 ∧ 𝑆𝑖𝑏𝑙𝑖𝑛𝑔𝑠 𝐵, 𝐴

Universal Elimination of (6)

• ∀𝑥, 𝑦, 𝑧 𝐷𝑎𝑢𝑔ℎ𝑡𝑒𝑟𝑂𝑓 𝑥, 𝑦 ∧ 𝑆𝑖𝑏𝑙𝑖𝑛𝑔𝑠 𝑦, 𝑧 ⇒ 𝑁𝑖𝑒𝑐𝑒𝑂𝑓(𝑥, 𝑧)
• 𝐷𝑎𝑢𝑔ℎ𝑡𝑒𝑟𝑂𝑓 𝑊, 𝐵 ∧ 𝑆𝑖𝑏𝑙𝑖𝑛𝑔𝑠 𝐵, 𝐴 ⇒ 𝑁𝑖𝑒𝑐𝑒𝑂𝑓(𝑊, 𝐴) (9)

And-Introduction from (3) and (8)

• 𝐷𝑎𝑢𝑔ℎ𝑡𝑒𝑟𝑂𝑓 𝑊, 𝐵 ∧ 𝑆𝑖𝑏𝑙𝑖𝑛𝑔𝑠 𝐵, 𝐴 (10)

Modus Ponens of (9) and (10)

• 𝑁𝑖𝑒𝑐𝑒𝑂𝑓(𝑊, 𝐴) (11)

19 10/30/2018
Example: Avunculate marriage
𝑀𝑎𝑟𝑟𝑖𝑒𝑑 𝑊, 𝐴 ∧ 𝐷𝑎𝑢𝑔ℎ𝑡𝑒𝑟𝑂𝑓 𝑊, 𝐵 ∧ 𝑇𝑤𝑖𝑛𝑠 𝐵, 𝐴 ∧ 𝑆𝑖𝑏𝑙𝑖𝑛𝑔𝑠 𝐵, 𝐴 ∧
𝑁𝑖𝑒𝑐𝑒𝑂𝑓(𝑊, 𝐴)

Universal Elimination of (1)

• ∀𝑥, 𝑦 𝑁𝑖𝑒𝑐𝑒𝑂𝑓 𝑥, 𝑦 ∧ 𝑀𝑎𝑟𝑟𝑖𝑒𝑑 𝑥, 𝑦 ⇒ ¬𝑉𝑎𝑙𝑖𝑑 𝑀𝑎𝑟𝑟𝑖𝑒𝑑 𝑥, 𝑦
• 𝑁𝑖𝑒𝑐𝑒𝑂𝑓 𝑊, 𝐴 ∧ 𝑀𝑎𝑟𝑟𝑖𝑒𝑑 𝑊, 𝐴 ⇒ ¬𝑉𝑎𝑙𝑖𝑑 𝑀𝑎𝑟𝑟𝑖𝑒𝑑 𝑊, 𝐴 (12)

And-Introduction from (11) and (2)

• 𝑁𝑖𝑒𝑐𝑒𝑂𝑓 𝑊, 𝐴 ∧ 𝑀𝑎𝑟𝑟𝑖𝑒𝑑 𝑊, 𝐴 (13)

Modus Ponens of (12) and (13)

• ¬𝑉𝑎𝑙𝑖𝑑 𝑀𝑎𝑟𝑟𝑖𝑒𝑑 𝑊, 𝐴 (14)

20 10/30/2018
THANK YOU
10/30/2018
22