sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.44k stars 480 forks source link

SAT and MixedIntegerLinearProgram #24172

Open videlec opened 7 years ago

videlec commented 7 years ago

We could have a much more friendly user interface to SAT solvers by following what has been done for MixedIntegerLinearProgram. We propose that for a given SAT solver created via solver = SAT() we

sage: solver = SAT()
sage: x = solver.new_variable()
sage: solver.add_clause([x['hello'], -x[(1,2)], x[3]])

For compatibility with standard solvers, nonzero integers are also allowed, the variable x just provides an automatic translation from Python objects to integer.

CC: @sagetrac-tmonteil @mkoeppe

Component: combinatorics

Issue created by migration from https://trac.sagemath.org/ticket/24172

videlec commented 7 years ago

Description changed:

--- 
+++ 
@@ -7,5 +7,6 @@
 sage: x = solver.new_variable()
 sage: solver.add_clause([x['hello'], -x[(1,2)], x[3]])
edd8e884-f507-429a-b577-5d554626c0fe commented 6 years ago
comment:2

Someooooone suggested to support the pythonic syntax !x[(1,2)] for the negation of a variable ;)