• Sonuç bulunamadı

Basic Structures: Sets, Functions, Sequences, and Sums

N/A
N/A
Protected

Academic year: 2022

Share "Basic Structures: Sets, Functions, Sequences, and Sums"

Copied!
47
0
0

Yükleniyor.... (view fulltext now)

Tam metin

(1)

Basic Structures: Sets, Functions, Sequences, and Sums

CSC-2259 Discrete Structures

Konstantin Busch - LSU 1

Sets

A set is an unordered collection of objects English alphabet vowels: V {a,e,i,o,u}

Odd positive integers less than 10:

} 9 , 7 , 5 , 3 , 1 {

O elements of set members of set

V

a  b V

(2)

Konstantin Busch - LSU 3

Other set representations

Set of positive integers less than 100:

} 99 , , 3 , 2 , 1

{ 

Odd positive integers less than 10:

} 9 , 7 , 5 , 3 , 1 {

O

10}

than less

integer positive

odd an is

| {x x O 

10}

and odd is

|

{  

x Z x x

O

omitted elements

Venn Diagram

1 3

5 7 9

2

4 6

8

10}

than less

integer positive

odd an is

| {x x O 

10}

than less

integer positive

a is

| {x x U 

U

O

Universe

(3)

Konstantin Busch - LSU 5

Useful sets }

, 3 , 2 , 1 , 0

{ 

N

} , 2 , 1 , 0 , 1 , 2 ,

{  

Z

} , 3 , 2 , 1

{ 

Z

} 0 ,

,

| /

{   

p q p Z q Z q Q

} numbers Real

of set {

R

Natural numbers Integers

Positive integers

Rational numbers Real numbers

Empty set

{}

} {

(4)

Konstantin Busch - LSU 7

Cardinality (size) of set

} , , , ,

1 {a e i o u S 

} 99 , , 3 , 2 , 1

3 { 

S

} , 3 , 2 , 1 , 0

{ 

N

} , , , ,

2 {a b c z

S  

0

| {}

|

|

|   |{}|1 5

|

|S1  26

|

|S2

Number of elements

99

|

| S3

infinite size Finite sets

Infinite set

Equal sets B A 

) (x A x B x   

Examples: {1,3,5}{3,5,1}

} 5 , 5 , 5 , 5 , 3 , 3 , 3 , 1 { } 5 , 3 , 1

{ 

10}

and odd is

| {

} 9 , 7 , 5 , 3 , 1

{  xZ x x

(5)

Konstantin Busch - LSU 9

Subset

B A 

) (x A x B x   

Examples: {1,3,5}{0,1,3,5} N  Z

For any set :

A

B

S S 

S  S

Proper Subset

B A 

)) (

(x A x B y y B y A

x       

Examples: {1,3,5}{0,1,3,5} N  Z

A B

B A B

A   

y

(6)

Konstantin Busch - LSU 11

B A 

A B

B

A   

is equivalent to

Power set

The power set of contains all possible subsets of (and the empty set)

S S

} 3 , 2 , 1 {

S

}}

3 , 2 , 1 { }, 3 , 1 { }, 3 , 2 { }, 2 , 1 { }, 3 { }, 2 { }, 1 { , { )

(S   P

8 2

2

| ) (

| P S

|S|

3

Size of power set

Power set

Special cases } { )

(   P

}}

{ , { })

({    P

(7)

Konstantin Busch - LSU 13

Ordered tuples (relations) Ordered n-tuple

( a

1

, a

2

,  , a

n

)

ordered list of elements

) , , , ( ) , , ,

( a

1

a

2

a

n

b

1

b

2

b

n iff

i ( a

i

b

i

)

) 1 , 2 ( ) 2 , 1

( 

Example:

Cartesian product

Cartesian product of two sets

A, B }

| ) ,

{( a b a A b B B

A     

Example:

A  { 1 , 2 } B  { a , b , c }

)}

, 2 ( ), , 2 ( ), , 2 ( ), , 1 ( ), , 1 ( ), , 1

{( a b c a b c

B A 

)}

2 , ( ), 2 , ( ), 2 , ( ), 1 , ( ), 1 , ( ), 1 ,

