Given following languages over the alphabet
-
$L_1 = ∅$ . -
$L_2 = \{ε, aa\}$ . -
$L_3 = \{ε, a, aa, ab, abb\}$ . -
$L_4 = \{aabb, aabbb, aa, aaa\}$ . -
$L_5 = \{ε, b, bbb, abab, abba, aabb\}$ . -
$L_6 = \{ε, bbbaa, baba, aaab, aabba, aa\}$ .
- What are the following languages:
-
$L_4L_4$ . -
$(L_1 ∪ L_2 ∪ L_3)^R$ . -
$L_3L_1L_6$ .
-
- Define exponentiation as follows:
$L^K = \{x ∈ L \;|\; ∃ y ∈ K.(\abs{y} = \abs{x})\}$ . What are the languages $L_4L_5$ and $L_6L_1$?
- Concatenation of
$L_4$ with itself gives:$L_4L_4 = \{aabbaabb, aabbaabbb, aabbaa,\;$ $aabbaaa, aabbbaabb, aabbbaa, aabbbaaa, aaaabbb, aaaa, aaaaa, aaaaabb, aaaaabbb\}$ -
$(L_1 ∪ L_2 ∪ L_3)^R = \{ε, a, aa, ba, bba\}$ . -
$L_3L_1L_6 = ∅$ . This is so because there are no words in language$L_1$ to concatenate with.
:- use_module(library(lists)).
concatentated_member(L1, L2, L3) :-
member(M1, L1), member(M2, L2),
string_concat(M1, M2, L3).
concatentated(L1, L2, L3) :-
findall(X, concatentated_member(L1, L2, X), X),
list_to_set(X, L3).
assignment_11a :-
X = ["aabb", "aabbb", "aa", "aaa"],
concatentated(X, X, Y),
[First | Rest] = Y,
write("$$\\{"),
write(First),
maplist(format(',\\allowbreak ~s'), Rest),
write("\\}$$").
- $L_4L_5 = \{aaa, aabb\}$.
- $L_6L_1 = ∅$.
Let
-
$(L_1 ∪ L_2) L_3 = L_1 L_3 ∪ L_2 L_3$ . -
$(L_1 ∩ L_2) L_3 = L_1 L_3 ∩ L_2 L_3$ .
First, I will prove
Similarly, to prove
This conjecture isn’t generally true. Suppose
-
$(L_1 ∩ L_2) L_3 = ∅$ . -
$L_1 L_3 ∩ L_2 L_3 = \{aa\}$ .
I.e. both sides of equation are not equal. This completes the proof.
An equivalence relation over
-
$xRy \iff \abs{x} \geq \abs{y}$ . -
$xRy \iff (\abs{x} = \abs{y} = 0 ∨ x = qz, y = pz, \abs{z} \geq 1)$ .
Total order relation is not symmetric. Suppose
This relation is an equivalence. It is transitive because whenever
The relation is reflexive because whenever every string is either
empty or its last symbol is equal to itself, i.e.
The relation is symmetric because whenever
The relation is also invariant from the right. The proof will proceed by induction on the string’s length.
Base step:
Inductive step: suppose the inductive hypotesis
Build an DFA accepting languages over alphabet
- The language contains all words with a substring
$abb$ , but never with the substring$aa$ . - If the word contains substring
$bb$ must, it must be preceded by$aba$ .
Below is the DFA for the first question:
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm,
semithick]
\node[initial,state] (A) {$q_a$};
\node[state] (B) [right of=A] {$q_b$};
\node[state] (C) [right of=B] {$q_c$};
\node[accepting,state] (D) [right of=C] {$q_d$};
\node[accepting,state] (E) [below of=D] {$q_e$};
\path (A) edge [loop above] node {b} (A)
edge node {a} (B)
(B) edge node {b} (C)
(C) edge node {a} (B)
edge node {b} (D)
(D) edge [loop above] node {b} (D)
edge node {a} (E)
(E) edge [loop left] node {b} (E)
edge node {a} (D);
\end{tikzpicture}
Nodes where the automata dies are not shown.
Below is the DFA for the second question:
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm,
semithick]
\node[accepting,initial,state] (A) {$q_a$};
\node[accepting,state] (B) [below of=A] {$q_b$};
\node[accepting,state] (C) [below of=B] {$q_c$};
\node[accepting,state] (D) [right of=C] {$q_d$};
\node[state] (E) [above of=D] {$q_e$};
\node[accepting,state] (F) [above of=E] {$q_f$};
\node[accepting,state] (G) [right of=D] {$q_g$};
\node[accepting,state] (H) [left of=B] {$q_H$};
\path (A) edge node {a} (B)
edge node {b} (H)
(B) edge node {b} (C)
(C) edge node {a} (D)
(D) edge node {b} (E)
edge node {a} (B)
(E) edge node {b} (F)
edge node {a} (G)
(F) edge node {a} (B)
(G) edge node {a} (D)
edge node {b} (E)
(H) edge node {a} (A);
\end{tikzpicture}
Nodes where the automata dies are not shown.
Given alphabet of binary strings and netation operation defined as follows:
\begin{align*}
\Neg(w) = \begin{cases}
\epsilon &\mbox{if } w = \epsilon \\
1 &\mbox{if } w = 0 \\
0 &\mbox{if } w = 1 \\
0.\Neg(y) &\mbox{if } w = ay \land a = 1 \\
1.\Neg(y) &\mbox{if } w = ay \land a = 0\;.
\end{cases}
\end{align*}
And similarly for languages:
- Does there exist a language
$\overline{L} = \Neg(L)$ ? - Does there exist a language
$\overline{L} \setminus \{ε\} = \Neg(L)$ ?
No, there cannot be such language. Suppose there was such a language, then
Yes, there exists such a language, for instance the language representing all
odd numbers in base 2. Its complement would be a language representing all
even numbers in base 2 and because words in
No number is both odd and even, therefore negation produces exactly the
complement of
- Given DFAs
$A = (Σ, Q, q_0, F, δ)$ and$B = (Σ, Q, q_0, F ∩ (Q \setminus q_0), δ)$ , is it also the case that$L(B) = L(A) ∩ Σ^+$ ? - Given DFA
$A = (Σ, Q, q_0, F, δ)$ construct DFA$B$ from$A$ s.t. it accepts all words of the language of$A$ which have length distinct from 1.
The conjecture is false. Consider the language of unary strings of even length described by the following transitions table:
a | |
---|---|
In other words,
A DFA can accept words of length 1 in only these two scenarios:
- It loops on some input in the first accepting state.
- The state directly linked from the first state is accepting.
Below is the procedure to remove these accepting states while accepting all other inputs.
- If the first state loops on some inputs add a new state
$q_1$ , remove all transitions from$q_0$ to itself and add transitions for the same inputs$I_0$ from$q_0$ to$q_1$ . Add transitions on all inputs from$q_1$ back to itself.For any input which on which
$q_0$ used to loop$B$ now necessary makes at least two transitions before accepting it, possibly accepted string with prefixes that did not cause the automate to loop on$q_0$ are still accepted (nothing has changed). - For each accepting state
$q_n$ directly linked from$q_0$ we do the following:- change
$q_n$ from accepting to non-accepting. - add a new accepting state
$q_2$ . - remove transitions from states
$Q_i$ directly to$q_n$ , for each transition removed add a new one for the same input from$Q_i$ to$q_2$ . - for each outbound transition from
$q_n$ add new transition on the same input from$q_2$ .
- change
\begin{algorithm}
\caption{Ensure the language of this DFA has no words of length 1}
\begin{algorithmic}
\Procedure {$\textit{ensure-word-length-ne-one}$}{$\Sigma, Q, q_0, F, \delta$}
\State $loops \gets \{i \;|\; \exists i \in \Sigma. (\delta(q_0, i) = q_0)\}$
\State $new \gets \textit{make new accepting state}$
\State $backarcs \gets \{(v, w, i) \;|\;
\exists v,w \in Q. (\delta(q_0, j) = v = \delta(w, i) \land i \neq q_0)\}$
\For {$input \in loops$}
\State \Comment{Remove all loops from the first state}
\State \Call {$\textit{add-transition}$}{$q_0, new, input$}
\State \Call {$\textit{remove-transition}$}{$q_0, q_0, input$}
\State \Call {$\textit{add-transition}$}{$new, new, input$}
\EndFor
\For {$input \in \Sigma$}
\State \Comment{Bounce back from the new state to the first state}
\State \Call {$\textit{add-transition}$}{$new, q_0, input$}
\EndFor
\For {$(source, destination, input) \in backarcs$}
\State \Comment{For each state directly reachable \\
\hspace{6.7cm} from the first state reattach \\
\hspace{6.7cm} all inbound transitions \\
\hspace{6.7cm} to the new state}
\State $new \gets \textit{make new accepting state}$
\State \Call {$\textit{remove-transition}$}{$source, destination, input$}
\State \Call {$\textit{add-transition}$}{$source, new, input$}
\State $outbound \gets \{(i, w) \;|\; \exists w \in Q. (\delta(w, i) = destination)\}$
\For {$(input, destination) \in outbound$}
\State \Comment{Bounce back from the new state \\
\hspace{6.7cm} to the states immediately \\
\hspace{6.7cm} reachable from source state}
\State \Call {$\textit{add-transition}$}{$new, destination, input$}
\EndFor
\EndFor
\EndProcedure
\end{algorithmic}
\end{algorithm}
Another way to go about this is to simply construct an automaton accepting
all words of
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm,
semithick]
\node[accepting,initial,state] (A) {$q_a$};
\node[state] (B) [right of=A] {$q_b$};
\node[accepting,state] (C) [right of=B] {$q_c$};
\path (A) edge node {$a \in \Sigma$} (B)
(B) edge node {$a \in \Sigma$} (C)
(C) edge [loop right] node {$a \in \Sigma$} (C);
\end{tikzpicture}