Languages and acceptance
Today, we are going to return to the idea behind a solution space, which consisted of all of the sequences of legal moves that brought our puzzles into a "winning configuration". Just like how sequences of legal moves get abstracted to words, solution spaces are abstracted to languages.
The "winning configurations" of automata are the accepting states: in the definition of an automaton \(\mathcal A = (Q, A, \delta, F)\), these are the states \(x \in F \subseteq Q\). So the "solution space" of an automaton is, so to speak, the sequences of input letters that transition whichever state you start from to an accepting state.
A common turn of phrase you will see written is the statement "\(x\) accepts the language \(L\)". What this means is that \(L = \mathcal L(\mathcal A, x)\).
The second mistake is to say that a state \(x \in Q\) accepts a language \(L \subseteq A^*\) if every \(w \in L\) is accepted by \(x\). This is equivalent to saying that \(\mathcal L(\mathcal A, x) \supseteq L\), not \(\mathcal L(\mathcal A, x) = L\)! The terminology "\(x\) decides \(L\)" is really a lot clearer, but the standard literature usually uses the word "accept". Not sure why. 🙄
Notation. Given two sets \(X\) and \(Y\), we are going to write \(X \setminus Y\) for the set of elements of \(X\) that are not in \(Y\). Formally, \( X \setminus Y = \{x \in X \mid x \notin Y\} \). The set \(X \setminus Y\) is the complement of \(Y\) in \(X\).
- \(L_1 = \{a, aa, aaa\}\)
- \(L_2 = \{w \in A^* \mid \text{\(w\) ends with \(b\)}\}\)
- \(L_3 = \{w \in A^* \mid \text{\(w\) has an even number of \(a\)'s}\}\)
- \(L_4 = \{w \in A^* \mid \text{\(w\) has \(3k+1\) many \(a\)'s for some \(k \ge 0\)}\}\)
- \(L_5 = \{w \in A^* \mid \text{\(w\) either has \(3k+1\) or \(3k + 2\) many \(a\)'s for some \(k \ge 0\)}\}\)
- \(L_6 = A^* \setminus L_2\)
- \(L_7 = \{w \mid \text{every \(ab\) in \(w\) is immediately followed by a \(ba\)}\}\)
Common descriptions of languages
In the Let 'em Cook problem, we saw some descriptions of languages of the form \[ L = \{w \in A^* \mid \textit{(something that has to be true about \(w\))}\} \] As you have probably gathered so far, the sentence to the right of the \(\mid\) tells you explicitly when a particular \(w \in A^*\) is in \(L\) or not. This method of defining sets is called set comprehension, because you are giving a comprehensive description of which elements are in the set. Set comprehension is the most common way of describing sets of things in general, and it will come up frequently in this course.
Later, we will see a more compact notation for writing down languages.
- Over the alphabet \(A_1 = \{1, 2\}\) of input letters, define the function \(\mathrm{sum} \colon A^* \to \mathbb N\) by \[ \mathrm{sum}(\varepsilon) = 0 \qquad \mathrm{sum}(a_1a_2 \cdots a_n) = a_1 + a_2 + \cdots + a_n \] So, for example, \(\mathrm{sum}(1221) = 1 + 2 + 2 + 1 = 6\). Design an automaton with a state that accepts the language \[ L_1 = \{w \in A^* \mid \text{\(\mathrm{sum}(w)\) is a multiple of \(3\)} \} \]
- Over the alphabet \(A_2 = \{a, c, t\}\) of input letters, design an automaton with a state that accepts the language \[ L_2 = \{w \in A_2^* \mid \text{\(w\) contains the word \(cat\)}\} \]
- Over the alphabet \(A_3 = A_1 \cup A_2\) of input letters, design an automaton with a state that accepts the language \[ L_3 = L_1\cdot L_2 = \{wu \in A_3^* \mid \text{\(w \in L_1\) and \(u \in L_2\)}\} \]
States as literal programs
Returning to the idea that states of automata are programs, we can implement an automaton reading a string of input letters in any programming language rather easily. Working from the code back to an automaton isn't always as easy.
-
Run the program and test out which of the following strings are accepted/rejected (type "quit" to stop the program):
- \(1\)
- \(010\)
- \(\varepsilon\) (just hit Enter/Return)
- \(011011\)
- Write down a transition table for \(\mathcal A\) and draw a state diagram of \(\mathcal A\).
- Which state does the program correspond to?
- Using set comprehension, describe the language accepted by this state.