w1,2 - Ch01-1 Propositional Logic - Print
w1,2 - Ch01-1 Propositional Logic - Print
Structures
Instructor:
Assoc. Prof. Ahmed Sherif Zekri
1
Let’s get started with...
Logic!
2
Why logic?
• The rules of logic specify the meaning of
mathematical statements.
e.g.
“There exists an integer that is not the
sum of two squares”
3
Propositional Logic
• Crucial for mathematical reasoning
• Important for program design
• Applied in computer circuits design
4
The Statement/Proposition Game
5
Combining Propositions
6
Logical Operators (Connectives)
Negation (NOT, )
• Conjunction (AND, )
• Disjunction (OR,)
• Exclusive-or (XOR, )
• Implication (if – then, → )
• Biconditional (if and only if, )
P P
true (T) false (F)
false (F) true (T)
8
Conjunction (AND)
Binary Operator, Symbol:
P Q P Q
T T T
T F F
F T F
F F F
9
Disjunction (OR)
Binary Operator, Symbol:
P Q P Q
T T T
T F T
F T T
F F F
10
Exclusive Or (XOR)
Binary Operator, Symbol:
P Q PQ
T T F
T F T
F T T
F F F
11
Implication (if - then)
Binary Operator, Symbol: →
P Q P→Q
T T T
T F F
F T T
F F T
12
Biconditional (if and only if)
Binary Operator, Symbol:
P Q PQ
T T T
T F F
F T F
F F T
p → qq → p 13
Statements and Operators
Statements and operators can be combined in any
way to form new statements.
P Q P Q (P)(Q)
T T F F F
T F F T T
F T T F T
F F T T T
14
Statements and Operations
Statements and operators can be combined in any
way to form new statements.
15
Boolean operators summary
not not and or xor conditional Bi-
conditional
p q p q pq pq pq p→q pq
T T F F T T F T T
T F F T F T T F F
F T T F F T T T F
F F T T F F F T T
Precedence of operators
Just as in algebra, operators have
precedenc
e.g. 4+3*2 = 4+(3*2), not (4+3)*2
Precedence order (from highest to
lowest):
¬→↔
e.g. p q ¬r → s ↔ t yields:
(p (q (¬r)) → s) ↔ (t)
¬ is always performed before any other
operation
Logic and Bit Operations
Computers represent information using bits:
0 (T) and 1 (F).
A variable is called a Boolean variable if its
value is either true or false.
Computer bit operations correspond to the
logical connectives.
¬
18
Example
19
Applications of Propositional Logic
• Logic circuits
• Translating English Sentences
20
Logic Circuits
(p ∧¬q) ∨ ¬r
24
Translating English
Sentences
* If the moon is out and it is not snowing, then
Ali goes out for a walk.
( t u ) → s
(pq) (p→¬q)
p↔q
Equivalent Statements
P Q (PQ) (P)(Q) (PQ) (P)(Q)
T T F F T
T F T T T
F T T T T
F F T T T
The statements (PQ) and (P) (Q) are logically
equivalent, since they have the same truth table, or put
it in another way, (PQ) (P) (Q) is always true.
28
Equivalence
Definition: two propositional statements
S1 and S2 are said to be (logically)
equivalent, denoted S1 S2 if
– They have the same truth table,
or
– S1 S2 is a tautology
29
Equivalence Laws
– Identity law, P T P,
– Domination law, P F F,
– Idempotent law, P P P,
– Double negation law, ( P) P
– Commutative law, P Q Q P,
– Associative law, P (Q R) (P Q) R,
– Distributive law, P (Q R) (P Q) (P R),
– De Morgan’s law, (PQ) ( P) ( Q)
– Law with implication P→ Q PQ
30
31
32
Constructing New Logical Equivalences
Example:
Show that: ¬(p → q) and p ∧¬q are
logically equivalent.
33
Way1: By truth table
p q ¬q p→ q ¬(p→ q) p ¬ q
T T F T F F
T F T F T T
F T F T F F
F F T T F F
34
Way1: By truth table
p q ¬q p→ q ¬(p→ q) p ¬ q
T T F T F F
T F T F T T
F T F T F F
F F T T F F
35
Way2
• Use logical identities that we
already know to establish new logical
identities (e.g. Tables 6,7,8),
• This way is of practical importance
for establishing equivalences of
compound propositions with a large
number of variables.
• difficult to draw truth tables in this case!
36
Start with one of the two statements
and try to get the other statement:
¬(p → q)
≡ ¬(¬p ∨ q) Law of implication
≡ p ∧¬q
37
Exercise
Show that ¬(p ∨ (¬p ∧ q)) and ¬p ∧¬q are
logically equivalent by developing a series
of logical equivalences.
38
Questions
Q1: How many rows are required
to construct the truth-table of:
[(p ∨ q) ∧ (p → r) ∧ (q → r)] → r
Demonstrate that
[¬p (p q )]→q
is a tautology.
There are two ways:
1. Construct a truth table and show
that [¬p (p q )]→q is
always true
2. Using a proof (apply rules).
42
Tautology by truth table
p q ¬p p q ¬p (p q ) [¬p (p q )]→q
T T
T F
F T
F F
Tautology by truth table
p q ¬p p q ¬p (p q ) [¬p (p q )]→q
T T F
T F F
F T T
F F T
Tautology by truth table
p q ¬p p q ¬p (p q ) [¬p (p q )]→q
T T F T
T F F T
F T T T
F F T F
Tautology by truth table
p q ¬p p q ¬p (p q ) [¬p (p q )]→q
T T F T F
T F F T F
F T T T T
F F T F F
Tautology by truth table
p q ¬p p q ¬p (p q ) [¬p (p q )]→q
T T F T F T
T F F T F T
F T T T T T
F F T F F T
Derivational Proof
Techniques
Use derivational proof techniques to
show that the proposition
(p →p ) ((s r)t) ) (q →r )
is a tautology.
48
L3
Derivational Proof
Techniques
(p →p ) ((s r)t ))
(q→r )
≡ T ((sr)t )) (q→r )
≡ T
49
L3
Example
p (q q) Associativity
p q Idempotent
Tautology by proof
Prove that [¬p (p q )]→q is a tautology.
[(¬p p)(¬p q)]→q Distributive Law
[ F (¬p q)]→q Negation Law
[¬p q ]→q Identity Law
¬ [¬p q ] q Implication Law
[¬(¬p) ¬q ] q DeMorgan Law
[p ¬q ] q Double Negation
p [¬q q ] Associative Law
p [q ¬q ] Commutative Law
pT Negation Law
T Domination Law
51
L3