Skip to content
Snippets Groups Projects
Unverified Commit 44a6f15f authored by Recolic Keghart's avatar Recolic Keghart
Browse files

hw2

parent 33491d41
No related branches found
No related tags found
No related merge requests found
alphabet [01]
start state A
[0] -> AB
[1] -> A
state B
[0] -> C
[1] -> C
state C
[0] -> D
[1] -> D
final state D
[0] -> N
[1] -> N
state AB
[0] -> ABC
[1] -> AC
state ABC
[0] -> ABCD
[1] -> ACD
final state ACD
[0] -> ABD
[1] -> AD
final state AD
[0] -> AB
[1] -> A
final state ABD
[0] -> ABC
[1] -> AC
state AC
[0] -> ABD
[1] -> AD
final state ABCD
[0] -> ABCD
[1] -> ACD
state N
[01] -> N
A AB A
B C C
C D D
D N N
AB ABC AC
ABC ABCD ACD
ACD ABD AD
AD AB A
ABD ABC AC
AC ABD AD
ABCD ABCD ACD
alphabet [01]
start state A
[01] -> A
[0] -> B
state B
[01] -> C
state C
[01] -> D
final state D
4.
remove all x from string, then remove all be from string, then remove all bye from string, you should get empty string.
5.
a. Only infinite regular language can be pumped into this fashion. The regular expr `abc` is a regular language,
and it doesn't violate the theorm (just let M=4). Such language has a maximum string length N, we let M=N+1 so
this theorm is not violated.
Characterize the set of all such machines:
There's no loop in the FSA.
b. let M = (state_of(F) + 1). It always works.
c. Since the FSA has N states, every character in the string is on one state. Since stringLength = L >= M > N,
the character - string mapping should look like: (Pigeon Hole Principle)
c0 c1 c2 c3 ... ck ck+1 ... cm cm+1 ... cL-2 cL-1
s0 s1 s2 ... .. sk sk+1 ... sk sk+1 ... sN-2 sN-1
So there must be some substring [ck ck+1 ... cm] is read by state [sk ... sk].
let u = [c0 ... ck-1]
let x = [ck ... cm-1]
let v = [cm ... cL-1]
return u, x, v
d. Assume, for the sake of contradiction, that the FSA exists.
Let M be the minimum length as in the pumping lemma, for the existing FSA.
I can pick an example string `S = yy^r`, whose `len(S) == 2*M` and `len(y) == M`. The string S is
accepted by the FSA.
Then there is a decomposition `S = uxv` such that `|x| > 0`, `|ux| ≤ M`, and `u x^n v ∈ A`
for all n ≥ 0. So `uv ∈ A` is always true (n=0).
Since |ux| ≤ M, the substring ux must be entirely contained within the first half substring "y" of S.
S:
|----------y----------|----------y^r-----------|
|-----u-----|--x--|------------v---------------|
|-----u-----| |------------v---------------|
^ ^
`uv ∈ A` is always true => `S[len(u)+1] == S[len(S) - len(u)-1]`
Obviously, it's not always true.
This is a contradiction, and consequently the FSA doesn't exist.
6.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment