




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Some concept of Automata and Complexity Theory are Administrivia, Closure Properties, Context-Free Grammars, Decision Properties, Deterministic Finite Automata, Intractable Problems, More Undecidable Problems. Main points of this lecture are: Context-Free Grammars, Formalism, Derivations, Backus-Naur Form, Left- and Rightmost Derivations, Powerful, Nested Structures, Programming Languages, Strings, Recursive Rules
Typology: Slides
1 / 28
This page cannot be seen from the preview
Don't miss anything!
1
Formalism Derivations
Backus-Naur Form
Left- and Rightmost Derivations
2
is a notation
for describing languages.
It is more powerful than finite automata or RE’s, but still cannot defineall possible languages.
Useful for nested structures, e.g., parentheses in programming languages.
4
n
n
Productions:
S -> 01S -> 0S
Basis: 01 is in the language.
Induction: if w is in the language, then so is 0w1.
5
= symbols of the alphabet
of the language being defined.
= a finite
set of other symbols, each of whichrepresents a language.
= the variable whose
language is the one being defined.
7
Here is a formal CFG for { 0
n
n
| n > 1}.
Terminals = {0, 1}.
Variables = {S}.
Start symbol = S.
Productions =
S -> 01S -> 0S
8
We
strings in the language of a
CFG by starting with the start symbol,and repeatedly replacing some variableA by the right side of one of itsproductions.
That is, the “productions for A” are thosethat have A on the left side of the ->.
10
=>* means “zero or more derivation steps.”
Basis:
for any string
Induction: if
and
, then
11
So S =>* S; S =>* 0S1; S =>* 00S11; S =>* 000111.
13
If G is a CFG, then L(G), the
Note: w must be a terminal string, S is thestart symbol.
Example: G has productions S ->
ε
and
n
n
| n > 0}.
Note:
ε
is a legitimate
right side.
14
A language that is defined by some CFG is called a
There are CFL’s that are not regular languages, such as the example justgiven.
But not all languages are CFL’s.
Intuitively: CFL’s can count two things, not three.
16
Symbol ::= is often used for ->.
Symbol | is used for “or.”
A shorthand for a list of productions withthe same left side.
Example: S -> 0S1 | 01 is shorthand for S -> 0S1 and S -> 01.
17
Symbol … is used for “one or more.”
Example:
Note: that’s not exactly the * of RE’s.
Translation: Replace
… with a new
variable A and productions A -> A
19
Surround one or more symbols by […] to make them optional.
Example:
if
then
else
Translation: replace [
] by a new
variable A with productions A ->
ε
20
Grammar for if-then-else can be replaced by:
S -> iCtSAA -> ;eS |
ε