Uploaded by J.R. Drazypoffs

Assignment1 Discrete Maths

advertisement
1. There are two webcams, X and Y that can automatically switch On or Off at any given time to
record a live video streaming session. To ensure the smooth recording session, the live feed
input system is programmed with certain criteria. The conditions set are; if webcam X and
webcam Y are switch on, the input system can enable the recording input and the live
session will start. If either webcam X or webcam Y is switched on, the input system cannot
enable the recording and the live session will stop. In all other conditions, the input system
will enable the recording and the live session streaming will commence. a. Based on the
scenario above, generate a simple pseudocode with a function that has x and y as inputs
and livestream and nolivestream as outputs.
a. On a particular day, Prof. Z is intending to have a live session discussion with his
students. He informs his students before the session that “If webcam X works while
the other doesn't or the other way round, I’m afraid that the live discussion session
would not take place”. Represent it in a simple pseudocode the scenario of what was
said by Prof. Z.
b. Translate the pseudocodes in part (a.) and (b.) into propositional logic statements.
c. Using a Truth table, determine if what Prof. Z had stated is consistent with what the
input system was programmed to do.
2. There is an island with two mythical creatures, the Komos and the Dragos. Komos loves
eating visitors to the island while Dragos hates to eat visitors. One fine day, you
mysteriously end up on the island and encounter two creatures, Blue and Red. The Blue
creature smiles and tell you, “Don’t be afraid! We both are not human eaters”. Determine, if
possible, whether the Blue and Red creatures is a Komos or a Dragos.
3. Let A, B and C denotes the sets with the universal set, U. Prove the following equivalence:
𝐴∩(𝐡∪𝐢)=(𝐴∩𝐡)∪(𝐴∩𝐢).
Let A and B denote the sets with the universal set, U. The symmetric difference of two sets, A
& B is denoted by A Δ B and is defined as such:
A Δ B = (A-B) ∪ (B-A)
4. Prove using Set Builder notation that an equivalent definition of the symmetric difference of
two sets A & B is
A Δ B = (A∪B) − (A∩B)
5. In a set of integers between the numbers 100 and 100,000, how many of these numbers are
divisible by 2, 5, 9 and 13?
6. Find the result for the following double summation.
Question1
1a. Pseudocode
Start
x ο‚™ webcam x
y ο‚™ webcam y
function checkLivestream(x,y)
if (x=1 and y=1)
return livestream
if (x=1 and y=0)
return nolivestream
if (x=0 and y=1)
return nolivestream
if (x=0 and y=0)
return livestream
end
1b. Live discussion pseudocode
Start
x ο‚™ webcam x
y ο‚™ webcam y
function check live discussion(x,y)
if x=1 and y=1
return live discussion
if x=1 and y=0
return no live discussion
if x=0 and y=1
return no live discussion
if x=0 and y=0
return live discussion
end
1c.
Let:
X = webcam x is turned on
Y = webcam y is turned on
L = the livestream will occur
D = the live discussion will occur
For part 1a:
𝑋∧π‘Œ =𝐿
¬π‘‹ ∧ π‘Œ = ¬πΏ
𝑋 ∧ ¬π‘Œ = ¬πΏ
¬π‘‹ ∧ ¬π‘Œ = 𝐿
For part 1b:
¬π‘‹ ∧ π‘Œ = ¬π·
𝑋 ∧ ¬π‘Œ = ¬π·
𝑋∧π‘Œ =𝐷
¬π‘‹ ∧ ¬π‘Œ = 𝐷
1d.
X
Y
¬π‘‹
¬π‘Œ
T
T
F
F
T
F
T
F
F
F
T
T
F
T
F
T
𝑋∧π‘Œ
T
F
F
T
¬π‘‹ ∧ ¬π‘Œ
T
F
F
T
𝑋 ∧ ¬π‘Œ
F
T
T
F
¬π‘‹ ∧ π‘Œ
F
T
T
F
Based on the truth table above, the truth values of X ∧ Y = ¬X ∧ ¬Y and X ∧ ¬Y=
¬X ∧ Y, therefore what Prof. Z had stated is consistent with what the input
system was programmed to do.
2.
3.
𝑙𝑒𝑑 π‘₯ 𝑖𝑛 𝐴 ∩ (𝐡 ∪ 𝐢),
π‘‡β„Žπ‘’π‘› π‘₯ 𝑖𝑠 𝑖𝑛 𝐴 π‘Žπ‘›π‘‘ (𝐡 ∪ 𝐢),
𝑙𝑒𝑑 π‘₯ 𝑖𝑛 (𝐴 ∩ 𝐡) ∪ (𝐡 ∩ 𝐢),
π‘‡β„Žπ‘’π‘› π‘₯ 𝑖𝑠 𝑖𝑛 𝐴 ∩ (𝐡 ∪ 𝐢),
𝐼𝑓 π‘₯ 𝑖𝑠 𝑖𝑛 𝐡, π‘‘β„Žπ‘’π‘› π‘₯ 𝑖𝑠 𝑖𝑛 (𝐴 ∩ 𝐡)
𝐼𝑓 π‘₯ 𝑖𝑠 𝑖𝑛 𝐢, π‘‘β„Žπ‘’π‘› π‘₯ 𝑖𝑠 𝑖𝑛 (𝐴 ∩ 𝐢)
∴ (𝐴 ∩ 𝐡) ∪ (𝐴 ∩ 𝐢) ⊆ 𝐴 ∩ (𝐡 ∪ 𝐢)
∴ π‘₯ 𝑖𝑠 𝑖𝑛 (𝐴 ∩ 𝐡) ∪ (𝐴 ∩ 𝐢)
𝐴 ∩ (𝐡 ∪ 𝐢) ⊆ (𝐴 ∩ 𝐡) ∪ (𝐴 ∩ 𝐢)
Therefore, 𝐴 ∩ (𝐡 ∪ 𝐢) ⊆ (𝐴 ∩ 𝐡) ∪ (𝐴 ∩ 𝐢)
4.
π΄βˆ†π΅ = (𝐴 − 𝐡) ∪ (𝐡 − 𝐴)
𝐿𝑒𝑑 π‘₯ ∈ (𝐴 − 𝐡) ∪ (𝐡 − 𝐴)
π‘Šβ„Žπ‘’π‘› π‘₯ ∈ (𝐴 ∪ 𝐡) − (𝐴 ∩ 𝐡)
π‘₯ ∈ (𝐴 ∩ 𝐡)π‘Žπ‘›π‘‘ π‘₯ ∉ (𝐴 ∩ 𝐡)
(π‘₯ ∈ 𝐴 π‘Žπ‘›π‘‘ π‘₯ ∉ 𝐡) π‘œπ‘Ÿ (π‘₯ ∈ 𝐡 π‘Žπ‘›π‘‘ π‘₯ ∉ 𝐴)
(π‘₯ ∈ 𝐴 π‘œπ‘Ÿ π‘₯ ∈ 𝐡) π‘Žπ‘›π‘‘ (π‘₯ ∉ 𝐡 π‘œπ‘Ÿ π‘₯ ∉ 𝐴)
π‘₯ ∈ (𝐴 ∪ 𝐡) − (𝐴 ∩ 𝐡)
(π‘₯ ∈ 𝐴 π‘œπ‘Ÿ π‘₯ ∈ 𝐡) π‘Žπ‘›π‘‘ (π‘₯ ∉ 𝐡 π‘œπ‘Ÿ π‘₯ ∉ 𝐴)
(π‘₯ ∈ 𝐴 π‘Žπ‘›π‘‘ π‘₯ ∉ 𝐡) π‘œπ‘Ÿ (π‘₯ ∈ 𝐡 π‘Žπ‘›π‘‘ π‘₯ ∉ 𝐴)
π‘₯ ∈ (𝐴 − 𝐡) ∪ (𝐡 − 𝐴)
∴ (𝐴 − 𝐡) ∪ (𝐡 − 𝐴) ⊆ (𝐴 ∪ 𝐡) − (𝐴 ∩ 𝐡)
(𝐴 ∪ 𝐡) − (𝐴 ∩ 𝐡) ⊆ (𝐴 − 𝐡) ∪ (𝐡 − 𝐴)
Therefore, (𝐴 − 𝐡) ∪ (𝐡 − 𝐴) = (𝐴 ∪ 𝐡) − (𝐴 ∩ 𝐡)
5.
100ο‚š100,000
a. For numbers divisible by 2 less than 100,000
100,000
⌋
2
= 50,000
=⌊
Numbers divisible by 2 that is less than 100
100
⌋−1
2
= 50 − 1
= 49
=⌊
= 50,000 − 49
= 49,951
Therefore, there are 49,951 numbers that are divisible by 2 whose values
are less than 100,000 and more than or equal to 100.
b. For numbers divisible by 5 that is less than 100,000
100,000
=⌊
⌋
5
= 20,000
Numbers divisible by 5 that is less than 100
100
=⌊
⌋−1
5
= 20 − 1
= 19
= 20,000 − 49
= 19,981
Therefore, there are 19,981 numbers that are divisible by 5 whose values
are less than 100,000 and more than or equal to 100.
c. For numbers divisible by 9 that is less than 100,000
100,000
=⌊
⌋
9
= 11,111
Numbers divisible by 9 that is less than 100
100
=⌊
⌋
9
= 11
= 11,111 − 11
= 11,100
Therefore, there are 11,100 numbers that are divisible by 9 whose values
are less than 100,000 and more than or equal to 100.
d. For numbers divisible by 13 that is less than 100,000
100,000
=⌊
⌋
13
= 7692
Numbers divisible by 13 that is less than 100
100
=⌊
⌋
13
=7
= 7692 − 7
= 7685
Therefore, there are 7625 numbers that are divisible by 13 whose values
are less than 100,000 and more than or equal to 100.
e. For numbers divisible by 2, 5, 9, and 13 that is less than 100,000
Prime factors:
2=2
5=5
9 =3×3
13 = 13
LCM of 2, 5, 9, and 13 = 2 × 32 × 5 × 13
=1170
⌊
100,000
⌋ = 85
1170
Therefore, there are 85 numbers that are divisible by 2, 5, 9, and 13 whose
values are less than 100,000 but more than or equal to 100.
6.
𝑗
5
∑ ∑ 3𝑖𝑗
𝑖=1 𝑗=1
𝑗
= ∑[3𝑖 + 3(2)𝑖 + 3(3)𝑖 + 3(4)𝑖 + 3(5)𝑖]
𝑖=1
𝑗
= ∑[3𝑖 + 6𝑖 + 9𝑖 + 12𝑖 + 15𝑖]
𝑖=1
𝑗
= ∑[45𝑖]
𝑖=1
𝑗
= 45 ∑ 𝑖
𝑖=1
Using Sum Formula
𝑗
1
∑ 𝑖 = 𝑗(𝑗 + 1)
2
𝑖=1
1
= 45 ( 𝑗(𝑗 + 1))
2
45𝑗(𝑗 + 1)
=
2
Download