Uploaded by Vball Xxx

A3

advertisement
CIS 3150 Fall 2022 – A3
October 24, 2022
Andrew Debyl
1096633
𝑛
The size of the power set = 2
The size of concatenation of L and L = 2n
To get the same size language, n can only be 1 and 2.
Although, the size of concatenation with one element only using {0} is: 1 (while the power set is
2), and the size of concatenation with two elements only using {0} is: 2 (while the power set is
4), because there will be duplicates.
Therefore, no language exists.
The language is not regular because it requires the expression or automata to save information
about what x is. They do not have that property. Although, this language is context-free and can
be recognized by a grammar.
Strings: ∊, abba, aaaaa, b
Description: Every combination (string) of {a, b} including the empty string.
Strings: aaaaa
Description: All strings with at least three a’s together in it.
Strings: aaaaa
Description: All strings with ‘x>0’ amount of a’s, and doesn’t include ‘aa’.
Strings: b, aaaaa
Description:
No, because the string: aaabbbaa cannot be generated by this grammar but it is in the
language.
S → aTa | bTb
T → aT | bT | ∊
S → aTaTa | bTbTb | aaa | bbb
T → aP | bP
P → aT | bT | ∊
S → aSP0 | T
T → aRP | ∊
P→c|∊
R→b|∊
S → R0T0P
T → 0T0 | W
W → 1Q1 | 1
Q → 0Q | 1Q | Q1 | Q0 | e
R → Q1 | e
P → 1Q | e
Union
Given context-free languages L1 and L2 we must show that L = L1 ∪ L2 is also context-free.
Since L1 and L2 are context-free there exists a CFG that recognizes them:
𝐿1 = (𝑉1Σ1𝑅1𝑆1)
𝐿2 = (𝑉2Σ2𝑅2𝑆2)
So, we can form a grammar L such that 𝐿 = 𝐿1 ∪ 𝐿2
𝐿 = (𝑉1∪ 𝑉2 ∪ {𝑆}, Σ = Σ1 ∪ Σ2, 𝑅 = 𝑅1 ∪ 𝑅2 ∪ {𝑆 → 𝑆1} ∪ {𝑆 → 𝑆2}, 𝑆}
Therefore context-free languages are closed under union.
Concatenation
Given context-free languages L1 and L2 we must show that L = L1 ◦ L2 is also context-free.
Since L1 and L2 are context-free there exists a CFG that recognizes them:
𝐿1 = (𝑉1Σ1𝑅1𝑆1)
𝐿2 = (𝑉2Σ2𝑅2𝑆2)
So, we can form a grammar L such that 𝐿 = 𝐿1 ◦ 𝐿2
𝐿 = (𝑉1∪ 𝑉2 ∪ {𝑆}, Σ = Σ1 ∪ Σ2, 𝑅 = 𝑅1 ∪ 𝑅2 ∪ {𝑆 → 𝑆1𝑆2}, 𝑆}
Therefore context-free languages are closed under concatenation.
Star
Given context-free languages L we must show that L = L* is also context-free.
Since L is context-free there exists a CFG that recognizes it:
𝐿 = (𝑉, Σ, 𝑅, 𝑆)
So, we can form a grammar L such that 𝐿 = 𝐿 *
𝐿 = (𝑉1 ∪ {𝑆}, Σ = Σ1, 𝑅 = 𝑅1 ∪ {𝑆 → 𝑆1𝑆2} ∪ {𝑆 → ϵ}, 𝑆}
Therefore context-free languages are closed under star.
Assume that L is context-free, and that L is the intersection of A and B.
𝑧 𝑧 𝑥
𝐴 = {𝑎 𝑏 𝑐 | 𝑥, 𝑧 ≥ 0}
𝑧 𝑥 𝑥
𝐵 = {𝑎 𝑏 𝑐 | 𝑥, 𝑧 ≥ 0}
𝑥 𝑥 𝑥
Therefore 𝐿 = {𝑎 𝑏 𝑐 | 𝑥 ≥ 0} and as stated above, this is not context-free so it is a
contradiction.
Step 1:
P→S
S → TTS | a
T → bTb | aa | ∊
Step 2:
P→S
S → TTS | a | TS
T → bTb | aa | bb
Step 3:
P → TTS | a | TS
S → TTS | a | TS
T → bTb | aa | bb
Step 4:
P → TB | a | TS
S → TB | a | TS
T → bC | aa | bb
B → TS
C → Tb
Step 5:
P → TB | a | TS
S → TB | a | TS
T → DC | EE | DD
B → TS
C → TD
D→ b
E→a
Download