Exercise · Volume 1 · 1.2.1-14
Exercise 1.2.1-14
not stated yet in Lean solution written
| Rating | 50 |
|---|---|
| Kind | K9, research: an open problem, so no proof is claimed from the written solution |
| Section | Section 1.2.1 of Volume 1. Companion chapter: Mathematical induction |
The task
Floyd's problem: build a program that takes a program with some assertions and fills in the missing assertions to complete a proof that the program is correct.
State of the problem
The exercise is a research project, not a question with one answer. It asks for a program, so a solution would be judged by what it can prove. The target example is Algorithm E, from the assertions A1, A4 and A6 of the text. The assertion A6 is the one that needs an idea, and the other assertions follow from the three given ones. The problem is open in general: no program can always find the assertions that a proof needs. The reason is that the problem includes the halting problem and the theorem of Rice, so a complete method cannot exist. Only partial methods can exist, and the goal is a method that works for a good class of programs.
What is known
Floyd (1967) introduced the idea of assertions on the arrows of a flow chart. Hoare (1969) wrote it as a logic of triples. Dijkstra (1975) gave the weakest precondition, which turns the backward filling of assertions into a computation: for a program without loops the assertions follow from the final one by substitution. The loops are the difficult case, and there the program must find an invariant. Known partial methods find invariants of fixed forms: linear equalities between variables (Karr, 1976), and invariants of other shapes by abstract interpretation (Cousot and Cousot, 1977). Systems that combine these methods with an automatic prover of theorems have verified many programs, with some help from the user. The papers of Floyd and of King that the exercise names show the first attempts, in which a symbolic execution of the paths between assertions gives the conditions that a prover must show.
For Algorithm E the given assertion A6 is the loop invariant: two linear relations among with the inputs and as coefficients, , and . With A6 given, the missing assertions A2, A3 and A5 follow by symbolic execution of the steps around the loop. A harder test gives only A1 and A4, so that the program must find the invariant itself. Methods that search for polynomial equalities with unknown coefficients can find the two linear relations. The gcd condition is not of this shape, and a method needs a rule about the gcd for it.
The exact wording is in your copy of the book.
Remarks
The C1 chapter of Section 1.2.1 has the method of assertions in the form of a theorem about a flow chart. Exercise 1.2.1-13 adds the clock that gives a proof of termination, which is the other half of a proof of an algorithm.
This solution is checked, and a person has not reviewed it yet. The source.
In Lean
not stated yet The exercise is not stated in Lean yet. The exercise is a research problem, so the project claims no proof.
The status is computed from the Lean build. The node of the map.
Something is wrong? Report it.