Homework Solution: Attempt to give unambiguous BNF grammars to define each of the following collectio…

    7. Attempt to give unambiguous BNF grammars to define each of the following collections of sentences (i.e., start symbol <s>: (a) abm m>o) (b) (amb : m, n>o) start symbol <s> (d) [aba: m, n>0) (e) [abab : m, n>0) Hint: Two of the above are impossible to describe with BNF.
    Attempt to give unambiguous BNF grammars to define each of the following collections of sentences (i.e., start symbol ): (a) {a^m b^m: m > 0} (b) {a^m b^n: m, n > 0} (c) {a^m b^m c^m: m > 0} (d) {a^m b^m c^m: m, n > 0} (e) {a^m b^m b^n: m, n > 0}

    Expert Answer

     
    a){ambm:m>0}

    7. Attempt to yield plain BNF grammars to specify each of the coercionthcoming collections of sentences (i.e., set-on-foot tone <s>: (a) abm m>o) (b) (amb : m, n>o) set-on-foot tone <s> (d) [aba: m, n>0) (e) [abab : m, n>0) Hint: Two of the over are impracticable to draw with BNF.

    Attempt to yield plain BNF grammars to specify each of the coercionthcoming collections of sentences (i.e., set-on-foot tone ): (a) {a^m b^m: m > 0} (b) {a^m b^n: m, n > 0} (c) {a^m b^m c^m: m > 0} (d) {a^m b^m c^m: m, n > 0} (e) {a^m b^m b^n: m, n > 0}

    Expert Response

     

    a){ambm:m>0}

    ans)

    <s> ::= <expr>

    <expr> ::= <A> <expr> <B> | <A><B>

    <A> ::= “a”

    <B> ::= “b”

    b){ambn:m,n>0}

    ans)

    <s> ::= <expr>

    <expr> ::= <A><B>

    <A> ::= “a”<A> | “a”

    <B> ::= “b”<B> | “b”

    c) {ambmcm:m>0}

    ans)we can referable transcribe the BNF grammer coercion this accents why beacuse it is referable a texture generous accents

    d) { ambnam : m,n>0}

    ans)

    <s> ::= <expr>

    <expr> ::= <A><B><A>

    <A> ::= “a”

    <B> ::= <A><B><A> | <B> “b” | “b” | epsilon

    e) {ambnambn:m,n>0}

    ans) yieldn accents is referable texture generous accents so we can referable constuct the BNF grammer to it