{(a b c a b c

A B 

A B B

A   For this case:

6 3 2

|

|

|

|

|

|ABAB    Size:

(8)

Konstantin Busch - LSU 15

Cartesian product of sets

A

1

, A

2

,  , A

n

}

| ) , , , {(

1 2

2

1

A A

n

a a a

n

a

i

A

i

A       

Example:

A  { 1 , 2 } B  { a , b , c }

)}

, , 2 ( ), , , 2 ( ), , , 2 ( ), , , 1 ( ), , , 1 ( ), , , 1 (

), , , 2 ( ), , , 2 ( ), , , 2 ( ), , , 1 ( ), , , 1 ( ), , , 1 {(

y c y b y a y c y b y a

x c x b x a x

c x b x a C

B A

12 2 3 2

|

|

|

|

|

|

|

| ABCABC     Size:

} , { x y C 

|

|

|

|

|

|

|

| A1A2AnA1A2  An

Sets and propositions

)) ( ( P x S

x 

shorthand for

x ( xSP ( x )) ))

( ( P x S

x 

shorthand for

x ( xSP ( x ))

Truth set of proposition

P (x ) )}

(

| Domain

{ x  P x

all elements of the domain which satisfy

P (x )

(9)

Set operations

Konstantin Busch - LSU 17

Union

AB  { x | xAxB }

A B

U

} 5 , 3 , 1 {

A B  { 1 , 2 , 3 } A  B  { 1 , 2 , 3 , 5 }

Intersection

}

|

{ x x A x B B

A     

U

} 5 , 3 , 1 {

A B  { 1 , 2 , 3 } A  B  { 1 , 3 }

B

A

A 

B

(10)

Konstantin Busch - LSU 19

Disjoint sets

 B A

A B

U

} 5 , 3 , 1 {

A B  { 2 , 9 } A  B   B

A,

Set difference

}

|

{ x x A x B B

A     

A

B

U

} 5 , 3 , 1 {

A B  { 1 , 2 , 3 } A  B  { 5 } B

A 

(11)

Konstantin Busch - LSU 21

Complement

}

|

{ x x A

A  

A

U

} 5 , 3 , 1 {

A U  { 1 , 2 , 3 , 4 , 5 } A  { 2 , 4 }

|

|

|

|

|

|

|

| ABABAB

A B

U

} 5 , 3 , 1 {

A B {1,2,3}

Size of union

4 2 3 3

|

|

|

|

|

|

|

| ABABAB    

} 3 , 1 {

 B A } 5 , 3 , 2 , 1 {

 B A

B A 

(12)

Konstantin Busch - LSU 23

De Morgan’s laws

B A

B

A    B A

B

A   

Show that and Theorem:

ABAB

Proof: ABAB ABAB

B A B

A   

Part 1:

) (

) (

) (

) (

) (

) (

) (

)) (

) ((

) (

B A x

B x A x B

x A x

B x A

x B

x A x

B A x B

A x

B A x

De Morgan’s law from logic

(13)

Konstantin Busch - LSU 25

Part 2:

B A x

B A x

B x A x B

x A

x

B x A x B

x A x

B A x

) (

)) (

) ((

) (

) (

) (

) (

) (

) (

) (

B A B

A   

End of Proof

De Morgan’s law from logic

Set identities

A U A

A A

Identity laws

A

U U A

Domination laws

A A A

A A A

Idempotent laws

A A 

Complementation law

Complement laws

A A

U A A

De Morgan’s laws

B A B A

B A B A

(14)

Konstantin Busch - LSU 27

A B B A

A B B A

Commutative laws

C B A C

B A

C B A C

B A

) (

) (

) (

) (

Associative laws

A B A A

A B A A

) (

) (

Absorption laws

) (

) (

) (

) (

) (

) (

C A B

A C

B A

C A B

A C

B A

Distributive laws

Generalized unions and intersections

i n

i

n

A

A A

A

1 2

1

i n

i

n

A

A A

A

1 2

1

(15)

Konstantin Busch - LSU 29

Example:

A

i

 { i , i  1 , i  2 ,  }

} , 3 , 2 , 1 { }

, 2 , 1 ,

{ 1

1 1

A i

i i A

n

i i n

i

} , 2 ,

1 , { }

, 2 , 1 , {

1 1

n n

n A

i i i

A n

n

i i n

i

Computer representation of sets

} 10 , 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 {

U

} 9 , 7 , 5 , 3 , 1 {

A 1010101010

Represent sets as binary strings

} 10 , 8 , 6 , 4 , 2 {

B 0101010101

(16)

Konstantin Busch - LSU 31

Set operations become binary string operations

} 5 , 4 , 3 , 2 , 1 {

A

1010101010

} 9 , 7 , 5 , 3 , 1 {

B

1111100000

} 9 , 7 , 5 , 4 , 3 , 2 , 1 {

 B A

} 5 , 3 , 1 {

 B A

1111101010 1010100000

Bitwise OR

Bitwise AND

1111111111

:

0100000000 :

} {

1000000000 :

} {

0000000000

:

2 1

S a a

Powerset of S {a1,a2,a3,,an1,an}

bits n

ns combinatio 2

n

) (S P

elements n

|

2

|

2

| ) (

| P S

n

S

) (S P

(17)

Functions

Konstantin Busch - LSU 33

Adams Chou Goodfriend

Rodriguez Stevens

A B C D F

Names Grades

C

f ( Chou)  f ( Rodriguez)  A

B A

f : 

A B

a f ( a )  b

f

f

Domain Codomain

Image of

a

Every element of domain has exactly one image

maps to

A B

(18)

Konstantin Busch - LSU 35

Adams Chou Goodfriend

Rodriguez Stevens

A B C D F

Stevens}

Rodriguez, ,

Goodfriend Chou,

{Adams, Domain 

F}

D, C, B, {A, Codomain 

F}

C, B, {A,

Range  set of all images

Domain Codomain

f f

f

Z Z

f : 

)

2

( x x

f

Z Domain 

Z Codomain 

} {0,1,4,9,

Range

(19)

Konstantin Busch - LSU 37

Equal functions

B A

f :  g : CD

g f 

B A 

D B 

) ( )

(

, f x g x A

x  

same domain same codomain

same mapping

In some programming languages,

domain and codomain are explicitly defined

int f(int a) { return a*a;

}

(20)

Konstantin Busch - LSU 39

Add and multiply functions

R A

f

1

: 

Real numbers

R A

f

2

: 

) ( )

( )

)(

( f

1

f

2

xf

1

xf

2

x ) ( ) ( )

)(

( f

1

f

2

xf

1

x f

2

x

Example:

f

1

( x )  x

2

f

2

( x )  xx

2

x x

x x x f x f x f

f  )( ) ( ) ( ) (  )

( 1 2 1 2 2 2

4 3 2

2 2

1 2

1 )( ) ( ) ( ) ( )

(f f xf x f xx xxxx

Image of set

}

| ) ( {

))}

( (

| { ) (

S x x f

x f t S x t S

f

Example:

f ( x )  x

2

} 9 , 4 , 1 { }) 3 , 2 , 1

({ 

f

Set

S

(21)

Konstantin Busch - LSU 41

One-to-one (injection) function

) ( )

( x f y

f

implies

x  y

For every in domain

x, y

Examples:

f ( x )  x  1

is one-to-one

)

2

( x x

g

is not one-to-one: g(1) g(1)1

a 1

b 2

c d

3 4 5

Each element of range is image of one element of domain

Increasing function:

xyf ( x )  f ( y )

Strictly increasing:

xyf ( x )  f ( y )

Strictly increasing functions are one-to-one

(22)

Konstantin Busch - LSU 43

Onto (surjection) function

y x

f ( ) 

For every there is such that

B y 

Examples:

f ( x )  x  1

is onto

)

2

( x x

g

is not onto: xZ,g(x) 1

a 1

b 2

c d

3

B A

f :  B x 

Range = Codomain

One-to-one correspondence (bijection) function

Examples:

f ( x )  x  1

is bijection

)

2

( x x

g

is not bijection

a 1

b 2

c d

3

a function which is one-to-one and onto

4

x x ) 

 (

is bijection Identity function

(23)

Konstantin Busch - LSU 45

a 1

b 2

c 3

4

one-to-one not onto

a 1

b 2

c 3

not one-to-one onto

d

a 1

b 2

c d

3 4

one-to-one onto

a 1

b 2

c d

3 4

not one-to-one not onto

a 1

b 2

c 3

4

not a function

Inverse of a bijection function

f x

y

f

1

( ) 

when

f ( x )  y

1

f

a 1

b 2

c d

3 4

domain

f

codomain

a 1

b 2

c d

3 4 1

f

codomain domain

f

is invertible function

Example:

f ( x )  x  1 f

1

( y )  y  1

(24)

Konstantin Busch - LSU 47

A B

)

1

( b f

a

b  f (a )

) (a f

)

1

( b f

Composition of functions

C B

f :  B A

g :  ( fg )( x )  f ( g ( x )) C A

g

f  : 

Example:

f ( x )  2 x g ( x )  x

2

2 2

) 2 (

)) ( ( )

)(

( fg xf g xf xx

2

2

4

) 2 ( ) 2 ( ))

( ( )

)(

( gf xg f xg xxx

(25)

Konstantin Busch - LSU 49

i f f

f

f

1

1

 

identity function

y x

f y

f f y f

f

)( )  (

( ))  ( ) 

( 

1 1

x y

f x

f f x f

f

)( ) 

( ( )) 

( ) 

(

1

1 1

Suppose

f ( x )  y

Floor and Ceiling

Floor function:

Let be real

x

  x

largest integer less or equal to

x

Ceiling function:

  x

smallest integer

greater or equal to

x

Examples: 0

2 1

1

2 1

3.14 3.13

(26)

Konstantin Busch - LSU 51

Factorial function

 Z

N

f : f ( n )  n !  1  2  3  ( n  1 )  n 1

! 0 ) 0

(   f

1

!

1  2 !  1  2  2 6 !  1  2  3  4  5  6  760 000 , 640 , 176 , 008 , 902 , 432 , 2 20 19 3

2 1

!

20      

Stirling’s formula:

n

e n n

n

 

 

 2 

!

Sequences

2, 4, 6, 8, 10 1,3,9,27,81,…

Finite sequence Infinite sequence

function from a subset of integers to a set

S

Sequence:

a

n

n f ( ) 

 1,

1,3,9,27,8

, , , , , }

{

1 2 3 4 5

a a a a a a

n

2 )

1

(  a

1

f

10 )

5

(  a

5

f

5 4 3 2

1,a ,a ,a ,a a

Alternate representation

0 ,

3 

k

a

n k

(27)

Konstantin Busch - LSU 53

a

n

a

a

1

,

2

,  , a

n

a a

a

1 2 3

n a

a

a

n

| 

|

1 2

Length of string:

finite sequence:

Empty string (null):

|  |  0

String:

all elements of sequence concatenated

Arithmetic progression

 , ,

, 2 ,

, a d a d a nd

a   

Initial term

a

Common difference

d

Example:

{ s

n

}   1  4 n ,  11 , 7 , 3 , 1

0

start with

n

(28)

Konstantin Busch - LSU 55

Geometric progression

 , , ,

,

, ar ar

2

ar

n

a

Initial term

a

Common ratio

r

Example:

{ c

n

}  2  5

n

,  1250 ,

250 , 50 , 10 , 2

0

start with

n

Summations

n m

m

m

a a a

a ,

1

,

2

,  ,

   

n

m i

i n

m m

m

a a a a

a

1 2

Sum:

Sequence:

Example:

1 2 3 4 5

2

55

5

1

2 2 2 2

2

     

i

i

(29)

Konstantin Busch - LSU 57

Theorem:

2 ) 1 (

1

 

n i n

n

i

Proof:

1 1

1 1

1 1

} {

1 2

3 2

1 }

{

1 4

3 2

1 }

{

n n

n n

n n

c

n n

n n b

n n

a

n n n

n

i i n

i i n

i

b a

i S

1 1

1

S b a

c n

n

n

i i n

i i n

i

i 2

) 1 (

1 1

1

  

2 ) 1

n( n S

End of Proof

Theorem: If are real numbers and , then

r a,

} 1 , 0 {

r

1

1

0

 

ar ar r a

n n

i

i

Proof:

n

i

ar

i

S

0

Let

(30)

Konstantin Busch - LSU 59

) (

) (

1

1 0

1

1 0

1 0

a ar

S

a ar

ar ar ar ar r rS

n

n n

k k n

k k n

i i n

i i

rS S ( ar

n1

a )

1

1

 

r

a S ar

n

End of Proof

Useful Summation Formulas

1

|

| 1 ,

1

} 1 , 0 { 1 ,

6

) 1 2 )(

1 (

2 ) 1 (

0

1

0 1

2 1

 

 

 

 

 

x x x

r r

a ar ar

n n

i n

n i n

i i n n

i

i n

i n

i

(31)

Countable Sets

Konstantin Busch - LSU 61

Any finite set is countable by default

An infinite set is countable if there is a one-to-one correspondence from to

S

S

Countable finite set:

Countable infinite set:

Z

Positive integers

Even positive integers:

2 , 4 , 6 , 8 , 

Positive integers:

One-to-one

Correspondence:

 , 4 , 3 , 2 , 1

n

corresponds to

2 n

Theorem: Even positive integers are countable

Proof:

(32)

Konstantin Busch - LSU 63

The set of rational numbers is countable

all rational numbers:

,  8

, 7 4 , 3 2 1

Theorem:

Proof:

We need to find a method to list

Naïve Approach

Rational numbers: , 3 , 1 2 , 1 1 1

Positive integers:

One-to-one

correspondence:

 , 3 , 2 , 1

Doesn’t work:

we will never list

numbers with nominator 2:

,  3 , 2 2 , 2 1 2

Start with nominator=1

(33)

Konstantin Busch - LSU 65

Better Approach: scan diagonals

1 1

2 1

3 1

4 1

1 2

2 2

3 2

1 3

2 3

1 4

Nomin.=1

Nomin.=2

Nomin.=3

Nomin.=4

1 1

2 1

3 1

4 1

1 2

2 2

3 2

1 3

2 3

4

first diagonal

(34)

Konstantin Busch - LSU 67

1 1

2 1

3 1

4 1

1 2

2 2

3 2

1 3

2 3

1 4

second diagonal

1 1

2 1

3 1

4 1

1 2

2 2

3 2

1 3

2 3

4

third diagonal

(35)

Konstantin Busch - LSU 69

1 1

2 1

3 1

4 1

1 2

2 2

3 2

1 3

2 3

1 4

Every element will be eventually scanned

fourth diagonal…

Rational Numbers:

, 

2 , 2 3 , 1 1 , 2 2 , 1 1 1

One-to-one

correspondence:

Positive Integers:

1 , 2 , 3 , 4 , 5 , 

End of Proof Diagonal listing

(36)

Konstantin Busch - LSU 71

Theorem: Set is uncountable

S  ( 0 , 1 )  R

Proof: Assume that is countable,

S

then we can list its elements

} , , ,

{ s

1

s

2

s

3

S 

Elements of

S

1 2 5 1 2 4 8 1 6 4 . 0

3 1 1 2 3 0 0 1 2 3 . 0

4 8 1 3 5 0 2 0 3 1 . 0

1 3 7 5 1 2 3 1 2 1 . 0

6 1 2 4 9 2 5 4 1 0 . 0

5 4 3 2 1

s s s s s

List the elements of

S  ( 0 , 1 )

(37)

Konstantin Busch - LSU 73 10

9 8 7 6 5 4 3 2

. 1

0 x x x x x x x x x x

t

Create new element based on diagonal

1 2 5 1 2 4 8 1 6 4 . 0

3 1 1 2 3 0 0 1 2 3 . 0

4 8 1 3 5 0 2 0 3 1 . 0

1 3 7 5 1 2 3 1 2 1 . 0

6 1 2 4 9 2 5 4 1 0 . 0

5 4 3 2 1

s s s s s

10

9 8 7 6 5 4 3

1 2

.

0 x x x x x x x x x

t

1 2 5 1 2 4 8 1 6 4 . 0

3 1 1 2 3 0 0 1 2 3 . 0

4 8 1 3 5 0 2 0 3 1 . 0

1 3 7 5 1 2 3 1 2 1 . 0

6 1 2 4 9 2 5 4 1 0 . 0

5 4 3 2 1

s s s s s

If diagonal element is 0 then set digit to 1

(38)

Konstantin Busch - LSU 75 10

9 8 7 6 5 4

0 3

1 .

0 x x x x x x x x

t

1 2 5 1 2 4 8 1 6 4 . 0

3 1 1 2 3 0 0 1 2 3 . 0

4 8 1 3 5 0 2 0 3 1 . 0

1 3 7 5 1 2 3 1 2 1 . 0

6 1 2 4 9 2 5 4 1 0 . 0

5 4 3 2 1

s s s s s

If diagonal element is not 0 then set digit to 0

10

9 8 7 6 5

1 4

0 1 .

0 x x x x x x x

t

1 2 5 1 2 4 8 1 6 4 . 0

3 1 1 2 3 0 0 1 2 3 . 0

4 8 1 3 5 0 2 0 3 1 . 0

1 3 7 5 1 2 3 1 2 1 . 0

6 1 2 4 9 2 5 4 1 0 . 0

5 4 3 2 1

s s s s s

If diagonal element is 0 then set digit to 1

(39)

Konstantin Busch - LSU 77 10

9 8 7 6

1 5

1 0 1 .

0 x x x x x x

t

1 2 5 1 2 4 8 1 6 4 . 0

3 1 1 2 3 0 0 1 2 3 . 0

4 8 1 3 5 0 2 0 3 1 . 0

1 3 7 5 1 2 3 1 2 1 . 0

6 1 2 4 9 2 5 4 1 0 . 0

5 4 3 2 1

s s s s s

If diagonal element is 0 then set digit to 1

10

9 8 7

0 6

1 1 0 1 .

0 x x x x x

t

1 2 5 1 2 4 8 1 6 4 . 0

3 1 1 2 3 0 0 1 2 3 . 0

4 8 1 3 5 0 2 0 3 1 . 0

1 3 7 5 1 2 3 1 2 1 . 0

6 1 2 4 9 2 5 4 1 0 . 0

5 4 3 2 1

s s s s s

If diagonal element is not 0 then set digit to 0

(40)

Konstantin Busch - LSU 79

1 0 1 1 0 1 . 0

t

1 2 5 1 2 4 8 1 6 4 . 0

3 1 1 2 3 0 0 1 2 3 . 0

4 8 1 3 5 0 2 0 3 1 . 0

1 3 7 5 1 2 3 1 2 1 . 0

6 1 2 4 9 2 5 4 1 0 . 0

5 4 3 2 1

s s s s s

By repeating process we obtain new number

) 1 , 0 (

1 0 1 1 0 1 . 0

t

1 2 5 1 2 4 8 1 6 4 . 0

3 1 1 2 3 0 0 1 2 3 . 0

4 8 1 3 5 0 2 0 3 1 . 0

1 3 7 5 1 2 3 1 2 1 . 0

6 1 2 4 9 2 5 4 1 0 . 0

5 4 3 2 1

s s s s s

s

1

t 

(differ on first digit) Observation:

Referanslar

Benzer Belgeler

Bunun için elde edilen gaz-çözelti tepkimelerinde kullanılan deneysel tasarım sonuçları değerlendirilerek, hidroliz tepkimesinin kontrol edilmesi için

Şekil 2.1. Kuvvet ile yer değiştirme arasındaki ilişki ... Biçimlendirilebilir metaller için gerilme-şekil değiştirme eğrisi ... Dengedeki bir cisim ... tt en kesitli

Buna göre kültürel güç, toplumsal değer ve normlara uyum, profesyonelleşme, biçimsel organizasyon yapısı, şeffaflaşma ve hesap verebilirlik, biçimsel faaliyet

Bu tez çalışmasında kanal kodlama tekniklerinden katlamalı kodlar için kullanılan yumuşak çıkışlı Viterbi algoritması ve Turbo kod çözme algoritmalarından SOVA ile

Destekleyici ve ılımlı bir atmosferin oluşturulmasının ve üst yönetim ile çalışanlar arasında desteğin sağlanmasının güçlendirme, yaratıcılık, iş tatmini gibi

Bunun için, öncelikle BirGün, Cumhuriyet, Hürriyet, Yeniçağ ve Yeni Şafak gazetelerinin manşet sayfalarında konu ile ilgili çıkan haberler taranmıştır.. Bu

HPS’li çocukların üst ekstremite plejik taraflarının çevre (omuz eklemi, kol, dirsek eklemi, önkol ve el bilek eklemi), uzunluk (üst ekstremite, kol, önkol ve

a Department of Mathematics, Faculty of Sciences, Bilkent University, 06800 Ankara, Turkey b Department of Mathematics, Faculty of Sciences, Middle East Technical University,