all lectures adila

298
IKI10600I: Discrete Mathematics I Propositional Logic Adila A. Krisnadhi Faculty of Computer Science, University of Indonesia

Upload: rustamnortojiyev

Post on 07-Apr-2018

224 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 1/298

IKI10600I: Discrete Mathematics IPropositional Logic

Adila A. Krisnadhi

Faculty of Computer Science, University of Indonesia

Page 2: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 2/298

General Introduction Propositions Examples

Propositional LogicOutline

1 General Introduction

2 Propositions

The BasicsCompound propositions

3 ExamplesTranslating English sentencesSystem specicationsBoolean searchesLogic puzzlesLogic and bit operations

Page 3: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 3/298

General Introduction Propositions Examples

What is Discrete Mathematics?

Page 4: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 4/298

General Introduction Propositions Examples

What is Discrete Mathematics?

discrete : consisting of distinct or unconnected elements;opposite of continuousdiscrete mathematics : mathematics of discrete objectstypical topics : logic, arithmetics, algorithms, numbertheory, counting, set theory, graph theory, etc.

Page 5: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 5/298

General Introduction Propositions Examples

Why study Discrete Mathematics?

Page 6: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 6/298

General Introduction Propositions Examples

Why study Discrete Mathematics?

Because it is needed for answering the following questions:

How many ways are there to choose a valid password on acomputer system?

Is there a link between two computers in a network?How can I identify spam e-mail messages?How can I encyrpt a message so that no unintendedrecipient can read it?What is the shortest path between two cities using atransportation system?How can a circuit that adds two integers be designed?How many valid Internet addresses are there?...

l d l

Page 7: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 7/298

General Introduction Propositions Examples

List of Topics for Discrete Mathematics I

Logic: propositional, rst orderSets, functions, sequences and summationsNumber theoryMathematical induction

G l I d i P i i E l

Page 8: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 8/298

General Introduction Propositions Examples

List of Topics for Discrete Mathematics I

Logic: propositional, rst orderSets, functions, sequences and summationsNumber theoryMathematical induction

Important emphasis

problem solving skills, especially on reasoning andconstructing mathematical proofs .

General Introduction Propositions Examples

Page 9: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 9/298

General Introduction Propositions Examples

The Basics

Propositions

Denitionproposition : a declarative sentence that has a denite truthvalue (either true or false, but not both)

General Introduction Propositions Examples

Page 10: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 10/298

General Introduction Propositions Examples

The Basics

Propositions

Denitionproposition : a declarative sentence that has a denite truthvalue (either true or false, but not both)

Propositions are typically represented using letters:p , q , r , s , p 1 , p 2 . . . , q 1 , q 2 , . . .

General Introduction Propositions Examples

Page 11: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 11/298

General Introduction Propositions Examples

The Basics

Propositions

Denitionproposition : a declarative sentence that has a denite truthvalue (either true or false, but not both)

Propositions are typically represented using letters:p , q , r , s , p 1 , p 2 . . . , q 1 , q 2 , . . .Possible truth values for propositions: true and false (youcan use T and F ; or 1 and 0, etc.)

General Introduction Propositions Examples

Page 12: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 12/298

General Introduction Propositions Examples

The Basics

Propositions

Denitionproposition : a declarative sentence that has a denite truthvalue (either true or false, but not both)

Propositions are typically represented using letters:p , q , r , s , p 1 , p 2 . . . , q 1 , q 2 , . . .Possible truth values for propositions: true and false (youcan use T and F ; or 1 and 0, etc.)An interpretation (truth assignment) : mapping that mapspropositional variables to their truth values.

General Introduction Propositions Examples

Page 13: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 13/298

p p

The Basics

Propositions

Denitionproposition : a declarative sentence that has a denite truthvalue (either true or false, but not both)

Propositions are typically represented using letters:p , q , r , s , p 1 , p 2 . . . , q 1 , q 2 , . . .Possible truth values for propositions: true and false (youcan use T and F ; or 1 and 0, etc.)An interpretation (truth assignment) : mapping that mapspropositional variables to their truth values.

Example notation: p I = T means p is interpreted as true.Similarly, p I = F means p is false.

General Introduction Propositions Examples

Page 14: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 14/298

p p

The Basics

Propositions: examples

ExampleJakarta is the capital of Indonesia.There are 19 new students of this class.The students are on time for today’s class.

General Introduction Propositions Examples

Page 15: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 15/298

The Basics

Propositions: examples

ExampleJakarta is the capital of Indonesia.There are 19 new students of this class.The students are on time for today’s class.

Are the following propositions? Why?2 + 2 = 4.Study this subject well.x < 2.Blablabla.Do you know more examples of propositions?

I know more examples of propositions

General Introduction Propositions Examples

Page 16: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 16/298

Compound propositions

Logical connectives

Propositions that you have encountered up to now is calledatomic proposition .If you have one or two propositions, you can form a new

proposition using a logical connective or logical operator .Such a proposition is called compound proposition .

General Introduction Propositions Examples

Page 17: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 17/298

Compound propositions

Logical connectives

Propositions that you have encountered up to now is calledatomic proposition .If you have one or two propositions, you can form a new

proposition using a logical connective or logical operator .Such a proposition is called compound proposition .There are two kinds of logical operator:

unary operator (needs only one operand): negation ( ¬)binary operator (needs two operands):

conjunction ( ∧)disjunction ( ∨)exclusive-or ( ⊕)implication/conditional ( →)biconditional ( ↔).

General Introduction Propositions Examples

Page 18: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 18/298

Compound propositions

Negation

DenitionLet p be a proposition. Then ¬p is also a proposition.

¬p is called the negation of p and read as “ not p ”.

General Introduction Propositions Examples

Page 19: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 19/298

Compound propositions

Negation

DenitionLet p be a proposition. Then ¬p is also a proposition.

¬p is called the negation of p and read as “ not p ”.

Important!

¬p has always the opposite meaning of p .

This can be described using the following truth table :

p ¬p T FF T

General Introduction Propositions Examples

Page 20: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 20/298

Compound propositions

Negation: examples

Examplep : “Jakarta is the capital of Indonesia”

¬p : “Jakarta is not the capital of Indonesia”;

or “It is not the case that Jakarta is the capital of Indonesia”q : “Today is Friday”

¬q : “Today is not Friday”or “It is not the case that today is Friday”

General Introduction Propositions Examples

Page 21: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 21/298

Compound propositions

Negation: examples

Examplep : “Jakarta is the capital of Indonesia”

¬p : “Jakarta is not the capital of Indonesia”;

or “It is not the case that Jakarta is the capital of Indonesia”q : “Today is Friday”

¬q : “Today is not Friday”or “It is not the case that today is Friday”

What is the negation of each of the following?Jeff never sleeps in class.Jakarta has more than 10 million inhabitants.

General Introduction Propositions Examples

Page 22: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 22/298

Compound propositions

Conjunction

DenitionLet p and q be propositions. Then p ∧q is also a proposition.p ∧q is called the conjunction of p and q , read as “ p and q ”.

General Introduction Propositions Examples

Page 23: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 23/298

Compound propositions

Conjunction

DenitionLet p and q be propositions. Then p ∧q is also a proposition.p ∧q is called the conjunction of p and q , read as “ p and q ”.

Important!p ∧q is true whenever both p and q are true .Otherwise, it is false.

p q p

q

T T TT F FF T FF F F

General Introduction Propositions Examples

Page 24: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 24/298

Compound propositions

Conjunction: examples

Examplep : Today is Friday.q : It is raining today.p ∧q : Today is Friday and it is raining today.p : This class is interesting.q : Class participation is lacking.

p ∧

q : This class is interesting, but class participation islacking.

General Introduction Propositions Examples

Page 25: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 25/298

Compound propositions

Disjunction

DenitionLet p and q be propositions. Then p ∨q is also a proposition.p ∨q is called the disjunction of p and q , read as “ p or q ”.

General Introduction Propositions Examples

Page 26: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 26/298

Compound propositions

Disjunction

DenitionLet p and q be propositions. Then p ∨q is also a proposition.p ∨q is called the disjunction of p and q , read as “ p or q ”.

Important!p ∨q is true whenever at least one among p and q is true ,otherwise it is false.

p q p

q T T TT F TF T TF F F

General Introduction Propositions Examples

Page 27: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 27/298

Compound propositions

Disjunction: examples

Examplep : Today is Friday.q : It is raining today.p

q : Today is Friday or it is raining today.p : This job requires experience in web design.q : This job requires experience in web programming.p ∨q : This job requires experience in web design or webprogramming.

General Introduction Propositions Examples

Page 28: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 28/298

Compound propositions

Disjunction: examples

Examplep : Today is Friday.q : It is raining today.p

q : Today is Friday or it is raining today.p : This job requires experience in web design.q : This job requires experience in web programming.p ∨q : This job requires experience in web design or webprogramming.

Important!The use of or in disjunction is inclusive , i.e., p ∨q is still truewhenever both p and q are true.For the exclusive or, see next slide.

General Introduction Propositions Examples

Page 29: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 29/298

Compound propositions

Exclusive Or

DenitionLet p and q be propositions. Then p ⊕q is also a proposition.p ⊕q is called the exclusive or of p and q , read as “ p xor q ”.

General Introduction Propositions Examples

Page 30: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 30/298

Compound propositions

Exclusive Or

DenitionLet p and q be propositions. Then p ⊕q is also a proposition.p ⊕q is called the exclusive or of p and q , read as “ p xor q ”.

Important!p ⊕q is true whenever exactly one among p and q is true ,otherwise it is false.

p q p

q T T FT F TF T TF F F

General Introduction Propositions Examples

Page 31: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 31/298

Compound propositions

Exclusive Or: examples

Example

p : I pass this course. q : I fail this course.p ⊕q : (Either ) I pass this course or I fail it.p : You can choose computer science.q : You can choose information systems.p

q : You can choose ( either ) computer science orinformation systems, ( but not both ).

General Introduction Propositions Examples

Page 32: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 32/298

Compound propositions

Implication/Conditional

DenitionLet p and q be propositions. Then p →q is also a proposition,called implication or conditional statement .p is called the hypothesis/antecedent/premise ;

and q is called the conclusion/consequence .

General Introduction Propositions Examples

Page 33: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 33/298

Compound propositions

Implication/Conditional

DenitionLet p and q be propositions. Then p →q is also a proposition,called implication or conditional statement .p is called the hypothesis/antecedent/premise ;

and q is called the conclusion/consequence .

p →q is read as:if p , (then) q

p is sufcient for q q if p

q when p

a necessary condition for p is q

q unless ¬p

p implies q

a sufcient condition for q is p p only if q

q whenever p

q is necessary for p

q follows from p

General Introduction Propositions Examples

C d i i

Page 34: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 34/298

Compound propositions

Implication/Conditional

Important!p →q is true whenever both p and q are true; or when p isfalse.

Thus, p →q is only false when p is true and q is false.

p q p →q

T T T

T F FF T TF F T

General Introduction Propositions Examples

C d iti

Page 35: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 35/298

Compound propositions

Implication: examples

Examplep : Jeff gets seasick. q : Jeff is on a boat.p →q : If Jeff gets seasick, then Jeff is on a boat.p : Tuesday is a holiday. q : 2 + 3 = 5.p →q : Tuesday is a holiday implies 2 + 3 = 5.

Try restate these examples using patterns in the previous slide.When do these implications become true?

General Introduction Propositions Examples

Compound propositions

Page 36: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 36/298

Compound propositions

Implication: contrapositive, converse and inverse

DenitionContrapositive of p →q is the proposition ¬q → ¬p .Converse of p →q is the proposition q →p .

Inverse of p →q is the proposition ¬p → ¬q .

General Introduction Propositions Examples

Compound propositions

Page 37: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 37/298

Compound propositions

Implication: contrapositive, converse and inverse

DenitionContrapositive of p →q is the proposition ¬q → ¬p .Converse of p →q is the proposition q →p .

Inverse of p →q is the proposition ¬p → ¬q .

What are the contrapositive, converse and inverse of theexamples in the previous slide?

General Introduction Propositions Examples

Compound propositions

Page 38: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 38/298

Compound propositions

Implication: contrapositive, converse and inverse

DenitionContrapositive of p →q is the proposition ¬q → ¬p .Converse of p →q is the proposition q →p .

Inverse of p →q is the proposition ¬p → ¬q .

What are the contrapositive, converse and inverse of theexamples in the previous slide?

Given a conditional statement, which one is equivalent(always has the same truth value) to it? Its contrapositive,converse or inverse?

General Introduction Propositions Examples

Compound propositions

Page 39: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 39/298

Compound propositions

Implication: contrapositive, converse and inverse

DenitionContrapositive of p →q is the proposition ¬q → ¬p .Converse of p →q is the proposition q →p .

Inverse of p →q is the proposition ¬p → ¬q .

What are the contrapositive, converse and inverse of theexamples in the previous slide?

Given a conditional statement, which one is equivalent(always has the same truth value) to it? Its contrapositive,converse or inverse?Prove it.

General Introduction Propositions Examples

Compound propositions

Page 40: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 40/298

p p p

Contrapositive, converse, inverse: truth table

contrapositive converse inverse

p q ¬p ¬q p →q ¬q → ¬p q →p ¬p → ¬q T T F F T T T TT F F T F F T TF T T F T T F F

F F T T T T T T

General Introduction Propositions Examples

Compound propositions

Page 41: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 41/298

p p p

Biconditional/bi-implication/equivalence

DenitionLet p and q be propositions. Then p ↔q is also a proposition,

called bi-implication or biconditional statement .

General Introduction Propositions Examples

Compound propositions

Page 42: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 42/298

Biconditional/bi-implication/equivalence

DenitionLet p and q be propositions. Then p ↔q is also a proposition,

called bi-implication or biconditional statement .

p ↔q is read as:p if and only if q

if p then q , and conversely.p is equivalent with q

p iff q

p is necessary and sufcient for q .p and q are equivalent

General Introduction Propositions Examples

Compound propositions

Page 43: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 43/298

Biconditional/Bi-implication: truth value

Important!p ↔q is true exactly when p and q have the same truthvalue.p

↔q is true when both p

→q and q

→p is true. See

truth table below.

p q p →q q →p (p →q )∧(q →p ) p ↔q T T T T T TT F F T F FF T T F F FF F T T T T

General Introduction Propositions Examples

Compound propositions

Page 44: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 44/298

Biconditional: examples

Examplep : You can take the ight. q : You buy a ticket.p ↔q : You can take the ight if and only if you buy a ticket.p : For you to win the contest.q : You have the only winning ticket.p

↔q : For you to win the contest, it is necessary and

sufcient that you have the only winning ticket.

General Introduction Propositions Examples

Compound propositions

Page 45: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 45/298

Truth tables of all logical connectives

negation conjunction disjunction exclusive or implication bi-implication

NOT AND OR XOR IMPLIES IFF

p q ¬p p ∧q p ∨q p ⊕q p →q p ↔q

T T F T T F T TT F F F T T F FF T T F T T T FF F T F F F T T

General Introduction Propositions Examples

Compound propositions

Page 46: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 46/298

Precedence of logical connectives

Operator Precedence

¬ 1

∧ 2

∨ 3

→ 4↔ 5

Use parantheses whenever necessary!

Examplep ∧q ∨r means (p ∧q )∨r

¬p ∧q means (¬p )∧q p ∨q →r means (p ∨q ) →r

General Introduction Propositions Examples

Translating English sentences

Page 47: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 47/298

Translating English sentences

Translate the following sentence into logical expression:“You cannot ride the roller coaster if you are under 130 cm tallunless you are older than 16 years old.”

General Introduction Propositions Examples

Translating English sentences

