You are on page 1of 38

Discrete Structures

.
Dr. Omar Zarty
\ \

Discrete Structures

.
54

Sets
2.1
.

.
2.2

} { 1

10 :

Discrete Structures

.
55

}S ={1, 3, 5, 7, 9

infinite :
} A = {1, 2, 3,
.

}Z = {,-3,-2,-1 , 0 ,1 ,2 ,3,
.

a Aa A :
a A:

aA


) (empty set } { .

Discrete Structures

.
56

N Z Q
R C

2.3

A B )

(.

: :
}A = {1, 3, 5
}B = {5, 3, 1

: .
: :
}A = {3, 4, 5, 6
}B = {3, 3, 4, 5, 5, 6

: .

Discrete Structures

.
57

:
})A = {x: p(x
x . p(x)=true

}A = { x : x is an odd positive integer


} B = {1, 3, 5,
. odd positive integer
.

:
2

}{x: x -3x + 2} = { 1, 2

2.4

A B ) ( A

. B

. :

AB

A . B x (x A x B) :
The set A is a subset of the set B, denoted A B, if every element of

A is also an element of B. Symbolically, A B if x[x A x B] is


true, and conversely.

Discrete Structures

.
58

) ( S :
S
:

AA

AB
A B .

} {1, 2 } {1 , 3, 2 :
}{1 , 2} {1 , 3, 2

. Venn diagrams

Discrete Structures

.
59

A B
A=B if and only if A B and B A
:
) (p q) (q p p q

2.2 Power set

S ) ) ( P(S
.S

: }{0,1,2
:
}}P{012} = {{0}{1}{2}{01}{02}{12}{012
.
8

3 .
.

Discrete Structures

.
60

cardinality .

.A
:

}A = {7,8,9

A= 3

S ) P(S
:

P(S)= 2

.
:
|P{7, 8, 9}| = 23 = 8

2.3 ) (:
B , A .
) (a , b b B , a A :

}A B = {(a, b): aA bB

Discrete Structures

.
61

: :
}A = { 1 , 2} B={ a , b , c
:
})A B = {(1,a), (1, b), (1, c), (2, a), (2, b), (2, c
:
ABBA
:


||A B| = |A| |B
:

}A B C = {(a, b, c): aA , bB , cC

Discrete Structures

.
62

(4)

2.4

:( 1)
()

A = {x : x is a real number and x=1}

()

B = {x : x is positive integer less than 12}

()

C = {x : x is a square of an integer and x<100}

()
D = {x : x is an integer and x=2}
. F ( T) ( 2)
T F
T F

{1,3,5}

{1{1}}

= {1,3,3,5}
=

{{1} 1}

()

()

T F

{{2}} = {2} ()

T F

={}

()

Discrete Structures

.
63

) (3 2 :
}A = {xR: x is integer greater than 1
}B = {xR: x is the square of an integer
}}C = {2,{2
}}}D = {{2},{2,{2
}}}E = {{{2
) (4 True False
}}d) {x} {{x
}e) {x
}f) {x

}a) x {x
}b) x {x

}c) {x} {x

) (5 C , B , A BC AB AC
) (6 :
}{a
}}{{a
}}{a,{a
}}}{a,{a} ,{a,{a
) (7 Power Set :

)a
)b
)c
)d

Discrete Structures

.
64

{a}

{a, b}

{,{}}
A = {a, b, c, d}
B = {y, z}

( 8)
:

BA ,

AB

Set Operations 2.5

AB ={x: xA

Union

:(1)

xB}
Intersection

:(2)

AB ={x: xA xB}

Discrete Structures

.
65

