A context-free grammar with start symbol , terminal alphabet , and the following productions generates all binary palindromes:
Each production preserves the palindrome property: it either supplies a central string of length zero or one, or wraps the same symbol around a shorter palindrome. This proves soundness by structural induction on the parse tree.
Conversely, any palindrome of length at least two has equal first and last symbols. Remove them to obtain a shorter palindrome, apply mathematical induction on length, and then use the corresponding wrapping production. The three base cases are , , and , proving completeness.
Use start symbol and an auxiliary symbol in the context-free grammar
The symbol generates exactly , so every generated string has the three explicitly displayed ones. Conversely, any string with at least three ones can be split at any three of them as , and each can be generated by . This proves both inclusions. For example,
by taking the four substrings to be , , , and respectively.

Articles by others on the same topic (0)

There are currently no matching articles.