0% found this document useful (0 votes)
20 views

Automata

Uploaded by

YASAS MANUJAYA
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Automata

Uploaded by

YASAS MANUJAYA
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Automata

Finite Automata

A formal System

Remember only a finite no. of information.

• Information -> States


• State Change -> Input
• Rues how state change According to input -> transitions

Deterministic Finite Automata DFA

Alphabet - ∑ → all the possible inputs

Strings → all the combinations from the possible inputs

Language – L() → All the strings accepted by an automata

L(A) – set of strings accepted by Automata A

Finite Set of States → Q

Transition functions → δ(A,0) = C

A → initial State

0 → Input

C → next State

Start State → q0

Final State → F

For a string to be accepted it should end in an End/Final state

Strings vs Language

• Strings → all the possible combinations from the alphabet


• Language → only the accepted combinations from the sting
Alternate representation of Transitions: Transition Table

States\inputs 0 1 Transition
→ A A B δ(A,0) = A δ(A,1) = B
B A C δ(B,0) = A δ(B,1) = C
*C C C δ(C,0) = C δ(C,1) = C

Extended transitions – delta hat (δ^)

We know what happens when we give one input to a state it will move to another state but in
extended transitions, we will provide more than one input and then we need to find the transition of the
state to the corresponding inputs.

δ^(B,00) → δ(δ(B,0),0) = δ(A,0) = A → here we know that when we give 0 to the state B it
will move to state A, and then we will consider the next
input based on the current state A.

Ex: δ^(B,001) = δ(δ(B,0),01) = δ(δ(A,0),1) = δ(A,1) = B

Language of a DFA

L(A) = the set of strings accepted by the automata A

L(A) = the set of strings w such that δ(q0,w) is in F state

Formal way representing a language:

{w | w is in {0,1} * and w does not have 2 consecutive 1’s}

| → Such that

Regular Language

For a language to be regular

• it should be accepted by some DFA.


• contain a finite set of strings.
• DFA must accept only the strings in the language and cannot accept anything
else.
Non regular languages

Ex: Square number set, all natural numbers, real numbers, etc.

L(A) = {0n 1n | n>= 1 } and a4 means aaaa

L(A) = {01,0011,000111,00001111, 0000011111…} this never ends and therefore this is a no regular
language

Nondeterministic Finite Automata (NFA)

Main thing here is the non-determinism. Unlike in DFA a here we can transit to different states based in a
single input. As a result, we cannot determine the next state correctly.

1 2 3 B W
1 2,4 5
2 4,6 1,3,5
4 5 6 3 2,6 5
4 2,8 1,5,7
7 8 9 5 2,4,6,8 1,3,7,9
6 2,8 3,5,9
7 4,8 5
8 4,6 7,5,9
9 8,6 5

Alphabet - ∑ → all the possible inputs

Strings → all the combinations from the possible inputs

Language – L() → All the strings accepted by an automata

L(A) – set of strings accepted by Automata A

Finite Set of States → Q

Transition functions → δ(q,0) = {q}

A → initial State

0 → Input
C → next State

Start State → q0

Final State → F

Equivalence of DFA and NFA

DFA can be changed into NFA which accepts the same language.

δD(q,0) = p δN(q,0) = {p}

NFA is always in a set containing a set.

NFA to DFA

B W B W
1 2,4 5 →{1} {2,4} {5}
2 4,6 1,3,5 {2,4} {2,4,6,8} {1,3,5,7}
3 2,6 5 {5} {2,4,6,8} {1,3,7,9}
4 2,8 1,5,7 {2,4,6,8} {2,4,6,8} {1,3,5,7,9}
5 2,4,6,8 1,3,7,9 {1,3,5,7} {2,4,6,8} {1,3,5,7,9}
6 2,8 3,5,9 *{1,3,7,9} {2,4,6,8} {5}
7 4,8 5 *{1,3,5,7,9} {2,4,6,8} {1,3,5,7,9}
8 4,6 7,5,9
9 8,6 5

Do the math

Proof of equivalence

Show by induction on |w| that:

δN(q0,w) = δD({q0},w)

basis : w = ε: δN(q0,w) = δD({q0},w) = {q0}

let w be any length

if w = ε (empty set)

δN(q0,w) = q0

δD({q0},w) = {q0}
assume that w = x (length x)

δN(q0,x) = δD({q0},x) = F

let w = xa (x+1 length)

δN(q0,xa) = δN(δN (q0,x),a) = δN(F,a)

δD({q0},xa) = δD(δD ({q0},x),a) = δD(F,a)

therefore δN(q0,xa) == δD(q0,xa)

NFA with ε transition

Closure of a state → set of states we can reach from state q by following arcs labeled ε.

CL(A) = {A}

CL(E) = {E,B,C,D}
Extended delta of NFA

δ^(A,ε) = CL(A) = {A}

δ^(E,ε) = CL(E) = {B,C,D,E}

δ^(A,01) = del(del(A,0),1)

Equivalence of NFA and ε-NFA

0 1

0 1 ε
A {E} {B}

A {E} {B} Φ B Φ {C}

B Φ {C} {D}
C φ {D}

C φ {D} Φ
D φ Φ

D φ Φ Φ E {F} {C,D}

E {F} Φ {B,C}
F {D} φ

F {D} φ φ

Do the math

Del(B,Ep)= CL(B) = {D,B}

= CL(B) u CL(D) = {B,D} U {D} = {B,D}

= del(B,0) U del(D,0) ➔ φ U φ = φ
= del(B,1) U del(D,1) ➔{C} U φ = {c}

Del(E,Ep)= CL(E) = {E,B,C,D}

= CL(B) u CL(D) u CL(C) u CL(E) = {B,D} U {D} = {E,B,C,D}

= del(E,0) U del(B,0) U del(C,0) U del(D,0) ➔ {F} U φ U φ U φ = {F}

= del(E,1) U del(B,1) U del(C,1) U del(D,1) ➔ φ U {C} U {D} U φ = {C,D}

Procedure

Get ε-NFA → Identify Interesting States → Calculate Closure → Find the Transitions for 1 and 0 (inputs)

Interesting States* → states with transitions for ε → B and E

If the closure of any ε state have the final state then it will become an accepting state.

Regular Expressions RE’s

Operations on languages

3 operations

• Union → {0,1,11,01} U {100,0} = {0,1,11,01,100}


• Concatenation → {0,1} . {1,0} = {01,00,11,10}
• Kleen Star → {0,1}* = {ε,0,1,00,01,10,11,000,001,..} ({0,1}.{0,1}.{0,1}.{0,1}.{0,1}…)

Definition:

If a is any symbol, then a is a RE and L(a) = {a}

1. {a} → language having a sting and that sting is of length 1


2. ε is RE L(ε) = {ε} empty string
3. Φ is RE L(φ) = φ empty set

Induction 1

• E1,E2 → RE ➔ E1 + E2 → RE L(E1+E2) = L(E1) U L(E2)

Induction 2

• E1,E2 → RE ➔ E1 . E2 → RE L(E1E2) = L(E1) . L(E2)


Induction 3

• E1 → RE ➔ E1* → RE L(E1*) = (L(E1))*

Precedence order ➔ ()→* → concatenation → union

Equivalence of RE’s and Finite automata

We should show that for each RE there is a finite automaton that accepts the same language

Symbol a

Union

a+b

concatenation

a.b
Kleen star

Questions

Basic DFA and NFA drawing.

NFA to DFA conversion.

ε – NFA to NFA conversion.

Regular Expressions – IF, While, For loops, somethings from programming, etc.

if(x>0):

while(. {a..z+1..9+<>,..}*.){}

Regular expression conversion to finite automata.

Regular Expressions

1. Write a RE for strings starting with 01 or ending with 01. ∑ = {0,1}


a. {01,0111,1110101010101010011001010011101,…}
b. 01.{0+1}* + {0+1}*.01
2. Write a RE for strings that has at least 2 consecutive 0’s and 1’s.
a. {0+1}*.0011.{0+1}*
3. RE for the language accepting all the strings which starts with 1 & end with 0 ∑ = {0,1}
a. {100101001010101,10,101010100110,…}
b. 1.{1+0}*.0
4. RE for language ∑ = {0} having even length of strings
5. RE for length exactly 2 with ∑ = {a,b}
6. RE for length at least 2 with ∑ = {a,b}
7. RE for even length with ∑ = {a,b}
a. {0,2,4,6,8…}
b. {a}*.{bb}* {abb,aaaabb,aaaaaa,bb,bbbb,bbbbbb,..
8. RE for odd length with ∑ = {a,b}
9. RE starts with a with ∑ = {a,b}
10. RE ends with a with ∑ = {a,b}
11. RE containing a with ∑ = {a,b}
12. RE starts and end with different symbols with ∑ = {a,b}
a. {ab,ba,a……b,b….a,…}
b. a.{a+b}*.b + b.{a+b}*.a
13. RE starts and end with same symbol with ∑ = {a,b}
a. a.{a+b}*.a + b.{a+b}*.b
14. Convert (0+1)*.1(0+1) to ε-NFA
15. Convert 0.(a+b)*.1(a+b)* to ε-NFA
16. Set of strings over the ∑ = {a,b,c} containing at least one a and at least one b
17.

Convert (0+1)*.1(0+1) to ε-NFA


1. Set of strings over the ∑ = {a,b,c} containing at least one a and at least one b

{a,b,c}*.ab.{a,b,c}*

Alphabet {0,1} strings which does not accpect things with 2 consecutive 11’s

You might also like