28
Consider Lagrange's four square theorem. It states that if $B = \{1^{n^2}| n \geq 0\}$ then $B^4 = \{1^n | n \geq 0\}$. If $B^2$ is regular, take $A = B$ else take $A = B^2$. Either way, this proves the existence of irregular $A$ such that $A^2$ is regular.
27
There's a significant difference between the question as you pose it and the question posed in the exercise. The question asks for an example of a set of regular languages $L_{1}, L_{2}, \ldots$ such that their union
$$
L = \bigcup_{i=1}^{\infty}L_{i}
$$
is not regular. Note the range of the union: $1$ to $\infty$. Regular languages are closed under finite ...
16
First of all, the question you are asking is open, since an affirmative answer shows that $\sf NP = coNP$. In fact it is one of the most prominent open problems in computer science.
If $\sf P= NP$, then the class $\sf NP$ is closed under complement since $\sf P$ is. If on the other hand $\sf P \not = NP$ then we cannot say whether $\sf NP = coNP$ or not. ...
16
Note that the languages $\emptyset$, $\{\epsilon\}$ and $\Sigma^*$ are regular. Let $L_2$ be any non-regular language over $\Sigma$.
Union. $\emptyset \cup L_2 = L_2$, which is non-regular; $\Sigma^*\cup L_2 = \Sigma^*$, which is regular.
Intersection. $\Sigma^*\cap L_2 = L_2$; $\emptyset\cap L_2 = \emptyset$.
Subtraction. $\Sigma^*\setminus L_2 = \...
answered Nov 13 '15 at 21:32
David Richerby
78.6k2525 gold badges125125 silver badges219219 bronze badges
15
"Effectively closed" means that the family is closed under the operation, and that the closure can be computed by giving an automaton/grammar for it (if the original languages are also given in such an effective representation). E.g., given a finite state automaton, we can actually find an automaton for the complement.
Then it is a natural question, whether ...
15
For all of the examples in this answer, I'm taking the alphabet to be $\{0,1\}$. Note that the languages $\emptyset$ and $\{0,1\}^*$ are definitely not NP-complete.
The class of NP-complete languages is not closed under intersection. For any NP-complete language $L$, let $L_0 = \{0w\mid w\in L\}$ and $L_1 = \{1w\mid w\in L\}$. $L_0$ and $L_1$ ...
answered Apr 30 '14 at 19:08
David Richerby
78.6k2525 gold badges125125 silver badges219219 bronze badges
13
This is a common misconception: complexity is not a measure of size. That is, it's not that "bigger" language are harder.
Intuitively, a language becomes harder when it's harder to describe it (TMs being a form of description). For example, as @Yuval Filmus points out in the comments, the language whose description is "everything" is very easy to decide.
...
13
I was posting only a hint, then I saw other full answers, so this is a full (hidden) succinct solution :-)
13
The statement is false. Consider the language $L = \{a^n b : n \geq 0\}$. Then $L' = \{ a^n b a^n b : n \geq 0 \}$ is not regular (exercise).
The invalid point in your reasoning is a confusion between the following two languages: $L' = \{ ww : w \in L \}$ and $L'' = \{ w_1w_2 : w_1,w_2 \in L \}$. It is $L''$ which is the concatenation of $L$ with itself. ...
answered May 7 '18 at 7:48
Yuval Filmus
246k2424 gold badges258258 silver badges433433 bronze badges
12
This characterization of bounded context-free languages is due to Ginsburg ("The Mathematical Theory of Context-Free Languages"), and appears as Corollary 5.3.1 in his book. For general $k$ there are some restrictions on the semilinear sets, but for $k \leq 2$ these restrictions are always satisfied, and so it is straightforward to deduce that the complement ...
answered Apr 8 '13 at 14:39
Yuval Filmus
246k2424 gold badges258258 silver badges433433 bronze badges
11
The reason that $A$ is not defined as in NP is that we use a finer notion for NP-completeness, which is mapping (Karp) reductions.
Intuitively, in a Karp reduction, we not only want the problem $A$ to be solvable using an oracle for $B$, but we also require that this oracle is only used once, and only as the very last operation.
Why this notion and not ...
11
You cannot do it in general.
It would make the complement of your language semi-decidable, like the language itself. Hence they would be both decidable by running both machines in parallel.
Of course, this concerns only the case of semi -decidable languages for which the TM does not always halt for words not in the language.
If you have a decidable ...
11
Suppose that $L_2 = \Sigma^*$ and $L_1$ includes the empty string. Then $L_1 \cdot L_2 = \Sigma^*$, yet $L_1$ doesn't even have to be computable.
answered Oct 9 '14 at 18:15
Yuval Filmus
246k2424 gold badges258258 silver badges433433 bronze badges
11
Yes you are on right track.
We can first define ($A$ avoids $B$) as ($A$ - ($A$ has $B$)), where ($A$ has $B$) are strings of $A$ which contain strings of $B$ as substrings. Then ($A$ avoids $B$) will be strings of $A$ that do not contain strings of $B$ as substrings.
We can define ($A$ has $B$) as $A \cap (\Sigma^* B \Sigma^*)$. Then ($A$ has $B$) are ...
10
There is another way to look at this problem.
Consider that the Language $L$ is a CFL. This means that there is a grammar $G=\{N,\sum,P,S\}$ that satisfies the CFL. We can assume that this is in Chomsky Normal Form.
If $\epsilon$ is part of the language, trivially $\epsilon^R$ is also part of the language.
Now for every production of the form $P_1 \...
10
Hint:
Suppose it was. Let $L$ be a recognizable language and let $\overline{L}$ be its complement. If $\overline{L}$ was recognizable as well, let $M_1$ and $M_2$ be recognizers of $L$ and $\overline{L}$, respectively.
Can you now use $M_1$ and $M_2$ to construct a decider for $L$? What does this mean for undecidable and recognizable problems like the ...
10
As Shaull noted in the comments, $\{a^n b^n\}$ works. The language is trivially context-free but not regular, so I'll show the complement is context-free. A word which is not of the form $a^n b^n$ is either $a^n b^m$ where $n\neq m$, or not of the form $a^n b^m$ at all. So
$(a+b)^{\ast}-{a^n b^n}=\{a^i b^j: i \neq j\} \cup ((a+b)^{\ast}-a^{\ast} b^{\ast})$
...
10
I looked up Hopcroft and Ullman 1979 and it say on page 281 that it is not closed under reversal. But I found no proof in my very fast look at the relevant chapter.
Searching the web does also give a negative answer, with counter example, on stackoverflow by a member of CS (notation adapted):
$(a+b+c)^*WcW^R$, where $W \in (a+b)^+$; this is non-...
10
Note that the construction for the intersection and union ("and" and "or") of two automata is exactly the same, except for the definition of which states are accepting. The same principle applies to any Boolean combination of any finite set of languages: use the product construction and the appropriate definition of which states should be accepting.
answered Nov 12 '14 at 9:27
David Richerby
78.6k2525 gold badges125125 silver badges219219 bronze badges
10
The notion of a PDA can be generalized to an $S(n)$ auxiliary pushdown automaton ($S(n)$-AuxPDA). It consists of
a read-only input tape, surrounded by endmarkers,
a finite state control,
a read-write storage tape of length $S(n)$, where $n$ is the length of the input string, and
a stack
In "Hopcroft/Ullman (1979) Introduction to Automata Theory, Languages, ...
10
Going by the OP's comments, the real question here is not the one in the title, but "Why is the set of regular expressions a context-free (rather than regular) language?"
The reason is simply the occurrence of parentheses in more complex regular expressions like $(a+b)^*b(a+c)^*$. In order for such an expression to be well-formed, the parentheses must be ...
10
Because regular langauges are closed under complementation. That is, if $L$ is regular, so is $\overline{L}$. (Exercise: prove this.)
So, suppose that $L$ is non-regular. If its complement $\overline{L}$ were regular, then $\overline{\overline{L}}=L$ would also have to be regular.
answered Nov 18 '15 at 18:40
David Richerby
78.6k2525 gold badges125125 silver badges219219 bronze badges
9
The first closure property, closure under intersection, is a DIY proof if you choose the right model for the context-sensitive languages. By defining them with the help of linear-bounded automata you can run two of these automata successively to test (nondeterministically) for acceptance of the intersection.
Second, closure under complement, is hard! It ...
9
That is possible, but perhaps not exactly in the way you ask. As a start take the Dyck language $D_2$ of all strings of matching brackets over two pairs of brackets, say $\{ [,], (,) \}$, or more abstractly $a_1,b_1,a_2,b_2$.
Then every context-free language can be obtained from $D_2$ using homomorphisms, inverse homomorphisms and intersection with regular ...
9
Let $L_1, L_2$ be languages, then the concatenation $L_1\circ L_2=\{w\mid w=xy, x\in L_1, y\in L_2\}$. If $L_2=\varnothing$, then there is no string $y\in L_2$ and so there is no possible $w$ such that $w=xy$. Thus for any $L_1$, we'll have $L_1\circ\varnothing = \varnothing$.
9
The claim is that the intersection of a regular language and a context-free language is context-free. You've intersected a regular language ($\{ab\}$) and a context-free language ($\{a^nb^n\mid n\geq 0\}$) and the result was a context-free language ($\{a,b\}$). Sure, that language is also regular but every regular language is also context-free. The statement ...
answered Jun 22 '16 at 7:45
David Richerby
78.6k2525 gold badges125125 silver badges219219 bronze badges
9
So when doing the transition table of the two automata, if there is no transition, should I just ignore it like in the 3rd automaton?
If there is no transition in one of the automata, then that one won't accept the input word. Therefore, the automaton for the intersection should not accept either; not having a transition is one way to make sure of that.
8
Here is an example of a non-computable language $A$ such that $A^2 = \Sigma^*$. Take any non-computable $K$ (represented as a set of numbers, e.g. the codes of Turing machines that halt), and define
$$ A = \{ w \in \Sigma^* : |w| \neq 4^k \text{ for all } k \in K \}. $$
So $A$ contains all words other than ones of length $4^k$ for some $k \in K$. If $A$ were ...
answered Feb 16 '13 at 17:50
Yuval Filmus
246k2424 gold badges258258 silver badges433433 bronze badges
8
Non regular languages are closed under reverse, because $L = (L^R)^R$. Same is true for complement.
Non regular languages are not closed under most other basic operations though. Consider, for example, that $L \cup \overline{L} = \Sigma^\star$. Similarly, if $L = \{1^{x^2} | x > 1\}$ then $\overline{L} \circ \overline{L} = 1^\star$.
There is no complete ...
8
Let $R$ be a regular language. Then there is a finite automaton $M$ for which the language, $L(M)$, of $M$ is $R$. Without loss of generality, we may assume that $M$ has no unreachable states. Construct a new FA, $M'$, as follows:
For each state $q$ of $M$ which has a sequence of transitions to a final state of $M$, make $q$ a final state. Call the set of ...
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
closure-properties × 328formal-languages × 190
regular-languages × 129
context-free × 82
complexity-theory × 47
finite-automata × 46
automata × 36
computability × 35
pushdown-automata × 18
np × 15
complexity-classes × 13
turing-machines × 12
undecidability × 12
regular-expressions × 11
nondeterminism × 10
semi-decidability × 10
proof-techniques × 9
formal-grammars × 8
reductions × 8
np-complete × 5
pumping-lemma × 5
terminology × 4
space-complexity × 4
computation-models × 4
polynomial-time × 4