Page 48: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 48/298

Translating English sentences

Translate the following sentence into logical expression:“You cannot ride the roller coaster if you are under 130 cm tallunless you are older than 16 years old.”

AnswerLet p : “You can ride the roller coaster”,q : “You are under 130 cm tall”, andr : “You are older than 16 years old”.Then the sentence can be translated into (q ∧¬r ) → ¬p

General Introduction Propositions Examples

System specications

Page 49: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 49/298

System specications are expected to be consistent , i.e., they should notcontain conicting requirements that can be used to derive a contradiction.

General Introduction Propositions Examples

System specications

Page 50: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 50/298

System specications are expected to be consistent , i.e., they should notcontain conicting requirements that can be used to derive a contradiction.

Are the following specications consistent?The system is in multiuser state if and only if it is operating normally. If thesystem is operating normally, the kernel is functioning. The kernel is notfunctioning or the system is in interrupt mode. The system is not in interruptmode.

General Introduction Propositions Examples

System specications

Page 51: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 51/298

System specications are expected to be consistent , i.e., they should notcontain conicting requirements that can be used to derive a contradiction.

Are the following specications consistent?The system is in multiuser state if and only if it is operating normally. If thesystem is operating normally, the kernel is functioning. The kernel is notfunctioning or the system is in interrupt mode. The system is not in interruptmode.

AnswerSuppose p : “The system is in multiuser state”, q : “The system is operatingnormally”, r : “The kernel is functioning” and s : “The system is in interruptmode”. Thus the specications can be written as: p ↔ q , q → r , ¬ r ∨ s , ¬s .

We want to nd a truth assignment for p , q , r , s that makes all statementstrue. First, s must be false to make ¬s true. Thus, to make ¬ r ∨ s true, r mustbe false. This means, q must also be false in order to make q → r true.Finally, p should be false to make p ↔ q true. Hence, the specications areconsistent because they are all true when p , q , r , s are all false. (Check thisusing truth table).

General Introduction Propositions Examples

Boolean searches

Page 52: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 52/298

Boolean searches

Logical connectives are used for searching in large collections ofinformation. E.g., in search engine.

AND: match records containing both two search terms

OR: match records containing at least one of the two search terms

NOT: exclude records containing the search term.

ExampleWe can search pages that contains the term “universitas”, either the

term “Indonesia” or “Bogor”, but does not contain the term “Semarang”.search term: UNIVERSITAS AND (INDONESIA OR BOGOR) ANDNOT SEMARANG

in Google: universitas indonesia OR bogor -semarang

General Introduction Propositions Examples

Logic puzzles

Page 53: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 53/298

Inhabitants of an island can be divided into the knights and theknaves. Knights always tell the truth and knaves always lie. Suppose

you meet two inhabitants of this island, say A and B. A says “At leastone of us is a knave” and B says nothing. Can you tell who’s theknight and/or who’s the knave?

General Introduction Propositions Examples

Logic puzzles

Page 54: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 54/298

Inhabitants of an island can be divided into the knights and theknaves. Knights always tell the truth and knaves always lie. Suppose

you meet two inhabitants of this island, say A and B. A says “At leastone of us is a knave” and B says nothing. Can you tell who’s theknight and/or who’s the knave?

AnswerLet p : “A is a knight” and q : “B is a knight”, so that

¬p means “A is a

knave” and ¬q means “B is a knave”. We can thus express A’sstatement as ¬p ∨¬q .

General Introduction Propositions Examples

Logic puzzles

Page 55: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 55/298

Inhabitants of an island can be divided into the knights and theknaves. Knights always tell the truth and knaves always lie. Supposeyou meet two inhabitants of this island, say A and B. A says “At leastone of us is a knave” and B says nothing. Can you tell who’s theknight and/or who’s the knave?

AnswerLet p : “A is a knight” and q : “B is a knight”, so that

¬p means “A is a

knave” and ¬q means “B is a knave”. We can thus express A’sstatement as ¬p ∨¬q .First suppose p is true, i.e., A is a knight. Then A’s statement, i.e.,

¬p ∨¬q is true. It follows that ¬q must be true, i.e., B is a knave.

General Introduction Propositions Examples

Logic puzzles

Page 56: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 56/298

Inhabitants of an island can be divided into the knights and theknaves. Knights always tell the truth and knaves always lie. Supposeyou meet two inhabitants of this island, say A and B. A says “At leastone of us is a knave” and B says nothing. Can you tell who’s theknight and/or who’s the knave?

AnswerLet p : “A is a knight” and q : “B is a knight”, so that

¬p means “A is a

knave” and ¬q means “B is a knave”. We can thus express A’sstatement as ¬p ∨¬q .First suppose p is true, i.e., A is a knight. Then A’s statement, i.e.,

¬p ∨¬q is true. It follows that ¬q must be true, i.e., B is a knave.To ensure that this is the only answer, let’s take a look what happen if

we assume p as false. If p is false, then ¬p is true, i.e., A must be aknave. This means A’s statement, ¬p ∨¬q must be false. But tomake ¬p ∨¬q false, we require ¬p to be false too which is impossiblesince we already have that ¬p is true.

General Introduction Propositions Examples

Logic puzzles

Page 57: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 57/298

Inhabitants of an island can be divided into the knights and theknaves. Knights always tell the truth and knaves always lie. Supposeyou meet two inhabitants of this island, say A and B. A says “At leastone of us is a knave” and B says nothing. Can you tell who’s theknight and/or who’s the knave?

AnswerLet p : “A is a knight” and q : “B is a knight”, so that

¬p means “A is a

knave” and ¬q means “B is a knave”. We can thus express A’sstatement as ¬p ∨¬q .First suppose p is true, i.e., A is a knight. Then A’s statement, i.e.,

¬p ∨¬q is true. It follows that ¬q must be true, i.e., B is a knave.To ensure that this is the only answer, let’s take a look what happen if

we assume p as false. If p is false, then ¬p is true, i.e., A must be aknave. This means A’s statement, ¬p ∨¬q must be false. But tomake ¬p ∨¬q false, we require ¬p to be false too which is impossiblesince we already have that ¬p is true.Hence, we conclude that A is a knight and B is a knave.

General Introduction Propositions Examples

Logic and bit operations

Bit ti

Page 58: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 58/298

Bit operation

Bit (Binary digit): a symbol with two possible values (0 and1).Computers represent information using bits.

Bit can be used to represent truth value: 1 represents trueand 0 represents false.Bit operations : analogous to operations using logicalconnectives (AND, OR, XOR).

Bit string : sequence of zero or more bits. Its length is thenumber of bits in the string.Example: 101010011 is a bit string of length nine.

General Introduction Propositions Examples

Logic and bit operations

Bitwise AND bitwise OR bitwise XOR

Page 59: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 59/298

Bitwise AND, bitwise OR, bitwise XOR

Find the bitwise AND, bitwise OR and bitwise XOR of the bitstrings 1011 0011 and 1110 0001.

General Introduction Propositions Examples

Logic and bit operations

Bitwise AND bitwise OR bitwise XOR

Page 60: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 60/298

Bitwise AND, bitwise OR, bitwise XOR

Find the bitwise AND, bitwise OR and bitwise XOR of the bitstrings 1011 0011 and 1110 0001.

Answer

1011 00111110 0001

−−−−−−−−−1010 0001 b i t w i s e AND

1111 0011 bi tw is e OR0101 0010 b i t w i s e XOR

Page 61: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 61/298

IKI10600I: Discrete Mathematics ILogical Equivalence

Adila A. Krisnadhi

Faculty of Computer Science, University of Indonesia

Interpretation Propositional Equivalence

Logical Equivalence

Page 62: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 62/298

Logical EquivalenceOutline

4 Interpretation

5 Propositional Equivalence

Interpretation Propositional Equivalence

Interpretation

Page 63: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 63/298

Interpretation

DenitionInterpretation is a truth assignment to a (possibly compound)proposition.

Interpretation can be described simply by truthassignments of all propositional variables of theproposition.Truth assignment of a compound proposition can then be

computed from truth assignments of its propositionalvariables.Each row of the truth table of a proposition corresponds toa particular interpretation of the proposition.

Interpretation Propositional Equivalence

Truth tables of compound proposition

Page 64: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 64/298

Truth tables of compound proposition

Construct the truth table for (p ∨¬q ) →(p ∧q )

Interpretations

¬q p

∨¬q p

q (p

∨¬q )

→(p

q )

I 1 : p I 1 = T , q I 1 = T F T T T

I 2 : p I 2 = T , q I 2 = F T T F F

I 3 : p I 3 = F , q I 3 = T F F F T

I 4: p I 4 = F , q I 4 = F T T F F

Interpretation Propositional Equivalence

Truth tables of compound proposition

Page 65: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 65/298

Truth tables of compound proposition

Construct the truth table for (p ∨¬q ) →(p ∧q )

p q ¬q p ∨¬q p ∧q (p ∨¬q ) →(p ∧q )T T F T T TT F T T F FF T F F F TF F T T F F

The compound proposition above used 2 variables. Its truthtable contains 4 rows. How many rows are there in the truthtable of a compound proposition that uses 3 variables? 4variables? n variables?

Interpretation Propositional Equivalence

Validity, satisability and contradiction

Page 66: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 66/298

Validity, satisability and contradiction

DenitionLet G be a proposition.

G is valid iff G is true for every interpretation of G . In thiscase, G is also called a tautology .

G is satisable iff there exists at least one interpretation ofG for which G is true.G is falsiable iff there exists at least one interpretation ofG for which G is false.

G is unsatisable/contradictory iff G is false for everyinterpretation of G . In this case, G is also called acontradiction .

Note: A proposition that is both not valid and non contradictoryis also called contingency .

Interpretation Propositional Equivalence

Equivalence

Page 67: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 67/298

Equivalence

DenitionLet p and q be two propositions. p is equivalent with q iff theproposition p ↔q is a tautology.

In other words, p and q are equivalent iff p and q have thesame truth value on every row of their truth tables.

Instead of using ↔, we often use ≡to denote equivalence.

Interpretation Propositional Equivalence

Proving equivalence

Page 68: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 68/298

Proving equivalence

If you are given two propositions p and q , how can you

show that they are equivalent?There are two ways of proving two propositions equivalent:

using truth tables;using laws of equivalence.

Interpretation Propositional Equivalence

Proving equivalence using truth table

Page 69: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 69/298

g q g

Show that p ∨q and ¬(¬p ∧¬q ) are equivalent (i.e.,p ∨q ↔ ¬(¬p ∧¬q ) is a tautology).

p q p

q

¬p

¬q

¬p

∧¬q

¬(

¬p

∧¬q ) G

T T T F F F T TT F T F T F T TF T T T F F T T

F F F T T T F TNote: we dene G := p ∨q ↔ ¬(¬p ∧¬q )

Interpretation Propositional Equivalence

Proving equivalence using truth table

Page 70: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 70/298

g q g

Show that p →q and ¬p ∨q are equivalent.

p q p →q ¬p ¬p ∨q

T T T F TT F F F FF T T T TF F T T T

Since p →q and ¬p ∨q have the same truth values on eachrow of the truth table, both of them are equivalent.

Interpretation Propositional Equivalence

Some logical equivalences (1)

Page 71: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 71/298

g q ( )

p ∧T ≡p Identity lawsp ∨F ≡p p

T

≡T Domination laws

p ∧

F ≡Fp ∨p ≡p Idempotent lawsp ∧p ≡p

¬(

¬p ) Double negation laws

p ∨

q ≡q ∨

p Commutative lawsp ∧q ≡q ∧p

Interpretation Propositional Equivalence

Some logical equivalences (2)

Page 72: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 72/298

g q ( )

(p ∨q )∨r ≡p ∨(q ∨r ) Associative laws(p ∧q )∧r ≡p ∧(q ∧r )

p ∨(q ∧r ) ≡(p ∨q )∧(p ∨r ) Distributive laws

p ∧(q ∨

r ) ≡(p ∧

q )∨(p ∧

r )¬(p ∧q ) ≡ ¬p ∨¬q De Morgan’s laws

¬(p ∨q ) ≡ ¬p ∧¬q p ∨(p ∧q ) ≡p Absorption laws

p ∧(p ∨

q ) ≡p p ∨¬p ≡T Negation lawsp ∧¬p ≡F

Interpretation Propositional Equivalence

Some logical equivalences (3)

Page 73: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 73/298

p →q ≡ ¬p ∨q p →q ≡ ¬q → ¬p

¬(p →q ) ≡p ∧¬q

(p →q )∧(p →r ) ≡p →(q ∧

r )(p →r )∧(q →r ) ≡(p ∨q ) →r (p →q )∨(p →r ) ≡p →(q ∨r )(p →r )∨(q →r ) ≡(p ∧q ) →r

p ↔q ≡(p →q )∧(q →p )p ↔q ≡ ¬p ↔ ¬q p ↔q ≡(p ∧q )∨(¬p ∧¬q )

(p q ) p q

Interpretation Propositional Equivalence

Proving equivalence without truth table

Page 74: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 74/298

Show that ¬(p ∨(¬p ∧

q )) and ¬p ∧¬q are equivalent

Answer

¬(p ∨(¬p ∧q )) ≡ ¬p ∧¬(¬p ∧q ) by De Morgan laws

≡ ¬p

(

¬(

¬p )

∨¬q ) by De Morgan laws

≡ ¬p ∧(p ∨¬q ) by double negationlaw

≡(¬p ∧p )∨(¬p ∧¬q ) by distributivity

≡F

(

¬p

∧¬q ) because

¬p

p

≡F

≡(¬p ∧¬q )∨F by commutativity ofdisjunction

≡ ¬p ∧¬q by identity law for F

Interpretation Propositional Equivalence

Proving tautology without truth table

Page 75: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 75/298

Show that (p ∧

q ) →(p ∨

q ) is a tautology.

AnswerWe show that the statement is equivalent to T.

(p ∧

q ) →(p ∨

q ) ≡ ¬(p ∧

q )∨(p ∨

q ) since p →q ≡ ¬p ∨

q ≡(¬p ∨¬q )∨(p ∨q ) by De Morgan laws

≡(¬p ∨p )∨(¬q ∨q ) by associativity and

commutativity of ∨

≡T∨

T by commutativity of∨and since p ∨¬p ≡T

≡T by domination law

Page 76: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 76/298

IKI10600I: Discrete Mathematics ILogical Equivalence: continued

Adila A. KrisnadhiFaculty of Computer Science, University of Indonesia

Logical Equivalence: continuedOutline

Page 77: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 77/298

Outline

Proving tautology without truth table

Page 78: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 78/298

Show that (¬p ∨ ¬q ) → ¬(p ∧ q ) is a tautology.

AnswerTo show that the statement is valid, we assume that there exists aninterpretation making it false, and derive a contradiction.

Assume that (¬p ∨ ¬q ) → ¬(p ∧ q ) is false.

It must be the case that (¬p ∨ ¬q ) is true and ¬(p ∧ q ) is false.

Since ¬(p ∧ q ) is false, p ∧ q must be true.

Since p ∧ q is true, we have both p and q are true.

p that p and q are true implies that both ¬p and ¬q are false.

Since ¬p and ¬q are false, (¬p ∨ ¬q ) must be false.

Since we already have that (¬p ∨ ¬q ) is true, we obtain a contradiction.

Therefore, our assumption that (¬p ∨ ¬q ) → ¬(p ∧ q ) is false isincorrect, i.e., (¬p ∨ ¬q ) → ¬(p ∧ q ) is always true.

More examples

Page 79: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 79/298

Determine whether the following statements are valid, orcontradictory or neither.

(p →q ) →(¬p → ¬q )¬(p ↔q ) ↔(p ↔ ¬q )p ∧(p →q ) →q ((p →q )∧(q →r )) →(p →r )

