Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
9 views

Week 2 - Logic

Module for week 2

Uploaded by

Cyril James
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Week 2 - Logic

Module for week 2

Uploaded by

Cyril James
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

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:

After completing this module, you should be able to:

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.”

• Logic, then, is also defined as the study of reason.

Importance of Logic

• The rules of logic specify the meaning of mathematical statements.

• 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.

Arguments, Premises, Conclusion

• An argument, as it occurs in logic, is a group of propositions/statements which is divided into


one or more premises and one, and only one conclusion.

• The statement being supported is the conclusion of the argument and the statements that
support it are the premises of the argument.

Three types of Logic

1. Propositional Logic (PL)

2. First Order Predicate Logic (FOPL)

3. Fuzzy Logic

However, this course will focus only in Propositional 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 Identity. “A thing is itself.”

– Law of Excluded Middle. “A statement is either true or false but not both.”

– Law of Non-Contradiction. “No statement is both true and false.”

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 Identity. “A thing is itself”

– Law of Excluded Middle. “A statement is either true or false but not both”

– Law of Non-Contradiction. “No statement is both true and false”

Propositions

• The rules of logic gives precise meaning of mathematical statements. These rules are used to
distinguish valid and invalid mathematical arguments.

• A declarative statement that is either true or false, but not both.

Example:

– 1+5=6
– The Earth revolves around the Sun
– 10 – 4 = 5
– Pigs can fly

Propositions 1 and 2 are true, whereas 3 and 4 are false.

Consider the following sentences

– 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

 A name that represents the proposition.

Example:

– p : The Earth revolves around the sun


– q : Pigs can fly
– r: 1+5=6

Exercise

Which of the following are propositions?

1. 10 is greater than 5

2. Please erase the board

3. 5 + a = 10

4. Take your medicine

5. It is not raining today

Compound Proposition

Can be obtained by: Negating a proposition, or Combining two or more propositions using
logical connectives

Logical Connectives

Compound Proposition uses the following logical connectives:

Logical Connectives Meaning


Negation Not
Conjunction And
Disjunction Or
Exclusive or XOr
Implication If – then
Biconditional If and only if

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)

Unary Operator, Symbol: ¬

p: The Earth does not revolve around the Sun p p


T: F true (T) false (F)

q: Pigs cannot fly


false (F) true (T)

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)

Binary Operator, Symbol: 

p  q: The Earth revolves around the p p pq


sun and pigs can fly. T T T
T F F
T  F: F
F T F
F F F

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.

Therefore, if p and q are statements, then

p but q means p and q

Example:

Let

p : Mathematics is easy

q : I will pass mathematics

Therefore: p  q = Mathematics is easy and I will pass mathematics

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

q : The sun is shining

Find p  q

DISCRETE STRUCTURES 1 9
Logic

Disjunction (Or)

Binary Operator, Symbol: 

p  q : The Earth revolves around the p q pq


sun or pigs can fly. T T T
TF:T
T F T
F T T
Example:
F F F
Let

p : Mathematics is easy

q : I will pass mathematics

Therefore: p  q = Mathematics is easy or I will pass mathematics

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

q : The sun is shining

Find p  q

And, Or, and Inequalities

The notation for inequalities involves and and or statements. For instance, if x, a, and b
are particular real numbers, then

x≤a means x < a or x = a

a≤x≤b means a ≤ x and x ≤ b

Note that the inequality

2 ≤ x ≤ 1 is not satisfied by any real numbers because

2≤x≤1 means 2 ≤ x and x ≤ 1

and this is False no matter what the value of x happens to be.

DISCRETE STRUCTURES 1 10
Logic

Exclusive or (XOR)

Binary Operator, Symbol: 

p  q : Either the Earth revolves around the Sun or pigs can fly

TF:T p q pq
T T F
T F T
F T T
F F F
Example:

Let

p : Mathematics is easy

q : I will pass mathematics

Therefore: p  q = Either mathematics is easy or I will pass mathematics

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

q : The sun is shining

Find p  q

Implication (if - then)

Binary Operator, Symbol: 

If p then q p q pq
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:

p: 2 < 6, r: 2 < 10, s: 2 < 1, t: 5 < 3

pr sp
If 2 < 6, then 2 < 10 If 2 < 1, then 2 < 6
TT:T FT:T
ps st
If 2 < 6, then 2 < 1 If 2 < 1, then 5 < 3
TF:F FF:T

Example:

Let

p : Mathematics is easy

q : I will pass mathematics

Therefore: p  q = If mathematics is easy then I will pass mathematics

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

q : The sun is shining

Find p  q

Biconditional (if and only if)

Binary Operator, Symbol: 

p if and only if q p q pq


p is necessary and
T T T
sufficient for q
T F F
F T F
(p ® q)  (q ® p) F F T
 (p  q)

DISCRETE STRUCTURES 1 12
Logic

Example:

Let

p : Mathematics is easy

q : I will pass mathematics

Therefore: p  q = Mathematics is easy if and only if I will pass mathematics

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

q : The sun is shining

Find p  q

Statements and Operators

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

p q pq (pq) p) v (q)


T T T F F
T F F T T
F T F T T
F F F T T

DISCRETE STRUCTURES 1 13
Logic

Exercise

Write truth tables for the statements.

1. ¬p  q

2. p(qr)

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

You might also like