Skip to content

Commit 6b7931d

Browse files
committed
Fix proofs of soundness
1 parent 6dc1508 commit 6b7931d

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/core/prove-rules.rkt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292

9393
[`(< (* ,a ,a) 0) '(FALSE)]
9494
[`(< (sqrt ,a) 0) '(FALSE)]
95+
[`(< (fabs ,a) 0) '(FALSE)]
9596
[`(,(or '< '==) (cosh ,a) ,(? (conjoin number? (curryr < 1)))) '(FALSE)]
9697
[`(,(or '< '==) (exp ,a) ,(? (conjoin number? (curryr <= 0)))) '(FALSE)]
9798
[`(,(or '< '==) (* ,a ,a) ,(? (conjoin number? (curryr < 0)))) '(FALSE)]
@@ -159,29 +160,32 @@
159160
xs
160161
(simplify-conditions simple1)))
161162

163+
;; The prover must prove: rhs-bad => lhs-bad
164+
;; IOW we can weaken the RHS or strengthen the LHS
165+
162166
(define soundness-proofs
163167
'((pow-plus (implies (< b -1) (< b 0)))
164168
(pow-sqr (implies (even-denominator? (* 2 b)) (even-denominator? b)))
165169
(hang-0p-tan (implies (== (cos (/ a 2)) 0) (== (cos a) -1)))
166-
(hang-0p-tan-rev (implies (== (cos (/ a 2)) 0) (== (cos a) -1)))
167-
(hang-0m-tan (implies (== (cos (/ a 2)) 0) (== (cos a) -1)))
168-
(hang-0m-tan-rev (implies (== (cos (/ a 2)) 0) (== (cos a) -1)))
170+
(hang-0p-tan-rev (implies (== (cos a) -1) (== (cos (/ a 2)) 0)))
171+
(hang-0m-tan (implies (== (cos (/ (neg a) 2)) 0) (== (cos a) -1)))
172+
(hang-0m-tan-rev (implies (== (cos a) -1) (== (cos (/ (neg a) 2)) 0)))
169173
(tanh-sum (implies (== (* (tanh x) (tanh y)) -1) (FALSE)))
170174
(tanh-def-a (implies (== (+ (exp x) (exp (neg x))) 0) (FALSE)))
171-
(acosh-def (implies (< x 1) (or (< x -1) (== x -1) (< (fabs x) 1))))
175+
(acosh-def (implies (< x -1) (< x 1)) (implies (== x -1) (< x 1)) (implies (< (fabs x) 1) (< x 1)))
172176
(acosh-def-rev (implies (< x 1) (or (< x -1) (== x -1) (< (fabs x) 1))))
173177
(sqrt-undiv (implies (< (/ x y) 0) (or (< x 0) (< y 0))))
174178
(sqrt-unprod (implies (< (* x y) 0) (or (< x 0) (< y 0))))
179+
(sqrt-pow2 (implies (and (< x 0) _) (< x 0)))
175180
(tan-sum-rev (implies (== (cos (+ x y)) 0) (== (* (tan x) (tan y)) 1)))
176181
(sum-log (implies (< (* x y) 0) (or (< x 0) (< y 0))))
177182
(diff-log (implies (< (/ x y) 0) (or (< x 0) (< y 0))))
178183
(exp-to-pow (implies (and a b) a))
179-
(sinh-acosh (implies (< (fabs x) 1) (< x 1)))
180184
(acosh-2-rev (implies (< (fabs x) 1) (< x 1)))
181185
(tanh-acosh (implies (< (fabs x) 1) (< x 1)) (implies (== x 0) (< x 1)))
186+
(sinh-acosh (implies (< (fabs x) 1) (< x 1)))
182187
(hang-p0-tan (implies (== (cos (/ a 2)) 0) (== (sin a) 0)))
183188
(hang-m0-tan (implies (== (cos (/ a 2)) 0) (== (sin a) 0)))
184-
(sqrt-pow2 (implies (and a b) a))
185189
(pow-div (implies (< (- b c) 0) (or (< b 0) (> c 0)))
186190
(implies (even-denominator? (- b c)) (or (even-denominator? b) (even-denominator? c))))
187191
(pow-prod-up (implies (< (+ b c) 0) (or (< b 0) (< c 0)))
@@ -196,7 +200,7 @@
196200
(simplify-conditions (map (curryr rewrite-all a b) terms))))
197201

198202
(define (rewrite-unsound? lhs rhs [proof '()])
199-
(define lhs-bad (execute-proof proof (undefined-conditions lhs)))
203+
(define lhs-bad (simplify-conditions (undefined-conditions lhs)))
200204
(define rhs-bad (execute-proof proof (undefined-conditions rhs)))
201205
(define extra (set-remove (set-subtract rhs-bad lhs-bad) '(FALSE)))
202206
(if (empty? extra)

src/core/rules.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@
373373
(define-rules exponents
374374
[log-prod (log (* a b)) (+ (log (fabs a)) (log (fabs b)))]
375375
[log-div (log (/ a b)) (- (log (fabs a)) (log (fabs b)))]
376-
[log-pow (log (pow a b)) (* b (log (fabs a)))])
376+
[log-pow (log (pow a b)) (* b (log (fabs a))) #:unsound]) ; unsound @ a == b == 0
377377

378378
(define-rules exponents
379379
[sum-log (+ (log a) (log b)) (log (* a b))]

0 commit comments

Comments
 (0)