core.logic

membero should be updated to use disequality constraints

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

William Byrd considers the version of membero that appears in core.logic to be outdated and inferior to a version that uses disequality constraints. Full discussion here: http://youtu.be/MTAhbsWUUxM?t=1h20m00s

NEW version:

(defne membero
  "A relation where l is a collection, such that l contains x"
  [x l]
  ([_ [x . tail]])
  ([_ [head . tail]]
     (!= x head)       ;; The addition of this line is the only change.
     (membero x tail)))

(run* [q] (membero q [1 1 1])) 
;; => (1)
;; The current version returns (1 1 1).

Patch to follow.

Activity

Hide
Austin Haas added a comment -

Regarding the tests, the first broke because it assumed reified fresh lvars wouldn't include disequality constraints.

For the 2nd one, test-116-constraint-store-migrate, I have not looked into it thoroughly, but I got the impression that the test needs to be rewritten. I'd argue that it is more important to fix membero before fixing that test (but I don't know what else that test is testing).

Show
Austin Haas added a comment - Regarding the tests, the first broke because it assumed reified fresh lvars wouldn't include disequality constraints. For the 2nd one, test-116-constraint-store-migrate, I have not looked into it thoroughly, but I got the impression that the test needs to be rewritten. I'd argue that it is more important to fix membero before fixing that test (but I don't know what else that test is testing).
Hide
Austin Haas added a comment -

This patch improves membero by adding a disequality constraint. Fix for LOGIC-135.

Note that this patch removes two tests that depended on assumptions that have nothing to do with the correctness of membero.

Show
Austin Haas added a comment - This patch improves membero by adding a disequality constraint. Fix for LOGIC-135. Note that this patch removes two tests that depended on assumptions that have nothing to do with the correctness of membero.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: