title: Express and (possibly simplify) Logical expressions as a tree
body: <p>I've been given a bunch of boolean expressions(in a sum of products form) like these for example:</p>
  <pre><code>(1  &amp; 0  &amp;  2) |
  (1  &amp; 0  &amp;  3  &amp;  4  &amp;  5) |
  (1  &amp;  6  &amp;  7  &amp;  2  &amp;  8) |
  (1  &amp;  6 &amp;  3) |
  (6  &amp;  7  &amp;  8) |
  (1  &amp;  9  &amp;  11  &amp;  12 &amp;  10) |
  (1  &amp;  9  &amp;  11  &amp;  12  &amp;  13)
  </code></pre>
  <p>Each number (eg: 1, 0 etc) represents an atomic boolean expression.</p>
  <ol>
  <li><p>I'd like to lay them out in a single condition tree.
  (For ex:</p>
  <pre><code>1
     0
        2
        3
           4
             5
   ...
  </code></pre>
  </li>
  </ol>
  <p>I would like to lay them out in a tree like above (ie every branch represents a condition expression and every node represents an atomic condition).</p>
  <p>When I lay them out in a tree, I also need to cater to the following.</p>
  <ol>
  <li>The tree must not have conflicting conditions (ie every branch should be mutually exclusive). The tree building algorithm must make a best possible effort to ensure that the branches are constructed without conflicts (although I'm not sure if it can be done 100% because the input conditions may be conflicting by itself).</li>
  <li>A few conditions are repeated and have multiple parents (eg: '8' it has 2 different parents 2 and 7_ - this violates the principles of a tree.</li>
  </ol>
  <p>I'm trying to find any pointers to the approach that needs to be taken to solve this problem.
  Also interested to validate my sentiments that problem cannot be solved 100% (meaning, we cannot get a conflict-free tree) as this depends on the nature of the input conditions?</p>