[BV] An option for SAT proof optimization (#2915)
authorAlex Ozdemir <aozdemir@hmc.edu>
Tue, 23 Apr 2019 22:58:57 +0000 (15:58 -0700)
committerGitHub <noreply@github.com>
Tue, 23 Apr 2019 22:58:57 +0000 (15:58 -0700)
* [BV] An option for SAT proof optimization

The option doesn't **do** anything yet, but exists.

* CopyPaste Fix: BvOptimizeSatProof documentation

It was the documentation for a different option. Now it has been
updated.

* Fix Typos per Mathias' review.

Co-Authored-By: alex-ozdemir <aozdemir@hmc.edu>
src/options/bv_bitblast_mode.cpp
src/options/bv_bitblast_mode.h
src/options/bv_options.toml
src/options/options_handler.cpp
src/options/options_handler.h

index 4bd7b9d77515a6bd07ca56f94d4b1d8994447e3d..d2425831a69ed515c2ef94d3dcad1e82eb9da58e 100644 (file)
@@ -81,4 +81,25 @@ std::ostream& operator<<(std::ostream& out, theory::bv::BvProofFormat format)
   return out;
 }
 
+std::ostream& operator<<(std::ostream& out,
+                         theory::bv::BvOptimizeSatProof level)
+{
+  switch (level)
+  {
+    case theory::bv::BITVECTOR_OPTIMIZE_SAT_PROOF_NONE:
+      out << "BITVECTOR_OPTIMIZE_SAT_PROOF_NONE";
+      break;
+    case theory::bv::BITVECTOR_OPTIMIZE_SAT_PROOF_PROOF:
+      out << "BITVECTOR_OPTIMIZE_SAT_PROOF_PROOF";
+      break;
+    case theory::bv::BITVECTOR_OPTIMIZE_SAT_PROOF_FORMULA:
+      out << "BITVECTOR_OPTIMIZE_SAT_PROOF_FORMULA";
+      break;
+    default: out << "BvOptimizeSatProof:UNKNOWN![" << unsigned(level) << "]";
+  }
+
+  return out;
+}
+
 }/* CVC4 namespace */
+
index 871333b35d316b780dcd993107f3cf6698148d37..270f2346d9fdc09a27de0009e10f59735274f972 100644 (file)
@@ -88,6 +88,27 @@ enum BvProofFormat
   BITVECTOR_PROOF_LRAT,
 };
 
+/**
+ * When the BV solver does eager bit-blasting backed by DRAT-producing SAT solvers, proofs
+ * can be written in a variety of formats.
+ */
+enum BvOptimizeSatProof
+{
+  /**
+   * Do not optimize the SAT proof.
+   */
+  BITVECTOR_OPTIMIZE_SAT_PROOF_NONE = 0,
+  /**
+   * Optimize the SAT proof, but do not shrink the formula
+   */
+  BITVECTOR_OPTIMIZE_SAT_PROOF_PROOF = 1,
+  /**
+   * Optimize the SAT proof and shrink the formula
+   */
+  BITVECTOR_OPTIMIZE_SAT_PROOF_FORMULA = 2,
+};
+
+
 }/* CVC4::theory::bv namespace */
 }/* CVC4::theory namespace */
 
@@ -95,6 +116,7 @@ std::ostream& operator<<(std::ostream& out, theory::bv::BitblastMode mode);
 std::ostream& operator<<(std::ostream& out, theory::bv::BvSlicerMode mode);
 std::ostream& operator<<(std::ostream& out, theory::bv::SatSolverMode mode);
 std::ostream& operator<<(std::ostream& out, theory::bv::BvProofFormat format);
+std::ostream& operator<<(std::ostream& out, theory::bv::BvOptimizeSatProof level);
 
 }/* CVC4 namespace */
 
