instruction
stringlengths
0
29.8k
⌀
I have an object that is moving towards target point and I want to determine when it will reach or pass through it. I receive points in real time, which represent the current location of the object. Naive approach: For each received point: - Calculate distance between current and target points. - As the object ...
Given two sets of nonnegative numbers $X=\{x_1,...,x_n\}$ and $Y=\{y_1,...,y_n\}$, my problems consists in finding the partition $S \subseteq \{1,...,n\}$ and $\bar{S}=\{1,...,n\}\backslash S$ maximizing the following quantity: $$\frac{\displaystyle\left(\sum_{i\in S}x_iy_i\right)^2}{\displaystyle\sum_{i\in S}x_i^2}+\...
Partition of two sets for multi-line fitting, NP-hard?
I’m curious about an embedding technique where every possible “tokenization” of a text gets an embedding - not just individuals words, but every single 2-gram, 3-gram, and n-gram. Does this exist? Or is it the bag of words approach? What I would really like is to explore in real time how the addition of a toke...
Does T5 or another embedding embed every possible length tokenization?
|discrete-mathematics|linear-algebra|natural-language-processing|euclidean-distance|bayesian-statistics|
I'm kind of struggling with this excercise. The obvious thing to try is to show that **3-COL** $\leq_p$ **3-COL-$K_4$-FREE** ($\leq_p$ stands for polynomial reduction). It is clear that **3-COL-$K_4$-FREE** is in $NP$. The first thing that comes to mind then is to take the trivial reduction that maps a graph $G$ ...
Let 3-COL-$K_4$-FREE be the decision problem that asks if a graph that doesn't contain $K_4$ admits a 3-coloring. Show that the problem is NP-complete
|np-complete|colorings|polynomial-time-reductions|
null
null
null
Yes, since the class of split graphs is a subclass of the class of chordal graphs, you can define a `parameterized reduction` from the problem parameterized by output size on split graph to the same problem parameterized by output size on chordal graph with $(G, k)\mapsto (G, k)$ where the output of the reduction is th...
I want to prove that the language $\text{Max-Unique-Clique} = \{<G> | \text{The maximal clique of $G$ is unique}\}$ is in $\Sigma_2^p$ by using the following $\Sigma_2^p$ machine: 1. The machine guesses $k$ and verifies that there is a subset of size $k$ that is a clique. If not, it rejects. 2. It verifies that a...
Here is a possible reduction $f$ from $3\text{-COL}$. Let $H$ be any fixed graph that does not contain $K_4$ and is not $3$-colorable (e.g., $H=(\{1,2,3,4,5\}, \{(1,2), (1,3), (1,4), (2,3), (2,4), (3,5), (4,5)\})$). Given an instance $G$ of $3\text{-COL}$ $f(G)$, define $f$ as follows: $$ f(G) = \begin{cases} H & ...
We were taught to use reductions in order to show that a given L is undecidable. My question is, given some definition of a new L, is there a way to find a reduction $$ L\leq_mHALT $$ So that I can determine $L \in RE$? More specifically, given the quite common problem of the decidability of $$ L = \\{\langle M...
Reduction from a language with unknown decidability to HALT
|turing-machines|reductions|halting-problem|turing-recognizable|
We were taught to use reductions in order to show that a given L is undecidable. My question is, given some definition of a new L, is there a way to find a reduction $$ L\leq_mHALT $$ So that I can determine $L \in RE$? More specifically, given the quite common problem of the decidability of $$ L=\\{\langle M\r...
We were taught to use reductions in order to show that a given L is undecidable. My question is, given some definition of a new L, is there a way to find a reduction $$ L\leq_mHALT $$ So that I can determine $L \in RE$? More specifically, given the quite common problem of the decidability of $$ L=\\{{\langle M\...
We were taught to use reductions in order to show that a given L is undecidable. My question is, given some definition of a new L, is there a way to find a reduction $$ L\leq_mHALT $$ So that I can determine $L \in RE$? More specifically, given the quite common problem of the decidability of $$ L=\{\langle M\ra...
We were taught to use reductions in order to show that a given L is undecidable. My question is, given some definition of a new L, is there a way to find a reduction $$ L\leq_mHALT $$ So that I can determine $L \in RE$? More specifically, given the quite common problem of the decidability of $$ L=\{\langle M\ra...
We were taught to use reductions in order to show that a given L is undecidable. My question is, given some definition of a new L, is there a way to find a reduction $$ L\leq_mHALT $$ So that I can determine $L \in RE$? More specifically, given the quite common problem of the decidability of $$ L=\{\langle M\ra...
null
null
There is no need to apply the $\varepsilon$-closure twice when computing transitions. There are two main ways to convert an $\varepsilon$-NFA into a NFA: the forward closure and the backward closure. Consider $(Q, \Delta, I, F)$ an $\varepsilon$-NFA. - In the forward closure, you are trying to apply $\varepsilon$-tr...
I have an object that is moving towards target points and I want to determine when it will reach or pass through them. I receive points in real time, which represent the current position of the object. The position is a 6-D vector. The data can be download from [here][1] **Initial approach** For each received poi...
Detecting if an object reached target points
|algorithms|python|robotics|
No one can tell you what will be best; you'll have to try different approaches and see what works best in your setting. I think one reasonable approach worth trying is to filter the data using a [Kalman filter](https://en.wikipedia.org/wiki/Kalman_filter), then find the filtered point that is closest to the origin (...
null
You can get a reduction from the proofs you've seen. Construct a TM $M_L$ which uses dovetailing to count how many inputs a given TM $M$ accepts and let $M_L$ halt once that counter reaches a value $\geq 5$. Thus, $M_L$ halts on input $\langle M \rangle$ if and only if $\langle M \rangle \in L$, yielding the desired re...
I'm not sure what you mean by "$\Sigma_2^p$ machine". If you consider a polytime NTM with a $\mathsf{coNP}$ oracle (i.e. using $\Sigma_2^p = \mathsf{NP}^{\mathsf{coNP}}$), then we only have restrictions on running time (that is, the length of "guessed" witnesses is merely bounded rather than fixed); essentially the sam...
null
Your $M_1$ is not a polynomial time NTM unless $\mathsf{NP} = \mathsf{coNP}$, I think. In the last step (checking that $G_{ij}$ contains no HC), you essentially want to decide the complement of HC, which is $\mathsf{coNP}$-complete. This is a bit of a tricky thing about nondeterministic computation: you cannot simply i...
null
I already asked this question previously on the [Mathematics Stack Exchange][1] but got no answers so maybe it's a better fit for the CS Stack Exchange after all (though I'm open to hearing opinions about what is the best place for this question). A linear equation $Ax=b$ can be solved by reducing the matrix $A$ to ...
A version of Bareiss algorithm or similar for symmetric matrices
|algorithms|matrices|linear-algebra|
null
The problem can be reduced to the *maximum independent set problem*. Let $G = (V,E)$ be the input instance of the problem. Then, create a new graph $G'$ such that each vertex in $G'$ corresponds to an arc in $G$. Two vertices in $G'$ have an edge between them if and only if the corresponding arcs are connected in $G$. ...
{"Voters":[{"Id":107966,"DisplayName":"Inuyasha Yagami"}],"DeleteType":1}
{"Voters":[{"Id":107966,"DisplayName":"Inuyasha Yagami"}]}
Dependently typed languages such as Agda support [inductive families][1], also called [indexed datatypes][2], which allow type parameters to vary between constructors. This can be used to define a set of relations between types, which can be used to constrain existentials. For example, we can capture the relation $$...
On the 7th of June 2023, Google DeepMind released an article about **AlphaDev**. **AlphaDev** is an evolution of **AlphaZero** (used to beat world champions at Go, Chess and Shogi), and it can produce assembly code for a task if said task is represented as a game. All of this information can be found [here](https://www...
How AlphaDev improved sorting arlgorithms?
|algorithms|sorting|assembly|
$FINITE_{TM} = \\{\langle M \rangle |\ M\ is\ an\ TM\ and\ L(M)\ is\ finite\\}$ $A_{MT} = \\{\langle M,w \rangle |\ M\ is\ an\ TM\ and\ M\ accepts\ w\\}$ I'm trying to prove that $FINITE_{TM}$ is not Turing-reducible to $A_{MT}$ by contradiction. Supposing it is, I get that there's an oracle Turing machine $H^...
$FINITE_{TM}$ is not Turing-reducible to $A_{MT}$
|turing-machines|undecidability|oracle-machines|
$FINITE_{TM} = \{\langle M \rangle\mid M\text{ is a TM and }L(M)\text{ is finite}\}$ $A_{MT} = \{\langle M,w \rangle \mid M\text{ is a TM and }M\text{ accepts }w\}$ I'm trying to prove that $FINITE_{TM}$ is not Turing-reducible to $A_{MT}$ by contradiction. Supposing it is, I get that there's an oracle Turing ...
null
**This problem can be solved in polynomial time** in the manner alluded to by Yves Daoust in a comment. Specifically, I'll show that there exists an optimal solution in which every input point "above" some line through the origin can be placed in one part, and every other point in the other. This enables a simple algor...
Check out Grady Booch's [tweet][1] on the matter. [1]: https://twitter.com/Grady_Booch/status/1672308719387029504 Coming up with assembly level tricks is not the same as finding a new sorting algorithm. That would be my two cents on it.
Check out Grady Booch's [tweet][1] on the matter: > there is no "new sorting algorithm" here. [1]: https://twitter.com/Grady_Booch/status/1672308719387029504 Coming up with assembly level tricks is not the same as finding a new sorting algorithm. That would be my two cents on it.
null
This is not a new sorting algorithm. It's much more interesting than that. AlphaDev appears to have produced a new technique for superoptimisation. You can think of the [superoptimisation][1] problem as trying to take a code fragment, and finding the optimal sequence of instructions that does the same thing. The ide...
This is not a new sorting algorithm. It's much more interesting than that. AlphaDev appears to have produced a new technique for superoptimisation. You can think of the [superoptimisation][1] problem as trying to take a code fragment, and finding the optimal sequence of instructions that does the same thing. The ide...
A contiguous single polygon is specified by it's vertices $(v_1, \ldots, v_n)$, given in order such that the line between $v_i$ and $v_{i+1}$ is an edge of the polygon (there's also an edge between $v_n$ and $v_1$). For example, a triangle might look like $v_1=(0, 0), v_2 = (1, 1), v_3 = (2, 0)$. Anyways, given two ...
Finding shortest path between two points in a polygon whose vertices are given?
|algorithms|graphs|shortest-path|graph-traversal|euclidean-distance|
The graph that you defined is known as [visibility graph](http://www.science.smith.edu/~istreinu/Teaching/Courses/274/Spring98/Projects/Philip/fp/visibility.htm#:~:text=The%20visibility%20graph%20of%20a,can%20%E2%80%9Csee%E2%80%9D%20each%20other.). You can find a $O(n^2 \log n)$ algorithm [here](http://www.science.smit...
The graph that you defined is known as [visibility graph](http://www.science.smith.edu/~istreinu/Teaching/Courses/274/Spring98/Projects/Philip/fp/visibility.htm#:~:text=The%20visibility%20graph%20of%20a,can%20%E2%80%9Csee%E2%80%9D%20each%20other.). You can find a $O(n^2 \log n)$ algorithm [here](http://www.science.smit...
null
The graph that you defined is known as [visibility graph](http://www.science.smith.edu/~istreinu/Teaching/Courses/274/Spring98/Projects/Philip/fp/visibility.htm#:~:text=The%20visibility%20graph%20of%20a,can%20%E2%80%9Csee%E2%80%9D%20each%20other.). You can find a $O(n^2 \log n)$ algorithm [here](http://www.science.smit...
I am trying to program a Turing machine that performs unary subtraction, $m-n$, but if $m<n$, the machine writes the $!$ symbol on the tape $|m-n|$ times. If $m=1$ and $n=3$, the machine would only leave $!!$ on the tape. Now, I have successfully created a machine that performs unary subtraction $m-n$ where $m<n$ an...
Turing machine for unary subtraction $m-n$. If $m<n$, the machine writes "$!$" $|m-n|$ times
|turing-machines|computability|automata|
On the 7th of June 2023, Google DeepMind released an article about AlphaDev. AlphaDev is an evolution of AlphaZero (used to beat world champions at Go, Chess and Shogi), and it can produce assembly code for a task if said task is represented as a game. All of this information can be found [here](https://www.deepmind.co...
How AlphaDev improved sorting algorithms?
I have read the GPT-1 paper, and my understanding is that it works as follows: $U$ is input tokens, $h_0=UW_e+W_p$, $h_i=\text{transformer_block}(h_{i-1})$ and the output is a probability vector $P(u)=\text{softmax}(h_nW_e^T)$, and the hidden states are the final latent layer before softmax, so the hidden states are $h...
Why is GPT model a higher order hidden markov model
|machine-learning|artificial-intelligence|
Why GPT model is a higher order hidden markov model
null
The statement that GPT is a higher order hidden Markov model should not be taken too seriously. It is intended as a slogan or intuition, not something that is intended to be be rigorously proven. Let $x_1,x_2,\dots,x_k$ denote the words of the text, in order ($x_1$ is the first word, etc.). GPT is a model for pr...
Why does Java's `HashSet` have an underlying `HashMap`, not the other way around? `HashMap` could have contained an internal `HashSet` of `Map.Entry`s, and `HashSet` wouldn't have stored twice as many elements because of those empty `Object`s as its elements' `Map` values (while implementing the hashtable data structur...
Why does Java's HashSet have an underlying HashMap, not the other way around?
|data-structures|java|
I can’t properly explain what the concrete differences are here or why they work. I’ll leave that to someone who is an expert on sorting algorithms. The comments in the pseudo-code though do explain somewhat tersely what each instruction is doing in high-level terms, so looking through those (and possibly experimenting...
On the 7th of June 2023, Google DeepMind released an article about AlphaDev. AlphaDev is an evolution of AlphaZero (used to beat world champions at Go, Chess and Shogi), and it can produce assembly code for a task if said task is represented as a game. All of this information can be found [here](https://www.deepmind.co...
null
null
The article says it. They focused on short sequences of $3$ to $5$ elements using the sorting network technique. Then the achieved $70\%$ speedup on these cases. But more interesting is the fact that the speedup is of $1.7\%$ on sequences of more than $250000$ elements. IMO, much fuss about nothing as regards the...
The article says it. They focused on short sequences of $3$ to $5$ elements using the sorting network technique. They say they achieved $70\%$ speedup on these cases. But when you look closely to the detailed benchmarks, you see that $70\%$ is a unique extreme case, and speedups are more commonly like $30\%$, $0\%$ and...
The article says it. They focused on short sequences of $3$ to $5$ elements using the sorting network technique. They say they achieved $70\%$ speedup on these cases. But when you look closely to the detailed benchmarks, you see that $70\%$ is a unique extreme case, and speedups are more commonly like $30\%$, $0\%$ and...
I've just hashed up the following hair-brained idea of how to sort n-tuples of integers, as demonstrated below with a set of 3-tuples: [ 4 , 1 , 3 ] [ 1 , 2 , 1 ] [ 2 , 2 , 1 ] [ 2 , 1 , 1 ] [ 1 , 1 , 1 ] [ 2 , 1 , 2 ] [ 3 , 1 , 3 ] [ 1 , 2 , 2 ] [ 1 , 1 , 3 ] [ 1 , 1 , 2 ] [ 3 , 1 , 1 ] [ 3 ,...
null
You don't tell us how you perform the "partitions", and in particular how you perform the sorts on the respective tuple elements. So it is hard to say if your rediscovered a radix-sort-like procedure or just successive sorting passes. By the way, it is probably more efficient to use a standard sort with a lexicograp...
AFAIU, there are only two issues, that VM solves: 1) Scarcity of RAM; 2) Access control to "unknown" memory, where SW tries to read from or write to the memory it does not own or share with other processes. While p.1) is becoming a non-factor for more use-cases, than it probably was in the past, are there any solu...
Why do we still need virtual memory in 21st century?
|virtual-memory|
null
I've had the following question on a test and I answered: 'False', my answer was incorrect and I'm trying to understand why. VC = {<G,k>| G = undirected graph with a vertex cover of size k} IS = {<G,k>| G = undirected graph with an independent set of size k} **Ture or False:** **Assuming there exists a lang...
what are the necessary requirements for proving NP is closed under complement?
|complexity-theory|graphs|np-complete|np-hard|np|
I'm trying to practice recurrence equations, so I'm trying to solve this typology by unfolding method. I was wondering if what I write below was correct and obviously the result: $T(n) = n^2 + T(n-4) = n^2 + [n^2 + T(n - 8)] = n^2 + n^2 +[n^2 + T(n-12)] = n^2 + n^2 + n^2 + [n^2 + T(n-16)] = ...$ In general we ca...
Solve Recurrence Equation: ()=(−4)+^2
|asymptotics|recurrence-relation|big-o-notation|
As the recurrence only involves values four units apart, we rewrite with $n=4m$: $$T(4m)=T(4m-4)+(4m)^2$$ or $$U(m)=U(m-1)+16m^2.$$ The solution is obviously $$U(m)=U(0)+16\sum_{k=1}^mk^2= U(0)+16\frac{m(m+1)(2m+1)}6$$ by the well-known formula for the sum of squares. From this $$T(n)=T(0)+\frac{n(n+2...