← View in Interactive Graph

Finite state automata

Finite Automata, is the machine or method that's used to recognize those patterns of regular expression .

A Finite Automaton (or FSA) is an abstract machine that reads an input string (like "good") one character at a time and then decides if it "accepts" (matches the pattern) or "rejects" (doesn't match) the string

There are two main types :

Deterministic Finite Automaton (DFA)

A Deterministic Finite Automaton (DFA) is a model of computation used to recognize patterns.

Non - Deterministic finite automation (DFS):

same as DFA with Two differences

  1. ϵ-Transitions (Your "void state E")

    • An NFA can move from one state to another without reading any input symbol. This is like a "free" move.

    • A DFA must read an input symbol to change states.

  2. Multiple Next States

    • In an NFA, a single state and a single input symbol (like 'a') can lead to multiple different states at the same time. It's like the path splits. and NFA simultaneously explores all possible paths at once

    • In a DFA, a state and an input symbol lead to exactly one state. The path is always predictable.

Formal Definition (The 5-Tuple)

A DFA is formally defined as a 5-tuple: \{Q, \Sigma, \delta, q_0, F\}


Simple Example

How it Works (Step-by-Step)

Let's use our last example, tracing the input "ab":

  1. Start: You are at q0. The next input symbol to read is 'a'.

  2. Read 'a': You read the 'a'. The NFA splits.

    • One path goes to q1.

    • Another path goes to q3.

  3. Process ϵ-Move: Before the NFA even looks at the 'b', it checks its new states.

    • The path at q3 does nothing.

    • The path at q1 sees the free ϵ-move to q2. It instantly takes this move without reading the 'b'.

  4. Ready for Next Input: The NFA has now processed the 'a' and is ready to read the 'b'. Its active "clones" are at states {q2,q3}.

  5. Read 'b': Now it finally reads the 'b' and proceeds as we discussed before.

graph LR;
    %% Define states
    q0((q0));
    q1((q1));
    q2((q2));
    q3((q3));
    q_final(((q_final))); 

    %% Define transitions
    start(( )) -- Start --> q0;

    %% Feature 2: Multiple Transitions
    q0 -- a --> q1; 
    q0 -- a --> q3; 

    %% Feature 1: Epsilon Transition
    q1 -- ε --> q2; 


    q2 -- b --> q_final;
    q3 -- c --> q_final;

Problem

Solving problems


Tags: