Regex and quotient construction
Give regular expressions for the languages below
L={anbm∣(n+m)%2=0}
(aa)∗(bb)∗+a(aa)∗b(bb)∗
L={w∣w does not contain the substring: aba}
b∗a∗((bb)b∗a∗)∗b∗
L={w∣w has an even number of b′s}
(a∗ba∗b)∗a∗
Minimize the number of states in DFA via quotient construction.
Note that all newly marked notes will be highlighted yellow.
Initial setup
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|
0 | | | | | | | | | | |
1 | x | | | | | | | | | |
2 | x | | | | | | | | | |
3 | | x | x | | | | | | | |
4 | x | | | x | | | | | | |
5 | x | | | x | | | | | | |
6 | x | | | x | | | | | | |
7 | x | | | x | | | | | | |
8 | x | | | x | | | | | | |
9 | x | | | x | | | | | | |
Iteration 1:
- (δ(0,a),δ(3,a))=(1,4), which is unmarked, skipped
Iteration 2:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|
0 | | | | | | | | | | |
1 | x | | | | | | | | | |
2 | x | x | | | | | | | | |
3 | | x | x | | | | | | | |
4 | x | | | x | | | | | | |
5 | x | x | | x | | | | | | |
6 | x | | | x | | | | | | |
7 | x | | | x | | | | | | |
8 | x | | | x | | | | | | |
9 | x | | | x | | | | | | |
- (δ(1,a),δ(2,a))=(2,3), which is marked, mark (1,2)
- (δ(1,a),δ(4,a))=(2,5), which is unmarked, skipped
- (δ(1,a),δ(5,a))=(2,0), which is marked, mark (1,5)
- (δ(1,a),δ(6,a))=(2,7), which is unmarked, skipped
- (δ(1,a),δ(7,a))=(2,9), which is unmarked, skipped
- (δ(1,a),δ(8,a))=(2,9), which is unmarked, skipped
- (δ(1,a),δ(9,a))=(2,7), which is unmarked, skipped
Iteration 3:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|
0 | | | | | | | | | | |
1 | x | | | | | | | | | |
2 | x | x | | | | | | | | |
3 | | x | x | | | | | | | |
4 | x | | x | x | | | | | | |
5 | x | x | | x | | | | | | |
6 | x | | x | x | | | | | | |
7 | x | | x | x | | | | | | |
8 | x | | x | x | | | | | | |
9 | x | | x | x | | | | | | |
- (δ(2,a),δ(4,a))=(3,5), which is marked, mark (2,4)
- (δ(2,a),δ(5,a))=(3,0), which is unmarked, skipped
- (δ(2,a),δ(6,a))=(3,7), which is marked, mark (2,6)
- (δ(2,a),δ(7,a))=(3,9), which is marked, mark (2,7)
- (δ(2,a),δ(8,a))=(3,9), which is marked, mark (2,8)
- (δ(2,a),δ(9,a))=(3,7), which is marked, mark (2,9)
Iteration 4:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|
0 | | | | | | | | | | |
1 | x | | | | | | | | | |
2 | x | x | | | | | | | | |
3 | | x | x | | | | | | | |
4 | x | | x | x | | | | | | |
5 | x | x | | x | x | | | | | |
6 | x | | x | x | | | | | | |
7 | x | | x | x | | | | | | |
8 | x | | x | x | | | | | | |
9 | x | | x | x | | | | | | |
- (δ(4,a),δ(5,a))=(5,0), which is marked, mark (4,5)
- (δ(4,a),δ(6,a))=(5,7), which is unmarked, skipped
- (δ(4,a),δ(7,a))=(5,9), which is unmarked, skipped
- (δ(4,a),δ(8,a))=(5,9), which is unmarked, skipped
- (δ(4,a),δ(9,a))=(5,7), which is unmarked, skipped
Iteration 5:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|
0 | | | | | | | | | | |
1 | x | | | | | | | | | |
2 | x | x | | | | | | | | |
3 | | x | x | | | | | | | |
4 | x | | x | x | | | | | | |
5 | x | x | | x | x | | | | | |
6 | x | | x | x | | x | | | | |
7 | x | | x | x | | x | | | | |
8 | x | | x | x | | x | | | | |
9 | x | | x | x | | x | | | | |
- (δ(5,a),δ(6,a))=(0,7), which is marked, mark (5,6)
- (δ(5,a),δ(7,a))=(0,9), which is marked, mark (5,7)
- (δ(5,a),δ(8,a))=(0,9), which is marked, mark (5,8)
- (δ(5,a),δ(9,a))=(0,7), which is marked, mark (5,9)
Iteration 6:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|
0 | | | | | | | | | | |
1 | x | | | | | | | | | |
2 | x | x | | | | | | | | |
3 | | x | x | | | | | | | |
4 | x | | x | x | | | | | | |
5 | x | x | | x | x | | | | | |
6 | x | | x | x | | x | | | | |
7 | x | | x | x | | x | | | | |
8 | x | | x | x | | x | | | | |
9 | x | | x | x | | x | | | | |
- (δ(6,a),δ(7,a))=(7,9), which is unmarked, skip
- (δ(6,a),δ(8,a))=(7,9), which is unmarked, skip
- (δ(6,a),δ(9,a))=(7,7), which is unmarked, skip
We stopped here, given that 7,8,9 doesn’t contains any direct transition on a to any final states.
The final transition table are as follows:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|
0 | | x | x | | x | x | x | x | x | x |
1 | x | | x | x | | x | | | | |
2 | x | x | | | x | | x | x | x | x |
3 | | x | x | | x | x | x | x | x | x |
4 | x | | x | x | | x | | | | |
5 | x | x | | x | x | | x | x | x | x |
6 | x | | x | x | | x | | | | |
7 | x | | x | x | | x | | | | |
8 | x | | x | x | | x | | | | |
9 | x | | x | x | | x | | | | |
We have the following states are equivalent:
Final DFA
Your friend is looking at the formal definition of the pumping lemma and they think something is wrong
L is regular ⟹(∃k∣k>0:(∀x,y,z∣xyz∈L∧∣y∣>k:(∃u,v,w∣y=uvw∧v=ϵ:(∀i∣i≥0:xuviwz∈L))))
They understand the argument it is crafted around, that is, due to the fact that strings are arbitrarily long and a DFA has finite states there must be a segment of accepted strings which “loop” in the machine. However, they claim for the pumping lemma above to hold, L must be infinite, because if L was finite the argument about “looping” no longer holds. Therefore, the pumping lemma only holds when L is infinite.
You can see where your friend is coming from, but they are incorrect. Why? Be precise in your argument, that is, show how if L is finite, then
(∃k∣k>0:(∀x,y,z∣xyz∈L∧∣y∣>k:(∃u,v,w∣y=uvw∧v=ϵ:(∀i∣i≥0:xuviwz∈L))))
evaluate to true.
The Pumping lemma also holds for finite regular language as well.
We need to show that if we assume L is finite, then the pumping lemma is True.
Now, there exists a longest string in L called m, choose k′=∣m∣
Consider the “forall” section ∀x,y,z∣xyz∈L∧∣y∣>k is False:
- For any string xyz∈L we know that ∣xyz∣≤m (since m is the longest string in L)
- since y is a substring of xyz, we must have ∣y∣≤∣xyz∣≤m=k
Given that the antecedent (“if” part) of an implication is false, the entire implication is vacuous truth (when the set is empty)
Therefore, the entire condition is true via vacuous truth (it holds trivially, as there are no strings xyz∈L∣∣y∣>k)
Using the Pumping Lemma, prove the following languages are not regular.
L={anmbman∣n,m≥0}
- The demon first pick k=n=m
- Choose x=ak2,y=bk,z=ak
- pick u=bj,v=br,w=bl such that j+r+l=k,r>0
- pick s′=xuviwz=ak2bj(br)iblak
use i=2 we have
s′=ak2bjb2rblak=ak2brbkak
- That s′∈/L, therefore L is not regular
q.e.d
L={ww∣w∈Σ∗}
- The demon pick k
- Choose x=akb,y=ak,z=b
- pick u=aj,v=ar,w=al such that j+r+l=k,r>0
- pick s′=xuviwz=akbaj(ar)ialb
use i=2 we have
s′=akbaja2ralb=akbarakb
- That s′∈/L, therefore L is not regular
q.e.d
L={ak3∣k≥0}
- The demon pick k
- Choose x=z=ϵ,y=ak3
- pick u=aj,v=ar,w=al such that j+r+l=k3,r>0,j+r≤k
- pick s′=xuviwz=aj(ar)ial
use i=2 we have
s′=aj(ar)2al=ak3+r
We can prove that k3<k3+r<(k+1)3
- Since r>0, we have k3<k3+r
- Given r≤k therefore (k+1)3=k3+3k2+3k+1>k3+k≥k3+r
Therefore, k3+r cannot be a perfect cube
- That s′∈/L, therefore L is not regular
q.e.d
Give the CFGs for the following language
L={anbmck∣n=m+k}
L=L1∪L2 where
- L1={anbmck∣n<m+k}
- L2={anbmck∣n>m+k}
Let grammar G=(V,Σ,R,S) where:
- V={S,S1,S2,A,B} be set of variables
- Σ={a,b,c} be the set of terminals
SS1ABS2CD→S1∣S2→aS1∣aA→aAb∣B→aBc∣ϵ→S2b∣S2c∣C→aCb∣D→aDc∣ϵ
L={anbmck∣n=m+k}
SU→aSc∣U→aUb∣ϵ