You are on page 1of 3

Grammar G is defined as a quadruple

G =(V, T, S, P),
V is a finite set of objects called
variables,
T is a finite set of objects called
terminal symbols,
S V is a special symbol called the
start variable,
P is a finite set of productions.
Left linear: S Aa
Right linear: S aA
2.1 Deterministic Finite Accepters
deterministic finite accepter or dfa is
defined by the quintuple
M = (Q,,,q0, F),
Q is a finite set of internal states,
is a finite set of symbols called the
input alphabet,
:Q Q is a total function called
the transition function,
q0 Q is the initial state,
F Q is a set of final states.

where Q,,q0,F are defined as for


deterministic finite accepters, but

Definition
The language L accepted by an nfa M
= (Q,,, q0,F) is defined as the set of
all strings accepted in the above
sense.

Definition
For an nfa, the extended transition
function is defined so that * (qi,w)
contains qj if and only if there is a walk
in the
transition graph from qi to qj labeled
w. This holds for all qi, qj Q, and w
*.
2.3 Equivalence of Deterministic and
Nondeterministic Finite Accepters

Languages and Dfa's


The language is the set of all the
strings accepted by the automaton

Regular Expressions for Regular


Languages
Theorem
Let L be a regular language. Then
there exists a regular expression r
such that L = L(r).

language accepted by a dfa M = (Q,


,, q0,F) is the set of all strings on
accepted by M.

Regular Languages
Every finite automaton accepts some
language. If we consider all possible
finite automata, we get a set of
languages
associated with them. We will call such
a set of languages a family

Theorem
Le t L be the language accepted by a
nondeterministic finite accepter MN=
(QN, , N,q0,FN). Then there exists a
deterministic finite accepter MD= (QD,
,D,{q0},FD) such that
L= L (MD).

Definition
A language L is called regular if and
only if there exists some deterministic
finite accepter M such that
L= L(M).

Theorem
The procedure mark, applied to any
dfa M =(Q, ,,q0,F), terminates and
determines all pairs of distinguishable
states.

Show that the language is regular.

Theorem
Given any dfa M, application of the
procedure reduce yields another dfa
such that
L(M)= L(^M ).
Furthermore, is minimal in the sense
that there is no other dfa with a
smaller number of states that also
accepts L(M).

if a language L is regular, so are L2,L3


2.2Nondeterministic Finite Accepters
nondeterministic finite accepter or nfa
is defined by the quintuple
M=(Q,,,q0,F),

Languages Associated with Regular


Expressions
Definition
The language L(r) denoted by any
regular expression r is defined by the
following rules.
1. is a regular expression denoting
the empty set,
2. is a regular expression denoting
{}.
3. For every a , a is a regular
expression denoting {a}.
If r1 and r2are regular expressions,
then
4. L (r1 + r2) = L (r1) L (r2),
5.L (r1 r2) = L (r1) L (r2);
6 L ((r1)) = L (r1),
7.L ( ) = (L (r1))*.
3.2 Connection between Regular
Expressions and Regular Languages
Theorem
Let r be a regular expression. Then
there exists some nondeterministic
finite accepter that accepts L(r).
Consequently, L(r)
is a regular language.

(q0, a) = q1,
if the dfa is in state q0 and the current
input symbol is a, the dfa will go into
state q1.

To show that this or any other


language is regular, all we have to do
is find a dfa for it

finite number of applications of the


rules in (2).

3.1 Regular Expressions


Definition
Let be a given alphabet. Then
1. , and a are all regular
expressions. These are called primitive
regular expressions.
2 If r1 and r2 are regular expressions,
so are r1+ r2,r1.r2, , and (r1).
3. A string is a regular expression if
and only if it can be derived from the
primitive regular expressions by a

3.3 Regular Grammars


Right- and Left-Linear Grammars
Definition
A grammar G =(V, T, S, P) is said to be
right-linear if all productions are of
the form
A xB,
A x,
where A, B V, and x T*. A
grammar is said to be left-linear if all
productions are of the form
A Bx,
or
A x.
A regular grammar is one that is
either right-linear or left-linear.
Right-Linear Grammars Generate
Regular Languages
Theorem
Let G =(V, T, S, P) be a right-linear
grammar. Then L (G) is a regular
language.
Theorem
If L is a regular language on the
alphabet , then there exists a rightlinear grammar G = (V, E,S, P) such
that L = L < (G).
Equivalence of Regular Languages and
Regular Grammars
Theorem
A language L is regular if and only if
there exists a left-linear grammar G
such that L = L ( G).

Theorem
A language L is regular if and only if
there exists a regular grammar G such
that L = L(G).

rex (regular expressions)


