instruction stringlengths 0 29.8k ⌀ |
|---|
Is it provably true/false that for a program, there exists a proof whether it halts or not? |
##### A standalone statement of my question
Given a program that takes no argument, we are interested in whether the program will eventually terminate. My question is this:
Theoretically speaking, can we always find a proof of the termination/non-termination of a program?
##### Clarification
Unlike the gen... |
Cross-validation is simple and easy to implement. Rather than inventing something new, which might be dubious, I recommend you use cross-validation. It works. |
This problem is basically to find the longest path in a directed acyclic graph (DAG).
------
<!-- Let the nodes are the tasks. If task $u$ must complete before task $v$, connect $v$ to $u$ with a directed edge. -->
Let $cost[t]$ be the number of days it takes to do task $t$.
Let $m[t]$ be the minimum number... |
##### A standalone statement of my question
Given a program that takes no argument, we are interested in whether the program will eventually terminate. My question is this:
Theoretically speaking, can we always find a proof of the termination/non-termination of a program?
##### Clarification
Unlike the gen... |
Is it better to think about tokens from right to left and perform right factoring on grammar for an LR(1) parser? As apposed to thinking about tokens left to right and doing left factoring on grammar for an LL(1) parser.
Example java import statement.
```
S1 -> S2 ;
S2 -> S5
S2 -> S3 id
S2 -> S4 *
S3 -> S5 a... |
This problem is basically to find the longest path in a directed acyclic graph (DAG). <!-- The length of a path is the sum of all costs at the nodes in the path. If we split each task into two nodes, task_start and task_end with an edge between them of the cost of the task, we will see the usual definition of the leng... |
The problem that I'm trying to solve goes like this:
A project is split into tasks. Each task takes a known number of days. Some tasks can be done at any time(lets call these simple tasks), others depend on other tasks that must first be done. Design an algorithm that can find the minimum number of days necessary to... |
Topological sort of minimum costs to finish interdependent tasks |
|algorithms|graphs|scheduling| |
Is it possible to solve the [maximum flow problem][1] in the real world, ie., using water running through physical pipes? So you would have a tap at the source node, pipes of various diameter (depending on their capacity) connecting nodes and a sink at the target node. You would turn on the tap on full and then try to ... |
Solving the maximum flow problem in the real world |
|network-flow|physics| |
Is it possible to solve the [maximum flow problem][1] in the real world, ie. using water running through physical pipes? So you would have a tap at the source node, pipes of various diameter (depending on their capacity) connecting nodes and a sink at the target node. You would turn on the tap on full and then try to m... |
Well, let's get the radix right. 1TB is $2^{40}$ bytes, and 4kB is $4\times 2^{10}$ bytes. So the number of blocks is:
$$\frac{2^{40}}{2^{12}} = 2^{28}$$
There are $2^3$ bits in a byte, so that's $2^{25}$ bytes to represent the bit vector, or 32MB.
The ratio between the two, of course, is exactly 8, which make... |
null |
I am assuming here that you are allowed to start tasks in parallel if there is no dependency between them, otherwise I think that no matter what order you do, the total time needed to finish the project will always be the same.
Let $t_i$ represent a task and a vertex in your dependency graph. Let $d[t_i]$ be the day... |
I am assuming here that you are allowed to start tasks in parallel if there is no dependency between them, otherwise I think that no matter what order you do, the total time needed to finish the project will always be the same.
Let $t_i$ represent a task and a vertex in your dependency graph. Let $d[t_i]$ be the day... |
Since $X_1,X_2$ are independent,
$$
H(X_1+X_2) \geq H(X_1+X_2|X_1) = H(X_2),
$$
and similarly $H(X_1+X_2) \geq H(X_1)$.
Therefore
$$
H(X_2|X_1+X_2) + H(X_1+X_2) = H(X_2,X_1+X_2) = H(X_1,X_2) \leq \\ H(X_1) + H(X_2) \leq 2H(X_1+X_2),
$$
which implies that
$$
H(X_2|X_1+X_2) \leq H(X_1+X_2).
$$
Since we have ... |
null |
null |
null |
null |
I wonder if there's Digital Logic Circuit (using combinatorial logic gates) that check if number is prime or not.
For example given input fixed 8-bit that will produce 1-bit output.
00000101 will produce output 1 (1 means prime)
00000110 will produce output 0 (0 means composite).
I know it's possible if u... |
Combinational logic check if bits is prime |
|logic|boolean-algebra|primes|digital-circuits|combinatory-logic| |
[Here is a question on Turing completeness of neural networks](https://stackoverflow.com/q/2990277/133374).
In [my answer](https://stackoverflow.com/a/53022636/133374), I also discuss the human brain a bit, and I reference also this question here.
I think allowing for some type of infinite medium for infinite exter... |
I wonder if there's Digital Logic Circuit (using combinatorial logic gates) that check if number is prime or not.
For example given input fixed 8-bit that will produce 1-bit output.
00000101 will produce output 1 (1 means prime)
00000110 will produce output 0 (0 means composite).
I know it's possible if u... |
There is no known regularity in the primes, and for small numbers (such as 8 bits naturals), the best is to implement them as a table.
If you want an instant answer, one comparator per prime can do. Otherwise, binary search can be implemented in hardware, possibly storing a binary trie. Or simply an array of bits.
|
null |
In theory, a Turing machine has enough power to simulate all the molecules in a brain, so there is no doubt that it is as capable.
We can also argue that in some decades, AI will be able to reach human performance and pass the Turing tests successfully, without the need for a detailed physical simulation, just globa... |
null |
What you're trying to build is kind of a crossword. [This][1] link shows an algorithm that generates crosswords. It's not quite your case, but it's close enough. Basically the algorithm does this (starting from the first word $w$ of the ordered dictonary):
1. If $w$ can be placed in a path and if it hasn't already ... |
null |
if UTC is universal, what drawbacks does it have in using it in a distributed system to coordinate events or use it as a global objective reference clock?
isn't it right to just use UTC to timestamp every message to order messages without using lamport logical clocks! |
can UTC replace Lamport logical clocks? |
|distributed-systems|clocks| |
Actually this is no different from the halting problem unsolvability. If you have any formal system T with a proof verifier program V that can reason about programs (as you desire in your question), then let H be the program that does the following on input (P,X):
  For each string s in length-lexicographic ord... |
Actually this is no different from the halting problem unsolvability. If you have any formal system T with a proof verifier program V that can reason about programs (as you desire in your question), then let H be the program that does the following on input (P,X):
  For each string s in length-lexicographic ord... |
null |
Let $k=\lg(n)+c$.
$(1) = O(\lg(n)),$
$(2) = O(2^{\lg(n)+c}\lg(n))=O(n\log(n)).$ |
null |
> Unlike the general halting problem, this problem does not require a mechanical procedure to generate a proof for each program which can potentially depend on the procedure itself, but instead, it allows the proof to depend on the specified program. It is thus a much weaker version.
The general halting problem alre... |
null |
I've been solving a lot of questions lately about determining the type of a given language, by type I mean whether it's regular, CFL, in P, Turing-decidable, Turing-acceptable, or all the languages. and I have this language here:
$$L=\{w:|w|\text{ is even, and it has }\frac{|w|}2\text{ consecutive 0's}\}$$
So my main... |
Determine the type of $L=\{w:|w|\text{ is even, and it has }\frac{|w|}2\text{ consecutive 0's}\}$ |
|formal-languages|computability|context-free| |
The $|w|$ is even requirement can be checked by a finite state automaton, so that is not a real restriction. Comparing two numbers (the total length $|w|$ and the length of a consecutive sequence of $0$'s) is usually impossible for FSA.
Now to determine the type, following this intuition, you will have to show the ... |
null |
null |
Cross-validation is simple and easy to implement. Rather than inventing something new, which might be dubious, I recommend you use cross-validation. It works.
There are no formulas for the regularization constant, because it depends on the specific task you are trying to solve (i.e., it depends on the data). |
null |
In the book "Fundamentos de sistemas operativos" (Gunnar Wolf, Esteban Ruiz, Federico Bergero, Erwin Meza p.254) it says:
> Al cargar un programa el sistema operativo calcula cuánta memoria va a
> requerir a lo largo de su vida prevista. Esto incluye el espacio
> requerido para la asignación dinámica de memoria co... |
On load estimation of memory consumption of program, is it possible? |
|operating-systems|memory-management| |
null |
null |
We want to design a **[Deterministic Finite Automaton (DFA)][1]** that **accepts** Binary Representation of Integers which are divisible by 3.
> Now, by **accept**, in layman terms, we can say that when we are done with scanning string, we should be in one of the multiple possible Final States.
>
> More Formally... |
For two real numbers $a$ and $b$, either $a < b$, $a=b$, or $a>b$. This notation works analogously but orders functions by growth rates. For two functions of $n$, $f(n)$ and $g(n)$, either $f(n)$ grows slower than $g(n)$, $f(n)$ grows as fast as $g(n)$ or $f(n)$ grows faster than $g(n)$. So if $f$ and $g$ are their gr... |
If you're really asking about every program then of course not. Such proof would need to consider every possible outcome of every choice within the most complex program imaginable… which would make the proof more complex than the program, which would spin on its own axis until it ceased to matter.
If "for a program... |
I recently started learning context free grammar and was working with a couple of exercise problems and couldn't really figure out how would this exactly look like
I started with
S -> S1S2
S1-> aS1|epsilon
S2-> bS2| epsilon
But Im not sure how to create transitions for the reverse .... Can someone give me som... |
How would a context free grammar for a^i b^j a^j b^i where I and j >= 0 look like? |
|automata|context-free| |
I recently started learning context free grammar and was working with a couple of exercise problems and couldn't really figure out how would this exactly look like
I started with
S -> S1S2
S1-> aS1|epsilon
S2-> bS2| epsilon
But Im not sure how to create transitions for the reverse .... Can someone give ... |
I see this occasionally when solving Dynamic programming questions. I like to solve dp questions using recursion, then Memoize it based on the number of parameters I pass to the recursive function.
The question is, in my code below, even though I passed three parameters to my recursive function, the solution still wor... |
Why dont I need to memoize maxHeight in the problem below |
|dynamic-programming|c++| |
null |
I recently started learning context free grammar and was working with a couple of exercise problems and couldn't really figure out how would this exactly look like.
I started with:
$$\begin{align}S&\to S_1S_2\\
S_1&\to aS_1\mid\epsilon\\
S_2&\to bS_2\mid\epsilon\\
\end{align}$$
But I'm not sure how to creat... |
How would a context free grammar for $a^i b^j a^j b^i$ where $i,j >= 0$ look? |
Context free grammars are basically the combination of four things:
* ***Alternation***: Choose one of two or more alternative sub-grammars.
* ***Concatenation***: Make one sub-grammar follow another one.
* ***Repetition***: Let a sub-grammar repeat any number of times.
* ***Recursion***: Nest a sub-grammar inside ... |
I see this occasionally when solving Dynamic programming questions. I like to solve dp questions using recursion, then Memoize it based on the number of parameters I pass to the recursive function.
The question is, in my code below, even though I passed three parameters to my recursive function, the solution still wor... |
I see this occasionally when solving Dynamic programming questions. I like to solve dp questions using recursion, then Memoize it based on the number of parameters I pass to the recursive function.
The question is, in my code below, even though I passed three parameters to my recursive function, the solution still wor... |
Looking for an example of a LR(1) grammar that can not be turned into an LL(1) grammar that parsers the same language. |
LR(1) grammar that can not be transformed an LL(1) grammar |
|formal-grammars|parsers| |
Memoization does not affect correctness. It only affects the running time. An algorithm that is correct with memoization will also be correct without memoization, and vice versa. Memoization doesn't change what result the algorithm returns, it only changes how long it takes to get to that result. |
That statement is incorrect. With most OS's we use today, the OS does not try to calculate in advance how much memory the process will use. Indeed, when we use dynamic memory allocation (such as malloc) it is typically impossible to predict how much memory the process might use. |
In a distributed system, achieving perfect time synchronization among all nodes is often impossible. Lamport logical clocks are one way to deal with this problem.
I presume that by "use UTC to timestamp" you are assuming that you will use a timestamp. The problem is that machines' clocks usually aren't perfectly s... |
You are on the right track that, given a change amount $n$ and denominations $k_1, k_2, k_3$, to compute the minimum number of coins $f(n)$ for change amount $n$ you need to compute $f(n-k_1)$, $f(n-k_2)$ and $f(n-k_3)$.
The main objective is to derive a recursive equation for $f(n)$. Imagine you are given the mi... |
null |
I recently started learning context free grammars and was working on a couple of exercise problems and couldn't really figure out how would this exactly look like.
I started with:
$$\begin{align}S&\to S_1S_2\\
S_1&\to aS_1\mid\epsilon\\
S_2&\to bS_2\mid\epsilon\\
\end{align}$$
But I'm not sure how to create... |
Context free grammar for $a^i b^j a^j b^i$ |
> show that $L=\{a^*\}\cup\{b^ja^{n^2}|0<j,1\leq n \}$
>Holds the pumping lemma for context-free languages
|
show that $L=\{a^*\}\cup\{b^ja^{n^2}|0<j,1\leq n \} Holds the pumping lemma for context-free languages |
|automata|context-free|pumping-lemma| |
show that $L=\{a^*\}\cup\{b^ja^{n^2}|0<j,1\leq n \}$ Holds the pumping lemma for context-free languages |
null |
Contribute some boolean relations/ inequalities that can be used in competitive programming. |
A collection of boolean relations for competetive programming |
|xor| |
Contribute some equations/ inequalities and properties of bitwise AND, OR, NOT,and X-OR that can be used in competitive programming. |
Bitwise operator properties for competitive programming |
Here's what the operating system could do at best: It could examine your computer, and find out what is the maximum amount of memory that can be successfully allocated. For example, if you have so much RAM, so much space for swap space on your hard drive etc. the OS could figure out something like "if you try to alloca... |
What are some equations/ inequalities and properties of bitwise X-OR that can be used in competitive programming. |
Bitwise X-OR properties for competitive programming |
Thanks to rici and D.W. for pointing out a very practical example of a LR(1) grammar that can not be expressed as an LL(1) grammar.
They've provided the example language $\{a^ib^j\mid i\ge j\}$, which shows why "if then optional-else" is not in $LL(k)$ for any $k$.
"if then-optional else" has a non-ambiguous solu... |
Thanks to rici and D.W. for pointing out a very practical example of a LR(1) grammar that can not be expressed as an LL(1) grammar.
They've provided the example language $\{a^ib^j\mid i\ge j\}$, which shows why "if then optional-else" is not in $LL(k)$ for any $k$. The example language has at least as many $a$s than... |
*Exclusive or* is non-monotone, linear, symmetric, balanced, evasive. |
null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.