instruction
stringlengths
0
29.8k
⌀
$K{-}DPDA$ is equivalent to $2{-}DPDA$ for any $K \geq3. $That means for example $2{-}DPDA$ is capable of do the same work as $3{-}DPDA$ do, $2{-}DPDA$ is capable of do the same work as $4{-}DPDA$ do etc$.......... ... ... .. .. ..... .. .$ And $K{-}DPDA$ is equivalent to Turing Machine for any $K \geq2$$.$ $\{a...
I was wondering about infinite closure properties. Are the Regular languages closed under infinite union? Infinite intersection? Probably not, by taking $\forall n>0~~L_n=\{a^nb^n\}\in RL$, then $\bigcup_{n=1}^{\infty}L_n=\{a^nb^n|n>0\}\notin RL$ By taking $L_k=\{a^ib^j~|~i\ne k ~~or~~ j\ne k\}\in RL$, then $\...
Regular, CFL, non-CFL infinite closures
|formal-languages|regular-languages|automata|context-free|closure-properties|
I'm reading Douglas Thain's book called "Introduction to Compilers and Language Design" and I've come across the following grammar: [![enter image description here][1]][1] , with the following LR(1) automaton: [![enter image description here][2]][2] , and I am not sure the look-ahead sets in state 0 (or any...
How is the lookahead for an LR(1) automaton computed?
|compilers|parsers|lr-k|
You always need an initial solution. If you don't have one, you create another problem to get the initial solution. In your case: Imagine you don't ship enough cars. Customer 1 misses $x_7$ and customer 2 misses $x_8$ cars. So you change two equations : $x_1 + x_5 + x_7 = 200$, $x_2 + x_6 + x_8 = 300$. And this has...
I'm reading Douglas Thain's book called "Introduction to Compilers and Language Design" and I've come across the following grammar: [![enter image description here][1]][1] , with the following LR(1) automaton: [![enter image description here][2]][2] , and I am not sure the look-ahead sets in state 0 (or any...
null
[![enter image description here][1]][1] Above is the proof of pumping lemma for context-free languages, coming from the book 'Formal Languages and automata' of Peter Linz. The photo above is in support of the proof. [![enter image description here][2]][2] I do not understand two things about this proof: ...
variable repetitions in pumping lemma for context-free languages
|formal-languages|automata|finite-automata|context-free|pumping-lemma|
[![enter image description here][1]][1] Above is the proof of the pumping lemma for context-free languages, coming from the book 'Formal Languages and automata' by Peter Linz. The photo above is in support of the proof. [![enter image description here][2]][2] I do not understand two things about this proo...
[![enter image description here][1]][1] Above is the proof of the pumping lemma for context-free languages, coming from the book 'Formal Languages and automata' by Peter Linz. The picture below is in support of the proof. [![enter image description here][2]][2] I do not understand two things about this pr...
[![enter image description here][1]][1] Above is the proof of the pumping lemma for context-free languages, coming from the book 'Formal Languages and automata' by Peter Linz. The picture below is in support of the proof. [![enter image description here][2]][2] I do not understand two things about this pr...
FIRST(&beta;) is the set of possible first tokens in a derivation from &beta;. (It's usual to also add &epsilon; to the first set if &beta; could derive the empty sequence.) So FIRST(<code>+ *T*</code>) is { `+` }. No other token could possibly be at the beginning of any sentence derived from <code>+ *T*</code>. If ...
$K{-}DPDA$ is equivalent to $2{-}DPDA$ for any $K \geq3. $That means for example $2{-}DPDA$ is capable of do the same work as $3{-}DPDA$ do, $2{-}DPDA$ is capable of do the same work as $4{-}DPDA$ do etc$.......... ... ... .. .. ..... .. .$ And $K{-}DPDA$ is equivalent to Turing Machine for any $K \geq2$$.$ $\{a...
null
$K{-}DPDA$ is equivalent to $2{-}DPDA$ for any $K \geq3. $That means for example $2{-}DPDA$ is capable of do the same work as $3{-}DPDA$ do, $2{-}DPDA$ is capable of do the same work as $4{-}DPDA$ do etc$.......... ... ... .. .. ..... .. .$ And $K{-}DPDA$ is equivalent to Turing Machine for any $K \geq2$$.$ $\{a...
{"OriginalQuestionIds":[93464],"Voters":[{"Id":755,"DisplayName":"D.W."}]}
Define $L'=\{u\#v^R ~|~ u,v \in L\}$ and $L\in RL$ while $\#\notin \Sigma$ Why is $L'$ a regular language? Thanks!
Why is $L'=\{u\#v^R ~|~ u,v \in L\}$ and $L\in RL$ a regular language?
|formal-languages|regular-languages|automata|context-free|regular-expressions|
Lucky enough, your case is quite easy. The language is defined by the rule "total number of letters, modulo 3, equals total number of a's, modulo 3". This is equivalent to "number of letters that are not a's is divisible by 3". Same language, but a lot easier. You build a state machine with three states $S_0$, $S_1...
null
$K{-}DPDA$ is equivalent to $2{-}DPDA$ for any $K \geq3. $That means for example $2{-}DPDA$ is capable of do the same work as $3{-}DPDA$ do, $2{-}DPDA$ is capable of do the same work as $4{-}DPDA$ do etc$.......... ... ... .. .. ..... .. .$ And $K{-}DPDA$ is equivalent to Turing Machine for any $K \geq2$$.$ $\{a...
Define $L'=\{u\#v^R ~|~ u,v \in L\}$ and $L\in RL$ while $\#\notin \Sigma$ Why is $L'$ a regular language? I have tried to construct the DFA of L, then with a # move to a copy of this DFA with flipped edges. I think this is correct. Thanks!
Regular languages are closed under reversal, therefore $L^R = \{v^R \mid v \in L\}$ is regular. Moreover, regular languages are closed under concatenation, therefore $L' = L \circ \{\#\} \circ L^R$ is regular.
$K{-}DPDA$ is equivalent to $2{-}DPDA$ for any $K \geq3. $That means for example $2{-}DPDA$ is capable of do the same work as $3{-}DPDA$ do, $2{-}DPDA$ is capable of do the same work as $4{-}DPDA$ do etc$.......... ... ... .. .. ..... .. .$ And $K{-}DPDA$ is equivalent to Turing Machine for any $K \geq2$$.$ $\{a...
$K{-}DPDA$ is equivalent to $2{-}DPDA$ for any $K \geq3. $That means for example $2{-}DPDA$ is capable of do the same work as $3{-}DPDA$ do, $2{-}DPDA$ is capable of do the same work as $4{-}DPDA$ do etc$.......... ... ... .. .. ..... .. .$ And $K{-}DPDA$ is equivalent to Turing Machine for any $K \geq2$$.$ $\{a...
[![enter image description here][1]][1] [1]: https://i.stack.imgur.com/Bqtns.png Above is a theorem coming from the book "Formal languages and automata" by Peter Linz concerning substitution of variables. Could someone explain why A and B have to be different variables?
substitution of same variable in context-free grammars
|automata|finite-automata|context-free|logic|
$\text{FIRST}(\beta)$ is the set of possible first tokens in a derivation from &beta;. (It's usual to also add &epsilon; to the first set if &beta; could derive the empty sequence.) So $\text{FIRST}(\mathbf{+}\mathit{T})$ is $\{\mathbf{+}\}$. No other token could possibly be at the beginning of any sentence derived ...
> So far every language that I saw containing modulo was a regular language. As [John L. notes](https://cs.stackexchange.com/a/152519), that's a very good observation. Indeed, any language where the _only_ constraint on words is that _some number_ modulo $n$ (which we can update letter by letter as we parse the inp...
null
As you suspect probably, theorem 6.1 still holds even if $A$ and $B$ are the same variable. This can be seen by following the proof of the theorem, assuming $B$ is $A$. So, it is not correct to say "it is necessary that $A$ and $B$ be different variables" so that the conclusion $L(\widehat G) = L(G)$ holds. The quo...
$S\to.E$,\$.........$(1)$, now compute the closure of $E$, which is $E\to.E+T,$\$..........$(2)$ and $E\to.T,$\$.........$(3)$ use lookahead \$ because in $(1)$ after $E$ is \$ and $FIRST$ of \$ is \$ that's why lookahead is \$ in (2) and (3). From $(2)$ you need to find the closure of $E$, which is $E\to.E+T,+$....
I want to prove that $\{a^ib^jc^k ~|~k\le\max(i,j) ~and~ k\ge\min(i,j)\}$ is not a CFL. Using the pumping lemma, let $p$ be the constant, then I tried to choose $w=a^pb^pc^p$. When I separate to cases, looking at the homogeneous case, by choosing either $w_0$ or $w_2$ I can't disprove the lemma, because the numbe...
How to prove that $\{a^ib^jc^k ~|~k\le\max(i,j) ~and~ k\ge\min(i,j)\}$ is not a CFL?
|formal-languages|regular-languages|automata|context-free|pumping-lemma|
null
For every position of the left pointer, there is a *unique position* of the right pointer such that the sum exceeds or equals $K$ and moving the right pointer to the left makes the sum smaller than $K$, and symmetrically. E.g. $2,5,6,8,11,15,21$, target sum $14$. We show the unique right positions for increasing lef...
[This blog posting][1] states that *"regular languages aren't structurally recursive"* while *"That's not the case for context-free grammars"* In what sense is the term "structurally recursive" meant here? [1]: https://matt.might.net/articles/parsing-with-derivatives/
How are regular languages not structurally recursive?
|formal-languages|regular-languages|context-free|recursion|
null
null
Regular languages don't have recursive structures, so formally regular expressions cannot express recursive structures by definition.All regular languages can be recognized by a finite automaton. A finite automaton has a finite number of states, and consequently, finite memory . A recursive "regular" expression req...
Suppose we have finite field $\mathbb{F}_p$ with prime order $p$. Can we find polynomial in $\mathbb{F}_p[x]$ having given values $a_1, a_2, ... a_n$ at $x=1, 2, ..., n$ in less than $O(n^2)$ operations in $\mathbb{F}_p$? There is [reference to general algorithm in another question][1] which runs in $O(n \log^2 n)$ ...
What's the fastest algorithm for polynomial interpolation in finite field with prime order at points 1, 2, 3, ..., n?
|reference-request|polynomials|
null
Let's determine if an expression is tautological or not and let's try this expression: ((a ⊼ b) ∨ c) ↔ (¬a ∨ ¬b ∨ c). We can turn this problem into CIRCUIT-SAT decision problem by asking if the expression ((a ⊼ b) ∨ c) ⊕ (¬a ∨ ¬b ∨ c) is satisfiable. Note that we repalced the universal gate with its inverse (by "uni...
Why don't we consider that NP = co-NP while we can reduce Tautology problem into Satisfiability in polynomail time easily?
|np-complete|np|satisfiability|decision-problem|co-np|
It is certainly possible that some variables repeat in the subtree $T_3$, $T_4$ or $T_5$. There is nothing wrong with those situations, except that those situations are too relaxed for us to ensure "the lengths of the strings $v$, $x$, and $y$ depend only on the productions of the grammar and can be bounded independent...
I'm somewhat confused about the Wikipedia terms about the meaning of 'reversed' in the context of tree & graph treversals Suppose I have a tree: ``` 1 / \ / \ / \ / \ 2 3 / \ / 4 5 6 / \ / \ 7 8 9 10 ``` [Tree ...
Does 'reverse' mean 2 separate things in contexts of tree vs. graph traversal?
|binary-trees|graph-traversal|
While I do not have an answer, I have given this some thought and would like to share my ideas. I am making two simplifying assumptions but the general case shouldn't be much harder. 1. All numbers are distinct on each column. 2. $k$ is odd. Now let $c_{i,j}$ be the number of inversions caused by putting row ...
It is certainly possible that some variables repeat in the subtree $T_3$, $T_4$ or $T_5$. There is nothing wrong with those situations, except that those situations are too relaxed for us to ensure "the lengths of the strings $v$, $x$, and $y$ depend only on the productions of the grammar and can be bounded independent...
I've been studying the examples of 3co-SAT recently. It's easy to find an example of one variable. $(x_1\lor x_1\lor x_1)\land (\overline{x_1}\lor \overline{x_1}\lor \overline{x_1})$ Examples of 2 variables are as follows. $(x_1\lor x_2\lor x_2)\land (x_1\lor \overline{x_2}\lor \overline{x_2})\land (\over...
Can you help me find some examples of 3co-SAT for 4 variables?
|complexity-theory|np-complete|satisfiability|3-sat|sat-solvers|
Assume you know the Euclidean Minimum Spanning Tree of a set of $n$ 2D points (in general position). Is there an efficient way (faster than $O(n \log n)$ operations) to obtain the Delaunay triangulation of these points ?
Delaunay triangulation from an EMST
|computational-geometry|minimum-spanning-tree|triangulation|
CNF is only used to describe problem formally, but it's kind of hard for human to understand it. Entailment is such tool that used to write "readable" formula. You can use propositional rules to give a contradiction. Here is how i work it out: First, given an unsatisfied clause using Entailment: $A\wedge B\rig...
As a software engineer, I am familiar with "domain-specific languages" (DSLs), such as PCRE and SQL, which aim to eschew complexity by only providing functionality specific to a given domain (e.g. string matching and database querying for PCRE and SQL, respectively). However, in some CSE literature I've seen the ter...
What is the difference between a Task-Specfic Programming (TSP) language and a Domain-Specific Language (DSL)?
|education|domain-specific-languages|
It looks like you are on the right track. However, some of your statements are not clear. For example, I do not see the relevance of "the existence of bijection from the computable numbers to $\Bbb Q$". Hint 1. >! As you might have suspected, it is not possible to computably enumerate all computable numbers, alth...
Could someone help me prove the following statement: “For any grammar in Greibach normal form, every sentence is obtainable by left-most derivations only.” I see that this is trivial, but I can't manage to start a formal proof of this statement.
proof that every sentence obtainable by left-most derivations only when Greibach normal form
|automata|context-free|normal-forms|derivation|
Could someone help me prove the following statement: “For any grammar in Greibach normal form, every sentence is obtainable by left-most derivations only.” I see that this is trivial, but I can't manage to start a formal proof of this statement. What I thought is: Since every derivation in Greibach Normal Form ha...
(Motivation: let $h = n/2$. Given $f_{ih} = f(x_i\dots x_{h-1}) \text{ and } f_{hj} = f(x_h\dots x_j)$ (precomputed in about $n$ evaluations of $f$), $f(x_{i+1}\dots x_{j-1})$ can be computed as $f(f_{(i+1)h}, f_{h(j-1)})$ for all $i\lt h\lt j$. This saves ?$\frac{(n-2)(n-3)} 2 - n$? evaluations. Similarly ...
(Motivation: let $h = n/2$. Given $f_{ih} = f(x_i\dots x_{h-1}) \text{ and } f_{hj} = f(x_h\dots x_j)$ (precomputed in about $n$ evaluations of $f$), $f(x_{i+1}\dots x_{j-1})$ can be computed as $f(f_{(i+1)h}, f_{h(j-1)})$ for all $i\lt h\lt j$. This saves ?$\frac{(n-2)(n-3)} 2 - n$? evaluations. Similarly ...
(Motivation: let $h = n/2$. Given $f_{ih} = f(x_i\dots x_{h-1}) \text{ and } f_{hj} = f(x_h\dots x_j)$ (precomputed in about $n$ evaluations of $f$), $f(x_{i+1}\dots x_{j-1})$ can be computed as $f(f_{(i+1)h}, f_{h(j-1)})$ for all $i\lt h\lt j$. This saves ?$\frac{(n-2)(n-3)} 2 - n$? evaluations. Similarly ...
null
On calculating the convexity of an optimization problem, I am getting a term $O(\sqrt{n+m}(n)^3)$. Here both $m$ and $n$ are parameters. Is there any way I can simplify this term to write it as a product?<br/> I know that if time complexity $T(n,m)=O(\sqrt{n+m}(n)^3)$, then $\exists C,M $ such that $\vert T(n,m) \vert...
Big O notation simplification from sum
|complexity-theory|time-complexity|
The fact that the grammar is in Greibach Normal Form does not contribute to the assertion being proved. For any context-free grammar $G$ with start symbol $S$, $\omega\in L(G)\iff S\Rightarrow_{lm}^*\omega$. It's not necessary to restrict the syntax of the productions of $G$ beyond the restriction imposed by the contex...
null
This started with me trying to make a regex to accept Bitcoin addresses. However, I couldn't do it. That led me to think: "is the set of all possible Bitcoin addresses even a regular language"? For simplicity, consider only "legacy" P2PKH Bitcoin addresses: a valid address consists of the character "1" followed by 2...
null
null
The [Wikipedia article][1] states, that: > the Delaunay triangulation can be constructed from the Euclidean minimum spanning tree in the near-linear time bound $O(n\log ^{*}n)$, where $\log ^{*}$ denotes the [Iterated logarithm][2]. This article refers to the [paper][3], where you can find a randomized algorithm ...
CNF is only used to describe problem formally, but it's kind of hard for human to understand it. Entailment is such tool that used to write "readable" formula. You can use propositional rules to give a contradiction. Here is how i work it out: First, given an unsatisfied clause using Entailment: $A\wedge B\rig...
Probably the most famous example of a divergent term (ie, one which admits infinitely many $\beta$-reductions) in the $\lambda$-calculus is the Y combinator $$ Y = \lambda f. (\lambda x. f(xx)) (\lambda x. f(xx)) $$ The kind of the "heart" of the recursion here is the inclusion of the subterm $xx$. I wondered if ...
Are there syntactic conditions on divergent $\lambda$-terms?
|lambda-calculus|
I notice there are different definitions for CFG(basic block or statement), so let's consider following definition: > Given a program, each statement is a node in CFG, and $(u,v)\in E\iff \text{v is successor of u ,or u is branch and u's target is v}$ Due to such definition, each node has atmost two out-edges. So...
Are Control Flow Graphs(CFG) planar?
|graphs|planar-graphs|
I am trying to find a lightweight data structure to find the nearest neighbor mesh for a given point. I have seen nearest neighbor problems for points and triangles, but never meshes as a whole collective. So, in essence given a point P find the nearest mesh (a mesh being a collection of non-unique triangles) to a ...
A nearest neighbor data structure for meshes