proof

Is there a way to prove a program has no bug?

巧了我就是萌 提交于 2019-12-05 08:51:39
I was thinking about the fact that we can prove a program has bugs. We can test it to assess that it is more or less bug resistant. But is there a way (even theoretically) to prove that a program has no bug ? For simple programs, such as a "Hello World", I guess we should be able to do it. But what about larger programs ? There are nowadays many different formalisms that can be used to prove programs correct (e.g., formalizations in proof assistants, dependently typed programming languages, separation logic, ...). As noted by others, there is no automatic way to prove any given program correct

Proving Big-O Sum Rule?

◇◆丶佛笑我妖孽 提交于 2019-12-05 02:06:10
问题 I am unsure how to formally prove the Big O Rule of Sums, i.e.: f1(n) + f2(n) is O(max(g1(n)),g2(n)) So far, I have supposed the following in my effort: Let there be two constants c1 and c2 such that c2 > c1 . By Big O definition: f1(n) <= c1g1(n) and f2(n) <= c2g2(n) How should I proceed? Is it reasonable to introduce numerical substitutions for the variables at this step to prove the relationship? Not knowing g or f , that is the only way I can think to approach. 回答1: Let gmax = max(g1, g2)

Proving correctness of multithread algorithms

↘锁芯ラ 提交于 2019-12-05 00:44:39
Multithread algorithms are notably hard to design/debug/prove. Dekker's algorithm is a prime example of how hard it can be to design a correct synchronized algorithm. Tanenbaum's Modern operating systems is filled with examples in its IPC section. Does anyone have a good reference (books, articles) for this? Thanks! It is impossible to prove anything without building upon guarentees, so the first thing you want to do is to get familiar with the memory model of your target platform; Java and x86 both have solid and standardized memory models - I'm not so sure about CLR, but if all else fails,

Functional proofs (Haskell)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 22:29:49
I failed at reading RWH; and not one to quit, I ordered Haskell: The Craft of Functional Programming . Now I'm curious about these functional proofs on page 146. Specifically I'm trying to prove 8.5.1 sum (reverse xs) = sum xs . I can do some of the induction proof but then I get stuck.. HYP: sum ( reverse xs ) = sum xs BASE: sum ( reverse [] ) = sum [] Left = sum ( [] ) (reverse.1) = 0 (sum.1) Right = 0 (sum.1) INDUCTION: sum ( reverse (x:xs) ) = sum (x:xs) Left = sum ( reverse xs ++ [x] ) (reverse.2) Right = sum (x:xs) = x + sum xs (sum.2) So now I'm just trying ot prove that Left sum (

Prove the efficiency of repeated calls to successor() in binary trees?

落爺英雄遲暮 提交于 2019-12-04 21:38:55
问题 I need a hint for this exercise from the CLRS Algorithms book: Prove that no matter what node we start at in a height-h binary search tree, k successive calls to Tree-Successor take O(k+h) time. 回答1: Let x be the starting node and z be the ending node after k successive calls to TREE-SUCCESSOR. Let p be the simple path between x and z inclusive. Let y be the common ancestor of x and z that p visits. The length of p is at most 2h , which is O(h) . Let output be the elements that their values

I can't prove (n - 0) = n with Idris

大城市里の小女人 提交于 2019-12-04 16:33:11
问题 I am trying to prove, what to my mind is a reasonable theorem: theorem1 : (n : Nat) -> (m : Nat) -> (n + (m - n)) = m Proof by induction gets to the point where me need to prove this: lemma1 : (n : Nat) -> (n - 0) = n This is what happens when I try to prove it (the lemma, for simplicity sake) using the interactive prover: ---------- Goal: ---------- {hole0} : (n : Nat) -> minus n 0 = n > intros ---------- Other goals: ---------- {hole0} ---------- Assumptions: ---------- n : Nat ----------

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

核能气质少年 提交于 2019-12-04 12:37:40
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 use a different collection of weights? What gave me the idea is property that a graph has no unique MST only if its edge weights are different. The sets must have the same weight. Here's a simple proof: suppose they don't. Let's let T1 and T2 be MSTs for some graph G with different multisets of edge weights. Sort those edges into ascending order of

Why can't programs be proven?

我的梦境 提交于 2019-12-03 18:19:52
问题 Why can't a computer program be proven just as a mathematical statement can? A mathematical proof is built up on other proofs, which are built up from yet more proofs and on down to axioms - those truths truths we hold as self evident. Computer programs don't seem to have such a structure. If you write a computer program, how is it that you can take previous proven works and use them to show the truth of your program? You can't since none exist. Further, what are the axioms of programming?

How to determine the height of a recursion tree from a recurrence relation?

删除回忆录丶 提交于 2019-12-03 17:33:16
问题 How does one go about determining the height of a recursion tree, built when dealing with recurrence run-times? How does it differ from determining the height of a regular tree? alt text http://homepages.ius.edu/rwisman/C455/html/notes/Chapter4/ch4-9.gif edit: sorry, i meant to add how to get the height of the recursion tree from the recurrence relation . 回答1: If recurrence is in the form of T(n) = aT(n/b) + f(n) then the depth of the tree is log base b of n. For example, 2T(n/2) + n

Proving Big-O Sum Rule?

别来无恙 提交于 2019-12-03 16:17:42
I am unsure how to formally prove the Big O Rule of Sums, i.e.: f1(n) + f2(n) is O(max(g1(n)),g2(n)) So far, I have supposed the following in my effort: Let there be two constants c1 and c2 such that c2 > c1 . By Big O definition: f1(n) <= c1g1(n) and f2(n) <= c2g2(n) How should I proceed? Is it reasonable to introduce numerical substitutions for the variables at this step to prove the relationship? Not knowing g or f , that is the only way I can think to approach. Let gmax = max(g1, g2), and gmin = min(g1, g2). gmin is O(gmax). Now, using the definition: gmin(n) <= c*gmax(n) for n > some k