(p ∨

q ) →(p ∧

q )

Determining validity of a proposition: summary

Page 80: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 80/298

Use a truth table:valid if the proposition is true on each row of the truth table;straightforward; difcult if there are too many variables (2 n

rows for n variables)

Use logical equivalence lawsUse a contradiction:

Assume that the proposition is falseDerive a contradictory truth assignment for the

variables/subpropositionsDue to contradiction, the initial assumption is incorrect, i.e.,the proposition is always true.

Page 81: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 81/298

IKI10600I: Discrete Mathematics IPredicates and Quantiers

Adila A. KrisnadhiFaculty of Computer Science, University of Indonesia

Predicates Quantiers

Predicates and QuantiersOutline

Page 82: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 82/298

6 Predicates

7 QuantiersUniversal quantierExistential quantier

More examples and remarks

Predicates Quantiers

Predicates

Page 83: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 83/298

The statement “ x > 3” or “x is greater than 3” consists oftwo parts:variable x whose possible values are taken from a certainset D predicate “is greater than 3”

The set D is called the domain or the universe of discourse .We can denote such statement as P (x ) where P denotesthe predicate and x is the variable .P (x ) has no truth value until x is assigned to a certain

element from D .A predicate is always associated to a certain arity : thenumber of variables associated to P An n -ary predicate is a predicate with arity n .

Predicates Quantiers

Let P (x ) be the statement “ x > 3 ” What are the truth

Page 84: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 84/298

Let P (x ) be the statement “ x > 3.” What are the truthvalues of P (5) and P (1)?

P (5) is obtained by setting x = 5 in the statement. Hence,P (5) is true since 5 > 3 is true.P (1) is false since 1 > 3 is false.P is a unary predicate, i.e., a predicate with arity 1.

Let A(c , n ) be “Computer c is connected to network n ”where c represents a computer and n represents anetwork.

A(c , n ) is true whenever c is a computer that is connectedto the network n , otherwise it is false.A is a binary predicate, i.e., its arity is 2.

Let R (x , y , z ) be “x + y = z ”.R is a ternary predicate, i.e., its arity is 3.R (1, 2, 3) is true whereas R (0, 0, 1) is false.

Predicates Quantiers

Variable Binding

Page 85: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 85/298

Variable x in P (x ) is bound if x is replaced with an element

of the domain D or bound by a quantier.Otherwise it is a free variable.Two mainly used quantiers are universal quantiers andexistential quantier.

Predicates Quantiers

Universal quantier

Universal quantier

Page 86: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 86/298

DenitionThe universal quantication of P (x ) (∀xP (x )) is the proposition“P (x ) is true for all (every) values of x in the domain D ”

∀is the universal quantier and read “for all”, “for every”,

“for each”, “for any”, “for arbitrary”, “all of”, “given any”, etc.An element for which P (x ) is false is calledcounterexample of∀xP (x )

∀xP (x ) is true when P (x ) is true for every x ∀xP (x ) is false when there is an x for which P (x ) is false.In∀xP (x , y ), x is a bound variable whereas y is a freevariable.

Predicates Quantiers

Universal quantier

Universal Quantier: examples

Page 87: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 87/298

Let P (x ) be “x + 1 > x ”. What is the truth value of ∀xP (x )with R as the domain ?Let Q (x ) be “x < 2”. What is the truth value of

xQ (x ) with

R as the domain?What is the truth value of ∀xP (x ), where P (x ) denotes“x 2 < 10” and the domain consists of positive integers notexceeding 4?

Note: for a nite domain where x 1 , . . . ,x n are its elements,∀xP (x ) is equivalent with P (x 1)∧P (x 2)∧ · · ·∧P (x n )

Predicates Quantiers

Universal quantier

Universal Quantier: examples

Page 88: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 88/298

“Every student in this class attends the course of Foundationsof Programming”

Predicates Quantiers

Universal quantier

Universal Quantier: examples

Page 89: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 89/298

“Every student in this class attends the course of Foundationsof Programming”

First alternative:Take D := {x | x is a student in this class }P

(x

) :=x attends the course of Foundations of

ProgrammingThen the statement can be written as ∀xP (x )

Predicates Quantiers

Universal quantier

Universal Quantier: examples

Page 90: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 90/298

“Every student in this class attends the course of Foundationsof Programming”

First alternative:Take D := {x | x is a student in this class }P (x ) := x attends the course of Foundations ofProgrammingThen the statement can be written as ∀xP (x )

Second alternative:Take as the domain: D := {x | x is a student }Q (x ) := x is in this class.P (x ) := x attends the course of Foundations ofProgrammingThen the statement can be written as ∀x (Q (x ) →P (x ))

Predicates Quantiers

Existential quantier

Existential quantier

Page 91: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 91/298

DenitionThe existential quantication of P (x ) (∃xP (x )) is the proposition“P (x ) is true for some values of x in the domain D ”

∃is the existential quantier and read: “for some”, “there

exists”, “there is”, “at least one”, etc.

∃xP (x ) is true when there is at least one element x of D forwhich P (x ) is true.

∃xP (x ) is false when P (x ) is false for every x , i.e., noelement x of D for which P (x ) is true.

In∃xP (x , y ), x is a bound variable whereas y is a freevariable.

Predicates Quantiers

Existential quantier

Existential Quantier: examples

Page 92: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 92/298

Let P (x ) be “x > 34”. What is the truth value of ∃xP (x )with R as the domain?Let Q (x ) be “x = x + 1”. What is the truth value of

xQ (x )

with R as the domain?What is the truth value of ∃xP (x ), where P (x ) denotes“x 2 < 10” and the domain consists of positive integers notexceeding 4?

Note: for a nite domain where x 1 , . . . ,x n are its elements,∃xP (x ) is equivalent with P (x 1)∨P (x 2)∨ · · ·∨P (x n )

Predicates Quantiers

More examples and remarks

More examples

Page 93: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 93/298

“Everyone has a close friend”

Predicates Quantiers

More examples and remarks

More examples

Page 94: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 94/298

“Everyone has a close friend”Because friendship is a relation between two person, weneed two variables: x and y

Predicates Quantiers

More examples and remarks

More examples

Page 95: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 95/298

“Everyone has a close friend”Because friendship is a relation between two person, weneed two variables: x and y Take D :=

{x

|x is a person

}as the domain of both

variables x and y .

Predicates Quantiers

More examples and remarks

More examples

Page 96: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 96/298

“Everyone has a close friend”Because friendship is a relation between two person, weneed two variables: x and y Take D :=

{x

|x is a person

}as the domain of both

variables x and y .Take a predicate A(x , y ) := y is a close friend of x

Predicates Quantiers

More examples and remarks

More examples

Page 97: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 97/298

“Everyone has a close friend”Because friendship is a relation between two person, weneed two variables: x and y Take D :=

{x

|x is a person

}as the domain of both

variables x and y .Take a predicate A(x , y ) := y is a close friend of x The sentence becomes:

∀x ∈D (∃y ∈DA(x , y )) or ∀x (∃yA(x , y )) or ∀x ∃yA(x , y )

Predicates Quantiers

More examples and remarks

More examples

Page 98: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 98/298

“Everyone has a close friend”Because friendship is a relation between two person, weneed two variables: x and y Take D :=

{x

|x is a person

}as the domain of both

variables x and y .Take a predicate A(x , y ) := y is a close friend of x The sentence becomes:

∀x ∈D (∃y ∈DA(x , y )) or ∀x (∃yA(x , y )) or ∀x ∃yA(x , y )

The scope for∃

y is A(x , y ) in which x is still a free variable.The scope for ∀x is ∃yA(x , y ) in which x is no longer a freevariable.

Predicates Quantiers

More examples and remarks

More examples

Page 99: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 99/298

Change the following sentences into expressions in predicatelogic.

Jackie has exactly one close friend.Everyone has exactly one close friend.If someone is a woman and has a child, then she is amother.

Predicates Quantiers

More examples and remarks

Summary

Page 100: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 100/298

∀xP (x ) :is true iff P (x ) is true for every x ∈D ;is false iff P (x ) is false for some x ∈D .

∃xP (x ):

is true iff P (x ) is true for some x ∈

D ;is false iff P (x ) is false for every x ∈D .

∀x ∀yP (x , y ):is true iff P (x , y ) is true for every pair x ∈D x and y ∈D y is false iff P (x , y ) is false for some pair x ∈D x and y ∈D y

∀y ∀

xP (x , y ):is true iff P (x , y ) is true for every pair y ∈D y and x ∈D x is false iff P (x , y ) is false for some pair y ∈D y and x ∈D x

Predicates Quantiers

More examples and remarks

Summary (2)

Page 101: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 101/298

∀x ∃yP (x , y ):is true iff for every x ∈D x , there is one y ∈D y for whichP (x , y ) is true;is false iff there is one x

D x such that P (x , y ) is false forevery y ∈D y .

∃x ∀yP (x , y ):is true iff there is one x ∈D x such that P (x , y ) is true forevery y ∈D y ;

is false iff for every x ∈

D x , there is one y ∈

D y for whichP (x , y ) is false.

Predicates Quantiers

More examples and remarks

Summary (3)

Page 102: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 102/298

∃x ∃yP (x , y ):is true iff there is (at least) one pair x ∈D x and y ∈D y suchthat P (x , y ) is true;is false iff for every pair x

∈D x and y

∈D y , P (x , y ) is false.

∃y ∃xP (x , y ):is true iff there is (at least) one pair y ∈D x and x ∈D y suchthat P (x , y ) is true;is false iff for every pair y

D x and x

D y , P (x , y ) is false.

Predicates Quantiers

More examples and remarks

More examples

Page 103: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 103/298

Here the domain of all variables are real numbers.Let Q (x , y ) be the relation x + y = y + x . What is the truthvalue of

x

yQ (x , y )?Let Q (x , y ) be the relation x + y = 0. What is the truthvalue of ∀x ∃yQ (x , y ) and ∃y ∀xQ (x , y )?Let Q (x , y , z ) be the relation x + y = z . What is the truthvalue of

x

y

zQ (x , y , z ) and

z

x

yQ (x , y , z )?

Predicates Quantiers

More examples and remarks

Some remarks

Page 104: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 104/298

∀x ∀yP (x , y ) ≡ ∀y ∀xP (x , y )

∃x ∃yP (x , y ) ≡ ∃y ∃xP (x , y )

¬∀xP (x ) ≡ ∃x ¬P (x ) (De Morgan’s)

¬∃xP (x ) ≡ ∀x ¬P (x ) (De Morgan’s)

∀x ∃yP (x , y ) is not equivalent with ∃y ∀xP (x , y )If the domain for x is empty , the statement:

∀xP (x ) is true , because we cannot nd anycounterexample for P (x ) (that makes P (x ) false);

∃xP (x ) is false , because we cannot nd any x in thedomain that makes P (x ) true.

Page 105: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 105/298

IKI10600I: Discrete Mathematics IRules of Inference

Adila A. Krisnadhi

Faculty of Computer Science, University of Indonesia

Valid arguments Fallacies Rules of inference for quantied statements

Rules of InferenceOutline

Page 106: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 106/298

8 Valid argumentsModus PonensModus tollensSyllogismsOther rules of inference

ResolutionExamples

9 Fallacies

10 Rules of inference for quantied statementsRules on universal quantiersRules on existential quantiersExamplesUniversal modus ponens & modus tollens

Valid arguments Fallacies Rules of inference for quantied statements

Argument in Logic

Page 107: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 107/298

DenitionArgument : a sequence of propositions

All but the nal proposition is called premises , whereas thenal proposition is the conclusion .An argument is valid if the truth of all its premises impliesthat the conclusion is true.

Valid arguments Fallacies Rules of inference for quantied statements

Modus Ponens

Modus Ponens (Law of Detachment)

Page 108: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 108/298

Modus ponens

p p

→q

∴ q

Valid arguments Fallacies Rules of inference for quantied statements

Modus Ponens

Modus Ponens (Law of Detachment)

Page 109: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 109/298

Modus ponens

p p

→q

∴ q

I f you do a l l t he e xe rc is es , the n you w i l l suceed i n exams .You do a l l t he e xe rc is es .

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∴ You w i l l succeed in exams .

Valid arguments Fallacies Rules of inference for quantied statements

Modus tollens

Modus Tollens

Page 110: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 110/298

Modus tollens

¬q p

→q

∴ ¬p

Valid arguments Fallacies Rules of inference for quantied statements

Modus tollens

Modus Tollens

Page 111: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 111/298

Modus tollens

¬q p

→q

∴ ¬p

I f you do a l l t he e xe rc is es , the n you w i l l suceed i n exams .You d id no t succeed in exams .

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∴ You d id n ot do a l l th e e xe rc is es .

Valid arguments Fallacies Rules of inference for quantied statements

Syllogisms

Syllogisms

Page 112: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 112/298

Hypothetical syllogism

p →q q →r

∴ p →r

Valid arguments Fallacies Rules of inference for quantied statements

Syllogisms

Syllogisms

Page 113: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 113/298

Hypothetical syllogism

p →q q →r

∴ p →r

Disjunctive syllogism

p

q

¬p ∴ q

Valid arguments Fallacies Rules of inference for quantied statements

Other rules of inference

Other rules

Addition

Page 114: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 114/298

p

∴ p ∨q

Valid arguments Fallacies Rules of inference for quantied statements

Other rules of inference

Other rules

Addition

Page 115: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 115/298

p

∴ p ∨q

Simplication

p ∧q

∴ p

Valid arguments Fallacies Rules of inference for quantied statements

Other rules of inference

Other rules

Addition

Page 116: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 116/298

p

∴ p ∨q

Simplication

p ∧q

∴ p

Conjunction

p q

∴ p ∧q

Valid arguments Fallacies Rules of inference for quantied statements

Resolution

Resolution

Page 117: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 117/298

p ∨

q

¬p ∨r

∴ q ∨r

Valid arguments Fallacies Rules of inference for quantied statements

Resolution

Resolution

Page 118: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 118/298

p ∨

q

¬p ∨r

∴ q ∨r

Resolution is the rule of inference for computer to do anautomatic reasoning.In the above denition, q ∨r is called the resolvent .In using resolution, hypotheses and conclusion must be

expressed as clauses .Clause: disjunction of variables or negations of variables.

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Is the following argument valid?

Is the following argument valid?

Page 119: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 119/298

If √2 > 32 , then (√2)2 > ( 3

2 )2 . We know that √2 > 32 .

Consequently, (√2)2 = 2 > ( 32 )2 = 9

4 .

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Is the following argument valid?

Is the following argument valid?

Page 120: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 120/298

If √2 > 32 , then (√2)2 > ( 3

2 )2 . We know that √2 > 32 .

Consequently, (√2)2 = 2 > ( 32 )2 = 9

4 .

AnswerLet p be the proposition “ √2 > 3

2 ” and q be the proposition“2 > 3

2 ”. The premises of the argument are p →q and p ,whereas the conclusion is q . Thus, the argument is validbecause it is constructed by using modus ponens, a validargument form.

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Is the following argument valid?

Is the following argument valid?

Page 121: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 121/298

If √2 > 32 , then (√2)2 > ( 3

2 )2 . We know that √2 > 32 .

Consequently, (√2)2 = 2 > ( 32 )2 = 9

4 .

AnswerLet p be the proposition “ √2 > 3

2 ” and q be the proposition“2 > 3

2 ”. The premises of the argument are p →q and p ,whereas the conclusion is q . Thus, the argument is validbecause it is constructed by using modus ponens, a validargument form.However, one of its premises, √2 > 3

