Answer
Finding a phrase-structure grammar for each of these languages.
a) the set of all bit strings containing an even number
of 0s and no 1s
b) the set of all bit strings made up of a 1 followed by an
odd number of 0s
c) the set of all bit strings containing an even number
of 0s and an even number of 1s
d) the set of all strings containing 10 or more 0s and no
1s
e) the set of all strings containing more 0s than 1s
f ) the set of all strings containing an equal number of 0s
and 1s
g) the set of all strings containing an unequal number
of 0s and 1s
Work Step by Step
a) S → 00S, S → λ
b) S → 10A, A → 00A, A → λ
c) S → AAS, S → BBS, AB → BA, BA → AB, S → λ, A → 0, B → 1
d) S → 0000000000A,A → 0A,A → λ
e) S → AS, S → ABS, S → A, AB → BA, BA → AB, A → 0, B → 1
f) S → ABS, S → λ, AB → BA, BA → AB, A → 0, B → 1
g) S → ABS, S → T , S →U, T →AT , T →A, U →BU, U →B, AB →BA,
BA → AB, A → 0, B → 1