<< Back to previous view

[LOGIC-135] membero should be updated to use disequality constraints Created: 07/May/13  Updated: 28/Jul/13  Resolved: 07/May/13

Status: Closed
Project: core.logic
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Austin Haas Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: File LOGIC-135-membero-using-disequality.diff    

 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.



 Comments   
Comment by Austin Haas [ 07/May/13 5:33 PM ]

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.

Comment by Austin Haas [ 07/May/13 5:41 PM ]

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).

Comment by David Nolen [ 07/May/13 10:24 PM ]

fixed http://github.com/clojure/core.logic/commit/a35c8eebfff90515796ea734ba81e3f5db041b5c

Generated at Sun Apr 20 03:32:39 CDT 2014 using JIRA 4.4#649-r158309.