231
WUCT121 Logic 1 WUCT121 Discrete Mathematics Logic 1. Logic 2. Predicate Logic 3. Proofs 4. Set Theory 5. Relations and Functions

WUCT121 Discrete Mathematics Logic

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 1

WUCT121

Discrete Mathematics

Logic

1. Logic

2. Predicate Logic

3. Proofs

4. Set Theory

5. Relations and Functions

Page 2: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 2

Section 1. Logic

1.1. Introduction.

In developing a mathematical theory, assertions or

statements are made. These statements are made in the

form of sentences using words and mathematical symbols.

When proving a theory, a mathematician uses a system of

logic. This is also the case when developing an algorithm

for a program or system of programs in computer science.

The system of logic is applied to decide if a statement

follows from, or is a logical consequence of, one or more

other statements.

You are familiar with using numbers in arithmetic and

symbols in algebra. You are also familiar with the ‘rules’ of

arithmetic and algebra.

Examples:

• ( ) ( )

13103

ityAssociativ 643643

=+=

++=++

• ( )x

xxx2

vityDistributi 5353−=−=−

Page 3: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 3

In a similar way, Logic deals with statements or sentences

by defining symbols and establishing ‘rules’.

Roughly speaking, in arithmetic an operation is a rule for

producing new numbers from a pair of given numbers, like

addition (+) or multiplication (×).

In logic, we form new statements by combining short

statements using connectives, like the words and, or.

Examples:

• This room is hot and I am tired.

• 1<x or 7>x .

1.2. Statements

1.2.1. Definition

Definition: Statement. A statement or proposition is an

assertion or declarative sentence which is true or false, but

not both.

The truth value of a mathematical statement can be

determined by application of known rules, axioms and laws

of mathematics.

Page 4: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 4

A statement which is true requires a proof.

Examples:

• Is the following statement True or False?

For a real number x, if 12 =x , then 1=x or 1−=x .

The statement is TRUE. Therefore, we must prove it.

Consider 12 =x .

Adding 1− to both sides gives 012 =−x .

Factorising this equation, we have ( )( ) 011 =+− xx .

Therefore, 01 =−x or 01 =+x .

Case 1: 01 =−x .

Add 1 to both sides and we have 1=x .

Case 2: 01 =+x .

Add 1− to both sides and we have 1−=x .

Page 5: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 5

A statement which is false requires a demonstration.

Example:

• Is the following statement True or False?

