Remove many cases of = that are unnecessary.

This commit is contained in:
Eric Dobson 2015-04-02 21:38:05 -07:00
parent 7b762933c6
commit a33b27a3c9
3 changed files with 24 additions and 46 deletions

View File

@ -891,8 +891,8 @@
;; There are 25 values that answer true to zero?. They are either reals, or inexact complexes.
;; Note -RealZero contains NaN and zero? returns #f on it
[zero?
(-> N B : (-FS (-filter (Un -RealZero -InexactComplex -InexactImaginary) 0)
(-not-filter (Un -Zero -InexactRealPosZero -InexactRealNegZero) 0)))]
(-> N B : (-FS (-filter (Un -RealZeroNoNan -InexactComplex -InexactImaginary) 0)
(-not-filter -RealZeroNoNan 0)))]
[number? (make-pred-ty N)]
[integer? (asym-pred Univ B (-FS (-filter (Un -Int -Flonum -SingleFlonum) 0) ; inexact-integers exist...
@ -920,46 +920,16 @@
[=
(from-cases
(map (lambda (l) (apply exclude-zero l))
(list (list -Byte -PosByte)
(list -Index -PosIndex)
(list -NonNegFixnum -PosFixnum)
(list -NonPosFixnum -NegFixnum)
(list -Nat -PosInt)
(list -NonPosInt -NegInt)
(list -Int (Un -PosInt -NegInt))
(list -NonNegRat -PosRat)
(list -NonPosRat -NegRat)
(list -Rat (Un -PosRat -NegRat))
(list -NonNegFlonum -PosFlonum -FlonumZero)
(list -NonPosFlonum -NegFlonum -FlonumZero)
(list -Flonum (Un -PosFlonum -NegFlonum) -FlonumZero)
(list -NonNegSingleFlonum -PosSingleFlonum -SingleFlonumZero)
(list -NonPosSingleFlonum -NegSingleFlonum -SingleFlonumZero)
(list -SingleFlonum (Un -PosSingleFlonum -NegSingleFlonum) -SingleFlonumZero)
(list -NonNegInexactReal -PosInexactReal -InexactRealZero)
(list -NonPosInexactReal -NegInexactReal -InexactRealZero)
(list -InexactReal (Un -PosInexactReal -NegInexactReal) -InexactRealZero)
(list -NonNegReal -PosReal -RealZero)
(list -NonPosReal -NegReal -RealZero)
(list -Real (Un -PosReal -NegReal) -RealZero)))
(-> -Real -RealZero B : (-FS (-filter -RealZeroNoNan 0) (-not-filter -RealZeroNoNan 0)))
(-> -RealZero -Real B : (-FS (-filter -RealZeroNoNan 1) (-not-filter -RealZeroNoNan 1)))
(map (lambda (t) (commutative-equality/filter -ExactNumber t))
(list -One -PosByte -Byte -PosIndex -Index
-PosFixnum -NonNegFixnum -NegFixnum -NonPosFixnum -Fixnum
-PosInt -Nat -NegInt -NonPosInt -Int
-PosRat -NonNegRat -NegRat -NonPosRat -Rat
-ExactNumber))
(map (lambda (t) (commutative-equality/filter -Flonum t))
(list -FlonumZero -PosFlonum -NonNegFlonum -NegFlonum -NonPosFlonum -Flonum))
(map (lambda (t) (commutative-equality/filter -SingleFlonum t))
(list -SingleFlonumZero -PosSingleFlonum -NonNegSingleFlonum
-NegSingleFlonum -NonPosSingleFlonum -SingleFlonum))
(map (lambda (t) (commutative-equality/filter -InexactReal t))
(list -InexactRealZero -PosInexactReal -NonNegInexactReal
-NegInexactReal -NonPosInexactReal -InexactReal))
;; this case should take care of mixed type equality. the filters give
;; sign information, and we get exactness information from the original
;; types
;; For all real types: the filters give sign information, and the exactness information is preserved
;; from the original types.
(map (lambda (t) (commutative-equality/filter -Real t))
(list -RealZero -PosReal -NonNegReal -NegReal -NonPosReal -Real))
(->* (list N N) N B))]

View File

@ -17,7 +17,7 @@
-FlonumPosZero -FlonumNegZero -FlonumZero -FlonumNan -PosFlonum -NonNegFlonum -NegFlonum -NonPosFlonum -Flonum
-SingleFlonumPosZero -SingleFlonumNegZero -SingleFlonumZero -SingleFlonumNan -PosSingleFlonum -NonNegSingleFlonum -NegSingleFlonum -NonPosSingleFlonum -SingleFlonum
-InexactRealPosZero -InexactRealNegZero -InexactRealZero -InexactRealNan -PosInexactReal -NonNegInexactReal -NegInexactReal -NonPosInexactReal -InexactReal
-RealZero -PosReal -NonNegReal -NegReal -NonPosReal -Real
-RealZero -RealZeroNoNan -PosReal -NonNegReal -NegReal -NonPosReal -Real
-PosInfinity -NegInfinity
-ExactImaginary -FloatImaginary -SingleFlonumImaginary -InexactImaginary -Imaginary
-ExactNumber -ExactComplex -FloatComplex -SingleFlonumComplex -InexactComplex -Number
@ -203,12 +203,13 @@
(define/decl -InexactReal (*Un -SingleFlonum -Flonum))
;; Reals
(define/decl -RealZero (*Un -Zero -InexactRealZero))
(define/decl -PosReal (*Un -PosRat -PosInexactReal))
(define/decl -NonNegReal (*Un -NonNegRat -NonNegInexactReal))
(define/decl -NegReal (*Un -NegRat -NegInexactReal))
(define/decl -NonPosReal (*Un -NonPosRat -NonPosInexactReal))
(define/decl -Real (*Un -Rat -InexactReal))
(define/decl -RealZero (*Un -Zero -InexactRealZero))
(define/decl -RealZeroNoNan (*Un -Zero -InexactRealPosZero -InexactRealNegZero))
(define/decl -PosReal (*Un -PosRat -PosInexactReal))
(define/decl -NonNegReal (*Un -NonNegRat -NonNegInexactReal))
(define/decl -NegReal (*Un -NegRat -NegInexactReal))
(define/decl -NonPosReal (*Un -NonPosRat -NonPosInexactReal))
(define/decl -Real (*Un -Rat -InexactReal))
;; Complexes
;; We could go into _much_ more precision here.

View File

@ -3578,8 +3578,7 @@
(t:-> -Nat -Boolean : (-FS (-filter (-val 0) 0) (-not-filter (-val 0) 0)))]
[tc-e/t
(lambda: ([x : Real]) (zero? x))
(t:-> -Real -Boolean : (-FS (-filter -RealZero 0)
(-not-filter (t:Un -Zero -InexactRealPosZero -InexactRealNegZero) 0)))]
(t:-> -Real -Boolean : (-FS (-filter -RealZeroNoNan 0) (-not-filter -RealZeroNoNan 0)))]
[tc-e/t (lambda: ([x : Byte]) (positive? x))
(t:-> -Byte -Boolean : (-FS (-filter -PosByte 0) (-filter -Zero 0)))]
@ -3597,7 +3596,15 @@
(t:-> -Flonum (t:Un (-val #t) -FlonumNan)
: -true-filter)]
[tc-e/t
(lambda: ([x : Flonum]) (if (= 0 x) 1.0 x))
(t:-> -Flonum (t:Un -PosFlonum -NegFlonum) : -true-filter)]
[tc-e/t
(lambda: ([x : Byte]) (if (= 0 x) 1 x))
(t:-> -Byte -PosByte : -true-filter)]
[tc-e/t
(lambda: ([x : Flonum]) (if (= x (ann 1.0 Positive-Flonum)) x 'other))
(t:-> -Flonum (t:Un -PosFlonum (-val 'other)) : -true-filter)]
)
(test-suite