:
}A = {1 2 3
}B = {2, 3, 4
}AB = {1, 2 , 3, 4
}AB = {2, 3
An ,, A2 , A1
i=1 Ai = A1 A2 .. An

i=1 Ai = A1 A2 A3.. An

Discrete Structures

.
66

) :(3 difference B , A:
}B A = {x : xB xA
:

) :(4 Complement
} = { x: x A
) (

Discrete Structures

.
67

:
}A = {3, 4, 5, 6, 7
}B = {6, 7, 8, 9
}A B = {3, 4, 5
:
} U = {x : x is integer
}A = {x : x is integer > 10
U .

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

2.6 :
) (1 identity Laws
A = A
A S = A
)(2

Domination Laws

AS = S
S

= A

.
68

Discrete Structures

Idempotent Laws ( 2)
AA = A

AA = A

Complementation Laws ( 4)

Commutative Laws
AB = BA

(5 )

AB = BA

Associative Laws

(6 )

A (BC) = (AB) C
A (BC) = (AB) C
De Morgan Laws

( 7)

Discrete Structures

.
69

-1

Discrete Structures

.
70

-2 A (B C) = (A B) (A C) :
:
}A (B C) = {x : x A x B C

})= {x : x A (x B or x C

)p (q v r) = (p q) v (p r

})A (B C) = {x : (x A x B) v (x A x B
)= (A B) (A C

Discrete Structures

2.7

.
71

. SET OF :
; )TYPE staff = (Ali, Raja, Ahmed, Adel
VAR
; p, q, r, u : SET OF Staff
Staff

; ]p:= [Ali, Adel


; ]q:= [Ali, Raja
*
r := p * q
+
; u:= p + q
IN :
; IF m IN r THEN i:= i + 1

Discrete Structures

.
72

2.8 )(5
-1 A ) ( B

) ( . ":
b) A B
d) b A

a) A B
c) A B

-2
}B = {0, 3, 6

}A = {1, 2, 3, 4

b) A B
d) B A
-3 A .
-4 B , A
-5

a) A B
c) A B

Discrete Structures

-6

.
73

}A = {0, 2, 4, 6 , 8, 10
}B = {0 , 1 , 2, 3, 4, 5, 6
}C = {4, 5, 6, 7, 8, 9, 10

b) A B C

d) (A B) C

-7

TRUE

b) A B = A

d) A B = B A

a) A B C

c) (A B) C

B , A
a) A B = A
c) A B = A
e) A B = B A

-8
.

3
2

Discrete Structures

.
74

Functions
3.1

function .
.

3.2
-1 relation A B

