CSC 473 Automata, Grammars & Languages 9/29/10 Automata, - - PDF document

csc 473 automata grammars languages 9 29 10
SMART_READER_LITE
LIVE PREVIEW

CSC 473 Automata, Grammars & Languages 9/29/10 Automata, - - PDF document

CSC 473 Automata, Grammars & Languages 9/29/10 Automata, Grammars and Languages Discourse 03 Finite Automata C SC 473 Automata, Grammars & Languages Finite Automata / Switching Theory (CS) / (CE) Boolean operators / Gates


slide-1
SLIDE 1

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 1

C SC 473 Automata, Grammars & Languages

Automata, Grammars and Languages

Discourse 03 Finite Automata

C SC 473 Automata, Grammars & Languages 2

Finite Automata / Switching Theory

(CS) / (CE)

  • Boolean operators / Gates (Elem. Switching Ops)

1 1 1 1 1 1 1 1 1 1 1 ¬ x x ⊕ y x ∨ y x ∧ y y x

C SC 473 Automata, Grammars & Languages 3

Boolean Functions / Combinatorial Circuits

  • Circuit

∨ ∧ ∧ ¬

1

x

2

x

1 (sum)

z

2 (carry)

z

1 2

x x

  • 1

2

x x

  • 1

2

x x

  • 1

2

x x

  • H half adder

H H

1

x

2

x

3

x

1 2

x x

  • 1 (sum)

z

1 2

x x

  • 1

2 3

( ) x x x

  • 2 (new carry)

z

F full adder

(old carry)

slide-2
SLIDE 2

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 2

C SC 473 Automata, Grammars & Languages 4

Boolean Functions / Comb. Circuits (contʼd)

  • Table representing F

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

z2 z1 x3 x2 x1

C SC 473 Automata, Grammars & Languages 5

Boolean Functions / Comb. Circuits (contʼd)

  • Equations representing F
  • General scheme (n inputs, m outputs)

1 1 1 2 3 2 2 1 2 3 1 2

( ) ( ) (( ) ) ( ) z g x x x x z g x x x x x x = =

  • =

=

  • 1

2 1 2 1 1 2 1 2

( ) ( , , , ) ( , , , ) ( ( , , , ), , ( , , , ))

m n n m n

z g x z z z g x x x g x x x g x x x = = = … … … … …

C SC 473 Automata, Grammars & Languages 6

Finite Automata / Sequential Circuits

  • Add “memory” elements = delay elements
  • Finite # of delay elements possible ⇒ ∃ d

( ) y i ( ) ( ( ), ( 1 ), ( 2 ), ) z i f x i x i x i =

( 1 ) y i + x z

f

combinatorial circuit

( ) ( ( ), ( 1 ), ( )) z i f x i x i x i d =

slide-3
SLIDE 3

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 3

C SC 473 Automata, Grammars & Languages 7

Finite Automata / Sequential Circuits

  • Ex: sequential adder: add 2 binary numbers; low
  • rder bits received first
  • (a) sequential net (circuit):

1001 0101 1110 carry

1

( ) x i

2

( ) x i

1

( ) z i

full adder F

1

( 1 ) y i +

1

( ) y i

1 2

( ) ( ) x x

C SC 473 Automata, Grammars & Languages 8

Finite Automata / Sequential Circuits

  • (b) Next-State & Output Equations:
  • (c) Transition Table: state space

1 1 2 1 1 2 1 1 2 1

( 1 ) (( ( ) ( )) ( )) ( ( ) ( )) ( ) ( ) ( ) ( ) y i x i x i y i x i x i z i x i x i y i + =

  • =
  • 1

{ ,1 } { , } q q = = input alphabet ={(00),(01),(10),(11)}

  • utput alphabet ={0,1}
  • (

00 ) ( 01 ) ( 10 ) ( 11 ) q

1

q

0 / 0

q

next state/output table

q

0 / 1

q

0 / 1

q

0 / 1

q

1 / 0

q

1 / 0

q

1 / 0

q

1 / 1

q

x

C SC 473 Automata, Grammars & Languages 9

Finite Automata / Sequential Circuits

  • (d) State Diagram:

( 00 )/ 1 ( 00 )/ 0 ( 01 )/ 1 ( 10 )/ 1

q

1

q

( 11 )/ 0 ( 11 )/ 1 ( 01 )/ 0 ( 10 )/ 0

slide-4
SLIDE 4

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 4

C SC 473 Automata, Grammars & Languages 10

Finite Automata / Sequential Circuits

  • (e) Finite-State Transducer (Mealy Machine)

 A 5-tuple

where

( , , , , ) M Q q

  • =

1 1 1 1

{ , } {( 00 ),( 01 ),( 10 ),( 11 )} { ,1 } : ( ,( 00 )) ( ,0 ) ( ,( 01 )) ( ,1 ) ( ,( 10 )) ( ,1 ) ( ,( 11 )) ( ,0 ) ( ,( 01 )) ( ,0 ) . Q q q q Q Q q q q q q q q q q q etc

  • =

= = = = = = =

finite set of states start state input alphabet

  • utput alphabet

transition/output function

C SC 473 Automata, Grammars & Languages 11

General Sequential Network

1 n

x x

  • 1

m

z z

  • 1

s

y y

:

n s m s

B B

  • +

+

  • {

,1 } B =

state space =

s

B

( ( ), ( )) ( ( 1 ), ( )) ( , ) ( , ) y i x i y i z i q a q b

  • =

+

  • =

δ is a boolean functio n

C SC 473 Automata, Grammars & Languages 12

Three Types of Automata

M M M

transducer recognizer (acceptor) Enumerator (generator)

3 2 1 n

a a a a

  • 3

2 1 n

c c c c

  • time

3 2 1 n

a a a a

  • 3

2 1 n

c c c c

  • i

a

Yes(1) No(0)

slide-5
SLIDE 5

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 5

C SC 473 Automata, Grammars & Languages 13

Machines that Recognize

  • Detection of an “event”, i.e., a pattern in input
  • Recognition of just those words in some language L
  • Definition of a language
  • Ex: detect abab –all non-overlapping occurrences

a b a b b a a b a b

