CS 228: Logic in Computer Science: Krishna. S
CS 228: Logic in Computer Science: Krishna. S
Krishna. S
1/16
Welcome
2/16
Welcome
2/16
Welcome
2/16
Welcome
2/16
Welcome
2/16
Welcome
2/16
Welcome
2/16
Welcome
2/16
Welcome
2/16
Members of the mini-zoo
3/16
Members of the mini-zoo
3/16
Members of the mini-zoo
3/16
Members of the mini-zoo
3/16
Members of the mini-zoo
3/16
Members of the mini-zoo
3/16
References
I To start with, the text book of Huth and Ryan : Logic for CS.
4/16
References
I To start with, the text book of Huth and Ryan : Logic for CS.
I As we go ahead, lecture notes/monographs/other text books.
4/16
References
I To start with, the text book of Huth and Ryan : Logic for CS.
I As we go ahead, lecture notes/monographs/other text books.
I Classes : Slot 5. Tutorial: To discuss.
I Confirmed TAs: Anish Yogesh Kulkarni, Ameya Vikrama Singh,
Om Swostik Mishra, Agnipratim Das, Nilabha Saha, Ashwin
Abraham
4/16
Propositional Logic
5/16
Syntax
6/16
Syntax
6/16
Syntax
6/16
Syntax
6/16
Syntax
6/16
Natural Deduction
I If it rains, Tia is outside and does not have any raingear with her,
she will get wet. ϕ = (R ∧ TiaOut ∧ ¬RG) → TiaWet
7/16
Natural Deduction
I If it rains, Tia is outside and does not have any raingear with her,
she will get wet. ϕ = (R ∧ TiaOut ∧ ¬RG) → TiaWet
I It is raining, and Tia is outside, and is not wet.
ψ = (R ∧ TiaOut ∧ ¬TiaWet)
7/16
Natural Deduction
I If it rains, Tia is outside and does not have any raingear with her,
she will get wet. ϕ = (R ∧ TiaOut ∧ ¬RG) → TiaWet
I It is raining, and Tia is outside, and is not wet.
ψ = (R ∧ TiaOut ∧ ¬TiaWet)
I So, Tia has her rain gear with her. RG
I Thus, χ = ϕ ∧ ψ → RG. You can deduce RG from ϕ ∧ ψ.
I Is χ valid? Is χ satisfiable?
7/16
Two Examples of Natural Deduction
8/16
Solve Sudoku
2 4
1 3
4 2
1 3
Rules:
I Each row must contain all numbers 1-4
I Each column must contain all numbers 1-4
I Each 2 × 2 block must contain all numbers 1-4
I No cell contains 2 or more numbers
9/16
Encoding as Propositional
Satisfiability
10/16
Encoding as Propositional
Satisfiability
10/16
Encoding as Propositional
Satisfiability
10/16
Encoding as Propositional
Satisfiability
10/16
Encoding as Propositional
Satisfiability
11/16
Encoding as Propositional
Satisfiability
11/16
Encoding as Propositional
Satisfiability
11/16
Encoding as Propositional
Satisfiability
Each 2 × 2 block must contain all numbers 1-4
12/16
Encoding as Propositional
Satisfiability
Each 2 × 2 block must contain all numbers 1-4
I Upper left block contains all numbers 1-4:
12/16
Encoding as Propositional
Satisfiability
Each 2 × 2 block must contain all numbers 1-4
I Upper left block contains all numbers 1-4:
13/16
Encoding as Propositional
Satisfiability
Solving Sodoku
To solve the puzzle, just conjunct all the above formulae and find a
satisfiable truth assignment!
14/16
Gold Rush
Only one message is true; the other two are false. Which box has the
gold?
15/16
Solve Gold Rush
16/16
Solve Gold Rush
16/16
Solve Gold Rush
16/16
Solve Gold Rush
16/16
Solve Gold Rush
16/16
Solve Gold Rush
16/16
Solve Gold Rush
16/16
Solve Gold Rush
16/16
Solve Gold Rush
16/16
Solve Gold Rush
16/16