Lec-23 Nonregular Languages

Download Report

Transcript Lec-23 Nonregular Languages

CSC312
Automata Theory
Lecture # 23
Chapter # 10 by Cohen
Nonregular Languages
Nonregular Languages:
The language that cannot be expressed by any regular
expression is called a nonregular language. The languages
PALINDROME and PRIME are the examples of nonregualr
language.
By Kleene’s theorem a nonregular language can also not be
accepted by any FA of TG. All the language are either
regular or nonregular, none are both.
Ex:
Consider the language
L={an bn : n=0,1,2,…} = {, ab, aabb, aaabbb, …}
PRIME = {ap where p is a prime}
PALINDROME = {w= wR} where w is a string in the language
2
Pumping Lemma:
If L be any infininte language (that has infinite many
words), defined over an alphabet  then there exists
three strings x, y and z belonging to * (where y is not the
null string) such that all the strings of the form synz for
n=1, 2, 3, … are the words in L. If the new word is in the
language then it is a regular language otherwise nonregular
language. .
Ex:
Consider the language
L={an bn : n=0,1,2,…} = {, ab, aabb, aaabbb, …}
3
Chapter # 11 by Cohen
Decidability
Effectively Solvable Problem:
A problem is said to be effectively solvable if
there exists an algorithm that provides the
solution in finite number of steps e.g. finding
solution for quadratic equation is effectively
solvable problem.
Decision Procedure:
An effective solution to a problem that has a yes
or no answer is called a decision procedure.
Decidable:
A problem that has a decision procedure is called
decidable.
5
Decidability Problems
Equivalency problem – equivalence of two languages
If L1 and L2 are regular languages, then they can be
expressed either by REs or by FAs. We can easily
/
/
,
develop FAs for L1 L 2 . Therefore, we can produce
an FA that accepts the language
L  L  L  L 
1
/
/
2
1
2
This machine accepts the language of all words that
are in L1 but not in L2, or else in L2 but not in L1. If
L1 is equal to L2, then this machine accepts nothing
at all, not even the Null string.
6
Decidability Problems
Equivalence of two languages (cont…)
Methods that determine whether a given FA accepts
any words or not.
Method-1:
Convert the FA into regular expression – If a single RE
is generated then the FA accepts some strings.
 The algorithm that determines what word is definitely
present in the given RE.
Step-1: Remove all Kleene’s Star and Kleene’s Plus
operators from the RE
Step-2: For each + sign, throw away the right half of
the sum and the + sign itself.
Step-3: Remove parentheses, and we get the final word
7
if exist.
Decidability Problems
Method-2: (Blue paint method)
To examine whether a certain FA accepts any word, it
is required to seek paths from initial to final state.
Following is the procedure to find such paths.
Step-1: Paint the start state Blue.
Step-2: From every blue state follow every edge that
leads out of it and paint the destination state blue,
then delete these edges from the machine.
Step-3: Repeat step-2 until no new state is painted
blue, then stop.
Step-4: When the procedure stops, if any of the final
states are painted blue, then the machine accepts
some words, otherwise not.
8