4. Properties of Regular Languages CIS 5513 - Automata and Formal Languages – Pei Wang
Questions about formal languages Fundamental questions about a language: Is it regular? Is it empty? Does it contain a specific string? Is it equivalent to another language? A typical regular language contains infinite strings, though has finite representations (as DFA, NFA, ε-NFA, Regular Expression)
Converting among representations ε-NFA to DFA: computing ε-closure, then listing the transitions between subsets DFA to NFA: transforming states to sets of state in the transition function DFA to Regular Expression: incrementally expending expressions to cover paths Regular Expression to ε-NFA: recursively building ε-NFA for each symbol and operation
Closure properties of regular languages If languages L1 and L2 are regular, so are their Union, Concatenations, and Closures Reversals Complements Intersection and Differences Homomorphism (substitution of strings for symbols) and inverse homomorphism These conclusions can be proved constructively
4.2.1: Suppose h is the homomorphism h(0) = a, h(1) = ab, h(2) = ba Exercises for Section 4.2 4.2.1: Suppose h is the homomorphism h(0) = a, h(1) = ab, h(2) = ba (a) What is h(0120)? (c) If L is L(01*2), what is h(L)? (e) If L = {ababa}, what is h-1(L)? 4.2.2: L/a, the quotient of L and a, is { w | wa L }. Prove: if L is regular, so is L/a Solutions: http://infolab.stanford.edu/~ullman/ialcsols/sol4.html#sol42
Pumping lemma
Applications of pumping lemma Pumping lemma can be used to prove that a language is not regular Example 4.2: the language Leq whose sentences each has the same number of 0’s and 1’s. Pick w = 0n1n, then xy contains 0 only Example 4.3: the language consisting of all strings of 1’s whose length is a prime. Pick w = 1p with p > n+2. Let |y| = m, |xyp-mz| = (m+1)(p–m), where both factors cannot be 1
Emptiness of regular languages If the language is represented by an automaton, then the question is about whether the final states are reachable from the start state, which can be solved by graph search If the language is represented by an expression without Ø, it is not empty; otherwise it can be decided recursively by checking each step of the construction
Membership of regular languages If the language is represented by an automaton, simply check δ^(q0, w) F Otherwise convert the representation into DFA first, or directly compare it with the Regular Expression that generates the language
Equivalence of states Two states p and q of a DFA are equivalent if for all input strings w, δ^(p, w) F if and only if δ^(q, w) F Otherwise they are distinguishable
Recognizing distinguishable states BASIS: an accepting state and a non-accepting state are distinguishable INDUCTION: If two states lead to distinguishable states by the same input symbol, they are distinguishable themselves
Equivalent states in a DFA {C} vs. {A, B, D, E, F, G, H} {D, F} vs. {A, B, E, G, H} on 0 {B, H} vs. {A, E, G} on 1 {G} vs. {A, E} on 1
Minimization of DFA’s A DFA can be minimized by removing the states unreachable from the start state, then merging the equivalent states A minimized DFA has fewest states among the equivalent DFA’s
Equivalence of DFA’s Two DFAs are equivalent if when they are considered as within the same DFA, the two start states are equivalent