3
$\begingroup$

I have three nonnegativity constraints \begin{equation} A_1>0, A_2>0, A_3>0. \end{equation} 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].

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

2 Answers 2

5
$\begingroup$

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$

$\endgroup$
3
$\begingroup$

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}

$\endgroup$
3
  • $\begingroup$ 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. $\endgroup$ May 11, 2019 at 22:55
  • $\begingroup$ @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. $\endgroup$
    – Carl Woll
    May 11, 2019 at 23:02
  • $\begingroup$ 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. $\endgroup$ May 11, 2019 at 23:40

Your Answer

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

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