# Create a list of all possible Boolean configurations of three constraints

I have three nonnegativity constraints $$$$A_1>0, A_2>0, A_3>0.$$$$ I want to create a single List consisting of all possible/inequivalent Boolean configurations of none (trivial), one (also trivial), two, and three of them, using the AND, NOT and OR operations.

How long will this List be?

Well--in response to the initial comment/answer--I was really thinking of a (multi-element) List such as

{B1 && B2 && ! B3, B1 || (B2 && B3), ! (B1 && B2) && B3,  B1 || (! B2 && B3), B1 || ! (B2 && B3), ! B1 && B2 && B3}


Given such a List, I would make the substitutions

{B1 -> A1 > 0, B2 -> A2 > 0, B3 -> A3 > 0}


and then attempt Boolean integrations using Boole[each element of the resulting list].

• Are there any equivalent pairs in this list? res = And @@ MapThread[Construct, {#, {a, b, c}}] & /@ Tuples[{Not, Identity}, 3]; res = Join[res, Not /@ res]; May 11, 2019 at 13:40

You can use BooleanCountingFunction:

exp = Array[Subscript[A, #] > 0 &, 3];
BooleanConvert[BooleanCountingFunction[{1}, 3] @@ exp]

TeXForm @ %


$$\small\left(A_1\leq 0\land A_2\leq 0\land A_3>0\right)\lor \left(A_1\leq 0\land A_2>0\land A_3\leq 0\right)\lor \left(A_1>0\land A_2\leq 0\land A_3\leq 0\right)$$

BooleanConvert[BooleanCountingFunction[{2}, 3] @@ exp] // TeXForm


$$\small \left(A_1\leq 0\land A_2>0\land A_3>0\right)\lor \left(A_1>0\land A_2\leq 0\land A_3>0\right)\lor \left(A_1>0\land A_2>0\land A_3\leq 0\right)$$

BooleanConvert[BooleanCountingFunction[{3}, 3] @@ exp] // TeXForm


$$\small A_1>0\land A_2>0\land A_3>0$$

You can create a list of all 8 possible combinations:

tups = Tuples[And[{B1, !B1}, {B2, !B2}, {B3, !B3}]]


{B1 && B2 && B3, B1 && B2 && ! B3, B1 && ! B2 && B3, B1 && ! B2 && ! B3, ! B1 && B2 && B3, ! B1 && B2 && ! B3, ! B1 && ! B2 && B3, ! B1 && ! B2 && ! B3}

Then, I think you want the power set:

sets = BooleanMinimize /@ Subsets[Or @@ tups];
sets[[;;20]]


{False, B1 && B2 && B3, B1 && B2 && ! B3, B1 && ! B2 && B3, B1 && ! B2 && ! B3, ! B1 && B2 && B3, ! B1 && B2 && ! B3, ! B1 && ! B2 && B3, ! B1 && ! B2 && ! B3, B1 && B2, B1 && B3, (B1 && B2 && B3) || (B1 && ! B2 && ! B3), B2 && B3, (B1 && B2 && B3) || (! B1 && B2 && ! B3), (B1 && B2 && B3) || (! B1 && ! B2 && B3), (B1 && B2 && B3) || (! B1 && ! B2 && ! B3), (B1 && B2 && ! B3) || (B1 && ! B2 && B3), B1 && ! B3, (B1 && B2 && ! B3) || (! B1 && B2 && B3), B2 && ! B3}

You examples are all included:

examples = {
B1 && B2 && ! B3,
B1 || (B2 && B3),
! (B1 && B2) && B3,
B1 || (! B2 && B3),
B1 || ! (B2 && B3),
! B1 && B2 && B3
};
MemberQ[sets, #]& /@ BooleanMinimize /@ examples


{True, True, True, True, True, True}

• Thanks! I don't think I was considering more than 3 member combinations (hard enough to integrate with them as constraints)--but some of those (at most three) member combinations would have OR's in them--such as B1 || (B2 && B3). I don't see that standing by itself in your list (or any other two- or three-member group with an imbedded OR). Why is its presence tested as TRUE? Not sure as to the conversion rules of Boolean operations--can parentheses be removed? That's why I posted the question--to try to efficiently list all three-member distinct possibilities for my integration computations. May 11, 2019 at 22:55
• @PaulB.Slater I only showed the first 20 of the 256 elements of the power set. I don't understnad your criteria for what elements of the power set you want to consider. May 11, 2019 at 23:02
• Thanks again! I do now see the full 256 entries. How can I select those among them with n B's in them (n=2, 3, 4,...)? That seem like a resonable order in which to attempt my constrained integrations. May 11, 2019 at 23:40