Saturday, January 24, 2026

Day three of theory of computation

 1. Non-deterministic Finite Automata (NFA) 

Unlike a DFA, an NFA allows a machine to explore multiple paths simultaneously. 
  • Definition: For a given state and input symbol, an NFA can transition to zero, one, or multiple states.
  • Acceptance: A string is accepted if at least one possible path leads to a final state.
  • Flexibility: NFAs are generally easier to construct than DFAs because you don't need to define transitions for every possible input or worry about "dead states". 
2. NFA with Epsilon Transitions (
ϵepsilon
-NFA) 
An
ϵepsilon
-NFA introduces the epsilon (
ϵepsilon
) move
, which allows the machine to change states without consuming any input symbol. 
  • ϵepsilon
    -Closure:
    This is a critical Day Three concept. It is the set of all states reachable from a specific state using only
    ϵepsilon
    transitions (including the state itself).
  • Use Case:
    ϵepsilon
    -NFAs are highly useful for combining smaller machines (e.g., when implementing the "union" or "star" operations in Regular Expressions).
     
3. Equivalence of NFA and DFA (Subset Construction) 
The most important takeaway of Day Three is that NFAs and DFAs are equally powerful; they both recognize the same class of languages (Regular Languages). 
  • Conversion: Any NFA can be converted to an equivalent DFA using the Subset Construction (or Powerset Construction) algorithm.
  • State Explosion: While an NFA with
    nn
    states is simpler, its equivalent DFA may have up to
    2n2 to the n-th power
    states
    in the worst case.

day two of theory of computation

 1. The Formal Definition (The 5-Tuple) 

A DFA is mathematically defined as a 5-tuple
M=(Q,Σ,δ,q0,F)cap M equals open paren cap Q comma cap sigma comma delta comma q sub 0 comma cap F close paren
: 
  • Qcap Q
    :
    A finite set of states (e.g.,
    {q0,q1,q2}the set q sub 0 comma q sub 1 comma q sub 2 end-set
    ).
  • Σcap sigma
    :
    A finite set of symbols called the alphabet (e.g.,
    {0,1}the set 0 comma 1 end-set
    ).
  • δdelta
    :
    The transition function, defined as
    δQ×ΣQdelta colon cap Q cross cap sigma right arrow cap Q
    . This ensures that for every state and input, there is exactly one destination state.
  • q0q sub 0
    :
    The start state (
    q0Qq sub 0 is an element of cap Q
    ).
  • Fcap F
    :
    The set of accept states or final states (
    FQcap F is a subset of or equal to cap Q
    ).
     
2. Key Rules of DFA Design 
  • Determinism: Every state must have exactly one outgoing arrow for every symbol in the alphabet.
  • No Epsilon (
    ϵepsilon
    ) Moves:
    A DFA cannot change states without consuming an input symbol.
  • Completeness: If a state should not lead to an acceptance path, it must transition to a "Dead State" (trap state) where it stays for all subsequent inputs. 
3. Practical Design Examples 
Common Day Two exercises include building machines for specific languages: 
  • Strings ending with '01': Requires at least 3 states to track the last two seen characters.
  • Even number of 'a's: Uses two states to flip-flop between "Even" (Accepting) and "Odd" (Non-Accepting) counts.
  • Strings starting with 'ab': Uses a "Dead State" for any string that begins with 'b' or 'aa'. 

Day three of theory of computation

 1. Non-deterministic Finite Automata (NFA)   Unlike a DFA, an NFA allows a machine to explore multiple paths simultaneously.   Definition: ...