Addis Ababa University College of Natural and Computational Science
Addis Ababa University College of Natural and Computational Science
computational science
Formal Language and Automata Theory assignment
Prepared by:
The algorithm
if a string s ∈ L(G), then there exists a production in the CNF grammar G such that A → BC,
where B is a nonterminal that generates some prefix of s, and C is a nonterminal that generates
the rest. To restate that in the bottom-up fashion befitting of a dynamic programming
algorithm: given a string s, consider any “split” `, r such that ` + r = s. (So, if s = 10001, then one
such split is ` = 10 and r = 001.) We assume we know all the nonterminal that can generate ` and
all the nonterminal that can generate r. To determine the nonterminal that generate s, see if
there is a nonterminal called B that generates `, a nonterminal C that generates r, and a
nonterminal A that generates BC. In that case, we know that A generates s.
-> Compare at most n pairs of previously computed sets: (Xi, i , Xi+1, j ), (Xi, i+1 , Xi+2, j ) … (Xi, j-1 , Xj, j
Purpose
Its application:
S-> AB| BC
A-> BA| a
B->CC |b
C->AB |a
B a A B A
B {B}
A {A,C}
A {A,C}
B {B}
A {A,C}
We observe that s in the cell(1,5) hence ,the string baaba belongs to L(G).