Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since you haven’t specified what your problem is I will just go through what you need to know.</p> <p><strong>Closed under union</strong> - what does it mean? <br> If we have a language <code>L</code> and a language <code>S</code> and both are context-free we know that the union of the languages is also context free. </p> <blockquote> <p>L ∪ S = A Context-free Language</p> </blockquote> <p>See <a href="http://en.wikipedia.org/wiki/Context-free_language#Closure_properties" rel="nofollow noreferrer">this</a> for more closure properties of CFLs and you can find proofs of this on the web if you are interested (or you can try to make your own proof). </p> <p><strong>How can you use this to solve your problem?</strong> <br> You have this language specification (let’s call it <code>L</code>): </p> <blockquote> <p>L = {a<sup>m</sup> b<sup>n</sup> c<sup>p</sup> d<sup>q</sup> : n=q or m &lt;= p or m+n=p+q }</p> </blockquote> <p>You can split this language into 3 other languages:</p> <blockquote> <p>A = {a<sup>m</sup> b<sup>n</sup> c<sup>p</sup> d<sup>q</sup> : n = q } <br> B = {a<sup>m</sup> b<sup>n</sup> c<sup>p</sup> d<sup>q</sup> : m &lt;= p }<br> C = {a<sup>m</sup> b<sup>n</sup> c<sup>p</sup> d<sup>q</sup> : m+n = p+q }</p> </blockquote> <p>It is easy to see that <code>A ∪ B ∪ C = L</code>.</p> <p>If you can prove that A, B and C are context-free you can conclude that L is also context-free.</p> <p><strong>Solution</strong><br> To determine whether a language is context-free, see <a href="https://stackoverflow.com/a/3510165/1401257">this answer</a>. To quote the answer:</p> <blockquote> <p>First, you should attempt to build a <a href="http://en.wikipedia.org/wiki/Context-free_grammar" rel="nofollow noreferrer">context-free grammar</a> that forms the language in subject. A grammar is context-free if left-hand sides of all productions contain exactly one non-terminal symbol. By definition, if one exists, then the language is context-free.</p> <p>An equivalent construct would be a <a href="http://en.wikipedia.org/wiki/Pushdown_automaton" rel="nofollow noreferrer">pushdown automaton</a>. It's the same as DFA, but with a stack available. It may be easier to build than a grammar.</p> </blockquote> <p>So if you can build a CFG (or a PDA) for each of the languages A, B and C, you have solved your problem.</p> <p>Let’s take language <code>A</code>: We need a grammar that generates a string of the form <code>a..b..c..d..</code> where we must have an equal amount of <code>b</code>s and <code>d</code>s.</p> <pre><code>S -&gt; AE A -&gt; Aa | ε E -&gt; bEd | C C -&gt; Cc | ε </code></pre> <p><code>S</code> is the start variable (or non-terminal), <code>ε</code> is the empty string (some people use null symbol <code>^</code> but I have always been told to use <code>ε</code>). This grammar should be able to generate the language <code>A</code> and therefore <code>A</code> is a context-free. (Please let me know if anyone detects an error. I haven't created CFGs in a while).</p> <p>Since this is an exercise I will let you solve the remaining parts, but you should have gotten an idea of how to do it. </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