instruction
stringlengths
0
29.8k
⌀
[NTP](http://en.wikipedia.org/wiki/Network_Time_Protocol) actually uses 4 time measurements $t_0, t_1, t_2, t_3$ to compute the "offset". they are the "time points" in the round trip of the packet from client to server back to client but can be regarded as time offsets. its assumed that the time offset can be off betwe...
|np-complete|reductions|satisfiability|3-sat|
I think that given a decidable language $L$, you can always build a *2-states* TM that recognizes it. Indeed there exists a 2 state Universal Turing Machine $UTM_{2U}$ (with alphabet $|\Sigma| \geq 18$). If $TM_i$ decides $L$ then $UTM_{2U}(i,x)$ decides $L$; so you can build a 2-states $TM_{2L}$ hard encoding $i...
Intuitivley, every derivation in a CFG corresponds to a parse-tree and vise verca. How do I formalize this idea and prove that every derivation is equivalent to a parse-tree?
__Theorem__. Let $G = (V, T, P, S)$ be a Context-free Grammar. Then $\forall A \in V, A \rightarrow^* \alpha \Leftrightarrow \exists$ a parse-tree $T'$ rooted at node $A$ with yield $\alpha \in (V \cup T)^*$. Meanings of symbols: 1. $V$ is the set of non-terminals 2. $T$ is the set of terminals 3. $P$ is th...
It is not very clear what you wish to achieve. Do you wish to reduce the number of productions to the minimal possible? Do you only wish to avoid productions that are "not helpful" i.e., never appear in any valid derivation? The first question seems difficult (e.g., [This Work](https://dl.acm.org/citation.cfm?id=545...
Intuitively, every derivation in a context-free grammar corresponds to a parse-tree and vise versa. Is this intuition correct? If so how can I formalize and prove such a thing?
|formal-grammars|context-free|
**Edit:** I found a better example. Consider these clauses: \begin{align} & \lnot P(x) \lor P(f(x)) \\ & P(x) \\ & \lnot P(f(f(x)))\\ \end{align} Obviously, this set of clauses is contradictory. But without renaming variables, the only possible resolvent is $P(f(x))$ and no more resolvents are possible - all lead...
Let us say we know that problem A is hard, then we reduce A to the unknown problem B to prove B is also hard. As an example: we know 3-coloring is hard. Then we reduce 3-coloring to 4-coloring. By conflating one of the colors in the 3-coloring you have a 4-coloring, ergo 4-coloring is hard. That's the how. But wh...
Hardness and directions of reductions
|complexity-theory|np-complete|reductions|
A reduction from a problem $A$ to another problem $B$ is a transformation $f$ of any instance $a$ of $A$ into an instance $f(a)$ of $B$, such that $x∈A ⇔ f(x)∈B$. If $f$ is a transformation preserving the complexity you are interested in (e.g. $f$ is a polynomial transformation if you consider $\mathsf{NP}$-hardness...
Let us say we know that problem A is hard, then we reduce A to the unknown problem B to prove B is also hard. As an example: we know 3-coloring is hard. Then we reduce 3-coloring to 4-coloring. By conflating one of the colors in the 3-coloring you have a 4-coloring, ergo 4-coloring is hard. That's the how. But wh...
A reduction from a problem $A$ to another problem $B$ is a transformation $f$ of any instance $a$ of $A$ into an instance $f(a)$ of $B$, such that $$\qquad\qquad x∈A ~~⇔~~ f(x)∈B \qquad \qquad (E)$$ If $f$ is a transformation preserving the complexity you are interested in (e.g. $f$ is a polynomial transformation...
null
I took my theory of computation exams a few weeks ago, and this was one of the questions: >Assume language L={$(a^nb^m)^r$, where n,m,r$\ge$0} >Is L regular? If yes provide a regular expression or an automaton for it. After I briefly asked him the answer after the exam, it appears it really is regular (I beli...
Why is $(a^nb^m)^r$ regular?
|regular-expressions|
I am dealing with the problem of computing $ s = \lfloor sqrt(x)\rfloor$ with $x \in [0,30000^2]$. The common `sqrtf(x)` on C language is too slow for this case, however it always gives me the correct result. I've tried with the Newton's method but I get very small errors when the square root of a number is exact. This...
null
The language $L$ is not regular, as can be proved using Nerode's method. Consider the following words $w_n = a^n b$ for $n \in \mathbb{N}$. Then $w_n^2 \in L$, but for $n \neq m$, $w_n w_m \notin L$. Hence any automaton for $L$ must be in a different state after reading each $w_n$, which contradicts its finiteness.
The following answer is basically equivalent to the one you already know, but may seem a bit less "magical". On the other hand, it's more technical, but I believe the general technique "write your problem as an optimization on permutation matrices and invoke Birkhoff-von Neumann" is a great one to know. For a permut...
null
As the title says, I spent a couple of hours last weekend trying to wrap up my mind about the class of languages matched by Perl-compatible regular expressions, *excluding any matching operator that allows to execute arbitrary code inside the pattern*. If you don't know what PCREs are, please read [this][1] and [thi...
Which languages do Perl-compatible regular expressions recognize?
|formal-languages|
As the title says, I spent a couple of hours last weekend trying to wrap up my mind about the class of languages matched by Perl-compatible regular expressions, *excluding any matching operator that allows to execute arbitrary code inside the pattern*. If you don't know what PCREs are, please read [this][1] and [thi...
As the title says, I spent a couple of hours last weekend trying to wrap up my mind about the class of languages matched by Perl-compatible regular expressions, *excluding any matching operator that allows to execute arbitrary code inside the pattern*. If you don't know what PCREs are, please read [this][1] and [thi...
If there is a Turing machine that can compute a given language at all, which in your case there is, then there must be at least one such machine, which the number of its states are no more than any other alike TM, i.e. You may always ask what is the minimal TM (with minimum number of states) which could accept a given ...
I took my theory of computation exams a few weeks ago, and this was one of the questions: >Assume language L={$(a^nb^m)^r$, where n,m,r$\ge$0} >Is L regular? If yes provide a regular expression or an automaton for it. After I briefly asked him the answer after the exam, it appears it really is regular (I beli...
Is $(a^nb^m)^r$ regular?
|regular-languages|regular-expressions|
I'm trying to prove the following lemma: $c$ is a positive real number and $f, g$ are functions from natural numbers to non-negative real numbers. I'm trying to prove rigorously that: $\Omega(cf(n))$ = $\Omega(f(n))$. I know that it is obvious but I'm trying to construct a proof that is as complete as possible...
Proving A Little Omega Lemma
|asymptotics|proof-techniques|
I'm trying to prove the following lemma: $c$ is a positive real number and $f, g$ are functions from natural numbers to non-negative real numbers. I'm trying to prove rigorously that: $\Omega(cf(n))$ = $\Omega(f(n))$. I know that it is obvious but I'm trying to construct a proof that is as complete as possible...
I am dealing with the problem of computing $ s = \lfloor sqrt(x)\rfloor$ with $x \in [0,30000^2]$. The common `sqrtf(x)` on C language is too slow for this case, however it always gives me the correct result. I've tried with the Newton's method but I get very small errors when the square root of a number is exact. This...
You do not need an exact method, anything with error less than 1 is OK. Say you want to compute $\lfloor \sqrt{x} \rfloor$. This is the largest integer $y$ such that $y^2 \leq x$. Say you have an algorithm $\mathcal{A}$ which on input $x$ outputs $z = \mathcal{A}(x)$ such that $|z - \sqrt{x}| < 1$. You can just: * ...
null
You do not need an exact method, anything with error less than 1 is OK. Say you want to compute $\lfloor \sqrt{x} \rfloor$. This is the largest integer $y$ such that $y^2 \leq x$. Say you have an algorithm $\mathcal{A}$ which on input $x$ outputs $z = \mathcal{A}(x)$ such that $|z - \sqrt{x}| < 1$. You can just: * ...
They decide any context-sensitive language (which, as you point out, is a superset of the context-free languages). See [this perl monks post](http://www.perlmonks.org/?node_id=809842). The basic insight is that the "memory" of the machine is the number of capture groups, which is linearly bounded.
[Partition refinement](http://en.wikipedia.org/wiki/Partition_refinement) is a technique in which you start with a finite set of objects and progressively split the set. Some problems, like DFA minimization, can be solved using partition refinement quite efficiently. I don't know of any other problems that are usually ...
Problems for which algorithms based on partition refinement run faster than in loglinear time
|algorithms|reference-request|data-structures|partitions|sets|
|algorithm-analysis|asymptotics|
I took my theory of computation exams a few weeks ago, and this was one of the questions: >Assume language $L=\{(a^nb^m)^r \mid n,m,r\ge 0\}$ >Is L regular? If yes provide a regular expression or an automaton for it. After I briefly asked him the answer after the exam, it appears it really is regular (I belie...
|formal-languages|regular-languages|regular-expressions|
|asymptotics|proof-techniques|check-my-proof|
Proving $\Omega(cf) = \Omega(f)$
As for the question, why do such $d_1, d_2$ always exist? You might not be able to increase $d_1$ indefinitely in order to fulfil $d_1c\geq d_2$ because $t(n) \geq d_1cf(n)$ might break along the way.
|formal-languages|regular-expressions|
null
How can you show that the Language accepted by an NFA and the reverse NFA is the same? For a language L, there is an L^R { w^R | w is a member of L} Let's say that w^R is the string obtained by reversing the string w. I know that it involves using induction on the length of the input, but I would really apprec...
How do you prove that two languages are equivalent?
|regular-languages|finite-automata|
How can you show that the Language accepted by an NFA and the reverse NFA is the same? For a language $L$, there is an $L^R=\{ w^R \mid w \in L\}$ Let's say that $w^R$ is the string obtained by reversing the string $w$. I know that it involves using induction on the length of the input, but I would really appr...
Why do such $d_1, d_2$ always exist? You might not be able to increase $d_1$ indefinitely in order to fulfil $d_1c\geq d_2$ because $t(n) \geq d_1cf(n)$ might break along the way.
|formal-languages|regular-languages|finite-automata|
null
There's an algorithm for this. Construct a DFA from you NFA, construct the reverse DFA, and check whether the two DFAs accept the same language (for example, you could construct the DFA for the symmetric difference and see if it accepts anything). If you want a more serious answer, you'll need to tell us more about you...
As the title says, I spent a couple of hours last weekend trying to wrap up my mind about the class of languages matched by Perl-compatible regular expressions, *excluding any matching operator that allows to execute arbitrary code inside the pattern*. If you don't know what PCREs are, please read [this][1] and [thi...
null
As the title says, I spent a couple of hours last weekend trying to wrap up my mind about the class of languages matched by Perl-compatible regular expressions, *excluding any matching operator that allows to execute arbitrary code inside the pattern*. If you don't know what PCREs are, please read [this][1] and [thi...
When the iterations of the inner loop depend on the outer loop, it's better to sum over the amount of iterations of the inner loop. There is no need to overcomplicate this and think of logarithms just because the outer loop has logarithmic behavior. Iterations ---------- In this example, we can see the number of...
**EDIT**: I changed the problem from 3CNF to SUBSET SUM (perhaps it has a simpler instance enumeration). An instance of the **[SUBSET SUM][1]** problem (given $y$ and $A = \{x_1,...,x_n\}$ is there a non-empty subset of $A$ whose sum is $y$) can be represented on a one-tape Turing Machine with a list of comma separa...
Time complexity of an enumeration of SUBSET SUM instances
null
**EDIT**: I changed the problem from 3CNF to SUBSET SUM (perhaps it has a simpler instance enumeration). An instance of the **[SUBSET SUM][1]** problem (given $y$ and $A = \{x_1,...,x_n\}$ is there a non-empty subset of $A$ whose sum is $y$) can be represented on a one-tape Turing Machine with a list of comma separa...
I think you're trying to take too many steps at once. Try to think about it one small step at a time. Always think about: - What are the definitions I have available - What do I know already? What is proven? ## Proving sets equal## Since you have two sets, $\Omega(cf)$ and $\Omega(f)$ and you want to p...
I think you're trying to take too many steps at once. Try to think about it one small step at a time. Always think about: - What are the definitions I have available - What do I know already? What is proven? ## Proving sets equal## Since you have two sets, $\Omega(cf)$ and $\Omega(f)$ and you want to p...
I am trying to create an algorithm in linear time where if given a directed acyclic graph I can add edges to make it strongly connected components. I believe I have an algorithm to identify sources and sinks in the input list of edges in form 1 2 2 5 3 1 etc And I know that the minimum numb...
If I have sources and sinks of a DAG can I find the minimum number of edges to be added to make it Strongly Connected?
|graphs|
|algorithms|graphs|
null
Assuming there are no isolated vertices in the graph you only need to add $max(|\mbox{sources}|,|\mbox{sinks}|)$ edges to make it strongly connected. Let $T = \lbrace t_1,\ldots,t_n\rbrace$ be the sinks and $\lbrace s_1,\ldots,s_m \rbrace$ be the sources of the DAG. Construct a bipartite graph $G(T,S)$ between the ...
From [Wikipedia][1]: > Given two subsets A and B of N and a set of functions F from N to N > which is closed under composition, A is called reducible to B under F > if $$ \exists f \in F \mbox{ . } \forall x \in \mathbb{N} \mbox{ . } x \in A \Leftrightarrow f(x) \in B $$ We write $$ A \leq_{F} B $$ Let...
Understanding definition of Reduction
|complexity-theory|
Assuming there are no isolated vertices in the graph you only need to add $max(|\mbox{sources}|,|\mbox{sinks}|)$ edges to make it strongly connected. Let $T = \lbrace t_1,\ldots,t_n\rbrace$ be the sinks and $\lbrace s_1,\ldots,s_m \rbrace$ be the sources of the DAG. Consider a bipartite graph $G(T,S)$ between the t...
The definition you're quoting is very abstract, but the concepts you're trying to understand are pretty intuitive. A problem $A$ is NP-hard if you can solve any problem in NP using it. This means that any $B \in NP$ can be reduced to $A$, i.e. there is some polytime function $f$ such that $x \in B$ iff $f(x) \in A$; so...
What is a good textbook for a seminar about - virtual environments, virtual worlds, augmented reality and similar topics? A creative commons license and availability online would be a plus.
null
|complexity-theory|terminology|reductions|
From [Wikipedia][1]: > Given two subsets A and B of N and a set of functions F from N to N > which is closed under composition, A is called reducible to B under F > if $$ \exists f \in F \mbox{ . } \forall x \in \mathbb{N} \mbox{ . } x \in A \Leftrightarrow f(x) \in B $$ We write $$ A \leq_{F} B $$ Let...
Assuming there are no isolated vertices in the graph you only need to add $max(|\mbox{sources}|,|\mbox{sinks}|)$ edges to make it strongly connected. Let $T = \lbrace t_1,\ldots,t_n\rbrace$ be the sinks and $\lbrace s_1,\ldots,s_m \rbrace$ be the sources of the DAG. Assume that $n \le m$ (the other case is similar)...
have seen some questions related to functional programming on stackexchange sites which suggests it has significant popularity. have some experience with it from many yrs ago in Lisp/Scheme and have seen commentary on the difference between functional and imperative/mutable approaches eg [4]. the wikipedia page on ...
whats an example for which the purely functional programming approach gives better results than imperative style?
|programming-languages|functional-programming|
have seen some questions related to functional programming on stackexchange sites which suggests it has significant popularity. have some experience with it from many yrs ago in Lisp/Scheme and have seen commentary on the difference between functional and imperative/mutable approaches eg [4]. the wikipedia page on ...
"Better" is obviously subjective but Evan Farrer did his [master's thesis](http://evanfarrer.blogspot.ca/2012/06/unit-testing-isnt-enough-you-need.html) on rewriting python programs into Haskell (a purely functional language) and seeing how many bugs it caught. You can read his paper, but the Haskell compiler caught ma...
I have been reading [*Introduction to Algorithms* by Cormen et al.][1] and I'm reading [the statement of the Master theorem starting on page 73][2]. In case 3 there is also a regularity condition that needs to be satisfied to use the theorem: > ... 3. If > ![enter image description here][3] > for some constan...
Why is there the regularity condition in the master theorem?
|time-complexity|
[Suffix arrays][1] can be used for this problem. They contain the starting positions of each suffix of the string sorted in lexicographic order. Even though they can be constructed naively in $O(nlogn)$ complexity, there are methods to construct them in $\Theta(n)$ complexity. See for example [this][2] and [this][3]. L...
*I* have seen some questions related to functional programming on stackexchange sites which suggests it has significant popularity. *I* have some experience with it from many *years* ago in Lisp/Scheme and have seen commentary on the difference between functional and imperative/mutable approaches eg [4]. *The* wiki...