C SC 473 Automata, Grammars & Languages 14

Ex: C Comments /* … */

  • Filter in the lexical scanner
  • Recognizer

{,/} a

  • =

: aa

:

/ :

  • /

:

  • :

/ a a

:

  • /

: /

:

  • empty

/ :

  • :

a

:

  • :

a / a

  • a
  • /
  • /

(transducer)

notation in : out

C SC 473 Automata, Grammars & Languages 15

Finite Automaton (Finite State Machine, FSA)

  • Defn 1.5: A (deterministic) finite automaton is a 5-tuple
  • is a finite set, the states
  • is a finite set, the alphabet
  • is the transition function
  • is the start state
  • is the set of accepting (final) states
  • Ex:

( , , , )

,

M Q q

F

  • =
  • F

Q

  • Q

: Q Q

  • q

Q

  • ( , , ,

)

,

M Q q

F

  • =
  • 1

2

{ , , } Q q q q =

1

{ , } { } a b F q = =

1 2 1 2 1 2 2 2 2

( , ) ( , ) ( , ) ( , ) ( , ) ( , ) q a q q b q q a q q b q q a q q b q

  • =

= = = = =

q

1

q

2

q

a b b a , a b

M

slide-6
SLIDE 6

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 6

C SC 473 Automata, Grammars & Languages 16

How FA Compute

  • FA is a finite structure—like

a program—fixed and static

  • Need to define the behavior of M on input w

 Sequence of configurations  Like trace of a program on given data  Dynamic and input-dependent

  • Ex: start on input Look at sequence
  • f “moves” determined by the transition function:

Since in accepting state when input exhausted, w is recognized by

( , , , )

,

M Q q

F

  • =
  • M

w ababa = ( q0,ababa)( q1,baba) ( q0,aba)

  • (

q1,ba) ( q0,a)

  • (

q1,) ( q0,ababa)( q1,)

M

C SC 473 Automata, Grammars & Languages

www.jflap.org

JFLAP is a package of graphical tools which can be used as an aid in learning the basic concepts of Formal Languages and Automata Theory.

C SC 473 Automata, Grammars & Languages 18

Info on JFLAP

  • Website http://www.jflap.org/

Downloads

Tutorial

  • Lectura (linux) install

cd /usr/local/jflap

java -jar JFLAP.jar

  • X11 forwarding (graphics)

ssh -X lectura

slide-7
SLIDE 7

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 7

C SC 473 Automata, Grammars & Languages 19

How FA Compute (contʼd)

  • Given a FA
  • Defn: configuration of M is an element of
  • Defn: yields in one step (or moves) relation

between configurations is defined by where

 Notes: is a function, since δ is. Is undefined.

  • Defn: yields is the relation

 Means “moves in zero or more steps to” 

  • Defn: A string w is recognized (accepted) by M ⇔

( , , , )

,

M Q q

F

  • =
  • (

q,aw) ( q ,w) ( q,a) =

  • q

Q

  • !

, , , a w q q Q

  • (

q,)

  • (

q,w) ( q,w) ( f F)( q0,w) ( f,)

C SC 473 Automata, Grammars & Languages 20

How FA Compute (contʼd)

  • Defn: The language recognized (accepted) by M is
  • Defn 1.16: A language S is regular iff there is some FA

that recognizes it, i.e.,

  • Ex: In FA

( )[ is a FA ( )] M M S L M

  • =

L (M) = { w : M accepts w} = { w :( f F)( q0,w)

(

f,)

}

( q0,a) ( q1,) ( q0,aba)

(

q1,)

  • (

q0, ( ab)

ia)(

q1,) L (M0) = {( ab)

ia : i 0

}

M

C SC 473 Automata, Grammars & Languages 21

Example:

  • Coin checker for 30¢ coffee. Σ={n,d,q}

15 5 10 30 25 20 35 40 45 50

i

= make change for i – 30 ¢ & vend coffee q n n n n n n d d d d d d q q q q q

slide-8
SLIDE 8

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 8

C SC 473 Automata, Grammars & Languages 22

Regular Operations & Regular Expressions

  • The regular operations on languages are:

 union (∪), concatenation (⋅ ) and Kleene star (*).

  • So called because the class of regular languages are

closed under them—i.e., applying these operators to regular languages results in a regular language. (We will prove these closure results later.)

  • In fact, these three operations (∪, ⋅ ,*) actually characterize

what it means to be a regular language: any regular language can be built up from alphabet symbols and a finite number of these regular operations.

  • This motivates the notion of regular expression: a

sequence of symbols, like an arithmetic expression, that defines a regular language using regular ops.

C SC 473 Automata, Grammars & Languages 23

Regular Expressions

  • A syntax for describing sets of strings (languages)

 Terse  Eliminates fussy “{ }”  Reminiscent of arithmetic expressions  Obeys some useful “algebra”, e.g., (E*F*)* = (E+F)*

  • Syntax for regular expressions over Σ,+, ⋅ ,*,(,)

 E → (E+E) ( text uses ∪ not +; some authors use |)  → (EE)

(usually suppress the ⋅ in E ⋅ E)

 → (E*)  → ε (some authors use λ )  → ∅  → a for each a in Σ

  • suppress (,) where possible: (a+b)*a not ( ( (a + b)* ) ⋅ a )

C SC 473 Automata, Grammars & Languages 24

Regular Expressions (contʼd)

  • Meaning rules for the syntax
  • The meaning (denotation) of an expression, L(E), is a set
  • f strings (a language)
  • Rules

expression E language L(E) ∅ a {a} ε {ε} (E+F) L(E)∪L(F) (EF) L(E)⋅L(F) (E*) L(E)*

{} =

slide-9
SLIDE 9

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 9

C SC 473 Automata, Grammars & Languages 25

  • Reg. Expr.: Examples, Equivalence(=)
  • (a+b)*a
  • (a*b*)*
  • =(a+b)*
  • (a+b)*a(a+b)*a(a+b)*
  • (b*ab*ab*ab*)*

PASCAL unsigned numbers. d={0,1,…,9}

  • dd*(ε +.dd*)(ε+E(+ + – + ε)dd*)
  • aΣ*a+b Σ*b+a+b

