instruction
stringlengths
0
29.8k
⌀
|formal-languages|proof-techniques|
I'm trying to use pumping lemma to prove that $L = \{(01)^m 2^m \mid m \ge0\}$ is not regular. This is what I have so far: Assume $L$ is regular and let $p$ be the pumping length, so $w = (01)^p 2^p$. Consider any pumping decomposition $w = xyz$; $|y| > p$ and $|xy| \le p$. I'm not sure what to do next. Am I o...
|formal-languages|regular-languages|pumping-lemma|
Hint: You need to consider what all the decompositions $w=xyz$ look like, so what are all the possible things $x$, $y$ and $z$ can be given that $xyz=(01)^p2^p$. Then you pump each one and see whether you get a contradiction, which will be a word not in your language.
null
|formal-languages|context-free|formal-grammars|pumping-lemma|
I'm trying to use pumping lemma to prove that $L = \{(01)^m 2^m \mid m \ge0\}$ is not regular. This is what I have so far: Assume $L$ is regular and let $p$ be the pumping length, so $w = (01)^p 2^p$. Consider any pumping decomposition $w = xyz$; $|y| > p$ and $|xy| \le p$. I'm not sure what to do next. Am I o...
null
I'm trying to use pumping lemma to prove that $L = \{(01)^m 2^m \mid m \ge0\}$ is not regular. This is what I have so far: Assume $L$ is regular and let $p$ be the pumping length, so $w = (01)^p 2^p$. Consider any pumping decomposition $w = xyz$; $|y| >0$ and $|xy| \le p$. I'm not sure what to do next. Am I on...
I have to write a grammar for Pascal, and there is just one thing that is causing problems. Lets say we have operators (sorted by priority from low to high): 1. _postfix "^"_, 2. _prefix "^"_, 3. _"[ ]"_, and ".", (same priority and left associative) 1. the only terminal is id, which is any lowercase letter ...
reduce reduce and shift reduce error in LALR grammar
|formal-grammars|
|programming-languages|parsers|formal-grammars|
I'm trying to use pumping lemma to prove that $L = \{(01)^m 2^m \mid m \ge0\}$ is not regular. This is what I have so far: Assume $L$ is regular and let $p$ be the pumping length, so $w = (01)^p 2^p$. Consider any pumping decomposition $w = xyz$ such that $|y| >0$ and $|xy| \le p$. I'm not sure what to do next. ...
Hint: You need to consider what all the decompositions $w=xyz$ look like, so what are all the possible things $x$, $y$ and $z$ can be given that $xyz=(01)^p2^p$. Then you pump each one and see whether you get a contradiction, which will be a word not in your language. Each case needs to lead to a contradiction, which w...
I am trying to figure out the simplest way to do this using a regular expreesion. - Three symbols a, b, c. - The sequence length is unlimited, i.e. *. - The symbol a must be somewhere in the sequence at least once, but can appear more than once. - The sequence can have only a. The best I get is > ( (...
Regular Expression, 3 symbols, unlimited length, first symbol must be in sequence at least once
|formal-languages|regular-expressions|
I am trying to figure out the simplest way to do this using a regular expreesion. - Three symbols a, b, c. - The sequence length is unlimited, i.e. *. - The symbol a must be somewhere in the sequence at least once, but can appear more than once. - The sequence may have only a. More formally, $\{ w \in \{...
null
I am trying to figure out the simplest way to do this using a regular expreesion. - Three symbols a, b, c. - The sequence length is unlimited, i.e. *. - The symbol a must be somewhere in the sequence at least once, but can appear more than once. - The sequence may have only a. More formally, $\{ w \in \{...
Regular Expression for the language that requires one symbol to occur at least once
I am trying to figure out the simplest way to do this using a regular expression. - Three symbols a, b, c. - The sequence length is unlimited, i.e. *. - The symbol a must be somewhere in the sequence at least once, but can appear more than once. - The sequence may have only a. More formally, $\{ w \in \{...
We learned about the class of regular languages $\mathrm{REG}$. It is characterised by both left-linear grammars, regular expressions and finite automata so it is easy to show that a given language is regular. How do I show the opposite, though? My TA has been adamant that in order to do so, we would have to show fo...
How to prove that a language is not regular?
|formal-languages|regular-languages|proof-techniques|
|formal-languages|context-free|proof-techniques|
From Wikipaedia, [the pumping language for regular languages][1] is the following: > Let $L$ be a regular language. Then there exists an integer $p\ge 1$ depending only on $L$ such that every string $w$ in $L$ of length at least $p$ ($p$ is called the "pumping length") can be written as $w = xyz$ (i.e., $w$ can be...
From Wikipaedia, [the pumping language for regular languages][1] is the following: > Let $L$ be a regular language. Then there exists an integer $p\ge 1$ depending only on $L$ such that every string $w$ in $L$ of length at least $p$ ($p$ is called the "pumping length") can be written as $w = xyz$ (i.e., $w$ can be...
From Wikipaedia, [the pumping language for regular languages][1] is the following: > Let $L$ be a regular language. Then there exists an integer $p\ge 1$ depending only on $L$ such that every string $w$ in $L$ of length at least $p$ ($p$ is called the "pumping length") can be written as $w = xyz$ (i.e., $w$ can be...
The [Existential Theory of the Reals](http://en.wikipedia.org/wiki/Existential_theory_of_the_reals) is in **PSPACE**, but I don't know whether it is **PSPACE-Complete**. If I believe that it is not the case, how could I prove it? More generally, given a problem in some complexity class **X**, how can I show that i...
Proof by contrapositive is often used to show that a language is not regular: let $P$ a property true for all regular languages, if your specific language does not verify $P$, then it's not regular. The following properties can be used: 1. the pumping lemma, as exemplified in Dave's answer; 2. [closure propertie...
null
I am going to give a non-answer to this question, since this isn't exactly the pumping lemma, but maybe sheds light on what the idea of the pumping lemma is. Here is a basic fact about deterministic finite state automata, which is the essence of the Myhill-Nerode theorem: *If two strings $a$ and $b$ drive the FSA to t...
Consider two 2D-Array $B_{ij} $ (the buy array) and $S_{ij}$ (the sell array) where each $i^{th}$ element is associated with an array of floating-point values and each of the floating point value, in turn, is associated with an array of integers. For example B = [ 0001 => [ 32.5 => {10, 15, 20}, ...
I don't see any problem with your first grammar and bison doesn't complain on the rendering I've done of it. I see one conflict in your second grammar (which doesn't describe the same language). After having see `id id id` and you have a pending '^', you don't know if your last `id` and the `^` should be an F, or if...
This is an expanded version of my answer from here http://cs.stackexchange.com/questions/1027/using-pumping-lemma-to-prove-language-is-not-regular since this is supposed to be a reference question. So, you think the pumping lemma looks complicated? Don't worry. Here's a slightly different take on it, which is hidd...
I don't see any problem with your first grammar and bison doesn't complain on the rendering I've done of it. I (and bison) see one conflict in your second grammar (which doesn't describe the same language as the first BTW). After having seen `id id id` with a pending `^`, you don't know if your last `id` and the `^`...
I have to write a grammar for Pascal, and there is just one thing that is causing problems. Lets say we have operators (sorted by priority from low to high): 1. _postfix "^"_, 2. _prefix "^"_, 3. _"[ ]"_, and ".", (same priority and left associative) 1. the only terminal is id, which is any lowercase letter ...
I have to write a grammar for Pascal, and there is just one thing that is causing problems. Lets say we have operators (sorted by priority from low to high): 1. _postfix "^"_, 2. _prefix "^"_, 3. _"[ ]"_, and ".", (same priority and left associative) 1. the only terminal is id, which is any lowercase letter ...
You have a decomposition $xyz = (01)^p 2^p$ and a length constraint $|xy| \le p$. What does this say about how $x$, $y$ and $z$ can fit in the decomposition? In particular, the pumping lemma allows you to repeat $y$, so your objective is to find some way in which repeating $y$ many times (or removing $y$, sometimes thi...
Let's categorize data into three categories: data readable by humans (usually texts, varying from books to programs), data intended to be read by computers and other data (images, sound). For the first category, we need to process them into something a computer can use. As the languages used by humans can generally ...
We learned about the class of regular languages $\mathrm{REG}$. It is characterised by any one concept among regular expressions, finite automata and left-linear grammars, so it is easy to show that a given language is regular. How do I show the opposite, though? My TA has been adamant that in order to do so, we wou...
I don't see any problem with your first grammar and bison doesn't complain on the rendering I've done of it. I (and bison) see one conflict in your second grammar (which doesn't describe the same language as the first BTW). After having seen `id id id` with a pending `^`, you don't know if your last `id` and the `^`...
From Wikipedia, [the pumping language for regular languages][1] is the following: > Let $L$ be a regular language. Then there exists an integer $p\ge 1$ depending only on $L$ such that every string $w$ in $L$ of length at least $p$ ($p$ is called the "pumping length") can be written as $w = xyz$ (i.e., $w$ can be ...
From Wikipedia, [the pumping language for regular languages][1] is the following: > Let $L$ be a regular language. Then there exists an integer $p\ge 1$ depending only on $L$ such that every string $w$ in $L$ of length at least $p$ ($p$ is called the "pumping length") can be written as $w = xyz$ (i.e., $w$ can be ...
[According to Wikipedia][1], for any regular language $L$ there exist constants $\lambda_1,\ldots,\lambda_k$ and polynomials $p_1(x),\ldots,p_k(x)$ such that for every $n$ the number $s_L(n)$ of words of length $n$ in $L$ satisfies the equation $s_L(n)=p_1(n)\lambda_1^n+\dots+p_k(n)\lambda_k^n$. The language $L =\{ ...
Question about the number of words in a regular language
|regular-languages|combinatorics|
For your language, can you take $p_0(x) = 1/2$, $\lambda_0 = 1$, $p_1(x) = 1/2$, $\lambda_1 = -1$, and $p_i(x) = \lambda_i = 0$ for $i > 1$? The Wikipedia article doesn't say anything about the coefficients being either positive or integral. The sum for my choices is $1/2 + 1/2(-1)^n = 1/2 (1 + (-1)^n)$ which seems to ...
From Wikipedia, [the pumping language for regular languages][1] is the following: > Let $L$ be a regular language. Then there exists an integer $p\ge 1$ (depending only on $L$) such that every string $w$ in $L$ of length at least $p$ ($p$ is called the "pumping length") can be written as $w = xyz$ (i.e., $w$ can b...
As the expression is to be part of a parser (i.e. should be efficiently checkable), it might be a good idea to make the regular expression unambiguous: $\qquad \displaystyle (b \mid c)^*\, a\, (a \mid b \mid c)^*$ describes the same language but avoids ambiguity by distinguishing the *first* $a$ in a matching wor...
The simplest regular expression I can think of for this is $\left(a \mid b \mid c\right)^* a \left(a \mid b \mid c\right)^*$. This is simpler than yours by the following measures of complexity: * It contains less nesting (and fewer parentheses in general) * It contains fewer quantifiers
If a language needs to be parsed, it means not every input is valid, so the input language contains **redundancy**, either because multiple inputs map to the same parse tree or because some input strings are invalid. Humans like redundancy. For example, most humans find binary operators more readable than a pure prefix...
|formal-languages|regular-languages|combinatorics|
|formal-languages|regular-languages|combinatorics|word-combinatorics|
I am trying to figure out the simplest way to do this using a regular expression. - Three symbols a, b, c. - The sequence length is unlimited, i.e. *. - The symbol a must be somewhere in the sequence at least once, but can appear more than once. - The sequence may have only a. More formally, $\{ w \in \{...
For your language, can you take $p_0(x) = 1/2$, $\lambda_0 = 1$, $p_1(x) = 1/2$, $\lambda_1 = -1$, and $p_i(x) = \lambda_i = 0$ for $i > 1$? The Wikipedia article doesn't say anything about the coefficients being either positive or integral. The sum for my choices is $\qquad \displaystyle 1/2 + 1/2(-1)^n = 1/2 (1 +...
[According to Wikipedia][1], for any regular language $L$ there exist constants $\lambda_1,\ldots,\lambda_k$ and polynomials $p_1(x),\ldots,p_k(x)$ such that for every $n$ the number $s_L(n)$ of words of length $n$ in $L$ satisfies the equation $\qquad \displaystyle s_L(n)=p_1(n)\lambda_1^n+\dots+p_k(n)\lambda_k^n$...
I am trying to figure out the simplest way to do this using a regular expression. - Three symbols a, b, c. - The sequence length is unlimited, i.e. *. - The symbol a must be somewhere in the sequence at least once, but can appear more than once. - The sequence may have only a. More formally, $\{ w \in \{...
As the expression is to be part of a parser (i.e. should be efficiently checkable), it might be a good idea to make the regular expression unambiguous: $\qquad \displaystyle (b \mid c)^*\, a\, (a \mid b \mid c)^*$ describes the same language but avoids ambiguity by distinguishing the *first* $a$ in a matching wor...
Let's categorize data into three categories: data readable by humans (usually texts, varying from books to programs), data intended to be read by computers and other data (parsing images or sound). For the first category, we need to process them into something a computer can use. As the languages used by humans can ...
If a language needs to be parsed in some non-trivial way, it usually means that structural elements need to be matched, so the input language contains **redundancy**, either because multiple inputs map to the same parse tree or because some input strings are invalid. Humans like redundancy. For example, most humans fin...
I ran into the following doubts on the complexity of [Towers of Hanoi](http://en.wikipedia.org/wiki/Tower_of_Hanoi), on which I would like your comments. * <b>Is it in NP? </b> Attempted answer: Suppose Peggy (prover) solves the problem & submits it to Victor (verifier). Victor can easily see that the final ...
A problem in $X$ is not $X$-complete if there are any other problems in $X$ which cannot be reduced to it. One straightforward (but possibly only effective on trivial examples) method would be proving your problem is also in some other complexity class $Y$ such that $Y \subset X$. For example, if you want to show th...
null
I ran into the following doubts on the complexity of [Towers of Hanoi](http://en.wikipedia.org/wiki/Tower_of_Hanoi), on which I would like your comments. * <b>Is it in NP? </b> Attempted answer: Suppose Peggy (prover) solves the problem & submits it to Victor (verifier). Victor can easily see that the final ...
This is an expanded version of my answer from here http://cs.stackexchange.com/questions/1027/using-pumping-lemma-to-prove-language-is-not-regular since this is supposed to be a reference question. So, you think the pumping lemma looks complicated? Don't worry. Here's a slightly different take on it, which is hidd...
No, the problem you've described is actually quite easy. The high-level reason is that the index $i$ is roughly $n$ bits long, so we can actually afford to spend time polynomial in $n$. Consider the following related problem: Given two integers $n$ and $k$, describe the $k$th move in the solution of the $n$-disk pu...
Not a complete answer, but the [wikipedia page][1] you cited states: > The accuracy of the k-NN algorithm can be severely degraded by the presence of noisy or irrelevant features, or if the feature scales are not consistent with their importance. The likelihood of this occurring increases in the presence of high ...
Is there an algebraic characterization of the number of words of a given length in a regular language? [Wikipedia](http://en.wikipedia.org/wiki/Regular_language#The_number_of_words_in_a_regular_language) states a result somewhat imprecisely: > For any regular language $L$ there exist constants $\lambda_1,\,\ldots...
Number of words of a given length in a regular language
|regular-languages|word-combinatorics|
Number of words in the regular language $(00)^*$
This problem is known as the [curse of dimensionality][1]. Basically, as you increase the number of dimensions, $d$, points in the space generally tend to become far from all other points. This makes partitioning the space (such as is necessary for classification or clustering) very difficult. You can see this for y...
There is a lot of work done on this problem as the popularity of social networking has taken off. The problem is typically termed "Link Prediction" and very good and comprehensive surveys can be found [here][1] and [here][2]. The methods range from the very simple (e.g. Jaccard similarity between nodes) to the very com...
@Patrick87 gives a great answer for your specific case, I thought I would give a tip of how to find $s_L(n)$ in the more general case of any language $L$ that can be represented by an irreducible DFA (i.e. if it is possible to get to any state from any state). Note that your language is of this type. - - - - - #...
Let $L$ be a regular language and $\qquad \displaystyle L(z) = \sum\limits_{n \leq 0} |L_n|z^n$ its [generating function](https://en.wikipedia.org/wiki/Chomsky%E2%80%93Sch%C3%BCtzenberger_theorem). It is known that $L(z)$ is [*rational*](https://en.wikipedia.org/wiki/Linear_recursive_sequence#Rational_generating_...
null
Let $L$ be a regular language and $\qquad \displaystyle L(z) = \sum\limits_{n \leq 0} |L_n|z^n$ its [generating function](https://en.wikipedia.org/wiki/Chomsky%E2%80%93Sch%C3%BCtzenberger_theorem), where $L_n = \{w \in L \mid |w|=n\}$ and so $|L_n|=s_L(n)$. It is known that $L(z)$ is [*rational*](https://en.wi...
null
|formal-languages|regular-languages|word-combinatorics|
Let $C_n = \{x|x \text{ is a binary number that is a multiple of } n\}$. Show that for each $n$, the language $C_n$ is regular. Just provide a generic recipe (i.e., a formal definition for arbitrary $n$).
How do I do this question regarding regular expressions in CS Theory?
|regular-expressions|
|formal-languages|regular-expressions|
Multiples of n is a regular language
Let $C_n = \{x\mid x \text{ is a binary number that is a multiple of } n\}$. Show that for each $n$, the language $C_n$ is regular. Just provide a generic recipe (i.e., a formal definition for arbitrary $n$).
|formal-languages|regular-languages|
null
Based on Dave's answer, here is a step-by-step "manual" for using the pumping lemma. Recall the pumping lemma (taken from Dave's answer, taken form Wikipedia): > Let $L$ be a regular language. Then there exists an integer $n\ge 1$ (depending only on $L$) such that every string $w$ in $L$ of length at least $n$ ($...
Proof by contrapositive is often used to show that a language is not regular: let $P$ a property true for all regular languages, if your specific language does not verify $P$, then it's not regular. The following properties can be used: 1. The pumping lemma, as exemplified in [Dave's answer][1]; 2. [Closure prop...
null
I have to write a grammar for Pascal, and there is just one thing that is causing problems. Lets say we have operators (sorted by priority from low to high): 1. _Postfix `^`_. 2. _Prefix `^`_. 3. _`[ ]`_, and `.`, (same priority and left associative). 1. The only terminal is `id`, which is any lowercase lette...
null
The reason that $(\lambda y. \lambda x. \lambda y.y) (\lambda x. \lambda y. y)$ reduces to $\lambda x. \lambda y. y$ and not to $\lambda x. \lambda y.\lambda x.\lambda y.y$ is that the $y$ in the body of $\lambda y.\lambda x.\lambda y.y$ refers to the argument of the third lambda, not the first. If you rename the ar...
null
Based on Dave's answer, here is a step-by-step "manual" for using the pumping lemma. Recall the pumping lemma (taken from Dave's answer, taken form Wikipedia): > Let $L$ be a regular language. Then there exists an integer $n\ge 1$ (depending only on $L$) such that every string $w$ in $L$ of length at least $n$ ($...