# Can I write a regular expression or regular grammar for this language?

Let's say I have a formal language,

a^n b^n which mean ab,aabb,aaabbb

Can I write any regular expression or grammar to create a language like this? I am positive not entirely sure that there is not regex possible, however have no idea about the grammar part?

## 1 Answer

This language is context-free but not regular. It is isomorphic to the problem of matching open and closed parentheses: (n)n which is a well-known non-regular language. To prove this yourself, you would use the pumping lemma for regular languages.

Every regular grammar describes a regular language.
This language is not regular.
Therefore, there cannot be a regular grammar that describes it.