index 6dd755625b9aa959e3e836076385866cc0586cbe..9529b7500fdb54cdf06616e43f3118e6c2121546 100644 (file)
@@ -13,6 +13,17 @@ header = "options/bv_options.h"
   includes   = ["options/bv_bitblast_mode.h"]
   help       = "choose which UNSAT proof format to use, see --bv-sat-solver=help"
 
+[[option]]
+  name       = "bvOptimizeSatProof"
+  category   = "expert"
+  long       = "bv-optimize-sat-proof=MODE"
+  type       = "CVC4::theory::bv::BvOptimizeSatProof"
+  default    = "CVC4::theory::bv::BITVECTOR_OPTIMIZE_SAT_PROOF_FORMULA"
+  handler    = "stringToBvOptimizeSatProof"
+  predicates = ["satSolverEnabledBuild"]
+  includes   = ["options/bv_bitblast_mode.h"]
+  help       = "enable SAT proof optimizations, see --bv-optimize-sat-proof=help"
+
 [[option]]
   name       = "bvSatSolver"
   smt_name   = "bv-sat-solver"
index f171c907e4ce72343edcf1b6e74dbccafdd21d38..7a4967de5774e8b03ad3b45bb3ea33ec1bfbd3d1 100644 (file)
@@ -1245,6 +1245,45 @@ theory::bv::BvProofFormat OptionsHandler::stringToBvProofFormat(
   }
 }
 
+const std::string OptionsHandler::s_bvOptimizeSatProofHelp =
+    "\
+Optimization levels currently supported by the --bv-optimize-sat-proof option:\n\
+\n\
+  none    : Do not optimize the SAT proof\n\
+\n\
+  proof   : Use drat-trim to shrink the SAT proof\n\
+\n\
+  formula : Use drat-trim to shrink the SAT proof and formula (default)\
+";
+
+theory::bv::BvOptimizeSatProof OptionsHandler::stringToBvOptimizeSatProof(
+    std::string option, std::string optarg)
+{
+  if (optarg == "none")
+  {
+    return theory::bv::BITVECTOR_OPTIMIZE_SAT_PROOF_NONE;
+  }
+  else if (optarg == "proof")
+  {
+    return theory::bv::BITVECTOR_OPTIMIZE_SAT_PROOF_PROOF;
+  }
+  else if (optarg == "formula")
+  {
+    return theory::bv::BITVECTOR_OPTIMIZE_SAT_PROOF_FORMULA;
+  }
+  else if (optarg == "help")
+  {
+    puts(s_bvOptimizeSatProofHelp.c_str());
+    exit(1);
+  }
+  else
+  {
+    throw OptionException(std::string("unknown option for --bv-optimize-sat-proof: `")
+                          + optarg + "'.  Try --bv-optimize-sat-proof=help.");
+  }
+}
+
+
 const std::string OptionsHandler::s_bitblastingModeHelp = "\
 Bit-blasting modes currently supported by the --bitblast option:\n\
 \n\
index 16ddbce4de5147c18800a520bec877fdd8133eef..5c354be570fe1c287806807911535ce211bdcd5c 100644 (file)
@@ -148,6 +148,8 @@ public:
 
   theory::bv::BvProofFormat stringToBvProofFormat(std::string option,
                                                   std::string optarg);
+  theory::bv::BvOptimizeSatProof stringToBvOptimizeSatProof(std::string option,
+                                                            std::string optarg);
 
   theory::strings::ProcessLoopMode stringToStringsProcessLoopMode(
       std::string option, std::string optarg);
@@ -238,6 +240,7 @@ public:
   static const std::string s_bitblastingModeHelp;
   static const std::string s_bvSatSolverHelp;
   static const std::string s_bvProofFormatHelp;
+  static const std::string s_bvOptimizeSatProofHelp;
   static const std::string s_booleanTermConversionModeHelp;
   static const std::string s_bvSlicerModeHelp;
   static const std::string s_stringToStringsProcessLoopModeHelp;