3
; Solution to Exercise 6.6.
5
; This solution is just barely simple enough that we do not create lemma books
8
(include-book "partition-defuns")
10
; If one submits mesh-make-partition or thinks first about how the proof might
11
; go, one is led quickly to the decision to prove an appropriate fact about the
12
; mesh of (make-partition-rec a delta n), namely, mesh-make-partition-rec
13
; below. When that theorem is submitted to ACL2, the following term is printed
14
; in a goal that does not simplify further:
17
(CAR (MAKE-PARTITION-REC (+ A DELTA)
21
; But the first element of the result returned by make-partition-rec is clearly
22
; its first argument, a fact brought to the prover's attention with the first
29
(defthm car-make-partition-rec
30
(equal (car (make-partition-rec a delta n))
33
(defthm mesh-make-partition-rec
34
(implies (and (rationalp delta)
38
(equal (mesh (make-partition-rec a delta n))
40
:hints (("Goal" :expand ((make-partition-rec a delta 1))))))
42
; We need to disable the nonrecursive function symbol mesh in order for the
43
; rewrite rule mesh-make-partition-rec to apply when we are trying to prove
44
; mesh-make-partition.
45
(in-theory (disable mesh))
47
; The theorem mesh-make-partition now goes through automatically if we include
48
; an appropriate arithmetic book, e.g.,
49
; (include-book "/projects/acl2/v2-5/books/arithmetic/top"). However, below we
50
; show how one can get the theorem proved without such help.
52
; An attempt to prove mesh-make-partition causes an induction to be tried,
53
; which is perhaps surprising given the rewrite rule mesh-make-partition-rec,
54
; and is followed by failure to prove the thoerem. Why is that? The problem
55
; is that the prover cannot show that the particular delta fed to
56
; make-partition-rec by make-partition satisfies the nonnegativity hypothesis
57
; of rule mesh-make-partition-rec. If it is not clear that this is indeed the
58
; issue, then see file mesh-make-partition_info.txt for an annotated transcript
59
; of a proof-checker session that leads us to this fact.
61
; Lemma hack2 below states that the delta in question is indeed nonnegative.
62
; We have to work a bit in order to prove hack2. It seems clear if the
63
; distributivity law is applied in reverse, so our approach is to obtain hack2
64
; from a lemma hack1 that is the result of applying factoring to hack2 (and
65
; then simplifying and generalizing a bit). An attempt to prove hack1, in
66
; turn, leads the prover to get stuck attempting to prove
67
; (<= 0 (* X (+ (- A) B)))
68
; under relevant hypotheses, which leads us to prove the lemma
69
; product-nonnegative below.
76
(defthm product-nonnegative
77
(implies (and (rationalp x) (rationalp y))
78
;; If we use equal instead of iff, ACL2's linear arithmetic
79
;; doesn't happen to work.
80
(iff (< (* x y) 0);; (not (<= 0 (* x y)))
81
(or (and (< 0 x) (< y 0))
82
(and (< x 0) (< 0 y)))))))
86
(implies (and (rationalp x) (rationalp a) (rationalp b)
90
:hints (("Goal" :in-theory (disable distributivity)))
94
(implies (and (rationalp n)
99
(<= 0 (+ (* b (/ n)) (* (/ n) (- a)))))
100
:hints (("Goal" :use ((:instance hack1 (x (/ n)))))))))
102
(defthm mesh-make-partition
103
(implies (and (rationalp a)
108
(equal (mesh (make-partition a b n))