Notes
(Summary)
, Stuvia.com - The study-notes marketplace
Context Free Language (CFL)
CFL is a language generated by some Context Free Grammer(CFG)
CFGs
CFG formal definition:
Nonterminals are capital letters and terminals (since they can terminate, i.e end)
are small values.
Example:
So the general formulae is 𝑎𝑛 which is the language a*. Thus this CFG
generated the language a*. Remember a* means any certain number of a’s.
a* means any number of a’s. Can be 0 as well.
Note: -> is used in production and means ‘can be replaced by’ but the
double arrow means ‘çan develop into’.
Example:
Downloaded by: examsummaries29 |
Distribution of this document is illegal
, Stuvia.com - The study-notes marketplace
This is also the language a*. So both CFG’s in the 1 st example and 2 nd example
generated the language a*. This illustrated that more than 1 CFG can generate
the same language.
Example
The language generated by the CFG is the set of all possible strings of the
letters a and b except for the null string. Thus it is not (a+b)* because this
includes the null string.
In my own words: So we can start of with either making S aS or bS. Then again
we can replace that S with either aS or bS again for any number of times. Then
we can end it by replacing S with either a or b which makes the language all
possible strings of the letters a and b except for the null string.
Example
Downloaded by: examsummaries29 |
Distribution of this document is illegal
, Stuvia.com - The study-notes marketplace
From the start symbol S we can go to either X or Y. Notice then that X can only
produce the empty string .
Y can produce the same language as the previous example, i.e. all strings of a
and b excluding the empty string.
So adding then X production and Y productions then this CFG generates the
language (a+b)*. (a+b)* is any strings of a and b including the empty string .
Example
Also the word ab can be generated like this:
S=> aS
=>ab (S->b)
Downloaded by: examsummaries29 |
Distribution of this document is illegal