subtypep giving inconsistent results on certain cons types

Bug #1694839 reported by Paul F. Dietz
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
New
Undecided
Unassigned

Bug Description

If A is a subtype of B, then (NOT B) should be a subtype of (NOT A). If subtypep can determine the subtype relationship in both cases then they must be consistent. However:

(SUBTYPEP '(CONS INTEGER (CONS (REAL -3.3 4.4) (EQL 1)))
          '(NOT (CONS T (CONS (NOT INTEGER) (EQL 0))))) => T, T
(SUBTYPEP '(NOT (NOT (CONS T (CONS (NOT INTEGER) (EQL 0)))))
          '(NOT (CONS INTEGER (CONS (REAL -3.3 4.4) (EQL 1))))) => NIL, T
(SUBTYPEP '(CONS T (CONS (NOT INTEGER) (EQL 0)))
          '(NOT (CONS INTEGER (CONS (REAL -3.3 4.4) (EQL 1))))) => NIL, T

This is in sbcl 1.3.18.

Tags: types
tags: added: types
Changed in sbcl:
status: New → Incomplete
Revision history for this message
Paul F. Dietz (paul-f-dietz) wrote :

This is still occurring in 1.4.3.

Changed in sbcl:
status: Incomplete → New
Revision history for this message
Michał "phoe" Herda (phoe-krk) wrote :

(let* ((t1 '(not (cons float t)))
       (t2 `(or (not (cons (eql 0)
                           (real -3.926510009989861d7 -3.926510009989861d7)))
                (not (cons t (eql 0))))))
  (subtypep t1 t2))

;=> NIL, T

This happens even though T2 is equivalent to T.

Revision history for this message
Paul F. Dietz (paul-f-dietz) wrote :

That was from test SUBTYPEP.CONS.43 in ansi-test, which was added back in SBCL 0.9.6.57.

Revision history for this message
Paul F. Dietz (paul-f-dietz) wrote :

Still occurring in 2.2.11.38-5afe2f165.

Revision history for this message
Paul F. Dietz (paul-f-dietz) wrote :

#2 is good now, but the original bug is still there. Also:

(defun bug112 ()
  (let ((t1 '(cons t
              (cons (not (eql 0))
               cons)))
        (t2 '(not (cons null
                   (cons (real -2 -1)
                    null)))))
    (values
     (multiple-value-list (subtypep t1 t2))
     (multiple-value-list (subtypep `(not ,t2) `(not ,t1)))
     (multiple-value-list (subtypep (cadr t2) `(not ,t1))))))

(defun bug112a ()
  (let ((t1 '(cons (not (eql 0)) cons))
        (t2 '(not (cons (real -2 -1) null))))
    (values
     (multiple-value-list (subtypep t1 t2))
     (multiple-value-list (subtypep `(not ,t2) `(not ,t1)))
     (multiple-value-list (subtypep (cadr t2) `(not ,t1))))))

(bug112) ==> (NIL T), (T T), (T T)
(bug112a) ==> (NIL NIL), (T T), (T T) ;; which is ok

x86-64, "2.3.0.112-21b0a66b1"

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.