Defn: E=F ⇔L(E)= L(F)

 ∅*= ε (E*F*)*=(E+F)* E∅=∅E=∅  E(FG)=(EF)G E(F+G)=EF+EG Eε=εE=E

L

{ , }{ } a b a

  • ({ }{ })

a b

  • { , }

a b =

{ : has 2 a's} w w

  • {

w : # a's divisable by 3} { : ?? } w { : begins & ends same} w w

C SC 473 Automata, Grammars & Languages 26

Nondeterminism

  • Real computing devices are deterministic: the current

configuration and instruction determines the next

  • configuration. The relation is a function.
  • Why the concept of nondeterminism?

 Provides powerful, economical descriptive ability  Provides a way to specify languages without over-specifying and

complex handling of cases

 Can be algorithmically converted to a deterministic description (at

the sacrifice of some economy and with added complexity)

 Generalization of determinism

  • Ex: abab occurs somewhere in w: …abab…
  • a

b a b a,b a,b a,b a b a

C SC 473 Automata, Grammars & Languages 27

Nondeterminism (contʼd)

  • Ex: w∈Σ* has penultimate symbol b: w = …b?
  • Ex: w∈Σ* has ≥ 2 a’s: w = … a … a …

b b a,b a b a,b a a a a,b a,b a,b

slide-10
SLIDE 10

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 10

C SC 473 Automata, Grammars & Languages 28

ε-Moves Can Be Useful

  • SNOBOL arithmetic constants (no floating E)

 Use to specify “optional characters” like Unix command line [opt]

ε

d d=digit d d ε

  • d

C SC 473 Automata, Grammars & Languages 29

Nondeterministic Finite Automaton

  • Defn 1.5: A nondeterministic finite automaton is a 5-tuple

is a finite set, the states

is a finite set, the alphabet

transition function

is the start state

is the set of accepting (final) states

  • Ex:

( , , , )

,

M Q q

F

  • =
  • F

Q

  • Q

: ( { }) ( ) Q Q

  • P
  • q

Q

  • 1

( , , , )

,

M Q q

F

  • =
  • 1

{ , } Q q q =

1

{ , } { } a b F q = =

1 1 1 1 1

( , ) { } ( , ) { , } ( , ) { } ( , ) { } q a q q b q q q a q q b q

  • =

= = =

1

M

b a,b a,b

q

1

q

C SC 473 Automata, Grammars & Languages 30

DFA vs NFA

  • DFA δ
  • For each state q and input symbol

a, there is exactly one choice of new state (or no transition is defined at all). Each transition “consumes” an input symbol

  • Special case of NFA!
  • NFA δ
  • There may be multiple choices for

the same input symbol

  • There may be ε-moves that do not

“consume” an input character

  • There can be “chains” of ε-moves
  • ε-moves can create even more

choice for the next input character

q a b q a a b b ε ε

slide-11
SLIDE 11

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 11

C SC 473 Automata, Grammars & Languages 31

How NFA Compute

  • Given a NFA
  • Defn: configuration –
  • Defn: yields in one step (or moves) relation

between configurations

  • Defn: yields =

 Means “COULD move in zero or more steps to”

  • Defn: w is recognized (accepted) by M ⇔

 Same as before, but has the meaning “if there exists some

sequence of moves from the start config to some accepting config”

( , , , )

,

M Q q

F

  • =
  • (

q,aw) ( q ,w)

  • q

( q,a)

( , ) q w Q

  • !
  • !

( f F)( q0,w) ( f,) ( q,w) ( q ,w)

  • q

( q,)

(ε-move)

C SC 473 Automata, Grammars & Languages 32

How NFA Compute (contʼd)

  • Defn: The language recognized (accepted) by M is
  • Ex: In NFA

 This provides no “evidence” that aabbba is accepted (or not)  However, also via a separate computation sequence:  And so aabbba is recognized!

L (M) = { w : M accepts w} = { w :( f F)( q0,w)

(

f,)

}

( q0,aabbba) ( q0,)

1

M

( q0,aabbba) ( q1,)

C SC 473 Automata, Grammars & Languages 33

“Tree” of Computations

  • Ex: NFA M1

( , ) q aabbba ( , ) q abbba ( , ) q bbba

1

( , ) q bba ( , ) q bba ( , ) q ba

1

( , ) q ba ( , ) q a

1

( , ) q a ( , ) q

  • 1

( , ) q

  • X

null “evidence” ∃ accepting Computation ⇒ w∈L(M1)

1

q F

  • =
slide-12
SLIDE 12

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 12

C SC 473 Automata, Grammars & Languages 34

Computation Tree: Example

  • Ex: L = {w: w begins & ends same }

2

a

3 4

a,b

1

a,b b b a ( , )

2

( , )

3

( , )

1 ababa

( , )

2 baba

( , )

2 aba

( , )

2 ba

( , )

3 ba

( , )

2 a

X

3∈F

( , )

1 abab

( , )

2 bab

( , )

2 ab

( , )

2 b

( , )

3 b

( , )

2

X X

reject abab ¬∃ path to F accept ababa ∃ some path to F

C SC 473 Automata, Grammars & Languages 35

Example with ε-Moves

  • String length a multiple of 2 or 3

2 4 3 ε ε a 5 6 a a a a ( , )

0 aaa

( , )

2 aaa

( , )

4 aaa

( , )

3 aa

( , )

2 a

( , )

5 aa

( , )

6 a

( , )

3

( , )

4 !

X

4∈F ⇒ Accept aaa ← ε-moves

C SC 473 Automata, Grammars & Languages 36

Example with ε-Moves

  • a*b*

( , )

0 aab

( , )

1 aab

( , )

0 ab

( , )

1 ab

( , )

0 b !

X

1∈F ⇒ Accept aab

X

( , )

1 b

( , )

1

ε a 1 b ε-moves “consume” no input symbols

slide-13
SLIDE 13

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 13

C SC 473 Automata, Grammars & Languages 37

Equivalence of NFA to DFA

  • There is an algorithm to convert any NFA into a DFA

 We show basic idea assuming NFA has no ε-moves  Then (later) modify the construction for NFAs with ε-moves

  • Ex: L = {x : last symbol of x appeared previously } Σ={a,b}
  • Idea: given input string, keep track of all possible reached

states after reading each letter. At end of input, see if a final state is among those reached p q r s a b a,b a,b a,b a b N0:

C SC 473 Automata, Grammars & Languages 38

Equivalence of NFA and DFA (contʼd)

  • Computation paths through NFA N0 on w = abba

p p p p p r r r q q q q r r s s q a a b b a a b a b b a b b b a a

s F

  • C SC 473 Automata, Grammars & Languages

39

Equivalence of NFA and DFA (contʼd)

  • Idea: keep a list of all possible states reachable by each

prefix of w (“parallel worlds”). For NFA N0:

{ } { , { , { , { , } , , , } , , } } { } { , , , } ( ) since { , , , }

a b b a abba

p p p p p q q q q r r r s s p p q r s abba L N p q r s F

slide-14
SLIDE 14

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 14

C SC 473 Automata, Grammars & Languages 40

Equivalence of NFA and DFA (contʼd)

  • Equivalent DFA M will have:

 State set P (Q)  Alphabet Σ  Start state “set” {q0}  Accepting states {X ⊆ Q : X ∩ F ≠ ∅}  Deterministic transition function δ′ : P (Q) × Σ → P (Q)

  • Ex: For NFA N0:

({ , }, ) { , , } ({ , }, ) { , , } ({ }, ) { , } ({ }, ) { , } p q a p q s p q b p q r p a p q p b p r

  • =
  • =
  • =
  • =

C SC 473 Automata, Grammars & Languages 41

Equivalence of NFA and DFA (contʼd)

  • Thm: [Rabin-Scott Construction]. Let L = L(N) for some NFA

N with no ε-moves. There is an algorithm to constuct a DFA M equivalent to N, i.e. with L(M) = L(N). Pf: Given N we construct a DFA M and then verify that it recognizes the same set as N. Construction: Given NFA construct where

( , , , , ) N Q s F

  • =
  • ( , ,

, , ) M Q s F

  • =
  • Q

= P( Q),

  • s

= { s},

  • F

= { X

  • Q : X F }

and :

  • Q
  • Q

is defined as: (S Q,a )

  • (

S,a) = { q Q :(p S)q (p,a)}

C SC 473 Automata, Grammars & Languages 42

Equivalence of NFA and DFA (contʼd)

  • Picture of δ′
  • (

S,a) =

  • S

a a a b a b

S S

S Q S Q

slide-15
SLIDE 15

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 15

C SC 473 Automata, Grammars & Languages 43

Equivalence of NFA and DFA (contʼd)

  • Verification: Show (1) M is a DFA and (2) L(M)=L(N)

(1) δ′ is a function by the construction, and Q′ is finite: |Q′ | = 2|Q| . So M is a DFA. (2) To show equivalence we prove the

  • Lemma:

Pf: By induction on the length of the input string w. Base |w|=0. Step Suppose (IH) the lemma is true Let To show:

(p,w) N

(

q,) Q. q Q ({p},w)

M

(

Q,)

(p,) N

(

q,) p = q ({p},)

M

({

q},) . | | . w w k

  • | w |

= k + 1 ,w = ua,| u |= k. (p,ua) N

(

q,) Q. q Q ({p},ua)

M

(

Q,)

C SC 473 Automata, Grammars & Languages 44

Equivalence of NFA and DFA (contʼd)

⇒. Assume Then ∃ state r with

and Then By (IH) (*) By construction of M Let Then Using this with (*) results in: So

(p,ua) N

(

q,).

(p,ua) N

(

r,a) N ( q,) (p,u) N

(

r,).

R. r R ({p},u)

M

(R,)

( , ). q r a

  • ( , ).

q R a

  • ( , ).

Q R a

  • =

Q. q Q (R,a)

M

(

Q,). Q. q Q ({p},ua)

M

(R,a)

M

(

Q,). Q. q Q ({p},ua)M

(

Q,).

C SC 473 Automata, Grammars & Languages 45

Equivalence of NFA and DFA (contʼd)

⇐. Assume

Then ∃ state R with So (1) By construction and (2) Since we have from (IH) (3) Combining (2) & (3): So (p,ua) N

(

q,).

  • (p,ua) N

(

r,a) N ( q,)

({p},u)

M

(R,)

. ( , ) r R q r a

  • ( , )

. R a Q

  • =

({p},ua)

M

(R,a)

M

(

Q,). Q. q Q ({p},ua)M

(

Q,).

( r,a) N

(

q,). (p,u) N

(

r,)

slide-16
SLIDE 16

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 16

C SC 473 Automata, Grammars & Languages 46

Equivalence of NFA and DFA (contʼd)

We now finish the verification proof. Let

From the Lemma That is, for some for some ( s ,w)M

(

Q,) Q. f Q ({ s},w)M

(

Q,)

. f F

  • (

s,w) N

(

f,) ( s ,w)M

(

Q,) Q F . ( s,w) N

(

f,) f F

  • .

Q F

  • ( )

( ). L M L N

  • =
  • C SC 473 Automata, Grammars & Languages

47

Example: ε-Free NFA → DFA

  • Consider the previous NFA

( , , , )

,{ }

N Q

p s

  • =
  • ( ( ), ,

,{ )

},

M Q

p F

=

  • P

{p} {p,q} {p,r} {p,q,s} {p,q,r} {p,r,s} {p,q,r,s} a a b b a b a b a b a,b b a

C SC 473 Automata, Grammars & Languages 48

  • ε-closure(R) = E(R) for a set of

states R

a 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ε ε a ε ε ε a ε b ε ε ε c b d

  • closure({4, 5})

=E({4, 5}) ={1, 2, 3, 4, 5, 6,7, 8}

closure (R) = { q Q :(r R) ( r,) ( q,)}

For R ⊆ Q the ε-closure, E(R) of R is:

R

NFA with ε-Moves

slide-17
SLIDE 17

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 17

C SC 473 Automata, Grammars & Languages 49

ε-closure of a set of states

  • Coalesce all nodes reachable from {4,5} by ε-moves:

a 9 10 11 12 13 14 15 a a b c b d {1,2,3,4,5,6,7,8} Note: still an NFA

E({4,5}) E({9}) E({13})

a a Etc. a

  • closure({4, 5})

=E({4, 5}) ={1, 2, 3, 4, 5, 6,7, 8}

C SC 473 Automata, Grammars & Languages 50

Conversion: NFA → DFA

  • Thm: There is an algorithm to convert any NFA to an

equivalent DFA .

  • Pf: Construction: Given NFA

construct new NFA where Verification. Pf: By induction on |w|

M = ( 2

Q,,

, s , F ) ( , , , , ) N Q s F

  • =
  • F

= { S Q | S F }

  • : 2

Q 2 Q

  • s

= E ( s)

  • (

S,a) = { E (p) | p ( q,a) for some q S} ( q,w)

N (p,) (E

( q),w)

M (

P,) for some set P containing p

C SC 473 Automata, Grammars & Languages 51

Conversion: NFA → DFA

  • Thm 1.39: [Rabin-Scott Theorem]: There is an algorithm

to convert any NFA into an equivalent DFA.

  • Corollary 1.40: A language is regular ⇔ some NFA

recognizes it.

  • Ex: Start with an NFA N1 as follows:

ε

1 2 3 4 b b b d ε

1

N = {b,,d}

slide-18
SLIDE 18

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 18

C SC 473 Automata, Grammars & Languages 52

Conversion: NFA → DFA

  • Ex:

ε

1 2 3 4 b b b d ε

1

N

E ( 1 ) = { 1 } E ( 2 ) = { 1 ,2 ,3 } E ( 3 ) = { 1 ,3 } E ( 4 ) = { 4 } 1

b

2 2

b

2 3

b

4 4

b

  • 1
  • 2
  • 3

3

  • 4
  • 1

d

  • 2

d

  • 3

d

  • 4

d

3

Useful summary

C SC 473 Automata, Grammars & Languages 53

Conversion: NFA → DFA

  • Ex:

ε

1 2 3 4 b b b d ε

1

N

  • s

= E ( 1 ) = { 1 }

  • (

s ,b) = E ( 2 ) = { 1 ,2 ,3 }

  • (

s ,) =

  • (

s ,d) =

  • ({

1 ,2 ,3 },b) = E ( 1 ) E ( 2 ) E ( 3 ) E ( 4 ) = { 1 ,2 ,3 ,4 }

  • ({

1 ,2 ,3 },) = E ( 3 ) = { 1 ,3 }

  • ({

1 ,2 ,3 },d) =

C SC 473 Automata, Grammars & Languages 54

Ex: NFA → DFA (contʼd)

  • Ex:

ε

1 2 3 4 b b b d ε

1

N

  • ({

1 ,3 },b) = E ( 2 ) E ( 4 ) = { 1 ,2 ,3 ,4 }

  • ({

1 ,3 },) =

  • ({

1 ,3 },d) =

  • ({

1 ,2 ,3 ,4 },b) = E ( 2 ) E ( 4 ) = { 1 ,2 ,3 ,4 }

  • ({

1 ,2 ,3 ,4 },) = E ( 3 ) = { 1 ,3 }

  • ({

1 ,2 ,3 ,4 },d) = E ( 3 ) = { 1 ,3 }

slide-19
SLIDE 19

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 19

C SC 473 Automata, Grammars & Languages 55

Conversion: NFA → DFA (contʼd)

1

M

1 123 13 1234

b b b d

b

C SC 473 Automata, Grammars & Languages 56

Regular Expression → NFA

  • Thm 1.55: There is an algorithm that, given a regular

expression E, constructs a NFA N such that L(E) = L(M). Pf: Induction on the # of operator symbols in E. Base: E = ε ∅ a∈Σ Step: Assume (IH) the result is true of all expressions with ≤ operator symbols (+,⋅,*). Let E have k+1 ops. Three cases: Case E = (E1+E2). By IH, ∃ FA M1 , M2 with L(E1) = L(M1) and L(E2) = L(M2). Construct the following NFA M. a

C SC 473 Automata, Grammars & Languages 57

1

M

2

M

ε ε

1

F

2

F M

1 2

F F F =

  • 1

2

( ) ( ) ( ) L M L M L M =

  • Case +
slide-20
SLIDE 20

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 20

C SC 473 Automata, Grammars & Languages 58

Regular Expression → NFA (cont”d)

  • Case E = (E1⋅E2). By IH, ∃ FA M1 , M2 with L(E1) = L(M1)

and L(E2) = L(M2). Construct the following NFA M.

C SC 473 Automata, Grammars & Languages 59

2

M

ε

M

2

F F =

1 2

( ) ( ) ( ) L M L M L M =

i

Case •

2

F

1

F

1

M

ε

Unmark final states in M1

C SC 473 Automata, Grammars & Languages 60

Regular Expression → NFA (cont”d)

  • Case E = (E1)*. By IH, ∃ FA M1 with L(E1) = L(M1).

Construct the following NFA M.

slide-21
SLIDE 21

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 21

C SC 473 Automata, Grammars & Languages 61

s

M

1

{ } F F s =

  • 1

( ) ( ) L M L M

  • =

Case *

1

F

1

M

ε ε ε

QED

C SC 473 Automata, Grammars & Languages 62

ε b ε ε ε a ε a ε b a a

Example: Reg. Exp.→NFA

  • (b+aa)*

Not very economical

C SC 473 Automata, Grammars & Languages 63

Regular Expressions—Applications

  • Regexp used in various development tools

 qed – interactive text editor. 1st version Lampson & Deutsch 1967 ◆ Regexp added by Ken Thompson, Bell Labs, ca. 1968  Regexp compiled into NFA in machine code  Rabin-Scott idea used to scan “on the fly”  One of the first software patents ◆ Offspring ed by Ken for Unix ◆ Many others followed: em, vi / ex, sam, qedx, …  grep, egrep - pattern search in a file  shell – command line interpreter  lex – lexical analyzer generator  sed – non-interactive stream editor  awk – pattern scanning and processing language  perl – pattern-driven programming language

slide-22
SLIDE 22

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 22

C SC 473 Automata, Grammars & Languages 64

Applications (contʼd)

  • Regular expressions = “patterns”

meaning awk regexp matches >=1 r r+ matches >=0 r r* matches 0 or 1 r r? matches r then s rs matches r or s r|s match literal “c” \c match begin/end line ^ $ match any char

.

group exprs (s) character list [abc…] negated char list [^abc…]

C SC 473 Automata, Grammars & Languages 65

Applications--Examples

  • ?[0-9]+

nonempty digit strings, optional sign [^0-9] any char except digit \[.*\] reference citations in a paper g/^[ ]*$/d delete blank lines g/[ ]+/d delete lines with a blank Ex: match is always (1) leftmost and (2) longest file: abcddddef vi: s/d*/x/ → xabcddddef s/d+/x/ → abcxef Ex: csh: sort roll[1-5] | egrep “C SC|MATH” | pr

C SC 473 Automata, Grammars & Languages 66

Applications--Examples

Ex: traditional spelling mnemonic

  • “i before e, except after c,
  • r when pronounced ʻaʼ,

as in ʻneighborʼ and ʻweighʼ

  • -except for ʻweirdʼ examples.”
  • grep “[^c]ei” /usr/share/dict/words > foo

cat foo abseil Aeneid ageing Alamein albeit atheist Boeing Budweiser caffein canoeist deice deictic dilettanteism dreidl ...

  • if you think this spelling rule is sufficient, you will be deficient,

inefficient, unscientific and far from omniscient

slide-23
SLIDE 23

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 23

C SC 473 Automata, Grammars & Languages 67

Applications--Examples

Ex: lex – generates a lexical analyzer yylex(). Example: wordcount (wc) %{ int nchar, nword, nline; %} %% \n { nline++; nchar++; } [^ \t\n]+ { nword++, nchar += yyleng;} // yyleng = length of matched string . { nchar++;} %% int main(void) { yylex(); // invoke generated lexer printf("%d\t%d\t%d\n", nchar, nword, nline); return 0; }

C SC 473 Automata, Grammars & Languages 68

L Regular ⇔ L Denoted by a Reg. Expr.

  • Weʼve defined “regular” as meaning: recognized by a DFA

(equiv. to rec. by an NFA)

  • This equivalence result is known as “Kleeneʼs Theorem”
  • Weʼve already shown the ⇐ direction—we constructed an

NFA from a regular expression (Using Rabin-Scott we could convert this NFA to a DFA.)

  • Now we show the ⇒ direction: given a DFA M construct

a regular expr. E with L(M) = L(E).

  • Thm (Kleene): There is an algorithm that, given a DFA M ,

computes a regular expression E such that L(M) = L(E).

  • Pf: Given the graph of the DFA, use the “node elimination

algorithm” to gradually eliminate all nodes in favor of expressions on the edges of the graph.

C SC 473 Automata, Grammars & Languages 69

B C 1 1 A 1 S a ε ε B C 1 1 A 1 B 1 00 1 ε ε

Kleeneʼs Thm: use “Generalized NFA”

A S a 01 A S a 1(1+01)*00+0 ε ε S a ε(1(1+01)*00+0)*ε

E =(1(1+01)*00+0)*

1. Add init. S, & final a

  • 2. Elim. C
  • 3. Elim. B
  • 4. Elim. A

Order: CBA

slide-24
SLIDE 24

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 24

C SC 473 Automata, Grammars & Languages 70

Ex: Node Elimination Algorithm

B A

b b a b a

C B

C

A

b b a b a

Add ε-moves:

S

ε a ε

C SC 473 Automata, Grammars & Languages 71 B

C b b

ba*a

S

ε a ε

B

bb bba*a

S

ε a b (bb+bba*a)*b

S

a

  • Elim. A:
  • Elim. C:
  • Elim. B:

ACB

Ex: Node Elimination Algorithm (ACB)

A AC

C SC 473 Automata, Grammars & Languages 72 B

C

A

b b a b a

S

ε a ε

Ex: Node Elimination: other orders

slide-25
SLIDE 25

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 25

C SC 473 Automata, Grammars & Languages 73 B

b

S

ε a

B

bb bba*a

S

ε a b (bb+bba*a)*b

S

a

  • Elim. C:
  • Elim. A:
  • Elim. B:

CAB=ACB

Ex: Other elimination orders (CAB)

bb

A

bb a a

CA= AC (above) C

C SC 473 Automata, Grammars & Languages 74 B

b

S

ε a

A S

a (bb)*b (bb)*b+(bb)*bba*a(bb)*b

S

a

  • Elim. C:
  • Elim. B:
  • Elim. A:

CBA

Ex: Other elimination orders (CBA)

bb

A

bb a a

CB C

(bb)*bb a a(bb)*b

C SC 473 Automata, Grammars & Languages 75 A S

a b(bb+ba*ab)*

S

a

  • Elim. B:
  • Elim. A:

BAC=ABC

Ex: Other elimination orders (BAC)

BA =AB B

a

C

b bb ε b ab

S

a

C

b bb ba*ab ε

  • Elim. C:
slide-26
SLIDE 26

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 26

C SC 473 Automata, Grammars & Languages 76

Ex: All elimination orders equiv (BAC = ACB)

BAC

b(bb+ba*ab)*

ACB

(bb+bba*a)*b Easy to prove by induction: for any expression E, b(Eb)*=(bE)*b. Using this identity: b(bb+ba*ab)* = b[ (b+ba*a) b]* = [b (b+ba*a) ]*b = (bb+bba*a)*b Further regular expression simplication is possible:

b(bb+ba*ab)*=b[b(b+a*ab)]*=b[b(ε+a*a)b]* =b[ba*b]*

Good exercise: show results of all other elimination orders are equivalent to these, using regular expression algebra

C SC 473 Automata, Grammars & Languages 77

Algebra of Regular Expressions

  • ∃ an algebra for symplifying regular expressions
  • Can use this algebra to construct RegExps from FSA

r+s = s+r (r+s)+t=r+(s+t) r+r=r r+∅=r (rs)t = r(st) rε = εr = r r∅ = ∅r = ∅ r(s+t) = rs + rt (r+s)t = rt + st ∅* = ε (r*)* = r* r* = r + r* r* = ε + rr* (r*s*)* = (r+s)*

C SC 473 Automata, Grammars & Languages 78

Solving Regular Expr Equations

  • Can solve “linear equations” with regexp variables

X = aX + b =a(aX + b) + b = a2X + ab + b = a2 (aX + b) + ab + b = a3X + a2b + ab + b … X = a*b Check: a[a*b] + b = aa*b + b = (aa*+ε)b = a*b Ex: X

b a

Y X = aX + bY Y = ε  X = a*b

slide-27
SLIDE 27

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 27

C SC 473 Automata, Grammars & Languages 79

Solving RegExp Equations (contʼd)

  • Ex: NFA  RegExp

B C 1 1 A 1

1 1 1 ___ elim. ____ 1 0 11 0 11 0 ___ elim. ____ ( 11 0 )0 11 0 ( 11 0 )0 [ 11 0 ( 11 0 )0 ] [ 11 0 ( 11 0 )0 ] Simplify using reg. algebra: 11 0 ( 11 0 )0 [ 11 0 ( 11 A A B B B C C A B B B C A A C C A C C C A A A A A

  • =

+ + = + = + = = + + = + = = + + = + + = + + = + )] ( 11 0 )0 (( 11 0 ) 0 ) A

  • =
  • =

Gauss-Jordan elimination & back-substitution

C SC 473 Automata, Grammars & Languages 80

Ex: Node Elimination Example via Algebra

  • Want B. C is accept state.
  • Elim. A:
  • Elim B:
  • Elim C:

B A

b b a b a

C

A aA aB B bC C bA bB

  • =

+ = = + +

* A a aB =

* B bC C ba aB bB

  • =

= + +

B bC = * ( * ) C ba abC bbC ba ab bb C

  • =

+ + = + + ( * ) * C ba ab bb = + ( * ) * B bC b ba ab bb = = + Simplifies to = ( * ) * B b ba b

C SC 473 Automata, Grammars & Languages 81

Closure Properties

  • A class of languages is said to be closed under an
  • peration if applying that operation to members of the

class results in a language that is again a member of the

  • class. Example: the regular languages are closed under

the operations of union, concatenation and Kleene star.

  • Thm: The regular languages are closed under intersection

and complementation. Pf: Complementation. Let L = L(M) where is a DFA. Then the FA is also deterministic, and So w leads to a non- accepting state in ⇔ w leads to an accepting state in So

( , , , , ) M Q s F

  • =
  • ( , , , , )

M Q s F

  • =
  • (

s,w) M

(

q,) ( s,w) M

(

q,). . M M ( ) ( ). L M L M

  • =
slide-28
SLIDE 28

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 28

C SC 473 Automata, Grammars & Languages 82

Closure Properties (contʼd)

  • Intersection. Let be regular. By DeMorganʼs law

Since the regular languages are closed under complementation and union, the result follows.

1 2

, L L

1 2 1 2

( ). L L L L

  • =
  • C SC 473 Automata, Grammars & Languages

83

Closure Properties (contʼd)

  • Another proof of closure under ∩ illustrates the technique

called “cross-product construction”. See Sipser text, Theorem 1.25.

  • Thm: The class of regular languages is closed under the

intersection operation. Pf: Assume and , where the automata are deterministic.

  • Construction. Construct a “cross-product machine” M as

follows: where the transition function is defined by: Machine M simulates the two given machines “in parallel”, keeping each machine state in one component of

1 1 1 1 1 1 1 1

( ), ( , , , , ) L L M M Q s F

  • =

=

  • 2

2 2 2 2 2 2 2

( ), ( , , , , ) L L M M Q s F

  • =

=

  • 1

2 1 2 1 2 1, 2 1 2

( , , ,( ), ) M Q Q s s F F

  • =
  • 1

2 1 2 1 1 2 2

(( , ), ) ( ( , ), ( , )). q q a q a q a

  • =

1 2

( , ). q q

C SC 473 Automata, Grammars & Languages 84

Closure Properties (contʼd)

Verification By an easy induction on |x|, can show that Therefore, for a pair of final states This says that i.e., that

(( q1,q2),x) M

((p1, p2),)

( q1,x)M1

(p1,) (

q2,x)M2

(p2,)

(( s1,s2),x)M

((

f

1,f 2),)

( s1,x)M1

(

f

1,) (

s2,x)M2

(

f

2,) 1 1 2 2

, f F f F

  • 1

2

( ) ( ) ( ) x L M x L M x L M

  • 1

2

( ) ( ) ( ). L M L M L M =

slide-29
SLIDE 29

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 29

C SC 473 Automata, Grammars & Languages 85

Closure Properties (contʼd)

  • Defn: A homomorphism h is a function that maps each

symbol of to a string over some alphabet Δ, i.e.,

  • The homomorphism is extended to operate on strings

character-by-character, i.e.,

  • It is further extended to languages element-wise, i.e.,
  • Thm: If L is regular and h is a homomorphism, then h(L) is

regular. Pf: Assume L is recognized by a DFA

1 2

{ , , , }

n

a a a = …

1 1 2 2

( ) , ( ) , , ( )

n n

h a w h a w h a w = = = …

1 2 1 2

( ) ( )( ) ( ).

n n

hc c c hc hc hc = … … ( ) {( ): }. h L hw w L =

  • ( , , , , ).

M Q s F

  • =
  • C SC 473 Automata, Grammars & Languages

86

Closure Properties (contʼd)

  • Construction: Construct the machine

where for each transition in M: put into Mh the transition An easy induction establishes that from which it follows that

( , , , , )

h h

M Q s F

  • =
  • a

p q

h(a)

p q ( s,w) M

(

q,) ( s,h ( w)) M h

  • (

q,),

( ) ( ( )).

h

L M h L M =

  • Note: GNFA

C SC 473 Automata, Grammars & Languages 87

What is Not Regular?

  • FA have a very limited computing ability. They cannot, for

example, recognized strings of well-nested parentheses,

  • r well-formed arithmetic expressions, or even the

language of strings of the form w#w, having two copies of the same substring.

  • How can we show some languages are not regular? We

will give a property that all regular languages must have (called the pumping property). Then, to show that a language L is not regular, we argue that it lacks this pumping property.

slide-30
SLIDE 30

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 30

C SC 473 Automata, Grammars & Languages 88

Pumping Lemma

  • Thm [Pumping Lemma for Regular Languages]. Suppose

that L is an infinite¹ regular language. Then

¹All finite languages are regular, so only infinite languages are

  • f interest.

( )( )[ ( , , )( ( ) )]

i

p w w L w p x y z w xyz y xy p i xy z L

  • =
  • C SC 473 Automata, Grammars & Languages

89

Pumping Lemma (English)

  • Thm [Pumping Lemma for Regular Languages]. Suppose

that L is an infinite¹ regular language. Then there is some number p (called the pumping length) such that: if w is any string in L with |w| ≥ p, then w can be factored into 3 substrings, w = xyz, that satisfy the following 3 conditions: (i) y ≠ ε [y is not empty] (ii) |xy| ≤ p [the prefix and pumped part are short] (iii) for every i ≥ 0, xyiz ∈ L [“pumped up” and “pumped down” (i = 0) versions of the string must also be in L]

¹All finite languages are regular, so only infinite languages are

  • f interest.

C SC 473 Automata, Grammars & Languages 90

Pumping Lemma (contʼd)

  • Pf: Let be a DFA recognizing L and

let p be the number of its states. Let be an input string of length n where n ≥ p. Let be the sequence of states that M enters while processing w so that for This state sequence has length n+1 ≥ p+1. Among the first p+1 states of this sequence, at least 2 must be the same state [“pigeonhole principle”]. Call the first of these 2 and the second . Because

  • ccurs among the first p+1 places in the

sequence we have that k ≤ p+1. Define the following substrings of w: ( , , , , ) M Q s F

  • =
  • 1 2

n

w a a a =

  • 1

2 1

, , ,

n n

r r r r +

  • 1

( , )

i i i

r r a

  • +

= 1 . i n

  • j

r

k j

r r =

1 2 1

, , ,

n n

r r r r +

  • 1

1 1

, ,

j j k k n

x a a y a a z a a

  • =

= =

  • k

j

r r =

slide-31
SLIDE 31

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 31

C SC 473 Automata, Grammars & Languages 91

a rk rn+1 r1

1 1 j

x a a =

  • 1

j k

y a a =

  • =rj

k n

z a a =

  • Pumping Lemma (contʼd)
  • Picture:
  • From the picture, we see that there is an accepting path

from to a final state for all the strings of the form . Also, since it must be that Furthermore, so .

1

s r =

1 n

r + ,

i

xy z i j k

  • .

y

  • 1

k p

  • +

. xy p

  • C SC 473 Automata, Grammars & Languages

92

Non-regular Examples

  • Ex: is not regular.

Pf: By contradiction. Suppose L is regular. Then by the Pumping Lemma, Then it follows that is a perfect square. This is impossible. For suppose for a so large that Then Hence falls “in between” perfect squares—a contradiction.

2

{ : }

k

L a k =

  • (

, , ) , ( ), [( ) ( ) .

p q r p q n r

x y z x a y a q z a n a a a L

  • =

= > =

  • (

) n p q n r

  • +
  • +

2

p r q n k + +

  • =

k 2 1 . k q + > ( 1 ) p r q n + +

  • +

2 2 2

2 1 ( 1 ). k q k k k = + < + + = +

( 1 ) p r q n + +

  • +
  • C SC 473 Automata, Grammars & Languages

93

Non-regular Examples (contʼd)

  • Ex: is not regular.

Pf: By contradiction. Suppose L is regular. Then by closure properties of the regular languages is regular. Now We show cannot be regular, which provides a contradiction. If is regular, then there are substrings with such that Case 1. y is entirely in the aʼs. Assume it is in the aʼs before the 2 bʼs (The other subcase is symmetric). Then and But then where This is a contradiction.

{ : { , }}

R

L w w w a b =

  • *

* 1

L L a bba =

  • 1

{ : }.

n n

L

a bba n =

  • 1

L

1

L

y

  • , ,

x y z

1

.

n

n xy z L

  • ,

, ( )

p q r s

x a y a z a bba q = = = > . p q r s + + =

p r s

a a bba L

  • .

p r s + <

slide-32
SLIDE 32

CSC 473 Automata, Grammars & Languages 9/29/10 Lecture 03 32

C SC 473 Automata, Grammars & Languages 94

Non-regular Examples (contʼd)

  • Case 2. y contains a b. Then has more than 2

bʼs, and so This is a contradiction. Contradictions in all cases ⇒ contradiction to the assumption that is regular. So is not regular.

  • Ex: is not regular. See Text,

Example 1.73.

  • Ex:

is not regular. Pf: Suppose B is regular. Then so is as is its homomorphic image Contradiction.

1

L

3

xy z

3 1.

xy z L

  • 1

L {

: }

n n

L a b

n

=

  • {

: is a well-nested string of parentheses }

B

w w

=

{( ) : }

n n

n =

  • ( )

B B =

  • {

: }.

n n

a b n

  • C SC 473 Automata, Grammars & Languages

95

Decision Problems

  • For a property/predicate P the decision problem for P is:

Given: x

Question: Is P(x) true?

  • Ex: Given DFA M, is it true that L(M) = ∅?
  • Thm: For DFA M all the following decision problems are

solvable, i.e. there exists an algorithm to decide the question for any input: Given Question

  • 1. M,w

w ∈ L(M) ?

  • 2. M

L(M) = ∅ ?

  • 3. M L(M) = Σ* ?
  • 4. M, M′

L(M) ⊆ L(M′ ) ?

  • 5. M, M′

L(M) = L(M′ ) ?

C SC 473 Automata, Grammars & Languages 96

Decision Problems (contʼd)

Pf: Assume given DFAs for inputs. (1) Trace w through M. “Yes” if leads from s to some q ∈ F (2) “Yes” if there is some q ∈ F reachable from s (3) Convert (4) (5) Use (4) twice . ( ) ( ) M M L M L M

  • =
  • =

1 2 2 1

( ) ( ) ( ) ( ) L M L M L M L M

  • =

2

( ) L M

1

( ) L M