Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Note: The original author's post had a typo, he has since fixed the original. As a result, this answer does not make sense with the edited post. Additional information about the typo and edit in the comments of this answer. I have included the original post and answer below, in case anyone reading has a similar question about this context-free grammar problem.</strong></p> <p><code>Language: L1 = {a^i b^j | i&lt;j and i,j greater or = 0}</code></p> <p>My solution: </p> <pre><code> S::= aU U::= aU | aUb | end </code></pre> <p>Professor answer: <pre><code> S::= XY X::= aXb | end Y::= bY | b </pre></code></p> <p><strong>Answer:</strong></p> <p>It looks like your answer is backwards from the professor's. Using yours, you can get the string "aaaaa" using <code>U::= aU</code> repeatedly and then <code>U::= end</code>. With the Professor's grammar, you can't get "aaaa" (or any string with more a's than b's). If you look at the Professor's grammar, you'll notice that the only way to add an 'a' is to also add a 'b'. This ensures that there are never more a's than b's. You'll also notice that to get rid of the Y from the S, you have to put in a 'b'. Combining these two rules, we'll always have at least one more 'b' than 'a' because we add one in at the end to get rid of the Y. </p> <p>I believe the Professor's answer is the correct one in this case. the <code>i&lt;j</code> condition results in the condition that there has to be more b's than a's, which is true with the professor's grammar, but not true with yours. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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