2)35()23(5 −−=−−

The statement is FALSE. Therefore, we must demonstrate

it.

2)35()23(50

222)35(4

15)23(5

−−≠−−∴=

−=−−=

−=−−

Page 6: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 6

Exercise:

Determine which of the following sentences are statements.

For those which are statements, determine their truth value.

(i) 532 =+ Statement True

(ii) It is hot and sunny

outside.

Statement

(iii) 632 =+ Statement False

(iv) Is it raining? Not a statement

(v) Go away! Not a statement

(vi) There exists an

even prime

number.

Statement True

(vii) There are six

people in this room.

Statement

(viii) For some real

number , 2, <xx

Statement True

(ix) 2<x See comment in notes

(x) xyyx +=+ See comment in notes

Page 7: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 7

Strictly speaking, as we don’t know what x or y are, in parts

(ix) and (x), these should not be statements. In

Mathematics, x and y usually represent real numbers and

we will assume this is the case here.

Therefore, (ix) is either true or false (even if we don’t know

which) and (x) is always true, so we will allow both.

1.2.2. Simple Statements

Definition: Simple Statement. A simple or primitive

statement is a statement which cannot be broken down into

anything simpler.

A simple statement is denoted by use of letters p, q, r...

Examples:

• p: There are seven days in a week

p is a simple statement

• 632: =+p

p is a simple statement

Page 8: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 8

1.2.3. Compound Statements

Definition: Compound Statement. A compound or

composite statement is a statement which is comprised of

simple statements and logical operations.

A compound statement is denoted by use of letters P, Q,

R...

Examples:

• P: There are seven days in a week and twelve months

in a year.

Is a compound statement.

p: There are seven days in a week

q: There twelve months in a year

Operation: and

• P: 632 =+ or 2)35()23(5 −−=−− .

Is a compound statement.

p: 632 =+

q: 2)35()23(5 −−=−−

Operation: or

Page 9: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 9

• P: If it is not raining then I will go outside and eat my

lunch.

Is a compound statement

p: It is raining

q: I will go outside

r: I will eat my lunch

Negation of p

Operations: If … then, and

Page 10: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 10

Exercises:

Determine which of the following are simple statements,

and which are not. For those which are not, identify the

simple statement(s) used.

Simple Statement Operation

(i) 532 =+ is a simple Statement

(ii) It is hot and

sunny outside.

p: It is hot

q: It is sunny outside

and

(iii) 632 ≠+ p: 632 =+ negation

(iv) 2≤x p: 2<x

q: 2=x

or

(v) 25 <<− x p: x<−5

q: 2<x

and

(vi) If I study hard

then I will pass

my exam

p: I study hard

q: I will pass my exam

If..then

Page 11: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 11

1.3. Truth Tables

A statement P can hold one of two truth values, true or

false. These are denoted “T” and “F” respectively.

Note: Some books may use “1” for true and “0” for false.

When determining the truth value of a compound statement

all possible combinations of the truth values of the

statements comprising it must be considered.

This is done systematically by the use of truth tables. Each

connective is defined by its own unique truth table.

There are five fundamental truth tables which will be

covered in the following sections.

1.3.1. Truth Table Construction

To construct a truth table assign each statement a column.

The number of rows in the table is determined by the

number of statements. For n statements, n2 rows will be

required.

Systematically assign truth vales to each of the statements,

beginning in the first column.

Page 12: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 12

Once all possible truth values for the simple statements are

inserted, determine the truth vales of the compound

statements following the rules for the operations.

Example:

• Given three statements P, Q, R. The table setup is:

P Q R Compound Statement

T T T

T T F

T F T

T F F

F T T

F T F

F F T

F F F

Page 13: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 13

1.4. Logical Operations

There are five main operations which when applied to a

statement will return a statement.

If P and Q are statements, the five primary operations used

are:

not P, the negation of P.

P or Q, the disjunction of P and Q.

P and Q, the conjunction of P and Q.

P implies Q, the conditional of P and Q.

P if and only if Q, the biconditional of P and Q.

1.4.1. Negation, “not”

Definition: Statement Negation.

If P is a statement, the negation of P is “not P” or “it is not

the case that P” and is denoted ~P.

Page 14: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 14

Examples:

• There are not seven days in a week

p: There are seven days in a week

• P: It is raining outside.

~P: ~(It is raining outside.)

It is not raining outside.

• Q: 2>x or 2<x

~Q: ~( 2>x or 2<x )

Simplified: 2=x .

Exercises:

For each statement P, write down ~P.

• P: Discrete Maths is interesting.

~P: ~( Discrete Maths is interesting)

Discrete Maths is not interesting.

• 012 =−xP

( )01

01~:~2

2

≠−

=−

x

xP

Page 15: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 15

1.4.1.1 Truth Table for Negation

The negation of P has the opposite truth value from P,

~P is false when P is true; ~P is true when P is false.

P ~P

T F

F T

Example:

Write down the truth value of the following statements.

P ~P

• 752 =+ 752 ≠+

T F

• This room is

empty

This room is not

empty

F T

All possible truth values for P

All possible truth values for ~P depending on the value of P.

Page 16: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 16

Exercise:

Write down the truth value of the following statements.

P ~P

• ∈1 ∉1 T F

• Division is a closed

operation on

Division is not a closed

operation on F T

Note: • The truth table for negation tells us that for any

statement P, exactly one of P or ~P is true. So, to prove P

is true, we have two methods:

∗ Direct: Start with some facts and end up

proving P in a direct step-by-step manner.

∗ Indirect: Don’t prove P is true directly, but

prove that ~P is false.

• Generally, brackets are left out around ‘ P~ ’.

Thus, QP∨~ means QP ∨)(~ , and not )(~ QP∨ .

This is similar to arithmetic where yx +− means ( ) yx +−

and not ( )yx +− .

Page 17: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 17

1.4.2. Disjunction, “or”

Definition: Disjunction.

If P and Q are statements the disjunction of P and Q is “P

or Q”, denoted QP∨ .

Examples:

• Given 532: =+P , 632: =+Q , write down QP∨ .

6532:simplified)632()532(:elyalternativ

632532:

or

orQP

=+=+∨=+

=+=+∨

• Write 5: ≤xP using “∨ ”. )5()5( =∨< xx

Exercises:

• Write the following statements using “∨ ”

∗ I am catching the bus or train home.

(I am catching the bus home) ∨ (I am catching the train

home)

∗ A month has 30 or 31 days.

(A month has 30 days) ∨ (A month has 31 days)

Page 18: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 18

• For the statements P and Q, write down QP ∨ .

∗ 0:0: => xQxP

( ) ( )0:simplified

00:≥=∨>∨

xxxQP

∗ P: x is the square of an integer, Q: x is prime

( ) ( )primeisintegeran ofsquare theis : xxQP ∨∨

1.4.2.1 Truth Table for Disjunction

The disjunction of P and Q is true when either P is true, or

Q is true, or both P and Q are true; it is false only when

both P and Q are false.

P Q QP∨

T T T

T F T

F T T

F F F

Page 19: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 19

Example:

Write down the truth value of the following statements.

P Q QP∨

• 532 =+ 632 =+

T F T

• ∉1 ∈0

F F F

Exercise:

Write down the truth value of the following statements.

P Q QP∨

• 12 > 12)1( 22 ++=+ xxx

T T T

• 2 is odd 5 is odd

F T T

• 12 < This room is empty

F F F

Page 20: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 20

1.4.3. Conjunction, “and”

Definition: Conjunction.

If P and Q are statements the conjunction of P and Q is “P

and Q”, denoted QP ∧ .

Examples:

• Given P: It is hot, Q: It is sunny, write down QP ∧ .

QP ∧ : (It is hot) ∧ (It is sunny)

Simplified: It is hot and sunny

• Write 50: << xP using “∧”. )5()0( <∧< xx

Exercises:

• Write the following statements using “∧”

∗ Snow is cold and wet.

(Snow is cold) ∧ (Snow is wet)

∗ Natural numbers are positive and whole

numbers.

(Natural numbers are positive numbers) ∧ (Natural

numbers are whole numbers)

Page 21: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 21

• For the statements P and Q, write down QP ∧ .

∗ 1:0: <> xQxP

( ) ( )10:simplified

10:<<<∧>∧x

xxQP

∗ P: x is even, Q: x is a natural number

( ) ( )numbernaturalaisevenis : xxQP ∧∧

1.4.3.1 Truth Table for Conjunction

The conjunction of P and Q is true when, and only when,

both P and Q are true.

If either P or Q are false, of if both are false, QP ∧ is false.

P Q QP ∧

T T T

T F F

F T F

F F F

Page 22: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 22

Example:

Write down the truth value of the following statements.

P Q QP ∧

• 532 =+ 632 =+

T F F

• ∉1 ∈0

F F F

Exercise:

Write down the truth value of the following statements.

P Q QP ∧

• 12 > π>6

T T T

• 2 is odd 5 is odd

F T F

• 12 < 324 =

F F F

Page 23: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 23

1.4.4. Conditional, “If … then”, “implies”

Definition: Conditional.

If P and Q are statements the conditional of P by Q is “If P

then Q” or “P implies Q”, and is denoted QP ⇒ .

Examples:

• Given P: It is raining, Q: I will go home, write down

QP ⇒ .

QP ⇒ : (It is raining) ⇒ (I will go home)

Simplified: If it raining then I will go home

• Write “If x is even then 2x is even” using “⇒”.

evenisevenis 2xx ⇒

Exercises:

• Write the following statements using “⇒”

∗ If the snow is good then I will go skiing.

(The snow is good) ⇒ (I will go skiing)

∗ If x is a natural number then x is an integer.

(x is a natural number) ⇒ (x is an integer)

Page 24: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 24

• For the statements P and Q, write down QP ⇒ .

∗ 0:1: >−> xQxP

( ) ( )01: >⇒−>⇒ xxQP

∗ P: x is even, Q: x is a natural number

( ) ( ) number naturala is theneven is If

number naturala is even is :xx

xxQP ⇒⇒

1.4.4.1 Truth Table for Conditional

The conditional of P by Q is false when P is true and Q

false, otherwise it is true.

We call P the hypothesis (or antecedent) of the conditional

and Q the conclusion (or consequent).

In determining the truth values for conditional, consider the

following example.

Suppose your lecturer say to you:

“If you arrive for the lecture on time, then I will mark you

present.

Under what circumstances are you justified in saying the

lecturer lied? In other words under what circumstances is

the above statement false?

Page 25: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 25

It is false when you show up on time and are not marked

present.

The lecturers promise only says you will be marked present

if a certain condition (arriving on time) is met; it says

nothing about what will happen if the condition is not met.

So if the condition (arriving on time) is not met, you cannot

in fairness say the promise is false regardless of whether or

not you are marked present.

This example demonstrates that the only combination of

circumstances in which you have a conditional statement

false is when the hypothesis is true and the conclusion is

false.

Thus the truth table for conditional is:

P Q QP ⇒

T T T

T F F

F T T

F F T

Page 26: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 26

Example:

Write down the truth value of the following statements.

P Q QP ⇒

• 532 =+ 632 =+

T F F

• ∉1 ∈0

F F T

Exercise:

Write down the truth value of the following statements.

P Q QP ⇒

• 12 > 12 >

T T T

• 2 is even 5 is even

T F F

• 12 < 14 <

F F T

Page 27: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 27

Alternative wording for QP ⇒ can be:

• If P then Q.

• P implies Q.

• Q if P.

• Q provided P.

• Q whenever P.

• P is a sufficient condition for Q.

• Q is a necessary condition for P.

• P only if Q.

Page 28: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 28

1.4.5. Biconditional, “If and only if”

Definition: Biconditional.

If P and Q are statements the biconditional of P and Q is

“P if, and only if Q” and is denoted QP ⇔ .

Examples:

• Given P: Mark can study algebra, Q: Mark passes

pre-algebra, write down QP ⇔ .

QP ⇔ : (Mark can study algebra) ⇔ (Mark passes

pre-algebra)

Simplified: Mark can study algebra if, and only if, he

passes pre-algebra

• Write “Water boils if, and only if, it’s temperature is

over Co100 ” using “⇔ ”.

Co100over is etemperaturWatersWater boil ⇔

Exercises:

• Write the following statements using “⇔ ”

∗ I will go swimming if, and only if, the water is

warm.

(I will go swimming) ⇔ (The water is warm)

Page 29: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 29

∗ x is a natural number if, and only if, x is an

integer.

(x is a natural number) ⇔ (x is an integer)

• For the statements P and Q, write down QP ⇔ .

∗ 0:: >∈ xQxP

( ) ( )0: >⇔∈⇔ xxQP

∗ P: x is positive, Q: x is a natural number

( ) ( ) number naturala is positiveis : xxQP ⇔⇔

1.4.5.1 Truth Table for Biconditional

The biconditional of P and Q is true if both P and Q have

the same truth value, and is false if P and Q have opposite

truth values.

P Q QP ⇔

T T T

T F F

F T F

F F T

Page 30: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 30

Example:

Write down the truth value of the following statements.

P Q QP ⇔

• 532 =+ 632 =+

T F F

• ∉1 ∈0

F F T

Exercise:

Write down the truth value of the following statements.

P Q QP ⇔

• 12 > 12 >

T T T

• 2 is odd 5 is odd

F T F

• 12 < 14 <

F F T

Page 31: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 31

Alternative wording for QP ⇔ can be:

• P if, and only if Q.

• P iff Q.

• P implies and is implied by Q.

• P is equivalent to Q.

• P is a necessary and sufficient condition for Q.

Page 32: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 32

1.4.6. Order of Operation for Logical Operators.

The order of operation for logical operators is as follows:

1. Evaluate negations first

2. Evaluate ∨ and ∧ second. When both are present,

parenthesis may be needed, otherwise work left to right.

3. Evaluate ⇒ and ⇔ third. When both are present,

parenthesis may be needed, otherwise work left to right.

Note: Use of parenthesis will determine order of operations

which over ride the above order.

Examples: Indicate the order of operations in the following:

• { {qp21

~ ∧

• { { )(~12

qp∧

• { { { )(~231

rqp ∨∧

• { { {rqp231

~ ∧⇒

Exercises:

Indicate the order of operations in the following:

• { { {rqp321

)~( ∧⇒

• { { )(~12

qp∨

• { { {rqp231

~ ∨⇒

• { { {rqp231

~ ∧⇔

Page 33: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 33

1.4.7. Main Connective

Definition: Main Connective.

The main connective is the operation which “binds” the

statement together.

It is the final operation performed and is denoted with “*”.

Examples:

Indicate the main connective in the following:

• { {qp*21

~ ∧

• { { )(~1*2

qp∧

• { { { )(~2*31

rqp ∨∧

• { { {rqp2*31

~ ∧⇒

Exercises:

Indicate the main connective in the following:

• { { {rqp*321

)~( ∧⇒

• { { )(~1*2

qp∨

• { { {rqp2*31

~ ∨⇒

• { { {rqp2*31

~ ∧⇔

Page 34: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 34

Example:

Construct a truth table for )~(~ qp∧ , indicating order of

operations and the main connective

p q ~ (p ∧ ~ q) T T T F F T F F T T F T T F F F F T F T

Step: 3* 2 1

Exercises:

• Construct a truth table for pqp ∧⇒~~ , indicating

order of operations and the main connective

p q ~ p ⇒ ~ q ∧ p T T F T F F T F F T T T F T T F F F F F T F T F

Step: 1 3* 1 2

Page 35: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 35

• Construct a truth table for ( ) ( )qrqp ∨∧∨ , indicating

order of operations and the main connective

p q r (p ∨ q) ∧ (r ∨ q) T T T T T T T T F T T T T F T T T T T F F T F F F T T T T T F T F T T T F F T F F T F F F F F F

Step: 1 2* 1

• Construct a truth table for ( ) ( )rprq ∧∨∧ ~~ ,

indicating order of operations and the main connective

p q r (~ q ∧ r) ∨ ~ (p ∧ r) T T T F F F F T T T F F F T T F T F T T T T F T T F F T F T T F F T T F F T T F F T F F F T T F F F T T T T T F F F F T F T T F

Step: 1 2 3* 2 1

Page 36: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 36

1.5. Tautologies and Contradictions

1.5.1. Tautology

Definition: Tautology.

Any statement that is true regardless of the truth values of

the constituent parts is called a tautology or tautological

statement.

Examples:

Complete the truth table for the statement ( )PQP ⇒⇒

P Q P ⇒ (Q ⇒ P) T T T T T F T T F T T F F F T T

Step: 2* 1

Page 37: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 37

Exercises:

• Complete the truth table for the statement

QPQP ⇒∧⇒ ))(( to show it is a tautology.

P Q ((P ⇒ Q) ∧ P) ⇒ Q T T T T T T F F F T F T T F T F F T F T

Step: 1 2 3*

• Complete the truth table for the statement

PQQP ~)~)(( ⇒∧⇒ to show it is a tautology.

P Q ((P ⇒ Q) ∧ ~Q) ⇒ ~ P T T T F F T F T F F F T T F F T T F F T T F F T T T T T

Step: 2 3 1 4* 1

Page 38: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 38

1.5.1.1 Quick Method for Showing a

Tautology

In constructing a truth table for a compound statement

comprised of n statements, there will be n2 combinations of

truth values. This method can be long for large numbers of

statements.

We will consider a quicker method for determining if a

compound statement is a tautology. However, truth tables

are reliable (“safe”) and are highly recommended if the

“quick” method is confusing or leading nowhere!

The quick method relies on the fact that if a truth value of

“F” can occur under the main connective (for some

combination of truth values for the components), then the

statement is not a tautology. If this truth value is not

possible, then we have a tautology.

Therefore, to determine whether a statement is a tautology,

we place an “F” under the main connective and work

backwards.

Page 39: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 39

Examples:

• Determine if ( )PQP ⇒⇒ is a tautology, using the

quick method

P ⇒ (Q ⇒ P) Step 2* 1

1.Place “F” under main

connective

F

2. For “F” to occur under the

main connective, P must be

“T” and ⇒ must be “F”

T F

3. For “F” to occur under ⇒ ,

Q must be “T” and P must be

“F”

T F

P cannot be both “T” and “F”, thus ( )PQP ⇒⇒ can only

ever be true and is a tautology.

Page 40: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 40

• Determine if ( )SRQP ∧⇒∧ )( is a tautology, using

the quick method

(P ∧ Q) ⇒ (R ∧ S) Step 1 3* 2

1.Place “F” under main

connective

F

2. For “F” to occur under the

main connective, )( QP ∧ must

be “T” and ( )SR ∧ must be

“F”

T F

3. For “T” to occur under

)( QP ∧ , P must be “T” and Q

must be “T”

T T

3. For “F” to occur under

( )SR ∧ , R can be “T” and S

can be “F”

T F

As there is a valid combination of truth values which gives

“F” under the main connective, ( )SRQP ∧⇒∧ )( is not a

tautology.

Page 41: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 41

Exercises:

• Use the “quick” method for the statement

QPQP ⇒∧⇒ ))(( to determine if it is a tautology.

((P ⇒ Q) ∧ P) ⇒ Q Step 1 2 3*

1. Place “F” under main

connective.

F

2. For “F” to occur under the

main connective, ∧ must be

“T” and Q must be “F”

T F

3. For “T” to occur under ∧ , P

must be “T” and QP ⇒ must

be “T”

T T

4. For “T” to occur under

QP ⇒ ,when P is “T” Q must

be “T”

T T

Q cannot be both “T” and “F”, thus QPQP ⇒∧⇒ ))(( can only

ever be true and is a tautology.

Page 42: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 42

• Determine if the statement PQQP ~)~)(( ⇒∧⇒ is

a tautology, using the “quick” method.

((P ⇒ Q) ∧ ~Q) ⇒ ~P Step: 2 3 1 4* 1

1.Place “F” under main

connective

F

2. For “F” to occur under

the main connective, ∧

must be “T” and ~P must

be “F”

T F

3. For “T” to occur under ∧ , ~Q must be “T” and

QP ⇒ must be “T”

T T

4. For “T” to occur under

QP ⇒ ,when P is “T”, Q

must be “T”

T T

At step 2, ~P is “F”, thus P is “T”. Step 3 shows ~Q is “T”

thus Q is “F”and step 4 gives Q is “T”. Q cannot be both “T”

and “F”, thus PQQP ~)~)(( ⇒∧⇒ can only ever be true

and is a tautology.

Page 43: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 43

1.5.2. Contradiction

Definition: Contradiction.

Any statement that is false regardless of the truth values of

the constituent parts is called a contradiction or

contradictory statement.

Examples:

Complete the truth table for the statement

( )PQQP ∧⇔∧ )(~

P Q ~ (P ∧ Q) ⇔ (Q ∧ P) T T F T F T T F T F F F F T T F F F F F T F F F

Step: 2 1 4* 3

Page 44: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 44

Exercises:

• Complete the truth table for the statement

PQP ∧∨ )(~ to show it is a contradiction.

P Q ~(P ∨ Q) ∧ P T T F T F T F F T F F T F T F F F T F F

Step: 2 1 3*

• Complete the truth table for the statement

QQP ~)( ∧∧ to show it is a contradiction.

P Q (P ∧ Q) ∧ ~Q) T T T F F T F F F T F T F F F F F F T T

Step: 2 3* 1

Page 45: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 45

1.5.2.1 Quick Method for Showing a

Contradiction

The quick method for determining if a compound statement

is a tautology can be used similarly for showing a

contradiction.

The quick method relies on the fact that if a truth value of

“T” can occur under the main connective (for some

combination of truth values for the components), then the

statement is not a contradiction. If this truth value is not

possible, then we have a contradiction.

Therefore, to determine whether a statement is a

contradiction, we place a “T” under the main connective

and work backwards.

Page 46: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 46

Example:

• Use the “quick” method for the statement

PQP ∧∨ )(~ to determine if it is a contradiction.

~ (P ∨ Q) ∧ P Step: 2 1 3* 1.Place “T” under main

connective

T

2. For “T” to occur

under the main

connective, ~ must be

“T” and P must be “T”

T T

3. For “T” to occur

under ~, QP∨ must be

“F”.

F

4. For “F” to occur

under QP∨ , P must be

“F” and Q must be “F”

F F

P cannot be both “T” and “F”, thus PQP ∧∨ )(~ can only

ever be false and is a contradiction.

Page 47: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 47

Exercise:

• Use the “quick” method for the statement

QQP ~)( ∧∧ to determine if it is a contradiction.

(P ∧ Q) ∧ ~QStep: 2 3* 1 1.Place “T” under main

connective.

T

2. For “T” to occur under

the main connective,

)( QP ∧ must be “T” and

~Q must be “T”

T T

3. For “T” to occur under

)( QP ∧ , P must be “T”

and Q must be “T”.

T T

At Step 2, ~Q is “T”, thus Q is “F”. Step 3 shows Q is

“T”. Q cannot be both “T” and “F”, thus QQP ~)( ∧∧

can only ever be false and is a contradiction.

Page 48: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 48

1.5.3. Contingent

Definition: Contingent.

Any statement that is neither a tautology nor a

contradiction is called a contingent or intermediate

statement.

Examples:

Complete the truth table for the statement ( )PQQ ⇒∨

P Q Q ∨ (Q ⇒ P) T T T T T F T T F T F F F F T T

Step: 2* 1

Page 49: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 49

Exercises:

• Complete the truth table for the statement

( ) ( )qprp ∧⇒∨ to show it is contingent.

p q r (p ∨ r) ⇒ (p ∧ q) T T T T T T T T F T T T T F T T F F T F F T F F F T T T F F F T F F T F F F T T F F F F F F T F

Step: 1 3* 2

• Complete the truth table for the statement

( )( ) ( )qrrqp ⇒⇔∨∧ ~~ to show it is contingent.

p q r ~( (p ∧ ~ q) ∨ r) ⇔ (r ⇒ q)T T T F F F T F T T T F T F F F T T T F T F T T T T F T F F F T T T F T F T T F F F T F T F T F T F F F T T F F T F F T T T F F F F T F T F T T

Step: 4 2 1 3 6* 5

Page 50: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 50

1.6. Logical Equivalence

Definition: Logical Equivalence.

Two statements are logically equivalent if, and only if, they

have identical truth values for each possible substitution of

statements for their statements variables.

The logical equivalence of two statements P and Q is

denoted QP ≡ .

If two statements P and Q are logically equivalent then

QP ⇔ is a tautology

1.6.1. Determining Logical Equivalence.

To determine if two statements P and Q are logically

equivalent, construct a full truth table for each statement. If

their truth values at the main connective are identical, the

statements are equivalent.

Alternatively show QP ⇔ is a tautology and hence

conclude QP ≡ .

Page 51: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 51

Examples:

• Determine if the following statements are logically

equivalent. qpQqpP ∨⇒ :~,:

p q p ⇒ q ~p ∨ q T T T F T T F F F F F T T T T F F T T T

Step: 1* 1 2* Since the main connectives * are identical, the statements P

and Q are equivalent. Thus qpqpQP ∨≡⇒≡ ~i.e.

• Determine if the following statements are logically

equivalent. qpQqpP ~:~),(:~ ∧∧

p q ~( p ∧ q) ~p ∧ ~q T T F T F F F T F T F F F T F T T F T F F F F T F T T T

Step: 2* 1 1 2* 1 Since the main connectives * are not identical, the

statements P and Q are not equivalent.

Page 52: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 52

Exercises:

• Determine if the following statements are logically

equivalent. qpQqpP ~:~),(:~ ∧∨

p q ~( p ∨ q) ~p ∧ ~q T T F T F F F T F F T F F T F T F T T F F F F T F T T T

Step: 2* 1 1 2* 1 Since the main connectives are identical, the statements P

and Q are equivalent. Thus qpqpQP ~~)(~i.e. ∧≡∨≡

• Determine if qpqp ~~)(~ ∨⇔∧ is a tautology, and

hence if qpqp ~~)(~ ∨≡∧ .

p q ~( p ∧ q) ⇔ ~p ∨ ~q T T F T T F F F T F T F T F T T F T T F T T T F F F T F T T T T

Step: 2* 1 3* 1 2* 1 Since the main connective is all T, the statement

qpqp ~~)(~ ∨⇔∧ is a tautology, and hence

qpqp ~~)(~ ∨≡∧ .

Page 53: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 53

1.6.2. Substitution

There are two different types of substitution into

statements.

Rule of Substitution: If in a tautology all occurrences of a

variable are replaced by a statement, the result is still a

tautology.

Examples:

• We know PP ~∨ is a tautology.

Thus, by the rule of substitution, so too are:

∗ QQ ~∨ , by letting PQ = .

∗ ))((~))(( rqprqp ⇒∧∨⇒∧ , by letting

Prqp =⇒∧ )( .

Note: We have simply replaced every occurrence of P in

the tautology PP ~∨ , by some other statement.

Page 54: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 54

Rule of Substitution of Equivalence: If in a tautology we

replace any part of a statement by a statement equivalent to

that part, the result is still a tautology.

Example:

• Determine if )(~ PQP ∨⇒ is a tautology.

We know: )( PQP ⇒⇒ is a tautology and

QPQP ∨≡⇒ ~)(

By the rule of substitution PQPQ ∨≡⇒ ~)(

Thus, by the rule of substitution of equivalence,

)(~)( PQPPQP ∨⇒≡⇒⇒ , and hence

)(~ PQP ∨⇒ is also a tautology.

Exercise:

• )(~~ TST ∨∨ a tautology? Yes.

We know QPQP ∨≡⇒ ~)( . So, TSTS ∨≡⇒ ~)( and

)(~~)(~ TSTTST ∨∨≡∨⇒ (by RoS).

Hence, )()(~~ TSTTST ⇒⇒≡∨∨ (by SoE).

)( PQP ⇒⇒ is a known tautology, thus (by (SoE)

)( TST ⇒⇒ is a tautology, and since

)()(~~ TSTTST ⇒⇒≡∨∨ , )(~~ TST ∨∨ is a

tautology.

Page 55: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 55

1.6.3. Laws

The following logical equivalences hold:

1. Commutative Laws:

)()()()()()(

PQQPPQQPPQQP

⇔≡⇔•∧≡∧•∨≡∨•

2. Associative Laws:

( ) ( )( ) ( )( ) ( ))()(

)()()()(

RQPRQPRQPRQPRQPRQP

⇔⇔≡⇔⇔•∧∧≡∧∧•∨∨≡∨∨•

3. Distributive Laws:

( ) ( )( ) ( ))()()(

)()()(RPQPRQPRPQPRQP

∧∨∧≡∨∧•∨∧∨≡∧∨•

4. Double Negation (Involution) Law:

PP ≡• ~~

5. De Morgan’s Laws:

)~(~)(~)~(~)(~

QPQPQPQP

∨≡∧•∧≡∨•

Page 56: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 56

6. Implication Laws:

( )( ) )nalBiconditio()()()(

)nImplicatio(~)(PQQPQP

QPQP⇒∧⇒≡⇔•

∨≡⇒•

7. Identity Laws:

PTPPFP

≡∧•≡∨•

)()(

8. Negation (Complement) Laws:

FPPTPP

≡∧•≡∨•

)~()~(

9. Dominance Laws:

FFPTTP

≡∧•≡∨•

)()(

10. Idempotent Laws:

PPPPPP

≡∧•≡∨•

)()(

11. Absorption Laws:

PQPPPQPP

≡∧∨•≡∨∧•

)()(

12. Property of Implication:

( ) ( )( ) ( ))()()(

)()()(RQRPRQPRPQPRQP

⇒∧⇒≡⇒∨•⇒∧⇒≡∧⇒•

Page 57: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 57

Example:

Prove the first of De Morgan’s Laws using truth tables.

P Q ~( P ∨ Q) ~P ∧ ~QT T F T F F F T F F T F F T F T F T T F F F F T F T T T

Step: 2* 1 1 2* 1 Since the main connectives are identical, the statements are

equivalent., and first of De Morgan’s Laws is true.

Exercise:

Prove the second of De Morgan’s Laws using truth tables.

P Q ~( P ∧ Q) ~P ∨ ~QT T F T F F F T F T F F T T F T T F T T F F F T F T T T

Step: 2* 1 1 2* 1 Since the main connectives are identical, the statements are

equivalent, and second of De Morgan’s Laws is true.

Page 58: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 58

Example:

Using logically equivalent statements, without the direct

use of truth tables, show: ( ) ( ) pqpqp ≡∨∧∧~~

( ) ( ) ( )( ) ( ) ( )( ) ( ) ( )

( ) ( )( ) ( )

( )( )Identity NegationF

ityCommutativ~ vityDistributi~ Negation Double~ MorganDe~~~~~

pp

qqpqqp

qpqpqpqpqpqp

≡∨≡

∧∨≡∧∨≡

∨∧∨≡∨∧∨≡∨∧∧

Exercises:

Using logically equivalent statements, without the direct

use of truth tables, show:

• ( ) ( ) ( )pqqpqp ~~~ ∧∨∧≡⇔

( ) ( ) ( )( ) ( )( ) ( ) ( )( ) ( ) ( )

( ) ( ) ( )( ) ( ) ( )Negation Double~~

MorganDe~~~~~~nImplicatio~~~~

MorganDe~~nalBiconditio~~

pqqppqqp

pqqppqqp

pqqpqp

∧∨∧≡∧∨∧≡

∨∨∨≡⇒∨⇒≡

⇒∧⇒≡⇔

Page 59: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 59

• ( ) ( )pqqp ~~ ⇒≡⇒

( ) ( ) ( )( ) ( )( ) ( )( ) ( )nImplicatio~~

Negation Double~)(~~ityCommutativ~

nImplicatio~

pqpq

pqqpqp

⇒≡∨≡

∨≡∨≡⇒

• )()()( rpqprqp ⇒∧⇒≡∧⇒ , without using the

property of implication

( )( )( )nImplicatio)()(

veDistributi)(~)(~nImplicatio)(~)(

rpqprpqp

rqprqp

⇒∧⇒≡∨∧∨≡

∧∨≡∧⇒

Page 60: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 60

Section 2. Predicate Logic

Discussion:

In Maths we use variables (usually ranging over numbers)

in various ways.

How does x differ in what it represents in the following

statements? x is real.

• 02 =x x represents one value, 0=x

• 2>x x represents some, but not all values

• xx =+ 0 x represents all values

• 012 =+x x represents no values

Definition: Predicate

A predicate is a sentence that contains one or more

variables and becomes a statement when specific values are

substituted for the variables.

Definition: Domain

The domain of a predicate variable consists of all values

that may be substituted in place of the variable

Page 61: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 61

Definition: Truth Set

If P(x) is a predicate and x has domain D, the truth set of

P(x) is the set of all elements of D that make P(x) true. The

truth set is denoted )}(:{ xPDx∈ and is read “the set of all

x in D such that P(x).”

Examples:

• Let P(x) be the predicate “ xx >2 ” with ∈x i.e.

domain the set of real numbers .

Write down )2(),1(),2( −PPP and indicate which are true

and which are false.

Determine the truth set of P(x)

}10:{}:{

True)2(4or)2()2(:)2(False11or1)1(:)1(True24or22:)2(

2

2

2

2

>∨<∈=>∈

−>−>−−>>>>

xxxxxx

PPP

• Let Q(n) be the predicate “n is factor of 8”.

Determine the truth set of Q(n) if +∈n

}8,4,2,1{}"8offactorais:"{

428,818

=∈∴

±×±=±×±=+ nn

Page 62: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 62

Exercises:

• Let P(x) be the predicate “ xx >3 ” with ∈x i.e.

domain the set of integers, .

Write down )2(),0(),2( −PPP and indicate which are true

and which are false.

Determine the truth set of P(x)

}1:{}:{

False)2()8(or)2()2(:)2(

False00or0)0(:)0(

True28or22:)2(

3

2

3

3

>∈=>∈

−>−−>−−

>>

>>

xxxxx

P

P

P

• Let Q(n) be the predicate “n is factor of 6”.

Determine the truth set of Q(n) if ∈n

}6,3,2,1{}"6offactorais:"{326,616

±±±±=∈∴±×±=±×±=

nn

Page 63: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 63

2.1. Quantifiers

A way to obtain statements from predicates is to add

quantifiers. Quantifiers are words that refer to quantities

such as “all”, “every”, or “some” and tell for how many

elements a given predicate is true.

2.1.1. Universal Quantifier

The symbol ∀ denotes “for all” and is called the universal

quantifier.

Definition: Universal Statement

Let P(x) be a predicate and D the domain of x. A universal

statement is a statement of the form “ )(, xPDx∈∀ ”. It is

defined to be true if, and only if, P(x) is true for every x in

D. It is defined to be false if, and only if, P(x) is false for at

least one x in D. A value of x for which P(x) is false is

called a counterexample to the universal statement.

Examples:

• Write the sentence “All human beings are mortal”

using the universal quantifier.

Let H be the set of human beings. mortalis,hHh∈∀

Page 64: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 64

• Consider },,{ 321 xxxA = . With )(, xPAx∈∀ , the

following must hold: )()()( 321 xPxPxP ∧∧

Thus there will be 3 predicates which must hold.

Exercises:

Write the following statements using the universal

quantifier. Determine whether each statement is true or

false.

• “All dogs are animals”

Let D be the set of dogs and A the set of animals

AdDd ∈∈∀ , . True

• The square of any real number is positive.

0, 2 >∈∀ xx .

False, consider 22 0,0 =∈= xx u0.

Hence the statement is false by counterexample

• Every integer is a rational number.

∈∈∀ xx , . True

Page 65: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 65

Exercises:

Write the following statements in words. Determine

whether each statement is true or false.

• ∈∈∀ xx ,

The square root of any natural number is a natural number.

False. Consider ∉=∈= 2,2 xx . Hence the

statement is false by counterexample.

• 1, 2 −≠∈∀ xx .

The square of any real number does not equal –1. True.

Page 66: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 66

2.1.2. Existential Quantifier

The symbol ∃ denotes “there exists” and is called the

existential quantifier.

Definition: Existential Statement

Let P(x) be a predicate and D the domain of x.

An existential statement is a statement of the form

“ )(, xPDx∈∃ ”.

It is defined to be true if, and only if, P(x) is true for at least

one x in D.

It is defined to be false if, and only if, P(x) is false for all x

in D.

Examples:

• Write the sentence “Some people are vegetarians”

using the existential quantifier.

Let H be the set of human beings. n vegetariaais,hHh∈∃

• Consider },,{ 321 xxxA = . With )(, xPAx∈∃ , the

following must hold: )()()( 321 xPxPxP ∨∨

Thus there will be 1 predicate which must hold.

Page 67: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 67

Exercises:

Write the following statements using the existential

quantifier. Determine whether each statement is true or

false.

• “Some cats are black”

Let C be the set of cats.

blackis,cCc∈∃ . True

• There is a real number whose square is negative.

0, 2 <∈∃ xx .False.

• Some programs are structured.

Let P be the set of programs.

structuredis, pPp∈∃ . True

Page 68: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 68

Exercises:

Write the following statements in words. Determine

whether each statement is true or false.

• mmm =∈∃ 2,

There is an integer whose square is equal to itself.

True. Consider mmm ===∈= 11,1 22 .

Hence the statement is true.

• 1, 2 −=∈∃ xx .

There is a real number whose square is –1.

False.

• ∉∈∃x

x 1,

The reciprocal of some integer is not rational.

True. Consider ∉=∈=011,0

xx .

Hence the statement is true.

Page 69: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 69

2.1.3. Negation of Universal Statements

Let P(x) be a predicate and D the domain of x. The

negation of a universal statement of the form:

)(, xPDx∈∀ is logically equivalent to )(~, xPDx∈∃

Symbolically )(~,))(,(~ xPDxxPDx ∈∃≡∈∀

Example:

• Write down the negation of the following statement.

xxx 21, 2 ≥+∈∀

Negation:

xxx

xxx

xxx

21,

)21(~,

)21,(~

2

2

2

<+∈∃≡

≥+∈∃≡

≥+∈∀

False.

Page 70: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 70

Exercises:

• Write down the negation of the following statement.

0, 2 ≥∈∀ xx

Negation:

0,

)0(~,

)0,(~

2

2

2

<∈∃≡

≥∈∃≡

≥∈∀

xx

xx

xx

False.

• Write down the negation of the following statement.

⎟⎠

⎞⎜⎝

⎛<

+⇒≠∈∀ 110,

yyyy

Negation:

110,

11~0,

11)0(~~,

110~,

110,~

≥+

∧≠∈∃≡

⎟⎠

⎞⎜⎝

⎛<

+∧≠∈∃≡

⎟⎠

⎞⎜⎝

⎛<

+∨≠∈∃≡

⎟⎠

⎞⎜⎝

⎛<

+⇒≠∈∃≡

⎟⎟⎠

⎞⎜⎜⎝

⎛⎟⎠

⎞⎜⎝

⎛<

+⇒≠∈∀

yyyy

yyyy

yyyy

yyyy

yyyy

True, choose y = 1.

Page 71: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 71

Example:

• Write the following statement using quantifiers. Find

its negation and determine whether the statement or its

negation is true, giving a brief reason..

“Every real number is either positive or negative.”

Statement: 00, >∨<∈∀ xxx

Negation:

0,)0()0(,

)0(~)0(~,)00(~,

)00,(~

=∈∃≡≤∧≥∈∃≡

>∧<∈∃≡>∨<∈∃≡

>∨<∈∀

xxxxx

xxxxxx

xxx

The true statement is the negation because x = 0 is neither

positive nor negative.

Page 72: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 72

Exercises:

• Write the following statement using quantifiers. Find

the negation.

“The square of any integer is positive.”

Statement: 0, 2 >∈∀ xx

Negation:

0,

)0(~,

)0,(~

2

2

2

≤∈∃≡

>∈∃≡

>∈∀

xx

xx

xx

There is an integer whose square is not positive. The

negation is true, choose x = 0.

• Write the following statement using quantifiers. Find

the negation.

“All computer programs are finite.”

Let C be the set of computer programs

Statement: finiteis, xCx∈∀

Negation:

( )

finitenot is,finiteis,~

xCxxCx

∈∃≡∈∀≡

Not all computer programs are finite.

Some computer programs are not finite. True?

Page 73: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 73

2.1.4. Negation of Existential Quantifiers

Let P(x) be a predicate and D the domain of x. The

negation of an existential statement of the form:

)(, xPDx∈∃ is logically equivalent to )(~, xPDx∈∀

Symbolically )(~,))(,(~ xPDxxPDx ∈∀≡∈∃

Example:

• Write down the negation of the following statement.

2, 2 =∈∃ xx

Negation:

2,

)2(~,

)2,(~

2

2

2

≠∈∀≡

=∈∀≡

=∈∃

xx

xx

xx

The negation is true.

Page 74: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 74

Exercises:

• Write down the negation of the following statement. )evenis()oddis(, zzz ∨∈∃

Negation:

)evennotis()oddnotis(,)evenis(~)oddis(~,

))evenis()oddis((~,))evenis()oddis(,(~

zzzzzz

zzzzzz

∧∈∀≡∧∈∀≡∨∈∀≡

∨∈∃

The negation is false

• Write down the negation of the following statement.

)primeis()evenis(, nnn ∧∈∃

Negation:

)primenotis()evennotis(,)primeis(~)evenis(~,

))primeis()evenisn((~,))primeis()evenis(,(~

nnnnnn

nnnnn

∨∈∀≡

∨∈∀≡

∧∈∀≡

∧∈∃

The negation is false.

Page 75: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 75

Example:

• Write the following statement using quantifiers. Find

its negation

“Some dogs are vegetarians.”

Let D be the set of dogs.

Statement: vegetarianis, dDd ∈∃

Negation:

riannot vegetaare dogs Allriannot vegetais,

)vegetarianis(~,)vegetarianis,(~

dDddDd

dDd

∈∀≡∈∀≡∈∃

Exercises:

• Write the following statement using quantifiers. Find

the negation.

“There is a real number that is rational.”

Statement: ∈∈∃ xx ,

Negation:

rationalnotarenumbersrealAll,

)(~,),(~

∉∈∀≡∈∈∀≡

∈∈∃

xxxx

xx

False

Page 76: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 76

• Write the following statement using quantifiers. Find

the negation.

P(p): Some computer hackers are over 40.

Let C be the set of computer hackers. 40over is,:)( pCppP ∈∃

or under 40 are ackerscomputer h Allor under40is,

40over not is,40)over is(~,

40)over is,(~:)(~

pCppCp

pCppCp

pP

∈∀≡∈∀≡∈∀≡∈∃

False

• Write the following statement using quantifiers. Find

the negation.

“Some animals are dogs.”

Let A be the set of animals

Statement: dogais, xAx∈∃

Negation:

( )dog a not is,

dog ais,~xAxxAx

∈∀≡∈∃

All animals are not dogs. False

Page 77: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 77

2.1.5. Multiple Quantifiers

When a statement contains multiple quantifiers their order

must be applied as written and will produce different

results for the truth set.

Examples:

Write the following statements using quantifiers:

• “Everybody loves somebody.”

Let H be the set of people.

Statement: ,, HyHx ∈∃∈∀ x loves y.

• “Somebody loves everyone.”

Let H be the set of people.

Statement: ,, HyHx ∈∀∈∃ x loves y.

Page 78: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 78

Exercises:

Write the following statements using quantifiers:

• “Everybody loves everybody.”

Let H be the set of people.

Statement: ,, HyHx ∈∀∈∀ x loves y.

• The Commutative Law of Addition for

Statement: xyyxyx +=+∈∀∈∀ ,, ,

• “Everyone had a mother.”

Let H be the set of humans.

Statement: xyHyHx ofmotherthewas,, ∈∃∈∀ ,

or x was the child of y.

• “There is an oldest person.”

Let H be the set of humans.

Statement: yxHyHx older thanis,, ∈∀∈∃ ,

Page 79: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 79

Examples:

Write the following statements without using quantifiers:

• 0,, =+∈∃∈∀ yxyx ,

Statement: Given any real number, you can find a real

number so that the sum of the two is zero. Alternatively:

Every real number has an additive inverse.

• yyxyx =+∈∀∈∃ ,, ,

Statement: There is a real number, which added to any

other real number results in the other number.

Alternatively: Every real number has an additive identity.

Exercises:

Write the following statements without using quantifiers:

• caac colouredis,animals,colours ∈∃∈∀

Statement: For every colour, there is an animal of that

colour.

Alternatively: There are animals of every colour.

• bppb readhas,people,books ∈∀∈∃

Statement: There is a book everyone has read.

Page 80: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 80

2.1.6. Interpreting Statements with Multiple

Quantifiers

To establish the truth of a statement with more than one

quantifier, take the action suggested by the quantifiers as

being performed in the order in which the quantifiers occur.

Consider },{},,,{ 21321 yyBxxxA == and the

predicate ),( yxP .

There will be 6 possible predicates:

).,(,),(

),,(),,(

),,(,),(

2313

2212

2111

yxPyxP

yxPyxP

yxPyxP

• For ),(,, yxPByAx ∈∀∈∀ to be true the following

must hold:

),(),(

),(),(

),(),(

2313

2212

2111

yxPyxP

yxPyxP

yxPyxP

∧∧

∧∧

Thus there will be 6 predicates which must all be true. That

is for all pairs (x, y), P(x, y) must be true. It will be false if

there is one pair (x, y), for which P(x, y) is false.

Page 81: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 81

• For ),(,, yxPByAx ∈∃∈∀ to be true, the following

must hold:

),(),(

),(),(

),(),(

2313

2212

2111

yxPyxP

yxPyxP

yxPyxP

∨∧

∨∧

Thus there will be 3 predicates which must be true. That is

for every x there must be at least one y so that P(x, y) is

true. Given any element x in A you can find an element y in

B, so that P(x, y) is true. It will be false if there is one x in A

for which P(x, y) is false for every y in B.

• For ),(,, yxPByAx ∈∀∈∃ to be true, the following

must hold:

),(),(

),(),(

),(),(

2313

2212

2111

yxPyxP

yxPyxP

yxPyxP

∧∨

∧∨

Thus there will be 2 predicates which must be true. That is

there is one x that when paired with any y, P(x, y) is true.

You can find one element x in A that with all elements y in

B, P(x, y) is true. It will be false if for every x in A, there is

a y in B for which P(x, y) is false.

Page 82: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 82

• For ),(,, yxPByAx ∈∃∈∃ to be true, the following

must hold:

),(),(

),(),(

),(),(

2313

2212

2111

yxPyxP

yxPyxP

yxPyxP

∨∨

∨∨

Thus there will be 1 predicate which must be true. That is

there is one x that when paired with one y, P(x, y) is true.

You can find one element x in A and one element y in B,

P(x, y) is true. It will be false if for all pairs (x, y), P(x, y) is

false.

Summary:

Statement When true? When false? ),(,, yxPyx ∀∀ P(x, y) is true for

all pairs (x, y) There is a pair (x, y) for which P(x, y) is false

),(,, yxPyx ∃∀ For every x, there is a y for which P(x, y) is true

There is an x such that P(x, y) is false for every y

),(,, yxPyx ∀∃ There is an x such that P(x, y) is true for every y

For every x, there is a y for which P(x, y) is false

),(,, yxPyx ∃∃ There is a pair (x, y) for which P(x, y) is true

P(x, y) is false for all pairs (x, y)

Page 83: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 83

2.1.7. Negation of Statements with Multiple

Quantifiers.

To negate statements with multiple quantifiers, each

quantifier is negated and the predicate must be negated.

• To negate ),(,, yxPByAx ∈∀∈∀

( ) ),(~,,),(,,~ yxPByAxyxPByAx ∈∃∈∃≡∈∀∈∀

• To negate ),(,, yxPByAx ∈∃∈∀

( ) ),(~,,),(,,~ yxPByAxyxPByAx ∈∀∈∃≡∈∃∈∀

• To negate ),(,, yxPByAx ∈∀∈∃

( ) ),(~,,),(,,~ yxPByAxyxPByAx ∈∃∈∀≡∈∀∈∃

• To negate ),(,, yxPByAx ∈∃∈∃

( ) ),(~,,),(,,~ yxPByAxyxPByAx ∈∀∈∀≡∈∃∈∃

Examples:

Write the negation of the following:

• Statement: 0,, =+∈∃∈∀ yxyx ,

Negation:

( )

0then,Take:False0,,0,,~

=−=+−=≠+∈∀∈∃≡=+∈∃∈∀

xxyxxyyxyxyxyx

,

,

Page 84: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 84

• Statement: 1,, =∈∀∈∃ xyyx ,

Negation:

( )

1then,Take:True

1,,1,,~

2 ≠−=−=

≠∈∃∈∀≡=∈∀∈∃

xxyxy

xyyxxyyx

,

,

Exercises:

Write the negation of the following:

• Statement: caac colouredis,animals,colours ∈∃∈∀

Negation:

( )caac

caaccolourednot is,animals,colours

colouredis,animals,colours~∈∀∈∃≡∈∃∈∀≡

There is a colour which every animal is not. True, my cat is

not purple.

• Statement: bppb readhas,people,books ∈∀∈∃

Negation:

( )bppb

bppbnot readhas,people,books

readhas,people,books~∈∃∈∀≡∈∀∈∃≡

There is someone who has not read every book. True, me,

I’ve not read every book.

Page 85: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 85

Section 3. Proofs

3.1. Introduction.

A proof is a carefully reasoned argument which establishes

that a given statement is true. Logic is a tool for the

analysis of proofs. Each statement within a proof is an

assumption, an axiom, a previously proven theorem, or

follows from previous statements in the proof by a

mathematical or logical rules and definitions.

3.1.1. Assumptions.

Assumptions are the statements you assume to be true as

you try to prove the result.

Example:

If you want to prove:

“If ∈x and ∈n is even, then 0>nx ”

Your proof should start with the assumptions that ∈x

and ∈n is even. Further, you can use the “definition” of

an even natural number, and write the assumptions as

follows:

Let ∈x , and ∈n be even, that is, pnp 2, =∈∃ .

Page 86: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 86

Assumptions are often thought to be the “given

information” or information we “know” that can be used in

our proof. As in the example above, when you are proving

statements of the form QP ⇒ , then the assumption is the

statement P.

Exercise:

Write the statement to be proven in the previous example

using logical notation:

0)]2,:()[( >⇒=∈∃∈∧∈ nxpnpnx

3.1.2. Axioms.

Axioms are laws in Mathematics that hold true and require

no proof.

Examples:

• xx =

• xx =+ 0

• )()]()([,,, zxzyyxzyx =⇒=∧=∈∀

Page 87: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 87

3.1.3. Mathematical Rules.

Mathematical Rules are known rules that are often used.

Example:

)()(,,, zyzxyxzyx +=+⇒=∈∀

3.1.4. Logical Rules.

Logical Rules are rules of logic such as Substitution and

Substitution of Equivalence using the laws introduced

earlier

3.2. The Law of Syllogism

If QP ⇒ and RQ ⇒ are both tautologies, then so is

RP ⇒ .

Exercise:

• Write the Law of Syllogism using logical notation: )())()(( RPRQQP ⇒⇒⇒∧⇒

Page 88: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 88

• Show, using the quick method that the Law of

Syllogism is a tautology.

((P ⇒ Q) ∧ (Q ⇒ R)) ⇒ ( P ⇒ R) Step: 1 3 2 5* 4 1. F 2. T F 3. T F 4. T T 5. T T F F

1. Place “F” under main connective

2. For “F” to occur under the main connective, ∧ must be

“T” and ⇒ must be “F”

3. For “F” to occur under ⇒ , P must be “T” and R must

be “F”.

4. For “T” under ∧ , both ⇒ must be “T”

5. For the first ⇒ to be true, given P is “T”, Q must be

“T”. For the second ⇒ to be true, given R is “F”, Q must

be “F”.

Q cannot be both “T” and “F”, thus

)())()(( RPRQQP ⇒⇒⇒∧⇒ can only ever be true

and is a tautology.

Page 89: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 89

Examples:

• s is a square ⇒ s is a rectangle

s is a rectangle ⇒ s is a parallelogram

s is a parallelogram ⇒ s is a quadrilateral

∴ s is a square ⇒ s is a quadrilateral.

960

960)96(

0)96(0)3(

0)3(0

22

22

22

22

−≥−⇒≥∴

−≥−⇒≥+−

≥+−⇒≥−

≥−⇒≥

xxx

xxxx

xxx

xx

Exercise:

Complete the following using the Law of Syllogism:

• t is studying WUCT121 ⇒ t is enrolled in a diploma

t is enrolled in a diploma ⇒ t is student at WCA.

∴ t is studying WUCT121 ⇒ t is student at WCA.

∈⇒∈∴∈⇒∈

∈⇒∈∈⇒∈

xxxxxxxx

Page 90: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 90

Most results in Mathematics that require proofs are of the

form QP ⇒ . The Law of Syllogism provides the most

common method of performing proofs of such statements.

The Law of Syllogism is a kind of transitivity that can

apply to ⇒ .

To use the Law of Syllogism, we set up a sequence of

statements, QPPPPPPP n ⇒⇒⇒⇒ ,,,, 32211 K .

Then, by successive applications of the law, we have

QP ⇒ .

Example.

We wish to prove that for ∈n , if n is even, then 2n is

even.

In logic notation, we wish to prove:

n is even (P) 2n⇒ is even (Q).

This has the form QP ⇒ and we note that our assumption

includes ∈n and P: n is even.

Page 91: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 91

Proof:

)()()(

)(

evenis)2(2

)2(24

42,

2,evenis

3

32

21

1

222

2222

22

QPPPPPPP

npn

pnpn

pnpnp

pnpn

⇒⇒⇒⇒

⇒=

=⇒=

=⇒=∈∃

=∈∃⇒

K

K

K

K

Completing the proof is simply a matter of applying the

Law of Syllogism three times to get n is even 2n⇒ is

even.

The previous proof can be simplified to:

evenis

2),2(2

4

2,evenis

2

222

22

n

ppn

pn

pnpn

∈=⇒

=⇒

=∈∃⇒

The use of Law of Syllogism is a matter of common sense.

We shall use the Law of Syllogism without direct

reference.

Note. The use of the connective ⇒ in the previous proof

seems a little repetitive, albeit valid. For variety, the

connective can be replaced by words such as therefore,

thus, so we have, and hence.

Page 92: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 92

3.3. Modus Ponens

3.3.1. Rule of Modus Ponens:

If P and QP ⇒ are both tautologies, then so is Q.

In other words, Modus Ponens simply says that if we know

P to be true, and we know that P implies Q, then Q must

also be true.

Exercise:

• Write the rule of Modus Ponens using logical notation:

QQPP ⇒⇒∧ ))((

Page 93: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 93

• Show, using the quick method that the rule of Modus

Ponens is a tautology.

(P ∧ (P ⇒ Q)) ⇒ Q Step 2 1 3*

1. Place “F” under main

connective.

F

2. For “F” to occur under the

main connective, ∧ must be

“T” and Q must be “F”

T F

3. For “T” to occur under ∧ , P

must be “T” and QP ⇒ must

be “T”

T T

4. For “T” to occur under

QP ⇒ ,when P is “F” P must

be “F”

F F

P cannot be both “T” and “F”, thus QPQP ⇒∧⇒ ))(( can only

ever be true and is a tautology.

Page 94: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 94

Examples:

• If Zak is a cheater, then Zak sits in the back row

Zak is a cheater

Therefore Zak sits in the back row.

• If 2 = 3 then I will eat my hat

2 = 3

Therefore I will eat my hat

Exercise:

Complete the following using Modus Ponens

• If Zeus is a God, then Zeus is immortal

Zeus is a God

Therefore Zeus is immortal.

• If it is sunny then I will go to the beach

It is sunny

Therefore I will go to the beach

• If I study hard then I will pass

I study hard

Therefore I will pass

Page 95: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 95

3.3.2. Universal Rule of Modus Ponens:

If P(x) and Q(x) are predicates, the universal rule of Modus

Ponens is )())())()((( aQaPxQxP ⇒∧⇒ .

This means Modus Ponens can be applied to predicates

using specific values for the variables in the domain.

Examples:

• If x is even [P(x)], then 2x is even [Q(x)]

x = 98374 [P(a)]

Therefore 298374 is even. [Q(a)]

• The Principle of Mathematical Induction says that

when you have a statement, Claim(n), that concerns ∈n ,

If ⎩⎨⎧

∈∀+⇒ kkkP

),1(Claim)(Claim)1(Claim

: then Claim(n) is

true for all ∈n (Q)

Thus we have QP ⇒ .

Page 96: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 96

Exercise:

According to Modus Ponens, what must we establish so we

can apply this principle to the following statement and be

able to say “Claim(n) is true for all ∈n ”?

• Claim(n): 14 −n is a multiple of 3.

We must show that Claim(n) satisfies P.

So we need to establish two things:

1. Claim(1), i.e. 141 − is a multiple of 3; AND

2. ∈∀+⇒ kkk ),1(Claim)(Claim , i.e. If 14 −k is a

multiple of 3 for all ∈k , then ( ) 14 1 −+k is a multiple

of 3.

Page 97: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 97

3.4. Modus Tollens

3.4.1. Rule of Modus Tollens:

If ~Q and QP ⇒ are both tautologies, then so is ~P.

In other words, Modus Ponens simply says that if we know

~Q to be true, and we know that P implies Q, then ~P must

also be true. Similarly if we know Q to be false, and we

know that P implies Q, then P must also be false

Exercise:

• Write the rule of Modus Ponens using logical notation: PQQP ~)~)(( ⇒∧⇒

Page 98: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 98

• Show, using the quick method that the rule of Modus

Tollens is a tautology.

((P ⇒ Q) ∧ ~Q ⇒ ~P Step: 2 3 1 4* 5

1.Place “F” under main

connective

F

2. For “F” to occur under

the main connective, ∧

must be “T” and ~P must

be “F”

T F

3. For “T” to occur under ∧ , ~Q must be “T” and

QP ⇒ must be “T”

T T

4. For “T” to occur under

QP ⇒ ,when P is “T”, Q

must be “T”

T T

At step 2, ~P is “F”, thus P is “T”. Step 3 shows ~Q is “T”

thus Q is “F” and step 4 gives Q is “T”. Q cannot be both “T”

and “F”, thus PQQP ~)~)(( ⇒∧⇒ can only ever be true

and is a tautology.

Page 99: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 99

Examples:

• If Zak is a cheater, then Zak sits in the back row

Zak sits in the front row

Therefore Zak is not a cheater.

• If 2 > 3 then Earth is flat

The Earth is not flat

Therefore 2 u 3

Exercise:

Complete the following using Modus Tollens

• If Zeus is a God, then Zeus is immortal

Zeus is not immortal

Therefore Zeus is not a God.

• If I go to the beach then it is sunny

It is not sunny

Therefore I don’t go to the beach

• If I arrive on time then I will be marked present

I was marked absent

Therefore I did not arrive on time.

Page 100: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 100

3.4.2. Universal Rule of Modus Tollens:

If P(x) and Q(x) are predicates, the universal rule of Modus

Tollens is: )(~))(~))()((( aPaQxQxP ⇒∧⇒ .

This means Modus Tollens can be applied to predicates

using specific values for the variables in the domain.

Example:

• If ∈x , then baxbba =≠∈∃ ,0,,

2=x

Therefore ∉2 .

Exercise:

Complete the following using the universal rule of Modus

Tollens

• If ∈x , then 1≥x

1−=x

Therefore ∉−1 .

Page 101: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 101

3.5. Proving Quantified Statements

3.5.1. Proving Existential Statements

A statement of the form ( )xPDx ,∈∃ is true if and only if

( )xP is true for at least one Dx ∈ .

To prove this kind of statement, we need to find one Dx∈

that makes ( )xP true.

Examples:

• Prove that there exists an even integer that can be

written two ways as the sum of two primes.

The statement is of the form ( )xPDx ,∈∃ , where D is the

set of even integers and P(x) is the statement “x can be

written as the sum of two primes”

Thus we need find only one even integer which satisfies

P(x).

Essentially, to find the appropriate number, we have to

“guess”.

Consider 7714 += (7 is prime); and 11314 += (3 and 11

are prime).

Therefore, there exists an even integer that can be written

two ways as the sum of two primes.

Page 102: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 102

• Let ∈sr, . Prove ksrk 21822, =+∈∃

The statement is of the form ( )kPDk ,∈∃ , where D is the

set of integers and P(k) is the statement: “ ksr 21822 =+ ”.

Thus we need find only one integer which satisfies P(k)

∈+==

+=+srkk

srsr911where2

)911(21822

Exercises:

• Prove 05, =+∈∃ xx .

Let ∈−= 5x , then 0555 =+−=+x .

• Prove that if ∈ba, ,then ba 810 + is divisible by 2

(i.e., is even).

( )baba 452810 +=+ and ∈+ ba 45 .

Thus, ( )ba 8102 + .

Page 103: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 103

3.5.2. Proving Universal Statements

A statement of the form ( )xPDx ,∈∀ is true if and only if

( )xP is true for at every Dx ∈ .

To prove this kind of statement, we need prove that for

every Dx ∈ , ( )xP is true.

In order to prove this kind of statement, there are two

methods:

Method 1: Method of Exhaustion.

The method of exhaustion is used when the domain is

finite.

Exhaustion cannot be used when the domain is infinite.

To perform the method of exhaustion, every member of the

domain is tested to determine if it satisfies the predicate.

Page 104: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 104

Example:

• Prove the following statement:

Every even number between 2 and 16 can be written as a

sum of two prime numbers.

The statement is of the form ( )xPDx ,∈∀ , where

}14,12,10,8,6,4{=D ,and P(x) is the statement “x can be

written as the sum of two prime numbers”.

The domain D is finite so the method of exhaustion can be

used.

Thus we must test every number in D to show they can be

written as the sum of two primes.

7714538

7512336

5510224

+=+=

+=+=

+=+=

Thus by the method of exhaustion every even number

between 2 and 16 can be written as a sum of two prime

numbers.

Page 105: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 105

Exercise:

• Prove for each integer n with 101 ≤≤ n , 112 +− nn is

prime.

The statement is of the form ( )nPDn ,∈∀ , where

}10,9,8,7,6,5,4,3,2,1{=D ,and P(n) is the statement

“ 112 +− nn is prime”. Thus we must show all numbers in

D satisfy P(n).

primeis101111010)10(

primeis671188)8(

primeis411166)6(

primeis231144)4(

primeis131122)2(

primeis891199)9(

primeis531177)7(

primeis311155)5(

primeis171133)3(

primeis111111)1(

2

2

2

2

2

2

2

2

2

2

=+−=

=+−=

=+−=

=+−=

=+−=

=+−=

=+−=

=+−=

=+−=

=+−=

P

P

P

P

P

P

P

P

P

P

Thus by the method of exhaustion for each integer n with

101 ≤≤ n , 112 +− nn is prime.

Page 106: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 106

Method 2: Generalised Proof.

The generalised proof method is used when the domain is

infinite.

It is called the method of generalizing from the generic

particular.

In order to show that every element of the domain satisfies

the predicate, a particular but arbitrary element of the

domain is chosen and shown to satisfy the predicate.

The method to show the predicate is satisfied will vary

depending on the form of the predicate.

Specific techniques of generalized proof will be outlined

later in this section.

Page 107: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 107

Example:

• Pick any number, add 3, multiply by 4, subtract 6,

divide by two and subtract twice the original. The result is

3.

Proof:

Choose a particular but arbitrary number, say x, and then

determine if it satisfies the statement.

Step Result

Pick a number x

Add 3 3+x

Multiply by 4 1244)3( +=×+ xx

Subtract 6 646124 +=−+ xx

Divide by 2 322)64( +=÷+ xx

Subtract twice the original 3232 ==+ xx

In this example, x is particular in that it represents a single

quantity, but arbitrarily chosen as it can represent any

number.

Page 108: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 108

3.6. Disproving Quantified Statements

3.6.1. Disproving Existential Statements

A statement of the form ( )xPDx ,∈∃ is false if and only

if ( )xP is false for all Dx ∈ .

To disprove this kind of statement, we need to show the for

all Dx∈ , ( )xP is false.

That is we need to prove it’s negation: )(~,))(,(~ xPDxxPDx ∈∀≡∈∃

This is equivalent to proving a universal statement and so

the method of exhaustion or the generalized proof method

is used.

Example:

• Disprove: There exists a positive number n such that

232 ++ nn is prime.

Proving the given statement is false is equivalent to proving

its negation is true. That is proving that for all numbers n ,

232 ++ nn is not prime. Since this statement is universal,

its proof requires the generalised proof method.

Page 109: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 109

3.6.2. Disproving Universal Statements

A statement of the form ( )xPDx ,∈∀ is false if and only

if ( )xP is false for at least one Dx ∈ .

To disprove this kind of statement, we need to find one

Dx∈ such that ( )xP is false.

That is we need to prove it’s negation: )(~,))(,(~ xPDxxPDx ∈∃≡∈∀

This is known as finding a counterexample.

Example:

• Disprove: ).()(,, 22 bababa =⇒=∈∀

Let )()(:),( 22 bababaP =⇒= .

We need to show ),(~,, baPba ∈∃

Counterexample:

Let .1,1 −== ba Then 22 ba = however ba ≠ .

Now true ⇒ false is false, thus ),( baP is false, and

),(~ baP is true

So, we have shown, by counterexample ),(~,, baPba ∈∃

Page 110: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 110

Exercises:

• Disprove: ).00(, <∨>∈∀ xxx

Need to prove: ).00(~, <∨>∈∃ xxx

That is ).00(, ≥∧≤∈∃ xxx

Let 0=x .

• Disprove ).oddis2

1()oddis(, −⇒∈∀

zzz

Let ).evenis224

215(,)oddis(,5 ==

−∈= zz

• Prove or disprove: ).0(,, =+∈∃∈∀ yxyx

To prove the statement: Find a specific y for each “general”

x.

Consider an .∈x Let ,∈−= xy then

( ) 0=−+=+ xxyx .

Page 111: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 111

3.7. Generalised Proof Methods

Before proving a statement, it is of great use to write the

statement using logic notation, including quantifiers, where

appropriate.

Doing this means you have clearly written the assumptions

you can make AND the conclusion you are aiming to reach.

Example:

• Prove: For all integers n, if n is odd, then 2n is odd.

Rewritten using logic notation:

oddisoddis, 2nnn ⇒∈∀

Here the domain is given as , , and the predicate involves

the statements: P(n) is n is odd, Q(n) is 2n is odd.

The form of the predicate is )()( nQnP ⇒ .

Thus the assumption that can be made is P(n) and the

conclusion to be reached is Q(n).

Page 112: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 112

3.7.1. Direct Proof

A direct proof is one in which we begin with the

assumptions and work in a straightforward fashion to the

conclusion.

The steps in the final proof must proceed in the correct

“direction” beginning with the initial assumption and

following known laws, rules, definitions etc. until the final

conclusion is reached. The proof must not start with what

you are trying to prove.

Example:

• Prove that if 1593 =−x then 8=x .

Assuming the domain to be , then the statement is of the

form )()(, xQxPx ⇒∈∀ .

Thus the assumption is 1593:)( =−xxP , and the

conclusion 8:)( =xxQ .

83

243

3243

9159931593

=⇒

=⇒

=⇒+=+−⇒=−

x

xxxx

Page 113: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 113

Exercise:

• Prove: For all integers n, if n is odd, then 2n is odd.

Rewritten using logic notation:

oddisoddis, 2nnn ⇒∈∀

Here the domain is given as , , and the predicate involves

the statements: P(n) is n is odd, Q(n) is 2n is odd.

The form of the predicate is )()( nQnP ⇒ .

Thus the assumption that can be made is P(n) and the

conclusion to be reached is Q(n).

Proof:

oddofdefinitionoddis

2212

1)22(2

144

)12(

oddofdefinition12oddis

2

22

22

22

22

n

ppqqn

ppn

ppn

pn

ppnn

∈+=+=⇒

++=⇒

++=⇒

+=⇒

∈+=⇒

Page 114: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 114

When the statement to be proven is of the form:

)()( xQxP ⇒ , the assumption which begins the proof is

).(xP

If the form is not )()( xQxP ⇒ , or )(xP is not clear, it may

be necessary to examine what you are aiming to prove and

establish an assumption from which to begin.

Example:

• Prove that for ( ) 212, 2 ≤++−∈ xxx .

(Do not start with this!)

In this case, the form is not )()( xQxP ⇒ .

By examining what we are aiming to prove, i.e.

( ) 2122 ≤++− xx a beginning to the proof can be found.

( )⎪⎪⎩

⎪⎪⎨

≥−⇒

≥+−⇒

−≥−−⇒≤++−

true.is 01

012

212212

:working2

2

22

x

xx

xxxx

We can now put the proof together:

We know that ( ) 01 2 ≥−x for any .∈x

Thus,

Page 115: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 115

1bygmultiplyin212

sidesbothfrom2gsubtractin212

expanding012

knowniswhat0)1(

2

2

2

2

−≥++−⇒

−≥−−⇒

≥+−⇒

≥−

xx

xx

xx

x

Note. In the example, we did NOT start with the statement

( ) 2122 ≤++− xx , as we technically do not know whether

it is true or not. We started our proof with a statement we

know to be true.

Exercise:

• Prove the following:

If the right angled triangle XYZ with sides of length x and y

and hypotenuse z has an area of 4

2z , then the triangle is

isosceles.

z

Z

y

Y x

X

Page 116: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 116

The form of statement is )()( xQxP ⇒ .

What is known. i.e. the assumptions that can be made are:

• Area of the triangle: 4

2zA = , (1)

• Area of any triangle:

( ) ( ) xy21

21 height base =××= (2)

• The sides are of length x and y and hypotenuse

z so by Pythagoras: 222 yxz += . (3)

What is to be proven: That triangle XYZ is isosceles. Thus

we must show two sides have equal length.

Proof:

Substituting (3) into (1) and equating with (2) gives:

24

22 xyyx=

+

( )

( )yxyx

yxyx

xyyxxyyx

=⇒=−⇒

=+−⇒

=+⇒=+

0

02

4by sidesboth gmultiplyin224

2

22

2222

So two sides are equal and thus triangle XZY is isosceles.

Page 117: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 117

3.8. Indirect Proofs.

3.8.1. Method of Proof by Contradiction

The method of proof by contradiction can be used when the

statement to be proven is not of the form )()( xQxP ⇒ .

The method is as follows:

1. Suppose the statement to be proven is false. That is,

suppose that the negation of the statement is true.

2. Show that this supposition leads to a contradiction

3. Conclude that the statement to be proven is true.

Example:

• Prove there is no greatest integer.

Suppose not, that is suppose there is a greatest integer. N.

Then nN ≥ for every integer n. Let 1+= NM . Now M is

an integer since it is the sum of integers. Also NM > since

1+= NM

Thus M is an integer that is greater than N. So N is the

greatest integer and N is not the greatest integer, which is a

contradiction.

Thus the assumption that there is a greatest integer is false,

hence there is no greatest integer is true.

Page 118: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 118

Exercise:

• Prove there is no integer that is both even and odd.

Suppose not, that is suppose there is a greatest integer an

integer n, that is both even and odd.

By the definition of even )1(,2 K∈= kkn , and by the

definition of odd )2(,12 K∈+= lln .

If n is both even and odd then equation (1) and (2) gives:

∉=−⇒

=−⇒=−⇒

+=

21

1)(2122

122

lk

lklk

lk

Now since k and l are integers, the difference k – l must be

an integer. However ∉=−21lk . Thus k – l is an integer

and k – l is not an integer, which is a contradiction.

Thus the supposition is false and hence the statement

“There is no integer that is both even and odd” is true.

Page 119: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 119

3.8.2. Proof by Contraposition

Recall the following logical equivalence: ).~(~)( PQQP ⇒≡⇒

)~(~ PQ ⇒ is known as the contrapositive of )( QP ⇒ .

This equivalence indicates that if )~(~ PQ ⇒ is a true

statement, then so too is )( QP ⇒ .

Thus, in order to prove )( QP ⇒ , we prove the

contrapositive, that is )~(~ PQ ⇒ , is true.

The method of proof by contraposition can be used when

the statement to be proven is of the form )()( xQxP ⇒ .

The method is as follows:

1. Express the statement to be proven in the form: ).()(, xQxPDx ⇒∈∀

2. Rewrite the statement in the contrapositive

form: ).(~)(~, xPxQDx ⇒∈∀

3. Prove the contrapositive by a direct proof.

a. Suppose that x is a particular but arbitrary

element of D, such that Q(x) is false.

b. Show that P(x) is false.

Page 120: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 120

Example:

• Prove that for all integers n if 2n is even, n is even.

The statement can be expressed in the form:

.evenisevenis, 2 nnn ⇒∈∀

Thus the contrapositive is

.evennot isevennot is, 2nnn ⇒∈∀ That is

.oddisoddis, 2nnn ⇒∈∀

To prove the contrapositive:

Let n be any odd integer.

Then )1(,12 K∈+= kkn

Show 2n is odd, i.e. show ∈+= lln ,122

∈+=+=

++=

++=

+=

kkll

kk

kk

bykn

2212

1)22(2

144

)1()12(

2

2

2

22

So 2n is odd, and the contrapositive is true.

Hence the statement “for all integers n if 2n .is even, n is

even” is also true.

Page 121: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 121

Exercise:

• Prove that for all integers n if 2|5 n/ .then n|5 / .

The statement can be expressed in the form:

.|5|5, 2 nnn /⇒/∈∀

Thus the contrapositive is .|5|5, 2nnn ⇒∈∀

To prove the contrapositive:

Let n be any odd integer.

Then )1(,5|5 K∈=⇒ kknn

Show 2|5 n , i.e. show ∈= lln ,52

∈==

=

=

=

2

2

2

22

55

)5(5

25

)1()5(

kll

k

k

bykn

So 2|5 n , and the contrapositive is true.

Hence the statement “for all integers n if 2|5 n/ .then n|5 / ”

is also true.

Page 122: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 122

Exercise:

• Prove if y is irrational, then y + 7 is irrational.

The statement can be expressed in the form: ∉+⇒∉∈∀ 7, yyy

Thus the contrapositive is ∈⇒∈+∈∀ yyy 7,

To prove the contrapositive:

Let. ∈+∈ 7, yy , so 0,,,7 ≠∈=+ bbabay .

Show ∈y , that is 0,,, ≠∈= ddcdcy

0,,7

7

77

≠∈=−==⇒

−=⇒

−=⇒=+

dbdbacdcy

bbay

bay

bay

Therefore ∈y , and the contrapositive is true.

Hence the statement “if y is irrational, then y + 7 is

irrational” is also true.

Page 123: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 123

3.8.3. Proof by Cases

When the statement to be proven is of the form, or can be

written in the form: RQP ⇒∨ )( , the method of proof by

cases can be used.

It relies on the logical equivalence ).)(())()(( RQPRQRP ⇒∨≡⇒∧⇒

The method is as follows:

1. Prove RP ⇒

2. Prove .RQ ⇒

3. Conclude .)( RQP ⇒∨

If the statement is not written in the form RQP ⇒∨ )( , it

is necessary to establish the particular cases by exhaustion.

Page 124: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 124

Example:

• Prove: If 0≠x or 0≠y , then 022 >+ yx .

The statement can be expressed in the form:

0)0()0( 22 >+⇒≠∨≠ yxyx

We assume ∈yx, , thus .0,0 22 ≥≥ yx

Proof:

Case 1: Prove 00 22 >+⇒≠ yxx

Let 0≠x , then 02 >x and 02 ≥y .

Thus 022 >+ yx .

Case 2: Prove 00 22 >+⇒≠ yxy

Let 0≠y , then 02 >y and 02 ≥x .

Thus 022 >+ yx .

Therefore If 0≠x or 0≠y , then 022 >+ yx .

Page 125: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 125

Exercise.

• Prove: If 2−≤x or 2≥x , then 042 ≥−x .

The statement can be expressed in the form:

04)2()2( 2 ≥−⇒≥∨−≤ xxx

Proof:

Case 1: Prove 042 2 ≥−⇒−≤ xx

04

4

2

2

2

≥−⇒

≥⇒

−≤

x

x

x

Therefore 042 2 ≥−⇒−≤ xx

Case 2: Prove 042( 2 ≥−⇒≥ xx

04

4

2

2

2

≥−⇒

≥⇒

x

x

x

Therefore 042 2 ≥−⇒≥ xx

Thus if 2−≤x or 2≥x , then 042 ≥−x .

Page 126: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 126

If the statement is not written in the form RQP ⇒∨ )( , it

is necessary to establish the particular cases by exhaustion.

Example.

• Prove: 1, 2 ++∈∀ mmm is odd.

The statement is not in the form .)( RQP ⇒∨ However by

considering )oddis()evenis( mmm ∨⇒∈ . Then the

statement can be expressed in the form:

oddis1)oddis()evenis( 2 ++⇒∨ mmmm

Case 1: Prove oddis1evenis 2 ++⇒ mmm

)1(,2evenis K∈=⇒ ppmm .

( )

( )( ) ∈+=+=

++=

++=

++=++

ppkk

pp

pp

ppmm

2

2

2

22

2 where,12

122

124

)1(by1221

Therefore, oddis1evenis 2 ++⇒ mmm .

Page 127: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 127

Case 2: Prove oddis1oddis 2 ++⇒ mmm

)2(,12oddis K∈+=⇒ qqmm .

( )

( )( ) ∈++=+=

+++=

+++=

+++++=

++++=++

132 where,12

11322

1264

112144

)2(by112121

2

2

2

2

22

qqll

qq

qq

qqq

qqmm

Therefore, oddis1oddis 2 ++⇒ mmm .

Therefore, oddis1)oddis()evenis( 2 ++⇒∨ mmmm .

Therefore, 1, 2 ++∈∀ mmm is odd.

Page 128: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 128

Exercise.

• Prove: 3, 2 +−∈∀ nnn is odd.

The statement is not in the form .)( RQP ⇒∨ However by

considering )oddis()evenis( nnn ∨⇒∈ . Then the

statement can be expressed in the form:

oddis3)oddis()evenis( 2 +−⇒∨ nnnn

Case 1: Prove oddis3evenis 2 +−⇒ nnn

)1(,2evenis K∈=⇒ ppnn .

( )

( )( ) ∈+−=+=

++−=

++−=

+−=+−

12 where,12

1122

1224

)1(by3223

2

2

2

22

ppkk

pp

pp

ppnn

Therefore, oddis3evenis 2 +−⇒ nnn .

Page 129: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 129

Case 2: Prove oddis3oddis 2 +−⇒ nnn

)2(,12oddis K∈+=⇒ qqnn .

( )

( )( ) ∈++=+=

+++=

+++=

+−−++=

++−+=+−

12 where,12

1122

1224

312144

)2(by3)12(123

2

2

2

2

22

qqll

qq

qq

qqq

qqnn

Therefore, oddis3oddis 2 +−⇒ nnn .

Therefore, oddis3)oddis()evenis( 2 +−⇒∨ nnnn .

Therefore, 3, 2 +−∈∀ nnn is odd.

Page 130: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 130

Section 4. Set Theory

4.1. Definitions

A set may be viewed as any well defined collection of

objects, called elements or members of the set.

Sets are usually denoted with upper case letters, A, B, X,

Y,… while lower case letters are used to denote elements a,

b, x, y,…of a set.

Membership in a set is denoted as follows:

• Sa ∈ denotes that a is a member or element of a

set S. Similarly Sba ∈, denotes that a and b are both

elements of a set S.

• Sa ∉ denotes that a is not an element of a set S.

Similarly Sba ∉, denotes that neither of a and b are

elements of a set S.

In Set Theory, we work within a Universe, U, and consider

sets containing elements from U.

Page 131: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 131

A set may be specified in essentially two ways:

1. The elements of the set are listed within braces, {

}, and separated by commas.

Technically, the listing of elements can be done only for

finite sets. However, if an infinite set is defined by a

“simple” rule, we sometimes write a few elements and then

use “…” to mean roughly “and so on” or “by the same

rule”.

Examples:

• }9,7,5,3,1{=A . The set A is the finite collection of

odd integers, 1 to 9 inclusive

• },4,2,0,2,4,{ KK −−=B . The set B is the infinite

collection of even integers.

Exercises:

• List a finite set, C, containing even integers between

10 and 20 inclusive. }20,18,16,14,12,10{=C

• List an infinite set, D, containing natural numbers that

are divisible by 3 },9,6,3,0{ K=D

Page 132: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 132

2. A statement defining the properties which

characterise the elements in the set is written within braces

Examples:

• )}91oddis(:{ ≤≤∧∈= zzzA . The set A is the

finite collection of odd integers, 1 to 9 inclusive

• }2,:{ kzkzB =∈∃∈= . The set B is the infinite

collection of even integers.

Exercises:

• Define a finite set, C, containing even integers

between 10 and 20 inclusive

)}2010evenis(:{ ≤≤∧∈= zzzC

• Define an infinite set, D, containing natural numbers

that are divisible by 3

}|3:{ nnD ∈=

Page 133: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 133

4.1.2. Axiom of Specification.

Given a Universe U and any statement )(xP involving

Ux∈ , then there exists a set A such that

)).((, xPAxUx ⇔∈∈∀ Further, we write

)}.(:{ xPUxA ∈=

In other words, the Axiom of Specification says that we can

pick a set and a property and build a new set. This is why

the notation for A is sometimes referred to as set-builder

notation.

Example:

Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} and )(xP be the

statement “x is odd”.

\ by the Axiom of Specification, }.oddis:{ xUxA ∈=

Notes:

1. We know an element x belongs to the set

)}(:{ xPUxA ∈= if x satisfies the condition )(xP .

2. This notation is more simply written

)}(:{ xPDx∈ .

This is called set builder notation. In using this notation, the

elements of the domain, D, must belong to the Universe, U,

Page 134: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 134

and ( )xP can be any predicate involving x. D could be all

of U.

Examples:

• The interval [0, 1] can be written in set builder

notation as:

{ } { }10:10: ≤≤∈=≤≤∧∈ xxxxx

• The set of all rational numbers, – can be written as:

⎭⎬⎫

⎩⎨⎧ ≠∧∈==

⎭⎬⎫

⎩⎨⎧ ≠∧∈=

0,::

0,:

bbabaxx

bbaba

• }1,1,0{}:{ 3 −==∈ xxx .

Exercises:

Write down the following sets by listing their elements:

• }1{}:{ 3 ==∈ xxx

• }3,3{}9:{ 2 −==∈ xx

• }{}7:{ 2 ==∈ xx

Page 135: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 135

4.2. Venn Diagrams

Venn diagrams are a pictorial method of demonstrating the

relationship between set. The universal set, U, is

represented by a rectangle and sets within the universe are

depicted with circles.

While a Venn diagram may be used to demonstrate the

relationship between sets, it does not provide a method of

proving those relationships.

Page 136: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 136

4.3. Special Sets

4.3.1. The Singleton Set

Sets having a single element are frequently called singleton

sets.

Example:

• {1} is read “singleton 1”.

• If Ua∈ , then }{}:{ aaxUx ==∈

Note: The singleton set { }a is NOT the same as the element

a.

4.3.2. The Empty Set

The empty set or null set is a set which contains no

elements.

It is denoted by the symbol ∆ or by empty braces { }.

Using set builder notation, one way of defining the empty

set is: }:{ xxx ≠∈= ∆

Page 137: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 137

4.4. Subsets

4.4.1. Definition: Subset.

If A and B are sets, then A is called a subset of B, written

BA ⊆ , if and only if, every element in A is also in B.

Examples:

• }3,2,1{}2,1{ ⊆

• The Venn diagram demonstrating BA ⊆ is:

Exercises:

• Write the definition of subset using logic notation.

),( BxAxUxBA ∈⇒∈∈∀⇔⊆

• Is {cat, dog} ⊆ {bird, fish, cat, dog}? Yes

Page 138: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 138

4.4.2. Definition: Proper Subset.

If A and B are sets, then A is called a proper subset of B,

written BA ⊂ , if and only if, every element in A is also in

B but there is at least one element of B that is not in A.

A is a proper subset of B if BA ⊆ but BA ≠ .

Examples:

• }3,2,1{}2,1{ ⊂

Exercises:

• Draw a Venn diagram demonstrating BA ⊂ , where

}2,1{=A and }5,4,3,2,1{=B

• Is },,{},,{ abccba ⊂ ? No

Page 139: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 139

Notes.

1. If BA ⊆ , then each element of A belongs to B, or

for each Ax∈ , it is true that Bx∈ .

2. If A is a subset of B, then B is sometimes called a

superset of A.

3. If A and B are sets, then to prove BA ⊆ , we need

to prove BxAxx ∈⇒∈∀ ,

4. If A is a proper subset of B, there must be at least

one element in B that is not in A.

5. If A and B are sets, to prove A is not a subset of B,

denoted BA⊄ , we need to prove )(~ BA ⊆ :

)(,)(~,

)(~,),(~

BxAxxBxAxx

BxAxxBxAxx

∉∧∈∃≡∈∨∉∃≡∈⇒∈∃≡∈⇒∈∀

6. The following relationships hold in the number

system: ⊆⊆⊆⊆∆

Page 140: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 140

4.4.3. The null set as a subset.

For any set A in a Universe U, A⊆∆

Proof:

Suppose )(~ A⊆∆ . Then, there exists ∆∈x such that

Ax ∉ . This, therefore, means that ∆ is not empty, which is

a contradiction. Therefore, A⊆∆ .

4.4.4. Distinction between elements and subsets

Examples:

• }3,2,1{2∈ , }3,2,1{2⊄

• }3,2,1{}2{ ∉ , }3,2,1{}2{ ⊆

• }1:{1 2 =∈∈ xx , }1:{}1{ 2 =∈⊆ xx

Exercises:

Let S be a set in a Universe U. Determine whether the

following are true or false.

• SS ∈

False

• }{SS ∈

True

• }{SS ⊆

False

• }{S⊆∆

True

Page 141: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 141

• }{S∈∆

False

• }{}{ S⊆∆

False

4.5. Set Equality

4.5.1. Definition: Set Equality.

If A and B are sets, then A equals B, written BA = , if and

only if, every element in A is also in B and every element in

B is also in A.

Equivalently, BA = if, and only if BA ⊆ and AB ⊆ .

Note: To prove that two sets are equal two things must be

shown:: BA ⊆ and AB ⊆ .

Examples:

• The Venn diagram demonstrating BA = is:

Page 142: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 142

Exercises:

• Write the definition of set equality using logic

notation.

),(),(

ABBAUxAxBxBxAxUxBA

⊆∧⊆∈∀⇔∈⇒∈∧∈⇒∈∈∀⇔=

4.5.2. Axiom of Extent.

If A and B are sets then ),( BxAxUxBA ∈⇔∈∈∀⇔= .

The Axiom of Extent says that a set is completely

determined by its elements, the order in which the elements

are listed is irrelevant, as is the fact that some members

may be listed more than once.

Examples:

• }2,1{}2,1{ =

• },,{},,{ abccba =

Exercises:

• Is },,,{},,,{ cadbdcba = Yes

• Is }CalAnn,Cal,Bob,{}CalBob,Ann,{ = Yes

Page 143: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 143

4.5.3. Theorem: Equality by Specification

Let U be a universe and let ( )xP be a statement.

If ))()((, xQxPUx ⇔∈∀ , that is ))()((, xQxPUx ≡∈∀

then )}(:{)}(:{ xQUxxPUx ∈=∈

The Theorem states that subsets of the same universe U

which are defined by equivalent statements are equal sets.

This theorem allows the use of tautologies of logic to prove

set theoretic statements, as will be outlined later.

Example:

• We know that ( )1112 −=∨=⇔= xxx .

Therefore

( ) { }1,1}11{}1:{ 2 −=−=∨===∈ xxxx

• If Uaaaa n ∈K,,, 321 , then we can write

{ }{ }n

naaaa

axaxaxUxAK

K

,,,:

321

21=

=∨∨=∨=∈=

In other words, if we know the elements of a set, we know

the set.

• { } { }3,2,1321: ==∨=∨=∈= xxxxA

Page 144: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 144

Exercise:

• Are the following sets equal? Using logic, can you

prove your answer?

}3,2,1{},1,2,3{},2,1,3,1{ Yes

}3,2,1{}321:{}231:{

}2311:{}2131:{}2,1,3,1{

==∨=∨=∈==∨=∨=∈=

=∨=∨=∨=∈==∨=∨=∨=∈=

xxxxxxxx

xxxxxxxxxx

• Are the following two sets equal? Give reasons.

{ }even is : nnE :∈= and even} is :{ 2nnT :∈= .

Yes, previously is has been proven that

even is even is 2nn ⇔ , thus by equivalence of statements,

the two sets are equal.

Page 145: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 145

4.6. Power Sets

4.6.1. Definition: Power Set

If X is any set, then }:{ XAA ⊆ is the power set of X.

The power set of X is often written as )( X .

So }:{)( XAAX ⊆= .

A power set is a set whose elements are sets.

If the elements of X are in a universe U, those of )( X are

in a universe )(U .

Examples:

• Let }1{=X and let S be the set of all subsets of X.

Write down the set S by listing its elements.

}:{ XAAS ⊆= .

}1{⊆∆ and }1{}1{ ⊆ .

Thus }}1{,{∆=S

• Let }2,1{=X and }:{ XAAS ⊆= . Write down the

set S by listing its elements.

}2,1{⊆∆ , }2,1{}1{ ⊆ , }2,1{}2{ ⊆ , and }2,1{}2,1{ ⊆ . Thus

}}2,1{},2{},1{,{∆=S

Page 146: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 146

Exercises:

• Let }3,2,1{=X .

o Write down the set )( X by listing its elements.

}}3,2,1{},3,2{},3,1{},2,1{},3{},2{},1{,{)( ∆=X

o How many elements are there in )( X ? 8

o Is )( X∈∆ ? Yes

o Is )( X⊆∆ ? Yes

o Is )(1 X∈ ? No

o Is )(}1{ X∈ ? Yes

o Is )(}2{ X⊆ ? No

o Is )(}}2,1{{ X⊆ ? Yes

Page 147: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 147

4.7. Hasse Diagrams

The elements of )( X can be represented by diagrams

using the following procedure:

1. An upward directed line between two sets indicates

that the “lower” set is a subset of the “upper” set.

2. ∆ is at the bottom and X is at the top.

3. Each pair of sets is joined by an upward directed

line to the “smallest” set which contains each as a subset.

4. Each pair of sets is joined by a downward directed

line to the “largest” set which is a subset of each.

Example:

Let }2,1{=X , thus }}2,1{},2{},1{,{)( ∆=X and the

Hasse diagram is given by:

{1, 2}

ø

{2} {1}

Page 148: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 148

4.8. Set Operations

There are five main set theoretic operations, one

corresponding to each of the logical connectives.

Set Operation Name Logical

Connective

Name

A Complement P~ Negation

BA∪ Union QP ∨ Disjunction

BA ∩ Intersection QP ∧ Conjunction

BA ⊆ Subset QP ⇒ Conditional

BA = Equality QP ⇔

QP ≡

Biconditional

Equivalence

The set operations can be defined in terms of the

corresponding logical operations. This means that each of

the tautologies proved by truth tables for the logical

connectives will have a corresponding theorem in set

theory.

Page 149: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 149

We have seen how the logical conditional operator, QP ⇒

is related to subset, BA ⊆ and how the logical

biconditional operator, QP ⇔ (or equivalence, QP ≡ ) is

related to set equality, BA = .

The following sections will cover the three remaining set

operations: complement, union and intersection.

In our discussion of set theory, we will let U be a fixed set

and all other sets, whether denoted A, B, C, etc, will be

subsets of U. In other words, )(,, UCBA ∈ . Thus, each

result should start with a statement similar to “Let A, B, C

be subsets of a universal set U” or “Let )(,, UCBA ∈ ”.

4.8.1. Definition: Compliment

Let U be a universal set, and let UA ⊆ . Then the

complement of A, denoted by A, is given by

( ){ } { }AxUxAxUxA ∉∈=∈∈= :~: .

Notes.

1. AU \ , A′ and cA are also used for A in some

books.

Page 150: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 150

2. If the set U is fixed in a discussion, then A is

sometimes written as { }AxxA ∉= :

Example:

• The shaded area in the following Venn diagram

depicts A:

Exercises:

Let =U . Write down A for the following sets:

• { }3,2,1=A

{ }321: ≠∧≠∧≠∈= xxxxA

• { }evenis: xxA ∈=

{ }oddis: xxA ∈=

• { }00: <∨>∈= xxxA

{ }0=A

Page 151: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 151

4.8.2. Definition: Union

Let A and B be subsets of a universe U. Then the union of

A and B, denoted by BA ∪ , is given by

{ }BxAxUxBA ∈∨∈∈=∪ : .

Example:

• The shaded area in the following Venn diagram

depicts BA ∪ :

Exercises:

• Let =U . Write down BA ∪ for the following sets:

o { }1=A and { }2=B .

{ }2,1=∪ BA

o A is the set of all even integers, B is the set of all odd

integers.

=∪ BA .

Page 152: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 152

o { }20: ≤≤∈= xxA and { }31: ≤≤∈= xxB

[ ]3,0}30:{ =≤≤∈=∪ xxBA

• If UA ⊆ and UB ⊆ , is it true that UBA ⊆∪ ?

Yes.

UxUxUxBxAxBAx

∈⇒∈∨∈⇒∈∨∈⇒∪∈

4.8.3. Definition: Intersection

Let A and B be subsets of a universe U. Then the

intersection of A and B, denoted by BA∩ , is given by

{ }BxAxUxBA ∈∧∈∈=∩ : .

Example:

• The shaded area in the following Venn diagram

depicts BA∩ :

Page 153: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 153

Exercises:

• Let =U . Write down BA∩ for the following sets:

o { }5,3,2,1=A and { }6,5,4,1=B .

{ }5,1=∩ BA .

o A is the set of all even integers, B is the set of all odd

integers.

=∩ BA .

o { }20: ≤≤∈= xxA and { }31: ≤≤∈= xxB

[ ]2,1}21:{ =≤≤∈=∩ xxBA

• If UA ⊆ and UB ⊆ , is it true that UBA ⊆∩ ?

Yes.

UxUxUxBxAxBAx

∈⇒∈∧∈⇒∈∧∈⇒∩∈

4.8.4. Definition: Difference

Let A and B be subsets of a universe U. Then the

difference of A and B, denoted by BA − , is given by

{ }BxAxUxBA ∉∧∈∈=− : .

Page 154: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 154

Example:

• The shaded area in the following Venn diagram

depicts BA − :

Notes.

1. The difference of BA− is sometimes called the

relative complement of B in A.

2. If we let UA = , then we have

{ }{ }B

BxUx

BxUxUxBU

=

∈∈=

∉∧∈∈=−

:

:

3. Using Definitions for complement and intersection, we

can simplify the definition of difference as follows:

{ }{ }

BA

BxAxUx

BxAxUxBA

∩=

∈∧∈∈=

∉∧∈∈=−

:

:

Page 155: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 155

Exercises:

• Let =U . Write down BA − for the following sets:

o { }5,3,2,1=A and { }6,5,4,1=B .

{ }3,2=− BA .

o A is the set of all even integers, B is the set of all odd

integers. ABA =− .

o { }20: ≤≤∈= xxA and { }31: ≤≤∈= xxB

)1,0[}10:{ =<≤∈=− xxBA

• If UA ⊆ and UB ⊆ , is it true that UBA ⊆− ?

Yes.

UxUxUxBxAxBAx

∈⇒∈∧∈⇒∉∧∈⇒−∈

• Let =U , { }3,2,1=A , { }2=B , { }4,3,2=C and

[ ] { }10:1,0 ≤≤∈== xxD .Write down:

o { }1=− CA

o =− CB

o DBD =−

o { }10: <≤∈=− xxAD

o { }3,2=− DA

Page 156: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 156

4.8.5. Definition: Disjoint sets

Let A and B be subsets of a universe U. Then A and B are

said to be disjoint if =∩ BA .

Example:

• The following Venn diagram depicts disjoint sets A

and B:

Note. Disjoint sets have no elements in common.

Exercises:

• Let =U , { }3,2,1=A , { }2=B , { }4,3,2=C and

[ ] { }10:1,0 ≤≤∈== xxD . Which pairs of sets from A,

B, C, D are disjoint?

B and D are disjoint, as are C and D.

Page 157: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 157

4.9. Order of Operations for Set Operators.

The order of operation for set operators is as follows:

1. Evaluate complement first

2. Evaluate ∪ and ∩ second. When both are present,

parenthesis may be needed, otherwise work left to right.

3. Evaluate ⊆ and = third. When both are present,

parenthesis may be needed, otherwise work left to right.

Note: Use of parenthesis will determine order of operations

which over ride the above order.

Examples: Indicate the order of operations in the following:

• {{BA21∩

• {321

21

)( BA∩

• {{ { )(231

CBA ∪∩

• {{ {CBA231∩⊆

Page 158: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 158

Exercises:

Indicate the order of operations in the following:

• {{ {CBA321

)( ∩⊆

• {321

21

)( BA∪

• {{ {CBA231∪⊆

• {{ {CBA231∩=

Notes.

1. ∪ and ∩ are operations on sets, thus ∪ and ∩ can

only be put between two sets.

2. ∨ and ∧ are operations on statements, thus ∨ and ∧

can only be placed between statements.

Example:

• If A, B, and C are sets then CACBBA ⊆⇒⊆∧⊆ )(

is interpreted as )())()(( CACBBA ⊆⇒⊆∧⊆

• ))(()( CBBACBBA ⊆∧⊆≡/⊆∧⊆

Page 159: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 159

4.10. Set Laws

Let A, B, and C be subsets of a universal set U. That is

)(,, UCBA ∈ . Then for all sets A, B, and C following set

laws hold:

1. Commutative Laws:

)()()()()()(

ABBAABBAABBA

===•∩=∩•∪=∪•

2. Associative Laws:

( ) ( )( ) ( )( ) ( ))()(

)()()()(

CBACBACBACBACBACBA

=====•∩∩=∩∩•∪∪=∪∪•

3. Distributive Laws:

( ) ( )( ) ( ))()()(

)()()(CABACBACABACBA

∩∪∩=∪∩•∪∩∪=∩∪•

4. Double Complement (Involution) Law:

AA =• )(

5. De Morgan’s Laws:

)()(

)()(

BABA

BABA

∪=∩•

∩=∪•

Page 160: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 160

6. Identity Laws:

AUAAA

=∩•=∪•

)()(

7. Negation (Complement) Laws:

U

U

AA

UAA

=•

=•

=∩•

=∪•

)(

)(

8. Dominance Laws:

=∩•=∪•

)()(

AUUA

9. Idempotent Laws:

AAAAAA

=∩•=∪•

)()(

10. Absorption Laws:

ABAAABAA

=∩∪•=∪∩•

)()(

11. Set Difference

BABA ∩=−•

Page 161: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 161

12. Subset properties of ∪ and ∩

( ) ( )( ) ( ))()()(

)()()(CBCACBACABACBA

⊆∧⊆⇔⊆∪•⊆∧⊆⇔∩⊆•

13. Subset property inclusion of intersection

BBAABA

⊆∩•⊆∩•

14. Subset property inclusion in union

BABBAA

∪⊆•∪⊆•

15. Transitive Property.

)())()(()())()((

CACBBACACBBA

=⇒=∧=•⊆⇒⊆∧⊆•

Page 162: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 162

4.11. Proving and Disproving Set Statements.

4.11.1. Proof by Exhaustion

To prove set results for finite sets, the method of

exhaustion is used. That is every element in the set is tested

to ensure it satisfies the condition.

Example:

• Let }2,1{=A , }4,3,2,1{=B . Prove BAA ∪⊆ .

To prove the statement, we must show every element in A

is in BA∪ .

Now }4,3,2,1{=∪ BA

BAABAA

∪∈∈∪∈∈

2,21,1

Thus all elements in A are in BA∪ , and so by exhaustion

BAA ∪⊆ .

Page 163: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 163

Exercise:

• Let }2,1{=A , }4,3,2,1{=B . Prove BAA ∩= .

To prove the statement, we must show every element in A

is in BA∩ and every element in BA∩ is in A.

Now }2,1{=∩ BA

BAABAA

∩∈∈∩∈∈

2and21and1

Thus all elements in A are in BA∩ and vice versa, and so

by exhaustion BAA ∩= .

Exercise:

• Give an example of three sets A, B and C such that

BAC ∩⊆ .

Let }2,1{=A , }4,3,2,1{=B , }1{=C .

To prove BAC ∩⊆ , we must show every element in C is

in BA∩ .

Now }2,1{=∩ BA

BAC ∩∈∈ 1and1

Thus all elements in C are in BA∩ and so, for the given

sets A, B and C, BAC ∩⊆ .

Page 164: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 164

4.11.2. Disproof by Counterexample.

A set result can be disproven by giving a counterexample.

To find a counterexample often creating a Venn diagram

will be of benefit.

Example:

• Disprove BAA ∩⊆ .

To disprove the statement, we must give a counterexample.

Let }2,1{=A , }4,3{=B

Now =∩ BA

,1 A∈ however =∩∉ BA1

Thus by counterexample BAA ∩⊄ .

Exercise:

• Disprove BAA −⊆ .

To disprove the statement, we must show a

counterexample.

Let }2,1{=A , }4,3,2,1{=B . Now =− BA

,1 A∈ however =−∉ BA1

Thus by counterexample BAA −⊄ .

Page 165: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 165

4.11.3. Proof by Typical Element.

To prove set results for infinite sets, generalised methods

must be used. The typical element method considers a

particular but arbitrary element of the set and by applying

knows laws, rules and definitions prove the result.

It is the method for proving subset relationships.

So prove that BA ⊆ , we must show that

)(, BxAxx ∈⇒∈∀

Begin by letting Ax∈ , that is, we take x to be a particular

but arbitrary element of A. Using the definitions, we prove

that Bx∈ . As long as we use no special properties of the

element x, we can conclude that )(U , which is what we

wanted to prove.

This method can be used to prove set equalities. By using

the definition )( ABBABA ⊆∧⊆⇔= and showing

ABBA ⊆∧⊆ , that is proving )(, BxAxx ∈⇒∈∀ and

)(, AxBxx ∈⇒∈∀ , the result BA = follows. Using this

definition is sometimes called a “double containment”

proof.

Page 166: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 166

Examples:

• Let U be a set and let A and B be elements of )(U .

Prove BAA ∪⊆ .

Need to prove )(, BAxAxx ∪∈⇒∈∀

Let Ax∈ , then

BAABAx

BxAxAx

∪⊆∴∪∪∈

∈∨∈⇒⇒∈

ofdefinitionnotesee

Note: Appling rules of logic, we know QPP ∨⇒ is a

tautology. Let BxxQAxxP ∈∈ :)(,:)( . Thus

BxAxAx ∈∨∈⇒∈ is a tautology in the proof above.

• Let U be a set and let A and B be elements of )(U .

Prove BBABA =∪⇔⊆ .

Need to prove two parts:

1. BBABA =∪⇒⊆

2. BABBA ⊆⇒=∪

Page 167: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 167

• Proof of 1:

KNOW: BA ⊆ , that is )1()(, KBxAxx ∈⇒∈∀

PROVE: BBA =∪ .

Need to prove two parts:

i. BBA ⊆∪

ii. BAB ∪⊆

Proof of i.:

Let BAx ∪∈ then

BBAPPPBxBx

BxBxBxAxBAx

⊆∪∴≡∨

∈∨∈∈∨∈∈∨∈

⇒⇒⇒∪∈

ruleLogic(1)by

ofdefinition

Proof of ii.:

Let Bx∈ then

BABBAx

BxAxBx

∪⊆∴∪∪∈

∈∨∈⇒⇒∈

ofdefinitionexampleprevioussee

Since BBA ⊆∪ and BAB ∪⊆ , BBA =∪

Thus BBABA =∪⇒⊆ .

Page 168: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 168

Proof of 2:

KNOW: BBA =∪ , that is )2()(, KBxBAxx ∈⇔∪∈∀

PROVE: BA ⊆ .

Let Ax∈ then

BABx

BAxBxAxAx

⊆∴

∪∈

∪∈∈∨∈

⇒⇒⇒∈

(2)byofdefinition

exampleprevioussee

Thus BABBA ⊆⇒=∪

Since BBABA =∪⇒⊆ and BABBA ⊆⇒=∪ it is

proven that BBABA =∪⇔⊆ .

Exercise:

• Let U be a set and let A and B be elements of )(U .

Prove ABA ⊆∩ .

that is, prove )(, AxBAxx ∈⇒∩∈∀

Let BAx ∩∈ , then

ABAAx

BxAxBAx

⊆∩∴

∩∈

∈∧∈⇒⇒∩∈ ofdefinition

Page 169: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 169

4.11.4. Proof by Equivalence of Statements.

If A can be written as )}(:{ xPUxA ∈= and

)}(:{ xQUxB ∈= , the equality of specification theorem to

show that BA = by showing that )()( xQxP ≡ , that is, by

showing that )()( xQxP ⇔ is a tautology.

Examples:

• Let }1:{ 2 ≤∈= xxA and }11:{ ≤≤−∈= xxB .

Prove BA =

Let 1:)( 2 ≤xxP and 11:)( ≤≤− xxQ . Now

BAxQxP

xx

=∴⇔∴

≤≤−⇔≤)()(

1112

• Let U be a set and let A and B be elements of )(U .

Prove that ( ) BABA ∪=∩ .

We need to show that the statements defining the sets

( )BA∩ and BA∪ are equivalent.

( ) ABAxUxBA ofdefinition)}(:~{ ∩∈∈=∩

}:{ BAxUxBA ∪∈∈=∪

Page 170: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 170

Let )(:~)( BAxxP ∩∈ , and BAxxQ ∪∈:)(

( ) ( )( )( )

( ) BABA

xPxQBAx

BxAxABxAx

BxAxBAx

∪=∩∴

≡∴∩∩∈≡

∈∧∈≡∈∨∈≡

∪∈∨∈≡∪∈

)()( of definitionby ~

sMorgan' Deby Logic~ofdefinition~~ of definitionby

Exercise:

• Let U be a set and let A and B be elements of )(U .

Prove that ( ) BABA ∩=∪ .

We need to show that the statements defining the sets

( )BA∪ and BA∩ are equivalent.

( ) ionspecificat ofaxiom )}(:~{ BAxUxBA ∪∈∈=∪ionspecificat ofaxiom }:{ BAxUxBA ∩∈∈=∩

Let )(:~)( BAxxP ∪∈ , and BAxxQ ∩∈:)(

( ) ( )( )( )

( ) BABA

xPxQBAx

BxAxABxAx

BxAxBAx

∩=∪∴

≡∴∩∪∈≡

∈∨∈≡∈∧∈≡

∩∈∧∈≡∩∈

)()( of definitionby ~

sMorgan' Deby Logic~ofdefinition~~ of definitionby

Page 171: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 171

• Let U be a set and let A, B and C be elements of P(U).

Prove that ( ) ( ) BCACBA −−=−− .

Let CBAxxP −−∈ )(:)( , and BCAxxQ −−∈ )(:)(

( ) ( )( )

( )( )

( )( )

( )

( ) ( ) BCACBAxQxP

BCAxBxCAx

BxCxAxBxCxAxCxBxAx

CxBxAxCxBAxCBAx

−−=−−∴⇔∴

−−∈⇔∉∧−∈⇔

∉∧∉∧∈⇔∉∧∉∧∈⇔∉∧∉∧∈⇔∉∧∉∧∈⇔

∉∧−∈⇔−−∈

)()(

• Let U be a set and let X and Y be elements of )(U .

Prove that YXYX ∩=− .

Let YXxxP −∈:)( , and YXxxQ ∩∈:)(

YXYXxQxP

YXxYxXxYxXxYXx

∩=−∴

≡∴∩∈≡

∈∧∈≡

∉∧∈≡−∈

)()(onintersecti of Definition

complement of Definitiondifferenceset of Definition

Page 172: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 172

4.11.5. Proof by Set Laws.

Set equalities can be proven by using known set laws

Examples:

• Let U be a set and let A, B and C be elements of P(U).

Prove ( ) ( ) BCACBA −−=−−

( ) ( )( )

( )( )

( )( )( ) differenceset

differenceset

ityassociativ

itycommutativ

ityassociativ

differenceset

differenceset

BCABCA

BCA

BCA

CBA

CBA

CBACBA

−−=∩−=

∩∩=

∩∩=

∩∩=

∩∩=

∩−=−−

Page 173: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 173

4.11.6. Further Examples.

Examples:

• Let U be a set and let A, B and B be elements of P(U).

Using the following:

(i) BBABA =∪⇔⊆ ,

(ii): ABABA =∩⇔⊆ ,

(iii): ( )BABA ∩=∪ .

Prove that ABBA ⊆⇔⊆ .

Proof:

( )

(i)by part

(iii)by part

scomplement by taking

(ii)by part

AB

ABA

ABA

ABABA

⊆⇔

=∪⇔

=∩⇔

=∩⇔⊆

• Let U be a set and let A, B and C be elements of P(U).

Disprove that ( ) ( ) CBACBA −−=−− .

Let { }3,2,1=A , { }3,2=B , { }3=C .

( ) { } { }3,12 =−=−− ACBA

( ) { } { } ( )CBACCBA −−≠=−=−− 11

Page 174: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 174

• Let U be a set and let X and Y be elements of )(U .

Use a typical element argument to prove YXYX ∩=− .

Need to prove two parts:

1. YXYX ∩⊆−

2. YXYX −⊆∩

Proof of 1:Let YXx −∈ be a typical element.

{ }{ }{ }{ } onintersecti of Def:

complement of Def:differenceset of Def:

ionSpecificat of Axiom:

YXxUxYxXxUxYxXxUx

YXxUxYX

∩∈∈⇒

∈∧∈∈⇒

∉∧∈∈⇒

−∈∈≡−

( )YXYX

YXxYXxUx∩⊆−∴

∩∈⇒−∈∈∀∴

Proof 2: Let YXx ∩∈ be a typical element.

{ }{ }{ }{ } differenceset of Def:

complement of Def:onintersecti of Def:

ionSpecificat of Axiom:

YXxUxYxXxUxYxXxUx

YXxUxYX

−∈∈⇒

∉∧∈∈⇒

∈∧∈∈⇒

∩∈∈≡∩

( )YXYX

YXxYXxUx−⊆∩∴

−∈⇒∩∈∈∀∴

( )

extent ofAxiom ,..

,

YXYXYXYXYXYXei

YXxYXxUx

∩=−∴

−⊆∩∧∩⊆−

∩∈⇔−∈∈∀∴

Page 175: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 175

Section 5. Relations and Functions

5.1. Cartesian Product

5.1.1. Definition: Ordered Pair

Let A and B be sets and let Aa ∈ and Bb∈ .

An ordered pair ),( ba is a pair of elements with the

property that:

)()(),(),( dbcadcba =∧=⇔= .

Notes:

∗ A pair set },{ ba is NOT an ordered pair, since

},{},{ abba = .

∗ It should be clear from the context when ),( ba is an

ordered pair, and when }:{),( bxaxba <<∈= is an

open interval of real numbers.

Page 176: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 176

Examples:

• Points in the plane 2 are represented as ordered

pairs.

x

y

-4 -3 -2 -1 0 1 2 3 4

-3

-2

-1

1

2

3

(1, 2)

(2, 1)

(-1, -2)

(-2, -1)

From the graph it can be seen )1,2()2,1( ≠ and

)1,2()2,1( −−≠−− .

• Complex numbers iba + where 1−=i and ∈ba, ,

are ordered pairs in the sense that,

)()( dbcaidciba =∧=⇔+=+ .

Page 177: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 177

5.1.2. Definition: Cartesian Product

Let A and B be sets, then the Cartesian Product of A and B,

denoted BA× , is defined by

( ){ }BbAabaBA ∈∧∈=× :, .

Example:

• }::),{( ∈∧∈=× yxyx .

Sketch a graph of × , otherwise known as 2 . 2 is the usual Cartesian plane with the usual graph.

x

y

-6 -4 -2 0 2 4 6

-4

-2

2

4

Page 178: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 178

Exercises:

• Let }3{=A and }3,2{=B . Write down BA× . Sketch

a graph of BA× in 2 .

)}3,3(),2,3{(=×BA

x

y

-6 -4 -2 0 2 4 6

-6

-4

-2

2

4

6

(3, 2)

(3, 3)

• Let }11:{ ≤≤−∈= xxC and }2,1{=D . Write

down DC × . Sketch a graph of DC × in 2 .

)}2,1(11:),{( ∈∧≤≤−=× yxyxDC

x

y

-4 -3 -2 -1 0 1 2 3 4

-4

-2

2

4

Page 179: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 179

5.2. Relations

5.2.1. Definition: Binary Relation

Let A and B be sets. We say that R is a (binary) relation

from A to B if BAR ×⊆ .

Notes:

∗ If AAR ×⊆ , we say that R is a relation on A.

∗ If Rba ∈),( , we will frequently write aRb and say

that “a is in the relation R to b”.

∗ Every relation is a subset of a Cartesian product

Examples:

• Let A be the set of all male human beings and let B be

the set of all human beings. The relation T from A to B is

given by ( ){ }yxyxT offather theis :,= .

• ( ) ( ) ( ){ }π,5,1,2,2,1=W .

Note: W cannot be defined by a “rule”. Sometimes relations

are simply defined by a listing of elements.

Page 180: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 180

• Let R be the relation on , defined by

}1:),{( 22 =+= yxyxR . Sketch the graph of R in 2

x

y

-2 -1 0 1 2

Exercise:

• Let S be the relation on , defined by

}44:),{( =+= yxyxS . Sketch the graph of S in 2

x

y

-2 -1 0 1 2

2

4

Page 181: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 181

Example:

Consider the relation R on given by ( ){ }yxyxR == :,

• Sketch the graph of R in 2

x

y

-4 -3 -2 -1 0 1 2 3 4

-4

-2

2

4

• Are the following true or false?

o 1R1 True

o 1R2.2 False

o R∈− )3,3( False

• If aR100, what is the value of a? 100

Note. The relation R in this example is called the identity

relation on and is usually written ( ){ }∈= xxxR :, .

Page 182: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 182

Exercises:

• Let { }3,2,1,0=X , and let the relation R on X be

given by ( ){ }yzxzyxR =+∈∃= ,:, .

o What is an easier way of expressing the relation R?

( ){ }yxXyxyxR <∧∈= ,:,

o List all the elements of R.

( ) ( ) ( ) ( ) ( ) ( ){ }3,2,3,1,2,1,3,0,2,0,1,0=R

o Sketch XX × , and circle the elements of R.

x

y

0 1 2 3 4

2

• Let S be the relation on { }0− given by

( ){ }yxzzyxS =∈∃= ,:,

o Describe the relation S.

x is a factor of y, or yx | .

Page 183: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 183

o Are the following true or false?

( ) S4,2 ∈− True, since 4|2 − .

0S3− False, since { }00 −∉ .

( ) S5,3 ∈ False, since 3F5.

• Let R be the relation on given by

( ) }:,{ 2xyyxR == and let S be the relation on given

by ( ) }:,{ 2xyyxS == .

o Sketch each relation. What difference does the

input” set make to the elements in each relation.

x

y

-4 -3 -2 -1 0 1 2 3 4

2

4

6

8

R is a set of isolated points.

Page 184: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 184

x

y

-3 -2 -1 0 1 2 3

-1

1

2

3

S is a continuous curve.

Note. Care must be taken when writing relations. As can be

seen from this example, it must be very clear the sets a

relation is from and to.

• Let { }1,0=A and { }1,0,1−=B . Let two relations

from A to B be given by ( ) ( ) ( ){ }0,1,1,1,1,01 −−=R , and

)}1,1(),1,1(),0,0{(2 −=R .

Determine:

o ( ){ }1,1RR 21 −=∩ .

o ( ) ( ) ( ) ( ) ( ){ }1,1,0,1,1,1,0,0,1,0RR 21 −−=∪

Page 185: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 185

• Let 3R and 4R be relations on defined by

( ){ }yxyxR == :,3 , and ( ){ }yxyxR −== :,4 .

Determine:

o

( ){ }( ){ }( ){ }yxyx

yxyxyxyxyxRR

==

±==−=∨==∪

:,:,:,43

o ( ){ }0,043 =∩ RR

Page 186: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 186

5.2.2. Definition: Domain

Let R be a relation from A to B.

Then the domain of R, denoted Dom R, is given by

{ }xRyyxR ,:Dom ∃= .

Notes:

∗ Let R be a relation from A to B, then AR ⊆Dom .

∗ Dom R is the set of all first elements in the ordered

pairs that belong to R.

5.2.3. Definition: Range

Let R be a relation from A to B.

Then the range of R, denoted Range R, is given by

{ }xRyxyR ,: Range ∃= .

Notes:

∗ Let R be a relation from A to B, then BR ⊆ Range .

∗ Range R is the set of all second elements in the

ordered pairs that belong to R.

Page 187: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 187

Examples:

• Let { }3,2,1,0=A and let 1R be the relation on A

given by { })0,3(),2,0(),1,0(),0,0( 1 =R .

Determine:

o { }3,0Dom 1 =R

o { }2,1,0 Range 1 =R

Exercises:

• Let 2R be the relation on given by

( ){ }0:,2 ≠= xyyxR .

Determine:

o { }0Dom 2 −= R

o { }0 Range 2 −= R .

• Let 3R be the relation from to given by

( ){ }x

yxyxR 13 0:, =∧≠= .

Determine:

o { }0Dom 3 −= R

o { }0: Range 13 ≠∧∈= nnR

n

Page 188: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 188

5.2.4. Definition: Inverse Relations

Let R be a relation from A to B. The inverse relation,

denoted 1−R , from B to A is defined as

( ) ( ){ }R,:,1 ∈=− yxxyR .

Notes:

∗ For a relation R from A to B, the inverse relation 1−R can be defined by interchanging the elements of all the

ordered pairs of R. This turns out to be easier for a finite

(listed) relation than an infinite (given by formula) relation.

∗ BRR ⊆=− RangeDom 1 and

ARR ⊆=− Dom Range 1 .

Examples:

• Define a relation R on as ( ){ }xyyxR 2:, == .

o Write down 3 elements of R.

( ) ( ) ( )6,3,4,2,2,1

o Write down 3 elements of 1−R

( ) ( ) ( )3,6,2,4,1,2

Page 189: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 189

o Sketch a graph of R and 1−R on coordinate axis,

circle elements of 1−R .

x

y

-1 0 1 2 3 4 5 6 7

-1

1

2

3

4

5

6

o Write down a simple definition for 1−R .

( ){ }( ){ }( ){ }xyyx

yxyxxyxyR

21

1

:,

2:,2:,

==

====−

Exercise:

• Let S be the identity relation on the set of reals. What

is 1−S ?

( ){ }∈= xxxS :,

( ){ }S

xxxS=

∈=− :,1

Page 190: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 190

5.2.5. Directed Graph of a Relation

When a relation R is defined on a set A, we can represent it

with a directed graph. This is a graph in which an arrow is

drawn from each point in A to each related point.

Ayx ∈∀ , , there is an arrow from x to y yxR⇔ ,

( ) Ryx ∈⇔ ,

If a point is related to itself, a loop is drawn that extends

out from the point and goes back to it.

Example:

• Let { }3,2,1,0=A and let 1R be the relation on A

given by { })0,3(),2,0(),1,0(),0,0( 1 =R . Draw the directed

graph of 1 R .

0

3

2

1

Page 191: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 191

Exercise:

• Let { }3,2,1,0=A and let 2R be the relation on A

given by { })2,2(),2,1(),0,0( 2 =R .

Draw the directed graph of 2R .

0

1

2

Page 192: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 192

5.2.6. Properties of Relations

Let R be a relation on the set A.

Reflexivity:

R is reflexive on A if and only if ( ) RxxAx ∈∈∀ ,, .

Example:

• Let 1R be the relation on defined by

( ){ }yxyxR offactor a is :,1 = .

For each ∈x , we know that x is a factor of itself. Thus,

( ) 1, Rxx ∈ , and so 1R is reflexive

Symmetry:

R is symmetric on A if and only if

( ) ( )( )RxyRyxAyx ∈⇒∈∈∀ ,,,, .

Example:

• Let 2R be the identity relation on .

For ∈yx, , if yx = , then xy = , that is, if ( ) 2, Ryx ∈ ,

then ( ) 2, Rxy ∈ and so 2R is symmetric

Page 193: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 193

Transitivity:

R is transitive on A if and only if

( ) ( )( ) ( )( )RzxRzyRyxAzyx ∈⇒∈∧∈∈∀ ,,,,,, .

Example:

• Let 3R be the relation on defined by

( ){ }yxyxR <= :,3 .

For ∈zyx ,, , if yx < and zy < , then zx < , that is, if

( ) 3, Ryx ∈ and ( ) 3, Rzy ∈ , then ( ) 3, Rzx ∈ and so 3R is

transitive.

Notes:

∗ A relation R on a set A is reflexive if each element

in A is in relation to itself.

∗ A relation R on a set A is symmetric if you can

“swap” the ordered pairs around and still get elements of R.

∗ A relation R on a set A is transitive if pairs of

elements are “related via” a third element (x and z related

via y).

Page 194: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 194

Exercises:

Which of the three properties do the following relations

satisfy? Give reasons why or why not.

• 1R on , given by ( ){ }yxyxR |:,1 = .

1),(.|, Rxxxxx ∈∴∈∀ Thus 1R is reflexive.

Consider 1)4,2( R∈ , since 4|2 , however 1)2,4( R∉ , as

4 F 2, so 1R is not symmetric.

.|||,,, zxzyyxzyx ⇒∧∈∀

111 ),(),(),( RzxRzyRyx ∈⇒∴∈∴∧∈∴ , thus 1R is

transitive.

• 2R , the identity relation on

Reflexive: Yes

Symmetric: Yes

Transitive: Yes

• 3R on given by ( ){ }yxyxR <= :,3

Reflexive: No

Symmetric: No

Transitive: Yes

Page 195: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 195

• 4R on given by }:),{( 24 xyyxR ==

Reflexive: No

Symmetric: No

Transitive: No

• 5R on A where A is the set of all people.

( ){ }yxyxR offamily in the is :,5 =

Reflexive: Yes

Symmetric: Yes

Transitive: Yes

• 6R on A where A is the set of all people.

( ){ }yxyxR loves :,6 =

Reflexive: ?

Symmetric: ?

Transitive: ?

Page 196: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 196

5.2.7. Definition: Equivalence Relation

Let R be a relation on the set A. R is an equivalence relation

on A if and only if R is reflexive, symmetric and transitive

on A.

Example:

From the previous exercises, 2R and 5R are equivalence

relations.

Notes:

∗ If R is a relation on a set A, you must be able to

either prove or disprove the statement

“R is an equivalence relation.”

∗ To prove a relation R is an equivalence relation, it is

necessary to prove all three properties hold.

∗ To disprove that a relation R is an equivalence

relation, it is sufficient to show that one of the three

properties does not hold. This can usually be shown by

counterexample.

Page 197: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 197

Example:

• Let 1R be the identity relation on .

Prove or disprove 1R is an equivalence relation.

Proof:

Reflexive:

aaa =∈∀ , , that is ( ) 1, Raa ∈ . Thus 1R is reflexive.

Symmetric:

abbaba ==∈∀ then ,if ,, , that is,

( ) ( ) 11 ,, RabRba ∈⇒∈ . Thus 1R is symmetric.

Transitive:

cacbbacba ===∈∀ then ,and if,,, , that is

111 ),()),(),(( RcaRcbRba ∈⇒∈∧∈ . Thus 1R is

transitive.

Since 1R is reflexive, symmetric and transitive, 1R is an

equivalence relation.

Page 198: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 198

Exercises:

• Let ∈n . Consider the relation 2R on given by

( ) ( ){ }nbabaR mod:,2 ≡= .

Prove or disprove 2R is an equivalence relation.

Recall: ( ) nkbaknba =−∈∃⇔≡ ,mod .

Proof:

Reflexive:

00, ×==−∈∀ naaa , which implies that

( )naa mod≡ , ( ) 2, Raa ∈∴ Thus 2R is reflexive.

Symmetric:

( ) nkbanbaba =−≡∈∀ then ,mod if,,

( )knnkab −=−=−∴ , giving ( )nab mod≡ . Thus

( ) ( ) 22 ,, RabRba ∈⇒∈ . So 2R is symmetric.

Transitive:

( ) ( )ncbnbacba mod andmod if,,, ≡≡∈∀ , then

)()( nlcbnkba =−∧=− , nplknca =+=−∴ )( ,

so ( )nca mod≡ . That is

222 ),()),(),(( RcaRcbRba ∈⇒∈∧∈ . Thus 2R is

transitive.

Since 2R is reflexive, symmetric and transitive, 2R is an

equivalence relation.

Page 199: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 199

• Let 3R be the relation on given by

( ){ }0:,3 ≠= abbaR .

o Prove or disprove 3R is an equivalence relation.

Disprove:

Reflexive:

We must show 0, ≠×∈∀ aaa .

However 000and,0 =×∈ .

Thus ( ){ }0:,3 ≠= abbaR and so 3R is not

reflexive.

Therefore 3R is not an equivalence relation.

o Is 3R symmetric or transitive?

e transitiv000symmetric00

∴≠⇒≠∧≠∴≠⇒≠acbcab

baab

o How can we adjust the relation so it becomes an

equivalence relation?

3R on { }0− .

Page 200: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 200

• Let { }2,1,0=A and let R be the relation on A given by

( ) ( ) ( ) ( ) ( ){ }0,1,1,0,2,2,1,1,0,0=R .

Prove or disprove R is an equivalence relation on A.

Reflexive:

For ( ) Ra ∈= 0,0:0 . For ( ) Ra ∈= 1,1:1 .

For ( ) Ra ∈= 2,2:2 .

So, ( ) RaaAa ∈∈∀ ,, . Thus R is reflexive.

Symmetric:

For ( ) ( ) ( )2,2and 1,1,0,0 symmetry obviously holds.

( ) ( ) RR ∈⇒∈ 0,11,0 , ( ) ( ) RR ∈⇒∈ 0,10,1 ,

So, ( ) ( ) RabRba ∈⇒∈∀ ,, , thus R is symmetric.

Transitive:

( ) ( ) ( ) RR ∈⇒∈ 1,01,0,0,0 , ( ) ( ) ( ) RR ∈⇒∈ 0,10,1,1,1 ,

( ) ( ) ( ) RR ∈⇒∈ 1,01,1,1,0 , ( ) ( ) ( ) RR ∈⇒∈ 0,00,1,1,0

( ) ( ) ( ) RR ∈⇒∈ 1,11,0,0,1 , ( ) ( ) ( ) RR ∈⇒∈ 0,10,0,0,1 ,

So ( ) ( ) ( ) RcaRcbba ∈⇒∈∧∀ ,,, , thus R is transitive.

Therefore, since R is reflexive, symmetric and transitive, R

is an equivalence relation.

Page 201: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 201

5.2.8. Directed Graphs of Equivalence Relations

The directed graph of an equivalence relation on A has the

following properties:

∗ Each point of the graph has an arrow looping

around from it back to itself. (Reflexivity)

∗ In each case where there is an arrow going from one

point to a second, there is an arrow going from the second

point back to the first. (Symmetry)

∗ In each case where there is an arrow going from one

point to a second and from a second point to a third, there is

an arrow going from the first point to the third.

(Transitivity)

Page 202: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 202

Example:

• Let { }2,1,0=A and let R be the relation on A given

by ( ) ( ) ( ) ( ) ( ){ }0,1,1,0,2,2,1,1,0,0=R .

Draw the directed graph for R.

Previously R was shown to be an equivalence relation on A.

The directed graph is then :

1 0

2

Page 203: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 203

Exercise:

• Let { }9,7,6,4,3,2=A , and define a relation R on A

by ( ) ( ){ }3mod:, babaR ≡= .

Draw the directed graph for R.

Solution:

( ) ( ) ( ) ( ) ( ) ( ) ( )( ) ( ) ( ) ( ) ( ) ( ) ( )}4,7,7,4,6,9,9,6,3,9,9,3,3,6

,6,3,9,9,7,7,6,6,4,4,3,3,2,2{=R

It can be shown that R is an equivalence relation, and thus

the directed graph is:

9

6

3 2

4

7

Page 204: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 204

5.2.9. Equivalence Class

The fundamental property of equivalence relations which

makes them important is that each one determines a

partition of the set A into a family of disjoint sets.

Definition:

Let R be an equivalence relation on the set A. Then for each

Aa ∈ , we define the equivalence class of a as

( ){ }RbaAba ∈∈= ,:)(class .

Example:

• Let { }2,1,0=A and let R be the relation on A given

by ( ) ( ) ( ) ( ) ( ){ }0,1,1,0,2,2,1,1,0,0=R . For each element in

A, we define equivalence classes as follows:

( ) ( ){ } { }1,0,0:0class =∈∈= RbAb

( ) ( ){ } { } ( )0class0,1,1:1class ==∈∈= RbAb

( ) ( ){ } { }2,2:2class =∈∈= RbAb

Page 205: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 205

Exercises:

• Let 1R be the identity relation on . Write down the

following equivalence classes:

o ( ) { }11class =

o ( ) { }ππ =class

o ( ) { }21

21class =

o For any ∈x , ( ) { }xx =class .

• Consider the relation 2R on given by

( ) ( ){ }3mod:,2 babaR ≡= .

What kind of numbers are in class(2) (otherwise written as

[2])?

( ) { }KKK ,23,,11,8,5,2,1,42class +−−= k .

• Let 3R on A, the set of all people, be given by

( ){ }babaR offamily in the is :,3 = .

Who is in your equivalence class?

Page 206: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 206

5.3. Functions

5.3.1. Definition

If F is a relation from A to B, then we say F is a function

from A to B, if and only if the domain of F is all of A and

for each element Ax∈ , there is only one value By∈ such

that Fyx ∈),( .

Note:

A relation from A to B becomes a function if the domain is

all of A and if every first element is related to only one

second element. This last property is sometimes known as

the vertical line test.

Examples:

• Is 1R on , }:),{( 21 xyyxR == a function?

x

y

-3 -2 -1 0 1 2 3

-1

1

2

3

Dom =1R , vertical line test holds, thus 1R is a function.

Page 207: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 207

• Is 2R on , }:),{( 22 yxyxR == a function?

x

y

-1 0 1 2 3

-3

-2

-1

1

2

3

Dom =2R , vertical line test fails, thus 2R is not a

function.

Exercises:

• Is 3R on { }0: ≥∈= xxA , }:),{( 23 yxyxR ==

a function?

x

y

-1 0 1 2 3

-1

1

2

3

Dom AR =3 , vertical line test holds, thus 3R is a function.

Page 208: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 208

• Is 4R on , }:),{(4 xyyxR == a function?

x

y

-1 0 1 2 3

-1

1

2

3

Dom ≠∞= ),0[4R , thus 4R is not a function.

Notes:

When determining if a relation is a function:

∗ Infinite Case: Is the domain is the entire set A.

Finite Case: Is every element of A a first element in

an ordered pair?

∗ Infinite Case: Graph the relation and apply the

vertical line test.

Finite Case: List the ordered pairs and check each

first element appears only once.

Page 209: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 209

Exercises:

• Let { }6,4,2=A and let { }5,3,1=B . Which of the

following relations from A to B are functions?

o ( ){ } ( ) ( ){ }5,4,3,21:,1 ==+= yxyxR

Dom { } AR ≠= 4,21 .

Thus 1R is not a function.

o ( ) ( ) ( ) ( ){ }5,6,5,4,1,4,5,22 =R .

Dom { } AR == 6,4,22 .

However, ( ) ( ) 22 5,41,4 RR ∈∧∈

Thus 2R is not a function.

o ( ) ( ) ( ){ }5,6,1,4,5,23 =R .

Dom AR =3 , and each first element only appears

once.

Thus 3R is a function.

Page 210: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 210

• Which of the following are functions?

o 1F , the identity relation on { }10,5,1=A .

( ) ( ) ( ){ }10,10,5,5,1,11 =F

Dom AF =1 , and each first element only appears

once.

Thus 1F is a function

o 2F on , ( ){ }1:,2 == yyxF .

x

y

-3 -2 -1 0 1 2 3

-1

1

2

Dom =2F , vertical line test holds, thus 2F is a

function.

Page 211: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 211

o 3F on , ( ){ }1:,3 +== xyyxF .

x

y

-3 -2 -1 0 1 2 3

-2

-1

1

2

3

4

Dom =3F , vertical line test holds, thus 3F is a

function.

Page 212: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 212

5.3.2. One-to-one

Let F be a function from A to B. F is one-to-one if and only

if ( ) ( )( )212121 ,,,, xxyxyxAxx =⇒=∈∀ .

For one-to-one functions, any given element from the

Range is related to only one element from the Domain.

That is each element in both the domain and the range is

related to just one element.

Notes:

∗ Only functions can be one-to-one.

∗ It is often the case that if a function F is one-to-one,

it satisfies a horizontal line test.

∗ To establish if a relation is one-to-one show if the

relation is, in fact, a function. Then determine if it is

one-to-one.

∗ To show a function is one-to-one, show each

element in the range occurs once in an ordered pair.

∗ To show a function is not one-to-one, give a

counterexample, that is, find an element of the

range that is related to two elements in the domain.

Page 213: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 213

Examples:

• Consider the relation 1F on given by

}:),{( 21 xyyxF == . Is 1F a one-to-one function?

x

y

-3 -2 -1 0 1 2 3

-1

1

2

3

Dom =1F , vertical line test holds, thus 1F is a function.

Horizontal line test fails: FF ∈∧∈− )1,1()1,1( 1 , therefore

1F is not a one-to-one function

Page 214: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 214

• Consider the relation 2F on { }0: ≥∈=+ xx

given by }:),{( 22 xyyxF == . Is 2F a one-to-one

function?

x

y

-3 -2 -1 0 1 2 3

-1

1

2

3

4

Dom += 2F , vertical line test holds, thus 2F is a

function. Horizontal line test holds, therefore 2F is a one-

to-one function

• Let { }3,2,1,0=X .

Consider the function 3F from )( X to given by

( ){ }AnnAF set in the elements of number theis :,3 = .

Is 3F a one-to-one function?

Consider { } )(1,0 XA ∈= and { } )(2,1 XB ∈= .

Then ( ) 32, FA ∈ and ( ) 32, FB ∈ , that is, ∈2 appears

twice.

Thus, 3F is not a one-to-one function.

Page 215: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 215

Exercises:

Which of the following relations are one-to-one functions?

• 1F on { }3,2,1=A , ( ) ( ) ( ){ }1,3,3,2,2,11 =F .

x

y

0 1 2 3

-2

-1

1

2

3

4

5

Dom AF =1 , vertical line test holds, thus 1F is a function. Horizontal line test holds, therefore 1F is a one-to-one function.

• 2F on { }3,2,1=A , ( ) ( ) ( ){ }1,3,1,2,2,12 =F .

x

y

0 1 2 3

-2

-1

1

2

3

4

5

Dom AF =2 , vertical line test holds, thus 1F is a function. Horizontal line test fails: 22 )1,3()1,2( FF ∈∧∈ , therefore

2F is not a one-to-one function.

Page 216: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 216

• 3F on , ( ){ }xyyxF 2:,3 == .

x

y

-3 -2 -1 0 1 2 3

-4

-3

-2

-1

1

2

3

4

Dom =3F , vertical line test holds, thus 3F is a function.

Horizontal line test holds, therefore 3F is a one-to-one

function

• 4F from { }0− to , ( ){ }1:, 24 −== xyyxF .

x

y

-3 -2 -1 0 1 2 3

-1

1

2

3

4

Dom { }04 −= F , vertical line test holds, thus 4F is a

function.

Horizontal line test fails: 44 )0,1()0,1( FF ∈−∧∈ ,

therefore 4F is not a one-to-one function.

Page 217: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 217

5.3.3. Onto

Let F be a function from A to B. F is onto if and only if

Range BF = , that is,

FyxAxBy ∈∈∃∈∀ ),(,, .

For a function to be onto, every given element from the

range must be related to at least one element from the

domain.

Notes:

∗ Only functions can be onto.

∗ To establish if a relation is onto show if the relation

is, in fact, a function. Then determine if it is onto.

∗ To show a function F from A to B is onto, show that

Range BF = , that is every element in the range

occurs at least once in an ordered pair.

∗ To show a function is not onto, give a

counterexample, that is, find an element of the

range that is not related to an element in the

domain.

Page 218: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 218

Example:

• Consider the relation 1F from

}11:{ ≤≤−∈= xxA to given by

}1:),{( 21 xyyxF −== . Is 1F an onto function?

x

y

-2 -1 0 1 2

Dom AxxF =≤≤−∈= }11:{1 , vertical line test holds,

thus 1F is a function.

Range ≠≤≤∈= }10:{1 yyF , thus 1F is not an onto

function.

By defining the function to 2F from

}11:{ ≤≤−∈= xxA to }10:{ ≤≤∈= xxB given by

}1:),{( 22 xyyxF −== .

Now Range ByyF =≤≤∈= }10:{2 , thus the function

2F is an onto function

Page 219: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 219

Exercises:

Which of the following functions are onto?

• 1F from }5,4,3,2,1{=A to },,,{ dcbaB = ,

)},5(),,4(),,3(),,2(),,1{(1 ddccaF =

Range BdcaF ≠= },,{1 . Therefore 1F is not an onto

function.

• 2F from }5,4,3,2,1{=A to },,,{ dcbaB = ,

)},5(),,4(),,3(),,2(),,1{(2 adcbaF = .

Range BdcbaF == },,,{2 . Therefore 2F is an onto

function.

• 3F on , }14:),{(3 −== xyyxF .

For each ∈y , let ∈+

=4

1yx , then

3),(,, Fyxxy ∈∈∃∈∀ . Thus Range =3F . Therefore

3F is an onto function.

• 4F on , }14:),{(4 −== xyyxF .

Consider ∈= 0y , then for 4)0,( Fx ∈ requires

∉+

=4

10x . Thus Range ≠4F . Therefore 4F is not an

onto function

Page 220: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 220

5.3.4. Inverse

Every relation has an inverse and this holds for functions

also.

For any function, there is an inverse relation; however, this

inverse relation is not always a function.

The inverse of a function F will also be a function when F

is one-to-one and onto.

Example:

Consider the relation F on the interval

}11:{]1,1[ ≤≤−∈=− xx , given by

}1:),{( 2xyyxF −== .

• Sketch F. Is F a one-to-one and onto function?

x

y

-2 -1 0 1 2

Page 221: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 221

Dom ]1,1[−=F , and the vertical line test holds. Thus F is

a function. Horizontal line test fails, thus F is not a one-to-

one function. Range ]1,1[]1,0[ −≠=F , thus F is not an

onto function.

• Sketch 1−F . Is 1−F a function?

Since F is function, and thus a relation, there is an inverse

relation 1−F on ]1,1[− given by

}1:),{( 21 yxyxF −==− .

x

y

-2 -1 0 1 2

Dom ]1,1[]1,0[1 −≠=−F , and the vertical line test fails.

Thus 1−F is not a function.

Page 222: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 222

Exercises:

Consider the relation F on }0:{ ≥∈= xxA given by

}:),{( 2xyyxF == .

• Sketch F. Is F a one-to-one and onto function?

x

y

0 1 2

2

4

6

8

Dom AF = , vertical line test holds, horizontal line test

holds, Range AF = , thus F is one-to-one and onto

function.

• Sketch 1−F . Is 1−F a function?

x

y

0 1 2

2

Dom AF =−1 , vertical line test holds, thus 1−F a function.

Page 223: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 223

5.4. Permutations

5.4.1. Definition

Let A be a set and let F be a function on A. Then F is a

permutation of A if F is one-to-one and onto.

Example:

Let { }3,2,1,0=A . Define { })0,3(),3,2(),2,1(),1,0(=F .

F is a one-to-one and onto function on A and thus is a

permutation of the elements of A.

Using conventional function notation each ordered pair in F

can be written as: 0)3(,3)2(,2)1(,1)0( ==== FFFF

“Matrix” representation can also be used for permutations.

The function F can be written as

⎟⎠

⎞⎜⎝

⎛=

03213210

F

F is one possible permutation of the set A.

Other permutations are:

⎟⎠

⎞⎜⎝

⎛=

32103210

I , ⎟⎠

⎞⎜⎝

⎛=

23013210

G , ⎟⎠

⎞⎜⎝

⎛=

02313210

H

Page 224: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 224

There will be 1234!4 ×××= total different permutations

of the set A.

I is known as the identity permutation, where each element

in A is mapped to itself.

Notes:

∗ In general, if A is a set with n elements, there are n!

different permutations of A.

∗ The set of all permutations on a set A with n

elements is often denoted by nS .

Exercises:

Let { }3,2,1,0=A and let ⎟⎠

⎞⎜⎝

⎛=

23013210

G and

⎟⎠

⎞⎜⎝

⎛=

02313210

H be permutation on A.

Write down the following.

• 0)1( =G

• 2)3( =G

• 1)0( =H

• 3)1( =H

• 0))0(( =HG

• 2))1(( =HG

Page 225: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 225

5.4.2. Cycle notation

Obviously, the matrix notation for permutations can be

confusing when we start to combine permutations.

This notation can be mistaken for “normal” matrix

multiplication. Therefore, we introduce what is called cycle

notation for permutations.

Example:

Let { }5,4,3,2,1=A and let F be a permutation on A given

by ⎟⎠

⎞⎜⎝

⎛=

1543254321

F

we note that:

1 “goes to” 2

2 “goes to” 3

3 “goes to” 4

4 “goes to” 5

5 “goes to” 1.

This can be written as a cycle: ( )54321 .

Diagrammatically, this can be represented as

(1 2 3 4 5)

Page 226: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 226

If an element is mapped onto itself, then it is left out of the

cycle.

Examples:

Write the following permutations using cycle notation.

• Let { }3,2,1,0=A

( )2030123210

=⎟⎠

⎞⎜⎝

⎛=F

• { }5,4,3,2,1=A

( )( )54214531254321

=⎟⎠

⎞⎜⎝

⎛=G

• { }3,2,1=A

( ) ( ) ( ) ( )( )( )321or 3or 2or 1321321

=⎟⎠

⎞⎜⎝

⎛=I

Page 227: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 227

Exercises:

Write down the following permutations on

{ }3,2,1,0=A , using cycle notation.

• ( )3112303210

=⎟⎠

⎞⎜⎝

⎛=F

• ( )231020313210

=⎟⎠

⎞⎜⎝

⎛=G

• ( )( )321023013210

=⎟⎠

⎞⎜⎝

⎛=H

Page 228: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 228

5.4.3. Composition

In traditional Calculus, composition of functions is defined

to be ))(())(( xfgxfg =o .

The same idea is used when considering composition of

permutations.

Examples:

Let { }4,3,2,1=A and let )4321(=F ,

)43)(21(=G be permutations on A.

Write down the following:

• 3)2())1(( == GFG

• 4)3())2(( == GFG

• 3)4())3(( == GFG

• 2)1())4(( == GFG

What is FG o written using cyclic notation?

)42(=FG o

Page 229: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 229

This could be calculated by writing each function in cyclic

notation in the appropriate order, then determining the

resultant permutation.

)43)(21)(4321(== FGFG o

1 “goes to” 2 in the first cycle, then 2 “goes to” 1 in the

second. Thus, 1 “goes to” 1 overall.

2 “goes to” 3 in the first cycle, then 3 “goes to” 4 in the

third. Thus, 2 “goes to” 4 overall.

3 “goes to” 4 in the first cycle, then 4 “goes to” 3 in the

third. Thus, 3 “goes to” 3 overall.

4 “goes to” 1 in the first cycle, then 1 “goes to” 2 in the

second. Thus, 4 “goes to” 2 overall.

These calculations give )42(== FGFG o .

( )( )( ) ( )422341432143214321 =⎟⎠⎞⎜

⎝⎛=

Page 230: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 230

Exercises:

Calculate the following compositions of permutations on

{ }3,2,1,0=A .

• ( )( ) ( )2030123210

20121 =⎟⎠

⎞⎜⎝

⎛=

• ( )( )( ) ( )2030123210

32103210 =⎟⎠

⎞⎜⎝

⎛=

• ( )( ) ( )3112303210

23321 =⎟⎠

⎞⎜⎝

⎛=

5.4.4. Inverse Permutations

Permutations are one-to-one and onto functions, thus their

inverses are also functions which are one-to-one and onto.

Thus, the inverse of a permutation is also a permutation.

Recall that to find the inverse of a relation or function, we

simply reverse the ordered pairs. For permutations, the

process is identical.

Page 231: WUCT121 Discrete Mathematics Logic

WUCT121 Logic 231

Examples:

Let { }4,3,2,1=A and let )3421(=F .

In F:

1 “goes to” 2. Thus, in 1−F , 2 “goes to” 1.

2 “goes to” 4. Thus, in 1−F , 4 “goes to” 2.

3 “goes to” 1. Thus, in 1−F , 1 “goes to” 3.

4 “goes to” 3. Thus, in 1−F , 3 “goes to” 4.

Putting all these calculations together, we have

)1243()2431()3421( 11

=== −−F

Note that 1−F is just F written in the reverse order.

Exercises:

Let { }3,2,1,0=A Write down the following.

• ( ) ( )123321 1 =−

• ( ) ( )031130 1 =−