instruction
stringlengths
0
29.8k
⌀
|undecidability|
I know that given two problems are undecidable it does not follow that their conjunction must be undecidable. For example, take a property of languages $P$ such that it is undecidable whether the language accepted by a given pushdown automaton $M$ has that property. Clearly $P$ and not-$P$ are undecidable (for a given ...
Examples of undecidable problems whose conjunction is decidable
|reference-request|undecidability|decision-problem|
I'm trying to prove that $L_1=\{\langle M\rangle$ | $M$ is a Turing machine and in running on $\epsilon$, $M$ visits $q_0$ at least twice} $\notin R$. I'm not sure whether to reduce the $\text{HALT}$ problem to it or not. I tried to construct a new $M'$ which for $<M>,w$ $M'$ visits $q_o$ twice iff $M$ halts on $w$...
|turing-machines|undecidability|halting-problem|
Showing $L_1=\{\langle M\rangle$| $M$ is a Turing machine and in running on $\epsilon$, M visits $q_0$ at least twice} $\notin R$
Assume, we have an optimization problem with function $f$ to maximize. Then, the corresponding decision problem 'exists a solution with $f\ge k$ for a given $k$ ?' can easily be reduced to the optimization problem: Calculate the optimal solution and check if it is $\ge k$. Now, I was wondering, if it is always po...
Optimization problem vs decision problem - reduction
|optimization|reductions|decision-problem|
Assume we have an optimization problem with function $f$ to maximize. Then, the corresponding decision problem 'Does there exist a solution with $f\ge k$ for a given $k$?' can easily be reduced to the optimization problem: calculate the optimal solution and check if it is $\ge k$. Now, I was wondering, is it alwa...
Don't make this more complicated than it is. Instead of giving you a full solutions, I will give you a partial solution, which should allow you to work out the details by yourself: Every TM be turned into a TM that visits its initial state exactly once. To do so, introduce a new state $q^'_0$, which will be the new ...
I'm trying to prove that $L_1=\{\langle M\rangle$ | $M$ is a Turing machine and in running on $\epsilon$, $M$ visits $q_0$ at least twice} $\notin R$. I'm not sure whether to reduce the $\text{HALT}$ problem to it or not. I tried to construct a new machine $M'$ for $(\langle M \rangle,w)$, such that $M'$ visits $q_...
null
I'm trying to prove that $L_1=\{\langle M\rangle \mid M \text{ is a Turing machine and visits } q_0 \text{ at least twice on } \varepsilon\} \notin R$. I'm not sure whether to reduce the halting problem to it or not. I tried to construct a new machine $M'$ for $(\langle M \rangle,w)$, such that $M'$ visits $q_0$...
Showing that the set of TMs which visit the starting state twice on the empty input is undecidable
I'm trying to prove that $L_1=\{\langle M\rangle \mid M \text{ is a Turing machine and visits } q_0 \text{ at least twice on } \varepsilon\} \notin R$. I'm not sure whether to reduce the halting problem to it or not. I tried to construct a new machine $M'$ for $(\langle M \rangle,w)$, such that $M'$ visits $q_0$...
|turing-machines|reductions|undecidability|halting-problem|
On [Wikipedia](https://en.wikipedia.org/wiki/Levenshtein_distance#Computing_Levenshtein_distance), an implementation for the bottom-up dynamic programming scheme for the edit distance is given. It does not follow the definition completely; inner cells are computed thus: if s[i] = t[j] then d[i, j] := d[...
Micro-optimisation for edit distance computation: is it valid?
|algorithms|dynamic-programming|string-metrics|correctness-proof|program-optimization|
I want to make a sequence of numbers, where I pick the numbers $a_{0}, a_{1},..,a_{n}$. The length of the sequence is $n+1$. Now I want the product of any pair of 2 numbers in the sequence modulo k to be guaranteed to be unique and $k$ has to be as small as it can be in such a way that the resulting set has to be $r...
null
This question is about geometric theorem proving and is inspired by this <a href="http://math.stackexchange.com/questions/31192/is-it-possible-to-solve-any-euclidean-geometry-problem-using-a-computer"> Math.SE </a> post. Currently, Euclidean-geometric theorem provers, as referred to in the post, use coordinate geometr...
Automated geometric theorem-proving using synthetic methods
|artificial-intelligence|automated-theorem-proving|
Does any one know how to implement the simulation relation on two LTSs? I know how to do it for branching bi-simulation. The signature refinement theorem is used for that purpose which has the time complexity of $O(n^3)$ on cyclic LTSs. Is the signature refinement technique useful for simulation also? Is there a...
A question was asked at Stack Overflow ([here][1]): > `A^2+B^2+C^2+D^2 = N` Given an integer `N`, print out all possible > combinations of integer values of `ABCD` which solve the equation. This question is of course related to [Bachet's Conjecture][2] in Number Theory (sometimes called Lagrange's Four Square Th...
How fast can we find all Four-Square combinations that sum to N?
|algorithms|complexity-theory|performance|number-theory|
A question was asked at Stack Overflow ([here][1]): > Given an integer $N$, print out all possible > combinations of integer values of $A,B,C$ and $D$ which solve the equation $A^2+B^2+C^2+D^2 = N$. This question is of course related to [Bachet's Conjecture][2] in number theory (sometimes called Lagrange's Four ...
I have this question that is confusing the hell out of me. Consider the context free grammar: bill <- items total vat items <- item | item items item <- name price | name quantity price quantity <- integer price <- integer total <- integer total <- TOTAL price vat <- VAT price Question: Ho...
Factor the grammar
|formal-languages|formal-grammars|context-free|
I think a $o(N^2)$ time algorithm is not a trivial one and requires some insight if one exists. The obvious algorithm that runs in quadratic time enumerates all tuples $A,B,C,D \leq \sqrt[]{N}$. This can be done in four loops, so the total time complexity becomes $O(N^2)$. It also clearly enumerates all solutions. A...
Consider the context free grammar: bill <- items total vat items <- item | item items item <- name price | name quantity price quantity <- integer price <- integer total <- integer total <- TOTAL price vat <- VAT price How do I factor the grammar? This was asked in a past...
Factor a grammar
I know that given two problems are undecidable it does not follow that their conjunction must be undecidable. For example, take a property of languages $P$ such that it is undecidable whether the language accepted by a given pushdown automaton $M$ has that property. Clearly $P$ and not-$P$ are undecidable (for a given ...
I think a $o(N^2)$ time algorithm is not a trivial one and requires some insight if one exists. The obvious algorithm that runs in quadratic time enumerates all tuples $A,B,C,D \leq \sqrt[]{N}$. This can be done in four loops, so the total time complexity becomes $O(N^2)$. It also clearly enumerates all solutions. A...
I want to make a sequence of numbers, where I pick the numbers $a_{0}, a_{1},..,a_{n}$. The length of the sequence is $n+1$. Now I want the product of any pair of two numbers in the sequence modulo $k$ to be guaranteed to be unique and $k$ has to be as small as it can be in such a way that the resulting set has to b...
Does any one know how to implement the simulation relation on two [labelled transition systems](https://en.wikipedia.org/wiki/State_transition_system) (LTS)? I know how to do it for branching bi-simulation. The signature refinement theorem is used for that purpose which has the time complexity of $O(n^3)$ on cyclic...
Consider the context free grammar: $\qquad \begin{align} \mathrm{bill} &\to \mathrm{items}\ \mathrm{total}\ \mathrm{vat} \\ \mathrm{items} &\to \mathrm{item} \mid \mathrm{item}\ \mathrm{items} \\ \mathrm{item} &\to name\ \mathrm{price} \mid name\ \mathrm{quantity}\ \mathrm{price} \\ \mathrm{quant...
I know that given two problems are undecidable it does not follow that their intersection must be undecidable. For example, take a property of languages $P$ such that it is undecidable whether the language accepted by a given pushdown automaton $M$ has that property. Clearly $P$ and $\lnot P$ are undecidable (for a giv...
Examples of undecidable problems whose intersection is decidable
*(Note: I don't know anything about geometric reasoning, so I'm shifting from my limited experience in automated theorem proving in another field. I think the fundamental issue is the same.)* Synthetic reasoning tends to blow up exponentially. Typically, after $n$ steps of reasoning, there are about $a^k$ ways to ch...
null
Consider the following search tree. Your heuristic search algorithm starts the search at the root node. Unexpanded nodes are marked gray. ![Search tree][1] For some reason, the heuristic is being guided towards the left-most subtree, when in fact the goal node is in the right-most subtree, marked with green. !...
[Generalizing the Paige-Tarjan Algorithm by Abstract Interpretation][1], by Francesco Ranzato and Francesco Tapparo This paper provides a design-pattern for implementing partition-refinement style algorithms for checking bisimulation and simulation. The later sections of the paper are quite algorithmic. You could co...
The [3SUM][1] problem tries to identify 3 integers $a,b,c$ from a set $S$ of size $n$ such that $a + b + c = 0$. It is conjectured that there is not better solution than quadratic, i.e. $\mathcal{o}(n^2)$. Or to put it differently: $\mathcal{o}(n \log(n) + n^2)$. So I was wondering if this would apply to the gene...
Evening Gents, I've just begun this stage 2 Compsci paper on algorithms, and stuff like this is not my strong point. I've come across this in my lecture slides. int length = input.length(); for (int i = 0; i < length - 1; i++) { for (int j = i + 1; j < length; j++) { System.out.println...
Please explain how this time complexity formula was obtained
|time-complexity|
$k$-SUM can be solved more quickly as follows. * **For even $k$:** Compute a sorted list $S$ of all sums of $k/2$ input elements. Check whether $S$ contains both some number $x$ and its negation $-x$. The algorithm runs in $O(n^{k/2}\log n)$ time. * **For odd $k$:** Compute the sorted list $S$ of all sums of $(...
Don't make this more complicated than it is. Instead of giving you a full solutions, I will give you a partial solution, which should allow you to work out the details by yourself: Every TM be turned into a TM that visits its initial state exactly once. To do so, introduce a new state $q^'_0$, which will be the new ...
|algorithms|time-complexity|algorithm-analysis|
Your intuition is correct, the work is in identifying the things you're adding together. The first bit is that printing a string of length $m$ takes $m$ operations, so the <pre><code>System.out.println(input.substring(i,j));</code></pre> line takes $j-i$ operations. (A side note here is that this code is in Java...
|complexity-theory|optimization|reductions|decision-problem|
|programming-languages|logic|type-theory|type-inference|
|terminology|logic|
Evening Gents, I've just begun this stage 2 Compsci paper on algorithms, and stuff like this is not my strong point. I've come across this in my lecture slides. int length = input.length(); for (int i = 0; i < length - 1; i++) { for (int j = i + 1; j < length; j++) { System.out.println...
null
Does any one know how to implement the simulation relation on two [labelled transition systems](https://en.wikipedia.org/wiki/State_transition_system) (LTS)? I know how to do it for branching bi-simulation. The signature refinement theorem is used for that purpose which has the time complexity of $O(n^3)$ on cyclic...
|automata|formal-methods|process-algebras|
I need an example for how to calculate penetrance and branching factor of the search tree in in state-space heuristic search. The definitions are as following. *Penetrance* $P$ is defined by $\qquad \displaystyle P = \frac{L}{T}$ and *branching factor* $B$ is defined by $\qquad \displaystyle \frac{B}{(B-1)} \c...
I've just begun this stage 2 Compsci paper on algorithms, and stuff like this is not my strong point. I've come across this in my lecture slides. int length = input.length(); for (int i = 0; i < length - 1; i++) { for (int j = i + 1; j < length; j++) { System.out.println(input.substrin...
|algorithms|time-complexity|algorithm-analysis|runtime-analysis|
I don't think that the algorithm is flawed. If two strings are matched, we compare first its last two characters (and then recurse). If they are the same, we can match them to get an optimal alignment. For example, consider the strings `test` and `testat`. If you don't match the two last `t`s, than one of the `t`s re...
null
Let's work from the outside in. for (int i = 0; i < length - 1; i++) { Clearly, this loop is executed $n-1 = \mathrm{length}-1$ times, so we get $\sum_{i=0}^{n-2} \dots$ where $\dots$ stands for the time needed by the loop's body (for iteration $i$). Inside, we have for (int j = i + 1; j < length; j++)...
Let's work from the outside in. for (int i = 0; i < length - 1; i++) { Clearly, this loop is executed $n = \mathtt{length}-1$ times, so we get $\sum_{i=0}^{n-1} \dots$ where $\dots$ stands for the time needed by the loop's body (for iteration $i$). Inside, we have for (int j = i + 1; j < length; j++) {...
In *"Introduction to Algorithms: 3rd Edition"* there is theorem 34.2 which states P = { L : L is accepted by a polynomial-time algorithm } *"Accepted in polynomial-time"* is defined by: L is accepted in polynomial time by an algorithm A if it is accepted by A and if in addition there exists a cons...
P = { L : L is accepted by a polynomial-time algorithm }
|complexity-theory|
No this means, that the language $L$ that contains all possible words ($L=\Sigma^*$) is in $P$. In other words, no matter what your input is, the algorithm accepts. And the corresponding language is of course (trivially) decidable in polynomial time. To clarify things: A language is a set of words (the words are con...
Let's work from the outside in. for (int i = 0; i < length - 1; i++) { Clearly, this loop is executed $n = \mathtt{length}-1$ times, so we get $\sum_{i=0}^{n-1} \dots$ where $\dots$ stands for the time needed by the loop's body (for iteration $i$). Inside, we have for (int j = i + 1; j < length; j++) {...
In *"Introduction to Algorithms: 3rd Edition"* there is Theorem 34.2, which states > $P = \{ L \mid L \text{ is accepted by a polynomial-time algorithm} \}$ *"Accepted in polynomial-time"* is defined by: > $L$ is accepted in polynomial time by an algorithm $A$ if it is accepted by $A$ and if in addit...
|time-complexity|polynomial-time|
null
Let's work from the outside in. for (int i = 0; i < length - 1; i++) { Clearly, this loop is executed $n = \mathtt{length}-1$ times, so we get $\sum_{i=0}^{n-1} \dots$ where $\dots$ stands for the time needed by the loop's body (for iteration $i$). Inside, we have for (int j = i + 1; j < length; j++) {...
Problem with the definition of P
|complexity-theory|terminology|time-complexity|polynomial-time|
Time complexity formula of nested loops
I know that given two problems are undecidable it does not follow that their intersection must be undecidable. For example, take a property of languages $P$ such that it is undecidable whether the language accepted by a given pushdown automaton $M$ has that property. Clearly $P$ and $\lnot P$ are undecidable (for a giv...
I think a $o(N^2)$ time algorithm is not a trivial one and requires some insight if one exists. The obvious algorithm that runs in quadratic time enumerates all tuples $A,B,C,D \leq \sqrt[]{N}$. This can be done in four loops, so the total time complexity becomes $O(N^2)$. It also clearly enumerates all solutions. A...
Consider the following search tree. Your heuristic search algorithm starts the search at the root node. Unexpanded nodes are marked gray. ![Search tree][1] For some reason, the heuristic is being guided towards the left-most subtree, when in fact the goal node is in the right-most subtree, marked with green. !...
In a recent CACM article [1], the authors present a way to improve scalability of shared and coherent caches. The core ingredient is assuming the caches are *inclusive*, that is higher-level caches (e.g. L3, one global cache) contain all blocks which are stored in their descendant lower-level caches (e.g. L1, one cach...
Why can L3 caches hold only shared blocks?
|terminology|computer-architecture|cpu-cache|shared-memory|
## Master Theorem The [Master theorem](https://en.wikipedia.org/wiki/Master_theorem) gives asymptotics for the solutions of so-called [divide & conquer](https://en.wikipedia.org/wiki/Divide_and_conquer_algorithm) recurrences, that is such that divide their parameter into proportionate chunks (instead of cutting away...
So here is a example, which is probably not as *nice* as you wanted it to be, but less trivial than the one you have mentioned. Let $L_1,L_2\subset \{a,b,c\}^*$ be two undecidable languages, and $L_3\subseteq \{a,b,c\}^*$ a decidable language. We define **\begin{align} L_A&:=\{a\,w \mid w\in L_1\} \cup \{c\,w \m...
Juho's algorithm can be improved to an $O(N)$ algorithm using meet-in-the-middle. Go over all pairs $A,B \leq \sqrt{N}$; for each pair such that $M=A^2+B^2 \leq N$, store $(A,B)$ in some array $T$ of length $N$ (each position $M$ could contain several pairs, which might be stored in a linked list). Now go over pairs $M...
Perhaps I can shed some light on associativity. These caches aren't just open blocks of memory, so don't think of them as some kind of generic container. Each block of memory has a real address (whether this is physical or virtual doesn't matter, just assume it is a fixed address). At each level of cache this memory ca...
Juho's algorithm can be improved to an $O(N)$ algorithm using meet-in-the-middle. Go over all pairs $A,B \leq \sqrt{N}$; for each pair such that $M=A^2+B^2 \leq N$, store $(A,B)$ in some array $T$ of length $N$ (each position $M$ could contain several pairs, which might be stored in a linked list). Now go over pairs $M...
A Naive Bayes predictor makes its predictions using this formula: $$P(Y=y|X=x) = \alpha P(Y=y)\prod_i P(X_i=x_i|Y=y)$$ where $\alpha$ is a normalizing factor. This requires estimating the parameters $P(X_i=x_i|Y=y)$ from the data. If we do this with $k$-smoothing, then we get the estimate $$\hat{P}(X_i=x_i|Y=y...
Smoothing in Naive Bayes model
|machine-learning|probability-theory|
Juho's algorithm can be improved to an $O(N)$ algorithm using meet-in-the-middle. Go over all pairs $A,B \leq \sqrt{N}$; for each pair such that $M=A^2+B^2 \leq N$, store $(A,B)$ in some array $T$ of length $N$ (each position $M$ could contain several pairs, which might be stored in a linked list). Now go over pairs $M...
There are a few conditions you would need to specify for this to even work, most importantly, that your function does have a maximum, otherwise you could try all k and end up going off into infinity. Likewise, you'd probably need to assume that f is only producing outputs on the integers or some other countable set. ...
null