2 , is false. Consequently,we cannot conclude that the conclusion is true. Moreover, notethat the conclusion itself is false, because 2 < 9

4

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Show that the hypotheses “If you send me an e-mail, then I will nish writingthe program”, “If you do not send me an e-mail, then I will go to sleep early”,and “If I go to sleep early, then I will wake up feeling refreshed” lead to theconclusion “If I do not nish writing the program, then I will wake up feeling

Page 122: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 122/298

refreshed.”

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Show that the hypotheses “If you send me an e-mail, then I will nish writingthe program”, “If you do not send me an e-mail, then I will go to sleep early”,and “If I go to sleep early, then I will wake up feeling refreshed” lead to theconclusion “If I do not nish writing the program, then I will wake up feeling

Page 123: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 123/298

refreshed.”SolutionLet p be the proposition “You send me an e-mail” q , the proposition “I willnish writing the program” r , the proposition “I will go to sleep early” s , theproposition “I will wake up feeling refreshed”

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Show that the hypotheses “If you send me an e-mail, then I will nish writingthe program”, “If you do not send me an e-mail, then I will go to sleep early”,and “If I go to sleep early, then I will wake up feeling refreshed” lead to theconclusion “If I do not nish writing the program, then I will wake up feeling

Page 124: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 124/298

refreshed.”SolutionLet p be the proposition “You send me an e-mail” q , the proposition “I willnish writing the program” r , the proposition “I will go to sleep early” s , theproposition “I will wake up feeling refreshed”

The hypotheses are p → q , ¬p → r , r → s . The desired conclusion is¬q → s

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Show that the hypotheses “If you send me an e-mail, then I will nish writingthe program”, “If you do not send me an e-mail, then I will go to sleep early”,and “If I go to sleep early, then I will wake up feeling refreshed” lead to theconclusion “If I do not nish writing the program, then I will wake up feeling

f

Page 125: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 125/298

refreshed.”SolutionLet p be the proposition “You send me an e-mail” q , the proposition “I willnish writing the program” r , the proposition “I will go to sleep early” s , theproposition “I will wake up feeling refreshed”

The hypotheses are p → q , ¬p → r , r → s . The desired conclusion is¬q → s

1 p → q Hypothesis

3 ¬p → r Hypothesis

5 r → s Hypothesis

6 ¬q → s

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Show that the hypotheses “If you send me an e-mail, then I will nish writingthe program”, “If you do not send me an e-mail, then I will go to sleep early”,and “If I go to sleep early, then I will wake up feeling refreshed” lead to theconclusion “If I do not nish writing the program, then I will wake up feeling

f h d ”

Page 126: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 126/298

refreshed.”SolutionLet p be the proposition “You send me an e-mail” q , the proposition “I willnish writing the program” r , the proposition “I will go to sleep early” s , theproposition “I will wake up feeling refreshed”

The hypotheses are p → q , ¬p → r , r → s . The desired conclusion is¬q → s

1 p → q Hypothesis

2 ¬q → ¬p Contrapositive of (1)

3 ¬p → r Hypothesis

5 r → s Hypothesis

6 ¬q → s

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Show that the hypotheses “If you send me an e-mail, then I will nish writingthe program”, “If you do not send me an e-mail, then I will go to sleep early”,and “If I go to sleep early, then I will wake up feeling refreshed” lead to theconclusion “If I do not nish writing the program, then I will wake up feeling

f h d ”

Page 127: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 127/298

refreshed.”SolutionLet p be the proposition “You send me an e-mail” q , the proposition “I willnish writing the program” r , the proposition “I will go to sleep early” s , theproposition “I will wake up feeling refreshed”

The hypotheses are p → q , ¬p → r , r → s . The desired conclusion is¬q → s

1 p → q Hypothesis

2 ¬q → ¬p Contrapositive of (1)

3 ¬p → r Hypothesis4 ¬q → r Hypothetical syllogism using ( 2) and (3)

5 r → s Hypothesis

6 ¬q → s

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Show that the hypotheses “If you send me an e-mail, then I will nish writingthe program”, “If you do not send me an e-mail, then I will go to sleep early”,and “If I go to sleep early, then I will wake up feeling refreshed” lead to theconclusion “If I do not nish writing the program, then I will wake up feeling

f h d ”

Page 128: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 128/298

refreshed.”SolutionLet p be the proposition “You send me an e-mail” q , the proposition “I willnish writing the program” r , the proposition “I will go to sleep early” s , theproposition “I will wake up feeling refreshed”

The hypotheses are p → q , ¬p → r , r → s . The desired conclusion is¬q → s

1 p → q Hypothesis

2 ¬q → ¬p Contrapositive of (1)

3 ¬p → r Hypothesis4 ¬q → r Hypothetical syllogism using ( 2) and (3)

5 r → s Hypothesis

6 ¬q → s Hypothetical syllogism using ( 4) an d (5)

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Sh th t th h th ( ) d i l th

Page 129: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 129/298

Show that the hypotheses (p ∧

q )∨r and r →s imply theconclusion p ∨s

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Sh th t th h th ( q ) d i l th

Page 130: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 130/298

Show that the hypotheses (p ∧

q )∨r and r →s imply theconclusion p ∨s

Solution(p

q )

r can be rewritten as two clauses, p

r and q

r .r →s can also be rewritten as ¬r ∨s . Using resolution on thetwo clauses, p ∨r and ¬r ∨s , we can obtain the conclusionp ∨s .

Valid arguments Fallacies Rules of inference for quantied statements

Fallacy of afrming conclusion

Page 131: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 131/298

This is NOT a valid argumentIf you do every problem in this book, then you will learn discrete

mathematics. You learned discrete mathematics.Therefore, you did every problem in this book.

Valid arguments Fallacies Rules of inference for quantied statements

Fallacy of afrming conclusion

Page 132: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 132/298

This is NOT a valid argumentIf you do every problem in this book, then you will learn discrete

mathematics. You learned discrete mathematics.Therefore, you did every problem in this book.

This argument is not valid because the proposition[(p →q )∧q ] →p is NOT a tautology.

Valid arguments Fallacies Rules of inference for quantied statements

Fallacy of denying the hypothesis

Page 133: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 133/298

This is NOT a valid argumentIf you do every problem in this book, then you will learn discrete

mathematics. You did not do every problem in this book.Therefore, you did not learn discrete mathematics.

Valid arguments Fallacies Rules of inference for quantied statements

Fallacy of denying the hypothesis

Page 134: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 134/298

This is NOT a valid argumentIf you do every problem in this book, then you will learn discrete

mathematics. You did not do every problem in this book.Therefore, you did not learn discrete mathematics.

This argument is not valid because the proposition[(p →q )∧¬p ] → ¬q is NOT a tautology.

Valid arguments Fallacies Rules of inference for quantied statements

Rules on universal quantiers

Universal instantiation

Page 135: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 135/298

Universal instantiation

∀x .P (x )∴ P (c )

Valid arguments Fallacies Rules of inference for quantied statements

Rules on universal quantiers

Universal instantiation

Page 136: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 136/298

Universal instantiation

∀x .P (x )∴ P (c )

c is a particular member of the domain, given the premise

∀x .P (x )Example: from the statement “All women are wise”, we can

conclude “Lisa is wise”, provided that Lisa is a member ofthe domain of all women.

Valid arguments Fallacies Rules of inference for quantied statements

Rules on universal quantiers

Universal generalization

Universal generalization

P (c ) for an arbitrary c

Page 137: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 137/298

P (c ) for an arbitrary c

∀x .P (x )

Valid arguments Fallacies Rules of inference for quantied statements

Rules on universal quantiers

Universal generalization

Universal generalization

P (c ) for an arbitrary c

Page 138: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 138/298

P (c ) for an arbitrary c

∀x .P (x )

Universal generalization is used when we show that

∀x .P (x ) is true by taking an arbitrary element c from the

domain, and showing that P (c ) is true.Arbitrary means that we have no control over c and cannotmake any assumptions about c other than it comes from

the domain.This rule is often used implicitly in mathematics.Also often used incorrectly, due to making unwarrantedassumptions about the arbitrary element c .

Valid arguments Fallacies Rules of inference for quantied statements

Rules on existential quantiers

Existential instantiation

Existential instantiation

∃x P (x )

Page 139: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 139/298

∃x .P (x )∴ P (c ) for some element c

Valid arguments Fallacies Rules of inference for quantied statements

Rules on existential quantiers

Existential instantiation

Existential instantiation

∃x P (x )

Page 140: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 140/298

∃x .P (x )∴ P (c ) for some element c

This rule allows us to conclude that there is an element c in the domain for which P (c ) is true, if we know that

∃x .P (x ) is true.c is NOT arbitrary, but rather it must the c for which P (c ) istrue.Usually we have no knowledge over c , other that it exists.Because it exists, we may give it a name ( c ) and continueour argument.

Valid arguments Fallacies Rules of inference for quantied statements

Rules on existential quantiers

Existential generalization

Page 141: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 141/298

Existential generalization

P (c ) for some element c

∃x .P (x )

Valid arguments Fallacies Rules of inference for quantied statements

Rules on existential quantiers

Existential generalization

Page 142: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 142/298

Existential generalization

P (c ) for some element c

∃x .P (x )

This rule is used to conclude that ∃x .P (x ) is true when weknow a particular element c with P (c ) true.

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Show that the premises “Everyone in this discrete mathematicsclass also takes a course in foundations of programming”, and“Eva is a student is this class” imply the conclusion “Eva takes

a course in foundations of programming”.

Page 143: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 143/298

p g g

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Show that the premises “Everyone in this discrete mathematicsclass also takes a course in foundations of programming”, and“Eva is a student is this class” imply the conclusion “Eva takes

a course in foundations of programming”.

Page 144: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 144/298

SolutionLet D (x ) denote “ x is in this discrete mathematics class”, andC (x ) denote “ x takes a course in foundations of programming”.

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Show that the premises “Everyone in this discrete mathematicsclass also takes a course in foundations of programming”, and“Eva is a student is this class” imply the conclusion “Eva takes

a course in foundations of programming”.

Page 145: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 145/298

SolutionLet D (x ) denote “ x is in this discrete mathematics class”, andC (x ) denote “ x takes a course in foundations of programming”.The hypotheses are

∀x .(D (x ) →C (x )) and D (Eva ). The

desired conclusion is C (Eva )

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Show that the premises “Everyone in this discrete mathematicsclass also takes a course in foundations of programming”, and“Eva is a student is this class” imply the conclusion “Eva takes

a course in foundations of programming”.

Page 146: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 146/298

SolutionLet D (x ) denote “ x is in this discrete mathematics class”, andC (x ) denote “ x takes a course in foundations of programming”.The hypotheses are

∀x .(D (x ) →C (x )) and D (Eva ). The

desired conclusion is C (Eva )

1∀x .(D (x ) →C (x )) Premise

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Show that the premises “Everyone in this discrete mathematicsclass also takes a course in foundations of programming”, and“Eva is a student is this class” imply the conclusion “Eva takes

a course in foundations of programming”.

Page 147: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 147/298

SolutionLet D (x ) denote “ x is in this discrete mathematics class”, andC (x ) denote “ x takes a course in foundations of programming”.The hypotheses are

∀x .(D (x ) →C (x )) and D (Eva ). The

desired conclusion is C (Eva )

1∀x .(D (x ) →C (x )) Premise

2 D (Eva )

→C (Eva ) Universal instantiation from (1)

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Show that the premises “Everyone in this discrete mathematicsclass also takes a course in foundations of programming”, and“Eva is a student is this class” imply the conclusion “Eva takes

a course in foundations of programming”.

Page 148: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 148/298

SolutionLet D (x ) denote “ x is in this discrete mathematics class”, andC (x ) denote “ x takes a course in foundations of programming”.The hypotheses are

∀x .(D (x ) →C (x )) and D (Eva ). The

desired conclusion is C (Eva )

1∀x .(D (x ) →C (x )) Premise

2 D (Eva )

→C (Eva ) Universal instantiation from (1)

3 D (Eva ) Premise

Valid arguments Fallacies Rules of inference for quantied statements

Examples

Show that the premises “Everyone in this discrete mathematicsclass also takes a course in foundations of programming”, and“Eva is a student is this class” imply the conclusion “Eva takes

a course in foundations of programming”.

Page 149: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 149/298

SolutionLet D (x ) denote “ x is in this discrete mathematics class”, andC (x ) denote “ x takes a course in foundations of programming”.The hypotheses are

∀x .(D (x ) →C (x )) and D (Eva ). The

desired conclusion is C (Eva )

1∀x .(D (x ) →C (x )) Premise

2 D (Eva )

→C (Eva ) Universal instantiation from (1)

3 D (Eva ) Premise4 C (Eva ) Modus ponens from ( 2) and (3)

Valid arguments Fallacies Rules of inference for quantied statements

Universal modus ponens & modus tollens

Universal modus ponens & modus tollens

Universal modus ponens

Page 150: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 150/298

∀x .(P (x ) →Q (x ))P (a ), where a is a particular element in the domain

∴ Q (a )

Universal modus tollens

∀x .(P (x ) →Q (x ))

¬Q (a ), where a is a particular element in the domain

∴ ¬P (a )

Valid arguments Fallacies Rules of inference for quantied statements

Universal modus ponens & modus tollens

Example

Assume that “For all positive integers n, if n is greater than 4,

Page 151: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 151/298

Assume that For all positive integers n , if n is greater than 4,then n 2 is less than 2 n ” is true. Show that 100 2 < 2100 .

Valid arguments Fallacies Rules of inference for quantied statements

Universal modus ponens & modus tollens

Example

Assume that “For all positive integers n, if n is greater than 4,

Page 152: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 152/298

Assume that For all positive integers n , if n is greater than 4,then n 2 is less than 2 n ” is true. Show that 100 2 < 2100 .

Solution

Let P (n ) denote “ n > 4” and Q (n ) denote “ n 2 < 2n ”. Thepremise can be represented by ∀n .(P (n ) →Q (n )) , where thedomain consists of all positive integers. Note P (100 ) is truebecause 100 > 4. It follows by universal modus ponens thatQ (n ) is true, namely 100 2 < 2100

IKI10600I: Discrete Mathematics IProofs

Page 153: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 153/298

Adila A. Krisnadhi

Faculty of Computer Science, University of Indonesia

Basic Terminology of Mathematical Proof Proof methods

ProofsOutline

Page 154: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 154/298

11 Basic Terminology of Mathematical Proof

12 Proof methodsDirect proofsProof by contraposition

Basic Terminology of Mathematical Proof Proof methods

Another example (of previous lecture)

Is the following argument valid?

If Superman were able and willing to prevent evil, he would do so. IfSuperman were unable to prevent evil, he would be impotent; if he were

Page 155: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 155/298

unwilling to prevent evil, he would be malevolent. Superman does not preventevil. If Superman exists, he is neither impotent nor malevolent. Therefore,Superman does not exist.

Basic Terminology of Mathematical Proof Proof methods

Another example (of previous lecture)

Is the following argument valid?

If Superman were able and willing to prevent evil, he would do so. IfSuperman were unable to prevent evil, he would be impotent; if he werell l h ld b l l d

Page 156: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 156/298

unwilling to prevent evil, he would be malevolent. Superman does not preventevil. If Superman exists, he is neither impotent nor malevolent. Therefore,Superman does not exist.

AnswerSuperman does not prevent evil. By Modus Tollens, we obtain that Supermanis either unable or unwilling to prevent evil. If Superman is unable to preventevil, then he is impotent; similarly, if Superman is unwilling to prevent evil,then he is malevolent. Thus, by Modus Ponens, we have that Superman is

either impotent or malevolent. Since if Superman exists, he is neitherimpotent nor malevolent, by Modus Tollens, we conclude that Supermandoes not exist.Since the conclusion is derived by always using valid rules of inference, weknow that the argument is valid.

Basic Terminology of Mathematical Proof Proof methods

Basic Terminology I

Theorem, proposition, lemma : a statement that can be

shown to be true.Theorem is usually reserved for a statement that is

Page 157: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 157/298

Theorem is usually reserved for a statement that isconsidered somewhat important; sometimes it is refered asfact or result .

Propositions are typically less important than theorems;lemma are typically less important than propositions.Proof : a valid argument that establishes the truth of atheorem/proposition/lemma.Statements used in a proof can include:

axioms (postulates): statements assumed to be true;premise(s) of the theorem/proposition/lemma that we wantto prove;previously proven theorem/propositio n /lemma.

Basic Terminology of Mathematical Proof Proof methods

Basic Terminology II

Lemma (“small” theorem) are usually used to help provingother results (not as itself); complicated proofs are usually

Page 158: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 158/298

( ); p p yeasier to understand when they are proved using series oflemmas.

Corollary : a theorem that can be establisheddirectly/straightforwardly from a theorem that has beenproved.

Conjencture : a statement that is being proposed to be atrue statement; its truth is unknown until somebody gives it

a valid proof.

Basic Terminology of Mathematical Proof Proof methods

Theorem statement

Many (though not all) theorems assert that a propertyholds for all elements in a domain.

Page 159: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 159/298

In such cases, a universal quantier is usually omitted,although it is formally needed for a precise statement.In proving theorems, universal instantiation is often usedimplicitly.

Basic Terminology of Mathematical Proof Proof methods

Theorem statement

Many (though not all) theorems assert that a propertyholds for all elements in a domain.

Page 160: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 160/298

In such cases, a universal quantier is usually omitted,although it is formally needed for a precise statement.In proving theorems, universal instantiation is often usedimplicitly.The theorem:“Ifx > y , where x and y are positive real numbers, thenx 2 > y 2”

Basic Terminology of Mathematical Proof Proof methods

Theorem statement

Many (though not all) theorems assert that a propertyholds for all elements in a domain.

h l ll d

Page 161: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 161/298

In such cases, a universal quantier is usually omitted,although it is formally needed for a precise statement.In proving theorems, universal instantiation is often usedimplicitly.The theorem:“Ifx > y , where x and y are positive real numbers, thenx 2 > y 2”

actually means

Basic Terminology of Mathematical Proof Proof methods

Theorem statement

Many (though not all) theorems assert that a propertyholds for all elements in a domain.I h i l i i ll i d

Page 162: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 162/298

In such cases, a universal quantier is usually omitted,although it is formally needed for a precise statement.In proving theorems, universal instantiation is often usedimplicitly.The theorem:“Ifx > y , where x and y are positive real numbers, thenx 2 > y 2”

actually means“For all positive real numbers x and y , if x > y , thenx 2 > y 2”

Basic Terminology of Mathematical Proof Proof methods

Direct proofs

Direct proof

A direct proof of a statement p →q is constructed asfollows:

Page 163: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 163/298

Basic Terminology of Mathematical Proof Proof methods

Direct proofs

Direct proof

A direct proof of a statement p →q is constructed asfollows:

Page 164: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 164/298

rst, assume that p is true;

Basic Terminology of Mathematical Proof Proof methods

Direct proofs

Direct proof

A direct proof of a statement p →q is constructed asfollows:

Page 165: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 165/298

rst, assume that p is true;construct subsequent steps using rules of inference until ...

Basic Terminology of Mathematical Proof Proof methods

Direct proofs

Direct proof

A direct proof of a statement p →q is constructed asfollows:

Page 166: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 166/298

rst, assume that p is true;construct subsequent steps using rules of inference until ...q is obtained as true as the nal step.

Basic Terminology of Mathematical Proof Proof methods

Direct proofs

Direct proof

A direct proof of a statement p →q is constructed asfollows:

h i

Page 167: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 167/298

rst, assume that p is true;construct subsequent steps using rules of inference until ...q is obtained as true as the nal step.

In intermediate steps, we are also allowed to use axioms,denitions and previously proven theorems.

Basic Terminology of Mathematical Proof Proof methods

Direct proofs

Direct proof

A direct proof of a statement p →q is constructed asfollows: h i

Page 168: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 168/298

rst, assume that p is true;construct subsequent steps using rules of inference until ...q is obtained as true as the nal step.

In intermediate steps, we are also allowed to use axioms,denitions and previously proven theorems.A direct proof of a statement ∀x (P (x ) →Q (x )) isconstructed by showing that P (c ) →Q (c ) is true, where c

is an arbitrary element of the domain (and then applyinguniversal generalization).

Basic Terminology of Mathematical Proof Proof methods

Direct proofs

Prove the following theorems using direct proofsee the whiteboard for details; take notes if necessary!

Denition

Page 169: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 169/298

DenitionAn integer n is even if there exists an integer k such thatn = 2k ; and n is odd if there exists an integer k such thatn = 2k + 1.

TheoremIf n is an odd integer then n 2 is odd.

Basic Terminology of Mathematical Proof Proof methods

Direct proofs

Prove the following theorems using direct proofsee the whiteboard for details; take notes if necessary!

TheoremIf m and n are both perfect squares, then then nm is also perfect square where an integer a is a perfect square if there is

Page 170: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 170/298

perfect square, where an integer a is a perfect square if there is an integer b such that a = b 2 .

TheoremThe sum of two odd integers is even.The square of an even number is an even number.

TheoremIf m + n and n + p are even integers, where m , n, and p are integers, then m + p is even.

Basic Terminology of Mathematical Proof Proof methods

Direct proofs

Prove the following theorems using direct proofsee the whiteboard for details; take notes if necessary!

D i i

Page 171: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 171/298

DenitionA real number r is rational if there exists integers p and q withq

=0 such that r

=p

q ; otherwise it is called irrational .

TheoremThe sum of two rational numbers is rational.

Basic Terminology of Mathematical Proof Proof methods

Proof by contraposition

Proof by contraposition

Page 172: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 172/298

A proof by contraposition for a statement p →q isconstructed as follows:

Basic Terminology of Mathematical Proof Proof methods

Proof by contraposition

Proof by contraposition

Page 173: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 173/298

A proof by contraposition for a statement p →q isconstructed as follows:

assume that ¬q is true;

Basic Terminology of Mathematical Proof Proof methods

Proof by contraposition

Proof by contraposition

Page 174: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 174/298

A proof by contraposition for a statement p →q isconstructed as follows:

assume that ¬q is true;construct subsequent steps using rules of inference until ...

Basic Terminology of Mathematical Proof Proof methods

Proof by contraposition

Proof by contraposition

Page 175: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 175/298

A proof by contraposition for a statement p →q isconstructed as follows:

assume that ¬q is true;construct subsequent steps using rules of inference until ...

¬p is obtained as true as the nal step.

Basic Terminology of Mathematical Proof Proof methods

Proof by contraposition

Prove the following theorems by contrapositionsee the whiteboard for details; take notes if necessary!

TheoremIf n is an integer and 3n + 2 is odd, then n is odd.

Page 176: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 176/298

TheoremIf n = ab, where a and b are positive integers, then a

≤√n or

b ≤√n.

TheoremIf n is an integer and n 2 is odd, then n is odd.

TheoremIf x is irrational, then 1/ x is irrational.

IKI10600I: Discrete Mathematics IProofs (2)

Page 177: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 177/298

Adila A. Krisnadhi

Faculty of Computer Science, University of Indonesia

Proof Methods (2) Mistakes in Proof Proof methods (3)

Proofs (2)Outline

13 Proof Methods (2)Vacuous and Trivial ProofsProof by Contradiction

Page 178: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 178/298

Proof by ContradictionProofs of equivalenceCounterexamples

14 Mistakes in Proof

15 Proof methods (3)

Exhaustive proofProof by cases

Proof Methods (2) Mistakes in Proof Proof methods (3)

Vacuous and Trivial Proofs

Vacuous proof

We can quickly prove that a conditional statement p →q is truewhen we know that p is false . Why?

Page 179: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 179/298

Proof Methods (2) Mistakes in Proof Proof methods (3)

Vacuous and Trivial Proofs

Vacuous proof

We can quickly prove that a conditional statement p →q is truewhen we know that p is false . Why?Because p →q must be true whenever p is false.

Page 180: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 180/298

p →q p

Proof Methods (2) Mistakes in Proof Proof methods (3)

Vacuous and Trivial Proofs

Vacuous proof

We can quickly prove that a conditional statement p →q is truewhen we know that p is false . Why?Because p →q must be true whenever p is false.

Page 181: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 181/298

p →q p

Show that the proposition P (0) is true, where P (n ) is “If n > 1,

then n 2 > n ” and the domain consists of all integers.

Proof Methods (2) Mistakes in Proof Proof methods (3)

Vacuous and Trivial Proofs

Vacuous proof

We can quickly prove that a conditional statement p →q is truewhen we know that p is false . Why?Because p →q must be true whenever p is false.

Page 182: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 182/298

p →q p

Show that the proposition P (0) is true, where P (n ) is “If n > 1,

then n 2 > n ” and the domain consists of all integers.

Vacuous proof

Note that P (0) is “If 0 > 1, then 0 2 > 0”. Then P (0) is true

because the hypothesis 0 > 1 is false.

Proof Methods (2) Mistakes in Proof Proof methods (3)

Vacuous and Trivial Proofs

Trivial proof

We can quickly prove that a conditional statement p →q is truewhen we know that q is true . Why?

Page 183: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 183/298

Proof Methods (2) Mistakes in Proof Proof methods (3)

Vacuous and Trivial Proofs

Trivial proof

We can quickly prove that a conditional statement p →q is truewhen we know that q is true . Why?Because p →q must be true whenever q is true (regardless ofthe hypothesis p ).

Page 184: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 184/298

Proof Methods (2) Mistakes in Proof Proof methods (3)

Vacuous and Trivial Proofs

Trivial proof

We can quickly prove that a conditional statement p →q is truewhen we know that q is true . Why?Because p →q must be true whenever q is true (regardless ofthe hypothesis p ).

Page 185: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 185/298

Let P (n ) be “If a and b are positive integers with a ≥b , thena n

≥b n ” where the domain consists of all integers. Show that

P (0) is true.

Proof Methods (2) Mistakes in Proof Proof methods (3)

Vacuous and Trivial Proofs

Trivial proof

We can quickly prove that a conditional statement p →q is truewhen we know that q is true . Why?Because p →q must be true whenever q is true (regardless ofthe hypothesis p ).

Page 186: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 186/298

Let P (n ) be “If a and b are positive integers with a ≥b , thena n

≥b n ” where the domain consists of all integers. Show that

P (0) is true.

Trivial proof

Note that P (0) is “If a

≥b , then a 0

≥b 0”. Because

a 0 = b 0 = 1, the conclusion of the statement P (0) is true.Hence, P (0) itself is trivially true. Note that the hypothesis“a ≥b ” was not needed in this proof.

Proof Methods (2) Mistakes in Proof Proof methods (3)

Proof by Contradiction

Proof by contradiction: idea

The idea of proof by contradiction :Suppose we want to prove that a statement p is true .

Page 187: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 187/298

Proof Methods (2) Mistakes in Proof Proof methods (3)

Proof by Contradiction

Proof by contradiction: idea

The idea of proof by contradiction :Suppose we want to prove that a statement p is true .Moreover, suppose we can show that there is a statementq such that ¬p →q is true AND q is a contradictorystatement

Page 188: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 188/298

statement.

Proof Methods (2) Mistakes in Proof Proof methods (3)

Proof by Contradiction

Proof by contradiction: idea

The idea of proof by contradiction :Suppose we want to prove that a statement p is true .Moreover, suppose we can show that there is a statementq such that ¬p →q is true AND q is a contradictorystatement

Page 189: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 189/298

statement.Then, we can conclude that ¬p is false , which means that

p is true .

Proof Methods (2) Mistakes in Proof Proof methods (3)

Proof by Contradiction

Proof by contradiction: idea

The idea of proof by contradiction :Suppose we want to prove that a statement p is true .Moreover, suppose we can show that there is a statementq such that ¬p →q is true AND q is a contradictorystatement.

Page 190: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 190/298

statement.Then, we can conclude that ¬p is false , which means that

p is true .

How can we nd such a contradiction q that might help usprove that p is true in this way?

Proof Methods (2) Mistakes in Proof Proof methods (3)

Proof by Contradiction

Proof by contradiction: idea

The idea of proof by contradiction :Suppose we want to prove that a statement p is true .Moreover, suppose we can show that there is a statementq such that ¬p →q is true AND q is a contradictorystatement.

Page 191: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 191/298

statement.Then, we can conclude that ¬p is false , which means that

p is true .

How can we nd such a contradiction q that might help usprove that p is true in this way?

Because the statement r ∧¬r is always a contradictionwhenever r is a proposition, we can prove that p is true if wecan show that ¬p →(r ∧¬r ) is true for some proposition r .

Proof Methods (2) Mistakes in Proof Proof methods (3)

Proof by Contradiction

Proof by contradiction: steps

Suppose that p is a proposition that we want to prove.A proof by contradiction of p is constructed as follows:

Fi t th t i t

Page 192: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 192/298

First, assume that ¬p is true.

Proof Methods (2) Mistakes in Proof Proof methods (3)

Proof by Contradiction

Proof by contradiction: steps

Suppose that p is a proposition that we want to prove.A proof by contradiction of p is constructed as follows:

First assume that p is true

Page 193: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 193/298

First, assume that ¬p is true.Derive statements which are true as consequences of thisassumption until ...

Proof Methods (2) Mistakes in Proof Proof methods (3)

Proof by Contradiction

Proof by contradiction: steps

Suppose that p is a proposition that we want to prove.A proof by contradiction of p is constructed as follows:

First assume that p is true

Page 194: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 194/298

First, assume that ¬p is true.Derive statements which are true as consequences of thisassumption until ...we obtain a statement that contradicts previously-derivedstatements, i.e., a statement r whose negation ¬r isalready derived previously.

Proof Methods (2) Mistakes in Proof Proof methods (3)

Proof by Contradiction

Prove the following theorems by contradictionsee the whiteboard for details; take notes if necessary!

TheoremAt least four of any 22 days must fall on the same day.

Page 195: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 195/298

Theorem

√2 is irrational

TheoremIf 3n + 2 is odd, then n is odd.

Proof Methods (2) Mistakes in Proof Proof methods (3)

Proofs of equivalence

Proof of equivalence

In order to show that a biconditional statement p ↔q is

Page 196: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 196/298

p ↔qtrue, we show that p →q and q →p are both true.

Proof Methods (2) Mistakes in Proof Proof methods (3)

Proofs of equivalence

Proof of equivalence

In order to show that a biconditional statement p ↔q is

Page 197: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 197/298

p ↔qtrue, we show that p →q and q →p are both true.

This approach is valid because it is based on the tautology(p ↔q ) ↔[(p →q )∧(q →p )].

Proof Methods (2) Mistakes in Proof Proof methods (3)

Proofs of equivalence

Prove the following theoremssee the whiteboard for details; take notes if necessary!

Theorem

Page 198: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 198/298

If n is a positive integer, then n is odd iff n 2 is odd.

TheoremIf n is a positive integer, then n is odd if and only if 5n + 6 is odd.

Proof Methods (2) Mistakes in Proof Proof methods (3)

Proofs of equivalence

Proof of equivalence (more than 2 statements)

In order to show that the propositions p 1 , p 2 , . . . ,p n are

equivalent, we show that p 1 ↔p 2 ↔. . . ↔p n is true.One way to show this, is by showing that all conditionalstatements p 1 →p 2 , p 2 →p 3 , . . . , p n →p 1 are true.

