Automata & LanguagesTopic #39 of 40

Regular Languages

Closure properties, pumping lemma, and proving languages are not regular.

Definition

A language LΣL \subseteq \Sigma^* is regular if it is recognized by:

  • A DFA, or equivalently
  • An NFA, or equivalently
  • A regular expression

Closure Properties

Regular languages are closed under these operations:

Boolean Operations

OperationIf L1,L2L_1, L_2 regularResult
UnionL1L2L_1 \cup L_2Regular
IntersectionL1L2L_1 \cap L_2Regular
ComplementL\overline{L}Regular
DifferenceL1L2L_1 - L_2Regular

Construction Methods

Union: NFA with ϵ\epsilon-transitions to both machines.

Intersection: Product construction DFA. δA×B((p,q),a)=(δA(p,a),δB(q,a))\delta_{A \times B}((p, q), a) = (\delta_A(p, a), \delta_B(q, a)) Accept if both components accept.

Complement: Swap accept and non-accept states in DFA. (Must be complete DFA — every state has transitions for all symbols.)

String Operations

OperationResult
Concatenation L1L2L_1 L_2Regular
Kleene star LL^*Regular
Reversal LRL^RRegular
Homomorphism h(L)h(L)Regular
Inverse homomorphism h1(L)h^{-1}(L)Regular

Pumping Lemma

Statement

If LL is regular, then there exists p1p \geq 1 (pumping length) such that:

For any string wLw \in L with wp|w| \geq p, we can write w=xyzw = xyz where:

  1. xyp|xy| \leq p
  2. y1|y| \geq 1 (y is non-empty)
  3. For all i0i \geq 0: xyizLxy^i z \in L

Using the Pumping Lemma

To prove LL is not regular:

  1. Assume LL is regular with pumping length pp
  2. Choose a string wLw \in L with wp|w| \geq p
  3. For any valid division w=xyzw = xyz, show pumping fails
  4. Contradiction → LL is not regular

Example: L={anbnn0}L = \{a^n b^n \mid n \geq 0\} is not regular

Proof:

  1. Assume LL is regular with pumping length pp
  2. Choose w=apbpw = a^p b^p (clearly in LL)
  3. Any division w=xyzw = xyz with xyp|xy| \leq p has y=aky = a^k for some k1k \geq 1
  4. Pump up: xy2z=ap+kbpLxy^2z = a^{p+k} b^p \notin L (unequal a's and b's)
  5. Contradiction! LL is not regular. \square

Common Non-Regular Languages

LanguageWhy not regular
{anbn}\{a^n b^n\}Can't count to match
{wwwΣ}\{ww \mid w \in \Sigma^*\}Can't remember first half
{an2}\{a^{n^2}\}Can't count squares
{app prime}\{a^p \mid p \text{ prime}\}Primes not periodic

Myhill-Nerode Theorem

Distinguishability

Strings xx and yy are distinguishable by LL if: z:(xzLyzL) or (xzLyzL)\exists z: (xz \in L \land yz \notin L) \text{ or } (xz \notin L \land yz \in L)

Equivalence Relation

Define xLyx \equiv_L y iff xx and yy are indistinguishable.

This is an equivalence relation with equivalence classes.

Theorem

LL is regular if and only if L\equiv_L has finitely many equivalence classes.

Moreover, the number of classes equals the number of states in the minimal DFA.

Application: Proving Non-Regularity

Find infinitely many pairwise distinguishable strings.

Example: For L={anbn}L = \{a^n b^n\}:

  • Strings a,a2,a3,a, a^2, a^3, \ldots are pairwise distinguishable
  • aia^i and aja^j distinguished by bib^i (if iji \neq j)
  • Infinitely many classes → not regular

Decision Problems

Decidable for Regular Languages

ProblemQuestionComplexity
MembershipIs wLw \in L?$O(
EmptinessIs L=L = \emptyset?$O(
FinitenessIs LL finite?$O(
EquivalenceIs L1=L2L_1 = L_2?O(nlogn)O(n \log n)
InclusionIs L1L2L_1 \subseteq L_2?PSPACE-complete

Emptiness Test

Check if any accept state is reachable from start state.

Equivalence Test

Minimize both DFAs and check isomorphism.

Regular vs. Non-Regular

Regular: Can be Recognized With

  • Finite memory (constant)
  • No stack
  • No counting beyond a constant

Non-Regular: Requires

  • Unbounded memory
  • Counting
  • Matching/balancing
  • Remembering arbitrary patterns

Hierarchy

RegularContext-FreeContext-SensitiveRecursiveRE\text{Regular} \subset \text{Context-Free} \subset \text{Context-Sensitive} \subset \text{Recursive} \subset \text{RE}

Regular languages are the simplest class in the Chomsky hierarchy.