6 ms·
I had a run-in with this issue once. Many years ago, when working on a program verification system, I had to show that two theorem provers (Boyer-Moore and Nel
by Animats 9y ago
I had a run-in with this issue once. Many years ago, when working on a program verification system, I had to show that two theorem provers (Boyer-Moore and Nelson-Oppen) were working on compatible theories. If that was botched, the system
could prove false statements. So I undertook to prove, in Boyer-Moore theory, the "axioms" of arrays used in the Nelson-Oppen prover. McCarthy defined four classic axioms for arrays, and here are the first two.
p=r ⇒ read(write(a, p, v), r) = v
¬(p=r) ⇒ read(write(a, p, v), r) = read(a, r)
This just says that if you store v at a[p], and then read it back, you get what you put there, and you don't change any other elements.
So I set this up in Boyer-Moore notation.
(PROVE-LEMMA SELECT-OF-STORE-1 (REWRITE)
(IMPLIES (AND (arrayp A) (NUMBERP I))
(EQUAL (selecta (storea A I V) I) V)))
(PROVE-LEMMA SELECT-OF-STORE-2 (REWRITE)
(IMPLIES (AND (arrayp A) (NUMBERP I) (NUMBERP J) (NOT (EQUAL I J)))
(EQUAL (selecta (storea A I V) J) (selecta A J))))
But Boyer-Moore theory is constructive; everything must have a definition that can be evaluated as a function. So I had to define arrays and the "selecta" and "storea" functions so that this would work. I could do this by defining an array as a list of (subscript, value) tuples.
(ADD-SHELL UNDEFINED-OBJECT UNDEFINED UNDEFINEDP ())
(ADD-SHELL array-shell
empty-array
array-recognizer
((array-elt-value (NONE-OF) UNDEFINED)
(array-elt-subscript (ONE-OF NUMBERP) ZERO)
(array-prev (ONE-OF array-recognizer) empty-array)))
This is simply a structure definition for a list. An array-shell has an array-elt-value, an array-elt-subscript, and
array-prev, which is the rest of the elements. "array-shell" is the constructor, "empty-array" is essentially "nil" for
this type, and "array-recognizer" is a predicate which is true for objects of type array-shell.
For array equality to work, the list of tuples had to be ordered by subscript, so that two arrays with the same values would always have the same representation. So selecta and storea are complicated. selecta is a recursive lookup in a list:
(DEFN selecta (A I)
(IF (EQUAL (array-elt-subscript A) I)
(array-elt-value A)
(IF (EQUAL (array-prev A) (empty-array))
(UNDEFINED)
(selecta (array-prev A) I))))
Store into array is ugly, because it's an update of an ordered list.
(DEFN storea (A I V)
(IF (NOT (arrayp A))
(empty-array)
(IF (NOT (NUMBERP I))
A
(IF (EQUAL A (empty-array))
(IF (EQUAL V (UNDEFINED))
(empty-array)
(array-shell V I (empty-array)))
(IF (EQUAL (array-elt-subscript A) I)
(IF (EQUAL V (UNDEFINED))
(array-prev A)
(array-shell V I (array-prev A)))
(IF (LESSP (array-elt-subscript A) I)
(IF (EQUAL V (UNDEFINED))
A
(array-shell V I A))
(array-shell
(array-elt-value A)
(array-elt-subscript A)
(storea (array-prev A) I V))))))))
This recursive function is complicated enough that it needs a lemma to help with proof of termination.
(PROVE-LEMMA storea-is-sound (REWRITE)
(implies (and (arrayp a)
(not (equal a (empty-array))))
(lessp (count (array-prev a)) (count a))))
This says that the array-prev list component of a is always shorter than a. The Boyer-Moore prover must prove
termination for all defined functions, which it does by examining any recursive call and proving that there is
a measure defined on the arguments which is a smaller nonnegative integer. For the easy cases, the prover can do
this automatically, but sometimes you have to define a lemma to help it. The lemma, of course, also has to be proved.
So, given all that, the Boyer-Moore theorem prover could be turned loose to grind out proofs of the rules for arrays.
It took about 45 minutes of grinding in 1982 on a 1 MIPS VAX 11/780.
You can rerun it now. Here's the prover, which requires clisp.[1]. Here's the entire set of definitions and theorems we used for program verification.[2]. Read the instructions at [1], and get the system up to where it's done "boot-strap". Then load the file at [2]. Long, detailed, human-readable explanations of the proof steps are displayed. The entire proof run for all those basic theorems takes about a second, and that's probably mostly scrolling.
So, having rigorously proved the "axioms" for arrays from first principles, I submitted a paper to JACM. The reviewer comments I got back were mainly about the uglyness of the approach. All that case analysis! One comment was that the reviewer was upset about having a proof that ugly at the foundations of computer science. The paper was rejected.
The reason it's ugly is that it doesn't get to use set theory. Informally, a set is a collection whose order does not matter. "Order does not matter" is not a meaningful concept in strict Boyer-Moore theory. If order matters, there are many cases to prove, stemming from all those IF statements in the definitions.
A generation later, fewer mathematicians would be bothered by this form of "uglyness". But back then, machine proofs were
so rare that this was considered awful. Also, now that computers can do this in a second, complaining that it's too
complicated seems whiny.
[1] https://github.com/John-Nagle/nqthm https://github.com/John-Nagle/nqthm
[2] https://github.com/John-Nagle/pasv/blob/master/src/work/temporaryrulebase.lisp https://github.com/John-Nagle/pasv/blob/master/src/work/temp...
- mrout 9y ago>A generation later, fewer mathematicians would be bothered by this form of "uglyness". I totally disagree. Mathematicians haven't changed at all. Ugly proofs are still considered.. well.. ugly. Machine proofs are still considered at least inferior to 'proper' proofs at the best, and downright suspect at the worst.
- Animats 9y agoJust to look at, here are the actual machine proofs from running our verifier theory through the Boyer-Moore prover.[1] AI, the early years, at work. Here's one proof, for commutativity of TIMES for the natural numbers. (PROVE-LEMMA COMMUTATIVITY-OF-TIMES (REWRITE) (EQUAL (TIMES X Y) (TIMES Y X))) Give the conjecture the name *1. We will appeal to induction. Two inductions are suggested by terms in the conjecture, both of which are flawed. We limit our consideration to the two suggested by the largest number of nonprimitive recursive functions in the conjecture. Since both of these are equally likely, we will choose arbitrarily. We will induct according to the following scheme: (AND (IMPLIES (ZEROP X) (p X Y)) (IMPLIES (AND (NOT (ZEROP X)) (p (SUB1 X) Y)) (p X Y))). Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform us that the measure (COUNT X) decreases according to the well-founded relation LESSP in each induction step of the scheme. The above induction scheme produces the following two new conjectures: Case 2. (IMPLIES (ZEROP X) (EQUAL (TIMES X Y) (TIMES Y X))). This simplifies, applying TIMES-ZERO and TIMES-NON-NUMBERP, and opening up the functions ZEROP, EQUAL, and TIMES, to: T. Case 1. (IMPLIES (AND (NOT (ZEROP X)) (EQUAL (TIMES (SUB1 X) Y) (TIMES Y (SUB1 X)))) (EQUAL (TIMES X Y) (TIMES Y X))), which simplifies, unfolding the functions ZEROP and TIMES, to: (IMPLIES (AND (NOT (EQUAL X 0)) (NUMBERP X) (EQUAL (TIMES (SUB1 X) Y) (TIMES Y (SUB1 X)))) (EQUAL (PLUS Y (TIMES Y (SUB1 X))) (TIMES Y X))). Appealing to the lemma SUB1-ELIM, we now replace X by (ADD1 Z) to eliminate (SUB1 X). We employ the type restriction lemma noted when SUB1 was introduced to constrain the new variable. We must thus prove: (IMPLIES (AND (NUMBERP Z) (NOT (EQUAL (ADD1 Z) 0)) (EQUAL (TIMES Z Y) (TIMES Y Z))) (EQUAL (PLUS Y (TIMES Y Z)) (TIMES Y (ADD1 Z)))). However this further simplifies, applying the lemma TIMES-ADD1, to: T. That finishes the proof of *1. Q.E.D. Boyer and Moore were trying really hard to make the results understandable to traditional mathematicians. [1] https://github.com/John-Nagle/pasv/blob/master/src/work/temporaryrulebaseprooflog.txt https://github.com/John-Nagle/pasv/blob/master/src/work/temp...