CBMC
Loading...
Searching...
No Matches
satcheck_lingeling.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module:
4
5Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk
6
7\*******************************************************************/
8
10
11#include <algorithm>
12
13#include <util/invariant.h>
14#include <util/threeval.h>
15
16extern "C"
17{
18#include <lglib.h>
19}
20
21#ifndef HAVE_LINGELING
22#error "Expected HAVE_LINGELING"
23#endif
24
26{
27 if(a.is_constant())
28 return tvt(a.sign());
29
30 tvt result;
31
32 if(a.var_no()>lglmaxvar(solver))
34
35 const int val=lglderef(solver, a.dimacs());
36 if(val>0)
37 result=tvt(true);
38 else if(val<0)
39 result=tvt(false);
40 else
42
43 return result;
44}
45
47{
48 return "Lingeling";
49}
50
52{
53 bvt new_bv;
54
55 if(process_clause(bv, new_bv))
56 return;
57
58 for(const auto &literal : new_bv)
59 lgladd(solver, literal.dimacs());
60
61 lgladd(solver, 0);
62
64}
65
67{
69
70 // We start counting at 1, thus there is one variable fewer.
71 {
72 std::string msg=
73 std::to_string(no_variables()-1)+" variables, "+
74 std::to_string(clause_counter)+" clauses";
76 }
77
78 std::string msg;
79
80 for(const auto &literal : assumptions)
81 if(!literal.is_true())
82 lglassume(solver, literal.dimacs());
83
84 const int res=lglsat(solver);
85 CHECK_RETURN(res == 10 || res == 20);
86
87 if(res==10)
88 {
89 msg="SAT checker: instance is SATISFIABLE";
91 status=SAT;
92 return P_SATISFIABLE;
93 }
94 else
95 {
96 INVARIANT(res == 20, "result value is either 10 or 20");
97 msg="SAT checker: instance is UNSATISFIABLE";
99 }
100
102 return P_UNSATISFIABLE;
103}
104
109
114
120
122{
123 if(!a.is_constant())
124 lglfreeze(solver, a.dimacs());
125}
126
132{
133 PRECONDITION(!a.is_constant());
134 return lglfailed(solver, a.dimacs())!=0;
135}
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
statust status
Definition cnf.h:87
size_t clause_counter
Definition cnf.h:88
bool process_clause(const bvt &bv, bvt &dest) const
filter 'true' from clause, eliminate duplicates, recognise trivially satisfied clauses
Definition cnf.cpp:424
virtual size_t no_variables() const override
Definition cnf.h:42
mstreamt & statistics() const
Definition message.h:411
static eomt eom
Definition message.h:289
mstreamt & status() const
Definition message.h:406
resultt
Definition prop.h:101
messaget log
Definition prop.h:134
void lcnf(const bvt &bv) override
tvt l_get(literalt a) const override
resultt do_prop_solve(const bvt &assumptions) override
void set_assignment(literalt a, bool value) override
std::string solver_text() const override
void set_frozen(literalt a) override
bool is_in_conflict(literalt a) const override
Returns true if an assumed literal is in conflict if the formula is UNSAT.
Definition threeval.h:20
std::vector< literalt > bvt
Definition literal.h:201
void solver(std::vector< framet > &frames, const std::unordered_set< symbol_exprt, irep_hash > &address_taken, const solver_optionst &solver_options, const namespacet &ns, std::vector< propertyt > &properties, std::size_t property_index)
Definition solver.cpp:44
#define CHECK_RETURN(CONDITION)
Definition invariant.h:495
#define UNREACHABLE
This should be used to mark dead code.
Definition invariant.h:525
#define PRECONDITION(CONDITION)
Definition invariant.h:463
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
Definition invariant.h:423