Cub11k's BIU Notes
Cub11k's BIU Notes
Assignments
Discrete-math
Discrete-math 1
Discrete-math 10
Discrete-math 11
Discrete-math 12
Discrete-math 2
Discrete-math 3
Discrete-math 4
Discrete-math 5
Discrete-math 6
Discrete-math 7
Discrete-math 8
Discrete-math 9
Infi-1
Infi-1 10
Infi-1 11
Infi-1 2
Infi-1 3
Infi-1 4
Infi-1 5
Infi-1 6
Infi-1 7
Infi-1 8
Infi-1 9
Linear-1
Linear-1 1
Linear-1 10
Linear-1 11
Linear-1 12
Linear-1 2
Linear-1 3
Linear-1 4
Linear-1 5
Linear-1 6
Linear-1 7
Linear-1 8
Linear-1 9
Linear-2
Linear-2 1
Lectures
Data-structures
Data-structures 1
Data-structures 2
Data-structures 3
Discrete-math
Discrete-math 10
Discrete-math 11
Discrete-math 12
Discrete-math 13
Discrete-math 14
Discrete-math 15
Discrete-math 16
Discrete-math 18
Discrete-math 19
Discrete-math 20
Discrete-math 21
Discrete-math 22
Discrete-math 23
Discrete-math 24
Discrete-math 25
Discrete-math 26
Discrete-math 3
Discrete-math 4
Discrete-math 5
Discrete-math 6
Discrete-math 7
Discrete-math 8
Discrete-math 9
Exam 2023 (2A)
Exam 2023 (2B)
Exam 2023 (A)
Exam 2023 (B)
Exam 2023 (C)
Exam 2024 (A)
Exam 2024 (B)
Exam 2024 (C)
Midterm
Infi-1
Exam 2022B (A)
Exam 2022B (B)
Exam 2023B (A)
Exam 2023B (B)
Exam 2024 (A)
Exam 2024 (B)
Exam 2025 (A)
Infi-1 10
Infi-1 12
Infi-1 13
Infi-1 14
Infi-1 15
Infi-1 16
Infi-1 17
Infi-1 19
Infi-1 20
Infi-1 21
Infi-1 22
Infi-1 23
Infi-1 24
Infi-1 25
Infi-1 26
Infi-1 5
Infi-1 6
Infi-1 7
Infi-1 9
Midterm
Theorems and proofs
Infi-2
Infi-2 1
Infi-2 10
Infi-2 11
Infi-2 12
Infi-2 13
Infi-2 14
Infi-2 15
Infi-2 16
Infi-2 17
Infi-2 2-3
Infi-2 3-4
Infi-2 5
Infi-2 6
Infi-2 7
Infi-2 8
Infi-2 9
Linear-1
Exam 2023 (B)
Exam 2023 (C)
Exam 2024 (A)
Exam 2024 (B)
Exam 2024 (C)
Exam 2025 (A)
Linear-1 11
Linear-1 12
Linear-1 13
Linear-1 4
Linear-1 5
Linear-1 6
Linear-1 7
Linear-1 8
Linear-1 9
Midterm
Random exams
Theorems and proofs
Linear-2
Linear-2 1
Linear-2 2
Linear-2 3
Linear-2 4
Linear-2 5
Linear-2 6
Linear-2 7
Linear-2 8
Seminars
CSI
CSI 2
Data-structures
Data-structures 1
Data-structures 2
Data-structures 3
Discrete-math
Discrete-math 1
Discrete-math 10
Discrete-math 11
Discrete-math 12
Discrete-math 2
Discrete-math 3
Discrete-math 4
Discrete-math 5
Discrete-math 6
Discrete-math 7
Discrete-math 8
Discrete-math 9
Infi-1
Infi-1 10
Infi-1 11
Infi-1 12
Infi-1 13
Infi-1 3
Infi-1 4
Infi-1 5
Infi-1 6
Infi-1 8
Infi-2
Infi-2 1
Infi-2 2
Infi-2 3
Infi-2 4
Infi-2 6
Infi-2 7
Infi-2 8
Linear-1
Linear-1 10
Linear-1 11
Linear-1 12
Linear-1 3
Linear-1 5
Linear-1 6
Linear-1 7
Linear-1 8
Linear-1 9
Linear-2
Linear-2 1
Linear-2 2
Linear-2 3
Linear-2 4
Linear-2 5
Linear-2 6
Linear-2 7
Templates
Lecture Template
Seminar Template
Home
Discrete-math 19
Discrete-math 19
Inclusion-Exclusion Principle
#definition
Let
A
1
,
…
,
A
n
be finite sets
Then
|
⋃
i
=
1
n
A
i
|
=
∑
k
=
1
n
(
−
1
)
k
−
1
∑
B
⊆
[
n
]
|
B
|
=
k
|
⋂
j
∈
B
A
j
|
=
=
∑
k
=
1
n
(
−
1
)
k
−
1
∑
1
≤
i
1
<
i
2
<
⋯
<
i
k
≤
n
|
A
i
1
∩
A
i
2
∩
⋯
∩
A
i
k
|
Proof:
Let
x
∈
U
Let
m
be a number of sets which contain
x
Let
m
=
0
⟹
{
x
∉
⋃
i
=
1
n
A
i
∀
k
∈
[
n
]
:
∀
B
⊆
[
n
]
,
|
B
|
=
k
:
x
∉
⋂
j
∈
B
A
j
⟹
x
is counted zero times on both sides
Let
m
>
0
x
∈
A
i
1
,
A
i
2
,
…
,
A
i
m
Let
D
=
{
i
∈
[
n
]
|
x
∈
A
i
}
|
D
|
=
m
x
∈
⋃
i
=
1
n
A
i
⟹
x
is counted once on the left side
∀
B
⊈
D
:
x
∉
⋂
j
∈
B
A
j
⟹
∀
B
⊈
D
:
x
is counted zero times on the right side
Total contribution of
x
to the sum on the right side:
∑
k
=
1
m
(
−
1
)
k
−
1
∑
B
⊆
D
|
B
|
=
k
1
=
∑
k
=
1
m
(
−
1
)
k
−
1
(
m
k
)
=
−
∑
k
=
1
m
(
−
1
)
k
(
m
k
)
=
1
−
∑
k
=
0
m
(
−
1
)
k
(
m
k
)
=
=
1
−
0
=
1
⟹
∀
x
∈
U
:
x
is counted the same number of times on both sides
Proved
Special case
If
∀
k
∈
[
n
]
:
sizes of intersection of any
k
sets are equal to
α
k
Then
|
⋃
i
=
1
n
A
i
|
=
∑
k
=
1
n
(
−
1
)
k
−
1
∑
B
⊆
[
n
]
|
B
|
=
k
α
k
=
∑
k
=
1
n
(
−
1
)
k
−
1
α
k
(
n
k
)
Example
How many numbers from
[
1000
]
can be divided by at least one of numbers:
2
,
3
,
5
?
Solution:
Let
A
2
=
{
n
∈
[
1000
]
|
2
∣
n
}
Let
A
3
=
{
n
∈
[
1000
]
|
3
∣
n
}
Let
A
5
=
{
n
∈
[
1000
]
|
5
∣
n
}
|
A
2
∪
A
3
∪
A
5
|
=
|
A
2
|
+
|
A
3
|
+
|
A
5
|
⏟
k
=
1
−
(
|
A
2
∩
A
3
|
+
|
A
2
∩
A
5
|
+
|
A
3
∩
A
5
|
)
⏟
k
=
2
+
+
|
A
2
∩
A
3
∩
A
5
|
⏟
k
=
3
=
|
A
2
|
=
⌊
1000
2
⌋
=
500
|
A
3
|
=
⌊
1000
3
⌋
=
333
|
A
5
|
=
⌊
1000
5
⌋
=
200
|
A
2
∩
A
3
|
=
⌊
1000
2
∗
3
⌋
=
166
|
A
2
∩
A
5
|
=
⌊
1000
2
∗
5
⌋
=
100
|
A
3
∩
A
5
|
=
⌊
1000
3
∗
5
⌋
=
66
|
A
2
∩
A
3
∩
A
5
|
=
⌊
1000
2
∗
3
∗
5
⌋
=
33
⟹
|
A
2
∪
A
3
∪
A
5
|
=
500
+
333
+
200
−
166
−
100
−
66
+
33
=
734
Example
Let
n
,
m
∈
N
What is the number of surjective functions
f
:
[
n
]
→
[
m
]
?
Solution:
Let
m
>
n
⟹
|
[
n
]
|
<
|
[
m
]
|
⟹
Number of surjective functions is zero
Let
m
≤
n
|
[
m
]
[
n
]
|
=
m
n
Let’s count the number of functions that are not surjective
Let
∀
i
∈
[
m
]
:
A
i
=
{
f
:
[
n
]
→
[
m
]
|
i
∉
I
m
(
f
)
}
f
(
1
)
∈
[
m
]
∖
{
i
}
f
(
2
)
∈
[
m
]
∖
{
i
}
…
f
(
n
)
∈
[
m
]
∖
{
i
}
⟹
∀
i
∈
[
m
]
:
|
A
i
|
=
(
m
−
1
)
n
∀
1
≤
i
1
<
i
2
<
⋯
<
i
k
≤
m
:
|
A
i
1
∩
A
i
2
∩
⋯
∩
A
i
k
⏟
f
:
[
n
]
→
[
m
]
:
i
1
,
i
2
,
…
,
i
k
∉
I
m
(
f
)
⟹
|
I
m
(
f
)
|
=
m
−
k
|
=
(
m
−
k
)
n
⟹
|
⋃
i
∈
[
m
]
A
i
|
=
∑
k
=
1
m
(
−
1
)
k
−
1
(
m
−
k
)
n
(
m
k
)
Number of surjective functions is equal to:
m
n
−
|
⋃
i
∈
[
m
]
A
i
|
=
m
n
−
∑
k
=
1
m
(
−
1
)
k
−
1
(
m
−
k
)
n
(
m
k
)
Pigeon hole principle
#theorem
If there are
n
pigeons and
n
−
1
pigeon holes
then there are at least
2
pigeons in one of the holes
Proof:
…