You are on page 1of 25

Posts and Telecommunication Institute of Technology

Faculty of Information Technology 1

Introduction to Artificial Intelligence

Propositional logic
Outline
} Knowledge representation and reasoning
} Propositional logic
} Inference in propositional logic

2 http://www.ptit.edu.vn
The need of knowledge and reasoning
} Humans live in the environment
o Perceive the world through the senses (ears, eyes, ...)
o Collected information will be accumulated into knowledge
o Use accumulated knowledge and reasoning/inference ability to
make reasonable actions
} An intelligent system needs to have the ability to use
knowledge and make inference
o High flexibility
§ The combination of known knowledge and inference allows to create
new knowledge
o Can work in incomplete information cases
o Convenience for system building
§ Just change the knowledge base; keep the same inference procedure

3 http://www.ptit.edu.vn
Knowledge representation language
Knowledge representation language
= Syntax + Semantics + reasoning mechanism
} Syntax
o Includes symbols and rules for linking symbols (syntactic rules) to
form sentences (formulas) in the language
} Semantics
o Allows to determine the meaning of sentences in a certain domain
of the real world
} Reasoning mechanism
o A computational process
o Input: a set of formulas (formal representation of known
knowledge)
o Output: a set of new formulas (formal representation of new
knowledge)

4 http://www.ptit.edu.vn
A good knowledge
representation language
} Good representation ability
o Allows to represent all necessary knowledge of the problem

} Efficient
o Concise knowledge representation
o Inference procedure requires little computation time and little
memory space

} Close to natural language


o Convenient to describe knowledge

5 http://www.ptit.edu.vn
Outline
} Knowledge representation and reasoning
} Propositional logic
o Syntax
o Semantics
} Inference in propositional logic

6 http://www.ptit.edu.vn
Syntax of propositional logic (1/2)
} Symbols
o Truth symbols (logical constants): True (𝑇) and False (𝐹)
o Propositional symbols (Propositional variables): 𝑃, 𝑄, …
o Logical connectives: ∧,∨, ¬, ⇒, ⇔
o Brackets ( and )
} Syntactic rules
o Truth symbols and propositional variables are formulas
o If 𝐴 and 𝐵 are formulas
§ (𝐴 ∧ 𝐵): “A and B” (conjunction)
§ (𝐴 ∨ 𝐵): “A or B” (disjunction)
§ (¬𝐴) : “not A” (negation)
§ (𝐴 ⇒ 𝐵): “if A then B” (implication)
§ (𝐴 ⇔ 𝐵): “A if and only if B” (equivalence)
Are formulas
7 http://www.ptit.edu.vn
Syntax of propositional logic (2/2)
} Unnecessary parentheses can be removed
o Example: ((𝐴 ∨ 𝐵) ∧ 𝐶) can be written as (𝐴 ∨ 𝐵) ∧ 𝐶
} The precedence of logical connectives
o ¬, ∧, ∨, ⇒, ⇔
} Propositional symbols are atomic sentences
o Examples: 𝑃, 𝑄
} If 𝑃 is a propositional symbol then 𝑃 and ¬𝑃 are literal
o 𝑃 is a positive literal, ¬𝑃 is a negative literal
} Complex sentences of the form 𝐴* ∨ 𝐴+ ∨. . .∨ 𝐴, , where
𝐴- are literals, are called clausal sentences

8 http://www.ptit.edu.vn
Semantics of propositional logic (1/2)
} Each propositional symbol corresponds to a propositional
statement
o 𝑃 = “Paris is the capital of France”
o 𝑄 = “Pi constant is an integer number”
} A propositional statement is either True (T) or False (F)
o 𝑃 True, 𝑄 False
} An interpretation is a way of assigning each propositional
variable a truth value (True or False)
𝐴 𝐵 ¬𝐴 𝐴∧𝐵 𝐴∨𝐵 𝐴⇒𝐵 𝐴⇔𝐵
True True False True True True True
True False False False True False False
False True True False True True False
False False True False False True True
9 http://www.ptit.edu.vn
Semantics of propositional logic (2/2)
} A formula is satisfiable if there exists an interpretation
that makes the formula true
o (𝑃 ∧ 𝑄) ∨ ¬𝑅
} A formula whose truth table contains only false in any
interpretation is called unsatisfiable
o 𝑃 ∧ ¬𝑃
} A formula is valid if it is true in every interpretation
o 𝑃 ∨ ¬𝑃
} A model of a formula is an interpretation that makes the
formula true
o {𝑃 ⟵ 𝐹𝑎𝑙𝑠𝑒, 𝑄 ⟵ 𝑇𝑟𝑢𝑒, 𝑅 ⟵ 𝐹𝑎𝑙𝑠𝑒}

