1
$\begingroup$

I have defined two sets

set1[n_] := Table[i, {i, 1, n}];
set2[n_] := Subsets[Delete[Subsets[set[n]], 1]];

Now, I want to check whether an element of set2[n] is union closed, i.e. if the union of every two elements in set2[n] is again an element of set2[n].. How can I realize this?

$\endgroup$

1 Answer 1

0
$\begingroup$

An ugly solution, test them one by one:

closeness[set_]:=Block[{check=True},Do[If[FreeQ[set,Union[set[[i]],set[[j]]]],check=False;Break[]],{i,1,Length@set},{j,i+1,Length@set}];check]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.