답변:
아직도 CFL은 고전적 증거의 적응과 함께 믿습니다. 여기 스케치가 있습니다.
고려 L = { X에서 의 Y , Z를 : | x | = | y | = | z | ∧ ( x ≠ y ∨ y ≠ z ) }
하자 L ' = { u는 v에 : | u | ≡ 3 | v | ≡ 3 0 ∧ u 2 | u | / 3 ≠ v | v | / 3 }
| v | / 3 = ( | w | − 3 p / 2 ) / 3 = | 승 | / 3 − p / 2.
따라서 w
만약 Y P ≠ Z의 P
PDA를 사용 하여이 문제를 해결하는 방법은 다음과 같습니다. 제 생각에는 직관적으로 더 명확합니다.
워드 x는
We use the usual trick of using the stack to maintain an integer t
The goal is to use nondeterminism to guess the positions of the two symbols you are comparing, and use the stack to record t:=|x|−3d
We accomplish this as follows: increment t
The nice thing about this is that it should be completely clear how to extend this to arbitrary powers.
Just a different ("grammar oriented") perspective to prove that the complement of {wk} is CF for any fixed k using closure properties.
First note that in the complement of {wk} there is always i such that wi≠wi+1. We focus on w1≠w2 and start with a simple CF grammar that generates:
L={a00...0⏟w1b00...0⏟w2...000...0⏟wk∣|wi|=n}={a0n−1b0n(k−1)−1}
E.g. for k=3, we have L={ab0,a0b000,a00b00000,...}, GL={S→ab0|aX00,X→0X00|0b0}
Then apply closure under inverse homomorphism, and union:
First homomorphism: φ(1)→a,φ(0)→b,φ(1)→0,φ(0)→0
Second homomorphism: φ′(0)→a,φ′(1)→b,φ′(1)→0,φ′(0)→0
L′=φ−1(L)∪φ′−1(L) is still context free
Apply closure under cyclic shifts to L′ to get the set of strings of length kn not of the form wk:
L″=Shift(L′)={u∣u≠wk∧|u|=kn}.
Finally add the regular set of strings whose length is not divisible by k in order to get exactly the complement of {wk}:
L″∪{{0,1}n∣nmodk≠0}={u∣u≠wk}