Page 199: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 199/298

The idea is so that we can establish any chain ofconditional statements from any one of the proposition toany other propositions.

Show the following statements are equivalent1 n is even.2 n −1 is odd.3 n 2 is even.

Proof Methods (2) Mistakes in Proof Proof methods (3)

Counterexamples

Counterexamples

In order to show that a statement of the form ∀xP (x ), we need onlynd a counterexample , i.e., an example x for which P (x ) is false.

Using counterexampleDisprove the statement “Every positive integer is the sum of thesquares of two integers”.

Page 200: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 200/298

Proof Methods (2) Mistakes in Proof Proof methods (3)

Counterexamples

Counterexamples

In order to show that a statement of the form ∀xP (x ), we need onlynd a counterexample , i.e., an example x for which P (x ) is false.

Using counterexampleDisprove the statement “Every positive integer is the sum of thesquares of two integers”.

Page 201: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 201/298

AnswerTo disprove the universally quantied statement above, we look for acounterexample which is a particular integer that is NOT the sum ofthe squares of two integers. For this statement, a counterexample iseasy to nd. One such counterexample is 3. To show that this is the

case, not that the only two perfect squares not exceeding 3 are02 = 0 and 1 2 = 1. It is easy to see that there is no way to get 3 asthe sum of two terms each of which is 0 or 1. Thus 3 is acounterexample of the statement above.

Proof Methods (2) Mistakes in Proof Proof methods (3)

Fallacy: arming the conclusion

Can you nd what is wrong in the following “proof” of the statement “Ifn 2 is positive, then n is positive”?

Supposed ProofSuppose that n 2 is positive. Because the statement “If n is positive,then n 2 is positive” is true, we can conclude that n is positive.

Page 202: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 202/298

Proof Methods (2) Mistakes in Proof Proof methods (3)

Fallacy: arming the conclusion

Can you nd what is wrong in the following “proof” of the statement “Ifn 2 is positive, then n is positive”?

Supposed ProofSuppose that n 2 is positive. Because the statement “If n is positive,then n 2 is positive” is true, we can conclude that n is positive.

Page 203: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 203/298

This proof is wrong . Let P (n ) be “n is positive” and Q (n ) be “n 2

is positive”.

Then the statement that we want to prove is ∀n (Q (n ) →P (n )) .Take Q (n ) is the hypothesis.

In the supposed “proof”, we make use of the statement

∀n (P (n ) →Q (n )) .

But from Q (n ) as the hypothesis and the statement

∀n (P (n ) →Q (n )) , we cannot conclude P (n ), since there is novalid rule inference that is usable here.

Proof Methods (2) Mistakes in Proof Proof methods (3)

Fallacy: begging the question (circular reasoning)

Can you nd what is wrong with the following “proof” of thetheorem “ n 2 is an even integer implies n is an even integer”?

Supposed proofSuppose that n 2 is even. Then n 2 = 2k for some integer k . Letn = 2 for some integer . This shows that n is even.

Page 204: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 204/298

g

Proof Methods (2) Mistakes in Proof Proof methods (3)

Fallacy: begging the question (circular reasoning)

Can you nd what is wrong with the following “proof” of thetheorem “ n 2 is an even integer implies n is an even integer”?

Supposed proofSuppose that n 2 is even. Then n 2 = 2k for some integer k . Letn = 2 for some integer . This shows that n is even.

Page 205: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 205/298

The proof is wrong , because the statement “let n = 2 forsome integer ” occurs in the proof.No argument has been given to show that n can indeed bewritten as 2 for some integer .This is circular reasoning because this statement isequivalent to the statement being proved, i.e., “ n is even”.Note that the theorem itself is actually correct (can yougive a valid proof of it?), but the metho d of proof is wrong.

Proof Methods (2) Mistakes in Proof Proof methods (3)

Exhaustive proof

Some statement can be proved by examining ALL possibleexample. Such proofs is called exhaustive proof .This method is suitable only when the number of examplesare relatively small.

