MCA Mathematical Foundation For Computer Application 01
MCA Mathematical Foundation For Computer Application 01
MCA Mathematical Foundation For Computer Application 01
01 Fundamentals of Logic
Names of Sub-Units
Introduction, Basic Connectives, Truth Tables, Logic Equivalence, the Laws of Logic, Logical Implication:
Rules of Inference, Quantifiers, Types of Quantifiers, Use of Quantifiers, Definitions and the Proofs of
Theorems
Overview
The Unit begins by explaining the meaning of logic and propositions with examples. Further, you will
study the basic connectives to combine two or more propositions and how to draw their truth tables.
Moving ahead, you will study the laws of logic and inferences. Also, you will acquire the knowledge
of quantifiers and their types. In addition to this, you will also grasp the knowledge of validating a
statement using the truth tables.
Learning Objectives
Learning Outcomes
https://www.geeksforgeeks.org/proposition-logic/
https://www.cs.purdue.edu/homes/spa/courses/cs182/mod1.pdf
1.1 INTRODUCTION
One distinctive feature that differentiates human beings from other species of animals is his ability to
think and act logically in any situation of life. Humans have the ability to think critically and solve complex
problems related to life through logical reasoning. Thinking logically to solve complex life problems and
making the important decision of life is one of the most important traits of being successful. There are
hundreds of things you do every day where you make use of logic without consciously knowing that you
are making use of logic. For example, while playing ludo with your friend you think logically to decide
which ludo piece you should be moved so that the opponents piece does not land on your piece and your
piece is sent back to the start position. Similarly, when something rolls down your bed say the cap of
your bottle and you are not able to pick the thing with your hand, you think logically to decide to bring
a long stick or broom to get the thing out of your bed.
Thinking logically is the act of examining the circumstances and coming up with a rational solution.
In logical reasoning, one makes use of his reasoning skill or logic to analyse the facts or situation and
address the problem. Though the skill of thinking logically in any situation depends on person to person it
can be developed through activities such as brainstorming, participating in activities that require deep
thought and concentration such as content writing, socialising with other people as the environment
has a great role in your development and you study many things by observing, imaging the outcomes
of your decision.
Aristotle is the man who first tossed the term logic over 2000 years ago. Aristotle’s logical work is unique
and commendable especially “theory of the syllogism”. His most of the work is grouped under the title
“Organon” and still considered as the subject of interest for recent scholars.
Like in all spheres of life the logic plays a great role in computer applications too. Thinking logically is
one of the key traits for becoming successful computer professionals as one can develop any software,
application, program, game, hardware or coding language only if one has ability to think rationally.
Before moving ahead, you should understand the term proposition for solving complex problems on
logic in computer applications.
2
UNIT 01: Fundamentals of Logic JGI JAIN
DEEMED-TO-BE UNI VE RSI TY
1.2 PROPOSITION
A proposition is a declarative sentence that has a truth value that is it is either true or false but not both
at the same time.
Firstly, according to this definition, the proposition is a declarative sentence. A declarative sentence is a
statement that communicates facts or information.
Secondly, a proposition has a truth value that is either they are true or false.
Consider the following sentences:
p: Window is an operating system.
q: MS window is an application software.
r: Linux is better than MS Windows.
While the first sentence is true and the second is false, you cannot say anything about the third sentence
as different people may have different views regarding which operating system is better Linux or MS
windows. Thus, the third sentence does not have any truth value as it is true of some people and for
others it is false. Hence, the third sentence cannot be considered as a proposition as it does not have
any truth value. While the first two sentences can be considered as a proposition as they are declarative
sentences and have the truth value the third sentence cannot be considered as a proposition.
Now, consider the following sentences:
p: Is window an operating system?
q: Complete the PowerPoint presentation.
r: Wow! What a great presentation it was.
Now, here the first sentence is a question, the second sentence is a command and the third sentence
is an exclamation. Thus, all these are not the proposition. Thus, no question, command, request or
exclamation can be called a proposition.
Proposition is usually represented by small letters p, q, r, etc.
3
JGI JAIN
DEEMED-TO-BE UNI VE RSI TY
Mathematical Foundation for Computer Application
“p: Unix and Mainframe OS are the multiuser operating system.” can be written as two simple
propositions as follows.
q: Unix is a multiuser operating system.
r: Mainframe OS is a multiuser operating system.
4
UNIT 01: Fundamentals of Logic JGI JAIN
DEEMED-TO-BE UNI VE RSI TY
5. Biconditional Proposition: If p and q are two simple propositions, then the proposition formed
by combining these two propositions by using the word if and only if (also written as iff) is called
Biconditional Proposition. The biconditional proposition “p if and only if q” is symbolically written
as p q or p q.
Example:
p: A B and B A
q: A=B
p q: If A B and B A if and only if A=B.
p q pq
True True True
True False False
False True False
False False False
5
JGI JAIN
DEEMED-TO-BE UNI VE RSI TY
Mathematical Foundation for Computer Application
p q pq
True True True
True False True
False True True
False False False
p ~p
True False
False True
p q pq
True True True
True False False
False True True
False False True
6
UNIT 01: Fundamentals of Logic JGI JAIN
DEEMED-TO-BE UNI VE RSI TY
p q pq
True True True
True False False
False True False
False False True
Example 1
Find the truth value of following compound proposition when proposition p and q are as follows:
p: Python is a programming language.
q: Firefox is a programming language.
a. p q
b. p q
Solution
You know that python is a programming language but firefox is an example of web browser. Therefore,
here proposition ‘p’ is true, whereas the proposition ‘q’ is false.
Thus, the truth value of given compound propositions are as follows:
a. p q : Python and Firefox are programming languages.
p q p q
True False False
b. p q : Python or Firefox is a programming language.
p q p q
True False True
Example 2
Draw the truth table of the following proposition:
p: Printer can print on both sides of paper.
7
JGI JAIN
DEEMED-TO-BE UNI VE RSI TY
Mathematical Foundation for Computer Application
Solution
a. p q : If a printer can print on both sides of paper, then it is duplex a duplex printer.
p q pq
True True True
True False False
False True True
False False True
b. p q : Printer can print on both sides of the paper if and only if it is duplex.
p q pq
True True True
True False False
False True False
False False True
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
Since both (p q) and pq have the same truth table, therefore, the two given logical statements
are equivalent, i.e., (pq)pq.
Example 4
If p and q are two proposition then prove that (pq)pq.
8
UNIT 01: Fundamentals of Logic JGI JAIN DEEMED-TO-BE UNI VE RSI TY
Solution
Since both (p q) and pq have the same truth table, therefore, the two given logical statements are
equivalent, i.e., (p q)pq.
The logical statements (p q)pq and (p q)pq are known as De Morgan’s law.
p p pp
T F F
F T F
9
JGI JAIN
DEEMED-TO-BE UNI VE RSI TY
Mathematical Foundation for Computer Application
p p pp
T F T
F T T
6. Domination law: Let p be any proposition. Then the domination law states that the conjunction of
p with any false proposition is always false and disjunction of p with any true proposition is always
true.
Thus, p F F (∵ conjunction of two proposition is true only when both of them are true and when
we know that one of them is false then the conjunction of two proposition will obviously be false.)
And p T T (As we know the disjunction of two propositions is true when either one or both of the
propositions are true. Here, as you know that one of the propositions is true so the disjunction of p
and True proposition will be true whether p is false or true)
7. Identity law: Let p be any proposition. This law states that the truth value of conjunction of p with
any true proposition will be equal to the truth value of p and truth value of disjunction of p with any
false proposition will be equal to the truth value of p.
Thus,
p T p and p F p
This can be shown on the truth table as below:
p T pT
T T T
F T F
Note, here truth values of p and p T are the same.
p F pF
T F T
F F F
Note here the truth value of p and p F are the same.
8. Absorption law: Let p and q be any two propositions then according to absorption law:
p (p q) p and p (p q) p
Representing p (p q)on the truth table, we get
p q pq p(pq)
T T T T
T F T T
F T T F
F F F F
Thus the truth value of both p and p (p q) are the same. Thus, p and p (p q) are logically equivalent
propositions.
10
UNIT 01: Fundamentals of Logic JGI JAIN
DEEMED-TO-BE UNI VE RSI TY
p q pq p(pq)
T T T T
T F F T
F T F F
F F F F
Thus the truth value of both p and p (pq) are the same. Thus, p and p (p q) are logically equivalent
propositions.
p q
p
q
Here, p q and p are two premises. Now, if p q and p both are true, then obviously q must be true. So
this is a valid argument.
Now consider the argument
p q
q
p
11
JGI JAINDEEMED-TO-BE UNI VE RSI TY
Mathematical Foundation for Computer Application
Here, p q and q are two premises. Now, if p q and q both are true, then nothing can be said about
p whether it will be true or false. As in both case whether p is true or false the premises p q and q
will remain true. Hence, these premises do not imply that p will be true only. Thus, this is an invalid
argument.
1.6.2 Inference
The inference is the process of drawing conclusion on the basis of premises or the assumptions. Rule
of Inferences is the templates or models for constructing a valid argument. They are themselves valid
arguments and are used for constructing a more complicated valid argument.
1. Modus Ponens Rule: This states that if p q and p are true then q will also be true. This can be
written as:
p q
p
q or [(p q) p] q
2. Modus Tollens: According to this rule if p q and q are true then ∼ p will also be true. Now if
p q is true therefore q has to be true when p is true. But it is given that ∼ q is true. Hence, q will be
false. Therefore, p q will become false if p is true and q is false. Hence, p will be false and ∼ p will
be true. This can be written as:
p q
∼q
∼p or [(p q) ∼ q] ∼ p
3. Hypothetical Syllogism: According to this rule if p q and q r are true then p r will also be
true. Now, if p is true q will also be true and if q is true r will also be true so p r will be a true
statement. This can be written as follows:
p q
q r
p r or [(p q) (p q)] (p r)
4. Disjunctive Syllogism: According to this rule if (p q) and ∼ p are true then q will be true. Now, p will
be true only when p is false. Therefore p is false. And p q will be true when p or q is true. But as p is
false so q will be true. As both q and (p q) are true, therefore, (p q) ∼ p will be true. This can be
shown on the truth table as follows:
p –p q p q (p q) ∼ p
F T T T T
F T T T T
Disjunctive syllogism can be written as
(p q)
–p
q (p q) ∼ p q
12
UNIT 01: Fundamentals of Logic JGI JAIN
DEEMED-TO-BE UNI VE RSI TY
5. Addition: According to this rule if p is true then p q will be true. This is obvious as p q will remain
true whether q is false or true as p is true. This can be written as follows:
p
p q or p p q
6. Simplification: According to this rule if p q is true, then p and q both are true. This is obvious. This
can be written as follows:
p q or p q
p q
OR
(p q) p (p q) q
7. Conjunction Rule: According to this rule if p is true and q is true then p q will also be true. This can
be written as:
p
q
p q or [(p) (q)] (p q)
8. Resolution Rule: According to this rule if (p q) and ( ∼ p r) is true then q r is true. This can be
proved as follows.
Case I
Consider q to be false. Then p is true as (p q) is true and q is false. Therefore, ∼ p will be false. Hence,
r is true as ( ∼ p r) is true.
Hence the conclusion (q r) is true as r is true.
Case II
Consider q to be true. So in case to conclusion (q r) will be true considering the fact whether r is
true or false.
Therefore, Resolution Rule can be written as follows:
(p q)
(p r)
qr or (p q) (p r)qr
Example 6
Which rule of inference is used in each of these arguments?
a. Premises1: If the printer is monochrome, then it will print in black ink only.
Premises 2: HP Laserjet P1108 is a monochrome printer.
Conclusion: HP LaserJet P1108 prints in black ink only.
b. Premises 1: If the printer is duplex it can print on both sides of the paper.
Premises 2: HP Ink tank 315 colour printer cannot print on both sides of the paper.
Conclusion: HP Ink tank 315 colour printer is not the duplex printer.
13
JGI JAIN
DEEMED-TO-BE UNI VE RSI TY
Mathematical Foundation for Computer Application
Solution
a. It follows Modus Ponens Rule, i.e., [(p q) p] q
b. It follows Modus Tollens Rule, i.e., [(p q) ∼ q] ∼ p
c. It follows the Hypothetical Syllogism Rule, i.e., [(p q) (p q)] (p r)
d. It follows Disjunctive Syllogism, i.e., (p q) ∼ p q
e. As the first premise is true here and the second is false it follows the addition rule i.e. p p q
Example 7
Draw the conclusion using the law of inference from the following premises if the given premises are
true.
a. Premises 1: Keshav will research about device driver or Keshav will research about programming
language.
Premises 2: Keshav will not research device drivers or Keshav will research graphic programs.
b. Premises 1: Photoshop or Thunderbird is graphic software.
Premises 2: Thunderbird is not graphic software.
Solution
a. Let p: Keshav will research about device driver.
q: Keshav will research programming language.
r: Keshav will research graphic programs.
We know both premises 1 and 2 are true, i.e., (p q) ( ∼ p q) is true.
Therefore, by the resolution rule, we can conclude
Keshav will research programming language or Keshav will research graphic programs.
b. Let p : Photoshop is a graphic software.
q : Thunderbird is graphic software.
Now both the premises are true i.e. (p q) ∼ q is true. Therefore, by disjunction rule, you can
conclude p is true, i.e., Photoshop is a graphic program.
14
UNIT 01: Fundamentals of Logic JGI JAIN
DEEMED-TO-BE UNI VE RSI TY
1.7 QUANTIFIERS
Quantifiers are the words and phrases that give details about the quantity or number of objects or
persons.
From these two sentences, you can conclude that “All printers are hardware”
Rule of Inference for Quantified Statement
We make some important conclusions from the premises involving quantifiers. The rules of inferences
of the quantified statement are as follows:
1. Universal instantiation rule: If a property P(x) is true for all elements ‘x” in a group, then it must be
true for a particular element in that group.
Example:
Premise 1: All web browsers are application software.
Premise 2: Firefox is a web browser.
Conclusion: Firefox is an application software.
2. Universal generalisation: If a property p(x) is true for an element ‘c’ in a group then it must be true
for all elements of that group.
Example:
Premise 1: “A number divisible by 10 is an even number”
Conclusion: All numbers divisible by 10 are even numbers.
15
JGI JAIN
DEEMED-TO-BE UNI VE RSI TY
Mathematical Foundation for Computer Application
3. Existential instantiation: According to this law there exist some c in the given domain for which the
property p(x) is true. We use the symbol ‘ ’ for denoting the words “there exist”
Example
There exist a natural number that is even and prime.
So, according to this statement there exist at least one element in the domain N of a natural number
that is even and prime.
4. Existential generalisation: According to this rule if the property p(x) is true for any element ‘c’ in the
domain then we can conclude that there exists at least one element x in the domain for which the
property p is true.
Example:
Premise: Reema in class X has long hair.
Conclusion: Someone in class X has long hair.
Example 8
What can you conclude from the following premises:
a. Premise 1: All operating systems are system software.
Premise 2: Android is an operating system.
b. Premise 1: All word processors are application software.
Premise 2: Google Doc is a word processor.
Solution
a. By Universal Instantiation Rule we can conclude
Android is system software.
b. By Universal Instantiation Rule we can conclude
Google Doc is an application software.
Example: p ∼ p
Contradiction
A proposition that is always false is called a contradiction.
Example: p ∼ p
Contingency
A proposition that is neither a tautology nor a contradiction is called contingency. Example: p q
16
UNIT 01: Fundamentals of Logic JGI JAIN
DEEMED-TO-BE UNI VE RSI TY
p q pq
T T T
T F T
F T T
F F F
Example 9
Validate the following statements:
a. ∼ (p q) ∼ p ∼ q
b. ∼ (p q) [p ( ∼ q)]
Solution
a. ∼ (p q) ∼ p ∼ q
We will validate this statement by using a truth table
p q p q – (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
– (p q) and ∼ p ∼ q have the same truth table. Therefore,
– (p q) ∼ p ∼ q
b. ∼ (p q) [p ( ∼ q)]
We will validate this statement by using a truth table.
p q p q – (p q) –q [p ( ∼ q)]
T T T F F F
T F F T T T
F T T F F F
F F T F T F
Thinking logically to solve complex life problems and making the important decision of life is one of
the most important traits of being successful.
Thinking logically is the act of examining the circumstances and coming up with a rational solution.
17
JGI JAINDEEMED-TO-BE UNI VE RSI TY
Mathematical Foundation for Computer Application
Aristotle is the man who first tossed the term logic over 2000 years ago. Aristotle’s logical work
is unique and commendable especially “theory of the syllogism”. His most of the work is grouped
under the title “Organon” and still considered as the subject of interest for recent scholars.
Laws of logic
Commutative law: If p and q are two propositions, then:
p q q p and
p q q p
Associative law: If p, q and r are three propositions, then
(p q) r p (q r) and (p q) r p (q r)
Distributive law: If p, q and r are three propositions, then
p (q r) (p q) (p r) and p (q r) (p q) (q r)
Idempotent law: If p is a proposition, then
p p p and p p p
Inverse law: The inverse law states that if p is a proposition then p ∼ p f and p ∼ p t where
‘f’ means false and ‘t’ means true.
Domination law: Let p be any proposition.
Then p F Fand p T T
Identity law: Let p be any proposition. Then,
p T p and p F p
Absorption law: Let p and q be any two propositions then according to absorption law:
p (p q) p and p (p q) p
Quantifiers are the words and phrases that give details about the quantity or number of objects or
persons. The two types of quantifiers are as follows:
Universal quantifier
Existential quantifier
You can make some important inferences from the premises involving quantifiers.
1.10 GLOSSARY
Proposition: A proposition is a declarative sentence that has a truth value that is it is either true or
false but not both at the same time.
Simple proposition: A proposition is called simple if it cannot be broken down into two or more
propositions.
Compound proposition: A proposition made of two or more simple propositions is called a compound
proposition.
Basic Connectives: The basic connectives also referred to as propositional connectives are the words
that are used to combine two or more simple propositions to form a compound proposition.
Components or elements of a propositional logic: When two or more propositions are combined to
form a compound proposition then the propositions combined are called elements or components
of the propositional logic.
18
UNIT 01: Fundamentals of Logic JGI JAIN
DEEMED-TO-BE UNI VE RSI TY
Truth table: Truth table is the tabular representation of the change in truth value of the compound
proposition with respect to the change in the truth value of its components or elements.
Logical statement: A logical statement is a statement consisting of two or more simple propositions
combined using basic connectives.
Logic equivalence: Two logical statements are logically equivalent if they have the same truth table.
We use the symbol ‘ ’ to denote two logical equivalent statements.
Logical implication: The conditional statements involving the words if-then are called logical
implications.
Premises and conclusion: Premises are the propositions or assumptions on the basis of which we
derive a conclusion.
Argument: A group or set of statements consisting of both premises and conclusion is known as an
argument.
Inference: Inference is the process of drawing conclusion on the basis of premises or the assumptions.
Tautology: A proposition that is always true is called a tautology.
Example: p ∼ p
Contradiction: A proposition that is always false is called a contradiction.
Example: p ∼ p
Contingency: A proposition that is neither a tautology nor a contradiction is called contingency.
Example p q
19
JGI JAIN
DEEMED-TO-BE UNI VE RSI TY
Mathematical Foundation for Computer Application
3. Write the negation of the following proposition.
a. p: Discord is a communication app.
b. p: MySQL is a database management system.
4. Draw the truth table for the following logical statements.
a. (p q) q
b. p ∼ q
5. Prove p ∼ (p q) is a tautology.
6. Show ∼ [p ∼ (p q)] is a contradiction.
7. Prove ∼ (p ( ∼ pq)) ∼ p ∼ q .
8. Draw the conclusion using the law of inference from the following premises if the given premises are
true.
a. Premises 1: Keshav will play football or Keshav play basketball.
Premises 2: Keshav will not play football or Keshav will play cricket.
b. Premises 1: RAM or mouse is an internal hardware.
Premises 2: Mouse is not an internal hardware.
a. Let p: Keshav will play football.
q: Keshav will play basketball.
r: Keshav will play cricket.
We know both premises 1 & 2 are true i.e. (p q) ( ∼ p q) is true.
Therefore, by the resolution rule, you can conclude
Keshav will basket ball or Keshav will play cricket.
b. Let p : RAM is an internal hardware.
q :Mouse is an internal hardware.
Now, both the premises are true i.e. (p q) ∼ q is true. Therefore, by disjunction rule, you can
conclude p is true i.e. RAM is an internal hardware.
20
UNIT 01: Fundamentals of Logic JGI JAIN
DEEMED-TO-BE UNI VE RSI TY
p q∼q p∼q
T T F F
T F T T
F T F F
F F T F
5. p ∼ (p q)
p q pq – (p q) p ∼ (p q)
T T T F T
T F F T T
F T F T T
F F F T T
Since in all cases Truth value of p ∼ (p q) is true, therefore it is a tautology.
6. The answer is as follows:
p q p q – (p q) p ∼ (p q) ∼ [p ∼ (p q)]
T T T F T F
T F F T T F
F T F T T F
F F F T T F
21
JGI JAINDEEMED-TO-BE UNI VE RSI TY
Mathematical Foundation for Computer Application
T T F F F T F F
T F F T F T F F
F T T F T T F F
F F T T F F T T
Since ∼ (p ( ∼ pq)) and ∼ p ∼ q have same truth table they are logically equivalent.
8. The conclusion is as follows:.
a. Premises 1: Keshav will play football or Keshav play basket ball.
Premises 2: Keshav will not play football or Keshav will play cricket.
b. Premises 1: RAM or mouse is an internal hardware.
Premises 2: Mouse is not an internal hardware.
https://math.libretexts.org/Courses/Monroe_Community_College/MATH_220_Discrete_
Math/2%3A_Logic/2.5%3A_Logical_Equivalences
https://sites.millersville.edu/bikenaga/math-proof/truth-tables/truth-tables.html
22