Week 2 - Logic
Week 2 - Logic
2 LOGIC
The rules of logic specify the meaning of mathematical statements. It is the basis of all mathematical
reasoning (Rosen, 2012). Its application in the area of computer science is very vast that even the
computer itself defends on it, True or False, 1 or 0, and the presence or absence of bit. The study of logic
will increase your knowledge in formulating logical statements for the reason that program statements
and expressions are built from repeated application of logical operators. This module will help you
analyze arguments to determine the truth value of it.
Objectives:
1. Define Logic.
2. Appreciate the importance of Logic in mathematics.
3. Identify Propositions.
4. Convert Propositions to propositional variables.
5. Apply logical connectives to form compound propositions.
6. Construct and prove statements using Truth Table.
DISCRETE STRUCTURES 1 4
Logic
Definition
• Logic is the study of the methods and principles used to distinguish good (correct) from bad
(incorrect) reasoning.
• The term is derived from the Greek word logike – the feminine of the word logikos which means
“of reason.”
Importance of Logic
• Logic is the basis of all mathematical reasoning, and of all automated reasoning. It has practical
applications to the design of computing machines, to the specification of systems, to artificial
intelligence, to computer programming, to programming languages, and to other areas of
computer science, as well as to many other fields of study.
• The statement being supported is the conclusion of the argument and the statements that
support it are the premises of the argument.
3. Fuzzy Logic
Propositional Logic
• Propositional Logic or PL is that part of logic which deals with statements that are either true or
false but not both.
• The bases for propositional logic are the three laws of Aristotelian logic. These are:
– Law of Excluded Middle. “A statement is either true or false but not both.”
DISCRETE STRUCTURES 1 5
Logic
Example of Argument
If the program syntax is faulty or if program execution results in division by zero, then
the computer will generate an error message. Therefore, if the computer does not
generate an error message, then the program syntax is correct and program execution
does not result in division by zero.
• Propositional Logic or PL is that part of logic which deals with statements that are either true or
false but not both.
• The bases for propositional logic are the three laws of Aristotelian logic. These are:
– Law of Excluded Middle. “A statement is either true or false but not both”
Propositions
• The rules of logic gives precise meaning of mathematical statements. These rules are used to
distinguish valid and invalid mathematical arguments.
Example:
– 1+5=6
– The Earth revolves around the Sun
– 10 – 4 = 5
– Pigs can fly
– x+3=5
– x+y=z
– When is your birthday?
– Pass your assignment.
Sentences 1 and 2 are not propositions because they are neither true nor false.
Sentences 1 and 2 are not propositions because they are not declarative sentences.
DISCRETE STRUCTURES 1 6
Logic
Propositional Variable
Example:
Exercise
1. 10 is greater than 5
3. 5 + a = 10
Compound Proposition
Can be obtained by: Negating a proposition, or Combining two or more propositions using
logical connectives
Logical Connectives
The basic logical connectives are: not, and, or, if then, and if and only if.
Not is used to modify propositions while and, or, if then and if and only if are used to join
propositions.
DISCRETE STRUCTURES 1 7
Logic
Precedence Rules
In forming sentences, we put grouping symbols (parentheses, brackets, or braces). Without the
presence of grouping symbols, we will assume that the grouping will follow the precedence
rules for the logical connectives.
Logical Connectives
Not
And
Or
If then
If and only if
The connective with the higher priority will be considered first over the one with the lower
priority. Connectives having the same priorities are then considered from left to right.
Truth Table
A table that lists the truth value of the compound proposition for all possible values of its
proposition variables.
Truth tables can be used to show how these operators can combine propositions to form
compound propositions.
Negation (Not)
F: T
Proposition Negation
p : The sun is shining p : The sun is not shining
q : The program is running q : The program is not running
r : The value of x is positive r : The value of x is not positive
DISCRETE STRUCTURES 1 8
Logic
Conjunction (And)
In logic, the word “but” is sometimes used instead of conjunction “and”. Generally, the
word “but” is used in place of “and” when the part of the sentence that follows is, in some way,
unexpected.
Example:
Let
p : Mathematics is easy
The proposition will only result into TRUE if the statements p and q are both true. If one
of the statements results into False, the entire proposition will result into False.
Example:
Let
p : Today is Monday
Find p q
DISCRETE STRUCTURES 1 9
Logic
Disjunction (Or)
p : Mathematics is easy
The proposition will result into TRUE if the statements p or q are true. If one of the
statements results into True, the entire proposition will result into True.
Example:
Let
p : Today is Monday
Find p q
The notation for inequalities involves and and or statements. For instance, if x, a, and b
are particular real numbers, then
DISCRETE STRUCTURES 1 10
Logic
Exclusive or (XOR)
p q : Either the Earth revolves around the Sun or pigs can fly
TF:T p q pq
T T F
T F T
F T T
F F F
Example:
Let
p : Mathematics is easy
The proposition will only result into TRUE if one of the statements is true. If both
statements result into True or False, the entire proposition will also result to False.
Example:
Let
p : Today is Monday
Find p q
If p then q p q pq
p is sufficient for q T T T
q is necessary for p
T F F
F T T
p : Hypothesis
F F T
q : Conclusion
p q
DISCRETE STRUCTURES 1 11
Logic
Example:
Let:
pr sp
If 2 < 6, then 2 < 10 If 2 < 1, then 2 < 6
TT:T FT:T
ps st
If 2 < 6, then 2 < 1 If 2 < 1, then 5 < 3
TF:F FF:T
Example:
Let
p : Mathematics is easy
The proposition will only result into FALSE when p is true and q is false, and TRUE
otherwise. In the conditional statement p q, p is called hypothesis and q is called conclusion.
Example:
Let
p : Today is Monday
Find p q
DISCRETE STRUCTURES 1 12
Logic
Example:
Let
p : Mathematics is easy
The proposition will only result into TRUE when both p and q have the same value of
either True or False.
Example:
Let
p : Today is Monday
Find p q
Statements and operators can be combined in any way to form new statements.
Example:
p q p q p) v (q)
T T F F F
T F F T T
F T T F T
F F T T T
DISCRETE STRUCTURES 1 13
Logic
Exercise
1. ¬p q
2. p(qr)
3. ¬(p q ) (p q )
4. p (¬q r )
DISCRETE STRUCTURES 1 14
Logic
References:
1. Kenneth H. Rosen. Discrete Mathematics and Its Applications, 7th Edition. McGrawHill, 2012
2. Gary Weiss Damian Lyons, et al., Fundamentals of Discrete Structures, 2nd edition, Pearson
Learning Solutions, 2012.
3. Susanna S. Epp, Discrete Mathematics with Applications, Brooks Cole; 4th edition, 2011.
4. James L. Hein, Discrete Structures, Logic, and Computability, 3rd edition, Jones & Bartlett
Publishers, 3rd edition, 2009.
5. Kolman, B., Busby, R. C., Ross, S. C. Discrete Mathematical Structures, 6th Edition. Prentice Hall,
2008.
DISCRETE STRUCTURES 1 15