You are on page 1of 10

JAPAN - MALAYSIA TECHNICAL INSTITUTE

MANPOWER DEPARTMENT
JMTi
MINISTRY OF HUMAN RESOURCE

INFORMATION SHEET 1

DEPARTMENT COMPUTER ENGINEERING TECHNOLOGY COURSE


DKB3204
SECTION SYSTEM CODE
PROGRAMME DIP. IN COMPUTER ENG. TECHNOLOGY NOSS Ref
COURSE DISCRETE MATHEMATICS
SEM 3
UNIT Basic: Logic and Proof

Introduction
The rules of logic specify the meaning of mathematical statements. For instance, these rules help us
understand and reason with statements such as “There exists an integer that is not the sum of two squares”
and “For every positive integer n, the sum of the positive integers not exceeding n is n(n+1)/2.” 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.
To understand mathematics, we must understand what makes up a correct mathematical argument, that is,
a proof. Once we prove a mathematical statement is true, we call it a theorem. A collection of theorems on
a topic organize what we know about this topic. To learn a mathematical topic, a person needs to actively
construct mathematical arguments on this topic, and not just read exposition. Moreover, knowing the proof
of a theorem often makes it possible to modify the result to fit new situations.
Everyone knows that proofs are important throughout mathematics, but many people find it surprising how
important proofs are in computer science. In fact, proofs are used to verify that computer programs produce
the correct output for all possible input values, to show that algorithms always produce the correct result,
to establish the security of a system, and to create artificial intelligence. Furthermore, automated reasoning
systems have been created to allow computers to construct their own proofs.
In this chapter, we will
 Explain what makes up a correct mathematical argument
 Introduce tools to construct these arguments.

1
DKB3204
1.1 PROPOSITION LOGIC

Define the purpose of proposition logic


Our discussion begins with an introduction to the basic building blocks of logic — propositions. A
proposition is a declarative sentence (that is, a sentence that declares a fact) that is either TRUE or
FALSE, but NOT BOTH. The truth or falseness of the statement can be determined immediately.
Examples of proposition:
 Beijing is the capital of China – True (T)
 1992 was an Olympic year – True (T)
 Two plus two equals five – False (F)
 2+2 = 5 – False (F)

But, the following are NOT propositions:


 “Who’s there?” - interrogative, question
 “La la la la la…” - meaningless interjection
 “Just do it!” - imperative, command
 “1 + 2” - expression with a non-true/false value

Propositions can be denoted using letters such as p, q, r, s etc. The truth value can be either true (T)
or false (F). If a proposition is true, it is denoted by T. If the proposition is false, it is denoted by F.

Example
1. All the following declarative sentences are propositions.
a. Washington, D.C., is the capital of the United States of America.
b. Toronto is the capital of Canada.
c. 1+1= 2.
2. Consider the following sentences.
a. What time is it?
b. Read this carefully.
c. x + y = z.

Explain formula in proposition logic


Propositional Logic is the logic of compound statements built from simpler statements using Boolean
connectives. Some applications in computer science:
 Design of digital electronic circuits.
 Expressing conditions in programs.
 Queries to databases and search engines.

Two propositions can be combined called compound propositions using an operators or connectives
to build more complicated logical expressions. Some formulas in proposition logic are as the table below:

2
DKB3204
Formal Name Nickname Symbol
1) Negation operator NOT ~ or 

 Transform a proposition into a logical negation.


 It has opposite truth value from p; if p is true, p is false and vice versa.
 Example:
If p = “I have a brown hair”

Then ~ p = “I do not have a brown hair”

 The truth table for NOT:

p ~p

T F

F T

2) Conjunction operator AND 


 The conjunction operator “” (AND) combines two propositions to form their logical
conjunction.
 The proposition p  q is true when both p and q are true and is false otherwise.
 Example:
If p= “I will have salad for lunch.” and
q = “I will have steak for dinner.” then
pq = “I will have salad for lunch and I will have steak for dinner.”

 The truth table for AND:


p q pq

T T T

T F F

F T F

F F F

3
DKB3204
3) Disjunction operator OR 

 The disjunction operator “” (OR) combines two propositions to form their logical
disjunction.
 The proposition p  q is false when both p and q are false and is true otherwise.
 Example:
If p= “My car has a bad engine.” or
q = “My car has a bad carburetor.” then
pq = “Either my car has a bad engine or my car has a bad carburetor.”

 The truth table for OR:


p q pq

T T T
Note
T F T difference
from AND
F T T

F F F

4) Exclusive-OR operator XOR 

 The exclusive-or operator “” (XOR) combines two propositions to form their logical
exclusive or adjunction.
 Example:
If p = “I will earn an A in this course,” and

q = “I will drop this course,” then

pq = “I will either earn an A in this course, or I will drop it”

 Note that p q means that p is true, or q is true, but not both!


 The truth table for XOR:
p q pq Note
difference
T T F from OR

T F T

F T T

F F F

4
DKB3204
5) Conditional (Implication) operator IF, THEN or IMPLIES 

 The implication p→q states that p implies q.


 If p is true, then q is true; but if p is not true, then q could be either true or false.
 Example:
Let p= “You study hard.”

q= “You will get a good grade.”


p→q = “If you study hard, then you will get a good grade.” (else, it could go
either way)

 p→q is false only when p is true but q is not true.


 The truth table for IF, THEN :
p q p→q

T T T The only
False
T F F case

F T T

F F T

 In the case p → q, p is known as the hypothesis and q is the conclusion.


 From the above truth table, note that when hypothesis is true, the truth value of
implication depends on the truth value of conclusion.
 When hypothesis is false, the truth value of implication is always true.

 Examples of implication:

