VOOZH about

URL: https://www.geeksforgeeks.org/theory-of-computation/operations-on-dfa/

⇱ Operations on DFA - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Operations on DFA

Last Updated : 17 Dec, 2025

Deterministic Finite Automata (DFA) are abstract machines that recognize patterns and regular languages by processing input step by step using fixed rules. They are widely used in search engines, spell-checkers, and text-processing systems, and DFA operations help build more complex language recognizers from simpler ones.

  • Union → strings accepted by DFA1 or DFA2
  • Concatenation → strings of DFA1 followed by DFA2
  • Reversal → reverse of accepted strings
  • Complement → strings not accepted by DFA
  • Intersection → strings accepted by both DFAs
  • Difference → strings in DFA1 but not in DFA2
👁 operations_on_dfa
Operations on DFA

Here are some key operations on DFAs, explained with examples:

1. Union of Two DFAs (L₁ ∪ L₂)

Union means combining two DFAs so that the new DFA accepts all words that either of the original DFAs would accept. Example: Let,

  • DFA 1 (L₁) accepts L₁ = {a, ab}
  • DFA 2 (L₂) accepts L₂ = {b, ab}
  • The union DFA accepts L₁ ∪ L₂ = {a, ab, b}

Read more about Union process in DFA.

2. Concatenation of Two DFAs (L₁ ∘ L₂)

Concatenation means creating a new DFA that accepts words formed by taking a word from L₁ followed by a word from L₂. Example:
Let,

  • DFA 1 (L₁) accepts L₁ = {a, b}
  • DFA 2 (L₂) accepts L₂ = {c, d}
  • The concatenation DFA accepts L₁ ∘ L₂ = {ac, ad, bc, bd}

Read more about Concatenation process in DFA

3. Reversal of a DFA (Lᴿ)

A new DFA that accepts the reversed versions of words accepted by the original DFA. Example:

  • Let DFA accept L = {ab, abc, ba}
  • Then, reversed DFA accepts Lᴿ = {ba, cba, ab}

Read more about Reversal process in DFA.

4. Complementation of a DFA (L̅)

A new DFA that accepts all words not accepted by the original DFA. Example:

  • Let DFA accept L = {all strings containing 'a'}
  • Then, the complement DFA accepts L̅ = {all strings that do not contain 'a'}

Read more about Complementation process in DFA.

5. Intersection of Two DFAs (L₁ ∩ L₂)

A new DFA that accepts only words that are in both original DFAs. Example:
Let:

  • DFA 1 (L₁) accepts L₁ = {a, ab, bc}
  • DFA 2 (L₂) accepts L₂ = {ab, bc, cd}
  • The intersection DFA accepts L₁ ∩ L₂ = {ab, bc}

Read more about Intersection process in DFA

6. Difference of Two DFAs (L₁ - L₂)

Accepts strings in A but not in B

Let :

  • DFA A accepts strings containing at least one '0'.
  • DFA B accepts strings ending with '1'.
  • Difference DFA L₁ - L₂ accepts strings that have at least one '0' and do not end with '1'.
Comment
Article Tags:

Explore