Why can't programs be proven?

前端 未结 30 2218
礼貌的吻别
礼貌的吻别 2020-12-22 17:06

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

相关标签:
30条回答
  • 2020-12-22 17:52

    If you are looking for confidence, the alternative to proving programs is testing them. This is easier to understand and can be automated. It also allows for the class of programs for which proofs are mathematically not possible, as described above.

    Above all, no proof is a substitute for passing acceptance tests:*

    • Just because a program really does do what it says it does, doesn't mean it does what the user wants it to do.

      • Unless you can prove that what it says it does is what the user says they want.

        • Which you then have to prove is what they really want, because, being a user, they almost certainly don't know what they want. etc. Reductio ad absurdum.

    *not to mention unit, coverage, functional, integration and all the other kinds of tests.

    Hope this helps you on your path.

    0 讨论(0)
  • 2020-12-22 17:53

    Something that has not been mentioned here is the B - Method which is a formal method based system. It was used to develop the safety system of the Paris underground. There are tools available to support B and Event B development, notably Rodin.

    0 讨论(0)
  • 2020-12-22 17:53

    Read up on the halting problem (which is about the difficulty of proving something as simple as whether a program completes or not). Fundamentally the problem is related to Gödel's incompleteness theorem.

    0 讨论(0)
  • 2020-12-22 17:54

    Programs absolutely can be proven to be correct. Lousy programs are hard to prove. To do it even reasonably well, you have to evolve the program and proof hand-in-hand.

    You can't automate the proof because of the halting problem. You can, however, manually prove the post-conditions and preconditions of any arbitrary statement, or sequence of statements.

    You must read Dijsktra's A Discipline of Programming.

    Then, you must read Gries' The Science of Programming.

    Then you'll know how to prove programs correct.

    0 讨论(0)
  • 2020-12-22 17:55

    Not only can you prove programs, you can let your computer construct programs from proofs. See Coq. So you don't even have to worry about the possibility of having made a mistake in your implementation.

    0 讨论(0)
  • 2020-12-22 17:55

    Your statement is wide so it's catching lots of fish.

    The bottom line is: some programs can definitely be proven correct. All programs can not be proven correct.

    Here's a trivial example which, mind you, is exactly the same kind of proof that destroyed set theory back in the day: make a program which can determine whether itself is correct, and if it finds that it is correct, give an incorrect answer.

    This is Gödel's theorem, plain and simple.

    But this is not so problematic, since we can prove many programs.

    0 讨论(0)
提交回复
热议问题