Note that there are some explanatory texts on larger screens.

plurals
  1. POSolving Symbolic Boolean variables in Python
    primarykey
    data
    text
    <p>I need to solve a set of symbolic Boolean expressions like:</p> <pre><code>&gt;&gt;&gt; solve(x | y = False) (False, False) &gt;&gt;&gt; solve(x &amp; y = True) (True, True) &gt;&gt;&gt; solve (x &amp; y &amp; z = True) (True, True, True) &gt;&gt;&gt; solve(x ^ y = False) ((False, False), (True, True)) </code></pre> <p>Number of such variables is large (~200) so that Brute Force strategy is not possible. I searched the web and found that <a href="http://sympy.org/en/index.html" rel="nofollow">Sympy</a> and <a href="http://www.sagemath.org/index.html" rel="nofollow">Sage</a> have symbolic manipulation capabilities (particularly <a href="http://www.sagemath.org/doc/reference/logic/sage/logic/booleval.html" rel="nofollow">this</a> and <a href="http://www.sagemath.org/doc/reference/polynomial_rings/sage/rings/polynomial/pbori.html" rel="nofollow">this</a> may be useful). How can I do that?</p> <p>EDIT: I mainly tried to manipulate such things:</p> <pre><code>&gt;&gt;&gt; from sympy import * &gt;&gt;&gt; x=Symbol('x', bool=True) &gt;&gt;&gt; y=Symbol('y', bool=True) &gt;&gt;&gt; solve(x &amp; y, x) </code></pre> <p>which results in <code>NotImplementedError</code>. Then I tried <code>solve(x * y, x)</code> which gave <code>[0]</code> (I don't know what does it mean), <code>solve(x * y = True, x)</code> resulted in a <code>SyntaxError</code>, <code>solve(x * y, True, x)</code> and <code>solve(x &amp; y, True, x)</code> gave an <code>AttributeError</code>. I don't know what else to try!</p> <p>EDIT (2): I also found <a href="ftp://ftp.iitb.ac.in/packages/sagemath/doc/en/reference/sat/sat.pdf" rel="nofollow">this</a>, may be useful!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload