0% found this document useful (0 votes)
228 views54 pages

Designing Deterministic Finite Automata

Uploaded by

Ramya Samala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
228 views54 pages

Designing Deterministic Finite Automata

Uploaded by

Ramya Samala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Finite Automata

Ziwen Pan
Email: [Link]@[Link]
Basic model for machines

 An automatic door opens in one direction


Basic model for machines

 An automatic door opens in one direction


-- Open to let people in
-- Do not knock people on the opening side

How to design a machine fulfilling the function?


Basic model for machines

 An automatic door opens in one direction


-- Check front people: Yes/No
-- Check rear people: Yes/No
-- Check current status: Open/Close
-- Determine the next status: Open/Close
Basic model for machines

 An automatic door opens in one direction


-- Check front people: Yes/No
-- Check rear people: Yes/No
-- Check current status: Open/Close
-- Determine the next status: Open/Close
Basic model for machines

 An automatic door opens in one direction


Finite Automata -- informal

 An automatic door opens in one direction

State Diagram
Finite Automata -- informal

 An automatic door opens in one direction

Two states: Open/Closed


Finite Automata -- informal

 An automatic door opens in one direction

Start states: Closed


Finite Automata -- informal

 An automatic door opens in one direction

Transitions: arrows that bring


the machine from one state to
another
Finite Automata -- informal

 An automatic door opens in one direction

Accept state/final state: state


with a double cycle

We want to restrict our attention to a simplified scenario


where machines are used to ”compute”Yes/No
Finite Automata -- informal

 Example

Start states Final/Accept states


Finite Automata -- informal

 Example

What happens when we input 1101?


Finite Automata -- informal

 Example

What happens when we input 1101?


Finite Automata -- informal

 Example

What happens when we input 1101?


Finite Automata -- informal

 Example

What happens when we input 1101?


Finite Automata -- informal

 Example

What happens when we input 1101?


Finite Automata -- informal

 Example

What happens when we input 1101?

Machines ends at an accept state, i.e., machine output: Yes


Finite Automata -- informal

 Example

What happens when we input 1101?

Machines ends at an accept state, i.e., machine output: Yes

What happens when we input 101000?


Deterministic Finite Automata -- Formal

 A quintuple 𝑀 = (𝑄, Σ, 𝛿, 𝑞0 , 𝐹) where


- 𝑄 is a finite set of states
- Σ is an alphabet
- q0 ∈ 𝑄 is the initial state
- 𝐹 ⊆ 𝑄 is the set of final/accept states (can be multiple)

- 𝛿, the transition function, a function from Q × Σ to 𝑄


Deterministic Finite Automata

 Example
Deterministic Finite Automata

 A deterministic finite automaton 𝑀 can be viewed as a classifier that filters out all the
strings it accepts
-- The set 𝐴 of all the strings 𝑀 accepts is the language of machine 𝑀
-- Denote as 𝐿 𝑀 = 𝐴
-- 𝑀 recognizes/accepts 𝐴
Deterministic Finite Automata

 A deterministic finite automaton 𝑀 can be viewed as a classifier that filters out all the
strings it accepts
-- The set 𝐴 of all the strings 𝑀 accepts is the language of machine 𝑀
-- Denote as 𝐿 𝑀 = 𝐴
-- 𝑀 recognizes/accepts 𝐴

0,1

What if 𝑀 rejects all inputs? 𝑀 accepts ∅


0,1
𝑞0 𝑞1
DFA Examples

𝑏 𝑏 𝑏 𝑎, 𝑏
• 𝑄 = {𝑞 0 , 𝑞1, 𝑞2, 𝑞 3 }
𝑎 𝑎 𝑎
• Σ = {𝑎, 𝑏 } 𝑞0 𝑞1 𝑞2 𝑞3
• 𝛿=
{((𝑞0 , 𝑎), 𝑞1), ((𝑞0, 𝑏), 𝑞0), ((𝑞1, 𝑎), 𝑞2), ((𝑞1, 𝑏), 𝑞1),
((𝑞2, 𝑎), 𝑞3), ((𝑞2, 𝑏), 𝑞2), ((𝑞3, 𝑎), 𝑞3), ((𝑞3, 𝑏), 𝑞 3 )}
• start state = 𝑞0
• 𝐹 = {𝑞 2 }
DFA Configurations

 Deterministic finite automata are


- Deterministic: given the current state and next input symbol, it moves
deterministically to a next state.
DFA Configurations

 Deterministic finite automata are


- Deterministic: given the current state and next input symbol, it moves
deterministically to a next state.
- Finite: consists of finite number of states
- Automata: machine
DFA Configurations

 We have learned two ways of describing a DFA


- A quintuple 𝑀 = (𝑄, Σ, 𝛿, 𝑞0 , 𝐹)
- A state diagram
 How do we characterize the computation of a DFA?
DFA Configurations

 We have learned two ways of describing a DFA


- A quintuple 𝑀 = (𝑄, Σ, 𝛿, 𝑞0 , 𝐹)
- A state diagram
 How do we characterize the computation of a DFA?
- the computation of a DFA has to be defined on a specific input
- use a sequence of configurations to represent the computation
DFA Configurations

 Configuration for a DFA 𝑀 = (𝐾, Σ, 𝛿, 𝑠, 𝐹)


- any element of 𝐾 × Σ ∗
- the state the DFA currently in
- the remaining part of the string to be processed
DFA Configurations

 Configuration for a DFA 𝑀 = (𝐾, Σ, 𝛿, 𝑠, 𝐹)


- any element of 𝐾 × Σ ∗
- the state the DFA currently in
- the remaining part of the string to be processed

Input string: 𝑎𝑎𝑏𝑏𝑎


DFA Configurations

 We use a binary relation ⊢ M to denote that DFA pass from one state to
another state as a result of a single move
 ⊢ M is a function from 𝐾 × Σ + to 𝐾 × Σ ∗ (L+ = 𝐿𝐿∗ )

Input string: 𝑎𝑎𝑏𝑏𝑎


DFA Configurations
0 1

1 1 1
𝑞0 𝑞1 𝑞2 𝑞3
0 0 0

(q0, 11101) ⊢ M (q1, 1101)


⊢ M (q2, 101)
⊢ M (q3, 01)
⊢ M (q0, 1)
⊢ M (q1, e)
(q0, 11101) ⊢∗𝑀(q1, e) ⊢∗𝑀 : yields in 0 or more steps
DFA Configurations
0 1

1 1 1
𝑞0 𝑞1 𝑞2 𝑞3
0 0 0

(q0, 10111) ⊢ M (q1, 0111)


⊢M (q0, 111)
⊢M (q1, 11)
⊢M (q2, 1)
⊢M (q3, e)
(q0, 10111) ⊢∗𝑀(q3, e) ⊢∗𝑀 : yields in 0 or more steps
Regular language

 𝑀 accepts a string 𝑤 if (𝑞0 , 𝑤) ⊢∗𝑀 (𝑞,𝑒) for some 𝑞 ∈ 𝐹


 𝑀 recognize language 𝐴 if 𝐴 = {𝑤: 𝑀 accepts 𝑤}
 A language is regular if some finite automaton recognizes it.
DFA –> regular language

 All binary strings containing an odd number of 1s


DFA –> regular language

 Example Deterministic Finite Automaton


- All strings over {𝑎, 𝑏} that have length 3.
𝑎, 𝑏

𝑎, 𝑏 𝑎, 𝑏 𝑎, 𝑏 𝑎, 𝑏
𝑞0 𝑞1 𝑞2 𝑞3 𝑞4
DFA –> regular language

 All strings over {0, 1} that contain the substring 101


DFA –> regular language

 All strings over {𝑎, 𝑏} that does not contain three consecutive 𝑏’s
DFA Examples

 All strings over {𝑎, 𝑏} that contains three consecutive 𝑏’s

𝑎
Regular language

 So far we have learned: given an automaton, determine the language it


accepts
 Given a regular language, can we design an automaton recognizing it?
Regular language -> DFA

 All strings consisting of {0,1} and have an odd number of 1s.


Regular language -> DFA

 All strings consisting of {0,1} and have an odd number of 1s.


-- how would you design an algorithm achieving this?
1. read every symbol and check if it is 1;
2. set up a counter, counter -> counter +1 if the symbol is 1;
3. check odd/even of the counter
Regular language -> DFA

 All strings consisting of {0,1} and have an odd number of 1s.


-- how would you design an algorithm achieving this?
1. read every symbol and check if it is 1;
2. set up a counter, counter -> counter +1 if the symbol is 1;
3. check odd/even of the counter

Can we do better without memory?


Regular language -> DFA

 All strings consisting of {0,1} and have an odd number of 1s.


-- how would you design an algorithm achieving this?
1. read every symbol and check if it is 1;
2. set up a counter, counter -> counter +1 if the symbol is 1;
3. check odd/even of the counter

Identify states
Regular language -> DFA

 All strings consisting of {0,1} and have an odd number of 1s.


-- how would you design an algorithm achieving this?
1. read every symbol and check if it is 1;
2. set up a counter, counter -> counter +1 if the symbol is 1;
3. check odd/even of the counter

Identify transitions
Regular language -> DFA

 All strings consisting of {0,1} and have an odd number of 1s.


-- how would you design an algorithm achieving this?
1. read every symbol and check if it is 1;
2. set up a counter, counter -> counter +1 if the symbol is 1;
3. check odd/even of the counter

Identify start and final states


Regular language -> DFA

 All strings consisting of {0,1} and have 001 as a substring.

Identify states: what are the states?


