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.
Files changed (118) hide show
  1. {python_sat-1.9.dev10/python_sat.egg-info → python_sat-1.9.dev12}/PKG-INFO +1 -1
  2. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/__init__.py +1 -1
  3. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/formula.py +25 -10
  4. {python_sat-1.9.dev10 → python_sat-1.9.dev12/python_sat.egg-info}/PKG-INFO +1 -1
  5. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_clausification.py +8 -3
  6. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_formula_unique.py +27 -3
  7. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/LICENSE.txt +0 -0
  8. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/MANIFEST.in +0 -0
  9. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/README.rst +0 -0
  10. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/allies/__init__.py +0 -0
  11. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/allies/approxmc.py +0 -0
  12. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/allies/unigen.py +0 -0
  13. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/bitwise.hh +0 -0
  14. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/card.hh +0 -0
  15. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/clset.hh +0 -0
  16. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/common.hh +0 -0
  17. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/itot.hh +0 -0
  18. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/ladder.hh +0 -0
  19. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/mto.hh +0 -0
  20. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/pairwise.hh +0 -0
  21. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/ptypes.hh +0 -0
  22. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/pycard.cc +0 -0
  23. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/seqcounter.hh +0 -0
  24. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/sortcard.hh +0 -0
  25. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/cardenc/utils.hh +0 -0
  26. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/__init__.py +0 -0
  27. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/bbscan.py +0 -0
  28. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/bica.py +0 -0
  29. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/fm.py +0 -0
  30. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/genhard.py +0 -0
  31. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/hitman.py +0 -0
  32. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/lbx.py +0 -0
  33. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/lsu.py +0 -0
  34. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/mcsls.py +0 -0
  35. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/models.py +0 -0
  36. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/musx.py +0 -0
  37. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/optux.py +0 -0
  38. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/primer.py +0 -0
  39. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/rc2.py +0 -0
  40. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/examples/usage.py +0 -0
  41. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pf_parse.cc +0 -0
  42. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pf_plus.cc +0 -0
  43. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pf_plus.hh +0 -0
  44. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pf_py.hh +0 -0
  45. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pf_scan.hh +0 -0
  46. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pf_weight.cc +0 -0
  47. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pf_weight.hh +0 -0
  48. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pyformula.cc +0 -0
  49. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/formula/pyformula.hh +0 -0
  50. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/_fileio.py +0 -0
  51. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/_utils.py +0 -0
  52. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/card.py +0 -0
  53. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/engines.py +0 -0
  54. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/integer.py +0 -0
  55. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/pb.py +0 -0
  56. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/process.py +0 -0
  57. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/pysat/solvers.py +0 -0
  58. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/python_sat.egg-info/SOURCES.txt +0 -0
  59. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/python_sat.egg-info/dependency_links.txt +0 -0
  60. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/python_sat.egg-info/requires.txt +0 -0
  61. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/python_sat.egg-info/top_level.txt +0 -0
  62. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/requirements.txt +0 -0
  63. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/setup.cfg +0 -0
  64. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/setup.py +0 -0
  65. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/cadical103.tar.gz +0 -0
  66. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/cadical153.tar.gz +0 -0
  67. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/cadical195.tar.gz +0 -0
  68. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/cadical300.tar.gz +0 -0
  69. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/glucose30.tar.gz +0 -0
  70. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/glucose41.tar.gz +0 -0
  71. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/glucose421.tar.gz +0 -0
  72. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/lingeling.tar.gz +0 -0
  73. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/maplechrono.zip +0 -0
  74. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/maplecm.zip +0 -0
  75. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/maplesat.zip +0 -0
  76. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/mergesat3.tar.gz +0 -0
  77. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/minicard.tar.gz +0 -0
  78. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/minisat22.tar.gz +0 -0
  79. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/minisatgh.zip +0 -0
  80. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/cadical103.patch +0 -0
  81. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/cadical153.patch +0 -0
  82. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/cadical195.patch +0 -0
  83. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/cadical300.patch +0 -0
  84. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/glucose30.patch +0 -0
  85. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/glucose41.patch +0 -0
  86. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/glucose421.patch +0 -0
  87. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/gluecard30.patch +0 -0
  88. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/gluecard41.patch +0 -0
  89. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/kissat404.patch +0 -0
  90. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/lingeling.patch +0 -0
  91. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/maplechrono.patch +0 -0
  92. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/maplecm.patch +0 -0
  93. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/maplesat.patch +0 -0
  94. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/mergesat3.patch +0 -0
  95. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/minicard.patch +0 -0
  96. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/minisat22.patch +0 -0
  97. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/minisatep.patch +0 -0
  98. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/patches/minisatgh.patch +0 -0
  99. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/prepare.py +0 -0
  100. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/solvers/pysolvers.cc +0 -0
  101. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_accum_stats.py +0 -0
  102. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_atmost.py +0 -0
  103. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_atmost1.py +0 -0
  104. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_atmostk.py +0 -0
  105. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_boolengine.py +0 -0
  106. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_cnf.py +0 -0
  107. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_empty_extclause.py +0 -0
  108. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_encode_pb_conditional.py +0 -0
  109. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_equals1.py +0 -0
  110. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_formula_parsing.py +0 -0
  111. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_idpool.py +0 -0
  112. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_integer.py +0 -0
  113. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_oom.py +0 -0
  114. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_process.py +0 -0
  115. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_propagate.py +0 -0
  116. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_unique_model.py +0 -0
  117. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_unique_mus.py +0 -0
  118. {python_sat-1.9.dev10 → python_sat-1.9.dev12}/tests/test_warmstart.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-sat
3
- Version: 1.9.dev10
3
+ Version: 1.9.dev12
4
4
  Summary: A Python library for prototyping with SAT oracles
5
5
  Home-page: https://github.com/pysathq/pysat
6
6
  Author: Alexey Ignatiev, Joao Marques-Silva, Antonio Morgado
@@ -10,7 +10,7 @@
10
10
 
11
11
  # current version
12
12
  #==============================================================================
13
- VERSION = (1, 9, 'dev', 10)
13
+ VERSION = (1, 9, 'dev', 12)
14
14
 
15
15
 
16
16
  # PEP440 Format
@@ -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 _formula_key(form):
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, nested :class:`And` and
1787
- :class:`CNF` formulas are expanded without introducing
1788
- intermediate Boolean names - instead, they contribute their
1789
- clausal representations to the list of self's clauses unchanged.
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; nested `And` and
1803
- # `CNF` objects are conjunctions already, so they do not need a
1804
- # Boolean name at this level.
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) in (And, CNF):
1821
+ if type(sub) is CNF:
1807
1822
  sub._clausify(name_required=False)
1808
- self.clauses.extend(clause.copy() for clause in sub.clauses)
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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-sat
3
- Version: 1.9.dev10
3
+ Version: 1.9.dev12
4
4
  Summary: A Python library for prototyping with SAT oracles
5
5
  Home-page: https://github.com/pysathq/pysat
6
6
  Author: Alexey Ignatiev, Joao Marques-Silva, Antonio Morgado
@@ -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 are inherited directly by the outer conjunction
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
- formula = And(And(cnf, Atom(4)), Atom(5))
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
- assert list(formula) == [[-1, 2], [3], [4], [5]]
68
- assert formula.name is None
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