0% found this document useful (0 votes)
4 views10 pages

Module II

The document discusses regular expressions, finite automata, and their applications in defining regular languages, pattern matching, and compiler design. It also covers the Pumping Lemma, which is used to prove non-regularity of languages, and the minimization of deterministic finite automata (DFA) to reduce the number of states. Additionally, it explains the equivalence of regular expressions and finite automata, emphasizing their importance in formal language theory.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views10 pages

Module II

The document discusses regular expressions, finite automata, and their applications in defining regular languages, pattern matching, and compiler design. It also covers the Pumping Lemma, which is used to prove non-regularity of languages, and the minimization of deterministic finite automata (DFA) to reduce the number of states. Additionally, it explains the equivalence of regular expressions and finite automata, emphasizing their importance in formal language theory.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Module-II

Regular Expressions, Grammar and Languages


Finite automata can only recognize regular languages, which are a particularly
restricted category of languages.

Regular Expressions
Regular languages are denoted by regular expressions.

Identities for regular expression –


The regular expression has multiple identities. Consider the regular expressions p, q, and r.

1
Regular Expression
Regular languages are denoted by Regular Expressions.

Applications of Regular expressions:

1. Defining Regular Languages:


Regular expressions are used to define regular languages. A regular language is a
type of formal language that can be recognized by a finite automaton, and regular
expressions provide a concise and expressive way to represent such languages.
2
2. Finite Automata:
Regular expressions and finite automata are closely related. Regular expressions can be
converted into equivalent finite automata, and vice versa. This connection is formalized
by the Kleene's Theorem, which states that a language is regular if and only if it can be
described by a regular expression or recognized by a finite automaton.

3. Pattern Matching:
Regular expressions are used for pattern matching within strings. In the context of formal
languages, this involves checking if a given string belongs to a particular regular
language defined by a regular expression.

4. Lexical analysis:
Regular expressions are commonly used in the design of lexical analyzers (lexers) for
compilers. Lexers are responsible for breaking down the source code into tokens, and
regular expressions are used to describe the patterns of valid tokens in the programming
languages.

5. Text Editors and Search algorithms:


Regular expressions are applied in text editors and search algorithms to efficiently find
and manipulate patterns in textual data. This application is related to the concept of
regular languages and the efficient algorithms for pattern matching.

6. String Matching algorithms:


Regular expressions are used as patterns in string matching algorithms. These algorithms,
such as the Knuth-Morris-Pratt algorithm or the Boyer-Moore algorithm, are used to find
occurrences of a pattern within a text.

7. Network Protocol Specification:


Regular expressions are used in the specification of network protocols and in the design
of protocol analyzers. They help define the syntactic rules for valid messages or packets
in a network communication protocol.

7. Database Query Languages:


Regular expressions are integrated into some database query languages to provide
expressive pattern matching capabilities when searching or filtering data.

8. Automated String Processing:


Regular expressions are used in various automated string processing tasks, such as text
processing, data validation, and information retrieval.

They provide a concise and powerful notation for describing patterns and sets of strings
within the context of formal language theory.

3
Pumping Lemma:
Two Pumping Lemmas have been defined for the following:

1. Context – Free Languages


2. Regular Languages

Pumping Lemma for Regular Languages

This basically indicates that even after a string v is "pumped," or added a number of times, the
resulting string stays in L.
It is an evidence of language irregularity. Therefore, a language definitely fulfills pumping
lemma if it is regular. L is undoubtedly not regular if it contains a minimum of one pumping
string that is not in L.

It's possible that the contrary isn't always true. That is, the language is not regular even if
Pumping Lemma holds.

Ex: prove L01 = {0n1n | n ≥ 0} is irregular.


Assuming L is regular, the aforementioned rules derive from Pumping Lemma.

4
Applications of Pumping Lemma:

1. Proving Non-Regularity:
One of the primary applications of the Pumping Lemma is to prove that a given language
is not regular. If a language cannot satisfy the conditions of the Pumping Lemma, then it
cannot be regular

2. Identifying Non-Regular Languages


By applying the Pumping Lemma to a language, one can identify certain properties that
are not satisfied if the language is not regular. This helps in understanding the limitations
of regular language.

3. Compiler Design:
In the context of compiler design, the Pumping Lemma can be applied to analyze the
regularity of the language defined by the lexical structure of a programming language. It
helps ensure that the lexical analyzer can efficiently recognize valid tokens.

The Pumping Lemma is a powerful tool in formal language theory, and its applications
extend to various areas, including language design, compiler construction, and the
theoretical analysis of computational complexity.

Equivalence of Two Regular Expressions

Equivalence of two finite automata


If two automata A and B accept precisely the same set of input strings, then they are
considered comparable. If automata A and B are identical, then

i. If a path exists from the initial state of an A to its final state, designated a1a2..ak,
then a path exists from the initial state of a B to its final state, also designated
a1a2..ak.
ii. Should a path exist from the initial state of B to the ultimate state of B, designated
5
as b1b2..bj, then a path exists from the initial state of A to the ultimate state of A,
also designated as b1b2..bj.

Minimization of DFA
Conversion of a DFA to equivalent DFA with the fewest possible states is known as DFA
minimization. Partitioning algorithms are used in DFA minimization, also known as
Optimization of DFA.
Minimization of DFA

Assume a DFA D < Q, Σ, q0, δ, F > that is capable of identifying the language L.
Then, for language L, the reduced DFA D < Q', Σ, q0, δ', F' > can be built as follows:

Step 1: Q (the collection of states) will be split into two sets. All final states will be
included in one set, and non-final states will be included in the other. P0 is the name
of this partition.

Step 2: Set up k = 1.

Step 3: Partition the various Pk-1 sets to find Pk. We will take every feasible pair of
states in each set of Pk-1. We shall divide the sets into distinct sets in Pk if two states
inside a set can be distinguished from one another.

Step 4: if Pk equals Pk-1 (nopartition manipulation), stop.

Step 5: A set's states combine to form a single state. In Pk, the sets will equal the
states in reduced DFA.

6
How may the distinguishability between two states in partition Pk be determined?
If δ (qi, a) and δ (qj, a) are in separate sets in partition Pk-1 for each given input
symbol a, then two states (qi, qj) can be distinguished in partition Pk.

Ex:
. Examine the DFA that is depicted as

Step 1. P0 contains 2 states. The last DFA states, q1, q2, and q4, will be in one set, and
the remaining states will be in another.

Step 2. Now determine whether or not sets of partition P0 can be partitioned in order to
compute P1:

As a result, q2 and q4 cannot be distinguished from q1 and q2, which cannot be


distinguished from q1 and q4. Consequently, P1 will not partition the { q1, q2, q4 } set.

7
In the same way, q0 and q3 combine to form q3. Figure 2 displays the minimized DFA that
corresponds to the DFA of Figure 1 as:

8
Ex:
Examine the provided DFA. Which statement below is not true?
1. L(A)'s complement is independent of context.
2. L (A) = L ((11 * 0 + 0) (0 + 1)* 0* 1*)
3. A is the minimal DFA for the language that A has approved.
4. A takes any string longer than { 0, 1 } by at least two lengths.

9
Solution:

It will take all strings with a minimum length of two, according to statement 4. However, it
takes 0 (which has length 1). Thus, 4 is untrue.

According to Statement 3, the DFA is negligible. We will verify with the previously
mentioned algorithm.

P0 equals P1, hence P1 is ultimate DFA. Q0 , Q1 are combinable. Then there will be 2
states for minimal DFA. As a result, statement 3 is likewise not true.
Thus, (D) is the correct choice.

You might also like