COS3701 -
Notes
(Summary)
S - 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...
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 | sarikanaidoo29@gmail.com
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 | sarikanaidoo29@gmail.com
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 | sarikanaidoo29@gmail.com
Distribution of this document is illegal
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller Tutor23. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $3.30. You're not tied to anything after your purchase.