LOGIC
LOGIC
LOGIC
Introduction
Application of Logic
Examples
(i) Amina is the most beautiful girl in the class.
(ii) Tanzanians are the best in pure mathematics.
61
Statement is a group of words which can be judged to be true or false but not
both.
Example
Naomi is beautiful
Mayombya likes Mathematics
Eva is tall but Salome is fat
Two is greater than four
Dodoma is a capital city of Tanzania.
Every square is a rectangle .
Conjunction is denoted by
Example 1
The sky is blue and the grass is green.
Let p The sky is blue
q The grass is green
Connective is ' and'
Symbolically is p q
Example 2
Draw the truth table of p q
Solution
p q pq
T T T
T F F
F T F
F F F
63
Example 3
Draw the truth table of p q r
Solution
p q r pq p q r
T T T T T
T F T F
T F T F F
T F F F F
F T T F F
F T F F F
F F T F F
F F F F F
(ii) Disjunction ( )
Disjunction is the connective in which the statement is said to true if at least
one proposition is true.
Connective words which stands for Disjunctions are or, either or, etc.
Disjunction is denoted by
Example 4
Robert is reading or writing
Let p Robert is reading
q Robert is writing
connective is ' or'
Symbolically is p q
64
Example 5
Draw the truth table of p q
Solution
p q pq
T T T
T F T
F T T
F F F
65
Example 6
If you study hard then you will pass an examination.
Solution
p You study hard
q You will pass an examination
Connective word is " If....then....."
If p then q p q
Example 7
Draw the truth table of p q
Solution
p q pq
T T T
T F F
F T T
F F T
Example 8
You can take the flight if and only if you buy a ticket.
p you can take the flight
q you buy a ticket
Connective word is "iff "
p iff q p q
66
Example 9
Draw the truth table of p q
Solution
p q pq
T T T
T F F
F T F
F F T
(v) Negation
This is the opposite of the stated statement, and denoted by ~
If p is a given statement, its negation is ~ p
Example 10
Peter is clever p
Peter is not clever ~ p
T F
F T
67
OTHER LOGICAL CONNECTIVES
This involves two common connectives namely as
(a) Exclusive disjunction
A mathematical statement is said to be exclusive disjunction if the results of the
truth table is said to be true if one of them is true but not both otherwise is false.
The exclusive disjunction of p and q is denoted by pq read as either
p or q but not both of them.
Example 11
Draw the truth table of pq
Solution
p q pq
T T F
T F T
F T T
F F F
Example 12
Draw the truth table of p q
Solution
p q pq
T T F
T F F
F T F
F F T
68
3.3 TRUTH TABLES FOR SIMPLE AND COMPOUND STATEMENTS
Simple and compound statements can be expressed in symbolic form,
Let p = first proposition, q second proposition, r third proposition etc ,
then connect the symbols by using the specified connectives. Now from
symbolic logic connectives its possible to draw the truth table.
Example 13
Change into symbolic logical form and draw the truth table of the statement
“If I am clever then I understand logic”
Solution
Let P= I am clever
q= I understand logic
In symbolic form p q
Truth table
p q pq
T T T
T F F
F T T
F F T
Example 14
Change into symbolic logical form and draw the truth table of the statement
“If today is Monday then tomorrow is Tuesday”
Solution
Let P= today is Monday
q= tomorrow is Tuesday
In symbolic form p q
Truth table
p q pq
T T T
T F F
F T T
F F T
69
Example 15
Change into symbolic logical form and draw the truth table of the statement
“If I like Mathematics or I study then I will pass”
Solution
Let P= I like mathematics
q= I study
r= I will pass
In symbolic form p q r
Truth table
p q r p q p q r
T T T T T
T T F T F
T F T T T
T F F T F
F T T T T
F T F T F
F F T F T
F F F F T
Example 16
Change into symbolic form the statement “If my brother stands first in the class,
I will give him a phone. Either he stands first or I was out of station. I didn’t
give my brother a phone this time. Therefore I was out of station”
Solution
Let P= He stands first in the class
q= I will give him a phone
r= I was out of station
Symbolic logical form p q p r ~ q r
70
Equivalent of propositions
Two or more propositions are said to be equivalent if they have the same truth
value on the truth table.
Example 17
Determine whether the sentences p q and q p are equivalent.
Solution
p q pq q p
T T T T
T F T T
F T T T
F F F F
From the table above the column for p q is the same as the column for q p .
The given propositions are equivalent ie. p q q p .
Example 18
Determine whether the sentences p q and ~ p q are equivalent.
Solution
p q ~ p p q ~ pq
T T F T T
T F F F F
F T T T T
T F F T T
From the table above the column for p q is the same as the column
for ~ p q .
The given propositions are equivalent ie. p q ~ p q .
71
Example 19
Determine whether the sentences p q and p q q p are
equivalent.
Solution
p q pq q p pq p q q p
T T T T T T
T F F T F F
F T T F F F
T F F T T T
From the table above the column for p q is the same as the column
for p q q p .
The given propositions are equivalent p q p q q p
Example 20
Determine whether the sentences p q and ~ p q ~ q p are
equivalent.
Solution
p q ~p ~q ~ pq ~ q p pq ~ p q ~ q p
T T F F T T T T
T F F T F T F F
F T T F T F F F
T FT FT T T T
From the table above the column for p q is the same as the column
for ~ p q ~ q p .
The given propositions are equivalent p q ~ p q ~ q p
72
3.4 Tautologies, contradictions and equivalent statements
(i) Tautology
A compound statement is said to be tautology if it contains all True values
(T) in the last column of its truth table.
(ii) Contradiction
A compound statement is said to be contradiction if it contains all False
values (F) in the last column of its truth table.
(iii)Logical contigency
A compound statement is said to be contigent if it contains at least one T
and F in each row of its truth table.
(iv) Fallacy
Fallacy is the incorrect argument in logic or incorrect reasoning
73
(i) Converse of the conditional statement
Converse is the reverse of conditional statement.
If p q is the conditional statements then its converse is q p .
i.e.
Statement p q
Converse q p
Example 21
Write the converse, contrapositive and inverse of the statement “If Juma is a
poet, then he is poor”
Solution
Converse “If Juma is poor, then he is a poet”
Contrapositive “If Juma is not poor, then he is not a poet”
Inverse “If Juma is not a poet, then he is not poor”
Example 22
Write the converse, contrapositive and inverse of the statement “If it rains, then
they cancel school.”
Solution
Converse "If they cancel school, then it rains."
Contrapositive "If they do not cancel school, then it does not rain."
Inverse “If it does not rain, then they do not cancel school.”
74
Example 23
Write the converse, contrapositive and inverse of the statement “If two angles
are congruent, then they have the same measure.”
Solution
Converse “If two angles have the same measure, then they are congruent.”
Contrapositive “If two angles do not have the same measure, then they are not
congruent.”
Inverse “If two angles are not congruent, then they do not have the same
measure.”
Example 24
Write the converse, contrapositive and inverse of the statement “If a
quadrilateral is a rectangle, then it has two pairs of parallel sides.”
Solution
Converse “If a quadrilateral has two pairs of parallel sides, then it is a
rectangle.”
Contrapositive “If a quadrilateral does not have two pairs of parallel sides, then
it is not a rectangle.”
Inverse “If a quadrilateral is not a rectangle, then it does not have two pairs of
parallel sides.”
Example 25
Write the converse, contrapositive and inverse of the statement “If a person is
18 years old, then he is a legal adult.”
Solution
Converse “If a person is a legal adult, then he is 18 years old.”
Contrapositive “If a person is not a legal adult, then he is not 18 years old.”
Inverse “If a person is not 18 years old, then he is not a legal adult.”
75
3.6 LAWS OF ALGEBRA OF PROPOSITION
The following are laws of algebra used to simplify propositions;
(iii)Distributive law
p q r p q p r
p q r p q p r
76
Example 26
Use the algebra propositions to simplify the following expression
p q p q
Solutions
p q p q .......... .......... .......... .......... ..given
p q q p p q .......... .......... ......by defition
~ ~ p q ~ q p ~ p q .......... .......... ..by defition
~ ~ p q ~ ~ q p ~ p q .......... .......... Demorgan's law
~ ~ p q ~ p q ~ ~ q p .......... .......... commutative law
T ~ ~ q p .......... .......... .......... .......... .......... ..complement law
T .......... .......... .......... .......... .......... .......... .........identity law
Example 27
Determine whether the following proposition is a tautology
p ~ q q r p r
Solution
p ~ q q r p r.......... .......... ..given
~ ~ p ~ q q r p r.......... .......... by definition
~ ~ p ~ q p q r r.......... .......... commutative law
~ ~ p p ~ q p q r r.......... ..distributive law
~ F ~ q p q r r.......... ............ complement law
~ ~ q p q r r.......... ............ ......iden tity law
~ ~ q p ~ q r r.......... ............ ....Demorgan' s law
q ~ p ~ q ~ r r.......... ............ ....Demorgan' s law
q ~ p ~ q r ~ r r .......... ........dist ributive law
q ~ p ~ q r T .......... ............ .....compliment law
q ~ p ~ q r .......... ........... .......... ...identity law
q ~ q ~ p r .......... ........... .......... ...commutative law
T ~ p r .......... ........... .......... .......... ..complement law
T .......... ........... .......... .......... .......... .........i dentity law
77
Example 28
Simplify the following using laws p p q ~ p
Solution
p p q ~ p.......... .......... .......... .given
~ p p q ~ p.......... .......... .......... by definition
~ p ~ p q ~ p.......... .......... .......... Demorgan's law
~ p ~ p ~ q ~ p.......... .......... ........ Demorgan's law
~ p F ~ p ~ q ~ p.......... .......... identity law
~ p F ~ q ~ p.......... .......... .......... distributive law
~ p F ~ p.......... .......... .......... .......... identity law
~ p ~ p.......... .......... .......... .......... ........identity law
~ p.......... .......... .......... .......... .......... .......idempotent law
Example 29
Simplify by using law of algebra p q q
Solution
p q q.......... .......... .......given
~ p q q.......... .......... ....... by definition
~ p ~ q q.......... .......... .....Demorgan law
~ p ~ q q .......... .......... .....associative law
~ p T .......... .......... .......... .....complement law
T .......... .......... .......... .......... ....identity law
Example 30
Simplify by using law of algebra p p q ~ p
Solution
p p q ~ p.......... .......... ..given
~ p p q ~ p.......... .......... .by definition
~ p ~ p q ~ p.......... ......... Demorgan law
~ p ~ p ~ q ~ p.......... ......Demorgan law
~ p F ~ p ~ q ~ p........identity law
~ p F ~ q ~ p.......... .........distributive law
~ p F ~ p.......... .......... .........identity law
~ p ~ p .......... .......... .......... .....identity law
~ p.......... .......... .......... .......... .....idempotent law
78
Example 31
Simplify the following proposition by deductive reasoning p q ~ q p
Solution
p q ~ q p .......... .......... ....given
~ p q ~ ~ q p .......... ......... by definition
~ p ~ q q ~ p .......... ......... Demorgan's law
~ p ~ p ~ q q .......... ......... commutative law
~ p ~ q q .......... .......... ......... idempotent law
~ p F .......... .......... .......... ......... complement law
F .......... .......... .......... .......... .......identity law
Exercise 3.1
1. Simplify the expression p q q by using algebra laws
2. Simplify the following by using algebra laws ~ p q ~ p q
Principle of Validity
The premises represented by P1 P2 P3 Pn are joined using connective
“and” or “ ” and the conclusion is given by words like “Thus” or “Therefore”
and denoted by “ ” an implication.
i.e. P1 P2 P3 Pn Conclusion
79
Example 32
Check if the following argument is valid “If I am clever then I understand
Logic. I don’t understand Logic. Therefore I am not clever”
Solution
Let p I am clever
q I understand Logic
Compound statement p q ~ q ~ p
p q ~ p ~ q p q p q ~ q p q ~ q ~ p
T T F F T F T
T F F T F F T
F T T F T F T
F F T T T T T
Alternative
p q ~ q ~ p
~ p q ~ q ~ p By definition
~ ~ p q ~ q ~ p By definition
~ ~ p q q ~ p De Morgan' s law
p ~ q q ~ p De Morgan' s law
p q ~ q q ~ p Distributive law
p q T ~ p Complement law
p q ~ p Identity law
q p ~ p Commutative law
q p ~ p Associative law
qT Complement law
T Identity law
Hence the argument is valid because it is TAUTOLOGY
80
Example 33
Determine whether the following proposition is true or not
p ~ q q r p r by using laws.
Solution
p ~ q q r p r.......... .......... ......... given
~ p ~ q q r p r.......... .......... ........ definition
~ ~ p ~ q q r p r.......... .......... ......definition
~ ~ p ~ q p q r r.......... .......... ......commutative law
~ ~ p p ~ q p q r r.......... .......... distributive law
~ F ~ q p q r r.......... .......... .......... .complement law
~ ~ q p q r r.......... .......... .......... .......identity law
~ ~ q p ~ q r r.......... .......... .......... .....demorgan's law
q ~ p ~ q ~ r r.......... .......... .......... .....demorgan's law
q ~ p ~ q ~ r r .......... .......... .......... .....associative law
q ~ p ~ q r ~ r r .......... .......... ........distributive law
q ~ p ~ q r T .......... .......... .......... .......complement law
q ~ p ~ q r .......... .......... .......... .......... ....identity law
q ~ q ~ p r .......... .......... .......... .......... ....commutative law
T ~ p r .......... .......... .......... .......... .......... ....complement law
T .......... .......... .......... .......... .......... .......... .......... .identity law
Exercise 3.2
1. Test the validity of the following arguments p ~ q , ~ r q , r ~ p
2. Test the validity of the following argument p ~ q, r q, q Ⱶ ~ r
81
Point to note in electrical networks
(i) The current will flow from T1 to T2 only if the switch is closed and
not otherwise.
(ii) The current may not flow from T1 to T2 only if the switch is open
and not otherwise.
(iii) The flow of current is denoted by T while not flow of current is
denoted by F .
(iv) Negation always implies opening of switch and its vice versa is
true.
Connection of Switches
There are two connections of switches namely;
(a) Series connection
(b) Parallel connection
Logically is represented by p q
Logically is represented by p q r
82
(b) Parallel connection
Parallel connection is the connection in which two or more
switches are connected in a side way.
Series connection use disconjunction connective.
Logically is represented by p q
Logically is represented by p q r
83
Example 35
Construct the network for p q r
Solution
Example 36
Construct the network for p q r s
Solution
Example 37
Construct the network for p q r s
Solution
Example 38
Construct the network for p q r s
Solution
84
Example 39
Construct the network for p q
Solution
p q ~ p q ~ q p
Alternative
Example 40
Draw the electrical network for the proposition ~ p q ~ p q
Solution
~ p q ~ p q
~ p q ~ p q ~ p ~ q ~ p q ........De Morgan' s law
Example 41
Use the laws of algebra of proposition to simplify the statement
q p ~ q r q and hence draw the corresponding simple
electrical network.
Solution
85
q p ~ q r q .......... ......given
q p q ~ q r q ......... distributive law
q p T r q .......... ........ .compliment law
q p r q .......... ........ .......ide ntity law
q p q r .......... ........ .......commutative law
q p r .......... ........ .......... .....distributive law
Example 42
Use the laws of algebra to simplify the statement
p q r ~ q ~ p ~ r and hence draw the corresponding simple
electrical network.
Solution
p q r ~ q ~ p ~ r .......... .......... .......... ......given
p q r q ~ q ~ p ~ r .......... .......... ......... distributive law
p q r F ~ p ~ r .......... .......... .......... ........ complement law
p q r ~ p ~ r .......... .......... .......... ........ ......iden tity law
p q r ~ p ~ r .......... .......... .......... .......... ......asso ciative law
86
Example 43
Simplify the logical proposition below and draw its corresponding electrical
network r ~ p q p
Solution
r ~ p q p .......... .......... .......... ......given
r p q p .......... .......... .......... .......... by definition
r p p q p .......... .......... .......... ..distributive law
r p q p .......... .......... .......... .......... idempotent law
r p T q p .......... .......... .......... ...identity law
r p T p q .......... .......... .......... ...commutative law
r p T q .......... .......... .......... ...........di stributive law
r p T .......... .......... .......... ............. ......iden tity law
r p.......... .......... .......... ............. .......... ....identi ty law
Example 44
Determine the compound statement in words from the table below. Hence
draw electric diagram for the statement.
M N PM , N
T T F
T F F
F T T
F F F
Solution
Circle T from P in the truth table
~M N
Alternative
87
Example 45
Draw a simple network diagram corresponding to the statement of the
following truth table
x y z p
T T T F
T T F F
T F T
T F F T
F T T F
F T F T
F F T T
F F F T
Solution
On circling F
~ x ~ y ~ z ~ x ~ y z x ~ y ~ z .........given
~ x ~ y ~ z z x ~ y ~ z ......... .......... .....distributive law
~ x ~ y F x ~ y ~ z ......... .......... .......... .....complement law
~ x ~ y x ~ y ~ z ......... .......... .......... .......... ..identity law
~ y ~ x ~ y x ~ z ......... .......... .......... .......... ..commutative law
~ y ~ x x ~ z ......... .......... .......... .......... .......... distributive law
~ y ~ x x ~ x ~ z ......... .......... .......... .......... distributive law
~ y F ~ x ~ z ......... .......... .......... .......... .......... complement law
~ y ~ x ~ z ......... .......... .......... .......... .......... .......ide ntity law
88
Example 46
A statement J is formed from P, G and M . Write J in most simplified
form and use it to draw an electric circuit which will allow the current to
flow whenever J is true
P G M J
T T T T
T T F T
T F T
T F F T
F T T T
F T F F
F F T F
F F F F
Solution
P G M P G ~ M P ~ G M P ~ G ~ M ~ P G M .......... given
P G M P G ~ M P ~ G M P ~ G ~ M ~ P G M .......given
P G M ~ M P ~ G M ~ M ~ P G M .......... .......... distributive law
P G T P ~ G T ~ P G M .......... .......... .......... .......... .......complement law
P G P ~ G ~ P G M .......... .......... .......... .......... .......... .......... ..identity law
P G ~ G ~ P G M .......... .......... .......... .......... .......... .......... .........d istributive law
P T ~ P G M .......... .......... .......... .......... .......... .......... .......... .......... complement law
P ~ P G M .......... .......... .......... .......... .......... .......... .......... .......... ........id entity law
P ~ P P G M .......... .......... .......... .......... .......... .......... .......... .........d estributive law
T P G M .......... .......... .......... .......... .......... .......... .......... .......... .........c omplement law
P G M .......... ......... .......... .......... .......... .......... .......... .......... .......... .......ide ntity law
89
Example 47
Draw the electrical diagram corresponding to the statement ~ p q q p
Solution
~ p q q p .......... .......... .......... .......... ...given
~ p ~ q q p .......... .......... .......... .......... Demorgan's law
Example 48
Draw a simple network for q p ~ q r ~ p
Solution
q p ~ q r ~ p .......... .......... .......... .....given
q p q ~ q r ~ p .......... .......... ..... .distributive law
q p T r ~ p .......... .......... ..... .......... .complement law
q p r ~ p .......... .......... ..... .......... ........id entity law
q p r q p ~ p.......... .......... ........di stributive law
q p r q p ~ p .......... .......... ........as sociative law
q p r q T .......... .......... .......... ........co mplement law
q p r T .......... .......... .......... .......... ......iden tity law
q p r.......... .......... .......... .......... .......... .....ident ity law
90
Example 49
Draw a simple network for s p, q, r having the truth table shown below.
p q r s
T T T T
T T F F
T F TT
T F F F
F T T F
F T F F
F F T F
F F F F
Solution
Circle T from the compound statement s from the table
p q r p ~ q r .......... .......... .......... ......... given
p r q p r ~ q .......... .......... .......... ......... commutative law
p r q ~ q .......... .......... .......... .......... .......... distributive law
p r T .......... .......... .......... .......... .......... .......... complement law
p r .......... .......... .......... .......... .......... .......... .....ident ity law
Exercise 3.3
1. Simplify the following by using laws, then draw a circuit diagram
p q ~ p r q r
2. Write in symbolic form the compound statement which represents the
following circuit diagram, where T1 and T2 are terminals
91