a) “If this lecture ever ends, then the sun will rise tomorrow.”
True or False?

b) “If Tuesday is a day of the week, then I am a penguin.”


True or False?

c) “If 1+1=6, then Obama is the president of USA.”


True or False?

d) “If the moon is made of green cheese, then I am richer than Bill Gates.” True or
False?

5
DKB3204
Converse, inverse, Contrapositive

p : it isn’t raining today


q : I am going to the beach

CONVERSE : the implication of q → p is called converse of p → q


Eg: If I am going to the beach today, then it isn’t raining
INVERSE:  p →  q
Eg : If it I raining today, then I am not going to the beach.
CONTRAPOSITIVE : the contrapositive of q →  p is the implication p → q
Eg : If I am not going to the beach today, then it is raining.

6) Biconditional operator IFF 


 The biconditional p↔q states that p is true if and only if (IFF) q is true.
 Example:
p = “Bush wins the 2004 election.”

q = “Bush will be president for all of 2005.”

p↔q = “If, and only if, Bush wins the 2004 election, Bush will be president for all of
2005.”

 p↔q means that p and q have the same truth value.


 The truth table for IFF:

p q p↔q

T T T

T F F

F T F

F F T

 Note this truth table is the exact opposite of ⊕’s!


 Thus, p↔q means ~ (p⊕q)
 Precedence of logical operators:

Operator Precedence
~ 1
 2
 3
 4
 5

6
DKB3204
 Use parentheses to group sub-expressions:
 Example:
“I just saw my old friend, and either he’s grown or I’ve shrunk.” = f ∧(g ∨s)

(f ∧g) ∨s would mean something different

f ∧g ∨s would be ambiguous

 Their truth table for Boolean operations summary:

p q ~p pq pq pq pq pq

T T F T T F T T

T F F F T T F F

F T T F T T T F

F F T F F F T T

 Some alternative notations:

NAME NOT AND OR XOR IMPLIES IFF


Propositional ~     
logic
Boolean p pq + 
algebra
C/C++/Java    = ==
Logic gates

1.2 PROPOSITIONAL EQUIVALENCES

Compound propositions that have the same truth values either true or false in all possible cases are
called logically equivalent.
**Example of truth table for logical equivalence:
Prove that ~pq is logically equivalent to p→q
7
DKB3204
p q ~p ~pq p→q

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

Therefore, ~pq is logically equivalent to p→q.

Some equivalent rules are:


a) Tautologies
o A tautology is a compound proposition that is true no matter what the truth values of its
atomic propositions are.
o A statement whose form is a tautology is called tautological statement.
b) Contradictions:
o A contradiction is a compound proposition that is false no matter what!
o A statement whose form is a contradiction is called contradictory statement.

Truth table:
p ~p p ~p p~p

T F T F

F T T F

All FALSE so it’s a


CONTRADICTION
All TRUE so
it’s a
TAUTOLOGY

This notation can also be defined as:


 The propositions p and q are called logically equivalent if pq is a tautology.
 The notation pq denotes that p and q logically equivalent.
The symbol  is not logical connective since pq is not a compound proposition, but
rather is the statement that pq is a tautology.

 The symbol  is sometimes used instead of  to denote logical equivalence.

1.3 PREDICATES AND QUANTIFIERS

Propositional logic, cannot adequately express the meaning of all statements in mathematics and in natural
language. For example, suppose that we know that
“Every computer connected to the university network is functioning properly.”

8
DKB3204
No rules of propositional logic allow us to conclude the truth of the statement
“MATH3 is functioning properly,” where MATH3 is one of the computers connected to the
university network.

Likewise, we cannot use the rules of propositional logic to conclude from the statement

“CS2 is under attack by an intruder,” where CS2 is a computer on the university network, to conclude the
truth of “There is a computer on the university network that is under attack by an intruder.”

In this section we will study


 Predicate logic to express the meaning of a wide range of statements in mathematics and
computer science, that permit us to reason and explore relationships between objects.
 The notion of quantifiers, which enable us to reason with statements that assert that a certain
property holds for all objects of a certain type and with statements that assert the existence of
an object with a particular property.

PREDICATE
The statement x > 3 “x is greater than 3” has two parts:
i – The variable, x is the subject of the statement

ii – the predicate “is greater than 3” – refer to a property that the subject of the statement can have

Let P(x) be the propositional function – P at x. Once a value has been assigned to the variable x, the
statement P(x) becomes a proposition and has a truth value.

Example 1
Let P(x) denote the statement “x > 3”. What is the truth values of P(4) and P(2) ?

QUANTIFIER
Quantifiers are words that refer to quantities such as some or all and tell for how many elements a given
predicate is true.
There are two kinds of quantifiers which are :
1) Existential quantifier that can be symbolically written as 
2) Universal quantifier that can be symbolically written as 

a) Universal

The symbol  denotes “for all” and is called the universal quantifier.
For example, another way to express the sentence “All human beings are mortal” is to write or, more
formally:
 x  S, x is mortal
Where S denotes the set of all human beings. (Think “for all” when you see the symbol  ). The
domain of the predicate variable is generally indicated between the  symbol and the variable name
(as in All human beings x) or immediately following the variable name (as in  x  S).

9
DKB3204
b) Existential

The symbol  denotes “there exists” and is called the existential quantifier.
For example, the sentence “There is a student in DKB3204” can be written as “a person m such that S
is a student in DKB3204” or more formally:
 m  S, such that S is a student in DKB3204.
Where S is the set of all people. (Think “there exists” when you see the symbol  ). The domain of
the predicate variable is generally indicated either between the  symbol and the variable name or
immediately following the variable name.

10
DKB3204

You might also like