cs 207m: discrete structures (minor) - iit bombay

41
CS 207m: Discrete Structures (Minor) Instructor : S. Akshay Jan 05, 2018 Lecture 01 { Introduction 1

Upload: others

Post on 11-May-2022

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 207m: Discrete Structures (Minor) - IIT Bombay

CS 207m: Discrete Structures (Minor)

Instructor : S. Akshay

Jan 05, 2018

Lecture 01 – Introduction

1

Page 2: CS 207m: Discrete Structures (Minor) - IIT Bombay

Logistics

Course hours: Slot 5;Wed 09:30-11:00, Fri 09:30-11:00

Office hours: By prior appointment

Evaluation

I Quizzes: 30%

I Midsem: 25%

I Endsem: 40%

I Other (pop quizzes, participation, assignments): 5%

Course material, references will be posted at

I http://www.cse.iitb.ac.in/~akshayss/teaching.html

I piazza (will be set up by TAs soon)

2

Page 3: CS 207m: Discrete Structures (Minor) - IIT Bombay

Logistics

Course hours: Slot 5;Wed 09:30-11:00, Fri 09:30-11:00

Office hours: By prior appointment

Evaluation

I Quizzes: 30%

I Midsem: 25%

I Endsem: 40%

I Other (pop quizzes, participation, assignments): 5%

Course material, references will be posted at

I http://www.cse.iitb.ac.in/~akshayss/teaching.html

I piazza (will be set up by TAs soon)

2

Page 4: CS 207m: Discrete Structures (Minor) - IIT Bombay

Goal

First things first...

I What are discrete structures?

I Why are we interested in them?

3

Page 5: CS 207m: Discrete Structures (Minor) - IIT Bombay

Course Outline

What we will broadly cover in this course

1. Mathematical reasoning: proofs and structures

2. Counting and combinatorics

3. Elements of graph theory

4. Introduction to abstract algebra & number theory

What we don’t cover

1. Discrete probability

2. Algorithms

3. Logic and Finite automata

4. Details and applications of everything above – rest of your(minor) life!

4

Page 6: CS 207m: Discrete Structures (Minor) - IIT Bombay

Course Outline

What we will broadly cover in this course

1. Mathematical reasoning: proofs and structures

2. Counting and combinatorics

3. Elements of graph theory

4. Introduction to abstract algebra & number theory

What we don’t cover

1. Discrete probability

2. Algorithms

3. Logic and Finite automata

4. Details and applications of everything above – rest of your(minor) life!

4

Page 7: CS 207m: Discrete Structures (Minor) - IIT Bombay

Course Outline

What we will cover in this course

1. Mathematical reasoning: proofs and structures

2. Counting and combinatorics

3. Elements of graph theory

4. Introduction to abstract algebra and number theory

Textbooks

I Discrete Mathematics and its Applications withCombinatorics and Graph Theory, by Kenneth H Rosen.

I Discrete Mathematics by Norman Biggs.

I Introduction to Graph theory by Douglas B West.

I More will be listed on webpage as we go along.

5

Page 8: CS 207m: Discrete Structures (Minor) - IIT Bombay

More lofty aims of the course

1. Introduce mathematical background needed in variousbranches of computer science (and in other sciences!)

2. (New and old) techniques for problem solving: how toattack problems that you have never seen before.

3. To write proofs and convey your ideas formally.

4. To develop skills to read/understand/solve new material inthe future.

6

Page 9: CS 207m: Discrete Structures (Minor) - IIT Bombay

Chapter 1: Proofs and Structures

Outline of next few classes

I Propositions, statements

I What/why of proofs and some generic proof strategies

I Mathematical induction

I Notions and properties of sets, functions, relations

7

Page 10: CS 207m: Discrete Structures (Minor) - IIT Bombay

Propositions

What is a proposition?

I It is raining

I 1 + 1 = 2

I every odd number is a prime

I 267 − 1 is a prime

I (n + 1)(n− 1) = (n2 − 1) for any integer n

8

Page 11: CS 207m: Discrete Structures (Minor) - IIT Bombay

Propositions

What is a proposition?

I It is raining

I 1 + 1 = 2

I every odd number is a prime

I 267 − 1 is a prime

I (n + 1)(n− 1) = (n2 − 1) for any integer n

What is common between these statements?

8

Page 12: CS 207m: Discrete Structures (Minor) - IIT Bombay

Propositions

What is a proposition?

I It is raining

I 1 + 1 = 2

I every odd number is a prime

I 267 − 1 is a prime

I (n + 1)(n− 1) = (n2 − 1) for any integer n

A proposition is a statement that is either true or false (butnot both).

8

Page 13: CS 207m: Discrete Structures (Minor) - IIT Bombay

Propositions

What is a proposition?

I It is raining

I 1 + 1 = 2

I every odd number is a prime

I 267 − 1 is a prime

I (n + 1)(n− 1) = (n2 − 1) for any integer n

A proposition is a statement that is either true or false (butnot both).

Give an example of a statement that is not a proposition.

8

Page 14: CS 207m: Discrete Structures (Minor) - IIT Bombay

Propositions

What is a proposition?

I It is raining

I 1 + 1 = 2

I every odd number is a prime

I 267 − 1 is a prime

I (n + 1)(n− 1) = (n2 − 1) for any integer n

A proposition is a statement that is either true or false (butnot both).

Give an example of a statement that is not a proposition.

I x + 1 = 8

8

Page 15: CS 207m: Discrete Structures (Minor) - IIT Bombay

Propositional calculus

Figure: Aristotle (384 – 322 BCE)

I propositions are statements that are either true or false.

I Just as we use variables x, y, . . . for numbers, we will usevariables p, q, . . . for propositions.

I “if it is raining, it will be wet” : p→ q

9

Page 16: CS 207m: Discrete Structures (Minor) - IIT Bombay

Propositional calculus

Combining propositions

If p, q are propositions, then so are:

I ¬p - not every prime number is odd

I p ∨ q - either it is raining or it will be wet

I p ∧ q - it is raining and it is wet

I p→ q

I p iff q

Can all mathematical statements be written this way?

10

Page 17: CS 207m: Discrete Structures (Minor) - IIT Bombay

Propositional calculus

Combining propositions

If p, q are propositions, then so are:

I ¬p - not every prime number is odd

I p ∨ q - either it is raining or it will be wet

I p ∧ q - it is raining and it is wet

I p→ q

I p iff q

Can all mathematical statements be written this way?

10

Page 18: CS 207m: Discrete Structures (Minor) - IIT Bombay

Propositional calculus

Combining propositions

If p, q are propositions, then so are:

I ¬p - not every prime number is odd

I p ∨ q - either it is raining or it will be wet

I p ∧ q - it is raining and it is wet

I p→ q

I p iff q

Can all mathematical statements be written this way?

10

Page 19: CS 207m: Discrete Structures (Minor) - IIT Bombay

Propositional calculus

Combining propositions

If p, q are propositions, then so are:

I ¬p - not every prime number is odd

I p ∨ q - either it is raining or it will be wet

I p ∧ q - it is raining and it is wet

I p→ q

I p iff q

Can all mathematical statements be written this way?

10

Page 20: CS 207m: Discrete Structures (Minor) - IIT Bombay

Propositional calculus

Combining propositions

If p, q are propositions, then so are:

I ¬p - not every prime number is odd

I p ∨ q - either it is raining or it will be wet

I p ∧ q - it is raining and it is wet

I p→ q

I p iff q

Can all mathematical statements be written this way?

10

Page 21: CS 207m: Discrete Structures (Minor) - IIT Bombay

Predicates and quantifiers

Consider again...

I ∀n

∈ N

(n + 1)(n− 1) = (n2 − 1)

I ∀x, ∃y,

x, y ∈ Z

x = y + 8

I ∀n stands for all values of n in a given domain

I ∃n stands for exists n

I ∈ is the “element of” symbol

I N stands for all natural numbers

I Z stands for all integers

I R, Q, ...

Some propositions are not so easy to “determine”...– e.g., 267 − 1 is not a prime.

11

Page 22: CS 207m: Discrete Structures (Minor) - IIT Bombay

Predicates and quantifiers

Consider again...

I ∀n

∈ N

(n + 1)(n− 1) = (n2 − 1)

I ∀x, ∃y,

x, y ∈ Z

x = y + 8

I ∀n stands for all values of n in a given domain

I ∃n stands for exists n

I ∈ is the “element of” symbol

I N stands for all natural numbers

I Z stands for all integers

I R, Q, ...

Some propositions are not so easy to “determine”...– e.g., 267 − 1 is not a prime.

11

Page 23: CS 207m: Discrete Structures (Minor) - IIT Bombay

Predicates and quantifiers

Consider again...

I ∀n ∈ N (n + 1)(n− 1) = (n2 − 1)

I ∀x, ∃y, x, y ∈ Z x = y + 8

I ∀n stands for all values of n in a given domain

I ∃n stands for exists n

I ∈ is the “element of” symbol

I N stands for all natural numbers

I Z stands for all integers

I R, Q, ...

Some propositions are not so easy to “determine”...– e.g., 267 − 1 is not a prime.

11

Page 24: CS 207m: Discrete Structures (Minor) - IIT Bombay

Theorems and proofs

A theorem is a proposition which can be shown true

Classwork: Prove the following theorems.

1. If m and n are perfect squares of integers, then mn is alsoa perfect square.

2. If 6 is prime, then 62 = 30.

3. Let x be an integer. Then, x is even iff x + x2 − x3 is even.

4. There are infinitely many prime numbers.

5. There exist irrational numbers x, y such that xy is rational.

6. For all n ∈ N, n! ≤ nn.

7. There does not exist a (input-free) C-program which willalways determine whether an arbitrary (input-free)C-program will halt.

12

Page 25: CS 207m: Discrete Structures (Minor) - IIT Bombay

Theorems and proofs

Contrapositive and converse

I The contrapositive of “if A then B” is “if ¬B then ¬A”.

I A statement is logically equivalent to its contrapositive,i.e., it suffices to show one to imply the other.

I To show A iff B, you have to show A implies B andconversely, B implies A.

I Note the difference between contrapositive and converse.

13

Page 26: CS 207m: Discrete Structures (Minor) - IIT Bombay

Proof by contradiction

Theorem 4.: There are infinitely many primes.

Proof by contradiction:

I Suppose there are only finitely many primes, sayp1 < p2 < . . . < pr.

I Let k = (p1 ∗ p2 ∗ . . . ∗ pr) + 1. Then k when divided by anypi has remainder 1. So pi 6 | k for all i ∈ {1, . . . , r}.

I But k > 1 and k is not prime, so k can be written as aproduct of primes (why?)

I Fundamental theorem of arithmetic: any natural number> 1 can be written as a unique product of primes.

I Now let p|k. But p 6∈ {p1, . . . , pr}, so this is a contradiction.

14

Page 27: CS 207m: Discrete Structures (Minor) - IIT Bombay

Proof by contradiction

Theorem 4.: There are infinitely many primes.

Proof by contradiction:

I Suppose there are only finitely many primes, sayp1 < p2 < . . . < pr.

I Let k = (p1 ∗ p2 ∗ . . . ∗ pr) + 1. Then k when divided by anypi has remainder 1. So pi 6 | k for all i ∈ {1, . . . , r}.

I But k > 1 and k is not prime, so k can be written as aproduct of primes (why?)

I Fundamental theorem of arithmetic: any natural number> 1 can be written as a unique product of primes.

I Now let p|k. But p 6∈ {p1, . . . , pr}, so this is a contradiction.

14

Page 28: CS 207m: Discrete Structures (Minor) - IIT Bombay

Proof by contradiction

Theorem 4.: There are infinitely many primes.

Proof by contradiction:

I Suppose there are only finitely many primes, sayp1 < p2 < . . . < pr.

I Let k = (p1 ∗ p2 ∗ . . . ∗ pr) + 1. Then k when divided by anypi has remainder 1. So pi 6 | k for all i ∈ {1, . . . , r}.

I But k > 1 and k is not prime, so k can be written as aproduct of primes (why?)

I Fundamental theorem of arithmetic: any natural number> 1 can be written as a unique product of primes.

I Now let p|k. But p 6∈ {p1, . . . , pr}, so this is a contradiction.

14

Page 29: CS 207m: Discrete Structures (Minor) - IIT Bombay

Proof by contradiction

Theorem 4.: There are infinitely many primes.

Proof by contradiction:

I Suppose there are only finitely many primes, sayp1 < p2 < . . . < pr.

I Let k = (p1 ∗ p2 ∗ . . . ∗ pr) + 1. Then k when divided by anypi has remainder 1. So pi 6 | k for all i ∈ {1, . . . , r}.

I But k > 1 and k is not prime, so k can be written as aproduct of primes (why?)

I Fundamental theorem of arithmetic: any natural number> 1 can be written as a unique product of primes.

I Now let p|k. But p 6∈ {p1, . . . , pr}, so this is a contradiction.

14

Page 30: CS 207m: Discrete Structures (Minor) - IIT Bombay

Proof by contradiction

Theorem 4.: There are infinitely many primes.

Proof by contradiction:

I Suppose there are only finitely many primes, sayp1 < p2 < . . . < pr.

I Let k = (p1 ∗ p2 ∗ . . . ∗ pr) + 1. Then k when divided by anypi has remainder 1. So pi 6 | k for all i ∈ {1, . . . , r}.

I But k > 1 and k is not prime, so k can be written as aproduct of primes (why?)

I Fundamental theorem of arithmetic: any natural number> 1 can be written as a unique product of primes.

I Now let p|k. But p 6∈ {p1, . . . , pr}, so this is a contradiction.

14

Page 31: CS 207m: Discrete Structures (Minor) - IIT Bombay

Proof by contradiction

Theorem 4.: There are infinitely many primes.

Proof by contradiction:

I Suppose there are only finitely many primes, sayp1 < p2 < . . . < pr.

I Let k = (p1 ∗ p2 ∗ . . . ∗ pr) + 1. Then k when divided by anypi has remainder 1. So pi 6 | k for all i ∈ {1, . . . , r}.

I But k > 1 and k is not prime, so k can be written as aproduct of primes (why?)

I Fundamental theorem of arithmetic: any natural number> 1 can be written as a unique product of primes.

I Now let p|k. But p 6∈ {p1, . . . , pr}, so this is a contradiction.

14

Page 32: CS 207m: Discrete Structures (Minor) - IIT Bombay

A Non-constructive proof

Theorem 5.: There exist irrational numbers x and y suchthat xy is rational.

Proof:

I Consider√

2. First show that√

2 is irrational.

I Let x = y =√

2 and consider z =√

2√2.

I Case 1: If z is rational, we are done (why?)

I Case 2: Else z is irrational.

I Then consider z√2 = (

√2√2)√2 = (

√2)2 = 2.

I Thus we have found two irrationals x = z, y =√

2 such thatxy = 2 is rational.

Indeed, note that the above proof is not constructive!

(H.W): Find a constructive proof of this theorem.

15

Page 33: CS 207m: Discrete Structures (Minor) - IIT Bombay

A Non-constructive proof

Theorem 5.: There exist irrational numbers x and y suchthat xy is rational.

Proof:

I Consider√

2. First show that√

2 is irrational.

I Let x = y =√

2 and consider z =√

2√2.

I Case 1: If z is rational, we are done (why?)

I Case 2: Else z is irrational.

I Then consider z√2 = (

√2√2)√2 = (

√2)2 = 2.

I Thus we have found two irrationals x = z, y =√

2 such thatxy = 2 is rational.

Indeed, note that the above proof is not constructive!

(H.W): Find a constructive proof of this theorem.

15

Page 34: CS 207m: Discrete Structures (Minor) - IIT Bombay

A Non-constructive proof

Theorem 5.: There exist irrational numbers x and y suchthat xy is rational.

Proof:

I Consider√

2. First show that√

2 is irrational.

I Let x = y =√

2 and consider z =√

2√2.

I Case 1: If z is rational, we are done (why?)

I Case 2: Else z is irrational.

I Then consider z√2 = (

√2√2)√2 = (

√2)2 = 2.

I Thus we have found two irrationals x = z, y =√

2 such thatxy = 2 is rational.

Indeed, note that the above proof is not constructive!

(H.W): Find a constructive proof of this theorem.

15

Page 35: CS 207m: Discrete Structures (Minor) - IIT Bombay

A Non-constructive proof

Theorem 5.: There exist irrational numbers x and y suchthat xy is rational.

Proof:

I Consider√

2. First show that√

2 is irrational.

I Let x = y =√

2 and consider z =√

2√2.

I Case 1: If z is rational, we are done (why?)

I Case 2: Else z is irrational.

I Then consider z√2 = (

√2√2)√2 = (

√2)2 = 2.

I Thus we have found two irrationals x = z, y =√

2 such thatxy = 2 is rational.

Indeed, note that the above proof is not constructive!

(H.W): Find a constructive proof of this theorem.

15

Page 36: CS 207m: Discrete Structures (Minor) - IIT Bombay

A Non-constructive proof

Theorem 5.: There exist irrational numbers x and y suchthat xy is rational.

Proof:

I Consider√

2. First show that√

2 is irrational.

I Let x = y =√

2 and consider z =√

2√2.

I Case 1: If z is rational, we are done (why?)

I Case 2: Else z is irrational.

I Then consider z√2 = (

√2√2)√2 = (

√2)2 = 2.

I Thus we have found two irrationals x = z, y =√

2 such thatxy = 2 is rational.

Indeed, note that the above proof is not constructive!

(H.W): Find a constructive proof of this theorem.

15

Page 37: CS 207m: Discrete Structures (Minor) - IIT Bombay

A Non-constructive proof

Theorem 5.: There exist irrational numbers x and y suchthat xy is rational.

Proof:

I Consider√

2. First show that√

2 is irrational.

I Let x = y =√

2 and consider z =√

2√2.

I Case 1: If z is rational, we are done (why?)

I Case 2: Else z is irrational.

I Then consider z√2 = (

√2√2)√2 = (

√2)2 = 2.

I Thus we have found two irrationals x = z, y =√

2 such thatxy = 2 is rational.

Indeed, note that the above proof is not constructive!

(H.W): Find a constructive proof of this theorem.

15

Page 38: CS 207m: Discrete Structures (Minor) - IIT Bombay

A Non-constructive proof

Theorem 5.: There exist irrational numbers x and y suchthat xy is rational.

Proof:

I Consider√

2. First show that√

2 is irrational.

I Let x = y =√

2 and consider z =√

2√2.

I Case 1: If z is rational, we are done (why?)

I Case 2: Else z is irrational.

I Then consider z√2 = (

√2√2)√2 = (

√2)2 = 2.

I Thus we have found two irrationals x = z, y =√

2 such thatxy = 2 is rational.

Indeed, note that the above proof is not constructive!

(H.W): Find a constructive proof of this theorem.

15

Page 39: CS 207m: Discrete Structures (Minor) - IIT Bombay

A Non-constructive proof

Theorem 5.: There exist irrational numbers x and y suchthat xy is rational.

Proof:

I Consider√

2. First show that√

2 is irrational.

I Let x = y =√

2 and consider z =√

2√2.

I Case 1: If z is rational, we are done (why?)

I Case 2: Else z is irrational.

I Then consider z√2 = (

√2√2)√2 = (

√2)2 = 2.

I Thus we have found two irrationals x = z, y =√

2 such thatxy = 2 is rational.

Indeed, note that the above proof is not constructive!

(H.W): Find a constructive proof of this theorem.

15

Page 40: CS 207m: Discrete Structures (Minor) - IIT Bombay

Types of proofs

1. If m and n are perfect squares of integers, then mn is alsoa perfect square.

– Direct proof

2. If 6 is prime, then 62 = 30.

– Vacuous/trivial proof

3. Let x be an integer. Then, x is even iff x + x2 − x3 is even.

– Both directions, by contrapositive (A→ B = ¬B → ¬A)

4. There are infinitely many prime numbers.

– Proof by contradiction

5. There exist irrational numbers x, y such that xy is rational.

– Non-constructive proof

6. For all n ∈ N, n! ≤ nn.

7. There does not exist a (input-free) C-program which willalways determine whether an arbitrary (input-free)C-program will halt.

16

Page 41: CS 207m: Discrete Structures (Minor) - IIT Bombay

Types of proofs

1. If m and n are perfect squares of integers, then mn is alsoa perfect square. – Direct proof

2. If 6 is prime, then 62 = 30. – Vacuous/trivial proof

3. Let x be an integer. Then, x is even iff x + x2 − x3 is even.– Both directions, by contrapositive (A→ B = ¬B → ¬A)

4. There are infinitely many prime numbers.– Proof by contradiction

5. There exist irrational numbers x, y such that xy is rational.– Non-constructive proof

6. For all n ∈ N, n! ≤ nn.

7. There does not exist a (input-free) C-program which willalways determine whether an arbitrary (input-free)C-program will halt.

16