7. Closure properties

7.1.1. Identify different strategies to verify that two regular expressions generate the same language. State them as algorithmic procedures.

Click to display ⇲

Click to hide ⇱

All strategies require building DFAs from the regexes.

  1. You can use an existing minimisation algorithm to find the minimal DFAs. Then, label each state from each DFA from 0 to |K|. Fix an ordering of the symbols of the alphabet. Sort the transitions by symbol. Make a textual representation of each DFA which includes the number of states and the sorted transition function. If the textual representations of the two DFAs are identical then they accept the same language.
  2. Use the indistinguishability algorithm to check if the two initial states of the two DFAs are indistinguishable.
  3. Check $ L(A_1) \subseteq L(A_2)$ and $ L(A_2) \subseteq L(A_1)$ . The condition $ L(A) \subseteq L(B)$ can be restated as $ L(A) \cap complement(L(B)) = \emptyset$ . Build the complement DFA for B, and use the product construction with A. Check if the resulting DFA has any final state accessible from the initial one.

7.1.2. Write a regex for the complement of $ L((10 \cup 0)^*(1 \cup \epsilon))$ .

Click to display ⇲

Click to hide ⇱

Build the DFA for that regex and then build the complement of that DFA. Transform it into a regex.

7.1.3. Suppose $ A$ is a DFA. Write another DFA which accepts only those words $ w$ such that both $ w \in L(A)$ and $ reverse(w) \in L(A)$ .

Click to display ⇲

Click to hide ⇱

Build the DFA $ A^R$ which accepts $ reverse(L(A))$ . Build the product construction between $ A$ and $ A^R$ .

Let $ L \subseteq \Sigma^* $ be a language and $ c \in \Sigma $ a symbol. The quotient of $ L $ and $ c $ is the language defined as $ L/c = \{ w \in \Sigma^* | wc \in L\} $.

7.2.1. Let $ L = L((aaa \cup ba)^*(ab)^* )$. What is the language $ L/a $ ?

Click to display ⇲

Click to hide ⇱

$ L/a = L((aaa \cup ba)^*(aa \cup b))$

7.2.2. Let $ L = L(a^*)$. What is the language $ L/a $ ?

Click to display ⇲

Click to hide ⇱

$ L/a = L(a^*)$

7.2.3. Prove that if $ L $ is a regular language, then $ L/c$ is a regular language $ \forall c \in \Sigma$.

Click to display ⇲

Click to hide ⇱

Let $ A$ be a DFA which accepts $ L$ . We build a new DFA $ A/c$ which accepts $ L/c$ . This new DFA has the same number of states, initial state, same transitions and same alphabet. The set of final states is different though: $ F/c = \{q' \in K $ . In other words, the final states of $ A/c$ are those states which are $ c-$ predecessors of some final state of $ A$ . Note that some $ q'$ may be equal to $ q$ , and it may also be the case that no such predecessors exist.

7.2.4. Let $ L \subseteq \Sigma^* $ be a language and $ c \in \Sigma $ a symbol. Then $ c / L = \{ w \in \Sigma^* | cw \in L \} $. Prove that if $ L $ is a regular language, then $ a / L $ is a regular language,$ \forall a \in \Sigma$.

Click to display ⇲

Click to hide ⇱

The easiest way is to rely on other closure properties: $ c/L = reverse(reverse(L)/c)$

7.3.1. Prove that $ \text{suffix}(L) = \{ w \in \Sigma^* | \exists x \in \Sigma^*, \: \text{such that} \: xw \in L \} $ is a closure property.

Click to display ⇲

Click to hide ⇱

Suppose $ A$ is the accepting DFA of L. We build a new NFA from A by adding $ \epsilon-$ transitions from the initial state to all other states of A (obs: if the initial state of A had transitions that entered it, then, in the new NFA, create another initial state that has an $ \epsilon-$ transition to the former initial state). Thus, we can nondeterministically skip any prefix $ x$ of any accepted word from $ L$ . This new DFA accepts $ \text{suffix(L)}$

Let $ min(L) = \{ w \in L | \; \nexists x \in L, \; y \in \Sigma^* \setminus \{\epsilon\}, \: \text{such that} \: xy = w \}$.

Example: If $ L = \{ aab, bab, aa \} $, then $ min(L) = \{ bab, aa \} $.

7.4.1. Describe $ min(L)$ without mathematical notation.

Click to display ⇲

Click to hide ⇱

$ min(L)$ is the set of words from $ L$ that have no proper ($ \neq \epsilon$ ) prefix in $ L$ .

7.4.2. What is the language $ min(L(a^*)) $ ?

Click to display ⇲

Click to hide ⇱

$ min(L(a^*)) = \{\epsilon\}$

7.4.3. What is the language $ min(L(a^*b)) $ ?

Click to display ⇲

Click to hide ⇱

No word from $ L(a^*b)$ has a prefix in this same language, hence the answer is $ L(a^*b)$ .

7.4.4. Prove that $ min $ has the closure property with respect to the regular languages.

Click to display ⇲

Click to hide ⇱

Let $ A$ be the accepting DFA of L. If a word $ w=xy \in L$ has a proper prefix $ x$ in $ L$ , then $ (q_0,xy) \vdash^* (q_1,x) \vdash^* (q_2,\epsilon)$ where $ q_1,q_2$ are final states. We need to break-off those paths leading from one final state (such as $ q_1$ ) to another.

We construct a new DFA which accepts $ min(L)$ . We build a new sink state. We change all outgoing transitions of all final states such that they now go to the sink state. In this way, once a final state was visited once, no other final state can be visited while accepting any word $ w$ . This means $ w$ has no accepting proper prefix.

7.4.5. Let $ L$ be a regular language and $ R = \{xy \mid yx \in L\}$ . Both $ x$ and $ y$ can be empty strings. Show that $ R$ is regular.

Click to display ⇲

Click to hide ⇱

The language $ R$ contains all those words formed by taking any suffix $ x$ of a word from $ L$ an appending its respective prefix $ y$ to it. We start from the accepting DFA $ A$ of $ L$ . We create a new initial state and a new final one. All states of A are no longer initial or final in our construction. We create $ n$ copies of $ A$ , denoted as $ A_q$ , one for each state $ q\in K$ of $ A$ .

We add $ \epsilon-$ transitions from our new initial state, to the corresponding state $ q$ from each copy $ A_q$ . If a final state from copy $ A_q$ is now reached, then a suffix of some word accepted by $ A$ was accepted by our construction. We now need to continue by accepting the prefix part. We create another $ n$ copies of $ A$ , denoted as $ B_q$ . We connect the final state of each suffix DFA $ A_q$ to the initial state of its corresponding prefix DFA $ B_q$ . We also take state $ q$ from copy $ B_q$ and add an epsilon-transition to our final state.

Now, any accepted word of our construction starts from the initial state, skips to some state $ q$ of the suffix DFA $ A_q$ , and consumes a suffix of some word accepted by $ A$ . Next, it moves on the initial state of $ B_q$ , consumes the skipped prefix of the same word, and then accepts.

7.5.1. (Solved during lecture) Define the reversal of a language $ L $ as $ rev(L) = \{ w \in \Sigma^* | rev(w) \in L \}$, where $ rev(c_1c_2 \dots c_n) = c_nc_{n - 1} \dots c_1$ , with $ c_i \in \Sigma, 1 \leq i \leq n $. Show that reversal is a closure property.

7.5.2. Invent a language transformation or an operation between languages. See if you can show that it is a closure property.