Propositional Logic
Propositional Logic
Propositional Logic
Truth Tables
Formalizing Sentences
Problem Formalization
Mathematical Logic
Practical Class: Formalization in Propositional Logic
Chiara Ghidini
FBK-IRST, Trento, Italy
2013/2014
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
Truth Tables
Formalizing Sentences
Problem Formalization
Traffic Light
Graph Coloring
Sudoku
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
Truth Tables
F
T
T
F
F
G
T
F
T
F
F
F
F
T
T
F G
T
F
F
F
F G
T
T
T
F
F G
T
F
T
T
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
F
T
T
F
F
G
T
F
T
F
F G
T
T
T
F
F G
T
F
F
F
(F G )
F
T
T
T
(F G ) (F G )
F
T
T
F
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
Truth Tables
Recall some definitions
Two formulas F and G are logically equivalent (denoted with
F G ) if for each interpretation I, I(F ) = I(G ).
Let F and G be formulas. G is a logical consequence of F
(denoted with F |= G ) if each interpretation satisfying F satisfies
also G .
Let F be a formula:
F is valid if every interpretation satisfies F
F is satisfiable if F is satisfied by some interpretation
F is unsatisfiable if there isnt any interpretation satisfying F
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
p
T
T
F
F
q
T
F
T
F
pq
T
F
T
T
q
F
T
F
T
p q
F
T
T
T
(p q) (p q)
T
T
T
T
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
p
T
T
T
T
F
F
F
F
q
T
T
F
F
T
T
F
F
r
T
F
T
F
T
F
T
F
p q
T
T
F
F
T
T
T
T
r p
F
F
F
F
F
T
F
T
q r p
F
F
T
T
F
T
T
T
(p r )
T
T
T
T
T
F
T
F
Mathematical Logic
F
F
F
F
F
F
F
T
F
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
p
T
T
F
F
q
T
F
T
F
p
F
F
T
T
p q
F
T
F
F
Chiara Ghidini
pq
T
F
F
F
p q p q
T
F
T
T
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
p
T
T
F
F
q
T
F
T
F
q q
F
F
F
F
Chiara Ghidini
p (q q)
F
F
T
T
Mathematical Logic
p
F
F
T
T
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
If Davide comes to the party then Bruno and Carlo come too
Carlo comes to the party only if Angelo and Bruno do not come
If Davide comes to the party, then, if Carlo doesnt come then Angelo comes
Carlo comes to the party provided that Davide doesnt come, but, if Davide
comes, then Bruno doesnt come
A necessary condition for Angelo coming to the party, is that, if Bruno and
Carlo arent coming, Davide comes
Angelo, Bruno and Carlo come to the party if and only if Davide doesnt come,
but, if neither Angelo nor Bruno come, then Davide comes only if Carlo comes
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
If Davide comes to the party then Bruno and Carlo come too
D B C
Carlo comes to the party only if Angelo and Bruno do not come
C A B
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
Carlo comes to the party provided that Davide doesnt come, but,
if Davide comes, then Bruno doesnt come
(C D) (D B)
Angelo, Bruno and Carlo come to the party if and only if Davide
doesnt come, but, if neither Angelo nor Bruno come, then Davide
comes only if Carlo comes
(A B C D) (A B (D C ))
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
ps e
p s e
p (s e) (s e)
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
The 3 doors
Problem
Kyle, Neal, and Grant find themselves trapped in a dark and cold dungeon (HOW they
arrived there is another story). After a quick search the boys find three doors, the first
one red, the second one blue, and the third one green.
Behind one of the doors is a path to freedom. Behind the other two doors, however, is
an evil fire-breathing dragon. Opening a door to the dragon means almost certain
death.
On each door there is an inscription:
freedom
freedom
freedom
is behind
is not behind
is not behind
this door
this door
Given the fact that at LEAST ONE of the three statements on the three doors is true
and at LEAST ONE of them is false, which door would lead the boys to safety?
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
behind one of the door is a path to freedom, behind the other two doors
is an evil dragon
(r b g ) (r b g ) (r b g )
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
(r b g ) (r b g ) (r b g )
r b
r b
Solution
r
T
F
F
b
F
T
F
g
F
F
T
2
T
F
T
3
F
T
T
23
F
F
T
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
Traffic Light
Graph Coloring
Sudoku
Traffic Light
Problem
Define a propositional language which allows to describe the state of a
traffic light on different instants. With the language defined above
provide a (set of) formulas which expresses the following facts:
the traffic light is either green, or red or orange;
the traffic light switches from green to orange, from orange to red,
and from red to green;
it can keep the same color over at most 3 successive states.
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
Traffic Light
Graph Coloring
Sudoku
Traffic Light
Solution
gk =traffic light is green at instant k, rk =traffic light is red at instant
k and ok =traffic light is orange at instant k.
Lets formalize the traffic light behavior:
1
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
Traffic Light
Graph Coloring
Sudoku
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
Traffic Light
Graph Coloring
Sudoku
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
Traffic Light
Graph Coloring
Sudoku
Sudoku Example
Problem
Sudoku is a placement puzzle. The aim of the puzzle is to enter a numeral from
1 through 9 in each cell of a grid, most frequently a 9 9 grid made up of 3 3
subgrids (called regions), starting with various numerals given in some cells
(the givens). Each row, column and region must contain only one instance of
each numeral. Its grid layout is like the one shown in the following schema
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
Traffic Light
Graph Coloring
Sudoku
Chiara Ghidini
Mathematical Logic
Outline
Truth Tables
Formalizing Sentences
Problem Formalization
Traffic Light
Graph Coloring
Sudoku
9
9
9
^
^
_
in(n, r , c)
r =1
n=1
c=1
A column contains
numbers from 1to
all
9
9
9
9
^
^
_
in(n, r , c)
c=1
for any
n=1
0 k, h 2
r =1
9
^
n=1
3
_
3
_
r =1
in(n, 3 k + r , 3 h + c)
c=1
in(n, r , c) in(n , r , c)
Chiara Ghidini
Mathematical Logic