Let be a given alphabet. Then
1. , and a are all regular
expressions. These are called primitive
regular expressions.
2 If r1 and r2 are regular expressions, so are
r1+ r2, r1.r2, and (r1)*.
3. A string is a regular expression if and only
if it can be derived from the primitive regular
expressions by a finite number of
applications of the rules in (2).

Theorem
The family of regular languages is
closed under reversal.
Closure under Other Operations
Definition
Suppose and are alphabets. Then a
function
is called a homomorphism.
Theorem
Let h be a homomorphism. If L is a
regular language, then its
homomorphic image h (L) is also
regular. The family of
regular languages is therefore closed
under arbitrary homomorphisms.

Definition
Order of Operations in Rex:

Let L1 and L2 be languages on the


same alphabet. Then the right quotient
of L1 with L2 is defined as

* has the highest precedence


+

has the lowest precedence

Using the Pigeonhole Principle


A Pumping Lemma
The following result, known as the
pumping lemma for regular languages,
uses the pigeonhole principle in
another form.
The proof is based on the observation
that in a transition graph with n
vertices, any walk of length n or longer
must repeat some vertex, that is,
contain a cycle.
Theorem
Let L be an infinite regular language.
Then there exists some positive
integer m such that any w L |w| m
can be decomposed as
w = xyz
with

and

such that
is also in L for all i = 0, 1, 2,.
To paraphrase this, every sufficiently
long string in L can be broken into
three partsin such a way that an
arbitrary
number of repetitions ofthe middle
part yields another string in L. We say
that the middle string is pumped,
hence the
term pumping lemma for this result.
Example

If r1 and r2 are regular expressions, then


4. L (r1 + r2) = L (r1) L (r2),
5.L (r1 r2) = L (r1) L (r2);

Theorem
If L1 and L2 are regular languages,
then L1 /L2 is also regular. We say that
the family of regular languages is
closed under
right quotient with a regular language.

6 L ((r1)) = L (r1),
7.L () = (L (r1))*.

Ex:
L(01) = {01}
L(01+0) = {01, 0}

4.2 Elementary Questions about


Regular Languages
Theorem
Given a standard representation of any
regular language L on and any w
*, there exists an algorithm for
determining whether or not w is in L.

L(0(1+0)) = {01, 00} [note the precedence]


L(0*) = {empty, 0, 00, 000,...}

4.1 Closure Properties of Regular


Languages
Closure under Simple Set Operations
Theorem
If L1 and L2 are regular languages,
then so are L1 L2, L1 L2, L1L2, ,
. We say that the family of
regular languages is closed under
union, intersection, concatenation,
complementation, and star-closure.

Theorem
There exists an algorithm for
determining whether a regular
language, given in standard
representation, is empty, finite, or
infinite.
Theorem
Given standard representations of two
regular languages L1 and L2, there
exists an algorithm to determine
whether or not L1 = L2.
4.3 Identifying Nonregular Languages

5.1 Context-Free Grammars


Definition
A grammar G = (V, T, S, P) is said to be contextfree if all productions in P have the form A x
where A V and x (V T)*.
A language L is said to be context-free if and
only if there is a context-free grammar G such
that L = L (G).
Consider the grammar G, with productions

5.2 Parsing and Ambiguity


Definition
A context-free grammar G is said to be
ambiguous if there exists some w L
(G) that has at least two distinct
derivation trees. Alternatively,
ambiguity implies the existence of two
or more leftmost or rightmost
derivations.
Definition
If L is a context-free language for
which there exists an unambiguous
grammar, then L is said to be
unambiguous. If every grammar that
generates L is ambiguous, then the
language is called inherently
ambiguous.
6.1 Methods for Transforming
Grammars
Definition
Let G = (V, T, S, P) be a context-free
grammar. A variable A V is said to

be useful if and only if there is at least


one w L (G) such that S * x Ay
* w, (6.2) with x, y in (V T)*. In
words, a variable is useful if and only if
it occurs in at least one derivation. A
variable that is not useful is called
useless. A production is useless if it
involves any useless variable.
Definition
Any production of a context-free
grammar of the form A is called a
-production. Any variable A for which
the derivation A * (6.3) is
possible is called nullable.
Definition
Any production of a context-free
grammar of the form A B, where A, B
V, is called a unit-production.
Let L be a context-free language that does not
contain . Then there exists a context-free
grammar that generates L and that
does not have any useless productions, productions, or unit-productions.

6.2 Chomsky Normal Form


Definition
A context-free grammar is in Chomsky
normal form if all productions are of
the form A BC or A a, where A, B,
C are in V, and a is in T.
Example
The grammar S AS | a, A SA | b is
in Chomsky normal form. The grammar
S AS | AAS, A SA | aa is not;
1. Remove -productions.
2. Remove unit-productions.
3. Remove useless productions.

You might also like