Professional Documents
Culture Documents
DR Nazir A. Zafar Advanced Algorithms Analysis and Design
DR Nazir A. Zafar Advanced Algorithms Analysis and Design
DR Nazir A. Zafar Advanced Algorithms Analysis and Design
and Design
By
negation not
conjunction and
disjunction or
implication implies
equivalence if and only if
Negation
Conjunction
• The conjunction p q is true only if p and q both are
true otherwise false
• The conjunction follows the commutative property,
i.e. p q = q p
Disjunction
• The disjunction p q is false if both p and q are false
otherwise true
• The disjunction follows the commutative property as
well, i.e. p q = q p
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
Implication
p q r (p q r) (p (q r))
t t t t t t t tt
t t f t f t f ft
t f t f t t t tt
t f f f t t t tt
f t t f t t t tt
f t f f t t t ft
f f t f t t t tt
f f f f t t t tt
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
De Morgan’s Laws
1. (p q) = p q
p q pq (p q) p q p q
t t t f f f f
t f f t f t t
f t f t t f t
f f f t t t t
2. (p q) = p q
p q pq (p q) p q p q
t t t f f f f
t f t f f t f
f t t f t f f
f f f t t t t
Counter Example
To prove x (A(x) B(x)) is false, we show some
object x for which A(x) is true and B(x) is false.
Proof
( x (A(x) B(x)))
x, (A(x) B(x)))
x, (A(x) B(x))
x, A(x) B(x))
Contraposition
To prove A B, we show ( B) ( A)
• x is divisible by 4 x is divisible by 2
x is not divisible by 2 x is not divisible by 4
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
Proof by Contradiction
Contradiction
To prove A B,
Steps in Proof
• We assume A and to prove that B
• On contrary suppose that B and
• Then prove B, it will be contradiction
Further analysis
• A B (A B) B Contradiction
• A B (A B) is false
• Assuming (A B) is true,
and discover a contradiction (such as A A),
then conclude (A B) is false, and so A B.
Prove:
[B (B C)] C, by contradiction
Proof:
Suppose [B (B C)], to prove C
On contrary, assume C
C [B (B C)] must be true
C [B ( B C)]
C [(B B) (B C)]
C [f (B C)]
C B C = C C B = f B = f
False, Contradiction C
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
Rules of Inference
Modus ponens
If {B (B C)} then {C}, example in last slide
Proof:
Suppose B (B C) then
B
BC
Syllogism
If {A B B C} then {A C}
Proof
• Suppose A B B C, To prove A C
• B
• C
Rule of cases
If {B C B C} then {C}
B, true, implies C true
B, true, implies C true
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
Two Valued Boolean Logic
4. Commutative:
• x+y=y+x
• x·y=y·x
5. Distributive:
• x · (y + z) = (x · y) + (x · z)
• x + (y · z) = (x + y) · (x + z)
6. Complement:
x B, x’ B such that
x + x’ = 1, x · x’ = 0
Event
• Let S U. Then S is called an event, and
Pr( S ) Pr( si )
si S
Sure event
• U = {s1, s2, …, sk}, if S = U
Pr( S ) Pr( si ) 1
si S
Impossible event
• S = , Pr() = 0
6
6
n
i (i n
1)
k 1
i i i ... i
k 2 n
i 1
k
n
2 i
2 1
n
i
i 1
2 i
k 1 2 k 1
2
i 1
• Propositional Logic
• Predicate Logic
• We have discussed various techniques of proving
• Truth Tables
• Logical Equivalence
• Counter Example
• Contraposition
• Contradiction
• Rule of Inference
• Probability can be used for average cost analysis
• Series and summation are very helpful in simplification