How do we check whether a word
is in the language of
the grammar? We start with the start symbol
and use one
production
to replace the nonterminal symbol by the
until we have no nonterminal symbols left - this is called
a derivation. I.e.
in the example
:
![]() |
![]() |
|
![]() |
![]() |
|
![]() |
![]() |
|
![]() |
![]() |
|
![]() |
![]() |
|
![]() |
![]() |
|
![]() |
![]() |
|
![]() |
![]() |
|
![]() |
![]() |
|
![]() |
![]() |
|
![]() |
![]() |
Given any grammar
we define the
relation derives in one step
![]() |
![]() |
|
![]() |
![]() |
![]() |
![]() |
|
![]() |
![]() |
We now say that the language of a grammar
is
given by all words (over
) which can be derived in any number
of steps, i.e.
A language which can be given by a context-free grammar is called a context-free language (CFL).