57
votes
Proof that dead code cannot be detected by compilers
It all comes from undecidability of the halting problem. Suppose we have a "perfect" dead code function, some Turing Machine M, and some input string x, and a procedure that looks something like this:
...
42
votes
Accepted
Why are mathematical proofs so hard?
I feel like i am memorizing the proofs rather than learn how to prove
You can't learn "how to prove". "Proving" is not a mechanical process, but rather a creative one where you ...
41
votes
How to prove greedy algorithm is correct
Ultimately, you'll need a mathematical proof of correctness. I'll get to some proof techniques for that below, but first, before diving into that, let me save you some time: before you look for a ...

D.W.♦
- 156k
31
votes
Accepted
Proving Equivalence of Two Regular Expressions
One way to prove that two regular expressions $r_1,r_2$ generate the same language is to show both inclusions:
Show that if $w$ is generated by $r_1$ then it is generated by $r_2$.
Show that if $w$ ...
19
votes
Does contradiction definitively prove nonexistence
A proof is a proof, even if the system you work in is inconsistent.
So if you prove that the existence of a decider leads to contradiction, you have proved that such a decider does not exist. If in ...
18
votes
False proofs that look correct
One of my favourites is the "brothers paradox":
https://en.wikipedia.org/wiki/Boy_or_Girl_paradox
I tell it as I learned it*, as follows:
in a village, each family has two children, elder ...
16
votes
Accepted
Prove that A** = A*, where A is a language over Σ*
Since $L \subseteq L^*$ for all $L$, we have $\mathcal{A}^* \subseteq \mathcal{A}^{**}$. In the other direction, suppose that $w \in \mathcal{A}^{**}$. Then there exists an integer $n \geq 0$ and ...
16
votes
False proofs that look correct
Merge-sort can be done in linear time!
Indeed, the time complexity to sort a list or array of length $n$ verifies$^{(1)}$:
$$T(n) = T\left(\left\lfloor\frac{n}2\right\rfloor\right) + T\left(\left\...
14
votes
Proof that dead code cannot be detected by compilers
This is a twist on jmite's answer that circumvents the potential confusion about non-termination. I'll give a program that always halts itself, may have dead code but we can not (always) ...
14
votes
How to prove greedy algorithm is correct
I will use the following simple sorting algorithm as an example:
...
13
votes
Show that there are infinitely more problems than we will ever be able to compute
Reformulating in a more mathematically precise way, what the lecturer is trying to say is this: Any algorithm can be (uniquely) encoded as a finite string of bits, and any finite string of bits (...
13
votes
Accepted
Is every unambiguous grammar regular?
The following grammar is unambiguous yet generates a non-regular language:
$$ S \to aSb \mid \epsilon $$
12
votes
Accepted
Naive argument that P ≠ NP
The error in your argument is the claim
Nothing is known a priori about the function $f$, (...) so it is necessary to plug in all $2^n$ values.
, which is simply false. I will demonstrate why it ...
12
votes
Accepted
Is it possible to simulate a fair coin with a finite number of tossing of a biased one?
No, it's not possible. Suppose the bias of the coin is $1/3$, and suppose you could guarantee termination. Then there would be some $n$ such that this always terminates after $n$ coin flips. Let $S$...

D.W.♦
- 156k
12
votes
Why are mathematical proofs so hard?
As other authors have mentioned, partly because proofs are inherently hard, but also partly because of the cold fact that proofs are not written for the purpose of teaching, even in most textbooks. ...
11
votes
Accepted
Are there any specific problems known to be undecidable for reasons other than diagonalization, self-reference, or reducibility?
Yes, there are such proofs. They are based on the Low Basis Theorem.
See this answer to Are there any proofs the undecidability of the halting problem that does not depend on self-referencing or ...
11
votes
Accepted
Show that there are infinitely more problems than we will ever be able to compute
If I understand you correctly, your question is —
why a solution can be encoded by a natural number and a problem with a real number.
(I assume that you understand the next phase of the proof ...
11
votes
Why are mathematical proofs so hard?
I can certainly recommend the book of G. Polya's, How to Solve It. It is a standard classic, not to be missed. There is a newer book How to Read and Do Proofs: An Introduction to Mathematical Thought ...
10
votes
How to prove that a language is not regular?
Following the answer here, I will describe a method of proving non-regularity based on Kolmogorv complexity.
This approach is discussed in "A New Approach to Formal Language Theory by
Kolmogorov ...
10
votes
Accepted
Proof that TAUT is coNP-complete (or that a problem is coNP-complete if its complement is NP-complete)
I take it that we call $TAUT$ the problem of given a DNF formula, decide if it is a tautology (if you do not want to restrict to DNF, this will still work as this only makes the problem more general).
...
9
votes
Solving or approximating recurrence relations for sequences of numbers
After checking this post again, I'm surprised this isn't on here yet.
Domain Transformation / Change of Variables
When dealing with recurrences it's sometimes useful to be able to change your ...
9
votes
Solving or approximating recurrence relations for sequences of numbers
There may be times when you come across a strange recurrence like this:
$$T(n) = \begin{cases}
c & n < 7\\
2T\left(\frac{n}{5}\right) + 4T\left(\frac{n}{7}\right) + cn & n\geq 7
\end{...
9
votes
Prove that if f ∉ ω(g) →f∈O(g)
The claim is not true (unless you add some "nice" conditions on the functions).
Take, for example, the functions $g(n)=n$, and consider the following function $f$: on the even numbers, we'll take $f(...
9
votes
Accepted
Proof of non-regularity, based on the Kolmogorov complexity
To my knowledge, this is not one of the "classical" approaches used to characterize regular languages.
This approach is discussed in "A New Approach to Formal Language Theory by
Kolmogorov Complexity"...
9
votes
Accepted
Why proving programs correctness doesn't have the same importance as algorithms analysis or the theory of computation in practice?
On the contrary, it's certainly important practice, and is a huge area of research!
Perhaps a better question might be, "why is proving programs correct not common in practice, or not a main feature ...
9
votes
False proofs that look correct
I have often seen among undergraduates that they believe that the heaps are constructed in $\Theta(n \log n)$ time.
The standard algorithm for that is to insert an element to a heap one after another. ...
9
votes
False proofs that look correct
This one is regarding $\mathsf{FPT}$ time algorithm.
Suppose an algorithm has time complexity of: $O((\log n)^k \cdot n^{O(1)})$.
Is it an $\mathsf{FPT}$ time algorithm in parameter $k$?
Well ...
8
votes
How to prove that a language is not regular?
In the case of unary languages (languages over an alphabet of size 1), there is a simple criterion. Let us fix an alphabet $\{ \sigma \}$, and for $A \subseteq \mathbb{N}$, define
$$
L(A) = \{ \sigma^...
8
votes
How to prove a language is regular?
Another method, not covered by the answers above, is finite automaton transformation. As a simple example, let us show that the regular languages are closed under the shuffle operation, defined as ...
8
votes
Is a single string enough to prove regular expressions inequivalent?
Does it suffice to show that a single string is not present in the language and hence its different from the rest?
Yes. It's actually a very neat proof.
Formally speaking, you have found $w \in \{a,...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
proof-techniques × 679algorithms × 85
complexity-theory × 76
formal-languages × 73
computability × 47
regular-languages × 47
induction × 47
correctness-proof × 46
turing-machines × 45
graphs × 43
logic × 39
reductions × 38
undecidability × 38
context-free × 37
algorithm-analysis × 35
finite-automata × 33
np-complete × 31
asymptotics × 31
recurrence-relation × 28
automata × 27
pumping-lemma × 23
formal-grammars × 19
recursion × 15
time-complexity × 14
np × 14