Regular language -> DFA

 All strings consisting of {0,1} and have 001 as a substring.

Identify states: what are the states?

𝑞 𝑞0 𝑞00 𝑞001
Regular language -> DFA

 All strings consisting of {0,1} and have 001 as a substring.

Start and final states?

𝑞 𝑞0 𝑞00 𝑞001
Regular language -> DFA

 All strings consisting of {0,1} and have 001 as a substring.

Transitions
Regular operations

 How to design DFA for very complicated regular language? Is there a


systematic way (or “Algorithm”or designing DFA)?
Regular operations
Regular operations

𝐴 = good, bad , 𝐵 = {boy, girl}


Regular operations

 How to design DFA for very complicated regular language? Is there a


systematic way (or “Algorithm”or designing DFA)?
 Regular language is closed under union, concatenation and star, but how can
we prove it?

Common questions

Powered by AI

To verify if a DFA correctly identifies all strings with an odd number of 1s, apply a testing process that includes: creating a test suite of strings with known outcomes (odd/even number of 1s), executing these test strings through the DFA, and confirming that each string results in DFA ending in the correct state (odd for acceptance, even for rejection). Additionally, review transition logic for errors, ensure state transitions and final states align with the definition of having an odd number of 1s, and double-check against worked examples .

Regular languages being closed under union, concatenation, and star operations implies that applying these operations on regular languages results in another regular language. This property is crucial because it allows the use of basic DFAs to construct more complex languages by systematically combining simpler languages through these operations. For instance, if L1 and L2 are regular languages, their union, concatenation, or Kleene star operation also yields a regular language, enabling the construction of a DFA that can recognize these complex combinations effectively .

The quintuple representation of a deterministic finite automaton includes: a finite set of states (Q), an alphabet (Σ), a transition function (δ) mapping states and symbols to states, an initial state (q0), and a set of accept states (F). This framework allows us to systematically understand and predict how a DFA processes inputs by tracking states and transitions as it deterministically evaluates input strings .

Designing a DFA for complex regular languages systematically involves breaking down the problem using closure properties. Start by identifying simple components of the language, then use union, concatenation, or star operations to combine these components into the full language. A step-by-step method might involve initializing states for simple patterns, then adding transitions to reflect language rules, continuously assessing how each transition maintains the regularity of the correct language. Iteratively refine and add complexity until the entire language can be accurately recognized .

The DFA configuration begins with the initial state and the entire input string. With the string 'aabba', the DFA begins in its start state with (q0, 'aabba'). It will process each symbol in sequence, transitioning to new states as defined by the DFA's transition function. At each step, the state updates based on the input symbol and the DFA's configuration adjusts, eventually allowing it to either accept or reject the string, depending on whether it reaches an accept state with the input fully processed .

Designing a DFA for strings containing '101' involves identifying distinct states that represent the progress through the substring. Begin with an initial state q0 where no part of the substring has been matched. Move to state q1 on reading '1', indicating the first part of the substring. Transition to q2 on reading '0' after q1, indicating '10' has been matched. Finally, transition to an accept state q3 upon reading '1' after q2, signifying the full '101' has been matched. Any deviation resets the state progression as per the DFA's transition rules. This design allows the DFA to track and recognize occurrences of '101' within any input string .

In a DFA, the start state is the initial point where processing begins, while the final (or accept) states determine whether the input string is accepted. A DFA accepts a language if, after processing an input string from the start state through various transitions, it ends in one of the designated final states. If the end configuration of the DFA is in any of these final states, the string is considered as part of the language recognized by the DFA .

In a DFA, configuration progression means moving through states according to the input symbols. For example, given a string '1101' and a binary DFA accepting odd numbers of 1s: Start at the initial state (even state) with (q0, '1101'). Read '1' and transition to the odd state (q1), resulting in (q1, '101'). Continue with '1' and return to even state (q0, '01'). Read '0', staying in even: (q0, '1'). Finally, read '1' going to odd, (q1, ''). Since it ends in an accept state (odd state), the string is accepted .

Finite automata can simulate the operation of an automatic door by using states and transitions to represent the door's functions. In this model, the door has two states: Open and Closed. Transitions depend on inputs such as whether there are people in front or behind the door, and the current status of the door. Specific inputs initiate transitions between states, effectively simulating the door's response to real-world stimuli .

A DFA recognizing binary strings with an odd number of 1s can alternate between two states: one for an even number of 1s and another for an odd number. For instance, starting in the even state, reading '1' transitions the machine to the odd state, and reading another '1' returns it to the even state. For a string like '101', the transitions are: (even, '1') -> (odd, '0') -> (odd, '1') -> (even), ending in the even state, thus not accepted. In contrast, '111' results in transitions: (even, '1') -> (odd, '1') -> (even, '1') -> (odd), which ends in the odd state, thus accepted .

You might also like