PageRenderTime 94ms CodeModel.GetById 59ms RepoModel.GetById 0ms app.codeStats 0ms

/ComputerAlgebra/Satisfiability/Lisp/plans/general.hpp

https://github.com/MGwynne/oklibrary
C++ Header | 340 lines | 0 code | 2 blank | 338 comment | 0 complexity | 4a129f898bbe0521712bab5e8f8a7488 MD5 | raw file
  1. // Oliver Kullmann, 29.6.2007 (Swansea)
  2. /* Copyright 2007, 2008, 2009, 2011 Oliver Kullmann
  3. This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
  4. it and/or modify it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation and included in this library; either version 3 of the
  6. License, or any later version. */
  7. /*!
  8. \file ComputerAlgebra/Satisfiability/Lisp/plans/general.hpp
  9. \brief Plans for SAT at Maxima/Lisp level in general
  10. \todo Relations to other modules
  11. <ul>
  12. <li> What is the relation to
  13. LogicalReflection/FormalisedProofs/plans/FundamentalADTs.hpp ? </li>
  14. </ul>
  15. \todo Update plans:
  16. <ul>
  17. <li> Satisfiability/Lisp/plans/Clauses.hpp </li>
  18. <li> Satisfiability/Lisp/plans/Literals.hpp </li>
  19. <li> Satisfiability/Lisp/plans/MinimalSatisfyingAssignments.hpp </li>
  20. <li> Satisfiability/Lisp/plans/SatisfactionProblems.hpp </li>
  21. </ul>
  22. \todo Redesign
  23. <ul>
  24. <li> See "Clause-lists instead of clause-sets" below. </li>
  25. <li> See "Better general naming conventions" below. </li>
  26. </ul>
  27. \todo MaxSAT, weighted MaxSAT, and partial MaxSAT
  28. <ul>
  29. <li> We have the following definitions:
  30. <ul>
  31. <li> A MaxSAT problem, given a clause-set, is the problem of
  32. finding an assignment that maximises the number of satisfied
  33. clauses. </li>
  34. <li> A weighted MaxSAT problem, given a clause-set and a mapping from
  35. the clauses to positive-integer weights, is the problem of finding an
  36. assignment which maximises the sum of the weights of the satisfied
  37. clauses. </li>
  38. <li> A partial MaxSAT problem, given a clause-set and a partitioning of
  39. the clause-set into "hard" and "soft" clauses, is the problem of finding
  40. an assignment which satisfies all of the "hard" clauses, and maximises
  41. the number of satisfied "soft" clauses. </li>
  42. <li> A weighted partial MaxSAT problem, given a clause-set, a
  43. partitioning of the clause-set into "hard" and "soft" clauses, and map
  44. from "soft" clauses to positive-integer weights, is the problem of
  45. finding a total assignment which satisfies all "hard" clauses, and
  46. maximises the sum of the weights of the satisfied "soft" clauses. </li>
  47. <li> Such definitions are also provided in [The First and Second Max-SAT
  48. Evaluations; Josep Argerlich, Chu-Min Li, Felip ManyĆ” and Jordi Planes].
  49. </li>
  50. <li> MaxSAT competitions are available at http://maxsat.ia.udl.cat/ .
  51. </li>
  52. </ul>
  53. </li>
  54. <li> Note that in all cases where we "maximise the X of the
  55. satisfied clauses", we could also consider that we
  56. "minimise the X of the falsified clauses". This is likely better since
  57. falsified clauses are more appropriate for CNF (the standard). </li>
  58. <li> The following tools currently utilise translations to
  59. (weighted, partial or standard) MaxSAT:
  60. <ul>
  61. <li> MinOnes2WeightedMaxSAT in
  62. Satisfiability/Interfaces/InputOutput/MinOnes2WeightedMaxSAT.cpp. </li>
  63. <li> The AES MaxSAT benchmarks in
  64. Experimentation/Benchmarks/docus/SAT2011.hpp. </li>
  65. </ul>
  66. </li>
  67. <li> For MaxSAT solvers, see
  68. <ul>
  69. <li> maxsatz under "Satz", </li>
  70. <li> "MiniMaxSAT", and </li>
  71. <li> "Maxsat" </li>
  72. </ul>
  73. in Buildsystem/ExternalSources/SpecialBuilds/plans/SAT.hpp.
  74. </li>
  75. <li> We need data-structures at the Lisp-level to handle these concepts:
  76. <ul>
  77. <li> For MaxSAT, the standard clause-lists and so on are sufficient, as
  78. the input is the same as for standard satisfiability. </li>
  79. <li> Weighted MaxSAT:
  80. <ol>
  81. <li> We could represent this as a pair [F,w] where F is the (formal)
  82. clause-set and w is the map from clauses to weights. </li>
  83. <li> However using just pairs [C,w] of clauses of weights is more
  84. natural, since only the given clauses of weights, and the notion of
  85. a map is less natural here. </li>
  86. <li> Actually this replacement of clauses by pairs (C,w) replaces the
  87. set (or variations) of clauses by a map (in the set-theoretical sense).
  88. </li>
  89. </ol>
  90. </li>
  91. <li> For partial MaxSAT:
  92. <ul>
  93. <li> We could represent the input as a pair [F_H, F_S] of the
  94. "hard" clause-set and "soft" clause-set. </li>
  95. <li> For a "formal" partial MaxSAT instance, it seems best
  96. to have a triple [V,F_H,F_S], rather than a pair of formal
  97. clause-sets; we (likely) never consider the total assignments over
  98. just the variables of the "soft" clauses. </li>
  99. <li> But see below for a better possibility. </li>
  100. </ul>
  101. </li>
  102. <li> For weighted partial MaxSAT, it then seems natural to have a
  103. triple [F_H,F_S] where F_H and F_S are the "hard" and "soft"
  104. clauses, F_S is a weighted MaxSAT problem as above (pairs of clauses
  105. and weights). But see below. </li>
  106. </li>
  107. </ul>
  108. </li>
  109. <li> Considering minimising the falsified clauses (for CNF; for DNF we
  110. should consider minimising the satisfied clauses), we can unify partial
  111. and weighted MaxSAT by considering pairs [C,w], where the weight can be
  112. inf --- this indicates that the clause shall be satisfied (this is
  113. achievable iff the minimum weight is strictly less than inf). </li>
  114. <li> We consider thus just "wcl", i.e., weighted clauses, in all the
  115. usual variations ("wcs", "wcl", "fwcs", "fwcl"). </li>
  116. <li> The differentiation between partial and non-partial forms is just
  117. whether inf occurs or not; and for ordinary MaxSAT just all w=1. </li>
  118. <li> In principle we could allow arbitrary w. </li>
  119. <li> We should also a basic (weighted) (partial) MaxSAT solver
  120. at the Maxima level. </li>
  121. </ul>
  122. \todo Clause-lists instead of clause-sets
  123. <ul>
  124. <li> See "General design: Lists *here* are more fundamental than sets"
  125. in ComputerAlgebra/plans/Maxima.hpp for the general discussion. </li>
  126. </ul>
  127. \todo Better general naming conventions
  128. <ul>
  129. <li> See "Notions for clauses, clause-sets etc." in
  130. ComputerAlgebra/Satisfiability/Lisp/ClauseSets/plans/general.hpp
  131. for special issues regarding clause-sets etc. </li>
  132. <li> See "Naming" in
  133. ComputerAlgebra/Satisfiability/Lisp/ClauseSets/plans/Statistics.hpp
  134. for naming of statistics. </li>
  135. <li> Systematise the use of suffices like "cs" and "cs_f".
  136. <ol>
  137. <li> For variables: "v". </li>
  138. <li> For literals: "l". </li>
  139. <li> For clauses: "c". </li>
  140. <li> For clause-sets: "cs". </li>
  141. <li> For clause-lists: "cl". </li>
  142. <li> For ordered clause-sets: "ocs". </li>
  143. <li> The "formal" versions:
  144. <ul>
  145. <li> "fcs", "ofcs" </li>
  146. <li> "lcs", "olcs". </li>
  147. </ul>
  148. </li>
  149. </ol>
  150. </li>
  151. <li> For "standardised clause-sets we use prefix "std", e.g., "stdcs",
  152. or "stdnbfcs". </li>
  153. <li> What about literals as sets of pairs [v,e], where e is
  154. a value (forbidden for CNF, allowed for DNF)?
  155. <ol>
  156. <li> We could use the prefix "ms" for monosigned? </li>
  157. <li> So "msl", "msc", "mscs", "mscl", "msfcs", "msfocs",
  158. "msfmcs", "msfomcs", "msflcs", "msfolcs". </li>
  159. <li> However then we could not express that in a CNF (or DNF)
  160. we wanted to have both allowed and forbidden values? </li>
  161. <li> Then we needed triples [v,e,s], where [v,e] as before, while
  162. s in {-1,+1} ? (This would allow negation.) </li>
  163. <li> We could also have "signed literals" (see below) additionally
  164. with negation? </li>
  165. <li> We could call pairs [n,e] "non-boolean literals" ("nbl"), while
  166. triples [n,e,s] are "monosigned literals" ("msl") ? </li>
  167. <li> Clause-sets would then be "nbcs" resp. "mscs" etc. </li>
  168. </ol>
  169. </li>
  170. <li> And then we have signed literals as sets of pairs [v,E],
  171. where E is a set of values (or a list?)?
  172. <ol>
  173. <li> We could use the prefix "s" for signed? </li>
  174. <li> So "sl", "sc", "scs", "scl", "sfcs", "sofcs",
  175. "smucs", "somucs", "slcs", "solcs". </li>
  176. <li> It seems sensible to allow also triple [v,E,s], where s in {-1,+1}
  177. (for efficient negation). </li>
  178. <li> Such triples would sensibly be called "signed literals" ("sl");
  179. now how to call pairs [v,E]? "Power literals" ("pl")! </li>
  180. </ol>
  181. </li>
  182. <li> For the various forms of generalised clause-sets D we need also forms
  183. which are pairs [F,D], where D yields the domain of variables:
  184. <ol>
  185. <li> Using the suffix "ud" for "uniform domain" (D is just a set resp.
  186. a list for the ordered cases). </li>
  187. <li> While the suffix "fd" for "function domain" mean a function which
  188. assigns to every variable a set resp. a list. </li>
  189. </ol>
  190. </li>
  191. <li> Then we have the different kind of partial assignments:
  192. <ol>
  193. <li> Likely, partial assignments should be syntactically identical
  194. with clauses. </li>
  195. <li> Notions: "pa", "nbpa", "mspa", "ppa", "spa". </li>
  196. <li> And then, like for literals, clauses, clause-sets etc.
  197. one has the CNF- and the DNF-*interpretation*. </li>
  198. <li> For clauses we wanted to stay with sets; perhaps for partial
  199. assignments we could have them ordered?
  200. <ul>
  201. <li> So speaking of "opa", "omspa" and "ospa". </li>
  202. <li> Perhaps one should actually also allow to have ordered clauses?
  203. Better not! Then we have too many combinations. </li>
  204. </ul>
  205. </li>
  206. <li> But we also need the representation of partial assignments via
  207. total assignments! How to call them --- "total partial assignments"? </li>
  208. <li> Or perhaps, since we are already using suffixes like "_l" for
  209. stating representational differernces, "pa_mp" (for map). Seems
  210. reasonable. </li>
  211. <li> Then we could also have "pa_l" (as lists). </li>
  212. <li> And then there are partial assignments which are actually "total
  213. assignments" (w.r.t. a set of variables)?! Perhaps using "tpa" ? </li>
  214. </ol>
  215. </li>
  216. <li> It seems that in general we do not mention the output-type in the
  217. name:
  218. <ol>
  219. <li> However, if we do, for example "clause-sets maps to hash-map",
  220. then we should use "...hm_cs(args)". </li>
  221. <li> The special syntax "cs2hm(F)" should be reserved for conversions.
  222. </li>
  223. </ol>
  224. </li>
  225. <li> There is the issue of using underscores ("min_var_deg_cs") or
  226. not ("varregcsp").
  227. <ol>
  228. <li> Perhaps leaving it out only for those predicates. </li>
  229. </ol>
  230. </li>
  231. <li> See discussion of in-place modifications in "Singular DP-reduction" in
  232. Satisfiability/Lisp/Reductions/plans/DP-Reductions.hpp. </li>
  233. </ul>
  234. \todo Develop combinations of look-ahead with conflict-driven solvers
  235. <ul>
  236. <li> See [OK, Present and future of practical SAT solving;
  237. CSR 8-2008] for first schemes. </li>
  238. <li> This should go to Backtracking/CombinedSchemes.mac. </li>
  239. <li> Perhaps first we do not consider autarkies (and we add them
  240. later). </li>
  241. </ul>
  242. \todo Proof systems
  243. <ul>
  244. <li> We need a dedicated module for proof systems. </li>
  245. <li> See Satisfiability/ProofSystems/plans/general.hpp. </li>
  246. </ul>
  247. \todo Finding out "all properties" of an instance
  248. <ul>
  249. <li> We need some scheme which allows to let the system run all existing
  250. tests. </li>
  251. <li> One application would be to located poly-time classes which
  252. include the instance. </li>
  253. <li> Perhaps all relevant functions have an "exploration" version,
  254. these versions are put into a global list, and then one just runs
  255. through this list. </li>
  256. <li> Then there will be however duplications in the output; but perhaps
  257. this is the lesser evil.
  258. <ol>
  259. <li> Though for example once we know that the instance is satisfiable,
  260. then there is no point in running tests for minimal unsatisfiability.
  261. </li>
  262. <li> Perhaps for each module we write a basic exploration function,
  263. and this function then organises the exploration at module level,
  264. while if needed asks for input established by other modules. </li>
  265. <li> Such a hierarchical scheme looks alright; fits into our general,
  266. "tree-based" organisation. </li>
  267. </ol>
  268. </li>
  269. <li> Different from normal functions, this also needed text-output,
  270. to explain the findings:
  271. <ol>
  272. <li> Perhaps this output all goes to a file. </li>
  273. </ol>
  274. </li>
  275. </ul>
  276. \todo Survey and belief propagation
  277. <ul>
  278. <li> We should create a new module on belief propagation and survey
  279. propagation. </li>
  280. </ul>
  281. \todo Converting CNFs to DNFs
  282. <ul>
  283. <li> This should be the special domain of look-ahead solvers. </li>
  284. <li> See
  285. ComputerAlgebra/Satisfiability/Lisp/Backtracking/plans/SplittingTrees.hpp.
  286. </li>
  287. <li> See Satisfiability/Algorithms/AllSolutions/plans/general.hpp for
  288. plans at the C++-level. </li>
  289. <li> An important application is discussed in
  290. ComputerAlgebra/Satisfiability/Lisp/Preprocessing/plans/general.hpp. </li>
  291. <li> In a certain sense the task is a special case of the problems discussed
  292. in ComputerAlgebra/Satisfiability/Lisp/FiniteFunctions/plans/general.hpp,
  293. however it seems to have a different focus. </li>
  294. <li> The task of computing the transversal hypergraph is related, but
  295. different, namely this is computing (for a CNF) the set of *all*
  296. prime implicantes (minimal satisfying assignments), while here we typically
  297. want to minimise the number of clauses. Of course, knowing all prime
  298. implicants can help, but this restricts the problem to only small cases
  299. (i.e., "finite functions"). </li>
  300. <li> MG put at some time some heuristics into
  301. ComputerAlgebra/Satisfiability/Lisp/ClauseSets/Statistics.mac, but this
  302. is clearly not an appropriate place. </li>
  303. <li> The whole tau-methodology should be applicable here (especially
  304. since we are computing the whole tree; however now we are looking
  305. at satisfiable cases). </li>
  306. <li> ComputerAlgebra/Satisfiability/Lisp/Counting/plans/general.hpp is
  307. related, but likely we should have an independent module. </li>
  308. <li> There are plans in Solvers/OKsolver/SAT2002/plans/general.hpp
  309. (see "Enable finding all solutions" there), but due to the use of
  310. autarkies it is not clear whether the OKsolver is the right tool here.
  311. </li>
  312. <li> What is the appropriate name for the new module? "Cnf2Dnf"? Or perhaps
  313. better "Dualisation"? </li>
  314. </ul>
  315. */