equal - A CFG for Strings with Equal Numbers of as and bs G...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
A CFG for Strings with Equal Numbers of a s and b s G = ( { S } , { a, b } , R, S ) where R has rules: S ε S SS S aSb S bSa Claim : L ( G ) = { x : x has the same # of a ’s and b ’s } (1) x L ( G ) x has the same # of a ’s and b ’s Pf: Easy, every RHS has the same number of a ’s and b ’s. Formal proof by induction on length k of the derivation. (2) x has the same # of a ’s and b ’s x L ( G ) Proof: by induction on | x | (a) | x | = 0: then x = ε and is generated by a single rule (b) | x | = k + 2 4 subcases depending on first and last symbols of x (i) x = ayb for some y Σ * : So | y | = k , and y has the same # of
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 12/24/2011.

Ask a homework question - tutors are online