Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The definition of <code>T</code> in that grammer does indeed appear to be unnecessary complication. <code>T</code> can generate any string of <code>a</code>s and <code>b</code>s, so the simpler definition would have been just as good.</p> <p>I can only guess that the productions are given as they are because of the sausage-factory nature of writing a book.</p> <p><strong>ORIGINAL WRONG ANSWER:</strong></p> <p>They are not equivalent, because <code>X</code> itself cannot be <code>&lt;epsilon&gt;</code>, and <code>T</code> is not any combination of <code>a</code> and <code>b</code>. <code>T</code> can only expand to a palindrome (including the empty palindrome, a single character, or a palindrome with an unpaired central character).</p> <p>If <code>X</code> could be empty, then <code>T</code> could expand to anything, but it can't.</p> <p><em>NOTE</em></p> <p>This answer is based on the supposition that the author’s intention for the production <code>T -&gt; XTX</code> is that the two identical non-terminals in the substitution must represent identical strings of characters. Since I don't have the text to look at, I don't know if this assumption is well-founded except that it is motivated by the question itself. This supposition could be a mistake by the author if that is not the case elsewhere. I think that, in general, this requirement is not true of context-free grammers.</p> <p>The correct productions would be:</p> <pre><code>R -&gt; aRa | bRb | S S -&gt; aTb | bTa T -&gt; aTa | bTb | a | b | &lt;epsilon&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload