<< Back to previous view

[LOGIC-55] Unification of sets allows for duplicate values leading to non-set-like behavior Created: 21/Sep/12  Updated: 28/Jul/13  Resolved: 27/Sep/12

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

Type: Defect Priority: Major
Reporter: Aaron Brooks Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None


Considering this behavior:

user> (run* [out] (== 3 out) (== #{3 out} #{3 out}))

There are other more convoluted cases involving multiple lvars but I think the above is enough for discussion. I think the above behavior is at least unexpected (desiring documentation) if not actually incorrect behavior.

A possible solution would be to apply distincto (or some equivalent) to the members of each incoming set before the body of unify-with-set (extending IUnifyWithSet to clojure.lang.IPersistentSet). Naturally this makes set unification even more expensive than it currently is but I'm currently inclined to think that this additional cost is unavoidable, at least with the current approach.

Comment by David Nolen [ 21/Sep/12 3:19 PM ]

I probably should held off on implementing unification with sets. Oh well. The distincto approach sounds reasonable to me - would gladly take a patch.

Comment by Aaron Brooks [ 21/Sep/12 3:22 PM ]

I'll look in to that. Would you be against declaring distincto so I can use it earlier in the file? I don't recall off the top of my head but I think distincto can't be moved that early in the file and probably wants to stay where it is anyways.

Comment by David Nolen [ 27/Sep/12 9:38 PM ]

fixed, http://github.com/clojure/core.logic/commit/cdc4bf8563e9f566cc6e3e0e4f8a7735cd92b88e

Generated at Sun Sep 24 09:11:51 CDT 2017 using JIRA 4.4#649-r158309.