Languages and automata
László Kabódi
Denitions
Nondeterministic Finite Automata
I Similar to the Deterministic Finite Automata I The dierence is in the transition function
I There can be multiple transitions for a state and a letter I There can beεtransitions (changing state without reading
from the input)
I The automaton accepts a word if there is an accepting calculation
László Kabódi
Examples
Example
I Σ ={0,1}
I Create a nondeterministic nite automaton for the language, where the words end with 01
Examples
Solution
I L={w|w ends with 01}
A 0 B 1 C
0,1
László Kabódi
Examples
Example II
I Σ ={0,1}
I Create a nondeterministic nite automaton for the language, where the words contain 11 or 101
Examples
Solution II
I L={w|w contains 11 or 101}
A B C D
0,1
1 0,ε 1
0,1
László Kabódi
Examples
Example III
I Σ ={0,1}
I Create a nondeterministic nite automaton for the language, where the words contain 00 and 010
Examples
Solution III
I L={w|w contains 00 and 010} I state D: we already saw 010, we need 00 I state H: we already saw 00, we need 010
A
B C D E
F
G H I J
0,1 0
1 0 0
0 0, 1
0
0 0 1
0
0, 1
0, 1
László Kabódi
Concatenation
Proof for concatenation
I w ∈L1L2 if and only if w =w1w2 where w1 ∈L1 andw2∈L2 I If L1 andL2 are regular thenL1L2 is also regular
I If L1 andL2 are regular languages, there are M1 andM2 nite automata for them
I From all the accepting states ofM1 create εtransitions to the initial state of M2
I The initial state of the new automaton is the initial state ofM1 I The accepting states of the new automaton are the accepting
state ofM2
Concatenation
Example
I Σ ={a,b}
I L1 =words that start with a I L2 =words that end with b
László Kabódi
Concatenation
Example
I L1 =words that start with a
A a B
a,b
I L2 =words that end with b
C b D
a,b
Concatenation
Example
I L1 =words that start with a I L2 =words that end with b I L1L2 =?
I L2L1 =?
László Kabódi
Concatenation
Solution
I L1L2 =words that start with a and end with b
A a B C D
a,b ε
a,b b I L2L1 =words that contain ba
C b D A B
a,b
ε
a,b a
Transitive closure
Transitive closure
I w ∈L∗1 if and only ifw ∈
∞
S
i=0Li1
I Ln1 means L1 concatenated to itself n times.
I L01 =ε
I If L1 is regular then L∗1 is also regular.
László Kabódi
Transitive closure
Proof for transitive closure
I If L1 is regular, there is a nite automaton M1 for it I Create εtransitions from the accepting states to the initial
state
I Set the initial state to be also an accepting state while leaving the original accepting states accepting
I If the initial state has transitions go into it, then we create a new initial state, that will be an accepting state and the epsilon transitions go to that one
Union
Alternative proof for union
I If L1 andL2 are regular languages, there are M1 andM2 nite automata for them
I Create a new initial state
I Create twoεtransitions from this new initial state to the original initial states of M1 andM2
I The accepting states stay the same
László Kabódi
Complement
Complement of a language
I L= Σ∗\L
I In other words the complement of a language contains the words that are not in the original language
I w ∈L⇔w ∈/L
I If Lis regular, thenLis regular, because it can be created with
\ using two regular languages
I Or we can create an automaton from the automaton for Lby swapping accepting and not accepting states, if the initial state has no transition that goes back to it
Complement
Example
I L1,L2,L3⊆ {0,1}∗ I L1 andL3 are regular I is L2 regular if
I L3=L1∩L2? I L3=L1∪L2?
László Kabódi
Complement
Solution
I L3 =L1∩L2: not necessarily, if L3=L1=∅thenL2 can be not regular
I L3 =L1∪L2: not necessarily, if L3=L1= Σ∗ thenL2 can be not regular
Determinization algorithm (without ε )
I How can we create a deterministic nite automaton from a nondeterministic one?
I The idea is to simulate all possible computations of the nondeterministic automaton
I The states are all the possible subsets of the nondeterministic automaton's states
I The transitions are the unions of the transitions from the original states
László Kabódi
Example I
A B C
0, 1
0 1
Solution I
A AB AC
1 0
0 1
0 1
László Kabódi
Example II
A
C
B
a a,b
a,c
a,c
b
b
a,b c c
Solution II
A
B
BC
AC
C AB
ABC a
b
c a, c
b
a, b c a, b, c
a, c
a b
b
c
a, b
c
László Kabódi