CSCI 2670 Introduction to Theory of Computing - PowerPoint PPT Presentation

About This Presentation
Title:

CSCI 2670 Introduction to Theory of Computing

Description:

Title: PowerPoint Presentation Author: Wim van Dam Last modified by: Shelby Hyatt Funk Created Date: 8/27/2001 7:35:01 AM Document presentation format – PowerPoint PPT presentation

Number of Views:167
Avg rating:3.0/5.0
Slides: 33
Provided by: Wimva9
Learn more at: http://cobweb.cs.uga.edu
Category:

less

Transcript and Presenter's Notes

Title: CSCI 2670 Introduction to Theory of Computing


1
CSCI 2670Introduction to Theory of Computing
  • September 11, 2007

2
Agenda
  • Last class
  • Discussed non-determinism
  • Equivalence of DFAs and NFAs
  • Today
  • Further exploration of equivalence of DFAs and
    NFAs
  • Tomorrow
  • Closure of regular languages under regular
    operators
  • Another method for describing regular languages

3
Example
0 1
q1 q2,q3 ?
q2 ? q1,q3
q3 ? ?
q1,q2 q2,q3 q1,q3
q1,q3 q2,q3 ?
q2,q3 ? q1,q3
q1,q2,q3 q2,q3 q1,q3
? ? ?
4
What about e jumps?
  • For each R ? P(Q), define function E(R)
  • E(R) q q can be reach by 0 or more e jumps
    from some r ? R
  • Redefine ?(R,a) to include E(R)
  • ?(R,a) q q ? E(?(r,a)) for some r ? R
  • Are we done?
  • No! What if there are ? jumps from q0?

q0 E(q0)
5
Closure of NFAs under regular operations
  • Recall the following are the regular operators
  • Union
  • Concatenation
  • Kleene star

6
Union is a regular operation
Theorem The class of regular languages is
closed under the union operation Proof approach
Assume A1 and A2 are both regular languages with
A1L(M1) and A2L(M2) and create an NFA M such
that L(M) A1?A2 Method Proof by construction
7
Construct M from M1 and M2
e
e
8
Concatenation is a regular operation
Theorem The class of regular languages is
closed under the concatenation operation Proof
approach Assume A1 and A2 are both regular
languages with A1L(M1) and A2L(M2) and create
an NFA M such that L(M) A1?A2 Method Proof by
construction
9
Construct M from M1 and M2
e
e
10
Kleene star is a regular operation
Theorem The class of regular languages is
closed under the Kleene operation Proof approach
Assume A1 is a regular language with A1L(M1)
and create an NFA M such that L(M) A1 Method
Proof by construction
11
Construct M from M1
12
Regular expressions (REs)
  • So far we have had to describe languages either
    with finite automata or with words
  • Potentially clumsy or imprecise
  • Today we learn precise expression to describe
    regular languages
  • Example All strings with at least one 1 becomes
    ??1??, or more simply ?1?

13
Where have you seen REs?
  • Grep
  • Awk
  • Perl
  • Search expressions within emacs or vi

14
RE inductive definition
  • R is a regular expression if R is
  • a for some a ? ?
  • e
  • ?
  • R1 ? R2 where R1 and R2 are both regular
    expressions
  • R1 ? R2 where R1 and R2 are both regular
    expressions
  • (R1) where R1 is a regular expression

15
Examples
  • 01010
  • w w contains exactly two 1s
  • ?11?
  • w w contains two consecutive 1s
  • ?1(0?e)1?
  • w w contains two 1s separated by at most one
    0
  • (0?e)(1?e)
  • 0,1,01,e

16
REs and regular languages
  • Theorem A language is regular if and only if
    some regular expression describes it.
  • i.e., every regular expression has a
    corresponding DFA and vice versa

17
REs and regular languages
  • Lemma If a language is described by a regular
    expression, then it is regular.
  • find an NFA corresponding to any regular
    expression
  • use inductive definition of REs

18
1. Ra for some a??
  • N q1,q2,?,?,q1,q2 where ?(q1,a)q2 and
    ?(r,x)? whenever rq2 or x?a

19
2. Re
  • N q1,?,?,q1,q1 where ?(q1,x)? for all x

20
3. R?
  • N q1,?,?,q1,? where ?(q1,x)? for all x

21
Remaining constructions
  • R R1?R2
  • R R1?R2
  • R R1
  • These were all shown to be regular operators
  • We know we can construct NFAs for R provided
    they exist for R1 and R2

22
Example
  • R ?1
  • R (0?1)1

23
Example2
  • R 1(0?e)?

24
Equivalence of REs and DFAs
  • We have seen that every RE has a corresponding
    NFA
  • Therefore, every RE has a corresponding DFA
  • I.e, every RE describes a regular language
  • We need to show that every regular language can
    be described by a RE
  • Begin by converting all DFAs into GNFAs
  • Generalized Non-deterministic Finite Automata

25
GNFAs
  • A GNFA is an NFA with the following properties
  • The start state has transition arrows going to
    every other state, but no arrows coming in from
    any other state
  • There is exactly one accept state and there is an
    arrow from every other state to this state, but
    no arrows to any other state from the accept
    state
  • The start state is not the accept state

26
GNFAs (continued)
  1. Except for the start and accept states, one arrow
    goes from every state to every other state and
    also from each state to itself
  2. Instead of being labeled with symbols from the
    alphabet, transitions are labeled with regular
    expressions

27
Example GNFA
28
Equivalence of DFAs and REs
  • First show every DFA can be converted into a GNFA
    that accepts the same language
  • Then show that any GNFA has a corresponding RE
    that accepts the same language

29
Converting a DFA into a GNFA
  • Add two new states
  • New start state with an e jump to the original
    DFAs start state
  • New accept state with an e jump from each of the
    original DFAs accept states
  • This new state will be the only accept state
  • All transition labels with multiple labels are
    relabeled with the union of the previous labels
  • All pairs of states without transitions get a
    transition labeled ?

30
Converting a DFA to a GNFA
  • Add two new states

31
Converting a DFA to a GNFA
0
q2
1
q1
1
0
q3
q4
0,1
0?1
0,1
0?1
  • All transition labels with multiple labels are
    relabeled with the union of the previous labels

32
Converting a DFA to a GNFA
0
q2
1
q1
1
0
q3
q4
0?1
0?1
  • All pairs of states without transitions get a
    transition labeled ?
Write a Comment
User Comments (0)
About PowerShow.com