Regular expressions and languages pdf

Dilouarhossain 1,983 views 25 slides Dec 10, 2016
Slide 1
Slide 1 of 25
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25

About This Presentation

Also since {a} is regular, {a}* is a regular language which is the set of strings consisting of a's such as , a, aa, aaa, aaaa etc. Note also that *, which is the set of strings consisting of a's and b's, is a regular language because {a, b} is regular. Regular expressions are used to de...


Slide Content

Topic - Regular Expressions and Topic - Regular Expressions and
LanguagesLanguages
Dilouar Hossain
[email protected]

Topic ContentsTopic Contents
 Regular ExpressionsRegular Expressions

 Finite Automata and Regular ExpressionsFinite Automata and Regular Expressions

 Applications of Regular ExpressionsApplications of Regular Expressions

 Algebraic Laws for Regular ExpressionsAlgebraic Laws for Regular Expressions

Regular Expressions
Md. Tarek Habib3
Regular expressions are language-defining notation
Regular expressions are useful in applications such as text-search
applications and compiler components

Regular Expressions…
Md. Tarek Habib4
A FA (NFA or DFA) is a “blueprint" for constructing
a machine recognizing regular language.
A regular expression is a “user-friendly,"
declarative way of describing a regular language.
Example: 01* + 10*
Regular expressions are used in
1. UNIX grep command
2. UNIX Lex (Lexical analyzer generator)
.
.
.

Operations
5

Building Regular Expressions (regex’s)
6

Example
7

Equivalence of FA’s and regex’s
Md. Tarek Habib8

FA to regex
9
For each accepting state q, apply a reduction process to
produce an equivalent automaton with regular-
expression labels on the arcs. Eliminate all states except
q and the start state q
0
.
If q ≠ q
0
, then we shall be left with a two-state
automaton that looks like:

FA to regex…
Md. Tarek Habib10
If the start state is also an accepting state, then we must
also perform a state-elimination from the original FA
that gets rid of every state except the start state. Then
we are left with a one-state automaton:

FA to regex…
Md. Tarek Habib11
If there is more than one final state in the original FA, then
we must union all the Eq to obtain the final regular
expression.

FA to regex Example
Md. Tarek Habib12

FA to regex Example…
13

FA to regex Example…
14

regex to FA
Md. Tarek Habib15
Suppose L = L(R) for a regex R. Then we can design a -NFA
ε
E such that L(R) = L(E).
E will have:
•Exactly one accepting state
•No arcs into the initial state
•No arcs out of the accepting state

regex to FA…
Md. Tarek Habib16

regex to FA…
17

regex to FA Example
18

Algebraic Laws for Regular Expressions:
Commutativity and Associativity
Md. Tarek Habib19

Algebraic Laws for Regular Expressions:
Identities and Annihilators
Md. Tarek Habib20

Algebraic Laws for Regular Expressions:
Distributive Laws
Md. Tarek Habib21

Algebraic Laws for Regular Expressions:
Distributive Laws
Md. Tarek Habib22

Algebraic Laws for Regular Expressions:
The Idempotent Law
Md. Tarek Habib23

Algebraic Laws for Regular Expressions:
Laws Involving Closures
Md. Tarek Habib24

The End