Questions tagged [regular-language]

Regular languages are formal languages which are recognized by a finite automaton. It is equivalently the languages which are expressible as a regular expression. In addition to these two, there are several other equivalent definitions.

1275 questions
32
votes
8 answers

Is the set of all valid C++ programs countably infinite?

I have heard that the set of valid programs in a certain programming language is countably infinite. For instance, the set of all valid C++ programs is countably infinite. I don't understand why though. A programming language has open curly braces…
John Hoffman
  • 2,774
16
votes
4 answers

Can a regular grammar be ambiguous?

An ambiguous grammar is a context-free grammar for which there exists a string that has more than one leftmost derivation, while an unambiguous grammar is a context-free grammar for which every valid string has a unique leftmost derivation. A…
15
votes
1 answer

Automata | Prove that if $L$ is regular than $half(L)$ is regular too

I've see couple of approaches to this kind of questions yet I have no clue how to approach this one. Let L be regular language, and let $half(L)$ be: $half(L) = \{u \mid uv \in L\ s.t. |u|=|v|\}$. Prove that if $L$ is regular then $half(L)$ is…
Aviad
  • 253
12
votes
2 answers

Mystery Men Movie - Propositional Logic

In the movie Mystery Men, there is this scene: Captain Amazing (good guy): I knew you couldn't change. Casanova Frankenstein (bad guy): I knew you'd know that. Captain Amazing: Oh, I know. And I knew you'd know I'd know you knew. Casanova…
11
votes
3 answers

pumping lemma: ww^R not regular

I'm trying to prove that $L = \{ww^R : w \in \{a,b\}^*\}$ ($w^R$ is the reverse of $w$) is not regular using the pumping lemma. Let $p$ be the pumping length and $s = a^pbba^p$. $x = \epsilon$, $y = a^p$, $z = bba^p \implies s = \epsilon a^p bba^p =…
11
votes
6 answers

A computer's memory is finite, so how can there be languages more powerful than regular?

A computer has a finite memory. There are no computers with infinite memory. Therefore the only languages that a computer can process are those whose member strings are finite. As I recall, the computational power required for any finite language is…
10
votes
3 answers

Formally prove that every finite language is regular

I know how to prove this informally, but don't know what the formal proof should look like.
zeqof
  • 191
  • 1
  • 2
  • 10
9
votes
1 answer

Converting to Chomsky Normal Form

I am trying to learn how to convert any context free grammar to Chomsky Normal Form. In the example below, I tried to apply Chomsky Normal Form logic, to result in a grammar, where every symbol either produces two symbols, or every symbol produces a…
9
votes
1 answer

Is the set of regular languages closed under set difference?

Let $\Sigma$ be an alphabet and $L_1,L_2 \subseteq \Sigma^*$ two regular languages. I know that $REG$ is closed under intersections of regular languages and under complementation of a regular language. My reasoning looks like this: $L_1 \setminus…
9
votes
4 answers

Intersection of two deterministic finite automata?

I'm trying to solve a problem where I have to create a DFA for the intersection of two languages. These are: $$\{s \in \{{\tt a}, {\tt b},{\tt c}\}^\ast : \mbox{every ${\tt a}$ in $s$ is immediately followed by a ${\tt b}$}\}$$ and $$\{s \in…
8
votes
1 answer

Prove regular language closed under min and max

Given some regular language $L$, show that $L$ is closed under the following operations: $$\begin{align*} \min(L) &= \{w\mid w\in L,\text{ but no prefix of }w\text{ is in }L \}\\ \max(L) &= \{w\mid w\in L,\text{ but for no }x\text{ other than…
user93189
  • 537
8
votes
0 answers

What is the probability that a random regular expression defines the language of all binary strings $\{0, 1\}^*$?

Suppose we generate a random regular expression $R$ in the following way: We start with a single meta-symbol $S$. Then each turn we independently replace all $S$ in our word with $\{0\}$, $\{1\}$, $(S \cup S)$, $SS$ or $S^*$ with equal probability.…
8
votes
5 answers

If $L$ is regular, prove that $\sqrt{L}=\left\{ w : ww\in L\right\}$ is regular

Let $L$ be a regular language. Prove that $\sqrt{L}:=\left\{ w : ww\in L\right\}$ is also a regular language. I suppose I need to modify state machine for $L$ to accept $\sqrt{L}$, but I've been thinking how to do that for a few hours and still…
xan
  • 2,171
8
votes
3 answers

NFA of $k$ states recognizing all words of length $\le k$

Let $N$ be an NFA with $k$ states that recognizes some language $A$. a. Show that if $A$ is nonempty, $A$ contains some string of length at most $k$. b. Show, by giving an example, that part (a) is not necessarily true if you replace both $A$’s by…
8
votes
4 answers

Why isn't this a regular language?

I'm stuck as to figuring out why $L_1$={$n^p$ | $p$ = a prime number} is not a regular language but $L_2$={$n^p$ | $p$ = a prime number bounded by some fixed number f} is. I can see that $L_2$ is a finite language so it's a regular language. But I…
pauliwago
  • 655
1
2 3
84 85