10 http://www.ptit.edu.vn
Logical equivalences (1/2)
} Formulas 𝐴 and 𝐵 are said to be logical equivalent if they
have the same truth value in every interpretation
o Notation: 𝐴 ≡ 𝐵

} Basic logical equivalences


o 𝐴 ⇒ 𝐵 ≡ ¬𝐴 ∨ 𝐵 (implication law)
o 𝐴 ⇔ 𝐵 ≡ (𝐴 ⇒ 𝐵) ∧ (𝐵 ⇒ 𝐴) (equivalent law)
o ¬(¬𝐴) ≡ 𝐴 (double negation law)

} De Morgan’s laws
o ¬(𝐴 ∨ 𝐵) ≡ ¬𝐴 ∧ ¬𝐵
o ¬(𝐴 ∧ 𝐵) ≡ ¬𝐴 ∨ ¬𝐵

11 http://www.ptit.edu.vn
Logical equivalences (2/2)
} Commutative laws
o 𝐴∨𝐵 ≡𝐵∨𝐴
o 𝐴∧𝐵 ≡𝐵∧𝐴

} Associative laws
o 𝐴∨𝐵 ∨C≡𝐴∨ 𝐵∨C
o 𝐴∧𝐵 ∧C≡𝐴∧ 𝐵∧C

} Distributive laws
o 𝐴∧ 𝐵∨C ≡ 𝐴∧𝐵 ∨ 𝐴∧𝐶
o 𝐴∨ 𝐵∧C ≡ 𝐴∨𝐵 ∧ 𝐴∨𝐶

12 http://www.ptit.edu.vn
Conjunctive normal form (1/2)
} A disjunctive clause (or simply clause) is a disjunction of
literals
o A clause has the form 𝑃1 ∨ 𝑃2 ∨. . .∨ 𝑃𝑛 , where 𝑃𝑖 are literals

} A conjunctive normal form (CNF) formula is a conjunction


of disjunctive clauses
o (𝐴 ∨ 𝐸 ∨ 𝐹 ∨ 𝐺) ∧ 𝐵 ∨ C ∨ 𝐷

13 http://www.ptit.edu.vn
Conjunctive normal form (2/2)
} We can convert any formula into an equivalent formula
that is in CNF:
o Eliminate equivalences: 𝐴 ⇔ 𝐵 ≡ (𝐴 ⇒ 𝐵) ∧ (𝐵 ⇒ 𝐴)
o Eliminate implications: 𝐴 ⇒ 𝐵 ≡ ¬𝐴 ∨ 𝐵
o Apply De Morgan’s laws to move negations close to propositional
variables
o Eliminate double negations: ¬(¬𝐴) ≡ 𝐴
o Apply distributive laws: 𝐴 ∨ 𝐵 ∧ C ≡ 𝐴 ∨ 𝐵 ∧ 𝐴 ∨ 𝐶

14 http://www.ptit.edu.vn
Exercise 1
} Prove the following basic logical equivalences using truth
tables
1. 𝐴 ⇒ 𝐵 ≡ ¬𝐴 ∨ 𝐵 (Implication law)
2. 𝐴 ⇔ 𝐵 ≡ (𝐴 ⇒ 𝐵) ∧ 𝐵 ⇒ 𝐴 (Equivalent law)
3. ¬(¬𝐴) ≡ 𝐴 (Double negation law)
4. ¬(𝐴 ∨ 𝐵) ≡ ¬𝐴 ∧ ¬𝐵 (De Morgan’s law)
5. ¬(𝐴 ∧ 𝐵) ≡ ¬𝐴 ∨ ¬𝐵 (De Morgan’s law)
6. 𝐴 ∧ 𝐵 ∨ C ≡ 𝐴 ∧ 𝐵 ∨ 𝐴 ∧ 𝐶 (Distributive law)
7. 𝐴 ∨ 𝐵 ∧ C ≡ 𝐴 ∨ 𝐵 ∧ 𝐴 ∨ 𝐶 (Distributive law)

15 http://www.ptit.edu.vn
Exercise 2
} Prove that the following formulas are valid (using basic
logical equivalences and laws)
a) (P Ù Q ) Þ P g) ¬𝑃 ∧ 𝑃 ∨ 𝑄 ⇒ 𝑄
b) P Þ ( P Ú Q)
h) (𝑃 ⇒ 𝑄) ∧ 𝑄 ⇒ 𝑅 ⇒ 𝑃 ⇒ 𝑅
c) ¬P Þ ( P Þ Q )
d ) ( P Ù Q) Þ ( P Þ Q) i) (𝑃 ∧ (𝑃 ⇒ 𝑄)) ⇒ 𝑄