Prove the following resultThe only consecutive positive integers not exceeding 100 thatare perfect powers are 8 and 9 (An integer n is a perfect power

Page 206: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 206/298

are perfect powers are 8 and 9. (An integer n is a perfect powerif there exists two integers m and k > 1 such that n = m k ).

Proof Methods (2) Mistakes in Proof Proof methods (3)

Exhaustive proof

Some statement can be proved by examining ALL possibleexample. Such proofs is called exhaustive proof .This method is suitable only when the number of examplesare relatively small.

Prove the following resultThe only consecutive positive integers not exceeding 100 thatare perfect powers are 8 and 9. (An integer n is a perfect power

Page 207: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 207/298

are perfect powers are 8 and 9. (An integer n is a perfect powerif there exists two integers m and k > 1 such that n = m k ).

An exhaustive proof of this statement can be done byconstructing a table consisting all possible example ofnumbers not exceeding 100 and of the form m k .

This method is suitable only because the size of the tableis relatively small.If you must prove the result for integers not exceeding1000, this method would be too difcu lt a nd te dious .

Proof Methods (2) Mistakes in Proof Proof methods (3)

Proof by cases

Proof by casessee the whiteboard for details; take notes if necessary!

A proof by cases must cover ALL possible cases that arise

in a theorem.This method works since the statement(p 1∨p 2∨. . .∨p n ) →q is equivalent to(p q )∧(p q )∧ ∧(p q )

Page 208: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 208/298

(p 1 →q )∧(p 2 →q )∧. . .∧(p n →q ).

TheoremIf n is an integer, then n 2 ≥n.

TheoremFor every real numbers x and y, |xy | = |x ||y |, where |a | = a if a ≥0 and |a | = −a if a < 0.

IKI10600I: Discrete Mathematics ISet

Adila A. Krisnadhi

Page 209: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 209/298

Faculty of Computer Science, University of Indonesia

Set: basics Set operations

SetOutline

16 Set: basics

Page 210: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 210/298

17 Set operations

Set: basics Set operations

Set: denition

DenitionA set is an unordered collection of distinct objects.

Page 211: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 211/298

DenitionObjects in a set are called elements or members of the set.Here, the set is said to contain its elements.

Set: basics Set operations

Set: notation

Sets are usually denoted by large capitals: A, B , X , Y , . . . ;if necessary with index.Elements of a set are usually denoted by small letters:

b if i h i d

Page 212: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 212/298

a , b , x , y , . . . ; if necessary with index.

x ∈

A denotes that x is an element of A, i.e., A contains x as one of its element.x /∈A denotes that x is not an element of A.

∅denotes the empty set.

Set: basics Set operations

Set: representation

Representation of sets:using listing:

{x 1 , x 2 , x 3 . . . ,x n }for sets with nite number of elements

{x 1 , x 2 , x 3 . . .}for sets with innite number of elements

Page 213: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 213/298

{ }using description (set builder notation) where P is apredicate over elements of the set:

{x : P (x )}or {x | P (x )}{x ∈S : P (x )}or {x ∈S | P (x )}where S is another set inthe context of the discussion, restricting the elements of thedenoted set (sometimes called a universal set ).

Set: basics Set operations

Set: examples

The set of natural numbers N = {0, 1, 2, 3, . . . }(Note: sometimes people dene natural numbers starting from 1, not 0)

The set of integersZ = {0, 1, − 1, 2, − 2, . . . } = {. . . , − 2, − 1, 0, 1, 2, . . . }The set of positive integers Z + = {1, 2, 3, . . . }The set of rational numbers Q = {p / q | p ∈Z , q ∈Z , and q = 0}

Page 214: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 214/298

Q {p q | p , q , q }

The set of real numbersR

A = {x ∈N | x 2 − 3x + 2 = 0}, set of natural numbers x such thatx 2 − 3x + 2 = 0. A can also be written as {1, 2}.

The set of positive even numbers is written as {2x | x ∈N} or{x | x = 2y , y ∈N} or {x ∈N | x = 2y , y ∈N}.

The set B = {x ∈N | 6 < x < 9} can also be written as B = {7, 8}The set B = {7, 8} can also be written as {x ∈N | 40 < x 2 < 80 } or{x ∈N | x 2 − 15 x + 56 = 0} or {7 + x ∈N | x = 0 or x = 1}

Set: basics Set operations

Set equality and subsets

DenitionTwo sets A and B are equal (written A = B ) iffA and B have the same

elements. Otherwise, they are not equal and written as A = B .

A = B iff∀x (x ∈A ↔x ∈B ) is true.

Denition

Page 215: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 215/298

The set A is a subset of B (written A

B ) iff every element of A isalso an element of B .

Here, we also say that B is a superset of A (written B ⊇A)

A⊆B iff∀x (x ∈A →x ∈B ) is true.

DenitionThe set A is a proper subset of B iff A⊆B and A = B

Set: basics Set operations

Set equality and subsets (contd.)

{1, 3 , 5}= {3, 5, 1}(the order is not important)

{1, 3 , 5

} ⊆ {3, 5, 1

}{1, 3 , 5} ⊆N{1, 3 , 5} {3, 1}and {1 , 3, 5} {x ∈N | x is even }

Page 216: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 216/298

Theorem (proof is for exercise!)For every set S

∅ ⊆S S ⊆S

Theorem (proof is for exercise!)For every two sets A and B, A = B iff A⊆B and B ⊆A

Set: basics Set operations

Finite set and cardinality

Denition

Let S be a set.S is a nite set iff it has exactly n elements where n isnonnegative integer.Here, n is called the cardinality of S .

Page 217: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 217/298

The cardinality of S is denoted by |S |S is innite iff it is not nite.

Let A be the set of odd positive integer less than 10. ThenA is nite (its cardinality

|A

|is 5).

|∅|= 0.The set of positive integers is innite.

Set: basics Set operations

The power set

DenitionLet S be a set. The power set of S is the set of all subsets of S .The power set of S is denoted by P (S ) or sometimes 2 S .

The power set of the set {0, 1 , 2}isP ({0 1 2}) =

Page 218: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 218/298

P ({0 , 1, 2}) =

{∅, {0}, {1}, {2}, {0 , 1}, {0 , 2}, {1 , 2}, {0 , 1, 2}}The power set of the empty set ∅is P (∅) = {∅}.The power set of the set {∅}is P ({∅}) = {∅, {∅}}

TheoremIf a set S has n elements then its power set P (S ) has 2n

elements.

Set: basics Set operations

Ordered tuple

Sets are unordered ; we need different structure torepresent ordered collection.

DenitionThe (ordered) n-tuple (a 1 , a 2 , . . . ,a n ) is the ordered collectionwith a 1 as its rst element, a 2 as its second element, ..., and a n

Page 219: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 219/298

1 2

as its n th element.

2-tuples are usually called ordered pairsTwo n -tuples (a 1 , a 2 , . . . ,a n ) and (b 1 , b 2 , . . . ,b n ) are equaliff a i = b i for i = 1 , 2, . . . ,n (i.e., each corresponding pair oftheir elements are equal).In particular, two ordered pairs (a , b ) and (c , d ) are equaliff a = c and b = d .

Set: basics Set operations

Cartesian products

We can use Cartesian product to form a set of ordered pairsfrom two sets.

DenitionLet A and B be sets. The Cartesian product of A and B (denoted by A ×B ), is the set of all ordered pairs (a , b ) wherea ∈A and b ∈B . In other words

Page 220: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 220/298

∈ ∈

A ×B = {(a , b ) | a ∈

A∧

b ∈

B }If A = {1, 2, 3}and B = {2, 3}, thenA ×B = {(1, 2), (1, 3), (2, 2), (2, 3), (3, 2), (3, 3)}If A = {x | 2 ≤x ≤3}and B = {x | 1 ≤x ≤2 or 3 ≤x ≤4},then A ×B = {(x , y ) | 2 ≤x ≤3 and 1 ≤y ≤2 or 3 ≤y ≤4}A ×B = B ×A unless A = B or A = ∅or B = ∅

Set: basics Set operations

Relation

DenitionA relation R from a set A to a set B is a set of ordered pairs(a , b ) such that a is some element of a and b is some elementB . In other words, R ⊆A ×B .

Page 221: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 221/298

⊆ ×Let A = {1 , 2, 3}and B = {2 , 3}. R = {(1, 3), (3, 3)}is arelation from A to B .Let A = {1 , 2, 3}and B = {a , b , c }.R =

{(1 , a ), (1 , b ), (1, c )

}is a relation from A to B .

Set: basics Set operations

Cartesian products of more than two sets

DenitionThe Cartesian product of the sets A1 , A2 , . . . ,An , (denoted byA1 ×A2 ×· · ·×An ) is the set of ordered n -tuples(a 1 , a 2 , . . . ,a n ), where a i ∈Ai for i = 1, 2 , . . . ,n . In other words,

Page 222: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 222/298

A1 ×A2 ×·· ·×An = {(a 1 , a 2 , . . . ,a n ) | a i ∈

Ai for i = 1 , 2, . . . ,n }Let A = {0, 1}, B = {1, 2}and C = {0, 1, 2}.

A ×B ×C = {(0, 1, 0), (0, 1, 1), (0, 1, 2), (0, 2, 0), (0, 2, 1), (0, 2, 2),

(1, 1, 0), (1, 1, 1), (1, 1, 2), (1, 2, 0), (1, 2, 1), (1, 2, 2)}

Set: basics Set operations

Venn diagram

Let V = {a , e , i , o , u }be the set of all vowels. A Venn diagramf V i

Page 223: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 223/298

{ }for V is:

Set: basics Set operations

Set union, intersection, difference and complement

Denition

The union of the sets A and B isA∪B = {x | x ∈A∨x ∈B }.The intersection of the sets A and B isA ∩B = {x | x ∈A∧x ∈B }.

Page 224: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 224/298

∩ { | ∈∧ ∈}Two sets A and B are disjoint iff A ∩B = ∅.The difference of the sets A and B isA −B = A \ B = {x | x ∈A∧x /∈B }.A \ B is also called the complement of B with respect to A.

Assuming that we have a universal set S , the complementof a set A is AC = A = S \ A = {x | x /∈A}.

Set: basics Set operations

Venn diagrams of set operations

Page 225: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 225/298

Set: basics Set operations

Set operations: examples

Let A = {1, 3, 5}and B = {1 , 2, 4}A∪B = {1 , 3, 5, 2 , 4}A ∩B = {1}A \ B = {3, 5}

Page 226: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 226/298

\ { }B \ A = {2, 4}A and B are NOT disjoint. But A and {2, 4}are disjoint.If the universal set U = {x ∈N | 1 ≤x ≤10}, thenA = {2, 4, 6 , 7, 8, 9 , 10}

Set: basics Set operations

Set identitiesProofs of them are left as exercises

Identity laws: A∪∅= A and A ∩ U = A for a universal set U

Domination laws: A∪U = U for a universal set U and A ∩∅= ∅Idempotent laws: A∪A = A and A ∩ A = A.

Complementation law: A = A.

Complement laws: A∪A = U for a universal set U , and A ∩ A = ∅

Page 227: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 227/298

Commutative laws: A∪B = B ∪A and A ∩ B = B ∩ A.Associative laws: A∪ (B ∪C ) = ( A∪B ) ∪C andA ∩ (B ∩ C ) = ( A ∩ B ) ∩ C .

Distributive laws: A∪ (B ∩ C ) = ( A∪B ) ∩ (A∪C ) andA ∩ (B ∪C ) = ( A ∩ B ) ∪ (A ∩ C ).

De Morgan’s laws: A∪B = A ∩ B and A ∩ B = A∪B Absorption laws: A∪ (A ∩ B ) = A and A ∩ (A∪B ) = A.

Set: basics Set operations

Generalized unions and intersections

Due to associativity, A∪(B ∪C ) or (A∪B )∪C can bewritten as A

B

C . Similarly, A

∩(B

∩C ) and (A

∩B )

∩C

can be written as A ∩B ∩C .For n ≥3 sets A1 , A2 , . . . ,An , their intersection can bewritten as

n

Page 228: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 228/298

n

i = 1Ai = {Ai , i = 1 , 2, . . . ,n }= A1 ∩A2 ∩. . . ∩An

and their union can be written as

n

i = 1Ai = {Ai , i = 1 , 2, . . . ,n }= A1∪

A2∪. . .∪An

IKI10600I: Discrete Mathematics I

Functions, Sequences and Summations

Adila A. Krisnadhi

Page 229: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 229/298

Faculty of Computer Science, University of Indonesia

Functions Sequences and Summations Cardinality of set: revisited

Functions, Sequences and SummationsOutline

18 Functions

19 Sequences and Summations

Page 230: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 230/298

SequencesSummations

20 Cardinality of set: revisited

Functions Sequences and Summations Cardinality of set: revisited

Function: denitions

DenitionLet A and B be nonempty sets. A function f from A to B (writtenf : A →B ) is an assignment of each element of A to exactly oneelement of B .

Page 231: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 231/298

Functions are also called mappings or transformationsWe write f (a ) = b if a ∈A is assigned to a unique b ∈B A function can also be viewed as a relation from A to B thatcontains one and only one ordered pair (a , b ) for evey

element a ∈

A.

Functions Sequences and Summations Cardinality of set: revisited

Domain, codomain and range

If f is a function from A to B , we say thatA is the domain of f

B is the codomain of f If f (a ) = b , we say thatb is the image of a a is the preimage of b

The range of f is the set of all images of elements of A.

Page 232: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 232/298

The range of f is always a subset of the codomain of f If f is a function from A to B , we say that f maps A to B .Two functions are equal if they have the same domain, thesame codomain and map elements of their common

domain to the same elements in their common codomain.Equality of functions can also be seen as equality of sets(recall the denition of function as relation).

Functions Sequences and Summations Cardinality of set: revisited

More basics on functions

Let f 1 and f 2 be functions from A to R. Then

f 1 + f 2 is a function from A to R dened by(f 1 + f 2)(x ) = f 1(x ) + f 2(x )f 1 f 2 is a function from A to R dened by(f 1 f 2)(x ) = f 1(x )f 2 (x )

Let f be a function from A to B and S ⊆A. The image of S

Page 233: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 233/298

⊆under f is the subset of B that consists of the images ofelements of S , i.e.,

{t | ∃s ∈S (t = f (s ))}Note: we can also use a shorthand for this set:{f (s ) | s ∈S }

Functions Sequences and Summations Cardinality of set: revisited

Increasing and decreasing functions

Let f : A →B be a function.

f is increasing iff∀

x , y ∈

A : x < y →f (x ) ≤ f (y )f is strictly increasing iff∀x , y ∈A : x < y →f (x ) < f (y )f is decreasing iff∀x , y ∈A : x < y →f (x ) ≥ f (y )f is strictly decreasing iff x , y A : x < y f (x ) > f (y )

Page 234: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 234/298

∀ ∈ →LemmaLet f : A →B be a function.

If f is strictly increasing, then f is increasing.

If f is strictly decreasing, then f is decreasing.

Functions Sequences and Summations Cardinality of set: revisited

Surjective, injective and bijective functions

Let f : A

→B be a function.

f is surjective (onto) iff it satises∀

y ∈

B .∃x ∈

A : f (x ) = y f is injective (one-to-one) iff it satises

∀x 1∀x 2(f (x 1) = f (x 2 ) →x 1 = x 2)f is bijective (one-to-one correspondence) iff f is both

Page 235: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 235/298

surjective and injective.

TheoremLet f : A →B be a function. If f is either strictly increasing or strictly decreasing, then f is a one-to-one function.

Functions Sequences and Summations Cardinality of set: revisited

Examples

Let f be a function from {a , b , c , d }to {1 , 2, 3, 4 , 5}withf (a ) = 4, f (b ) = 5, f (c ) = 1 and f (d ) = 3. Then f is

one-to-one, but not onto.Let f : Z →Z be a function such that f (x ) = x 2 . Then

f is not one-to-one, because e.g., f (1) = f (−1) = 1, but1 = −1;f is not onto, because there is no x Z such that f (x ) = 1

Page 236: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 236/298

∈ −f is not increasing and not decreasing. Why?Let f : Z →Z be a function such that f (x ) = x + 1. Then

f is one-to-one, because for every x 1 , x 2∈Z,x 1 + 1 = x 2 + 1 implies x 1 = x 2 .f is onto, because for every y

Z, there is an x

Z suchthat f (x ) = y by taking x = y −1.f is bijective. Why?f is strictly increasing. Why?

Functions Sequences and Summations Cardinality of set: revisited

Inverse function

DenitionLet f : A →B be a bijective function. The inverse function of f isthe function f − 1 : B →A dened such that if f (x ) = y thenf − 1(y ) = x .

− 1

Page 237: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 237/298

Do not confuse f with the function 1 / f . They are NOTthe same.Inverse function of f only exists (is well-dened) if f isbijective. Why?If f is bijective, then f has an inverse function, i.e., f isinvertible.

Functions Sequences and Summations Cardinality of set: revisited

Examples

Let f be the function from

{a , b , c

}to

{1, 2 , 3

}such that

f (a ) = 2, f (b ) = 3 and f (c ) = 1. Then f is invertible (why?)and the inverse of f is the function f − 1 from {1, 2, 3}to

{a , b , c }such that f − 1(1) = c , f − 1(2) = a , and f − 1(3) = b .Let f : Z →Z be such that f (x ) = x + 1. Then f is invertible(why?) and its inverse is the function f− 1 : such that

Page 238: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 238/298

(why?) and its inverse is the function f :Z →Z

such thatf − 1 (x ) = x −1.Let f : R →R be such that f (x ) = x 2 . Is f invertible? If it is,what is its inverse?Let f : R+

∪{0

} →R+

∪{0

}be such that f (x ) = x 2 . Is f

invertible? If it is, what is its inverse?

Functions Sequences and Summations Cardinality of set: revisited

Function composition

DenitionLet f : B →C and g : A →B be functions. The composition of f and g is the function f ◦g : A →C dened as

(f ◦g )(x ) = f (g (x ))

Page 239: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 239/298

To nd (f ◦g )(a ), we rst apply g to a obtaining g (a ) andthen we apply f to g (a ) to obtain (f ◦g )(a ).For the function f ◦g to be well-dened, the range of g must be a subset of the domain of f . Why?

Functions Sequences and Summations Cardinality of set: revisited

Examples

Let g be the function from {a , b , c }to itself such thatg (a ) = b , g (b ) = c and g (c ) = a . Let f be the functionfrom {a , b , c }to {1 , 2, 3}such that f (a ) = 3, f (b ) = 2 andf (c ) = 1. Then

(f ◦g ) is the function from {a , b , c }to {1, 2, 3}such thatf g a f g a 2, f g b f g b 1 and

Page 240: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 240/298

(f

◦g

)(a

) =f (g

(a

)) =2,

(f

◦g

)(b

) =f (g

(b

)) =1 and

(f ◦g )(c ) = f (g (c )) = 3Is g ◦ f well-dened? If it is, give the denition of g ◦ f .

Let f , g : Z →Z be functions such that f (x ) = 2x + 3 andg (x ) = 3x + 2. What is f ◦g ? What is g ◦ f ?

Functions Sequences and Summations Cardinality of set: revisited

Some theorems on composition and inverse

f ◦g does not equal g ◦ f in general.For a function f : A →B , if f − 1 exists, then

f ◦ f − 1 = id A where id : A →A is the identity function on A,i.e., id (x ) = x ;

− 1

Page 241: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 241/298

f ◦ f = id B where id : B →B is the identity function on A,i.e., id (x ) = x ;If A = B , then f ◦ f − 1 = f − 1 ◦ f = id A(f − 1 )− 1 = f .

Functions Sequences and Summations Cardinality of set: revisited

Sequences

Sequences

Denition (Informal denition)

A sequence is an ordered list of terms.

Denition (Formal denition)A sequence is a function from a subset of the set of integers

Page 242: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 242/298

(typically the set {0 , 1, 2, . . .}or {1, 2 , 3, . . .}) to a set S .

We use the notation {a n }to denote a sequence (DO NOTconfuse it with sets) where we can either describe the formof a n and/or list the terms of the sequence in order ofincreasing subscripts.

Functions Sequences and Summations Cardinality of set: revisited

Sequences

Examples

The sequence {a n }where a n = 1/ n for n = 1 , 2, . . . is the

sequence 1 ,12 ,

13 ,

14 , . . . .A geometric progression is the sequence of the form

a , ar , ar 2 , . . . ,ar n , . . . with the initial term a and the ratio r are real numbers. For example:

1, 2, 4, 8, . . . .1 1 1

Page 243: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 243/298

1, 2 , 4 , 8 , . . . .1, −1, 1, −1, 1, . . . .An arithmetic progression is the sequence of the forma , a + d , a + 2d , . . . ,a + nd , . . . where the initial term a andthe common difference r are real numbers. For example:

−1, 3, 7, 11 , . . . .7, 4, 1, −2, . . . .

Functions Sequences and Summations Cardinality of set: revisited

Sequences

Deducing formula for terms of a sequence

When you want to deduce a formula for the terms of asequence, try to answer the following questions:

Are there runs of the same value? I.e., does the samevalue occur many times in a row?Are terms obtained from previous terms by adding thesame amount or an amount that depends on the position in

Page 244: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 244/298

the sequence?Are terms obtained from previous terms by multiplying by aparticular amount?Are terms obtained by combining previous terms in a

certain way?Are there cycles among the terms?

Functions Sequences and Summations Cardinality of set: revisited

Sequences

Examples

Find the formulae for the sequences:1, 1/ 2, 1/ 4, 1/ 8, . . . .1, 3, 5, 7, 9, . . . .1, −1, 1, −1, . . . .

Continue the following sequence with appropriate terms:

Page 245: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 245/298

1, 2, 2, 3, 3, 3, 4, 4, 4, 4, . . . .5, 11 , 17 , 23 , 29 , 35 , 41 , 47 , 53 , 59 , . . . .

Guess a simple formula for a n if the rst 10 terms of thesequence {a n }are1, 7, 25 , 79 , 241 , 727 , 2185 , 6559 , 19681 , 59047.

Functions Sequences and Summations Cardinality of set: revisited

Summations

Summation

We are usually interested in summing a given sequence.Here, we use the summation notation, namely the sigma

notation .Given the terms a m , a m + 1 , . . . ,a n from the sequence {a n },we use the notation

n n n

Page 246: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 246/298

j = m a j , j = m a j , or m ≤ j ≤ n a j

to represent a m + a m + 1 + · · ·+ a n

In the notation, j is the index of summation , and we could

also use any other letter such as i or k .Also, m is the lower limit and n is the upper limit of thesummation.

Functions Sequences and Summations Cardinality of set: revisited

Summations

Example

The sum of the rst 100 terms of the sequences {a n }where a n = 1/ n for n = 1, 2, 3 , . . . is

100 j = 1

1 j .

Calculate 5 j = 1 j 2 .

Calculate 8k = 4 (−1)k .

Index of summation can be shifted, e.g.,5 2 4 (k )2

Page 247: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 247/298

5 j = 1 j 2 = 4k = 0(k + 1)2

Prove this result: if a and r ar real numbers, and r = 0,then

n

j = 0

ar j =ar n + 1 − a

r − 1 if r = 1

(n + 1)a if r = 1

Functions Sequences and Summations Cardinality of set: revisited

Summations

Nested summations and summations over set

Summations can be nested. E.g.:

4

i = 1

3

j = 1

ij =4

i = 1

(i + 2i + 3i )

=4

i=

1

6i

Page 248: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 248/298

i 1= 6 + 12 + 18 + 24 = 60

Functions Sequences and Summations Cardinality of set: revisited

Summations

Nested summations and summations over set

Summations can be nested. E.g.:

4

i = 1

3

j = 1

ij =4

i = 1

(i + 2i + 3i )

=4

i=

1

6i

Page 249: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 249/298

i 1= 6 + 12 + 18 + 24 = 60

Given a set S , we can sum the values f (s ) for all members ofS . E.g.:

s ∈{0 , 2 , 4}s

2= 0

2+ 2

2+ 4

2= 20

Functions Sequences and Summations Cardinality of set: revisited

Summations

Some useful summations

Provided r = 0:n

k = 0

ar k =ar n + 1 − a

r − 1 if r = 1(n + 1)a if r = 1

n

k = 0

(a + kd ) = ( n + 1)a +dn (n + 1)

2n

k ( + 1)

Page 250: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 250/298

k = 1

k = n (n + 1)2

n

k = 1

k 2 =n (n + 1)(2n + 1)

6

n

k = 1

k 3 = n 2 (n + 1)2

4

Functions Sequences and Summations Cardinality of set: revisited

Cardinality of set: revisited

Recall that, cardinality of a set is dened as the number ofelements in the set.Two nite sets A and B are of the same cardinality if thenumber of elements in A is the same as the number of

elements in B ( hich can be co nted)

Page 251: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 251/298

elements in B (which can be counted).What if the set is innite? Can we extend the notion ofcardinality to innite sets?

Functions Sequences and Summations Cardinality of set: revisited

Cardinality of a set: alternative denition

DenitionThe sets A and B have the same cardinality iff there existsa bijection from A to B .A set is countable iff it is either nite or has the same

cardinality with the set of positive integers ( Z+

)

Page 252: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 252/298

cardinality with the set of positive integers ( Z ).A set is uncountable iff it is not countable.When an innite set S is countable, we denote thecardinality of S (i.e., |S |) byℵ0 (read as “aleph null”)

Functions Sequences and Summations Cardinality of set: revisited

Examples

Is the set of odd positive integers is countable? Explain.Is the set {−5 , −4 , . . . ,9, 10}countable? Explain.Is the set of all integers ( Z) is countable? Explain.

Is the set of positive rational numbers is countable?

Page 253: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 253/298

Is the set of positive rational numbers is countable?Explain.Is the set of real numbers is countable? Explain.

Functions Sequences and Summations Cardinality of set: revisited

More examples

Is a subset of a countable set also countable?Suppose A and B are sets, A is uncountable, and A⊆B . IsB countable or uncountable? Prove it.

Suppose A is an uncountable set and B is a countable set

Page 254: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 254/298

Suppose A is an uncountable set and B is a countable set.Is A \ B countable or uncountable? Prove it.

IKI10600I: Discrete Mathematics IIntegers

Adila A. Krisnadhi

Faculty of Computer Science, University of Indonesia

Page 255: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 255/298

Page 256: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 256/298

The Integers Division Primes and Greatest Common Divisor

Division

Division

From your previous experiences, you should already knowsome properties of integers: on addition, multiplication, etc.We are going to look at an operation on integers in moredetails, namely the division .When an integer is divided by another, nonzero integer, theresult (i e quotient) may or may not be an integer E g

Page 257: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 257/298

result (i.e., quotient) may or may not be an integer. E.g.,12/4 = 3, whereas 11/4 = 2.75. So, if we require thedivision operation on integers always to give an integer, weneed the following denition

The Integers Division Primes and Greatest Common Divisor

Division

Division

DenitionLet a and b be integers with a = 0.

Then we say, a divides b (written as a | b ) if there is aninteger c such that b = ac .If a | b we say that a is a factor of b and b is a multiple of a

Page 258: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 258/298

If a | b , we say that a is a factor of b and b is a multiple of a .If a does NOT divide b , we write a b .

The Integers Division Primes and Greatest Common Divisor

Division

Division: some results

TheoremLet a, b and c are integers. Then

if (a | b ) and a | c, then a | (b + c )if a | b, then a | bc, for all integers c if a | b and b | c, then a | c.

For (1) only the rest are for exercise

Page 259: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 259/298

For (1) only, the rest are for exercise.Suppose a | b and a | c . Then, by denition of division, thereare integers s and t such that b = as and c = at . Hence,

b + c = as + at = a (s + t )

Therefore, a divides b + c , i.e., a | (b + c ).

The Integers Division Primes and Greatest Common Divisor

Division

Division: some results

TheoremIf a,b and c are integers such that a | b and a | c, then a | mb + nc for every integers m and n.

Proof.

Page 260: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 260/298

Proof.Left as exercise. (Hint: use the rst part of the previoustheorem).

The Integers Division Primes and Greatest Common Divisor

The Division Algorithm

The division algorithm

TheoremLet a be an integer and d a positive integer. Then there are

unique integers q and r, with 0 ≤ r < d such that a = dq + r .

The proof of this theorem uses the so-called well-orderingproperty of nonnegative integers (optional part of thiscourse).In the above theorem d is called the divisor a is called the

Page 261: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 261/298

In the above theorem, d is called the divisor , a is called thedividend , q is called the quotient, and r is called theremainder .The notation used to express the quotient and remainder:

q = a div d , r = a mod d

The Integers Division Primes and Greatest Common Divisor

The Division Algorithm

Example

What are the quotient and remainder when 101 is dividedby 11?What are the quotient and remainder when -11 is dividedby 3.

Page 262: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 262/298

The Integers Division Primes and Greatest Common Divisor

The Division Algorithm

Example

What are the quotient and remainder when 101 is divided

by 11?What are the quotient and remainder when -11 is dividedby 3.By the previous denition, remainder cannot be negative.

Page 263: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 263/298

The Integers Division Primes and Greatest Common Divisor

The Division Algorithm

Example

What are the quotient and remainder when 101 is divided

by 11?What are the quotient and remainder when -11 is dividedby 3.By the previous denition, remainder cannot be negative.

Theorem

Page 264: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 264/298

TheoremAn integer a is divisible (i.e., can be divided) by an integer d if and only if

a mod d = 0

The Integers Division Primes and Greatest Common Divisor

Modular Arithmetic

Modular arithmetic

DenitionLet a and b be integers, and m a positive integer. Then a iscongruent to b modulo m — written as a ≡b ( mod m ) iff

m | a −b

If a and b are not congruent modulo m , we write

a ≡b ( mod m )

Page 265: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 265/298

≡ ( )

The Integers Division Primes and Greatest Common Divisor

Modular Arithmetic

Modular arithmetic

DenitionLet a and b be integers, and m a positive integer. Then a is

congruent to b modulo m — written as a ≡b ( mod m ) iff

m | a −b

If a and b are not congruent modulo m , we write

a ≡b ( mod m )

Page 266: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 266/298

≡TheoremLet a and b be integers and m a positive integer. Then

a ≡b ( mod m ) iff a mod m = b mod m

Proof of this theorem is left as an exercise.

The Integers Division Primes and Greatest Common Divisor

Modular Arithmetic

Example

Determine whether 17 is congruent to 5 modulo 6.Determine whether 24 and 14 are congruent modulo 6.

Page 267: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 267/298

The Integers Division Primes and Greatest Common Divisor

Modular Arithmetic

Modular arithmetic and ordinary arithmetic

TheoremLet m be a positive integer. The integers a and b are congruent

modulo m iff there is an integer k such that a = b + km

Page 268: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 268/298

The Integers Division Primes and Greatest Common Divisor

Modular Arithmetic

Modular arithmetic and ordinary arithmetic

TheoremLet m be a positive integer. The integers a and b are congruent

modulo m iff there is an integer k such that a = b + km

Proof.

If a ≡b ( mod m ), then m | (a −b ). Hence, there is an integerk such that a −b = km . This means a = b + km .

Page 269: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 269/298

|Conversely, if there is an integer k such that a = b + km , thenkm = a −b . This implies that m divides a −b , which meansthat a ≡b ( mod m ).

Note: the set of all integers congruent to an integer a modulo m is called the congruence class of a modulo m .

The Integers Division Primes and Greatest Common Divisor

Modular Arithmetic

Addition and multiplication with congruencesTheorem (Addition and multiplication with congruences)Let m be a positive integer. If a ≡b ( mod m ) and c

≡d

( modm

), then

a + c ≡b + d ( mod m ) and ac ≡bd ( mod m )

Page 270: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 270/298

The Integers Division Primes and Greatest Common Divisor

Modular Arithmetic

Addition and multiplication with congruencesTheorem (Addition and multiplication with congruences)Let m be a positive integer. If a ≡b ( mod m ) and c

≡d

(mod m

), then

a + c ≡b + d ( mod m ) and ac ≡bd ( mod m )

Proof.Because a

≡b ( mod m ) and c

≡d ( mod m ), there are

integers s and t such that b = a + sm , and d = c + tm . Hence,b d ( ) ( ) ( ) ( )

Page 271: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 271/298

b + d = ( a + sm ) + ( c + tm ) = ( a + c ) + ( s + t )m bd = ( a + sm )(c + tm )

= ac + atm + csm + stm 2 = ac + m (at + cs + stm )Hence,

a + c ≡b + d ( mod m ) and ac ≡bd ( mod m )

The Integers Division Primes and Greatest Common Divisor

Modular Arithmetic

Addition and multiplication with congruencesCorollaryLet m be a positive integers and let a and b be integers. Then

(a + b ) mod m = (( a mod m ) + ( b mod m )) mod m

and ab mod m = (( a mod m )(b mod m )) mod m

For the proof, read Rosen’s book page 205.

Page 272: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 272/298

For the proof, read Rosen s book page 205.Note: although the we can do addition and multiplicationwith congruences, some properties are NOT valid:

if ac ≡bc ( mod m ), the congruence a ≡b ( mod m ) may

be FALSE.if a ≡b ( mod m ) and c ≡d ( mod m ), the congruencea c ≡b d ( mod m ) may be FALSE.

The Integers Division Primes and Greatest Common Divisor

Modular Arithmetic

Applications of Congruences

Read Rosen’s book page 205 – 208 for more details.Hashing functions: storing records in memory so thatretrieval can be done quickly.Pseudorandom numbers: random numbers generated by

computers.Cryptology: encryption and decryption of messages e g

Page 273: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 273/298

Cryptology: encryption and decryption of messages, e.g.with Caesar cipher, shift cipher, etc.

The Integers Division Primes and Greatest Common Divisor

Primes

Primes

DenitionA positive integer p > 1 is called prime if the only positivefactor of p are 1 and p . A pA positive integer that is greater than 1 and is not prime iscalled composite

Remark: an integer n is composite iff there exists an

Page 274: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 274/298

Remark: an integer n is composite iff there exists aninteger a such that a | n and 1 < a < n .List all primes less than 100

The Integers Division Primes and Greatest Common Divisor

Primes

Fundamental theorem of arithmetic

Theorem (Fundamental theorem of arithmetic)Every positive integer greater than 1 can be written uniquely as a prime or the product of two or more primes where the prime factors are written in order of nondecreasing size.

Page 275: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 275/298

The Integers Division Primes and Greatest Common Divisor

Primes

Fundamental theorem of arithmetic

Theorem (Fundamental theorem of arithmetic)Every positive integer greater than 1 can be written uniquely as a prime or the product of two or more primes where the prime factors are written in order of nondecreasing size.

The prime factorization of 100, 641, 999, 1024 are:

Page 276: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 276/298

The Integers Division Primes and Greatest Common Divisor

Primes

Fundamental theorem of arithmetic

Theorem (Fundamental theorem of arithmetic)Every positive integer greater than 1 can be written uniquely as a prime or the product of two or more primes where the prime factors are written in order of nondecreasing size.

The prime factorization of 100, 641, 999, 1024 are:100 = 2 ·2 ·5 ·5 = 2252 .

Page 277: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 277/298

The Integers Division Primes and Greatest Common Divisor

Primes

Fundamental theorem of arithmetic

Theorem (Fundamental theorem of arithmetic)Every positive integer greater than 1 can be written uniquely as a prime or the product of two or more primes where the prime factors are written in order of nondecreasing size.

The prime factorization of 100, 641, 999, 1024 are:100 = 2 ·2 ·5 ·5 = 2252 .

Page 278: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 278/298

641 = 641

The Integers Division Primes and Greatest Common Divisor

Primes

Fundamental theorem of arithmetic

Theorem (Fundamental theorem of arithmetic)

Every positive integer greater than 1 can be written uniquely as a prime or the product of two or more primes where the prime factors are written in order of nondecreasing size.

The prime factorization of 100, 641, 999, 1024 are:100 = 2 ·2 ·5 ·5 = 2252 .

Page 279: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 279/298

641 = 641999 = 3 ·3 ·3 ·37 = 33 ·37

The Integers Division Primes and Greatest Common Divisor

Primes

Fundamental theorem of arithmetic

Theorem (Fundamental theorem of arithmetic)

Every positive integer greater than 1 can be written uniquely as a prime or the product of two or more primes where the prime factors are written in order of nondecreasing size.

The prime factorization of 100, 641, 999, 1024 are:100 = 2 ·2 ·5 ·5 = 2252 .

Page 280: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 280/298

641 = 641999 = 3 ·3 ·3 ·37 = 33 ·371024 = 2

·2

·2

·2

·2

·2

·2

·2

·2

·2 = 210

The Integers Division Primes and Greatest Common Divisor

Primes

Prime divisor of a composite integer

TheoremIf n is a composite integer, then n has a prime divisor less than or equal √n

Page 281: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 281/298

The Integers Division Primes and Greatest Common Divisor

Primes

Prime divisor of a composite integer

TheoremIf n is a composite integer, then n has a prime divisor less than or equal √n

Proof: look at Rosen’s book page 211.Show that 101 is prime.

Page 282: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 282/298

Find the prime factorization of 7007.

The Integers Division Primes and Greatest Common Divisor

Primes

Innitude of primes

TheoremThere are innitely many primes.

Proof: Rosen’s book page 212.Mersenne primes: a prime that has a special form 2 p −1where p is also a prime

Page 283: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 283/298

where p is also a prime.

The Integers Division Primes and Greatest Common Divisor

Primes

Distribution of primes

Theorem (The prime number theorem)The ratio of number of primes not exceeding x and x / ln x approaches 1 as x grows without bound, where ln x is the

natural logarithm of x.

Page 284: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 284/298

The Integers Division Primes and Greatest Common Divisor

Greatest Common Divisor and Least Common Multiples

Greatest common divisor

DenitionLet a and b be integers, not both zero. The largest integer d such that d | a and d | b is called the greatest common divisorof a and b (written as gcd (a , b )).

What is gcd (24 , 36 )?

Page 285: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 285/298

What is gcd (17 , 22 )?

The Integers Division Primes and Greatest Common Divisor

Greatest Common Divisor and Least Common Multiples

Relatively primes

DenitionThe integers a and b are relatively prime if gcd(a , b ) = 1.

Page 286: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 286/298

The Integers Division Primes and Greatest Common Divisor

Greatest Common Divisor and Least Common Multiples

Relatively primes

DenitionThe integers a and b are relatively prime if gcd(a , b ) = 1.

DenitionThe integers a 1 , a 2 , . . . ,a n are pairwise relatively prime ifgcd (a i , a j ) = 1 for every 1

≤i < j

≤n .

Determine whether 10, 17 and 21 are pairwise relatively

Page 287: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 287/298

Determine whether 10, 17 and 21 are pairwise relativelyprime.Determine whether 10, 19 and 24 are pairwise relatively

prime.

The Integers Division Primes and Greatest Common Divisor

Greatest Common Divisor and Least Common Multiples

Least common multiple

Denition

The least common multiple of positive integers a and b (writtenlcm (a , b )) is the smallest positive integer that is divisible by botha and b .

What is lcm (233572 , 2433)?

Theorem

Page 288: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 288/298

Let a and b be positive integers. Then

ab = gcd (a , b )

·lcm (a , b )

IKI10600I: Discrete Mathematics IIntegers and Algorithms

Adila A. Krisnadhi

Faculty of Computer Science, University of Indonesia

Page 289: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 289/298

Representation of Integers Euclidean Algorithm

Integers and AlgorithmsOutline

23 Representation of Integers

24 Euclidean Algorithm

Page 290: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 290/298

Representation of Integers Euclidean Algorithm

Theorem (Base b expansion of n )Let b be a positive integer greater than 1. Then if n is a positive integer, it can be expressed uniquely in the form

n = a k b k + a k − 1b k − 1 + · · ·+ a 1b + a 0

The base b expansion of n is denoted by (a k a k − 1 . . . a 1a 0)b , e.g.,(245 )8 represents 2 ·82 + 4 ·8 + 5 = 165.

The base 10 expansion of integers is called decimal expansion.

The base 2 expansion of integers is called binary expansion.The base 8 expansion of integers is called octal expansion.

Page 291: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 291/298

The base 16 expansion of integers is called hexadecimalexpansion (using 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E, and F as digits

where A through F correspond to numbers 10 through 15 indecimal).

Representation of Integers Euclidean Algorithm

Base b expansion to decimal expansion

(101011111 )2 = 1 ·28 + 0 ·27 + 1 ·26 + 0 ·25 + 1 ·24

+ 1 ·23 + 1 ·22 + 1 ·21 + + 1 ·20 = ( 351 )10

(2AE 0B )16 = 2·16 4+ 10 ·16 3+ 14 ·16 2+ 0·16 + 11 = ( 175627 )10

Page 292: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 292/298

(3071 )8 = 3 · 83 + 0 · 82 + 7 · 8 + 1 = ( 1593 )10

Representation of Integers Euclidean Algorithm

Decimal expansion to base b expansion

Find octal expansion of 12345

Page 293: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 293/298

Representation of Integers Euclidean Algorithm

Decimal expansion to base b expansion

Find octal expansion of 12345Take the remainders of the following divisions:

12345 = 8 ·1543 + 11543 = 8 ·192 + 7

192 = 8 ·24 + 024

=8

·3

+0

3 = 8 ·0 + 3

Page 294: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 294/298

Hence, (12345 )10 = ( 30071 )8

Find hexadecimal expansion of (177130 )10 .Find binary expansion of (241 )10 .

Page 295: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 295/298

Representation of Integers Euclidean Algorithm

Finding GCD with Euclidean algorithm

Find gcd (91 , 287 ).

287 = 91 ·3 + 1491 = 14 ·6 + 7

14 = 7 ·2 + 0

Hence gcd (91 287 ) = 7

Page 296: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 296/298

Hence, gcd (91 , 287 ) = 7

Representation of Integers Euclidean Algorithm

Euclidean algorithm

procedure : gcd ( a , b : p o s i t i v e i n t e g e r s )x := a y := b wh i l e y = 0begin

r := x mod y x := y y := r

Page 297: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 297/298

end { gcd (a , b ) i s x }

Representation of Integers Euclidean Algorithm

Euclidean algorithm: Why it works?

TheoremLet a = bq + r, where a , b , q, and r are integers. Then gcd (a , b ) = gcd (b , r ).

For example, in the previous slide, it holds that:gcd (91 , 287 ) = gcd (91 , 14 ) = gcd (14 , 7) = gcd (7 , 0) = 7.

Page 298: All Lectures Adila

8/4/2019 All Lectures Adila

http://slidepdf.com/reader/full/all-lectures-adila 298/298