Search code examples
computer-scienceautomataformal-languages

generating grammars from a language (formal languages and automata theory)


guys I've been working on this assignment for my formal languages class for a couple of days now, and I'm stuck when it comes to generating grammars for a given language. I don't have an example in my textbook similar to this question to follow, so I was hoping anyone could provide an explanation. thank you. enter image description here


Solution

  • To solve the problem:

    • Understand which words are in L.

    I actually did this part for you: L defines that any words in that language start with any number (including 0) of a or b, followed by 1 or more as, follwoed by one b, maybe followed by any number of as, followed by the same character it started with (or a repetition of them).

    • Read one grammar. See if you can construct words with this grammar that are not in L.
    • See if you can find words in L that can not be constructed by this grammar
    • If you find either, proceed with the next grammar
    • if you find none, the grammar successfully generates L.