01 Lecture (Logic)
01 Lecture (Logic)
p p q ~ pr ~qp
p pq p~q
pq
pr r ~pq
TT F T P Q R T
TT T F T TTT F
T
T T
F
FT T 1- LogicF 1 F1 1 F
TF T T F TT F F
F
F F
F T T 1 T0 1
T F T T T TLecture No.1
T LogicT
F Course
F Objective: T 0 T1 1 T
T F F T T F F
0
1.Express statements with the precision of0formal logic0
F T T T
2.Analyze T to test their
arguments T validityT
3.Apply the basic properties and operations related to sets
F T F T T T F
4.Apply to sets the basic properties and operations related to relations and functions
F F T 5.Define
F terms recursively
T T T
6.Prove a formula using mathematical induction
F F F F statements
7.Prove T using directT and indirect
F methods
8.Compute probability of simple and conditional events
9.Identify and use the formulas of combinatorics in different problems
10.Illustrate the basic definitions of graph theory and properties of graphs
11.Relate each major topic in Discrete Mathematics to an application area in computing
1.Recommended Books:
MAIN TOPICS
:
1. Logic
2. Sets & Operations on sets
3. Relations & Their Properties
4. Functions
5. Sequences & Series
6. Recurrence Relations
7. Mathematical Induction
8. Method of Proof
9. Graphs and Trees
Discrete Continuous
1-Logic
Set of Integers:
• • • • • • •
-3 -2 -1 0 1 2 3
• • • • • • •
-3 -2 -1 0 1 2 3
LOGIC
:
Logic is the study of the principles and methods that distinguishes between a
valid and an invalid argument.
SIMPLE STATEMENT
:
A statement is a declarative sentence that is either true or false but not both.
A statement is also referred to as a proposition
Example: 2+2 = 4, It is Sunday today
If a proposition is true, we say that it has a truth value of "true”.
If a proposition is false, its truth value is "false".
The truth values “true” and “false” are, respectively, denoted by the letters T and F.
EXAMPLES
:
1.Grass is green.
2.4 + 2 = 6
2.4 + 2 = 7
3.There are four fingers in a hand.
are propositions
Rule:
If the sentence is preceded by other sentences that make the pronoun or variable reference
clear, then the sentence is a statement.
Example: Example
x=1 Bill Gates is an American
x>2 He is very rich
x > 2 is a statement with truth-value He is very rich is a statement with truth-value
FALSE. TRUE.
1-Logic
UNDERSTANDING STATEMENTS
:
COMPOUND STATEMENT
:
Simple statements could be used to build a compound statement.
SYMBOLIC REPRESENTATION
:
Statements are symbolically represented by letters such as p, q, r,...
EXAMPLES:
p = “Islamabad is the capital of Pakistan”
q = “17 is divisible by 3”
Disjunction or Vel
EXAMPLES:
EXAMPLE
:
A truth table specifies the truth value of a compound proposition for all
possible truth values of its constituent propositions.
NEGATION (~)
:
~p
CONJUNCTION ( )
:
If p and q are statements, then the conjunction of p and q is “p and q”, denoted as
“p q”.
It is true when, and only when, both p and q are true. If either p or q is false, or
if both are false, pq is false.
pq
p q pq
T T T
T F F
F T F
F F F
DISJUNCTION ( ) or INCLUSIVE OR
If p & q are statements, then the disjunction of p and q is “p or q”, denoted as
“p q”.It is true when at least one of p or q is true and is false only when both
p and q are false.
1-Logic
Remark:
Note that for Conjunction of two statements we find the T in both the statements, But in
disjunction we find F in both the statements. In other words we will fill T first in the
column of conjunction and F in the column of disjunction.
SUMMARY
1. What is a statement?
2. How a compound statement is formed.
3. Logical connectives (negation, conjunction, disjunction).
4. How to construct a truth table for a statement form.
1-Logic
1-Logic
1-Logic
1-Logic
1-Logic
1-Logic
1-Logic
2-Truth Tables
2-Truth Tables
Example
“It is not true that I am not happy”
Solution:
Let p = “I am happy”
then ~ p = “I am not happy”
and ~(~ p) = “It is not true that I am not happy”
Since ~(~p) p
Hence the given statement is equivalent to:
“I am happy”
~(pq) and ~p ~q are not logically equivalent
p q ~p ~q pq ~(pq) ~p ~q
T T F F T F F
T F F T F T F
F T T F F T F
F F T T F T T
Different truth values in row 2 and row 3
DE MORGAN’S LAWS
:
2-Truth Tables
Application:
Solution
a.The fan is not slow and it is not very hot.
b.Akram is not unfit or Saleem is not injured.
-1 < x 4
for some particular real no. x
-1 < x 4 means x > –1 and x 4
EXERCISE:
1. (p q) r p (q r)
2. Are the statements (pq)r and p (q r) logically equivalent?
TAUTOLOGY
:
A tautology is a statement form that is always true regardless of the truth
values of the statement variables.
A tautology is represented by the symbol “t”..
p ~p t
CONTRADICTION:
A contradiction is a statement form that is always false regardless of the truth values of
the statement variables.
A contradiction is represented by the symbol “c”.
So if we have to prove that a given statement form is CONTRADICTION we will make
the truth table for the statement form and if in the column of the given statement form all
the entries are F ,then we say that statement form is contradiction.
EXAMPLE:
The statement form p ~ p is a contradiction.
p ~p p~p
T F F
F T F
Since in the last column in the truth table we have F in all the entries so is a contradiction
p ~p c
REMARKS:
– Most statements are neither tautologies nor contradictions.
– The negation of a tautology is a contradiction and vice versa.
– In common usage we sometimes say that two statement are contradictory.
By this we mean that their conjunction is a contradiction: they cannot both be true.
LOGICAL EQUIVALENCE INVOLVING TAUTOLOGY
1. Show that p t p
p t pt
T T T
F T F
Since in the above table the entries in the first and last columns are identical so we have
the corresponding statement forms are Logically equivalent that is
ptp
p c pc
T F F Same truth values in the indicated columns so
F F F pc c
EXERCISE:
Use truth table to show that (p q) (~p (p ~q)) is a tautology.
2-Truth Tables
SOLUTION:
Since we have to show that the given statement form is Tautology so the column of the
above proposition in the truth table will have all entries as T.
As clear from the table below
T T T F F F F T
T F F F T T T T
F T F T F F T T
F F F T T F T T
Hence (p q) (~p (p ~q)) t
EXERCISE:
Use truth table to show that (p ~q) (~pq) is a contradiction.
SOLUTION:
Since we have to show that the given statement form is Contradiction so its column in the
truth table will have all entries
as F. As clear from the table below
EXCLUSIVE OR:
When or is used in its exclusive sense, The statement “p or q” means “p or q but not both”
or “p or q and not p and q” which translates into symbols as:
(p q) ~(p q)
Note:
Basically
p Å q ≡ (p q) ~p q)
≡ [p ~q) ~p] [(p ~q) q]
≡ (p q) p q)
≡ (p q) p ~q)
2-Truth Tables
2-Truth Tables
2-Truth Tables
2-Truth Tables
2-Truth Tables
3-Laws of logic
3-Laws of Logic
SIMPLIFYING A STATEMENT:
“You will get an A if you are hardworking and the sun shines, or you are hardworking and
it rains.”
Rephrase the condition more simply.
Solution:
Let p = “You are hardworking’
q = “The sun shines”
r = “It rains” .The condition is then (p q) (p r)
And using distributive law in reverse,
(p q) (p r) p (q r)
EXERCISE
:
Use Logical Equivalence to rewrite each of the following sentences more simply.
1.It is not true that I am tired and you are smart.
{I am not tired or you are not smart.}
2.It is not true that I am tired or you are smart.
{I am not tired and you are not smart.}
3.I forgot my pen or my bag and I forgot my pen or my glasses.
{I forgot my pen or I forgot my bag and glasses.
4.It is raining and I have forgotten my umbrella, or it is raining and I have
forgotten my hat.
{It is raining and I have forgotten my umbrella or my hat.}
CONDITIONAL STATEMENTS
:
Introduction
TRUTH TABLE
:
p q pq
T T T
T F F
F T T
F F T
PRACTICE WITH CONDITIONAL STATEMENTS:
EXERCISE:
Write the following statements in the form “if p, then q” in English.
a)Your guarantee is good only if you bought your CD less than 90 days ago.
If your guarantee is good, then you must have bought your CD player less
than 90 days ago.
b)To get tenure as a professor, it is sufficient to be world-famous.
If you are world-famous, then you will get tenure as a professor.
c)That you get the job implies that you have the best credentials.
If you get the job, then you have the best credentials.
d)It is necessary to walk 8 miles to get to the top of the Peak.
If you get to the top of the peak, then you must have walked 8 miles.
:
Let p and q be propositions:
p = “you get an A on the final exam”
q = “you do every exercise in this book”
r = “you get an A in this class”
Write the following propositions using p, q,and r and logical connectives.
1.To get an A in this class it is necessary for you to get an A on the final.
SOLUTION pr
2.You do every exercise in this book; You get an A on the final, implies,
you get an A in the class.
SOLUTION pqr
3. Getting an A on the final and doing every exercise in this book is sufficient
For getting an A in this class.
SOLUTION pqr
1.p q
If you have flu, then you will miss the final exam.
2.~q r
If you don’t miss the final exam, you will pass the course.
3.~p ~q r
If you neither have flu nor miss the final exam, then you will pass the course.
T T F F T T
T F T F F F
F T F T T T
F F T T T T
EXAMPLES
Write negations of each of the following statements:
1.If Ali lives in Pakistan then he lives in Lahore.
2.If my car is in the repair shop, then I cannot get to class.
3.If x is prime then x is odd or x is 2.
4.If n is divisible by 6, then n is divisible by 2 and n is divisible by 3.
SOLUTIONS:
1. Ali lives in Pakistan and he does not live in Lahore.
2. My car is in the repair shop and I can get to class.
3.x is prime but x is not odd and x is not 2.
4.n is divisible by 6 but n is not divisible by 2 or by 3.
p q pq ~p ~q ~p ~q
T T T F F T
T F F F T T
F T T T F F
F F T T T T
different truth values in rows 2 and 3
WRITING INVERSE
:
1. If today is Friday, then 2 + 3 = 5.
If today is not Friday, then 2 + 3 5.
p q pq qp
T T T T
T F F T
F T T F
F F T T
not the same
WRITING CONVERSE
:
1.If today is Friday, then 2 + 3 = 5.
If 2 + 3 = 5, then today is Friday.
REPHRASING BICONDITIONAL
:
pq is also expressed as:
“p is necessary and sufficient for q”
“if p then q, and conversely”
“p is equivalent to q”
EXERCISE
:
Rephrase the following propositions in the form “p if and only if q” in English.
1.If it is hot outside you buy an ice cream cone, and if you buy an ice cream
cone it is hot outside.
Sol You buy an ice cream cone if and only if it is hot outside.
2.For you to win the contest it is necessary and sufficient that you have the
only winning ticket.
Sol You win the contest if and only if you hold the only winning ticket.
3.If you read the news paper every day, you will be informed and conversely.
Sol You will be informed if and only if you read the news paper every day.
5.The train runs late on exactly those days when I take it.
Sol The train runs late if and only if it is a day I take the train.
p q pq ~q ~p ~ q ~ p (pq) (~ q ~ p)
T T T F F T T
T F F T F F T
F T T F T T T
F F T T T T T
4-Biconditional
p ~r qr
LOGICAL EQUIVALENCE
INVOLVING BICONDITIONAL
Show that ~pq and p~q are logically equivalent
p q ~p ~q ~pq p~q
T T F F F F
T F F T T T
F T T F T T
F F T T F F
EXERCISE
:
Show that ~(pÅq) and pq are logically equivalent
p q pÅq ~(pÅq) pq
T T F T T
T F T F F
F T T F F
F F F T T
same truth values
4-Biconditional
LAWS OF LOGIC
:
1.Commutative Law: pqqp
2.Implication Laws: p q ~p q
~(p ~q)
3.Exportation Law: (p q)r p (q r)
4.Equivalence: p q (p q)(q p)
5.Reductio ad absurdum p q (p ~q) c
APPLICATION
:
Rewrite the statement forms without using the symbols or
1.p~qr 2. (pr)(q r)
SOLUTION
1.p~qr (p~q)r order of operations
~(p~q) r implication law
2.(pr)(q r) (~p r)(~q r) implication law
[(~p r) (~q r)] [(~q r) (~p r)]
equivalence of biconditional
[~(~p r) (~q r)] [~(~q r) (~p r)]
implication law
Rewrite the statement form ~p q r ~q to a logically equivalent form that uses
only ~ and
SOLUTION
STATEMENT REASON
SOLUTION
STATEMENT REASON
EXERCISE
:
Suppose that p and q are statements so that pq is false. Find the truth values
of each of the following:
1.~ p q
2.p q
3.q p
SOLUTION
1.TRUE
2.TRUE
3.FALSE
4-Biconditional
4-Biconditional
4-Biconditional
4-Biconditional
5-Arguments
5-Argument
:
An argument is valid if the conclusion is true when all the premises are true.
Alternatively, an argument is valid if conjunction of its premises imply conclusion.
That is (P1 P2 P3 . . . Pn) C is a tautology.
An argument is invalid if the conclusion is false when all the premises are true.
Alternatively, an argument is invalid if conjunction of its premises does not imply
conclusion.
EXAMPLE
:
Show that the following argument form is valid:
pq
p
q
SOLUTION
premises conclusion
p q pq q p
T T T T T
T F F F T
F T T T F
EXERCISE
F F T F F
:
Use truth table to determine the argument form
pq
p ~q
5-Argument
pr
r
is valid or invalid.
premises conclusion
critical rows
t h ~t h ~h t ~t ~h
T T T T F
T F T T T
F T T T T
F F F F T
Argument is invalid. Because there are three critical rows ( Remember that the critical
rows are those rows where the premises have truth value T) and in the first critical row
conclusion has truth value F. (Also remember that we say an argument is valid if in all
critical rows conclusion has truth value T)
EXERCISE
5-Argument
If at least one of these two numbers is divisible by 6, then the product of these two
numbers is divisible by 6.
Neither of these two numbers is divisible by 6.
The product of these two numbers is not divisible by 6.
SOLUTION
Let d= at least one of these two numbers is divisible by 6.
p= product of these two numbers is divisible by 6.
Then the argument become in these symbols
dp
~d
~p
We will made the truth table for premises and conclusion as given below
d p d p ~d ~p
T T T F F
T F F F T
F T T T F
F F T T T
The Argument is invalid.
EXERCISE
If I got an Eid bonus, I’ll buy a stereo.
If I sell my motorcycle, I’ll buy a stereo.
If I get an Eid bonus or I sell my motorcycle, then I’ll buy a stereo.
SOLUTION:
Let e = I got an Eid bonus
s = I’ll buy a stereo
m = I sell my motorcycle
The argument is es
ms
e m s
e s m e s m s em em s
T T T T T T T
T T F T T T T
T F T F F T F
T F F F T T F
F T T T T T T
F T F T T F T
F F T T F T F
F F F T T F T
( Remember that the critical rows are those rows where the premises have truth value T)
and in all critical row conclusion has truth value T. (Also remember that we say an
argument is valid if in all critical rows conclusion has truth value T)
EXERCISE
An interesting teacher keeps me awake. I stay awake in Discrete Mathematics class.
Therefore, my Discrete Mathematics teacher is interesting.
Solution: t: my teacher is interesting a: I stay awake
m: I am in Discrete Mathematics class the argument to be tested is
t a,
am
Therefore mt
T a M ta am mt
T T T T T T
T T F T F F
T F T F F T
T F F F F F
F T T T T F
F T F T F F
F F T T F F
F F F T F F
Argument is not valid
5-
SWITCHES IN SERIES
P Q
Switches Light Bulb
Light bulb P Q State
Closed Closed On
Closed Open Off
open Open Closed Off
Open Open Off
c lo s e d
SWITCHES IN PARALLEL
:
P
Switches Light Bulb
P Q State
Q Closed Closed On
Light bulb Closed Open On
Open Closed On
Open Open Off
SWITCHES IN SERIES
:
Switches Light Bulb
P Q P Q
P Q State
T T T
Closed Closed On
T F F
Closed Open Off
F T F
Open Closed Off
F F F
Open Open Off
SWITCHES IN PARALLEL
5-
:
Switches Light Bulb
P Q P Q
P Q State
T T T
Closed Closed On
T F T
Closed Open On
F T T
Open Closed On
F F F
Open Open Off
1.NOT-gate
A NOT-gate (or inverter) is a circuit with one input and one output signal. If the
input signal is 1, the output signal is 0. Conversely, if the input signal is 0, then the output
signal is 1.
Input Output
P R
1 0
0 1
2.AND-gate
An AND-gate is a circuit with two input signals and one output signal.
If both input signals are 1, the output signal is 1. Otherwise the output signal is 0.
Symbolic representation & Input/Output Table
Input Output
P Q R
1 1 1
1 0 0
0 1 0
3. OR-gate
An OR-gate is a circuit with two input signals0 and0 one output
0 signal.
If both input signals are 0, then the output signal is 0. Otherwise, the output signal
is 1.
Symbolic representation & Input/Output Table
5-
P
R
Q OR
COMBINATIONAL CIRCUIT
:
A Combinational Circuit is a compound circuit consisting of the basic logic
gates such as NOT, AND, OR.
P
AND NOT
Q
OR
S
R
SOLUTION
:
Output S = 1
CONSTRUCTING THE INPUT/OUTPUT TABLE FOR A CIRCUIT
5-
P
AND NOT
Q
S
OR
LABELING
R INTERMEDIATE OUTPUTS
:
P X Y
AND NOT
Q
S
OR
R
P Q R X Y S
1 1 1 1 0 1
1 1 0 1 0 0
1 0 1 0 1 1
1 0 0 0 1 1
0 1 1 0 1 1
0 1 0 0 1 1
0
FINDING 0 1 EXPRESSION
A BOOLEAN 0 1 A CIRCUIT
FOR 1
0 0 0 0 1 1
P
OR
Q
AND
R OR
SOLUTION
:
Trace through the circuit from left to right, writing down the output of each logic gate.
5-
P PQ
Q OR
(PQ) (PR)
PR AND
R OR
Hence (PQ) (PR) is the Boolean expression for this circuit.
CIRCUIT CORRESPONDING TO A BOOLEAN EXPRESSION
EXERCISE
Construct circuit for the Boolean expression (PQ) ~R
SOLUTION
P PQ
Q AND (P Q) ~R
OR
~R
R NOT
INPUTS OUTPU
T
P Q R S
1 1 1 0
1 1 0 1
1 0 1 0
1 0 0 0
0 1 1 1
0 1 0 0
0 0 1 0
0 0 0 0
5-
SOLUTION
:
INPUTS OUTPUT
P Q R S
1 1 1 0
P Q ~R
1 1 0 1
1 0 1 0
1 0 0 0
0 1 1 1 ~P Q R
0 1 0 0
0 0 1 0
0 0 0 0
CIRCUIT DIAGRAM
:
P
Q AND S
R
OR
P
~P Q R
Q
EXERCISE : AND
PR
Q AND
NOT
OR
AND
AND
NOT
SOLUTION
5-
:
We find the Boolean expressions for the circuits and show that they are logically
equivalent, when regarded as statement forms.
STATEMENT REASON
(P Q) (~P Q) (P ~ Q)
(P Q) (~P Q) (P ~ Q)
(P ~P) Q (P ~ Q) Distributive law
t Q (P ~Q) Negation law
Q (P ~Q) Identity law
(Q P) (Q ~Q) Distributive law
(Q P) t Negation law
(Q P) t
QP identity law
PQ Commutative law
Thus (P Q) (~P Q) (P ~ Q) P Q
Accordingly, the two circuits are equivalent