core.logic

Unification of sets allows for duplicate values leading to non-set-like behavior

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

Considering this behavior:

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

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.

Activity

Hide
David Nolen added a comment -

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

Show
David Nolen added a comment - I probably should held off on implementing unification with sets. Oh well. The distincto approach sounds reasonable to me - would gladly take a patch.
David Nolen made changes -
Field Original Value New Value
Comment [ I probably should held off on implementing unification with sets. Oh well. The distincto approach sounds reasonable to me - would gladly take a patch. ]
Hide
Aaron Brooks added a comment -

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.

Show
Aaron Brooks added a comment - 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.
David Nolen made changes -
Resolution Completed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
David Nolen made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: