Questions tagged [proof]

A mathematical proof is any mathematical argument which demonstrates the truth of a mathematical statement. Informal proofs are typically rendered in natural language and are held true by consensus; formal proofs are typically rendered symbolically and can be checked mechanically. "Proofs" can be valid or invalid; only the former kind constitutes actual proof, whereas the latter kind usually refers to a flawed attempt at proof.

828 questions
5
votes
1 answer

Proving equivalence of programs

The ultimate in optimizing compilers would be one that searched among the space of programs for a program equivalent to the original but faster. This has been done in practice for very small basic blocks:…
rwallace
  • 31,405
  • 40
  • 123
  • 242
5
votes
1 answer

how to prove Theorem 3.5.4 in 《Types and Programming Languages》using Coq?

Update: with the help of Arthur Azevedo De Amorim, I finally manage it. The code is attached at the end of the question. I am reading the book 《Types and Programming Languages》, and I am trying to prove each theorem(lemma) in this book using coq.…
kainwen
  • 356
  • 1
  • 12
5
votes
2 answers

Why it is not possible to redefine (implement) foldr in terms of foldl

We have that foldl can be implemented in terms of foldr. This is explained in detail in A tutorial on the universality and expressiveness of fold. In the paper it is stated that: In contrast, it is not possible to redefine fold in terms of foldl ,…
Damian Nadales
  • 4,907
  • 1
  • 21
  • 34
5
votes
1 answer

Proof by counterexample in Coq

After proving tens of lemmas in propositional and predicate calculus (some more challenging than others but generally still provable on an intro-apply-destruct autopilot) I hit one starting w/ ~forall and was immediately snagged. Clearly, my…
jaam
  • 900
  • 4
  • 23
5
votes
2 answers

Explain why x == ~(~x + 1) + 1 (two's complement and back!)

As we all know usually negative numbers in memory represents as two's complement numbers like that from x to ~x + 1 and to get back we don't do the obvious thing like ~([~x + 1] - 1) but instead we do ~[~x + 1] + 1 can someone explain why does it…
Solar Dia
  • 53
  • 4
5
votes
1 answer

How to prove functions equal, knowing their bodies are equal?

How can we prove the following?: Lemma forfun: forall (A B : nat->nat), (forall x:nat, A x = B x) -> (fun x => A x) = (fun x => B x). Proof.
Necto
  • 2,594
  • 1
  • 20
  • 45
5
votes
2 answers

isabelle proving commutativity for add

Im trying to prove commutativity in Isabelle/HOL for a self-defined add function. I managed to prove associativity but I'm stuck on this. The definition of add: fun add :: "nat ⇒ nat ⇒ nat" where "add 0 n = n" | "add (Suc m) n = Suc(add m n)" The…
Eridanis
  • 410
  • 1
  • 6
  • 19
5
votes
1 answer

Can two Minimum Spanning Trees for the same graph have different edge weights?

A graph can have many different Minimum Spanning Trees (MSTs), but can different MSTs have different sets of edge weights? For example, if an MST uses edge weights {2,3,4,5}, must every other MST have edge weights {2,3,4,5}, or can some other MST…
Maggi Iggam
  • 682
  • 1
  • 8
  • 20
5
votes
3 answers

How can I use rules suggested by solve_direct? (by (rule …) doesn't always work)

Sometimes solve_direct (which I usually invoke via try) lists a number of library theorems and says “The current goal can be solved directly with: …”. Let be one search result of solve_direct, then in most cases I…
Christoph Lange
  • 595
  • 2
  • 13
5
votes
2 answers

In Coq, which tactic to change the goal from `S x = S y` to `x = y`

I want to change the goal from S x = S y to x = y. It's like inversion, but for the goal instead of a hypothesis. Such a tactic seems legit, because when we have x = y, we can simply use rewrite and reflexivity to prove the goal. Currently I always…
Tianyi Cui
  • 3,933
  • 3
  • 21
  • 18
4
votes
2 answers

(log n)^k = O(n)? For k greater or equal to 1

(log n)^k = O(n)? For k greater or equal to 1. My professor presented us with this statement in class, however I am not sure what it means for a function to a have a time complexity of O(n). Even stuff like n^2 = O(n^2), how can a function f(x) have…
user1084113
  • 932
  • 3
  • 15
  • 31
4
votes
1 answer

Lower bounds on comparison sorts for a small fraction of inputs?

Can someone please walk me through mathematical part of the solution of the following problem. Show that there is no comparison sort whose running time is linear for at least half of the n! inputs of length n. What about a fraction of 1/n of the…
Zombie
  • 493
  • 1
  • 8
  • 11
4
votes
3 answers

What's wrong with this inductive proof that mergesort is O(n)?

Comparison based sorting is big omega of nlog(n), so we know that mergesort can't be O(n). Nevertheless, I can't find the problem with the following proof: Proposition P(n): For a list of length n, mergesort takes O(n) time. P(0): merge sort on the…
rjkaplan
  • 3,138
  • 5
  • 27
  • 33
4
votes
2 answers

How does prolog resolution use proof by contradiction?

I'm learning prolog, and I'm confused by the claim that prolog uses proof by contradiction: The resolution proof process makes use of a technique that is known as reduction to the absurd: suppose that the formula to be proved is false, and show…
Joseph Garvin
  • 20,727
  • 18
  • 94
  • 165
4
votes
3 answers

Implementation of binary tree

The following text is snippet from algorithms book. We could draw the binary trees using rectangular boxes that are customary for linked lists, but trees are generally drawn as circles connected by lines because they are actually graphs. We…
venkysmarty
  • 11,099
  • 25
  • 101
  • 184