What are Properties of Regular Languages?
Properties are characteristics that help us understand, analyze, and manipulate regular languages. These properties fall into two main categories:
- Closure Properties: Operations that preserve regularity
- Decision Properties: Questions we can answer algorithmically
Why Properties Matter
Understanding properties helps us:
- Prove a language is regular
- Combine regular languages
- Optimize automata
- Answer questions about languages
- Design efficient algorithms
Two Main Categories
1. Closure Properties
If we perform certain operations on regular languages, the result is still regular
Examples:
- Union of regular languages → Regular
- Intersection of regular languages → Regular
- Complement of regular language → Regular
2. Decision Properties
Questions about regular languages that can be algorithmically decided
Examples:
- Is string w in language L?
- Is language L empty?
- Are two languages equal?
Overview of Closure Properties
Regular languages are closed under:
✓ Union (L₁ ∪ L₂)
✓ Intersection (L₁ ∩ L₂)
✓ Complement (L̄ or Σ* - L)
✓ Concatenation (L₁L₂)
✓ Kleene Star (L*)
✓ Reversal (L^R)
✓ Homomorphism (h(L))
✓ Inverse Homomorphism (h⁻¹(L))
✓ Difference (L₁ - L₂)
✓ Symmetric Difference (L₁ ⊕ L₂)
✓ Substitution
✓ Quotient
Not closed under: ✗ Infinite intersection (∩ᵢ₌₁^∞ Lᵢ)
Overview of Decision Properties
Decidable questions:
✓ Membership: Is w ∈ L?
✓ Emptiness: Is L = ∅?
✓ Finiteness: Is L finite?
✓ Equivalence: Is L₁ = L₂?
✓ Subset: Is L₁ ⊆ L₂?
✓ Disjointness: Is L₁ ∩ L₂ = ∅?
✓ Universality: Is L = Σ*?
✓ Regularity: Is L regular? (for certain representations)
Why Closure Properties are Important
1. Building Complex Languages
Start simple, combine operations:
L₁ = {binary strings ending in 0}
L₂ = {binary strings with even length}
L₃ = L₁ ∩ L₂ (still regular!)
2. Proving Regularity
If L₁ and L₂ are regular, and L₃ = L₁ ∩ L₂, then L₃ is regular
No need to construct DFA from scratch!
3. Language Transformations
Transform one regular language to another:
L = {w | w contains "ab"}
L̄ = {w | w does NOT contain "ab"} (still regular)
4. Optimization
Simplify complex constructions:
- Use algebraic properties
- Combine operations efficiently
- Reduce state count
Basic Closure Properties (Summary)
Union
If L₁ and L₂ are regular → L₁ ∪ L₂ is regular
Construction:
- Method 1: Regex r₁|r₂
- Method 2: NFA with ε-transitions
- Method 3: Product construction for DFAs
Intersection
If L₁ and L₂ are regular → L₁ ∩ L₂ is regular
Construction:
- Product DFA: M₁ × M₂
- State: (q₁, q₂)
- Accept: both components in accept states
Complement
If L is regular → L̄ = Σ* - L is regular
Construction:
- Take DFA for L
- Swap accept and non-accept states
- Result: DFA for L̄
Concatenation
If L₁ and L₂ are regular → L₁L₂ is regular
Construction:
- Regex: r₁r₂
- NFA: Connect L₁’s accept to L₂’s start with ε
Kleene Star
If L is regular → L* is regular
Construction:
- Regex: r*
- NFA: Add loops with ε-transitions
Advanced Closure Properties
Reversal
Definition: L^R = {w^R | w ∈ L} (reverse each string)
If L is regular → L^R is regular
Construction:
- Reverse all transitions in DFA
- Swap start and accept states
- May need NFA (multiple accept → multiple starts)
Example:
L = {ab, abc, abcd}
L^R = {ba, cba, dcba}
If L is regular, so is L^R
Difference
Definition: L₁ - L₂ = {w | w ∈ L₁ and w ∉ L₂}
If L₁ and L₂ are regular → L₁ - L₂ is regular
Construction:
L₁ - L₂ = L₁ ∩ L̄₂
Since:
- L̄₂ is regular (complement closure)
- L₁ ∩ L̄₂ is regular (intersection closure)
Example:
L₁ = {all binary strings}
L₂ = {strings with even length}
L₁ - L₂ = {strings with odd length} (regular)
Symmetric Difference
Definition: L₁ ⊕ L₂ = (L₁ - L₂) ∪ (L₂ - L₁)
If L₁ and L₂ are regular → L₁ ⊕ L₂ is regular
Alternative: L₁ ⊕ L₂ = (L₁ ∪ L₂) - (L₁ ∩ L₂)
Example:
L₁ = {a, ab, abc}
L₂ = {ab, abc, abcd}
L₁ ⊕ L₂ = {a, abcd} (in exactly one, not both)
Homomorphism
Definition: h: Σ* → Δ* (substitutes each symbol with a string)
Example:
h(a) = 01
h(b) = 10
h(ab) = 0110
h(aba) = 011001
If L is regular → h(L) is regular
Construction:
- For each transition q →^a p in DFA
- Replace with q →^{h(a)} p (path for h(a))
Inverse Homomorphism
Definition: h⁻¹(L) = {w | h(w) ∈ L}
If L is regular → h⁻¹(L) is regular
Example:
L = {01, 10}* (alternating 01 and 10)
h(a) = 01, h(b) = 10
h⁻¹(L) = {a, b}* (all strings over {a,b})
Surprising: Easier to prove than homomorphism!
Quotient
Definition: L₁/L₂ = {w | ∃x ∈ L₂ such that wx ∈ L₁}
If L₁ and L₂ are regular → L₁/L₂ is regular
Example:
L₁ = {abc, abcd, abd}
L₂ = {c, d}
L₁/L₂ = {ab, abc} (can append c or d to get into L₁)
Right Quotient: Most common form Left Quotient: L₂\L₁ = {w | ∃x ∈ L₂ such that xw ∈ L₁}
Substitution
Definition: For each a ∈ Σ, substitute a with language s(a)
Example:
s(a) = {0, 00}
s(b) = {1}
s(ab) = {01, 001}
s(aba) = {010, 0010, 0100, 00100}
If L is regular and each s(a) is regular → s(L) is regular
Decision Properties
1. Membership Problem
Question: Given DFA M and string w, is w ∈ L(M)?
Algorithm: Simulate DFA on w
def membership(M, w):
state = q₀
for symbol in w:
state = δ(state, symbol)
return state in F
Complexity: O(n) where n = |w|
Answer: ✓ Decidable in linear time
2. Emptiness Problem
Question: Given DFA M, is L(M) = ∅?
Algorithm: Check if any accept state is reachable from start
def is_empty(M):
reachable = BFS(q₀) # Breadth-first search
return reachable ∩ F == ∅
Complexity: O(n + m) where n = states, m = transitions
Answer: ✓ Decidable in linear time
Equivalent: Is there a path from q₀ to any state in F?
3. Finiteness Problem
Question: Given DFA M, is L(M) finite?
Algorithm: Check for cycles in paths from q₀ to F
def is_finite(M):
# L is infinite iff there's a cycle on path from q₀ to F
return not has_cycle_on_accepting_path(M)
Complexity: O(n + m)
Answer: ✓ Decidable
Key Insight:
- Finite ↔ No cycles on paths to accept states
- Infinite ↔ Cycle exists, can pump strings
4. Equivalence Problem
Question: Given DFAs M₁ and M₂, is L(M₁) = L(M₂)?
Algorithm: Check if (L₁ - L₂) ∪ (L₂ - L₁) = ∅
def equivalent(M₁, M₂):
# Build DFA for symmetric difference
M = (L₁ ∩ L̄₂) ∪ (L₂ ∩ L̄₁)
return is_empty(M)
Alternative: Minimize both DFAs, check isomorphism
Complexity: O(n₁ × n₂)
Answer: ✓ Decidable
5. Subset Problem
Question: Given DFAs M₁ and M₂, is L(M₁) ⊆ L(M₂)?
Algorithm: Check if L₁ - L₂ = ∅
def subset(M₁, M₂):
# L₁ ⊆ L₂ iff L₁ - L₂ = ∅
M = L₁ ∩ L̄₂ # DFA for L₁ - L₂
return is_empty(M)
Complexity: O(n₁ × n₂)
Answer: ✓ Decidable
6. Universality Problem
Question: Given DFA M, is L(M) = Σ*?
Algorithm: Check if L̄(M) = ∅
def is_universal(M):
M_complement = complement(M)
return is_empty(M_complement)
Complexity: O(n)
Answer: ✓ Decidable
Equivalent: Does M accept every possible string?
7. Disjointness Problem
Question: Given DFAs M₁ and M₂, is L(M₁) ∩ L(M₂) = ∅?
Algorithm: Check if intersection is empty
def disjoint(M₁, M₂):
M = intersection(M₁, M₂)
return is_empty(M)
Complexity: O(n₁ × n₂)
Answer: ✓ Decidable
8. Regularity Testing
Question: Is a given language (in some representation) regular?
Depends on representation:
- DFA/NFA/Regex → Yes (already regular)
- CFG → Decidable (check if regular grammar)
- Arbitrary description → May be undecidable
Summary Table: Decision Properties
| Problem | Question | Complexity | Decidable? |
|---|---|---|---|
| Membership | w ∈ L? | O(n) | ✓ Yes |
| Emptiness | L = ∅? | O(n+m) | ✓ Yes |
| Finiteness | L finite? | O(n+m) | ✓ Yes |
| Equivalence | L₁ = L₂? | O(n₁×n₂) | ✓ Yes |
| Subset | L₁ ⊆ L₂? | O(n₁×n₂) | ✓ Yes |
| Universality | L = Σ*? | O(n) | ✓ Yes |
| Disjointness | L₁ ∩ L₂ = ∅? | O(n₁×n₂) | ✓ Yes |
Key Point: All major decision problems for regular languages are decidable!
DFA Minimization
Why Minimize?
Goal: Find smallest DFA accepting the same language
Benefits:
- Fewer states = less memory
- Faster processing
- Unique canonical form (for equivalence testing)
Unique Minimal DFA
Theorem: For every regular language L, there exists a unique minimal DFA (up to isomorphism) accepting L.
This means:
- Every regular language has a smallest DFA
- Two minimal DFAs for same language are identical (after renaming)
- Test equivalence by minimizing and comparing
Minimization Algorithm
Myhill-Nerode Theorem approach:
Idea: Merge indistinguishable states
Two states p and q are distinguishable if:
∃w such that exactly one of δ(p,w) and δ(q,w) is in F
Algorithm (Partition Refinement):
1. Initial partition: {F, Q-F} (accept vs. non-accept)
2. Repeat until no change:
For each group G and symbol a:
Split G if states go to different groups on a
3. Merge indistinguishable states
4. Result: minimal DFA
Complexity: O(n² log n) or O(n log n) with optimizations
Example: Minimization
DFA: 5 states {q₀, q₁, q₂, q₃, q₄}
Step 1: Partition by accept/non-accept
P₀ = {{q₀, q₁, q₂}, {q₃, q₄}}
Step 2: Refine by transitions
On 'a': q₀→q₃, q₁→q₃, q₂→q₄ (different groups!)
Split: {{q₀, q₁}, {q₂}, {q₃, q₄}}
On 'b': No further splits
Step 3: Merge equivalent states
Minimal DFA: 3 states
A = {q₀, q₁}
B = {q₂}
C = {q₃, q₄}
Myhill-Nerode Theorem
The Fundamental Characterization
Myhill-Nerode Theorem: The following are equivalent:
- L is regular
- L is the union of some equivalence classes of ≡_L
- ≡_L has finite index (finitely many equivalence classes)
Where ≡_L is defined as:
x ≡_L y iff for all z, xz ∈ L ↔ yz ∈ L
Equivalence Relation
Two strings x and y are equivalent if:
- They lead to the same behavior for all continuations
- Cannot be distinguished by any suffix
Example:
L = strings ending with "01"
"ab" ≡_L "cd" because:
For all z: "abz" ∈ L ↔ "cdz" ∈ L (both need z = "...01")
Index of ≡_L
Index = number of equivalence classes
Key Results:
- L is regular ↔ index is finite
- Minimal DFA has exactly index(≡_L) states
- Each state corresponds to one equivalence class
Using Myhill-Nerode to Prove Non-Regularity
If index(≡_L) is infinite → L is not regular
Example: L = {0ⁿ1ⁿ | n ≥ 0}
Proof:
Consider strings: 0, 0², 0³, 0⁴, ...
For i ≠ j:
0^i 1^i ∈ L but 0^j 1^i ∉ L
So 0^i ≢_L 0^j
Infinitely many equivalence classes → Not regular!
Regular Language Hierarchy
Within Regular Languages
Finite Languages ⊂ Regular Languages ⊂ Context-Free Languages
All finite languages are regular:
- L = {w₁, w₂, …, wₙ}
- Regex: w₁|w₂|…|wₙ
Example:
L = {a, ab, abc}
Regex: a|ab|abc (regular)
Regular vs. Non-Regular
Regular: Can be expressed by DFA/NFA/Regex Non-Regular: Cannot (e.g., {0ⁿ1ⁿ})
Boundary: Finite memory (states) vs. unbounded counting
Practical Applications
1. Compiler Design
Lexical Analysis:
- Token recognition (membership)
- Verify token definitions don’t overlap (disjointness)
- Optimize lexer (minimization)
2. Network Security
Intrusion Detection:
- Pattern matching (membership)
- Combine rules (union/intersection)
- Check for conflicts (equivalence)
3. Text Processing
Search Engines:
- Query optimization (minimization)
- Complex patterns (closure properties)
- Result filtering (intersection)
4. Database Query Optimization
Pattern Queries:
- Simplify patterns (equivalence)
- Combine conditions (closure)
- Check feasibility (emptiness)
5. Bioinformatics
DNA Sequence Analysis:
- Motif search (membership)
- Pattern combinations (closure)
- Sequence validation (decision properties)
Important Exam Points
- ✓ Closure Properties: Regular languages closed under union, intersection, complement, concatenation, star, reversal, etc.
- ✓ Decision Properties: All major problems decidable (membership, emptiness, equivalence, etc.)
- ✓ Membership: O(n) using DFA simulation
- ✓ Emptiness: Check if accept states reachable
- ✓ Finiteness: Check for cycles on accepting paths
- ✓ Equivalence: Test (L₁ - L₂) ∪ (L₂ - L₁) = ∅
- ✓ Minimization: Unique minimal DFA exists
- ✓ Myhill-Nerode: L regular ↔ finite index
- ✓ Homomorphism: Both h(L) and h⁻¹(L) are regular
- ✓ Difference: L₁ - L₂ = L₁ ∩ L̄₂ (regular)
Common Mistakes to Avoid
✗ Mistake 1: Thinking closure under infinite intersection
✓ Correct: Closed under finite operations only
✗ Mistake 2: Confusing equivalence with subset
✓ Correct: L₁ = L₂ means both L₁ ⊆ L₂ AND L₂ ⊆ L₁
✗ Mistake 3: Thinking decision problems are undecidable
✓ Correct: All standard decision problems for regular languages are decidable
✗ Mistake 4: Multiple minimal DFAs exist
✓ Correct: Minimal DFA is unique (up to state renaming)
✗ Mistake 5: Homomorphism preserves size
✓ Correct: h(L) can be much larger or smaller than L
✗ Mistake 6: Testing emptiness requires checking all strings
✓ Correct: Only need to check reachability (graph search)
Practice Questions
Q1: If L₁ and L₂ are regular, is L₁ ∪ L₂ regular?
Answer: Yes, regular languages are closed under union.
Q2: How to test if L = Σ*?
Answer: Complement L, check if empty. L = Σ* iff L̄ = ∅.
Q3: Can we decide if DFA accepts exactly 42 strings?
Answer: Yes, using finiteness test and counting.
Q4: What’s the complexity of membership testing?
Answer: O(n) where n = input length.
Q5: Are L and L̄ both regular?
Answer: Yes, if L is regular, then L̄ is regular (closure under complement).
Q6: How to prove two DFAs are equivalent?
Answer: Minimize both, check if resulting DFAs are isomorphic.
Q7: What’s the index of ≡_L for finite language?
Answer: Finite (at most |L| + 1 equivalence classes).
Q8: Is L₁/L₂ always regular?
Answer: Yes, if both L₁ and L₂ are regular (quotient closure).
Summary
- Closure Properties: Regular languages closed under many operations (union, intersection, complement, concatenation, star, reversal, homomorphism, quotient, etc.)
- Decision Properties: All major problems decidable:
- Membership: O(n)
- Emptiness: O(n+m)
- Equivalence: O(n₁×n₂)
- All solvable efficiently!
- Minimization: Unique minimal DFA exists, computable in O(n² log n)
- Myhill-Nerode Theorem: L regular ↔ finite index of ≡_L
- Applications: Compilers, security, text processing, databases, bioinformatics
- Key Insight: Regular languages have excellent algorithmic properties - very well-behaved class!
These properties make regular languages extremely useful in practice - we can compute with them efficiently!