.AxB
:

}A = {1, 2, 3
}B = {a, b
})R = {(1, a), (2, b), (3, a

Discrete Structures

.
75

R AxB A .B

-2

f A B

(x, y) f ^ (x, z)f y=z


A

B . B
. A

b a f :
)b=f(a

f:AB
f A .B
Let A and B be sets. A function f from A to B, written

f:AB
is a subset f (A B) which satisfies:
() for each a A there exists a unique b B such that
(a, b) f .
The set A is called the domain, and the set B the
codomain, of f.
If (a, b) f the element b B is called the image of a A
and is written

)b = f (a
A function is also called a mapping or a transformation

Discrete Structures

.
76

:
A ) ( B

. .

: )( 65

: :

) = 65(f

f .
:
-1
f:AB
A domain
.codomain

B range

Discrete Structures

-2

77

) f(a a ) f(A A

)(image of A
-3

}f(A) = {y : y = f(x) x A

f decreasing
)x < y f(x) > f(y
y , x .

increasing
)x < y f(x) < f(y
-4 ) ( identity function
i:AA
i(x)=x

3.3

)(1-1

one-to-one function

f 1 -1 :
f(a) = f(b) a = b
) f(a)=f(b . a=b
. injective functions

Discrete Structures

.
78

f: A B

}A = {a, b, c, d
f(a) = 4 , f(b) = 5 , f(c) = 1 , f(d) = 3
1-1 .
: 1-1
A :B

1 -1
:
:

f(x) = x

1 -1 . Z
. Z

Discrete Structures

.
79

(- x) = x

)f(x)=f(-x
.1 -1
:

f(x) = 2x + 1 1-1 x

. x y ) f(x)=f(y

2x+1=2y+1 1 2x=2y
f(x) = f(y) x = y
f .1 -1

3.3

onto function

f :
f: A B
b B a A : f(a) = b
b B a A ).b=f(a

B . A

Discrete Structures

.
80

: .surjective
1 -1 .bijective
: ) ( onto . 1-1

. 1

a .

. 2

b .

. 3

c .
d .

:
f: Z Z
f(x) = x
Z integers
f onto
: . ) f(x
.

x . x= -1

Discrete Structures

.
81

: onto 1-1

. 1

a .

. 2

b .

. 3

c .

. 4

d .

1 -1
)(

) .(1-1
:

f: Z Z

f(x) = x

1 -1 :

identity function

3.4 inverse function


f:AB

Discrete Structures

.
82

) ( bijective
g :BA

f(b) = a

g(a) = b
g . f f-1
:

: } f:{a, b, c} {2, 3, 5
f(a) = 2 f(b) = 5 f(c) = 3
) 1-1 (

f-1

(5) = b(3) = c , f(2) = a , ff

: f(x) = x }{-2,-1,0,1,2
: one-to-one

Discrete Structures

.
83

3.5 composite function

f g

f: AB
g: BC
fog
))(fog) (a) = f(g(a
. :


))(gof)(a) = g (f (a
:
g(a) = b
g(b) = c
g(c) = a

f(a) = 3

Discrete Structures

.
84

f(b) = 2
f(c) = 1

)(
)(

)fog(x
)gof(x

x = a, b, c

)(
fog(a) = f(g(a)) = f(b) = 2
fog(b) = f(g(b)) = f(c) = 1
fog(c) = f(g(c)) = f(a) = 3
)(

? = )gof(a) = g(f(a)) = g(3


) g(3 gof
)(a, b, c
:
f(x) = 2x + 3
g(x) = 3x + 2

gof fog

Discrete Structures

.
85

)y = g(x) z = f(x

fog(x) = f(g(x)) =f(y)= 2y + 3


= 2(3x + 2) + 3 = 6x + 4 + 3
= 6x + 7
gof(x) = g(f(x)) = 3z + 2
= 3(2x + 3) + 2 = 6x + 11
) (1
fog gof
: f 1-1
o f (x) = f o f-1(x) = xf

-1
o f = f o f = if
. identity function

(z) = i(z) =z) ( f


z .
:
)(f(x(y) =fy=f(x) x= f
))(x(y)) x=f(fy = f(x)=f ( f

Discrete Structures

3.6

.
86

Graph of a function

f: A B
:
})G = {(a, b) : a A , b = f(a
) (a, b ordered pair
: :
f(n) = 2n + 1

f :AZ
Z .
}A = { 0, 1, 2
:
} )G = { (0,1), (1,3), (1,5
:

Discrete Structures

.
87

x .f(n) = 2n + 1
: f(x) = (x-4.5)/16 f: [ 0.5, 8.5] R
] [0.5, 8.5 0.5 8.5 R
.

Discrete Structures

.
88

: )
(
:

f(x) = (x-4.5)/16

Discrete Structures

.
89

3.7 )(6
(1 1-1
a) f(a) = b , f(b) = a , f(c) = c , f(d) = d
b) f(a) = b , f(b) = b , f(c) = d , f(d) = c
c) f(a) = d , f(b) = b , f(c) = c , f(d) = d

}f: {a, b, c, d} {a ,b, c, d
(2 ) (1 onto
(3 1 -1
f(x) = -3x + 4
)a
f(x) = -3x + 7
)b
f(x) = x
)c
f:

(4 g A f B B C :
)( g , f 1 -1 fog . 1-1
)( g , f onto fog.
(5

Discrete Structures

.
90

f(x) = 4x + 5
f:


(6

f(n) = 1 - n
f: D D
}D= {-2,-1,0,1,2

(7

f(x) = x + 1 .

You might also like