CBMC
qbf_squolem.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Squolem Backend
4 
5 Author: CM Wintersteiger
6 
7 \*******************************************************************/
8 
11 
12 #include "qbf_squolem.h"
13 
15  early_decision(false)
16 {
17 }
18 
20 {
21  squolem.reset();
22 }
23 
25 {
27 }
28 
29 std::string qbf_squolemt::solver_text() const
30 {
31  return "Squolem";
32 }
33 
35 {
36  {
37  std::string msg=
38  "Squolem: "+
39  std::to_string(no_variables())+" variables, "+
40  std::to_string(no_clauses())+" clauses";
41  messaget::status() << msg << messaget::eom;
42  }
43 
44  if(early_decision)
45  return P_UNSATISFIABLE;
46 
47 // squolem.options.set_showStatus(true);
48  squolem.options.set_freeOnExit(true);
49 // squolem.options.set_useExpansion(true);
50 // squolem.options.set_predictOnLiteralBound(true);
51  squolem.options.set_debugFilename("debug.qdimacs");
52  squolem.options.set_saveDebugFile(true);
53 
54  squolem.endOfOriginals();
55  bool result=squolem.decide();
56 
57  if(result)
58  {
59  messaget::status() << "Squolem: VALID" << messaget::eom;
60  return P_SATISFIABLE;
61  }
62  else
63  {
64  messaget::status() << "Squolem: INVALID" << messaget::eom;
65  return P_UNSATISFIABLE;
66  }
67 
68  return P_ERROR;
69 }
70 
71 void qbf_squolemt::lcnf(const bvt &bv)
72 {
73  if(early_decision)
74  return; // we don't need no more...
75 
76  bvt new_bv;
77 
78  if(process_clause(bv, new_bv))
79  return;
80 
81  if(new_bv.empty())
82  {
83  early_decision=true;
84  return;
85  }
86 
87  std::vector<Literal> buffer(new_bv.size());
88  unsigned long i=0;
89  do
90  {
91  buffer[i]=new_bv[i].dimacs();
92  i++;
93  }
94  while(i<new_bv.size());
95 
96  if(!squolem.addClause(buffer))
97  early_decision=true;
98 }
99 
101 {
102  squolem.quantifyVariableInner(
103  quantifier.var_no,
104  quantifier.type==quantifiert::UNIVERSAL);
105 
106  qdimacs_cnft::add_quantifier(quantifier); // necessary?
107 }
108 
110 {
111  squolem.setLastVariable(no+1);
113 }
114 
116  const quantifiert::typet type,
117  const literalt l)
118 {
120  squolem.requantifyVariable(l.var_no(), type==quantifiert::UNIVERSAL);
121 }
bool process_clause(const bvt &bv, bvt &dest) const
filter 'true' from clause, eliminate duplicates, recognise trivially satisfied clauses
Definition: cnf.cpp:424
virtual void set_no_variables(size_t no)
Definition: cnf.h:43
virtual size_t no_variables() const override
Definition: cnf.h:42
var_not var_no() const
Definition: literal.h:83
mstreamt & status() const
Definition: message.h:406
static eomt eom
Definition: message.h:289
resultt
Definition: prop.h:101
resultt prop_solve() override
Definition: qbf_squolem.cpp:34
std::string solver_text() const override
Definition: qbf_squolem.cpp:29
Squolem2 squolem
Definition: qbf_squolem.h:22
bool early_decision
Definition: qbf_squolem.h:23
~qbf_squolemt() override
Definition: qbf_squolem.cpp:19
tvt l_get(literalt a) const override
Definition: qbf_squolem.cpp:24
void set_no_variables(size_t no) override
void set_quantifier(const quantifiert::typet type, const literalt l) override
virtual size_t no_clauses() const
Definition: qbf_squolem.h:37
void add_quantifier(const quantifiert &quantifier) override
void lcnf(const bvt &bv) override
Definition: qbf_squolem.cpp:71
virtual void add_quantifier(const quantifiert &quantifier)
Definition: qdimacs_cnf.h:64
virtual void set_quantifier(const quantifiert::typet type, const literalt l)
Definition: qdimacs_cnf.cpp:73
Definition: threeval.h:20
std::vector< literalt > bvt
Definition: literal.h:201
Squolem Backend.
#define UNREACHABLE
This should be used to mark dead code.
Definition: invariant.h:525
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.