Re: [eclipse-clp-users] ic_sets question: negated set constraints

From: Joachim Schimpf <jschimpf_at_...311...>
Date: Sun, 18 Sep 2016 12:14:37 +0100
On 18/09/16 09:15, Daniel Jozsef wrote:
> Hello,
>
> I'm trying to wrap my head around the ic_sets library, and it feels extremely
> limited in its abilities. Specifically something I'd need for a model I'm
> working on is to be able to define a "A is NOT a subset of B" constraint.
>
> Given how the only constraint that has a reified form is the simple membership,
> no trivial solution seems to present itself. I came up with the following
> solution, it works but I don't really like it:
>
> notsubset(SetA, SetB) :-
> SetA :: []..[1,2,3,4],
> ic_sets:union(SetA, SetB, U),
> #(U, UCard),
> #(SetA, ACard),
> ACard #< UCard.
>
> Any idea how this could be done in a more elegant way?

One way that comes to mind is

notsubset(A, B) :-
	difference(A, B, D),
	#(D, DCard),
	DCard #> 0.

or, for short:

notsubset(A, B) :-
	#(A\B) #> 0.


-- Joachim
Received on Sun Sep 18 2016 - 11:41:01 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:30 CEST