python-sat 1.9.dev10__tar.gz → 1.9.dev12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_sat-1.9.dev10/python_sat.egg-info → python_sat-1.9.dev12}/PKG-INFO +1 -1
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/__init__.py +1 -1
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/formula.py +25 -10
- {python_sat-1.9.dev10 → python_sat-1.9.dev12/python_sat.egg-info}/PKG-INFO +1 -1
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_clausification.py +8 -3
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_formula_unique.py +27 -3
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/LICENSE.txt +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/MANIFEST.in +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/README.rst +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/allies/__init__.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/allies/approxmc.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/allies/unigen.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/bitwise.hh +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/card.hh +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/clset.hh +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/common.hh +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/itot.hh +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/ladder.hh +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/mto.hh +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/pairwise.hh +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/ptypes.hh +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/pycard.cc +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/seqcounter.hh +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/sortcard.hh +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/utils.hh +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/__init__.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/bbscan.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/bica.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/fm.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/genhard.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/hitman.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/lbx.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/lsu.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/mcsls.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/models.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/musx.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/optux.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/primer.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/rc2.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/usage.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pf_parse.cc +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pf_plus.cc +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pf_plus.hh +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pf_py.hh +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pf_scan.hh +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pf_weight.cc +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pf_weight.hh +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pyformula.cc +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pyformula.hh +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/_fileio.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/_utils.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/card.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/engines.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/integer.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/pb.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/process.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/solvers.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/python_sat.egg-info/SOURCES.txt +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/python_sat.egg-info/dependency_links.txt +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/python_sat.egg-info/requires.txt +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/python_sat.egg-info/top_level.txt +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/requirements.txt +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/setup.cfg +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/setup.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/cadical103.tar.gz +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/cadical153.tar.gz +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/cadical195.tar.gz +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/cadical300.tar.gz +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/glucose30.tar.gz +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/glucose41.tar.gz +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/glucose421.tar.gz +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/lingeling.tar.gz +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/maplechrono.zip +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/maplecm.zip +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/maplesat.zip +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/mergesat3.tar.gz +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/minicard.tar.gz +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/minisat22.tar.gz +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/minisatgh.zip +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/cadical103.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/cadical153.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/cadical195.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/cadical300.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/glucose30.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/glucose41.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/glucose421.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/gluecard30.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/gluecard41.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/kissat404.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/lingeling.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/maplechrono.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/maplecm.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/maplesat.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/mergesat3.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/minicard.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/minisat22.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/minisatep.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/minisatgh.patch +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/prepare.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/pysolvers.cc +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_accum_stats.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_atmost.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_atmost1.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_atmostk.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_boolengine.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_cnf.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_empty_extclause.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_encode_pb_conditional.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_equals1.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_formula_parsing.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_idpool.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_integer.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_oom.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_process.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_propagate.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_unique_model.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_unique_mus.py +0 -0
- {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_warmstart.py +0 -0
|
@@ -972,7 +972,7 @@ class Formula(object):
|
|
|
972
972
|
return ('identity', type(obj), id(obj))
|
|
973
973
|
return ('obj', type(obj), obj)
|
|
974
974
|
|
|
975
|
-
def
|
|
975
|
+
def _formula_key_uncached(form):
|
|
976
976
|
"""
|
|
977
977
|
Get a structural key without a formula's merge flag.
|
|
978
978
|
"""
|
|
@@ -1001,6 +1001,21 @@ class Formula(object):
|
|
|
1001
1001
|
counts = collections.Counter(_formula_key(subform) for subform in form.subformulas)
|
|
1002
1002
|
return (form.type, frozenset(counts.items()))
|
|
1003
1003
|
|
|
1004
|
+
def _formula_key(form):
|
|
1005
|
+
"""
|
|
1006
|
+
Get a cached structural key for an immutable formula.
|
|
1007
|
+
"""
|
|
1008
|
+
|
|
1009
|
+
if isinstance(form, Formula):
|
|
1010
|
+
key = getattr(form, '_key_cache', None)
|
|
1011
|
+
if key is None:
|
|
1012
|
+
key = _formula_key_uncached(form)
|
|
1013
|
+
form._key_cache = key
|
|
1014
|
+
|
|
1015
|
+
return key
|
|
1016
|
+
|
|
1017
|
+
return _formula_key_uncached(form)
|
|
1018
|
+
|
|
1004
1019
|
def _merged_operands(operands, formula_type):
|
|
1005
1020
|
"""Flatten same-type operands for a merged connective."""
|
|
1006
1021
|
result = []
|
|
@@ -1783,10 +1798,10 @@ class And(Formula):
|
|
|
1783
1798
|
the subformulas expanding self's list of clauses and also
|
|
1784
1799
|
populates self's clauses with unit clauses, each containing the
|
|
1785
1800
|
auxiliary "name" of the corresponding subformula, thus
|
|
1786
|
-
representing their conjunction. However,
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1801
|
+
representing their conjunction. However, :class:`CNF` formulas
|
|
1802
|
+
are expanded without introducing an intermediate Boolean name -
|
|
1803
|
+
instead, they contribute their clausal representations to the
|
|
1804
|
+
list of self's clauses unchanged.
|
|
1790
1805
|
|
|
1791
1806
|
If ``name_required`` is set to ``True``, the method introduces one
|
|
1792
1807
|
name for the complete conjunction and encodes the equivalence
|
|
@@ -1799,13 +1814,13 @@ class And(Formula):
|
|
|
1799
1814
|
save_clauses = bool(self.clauses)
|
|
1800
1815
|
|
|
1801
1816
|
if not self.clauses:
|
|
1802
|
-
# recursively collect a clausal representation;
|
|
1803
|
-
#
|
|
1804
|
-
#
|
|
1817
|
+
# recursively collect a clausal representation; CNF objects are
|
|
1818
|
+
# already clausal, so they do not need a Boolean name at this
|
|
1819
|
+
# level
|
|
1805
1820
|
for sub in self.subformulas:
|
|
1806
|
-
if type(sub)
|
|
1821
|
+
if type(sub) is CNF:
|
|
1807
1822
|
sub._clausify(name_required=False)
|
|
1808
|
-
self.clauses.extend(
|
|
1823
|
+
self.clauses.extend(cl.copy() for cl in sub.clauses)
|
|
1809
1824
|
else:
|
|
1810
1825
|
sub._clausify(name_required=True)
|
|
1811
1826
|
self.clauses.append([sub.name])
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from pysat.formula import Atom, Formula, And, Or, Neg, XOr
|
|
1
|
+
from pysat.formula import Atom, Formula, And, CNF, Or, Neg, XOr
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
def compare(a, b):
|
|
@@ -37,6 +37,11 @@ def test_clausification():
|
|
|
37
37
|
f = And(Atom('1'), Atom('2'))
|
|
38
38
|
compare(list(f), [[1], [2]])
|
|
39
39
|
|
|
40
|
-
# nested conjunctions
|
|
40
|
+
# nested conjunctions retain their own auxiliary name
|
|
41
41
|
g = And(f, Atom('3'))
|
|
42
|
-
compare(list(g), [[1], [2], [3]])
|
|
42
|
+
compare(list(g), [[1, -3], [2, -3], [3, -1, -2], [3], [4]])
|
|
43
|
+
|
|
44
|
+
# CNF operands are inherited directly by the outer conjunction
|
|
45
|
+
Formula.cleanup()
|
|
46
|
+
h = And(CNF(from_clauses=[[1, 2], [-1, 3]]), Atom('4'))
|
|
47
|
+
compare(list(h), [[1, 2], [-1, 3], [4]])
|
|
@@ -62,10 +62,34 @@ def test_ite_uniqueness():
|
|
|
62
62
|
def test_cnf_as_and_subformula():
|
|
63
63
|
Formula.cleanup()
|
|
64
64
|
cnf = CNF(from_clauses=[[-1, 2], [3]])
|
|
65
|
-
|
|
65
|
+
subf = And(cnf, Atom(4))
|
|
66
|
+
form = And(subf, Atom(5))
|
|
67
|
+
|
|
68
|
+
# the CNF is flattened into its immediate And operand, while the
|
|
69
|
+
# unmerged nested And retains its own auxiliary name
|
|
70
|
+
assert list(form) == [[1, 6], [-2, 6], [-1, 2, -6],
|
|
71
|
+
[6, -7], [3, -7], [4, -7],
|
|
72
|
+
[7, -6, -3, -4], [7], [5]]
|
|
73
|
+
assert form.name is None
|
|
74
|
+
assert subf.name == 7
|
|
75
|
+
assert cnf.name is None
|
|
76
|
+
assert cnf.encoded == []
|
|
77
|
+
|
|
66
78
|
|
|
67
|
-
|
|
68
|
-
|
|
79
|
+
def test_merged_and_with_cnf_subformula():
|
|
80
|
+
Formula.cleanup()
|
|
81
|
+
cnf = CNF(from_clauses=[[-1, 2], [3]])
|
|
82
|
+
subf = And(cnf, Atom(4))
|
|
83
|
+
form = And(subf, Atom(5), merge=True)
|
|
84
|
+
|
|
85
|
+
# Merging removes the nested And boundary. When the merged formula is
|
|
86
|
+
# used as a subformula, it therefore gets exactly one gate name.
|
|
87
|
+
assert list(Or(form, Atom(6))) == [[1, 7], [-2, 7], [-1, 2, -7],
|
|
88
|
+
[7, -8], [3, -8], [4, -8],
|
|
89
|
+
[5, -8], [8, -7, -3, -4, -5],
|
|
90
|
+
[8, 6]]
|
|
91
|
+
assert form.name == 8
|
|
92
|
+
assert subf.name is None
|
|
69
93
|
assert cnf.name is None
|
|
70
94
|
assert cnf.encoded == []
|
|
71
95
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|