e) ¬( P Þ Q ) Þ P j) ( 𝑃 ∨ 𝑄 ∧ 𝑃 ⇒ 𝑅 ∧ 𝑄 ⇒ 𝑅 ) ⇒ 𝑅
f) ¬( P Þ Q ) Þ ¬Q

16 http://www.ptit.edu.vn
Exercise 3
} Prove the following logical equivalences (using basic
logical equivalences and laws)
1) 𝑃 ⇔ 𝑄 ≡ 𝑃 ∧ 𝑄 ∨ ¬𝑃 ∧ ¬𝑄

2) ¬𝑃 ⇔ 𝑄 ≡ 𝑃 ⇔ ¬𝑄

3) ¬(𝑃 ⇔ 𝑄) ≡ ¬𝑃 ⇔ 𝑄

17 http://www.ptit.edu.vn
Exercise 4
} Convert the following formula into CNF
(𝑃 ⇒ 𝑄) ∨ ¬(𝑅 ∨ ¬𝑆)

18 http://www.ptit.edu.vn
Outline
} Knowledge representation and reasoning
} Propositional logic
} Inference in propositional logic
o Logical inference
o Inference using truth tables
o Inference rules

19 http://www.ptit.edu.vn
Logical inference
} A formula 𝐻 is said to be a logical consequence of a set
of formulas 𝐺 = {𝐺*, … , 𝐺, } if in any interpretation that 𝐺
is true then 𝐻 is also true
} An inference procedure consists of a set of premises and
a conclusion
𝑠𝑒𝑡 𝑜𝑓 𝑝𝑟𝑒𝑚𝑖𝑠𝑒𝑠
𝑐𝑜𝑛𝑐𝑙𝑢𝑠𝑖𝑜𝑛
o Soundness: if conclusion is a logical consequence of the set of
premises
o Completeness: if can find every logical consequence of the set of
premises
} Notations
o KB : Knowledge Base, set of known formulas
o KB├𝛼: 𝛼 is a logical consequence of KB

20 http://www.ptit.edu.vn
Inference using truth tables
} Using truth tables can determine whether a formula is a
logical consequence of a set of formulas in KB or not
o Example: 𝐾𝐵 = {𝐴 ∨ 𝐶, 𝐵 ∨ ¬𝐶}, 𝛼 = 𝐴 ∨ 𝐵

} Properties
o Soundness?
§ Yes
o Completeness?
§ Yes
o Computational complexity
§ High

21 http://www.ptit.edu.vn
Inference rules (1/2)
} Modus Ponens
𝛼 ⇒ 𝛽, 𝛼
𝛽
} Modus Tollens
𝛼 ⇒ 𝛽, ¬𝛽
¬𝛼
} And-Elimination
𝛼) ∧. . .∧ 𝛼* ∧. . .∧ 𝛼+
𝛼*
} And-Introduction
𝛼) , . . . , 𝛼* , . . . , 𝛼+
𝛼) ∧. . .∧ 𝛼* ∧. . .∧ 𝛼+

𝛼, 𝛽, 𝛼% are formulas

22 http://www.ptit.edu.vn
Inference rules (2/2)
} Or-Introduction
𝛼*
𝛼) ∨. . .∨ 𝛼* ∨. . .∨ 𝛼+
} Double-Negation Elimination
¬(¬𝛼)
𝛼
} Transitivity
𝛼 ⇒ 𝛽, 𝛽 ⇒ 𝛾 𝛼, 𝛽, 𝛾, 𝛼% are formulas
𝛼⇒𝛾
} Unit Resolution
𝛼 ∨ 𝛽, ¬𝛽
𝛼
} Resolution
𝛼 ∨ 𝛽, ¬𝛽 ∨ 𝛾
𝛼∨𝛾
23 http://www.ptit.edu.vn
Exercise 1
} Prove the following logical consequences using truth
tables
1. {𝐴 ⇒ 𝐵, 𝐴} ├ 𝐵
2. 𝐴 ⇒ 𝐵, ¬𝐵 ├ ¬𝐴
3. {𝐴 ⇒ 𝐵, 𝐵 ⇒ 𝐶} ├ 𝐴 ⇒ 𝐶
4. 𝐴 ∨ 𝐵, ¬𝐵 ├ 𝐴

24 http://www.ptit.edu.vn
Exercise 2
} Given a 𝐾𝐵:
𝑄∧𝑆 ⇒𝐺∧𝐻 (1)
𝑃⇒𝑄 2
𝑅⇒𝑆 3
𝑃 (4)
𝑅 (5)

Prove the following logical consequence using inference


rules: KB├ 𝐺

25 http://www.ptit.edu.vn

You might also like