-1

I need to find the grammar for the following language:

L = {a^n w w^R b^n; n >= 1, w є {a,b} and w^R is the reverse of w}

I'm really stuck on what "w є {a,b}" and "reverse of w" means.

Could someone explain this to me?

davai
  • 11
  • 4

1 Answers1

2

w є {a,b} means that w is in the set {a, b}, that is, w is either a or b. What I think they meant is that w is a string consisting of as and/or bs.

"reverse of w" means a string consisting of the same characters as w , but in the opposite order. If w = abbb, then w^R = bbba.

L, then, is the set of strings starting with some number of as, followed by a palindrome consisting of an even number of as and bs, and ending with the same number of bs as there were as preceding the palindrome.

For example, aaaabbabbbb would be in L: it starts with 4 as, ends with 4 bs, and has abba (w = ab, w^R = ba) in the middle.

aaaaababbbb would not be in L; it has equal numbers of as and bs at the beginning and end of the word, but aba cannot be decomposed into a string followed by its own reversal.

chepner
  • 497,756
  • 71
  • 530
  • 681