Theory of Computation - Assignment 1
Theory of Computation - Assignment 1
Theory of Computation - Assignment 1
Answer:
Given: U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, S1 = {2, 3, 5, 7} and S2 = {2, 4, 5, 8, 9}
S¯1 = U – S1 = {1, 4, 6, 8, 9, 10}
Given: S1 = {2, 3, 5, 7}
S2 = {2, 4, 5, 8, 9}
For S = S1 x S2 = {(2, 2), (2, 4), (2, 5), (2, 8), (2, 9), (3, 2), (3, 4), (3, 5), (3, 8), (3, 9), (5, 2), (5, 4), (5, 5), (5, 8), (5,
9), (7, 2), (7, 4), (7, 5), (7, 8), (7, 9)}.
For S = S2 x S1 = {(2, 2), (2, 3), (2, 5), (2, 7), (4, 2), (4, 3), (4, 5), (4, 7), (5, 2), (5, 3), (5, 5), (5, 7), (8, 2), (8, 3), (8,
5), (8, 7), (9, 2), (9, 3), (9, 5), (9, 7)}.
∪ OR
∩ AND
Number of elements in the set (S U T): set (S OR T)
|S ∪ T| = n (S U T) = n {2, 4, 5, 6, 8} = 5
Number of elements in the set (S ∩ T): set (S AND T)
|S ∩ T| = n (S ∩ T) = n {2, 6, 8} = 3
Therefore |S ∩ T| + |S ∪ T| = 3 + 5 = 8
4. What relation between two sets S and T must hold so that |S ∪T | = |S|+|T |?
Answer:
|S ∪ T| = |S| + |T| − |S ∩ T| -- (bars || indicating enclosed set cardinality)
If there is no overlap between the two sets which is S ∩ T = ∅ and in turn |∅| = 0.
Hence: |S ∪ T| = |S| + |T| − |S ∩ T|
= |S| + |T| − |∅|
= |S| + |T| − 0
= |S| + |T|
Therefore, two sets S and T to hold relation |S ∪T | = |S|+|T |
S ∩ T should be ∅
Note: This scenario occurs when there are disjoint sets, which mean no elements were in common in sets.
Case Scenario 1:
T¯ = {1,3,5,6,7,8,9,10}
S∩T¯ = {2, 4, 5, 8, 9} ∩ {1,3,5,6,7,8,9,10} = {5,8,9}
S−T = {2, 4, 5, 8, 9} - {2, 4} = {5,8,9}
Based on both scenarios we can say that for all sets of S and T, S−T=S∩T¯.
6. Prove DeMorgan’s laws, Equations (1.2) and (1.3), by showing that if an element x is in the set on one side
of the equality, then it must also be in the set on the other side of the equality.
Answer:
DeMorgan’s laws were shown below:
S1∪S2¯¯¯¯ = S¯1∩S¯2 --------------- (1.2)
S1∩S2¯¯¯¯= S¯1∪S¯2 --------------- (1.3)
complementation is another basic operation used. Denoted by S¯ is the complement of a set S, consists of all
elements not in S.
If U is universal set specified, then S¯= {x:x∈U, x∉S}
Assumptions:
U = {a, b, c, d, x, y}, S1 = {a, b, y} and S2 = {c, d, y}
S¯1 = U – (S1) = {a, b, c, d, x, y} – {a, b, y} = {c, d, x}
S¯2 = U – (S2) = {a, b, c, d, x, y} – {c, d, y} = {a, b, x}
S1 U S2 = {a, b, y} U {c, d, y} = {a, b, c, d, y}
S1 ∩ S2 = {a, b, y} ∩ {c, d, y} = {y}
S1 ∪ S2¯¯¯¯ = U – (S1 U S2) = {a, b, c, d, x, y} – {a, b, c, d, y} = {x} L.H.S of Equation
S¯1 ∩ S¯2 = {c, d, x} ∩ {a, b, x} = {x} R.H.S of Equation
S1 ∪ S2¯¯¯¯ = S¯1 ∩ S¯2 = {x} Equation 1.2 Proved
A ⊂ B and B ⊂ A ⟺ A = B
Example:
S1 = {1, 2, 3, 4, 5} and S2 = {5, 4, 3, 2, 1}
S1 ∪ S2 = {1, 2, 3, 4, 5} ∪ {5, 4, 3, 2, 1} = {1, 2, 3, 4, 5} 1
S1 ∩ S2 = {1, 2, 3, 4, 5} ∩ {5, 4, 3, 2, 1} = {1, 2, 3, 4, 5} 2
From 1 and 2 we can say S1 ∪ S2 = S1 ∩ S2
Hence, we can conclude S1 = S2.
2. Use induction on n to show that |un| = n |u| for all strings u and all n.
Answer:
un is n lots of u string concatenated into one string.
If we assume n = 1, |u1|=|u|=1|u|
Step of Induction:
Suppose |un| = n |u|
Then |un+1| = |un| + |u| (by cardinality string definition and un)
= n |u| + |u| (by inductive hypothesis)
= (n+1) |u| (by cardinality string definition)
|un+1| = (n+1) |u|
Therefore, |un| = n |u|
5. Let L = {ab, aa, baa}. Which of the following strings are in L*: abaabaaabaa, aaaabaaaa, baaaaabaaaab,
baaaaabaa? Which strings are in L4?
Answer:
The following were the strings in L4
aaaabaaaa, baaaaabaa