





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






This lecture covers Linear Bounded Automata, an interesting compromise in power be- tween Turing machines and the simpler automata (DFAs, NFAs, PDAs). We will use LBAs to show two CFG grammar problems (equality and generating all strings) are undecidable. This material follows the second half of Sipser section 5.1.
1 Linear bounded automatas
A linear bounded automata (LBA) is a TM whose head never moves off the tape section occupied by the input string. That is, an LBA is a TM that uses only the tape space occupied by the input. An equivalent definition of an LBA is that it uses only k times the amount of space occupied by the input string, where k is a constant fixed for the particular machine. To simulate k tape cells with a single tape cell, increase the size of the tape alphabet Γ. E.g. the new tape alphabet has symbols that are k-tuples of the symbols from the old alphabet. A lot of interesting algorithms are LBAs, because they use only space proportional to the length of the input. (This assumes you pick algorithms that use space efficiently.) Examples include ADFA, ACFG, EDFA, ECFG, s − t graph reachability, and many others. When an LBA runs, a transition off the righthand edge of the input area cause the input to be rejected. Or maybe the read head simply sticks on the rightmost input position. You can define them either way and it won’t matter for what we’re doing here.
2 LBA halting is decidable
Suppose that a given LBA M (which is a TM, naturally) has
Then M can be in at most
α(n) =
tape content ︷ ︸︸ ︷
head position ︷︸︸︷
controller state ︷︸︸︷
configurations. Here is the shocker: If an LBA runs more than α(n) steps, then it must be looping. As such, given an LBA M and a word w (with n characters), we can simulate it for α steps. If it does not terminate by then, then it must be looping, and as such it can never stop on its input. Thus, an LBA that stops on input w must stop in at most α(|w|) steps. This implies that
ALBA =
〈M, w〉
∣ M^ is a^ LBA^ and^ M^ accepts^ w
is decidable. Similarly, the language
HaltLBA =
〈M, w〉
∣ M^ is a^ LBA^ and^ M^ stops on^ w
is decidable. We formally prove one of the above claims. The other one follows by a similar argumen- tation.
Claim 2.1 The language ALBA is decidable.
Proof: Indeed, our decider would receive as input 〈M, w〉, where M is an LBA. Let n = |w|. By the argumentation above, if M accepts w, then it does it in at most α(n) steps (see Eq. (1)). As such, simulate M on the input w for α(n) steps, using the universal TM simulator UTM. If the simulation accepts, then accept. If the simulation rejects, then reject. Now, if the simulation did not accept after simulating M for α(n) steps, then M is looping forever on w, and so we reject. Of course, if during the simulation M decides to move past the end of the input, it’s not an LBA, and as such we reject the input.^1
In light of the above claim, one might presume that all “natural” languages on LBAs are decidable, but surprisingly, this is not the situation. Indeed, consider the language of all empty LBAs; that is,
ELBA =
∣ M^ is a^ LBA^ and^ L(M^ ) =^ ∅
The language ELBA is actually undecidable. (^1) For the very careful reader, Sipser handles this case slightly differently. His encoding of M would specify
that the machine is supposed to be an LBA. Attempts to move off the input region would cause the read head to stay put.
where α and β are two strings. Naturally, Ci+1 is the next configuration in the input trace t. Since VrfM,w has the code of M inside it (as a built-in constant), it knows what δM (q, b), the transition function of M , is. Say it knows that δM (q, b) = (q′, c, R). If our input is a valid trace, then Ci+1 is supposed to be
Ci+1 = αacq′β.
To verify that Ci and Ci+1 do match up in this way, the TM VrfM,w goes back and forth on the tape erasing the parts of Ci and Ci+1 that must be identical. We can not erase these symbols: we will need to keep Ci+1 around so we can check it against Ci+2. So instead we translate each letter a into a special version of this character ̂a.^3 After we have marked all the identical characters, we’ve verified this pair of configurations except for the middle 2 − 3 letters (depending on whether this was a left or right move). So the tape in this stage looks like
Ci ︷ ︸︸ ︷ αaqbβ #
Ci+ ︷ ︸︸ ︷̂ αacq′^ β̂ #...
We have verified that the prefix of Ci (i.e., α) is equal to α̂ , and the suffix of Ci (i.e., β) is equal to the suffix of Ci+1 (i.e., β̂ ). So only thing that remains to be verified is the middle part, which can be easily done since we know M ’s transition function. After that, the verifier removes the hats from the characters in Ci+1 and moves right to match Ci+1 against Ci+2. If it gets to the end of the trace and all these checks were successful, the verifier VrfM,w accepts the input trace t.
Lemma 3.1 Given a TM M and a string w, one can build a verifier VrfM,w, such that given an accepting trace t, the verifier accepts t, and no other string. Note, that VrfM,w is a decider that always stops. Moreover, VrfM,w is a LBA.
Proof: The details of VrfM,w are described above. It is easy to see that VrfM,w never goes on the portion of the tape which are not parts of its original input t. As such, VrfM,w is a LBA.
Theorem 3.2 The language ELBA is undecidable.
Proof: Proof by reduction from ATM. Assume for the sake of contradiction that ELBA is decidable, and let ELBA−Decider be the TM that decides it. We will build a decider Decider 5 - ATM for ATM.
(^3) We have omitted some details about how to handle moves near the right and left ends of the non-blank tape area. There details are tedious but easy to fill in, and the reader should verify that they know how to fill in the missing details.
Decider 5 - ATM
〈M, w〉
Check that 〈M 〉 is syntactically correct TM code Compute 〈VrfM,w〉 from 〈M, w〉. res ← ELBA−Decider
〈VrfM,w〉
if res == accept then reject else accept
Since we can compute 〈VrfM,w〉 from 〈M, w〉, it follows that this algorithm is a decider. Furthermore, given 〈M, w〉 such that M accepts w, then there exists an accepting trace t for
M accepting w, and as such, L(VrfM,w) 6 = ∅. As such ELBA−Decider
〈VrfM,w〉
rejects its
input, which imply that Decider 5 - ATM accepts 〈M, w〉.
Similarly, if M does not accept w, then L(VrfM,w) = ∅. As such, ELBA−Decider
〈VrfM,w〉
accepts its input, which imply that Decider 5 - ATM rejects 〈M, w〉. Thus Decider 5 - ATM is indeed a decider for ATM, but this is impossible, and we thus conclude that our assumption, that ELBA is decidable, was false, implying the claim.
4 The language of a context-free grammar generates
all strings is undecidable
Consider the language
ALLCFG =
∣ G^ is a^ CFG, and^ L(G) = Σ∗
This language seems like it should be decidable, since ECFG was decidable. But it is not. It is a fairly delicate matter whether questions about CFGs are decidable or not. The proof technique is similar to what we used for ELBA.
The idea is that given M and w to build a verifier to an accepting traces for M and w. Here the verifier is going to be a CFG. The problem is, if you think about it, is that there is no way that a CFG can verify a trace, as the checks needed to be performed are too complicated to be performed by a CFG. Luckily, we can generate a CFG VrfGM,w that would accept all the traces that are not accepting traces for M on w. Indeed, we will build several CFGs, each one “checking” one condition, and their union would be the required grammar. As such, L(VrfGM,w) is the set of all strings, if and only if, M does not have an accepting trace for w. The alphabet of our grammar is going to be
Σ = Γ ∪ Q ∪ {#} ,
Interestingly, the PDA P is deterministic, and as such, we can complement it (this is not true of a general PDA because of the nondeterminism). Thus, we have a PDA P that accepts X#Y R# iff the configuration X does not imply the configuration Y. Now, its easy to modify this PDA so that it accepts the language
∣ Configuration^ X^ does not imply configuration^ Y
which clearly contains only invalid traces. Similarly, we can build a PDA that accepts the language
∣ Configuration X does not imply configuration Y
Putting these two PDAs together, yield a PDA that accepts all strings containing two con- secutive configurations, such that the first one does not imply the second one. Now, since we a PDA for this language, we clearly can build a CFG GM that accepts all such strings.
Strings with invalid initial configurations. Consider all traces having invalid initial configurations. Clearly, they are generated by strings of the form
(Σ \ {#, q 0 })∗^ #Σ∗.
Clearly, one can generate a grammar GI that accepts these strings.
Strings with invalid final configurations. Consider all traces having invalid initial configurations. Clearly, they are generated by strings of the form
Σ∗#(Σ \ {#, qacc})∗^.
Clearly, one can generate a grammar GF that accepts these strings.
Putting things together. Clearly, all invalid (i.e., non-accepting) traces of M on w are generated by the grammars GI , GM , GF. Thus, consider the context free grammar GM,w formed by the union of GI , GM , GF. When M does not accept w, there is no accepting trace for M on w, so L(GM,w) (the strings that are not accepting traces) is Σ∗. When M accepts w, there is an accepting trace for M on w, so L(GM,w) (the strings that are not accepting traces) is not equal to Σ∗.
Theorem 4.1 The language
∣ G^ is a^ CFG, and^ L(G) = Σ∗
is undecidable.
Proof: Let us assume, for the sake of contradiction, that the language ALLCFG is decid- able, and let deciderAllCFG be its decider. We will now reduce ATM to it, by building a decider for it as follows.
Decider 6 - ATM
〈M, w〉
Check that 〈M 〉 is syntactically correct TM code Compute 〈GM,w〉 from 〈M, w〉, as described above. res ← deciderAllCFG
〈GM,w〉
if res == accept then reject else accept
Clearly, this is a decider, and indeed if M accepts w, then there exists an accepting trace t showing it. As such, L(GM,w) = Σ∗^ \ {t} 6 = Σ∗. Thus, deciderAllCFG rejects 〈GM,w〉, and thus Decider 6 - ATM accepts 〈M, w〉. Similarly, if M rejects w then L(GM,w) = Σ∗, and as such deciderAllCFG accepts 〈GM,w〉. Implying that Decider 6 - ATM rejects 〈M, w〉. Thus, Decider 6 - ATM is a decider for ATM, which is impossible. We conclude that our assumption, that ALLCFG is decidable, is false, implying the claim. This needs some stuff filled in, Sariel Now, suppose that ALLCFG is decided by R. We construct a decider for ATM as follows:
From the undecidability of ALLCFG, we can quickly deduce that
∣ G^ and^ H^ are^ CFGs and^ L(G) =^ L(H)
is undecidable. This proof is almost identical to the reduction of ETM to EQTM that we saw in lecture 21.
Theorem 4.2 The language EQCFG is undecidable.
Proof: Proof by contradiction. Suppose that EQCFG is decidable and let deciderEqCFG be a TM that decides it. Given an alphabet Σ, it is not hard to construct a grammar FΣ that generates all strings in Σ∗. E.g. if Σ = {c 1 , c 2 ,... ck}, then we could use rules:
S → XS |
X → c 1 | c 2 |... | ck
As such, here is a TM deciderAllCFG that decides ALLCFG.