GCC Code Coverage Report
Directory: . Exec Total Coverage
File: build-coverage/src/options/bv_options.cpp Lines: 20 130 15.4 %
Date: 2021-09-16 Branches: 26 146 17.8 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Mathias Preiner, Aina Niemetz
4
 *
5
 * This file is part of the cvc5 project.
6
 *
7
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
8
 * in the top-level source directory and their institutional affiliations.
9
 * All rights reserved.  See the file COPYING in the top-level source
10
 * directory for licensing information.
11
 * ****************************************************************************
12
 *
13
 * Option template for option modules.
14
 *
15
 * For each <module>_options.toml configuration file, mkoptions.py
16
 * expands this template and generates a <module>_options.cpp file.
17
 */
18
#include "options/bv_options.h"
19
20
#include <iostream>
21
22
#include "base/check.h"
23
#include "options/option_exception.h"
24
25
namespace cvc5::options {
26
27
// clang-format off
28
std::ostream& operator<<(std::ostream& os, BitblastMode mode)
29
{
30
  switch(mode)
31
  {
32
    case BitblastMode::LAZY: return os << "BitblastMode::LAZY";
33
    case BitblastMode::EAGER: return os << "BitblastMode::EAGER";
34
    default: Unreachable();
35
  }
36
  return os;
37
}
38
43
BitblastMode stringToBitblastMode(const std::string& optarg)
39
{
40
43
  if (optarg == "lazy") return BitblastMode::LAZY;
41
41
  else if (optarg == "eager") return BitblastMode::EAGER;
42
  else if (optarg == "help")
43
  {
44
    std::cerr << R"FOOBAR(
45
  Bit-blasting modes.
46
Available modes for --bitblast are:
47
+ lazy (default)
48
  Separate boolean structure and term reasoning between the core SAT solver and
49
  the bit-vector SAT solver.
50
+ eager
51
  Bitblast eagerly to bit-vector SAT solver.
52
)FOOBAR";
53
    std::exit(1);
54
  }
55
  throw OptionException(std::string("unknown option for --bitblast: `") +
56
                        optarg + "'.  Try --bitblast=help.");
57
}
58
std::ostream& operator<<(std::ostream& os, BoolToBVMode mode)
59
{
60
  switch(mode)
61
  {
62
    case BoolToBVMode::OFF: return os << "BoolToBVMode::OFF";
63
    case BoolToBVMode::ITE: return os << "BoolToBVMode::ITE";
64
    case BoolToBVMode::ALL: return os << "BoolToBVMode::ALL";
65
    default: Unreachable();
66
  }
67
  return os;
68
}
69
12
BoolToBVMode stringToBoolToBVMode(const std::string& optarg)
70
{
71
12
  if (optarg == "off") return BoolToBVMode::OFF;
72
12
  else if (optarg == "ite") return BoolToBVMode::ITE;
73
8
  else if (optarg == "all") return BoolToBVMode::ALL;
74
  else if (optarg == "help")
75
  {
76
    std::cerr << R"FOOBAR(
77
  BoolToBV preprocessing pass modes.
78
Available modes for --bool-to-bv are:
79
+ off (default)
80
  Don't push any booleans to width one bit-vectors.
81
+ ite
82
  Try to turn ITEs into BITVECTOR_ITE when possible. It can fail per-formula if
83
  not all sub-formulas can be turned to bit-vectors.
84
+ all
85
  Force all booleans to be bit-vectors of width one except at the top level.
86
  Most aggressive mode.
87
)FOOBAR";
88
    std::exit(1);
89
  }
90
  throw OptionException(std::string("unknown option for --bool-to-bv: `") +
91
                        optarg + "'.  Try --bool-to-bv=help.");
92
}
93
std::ostream& operator<<(std::ostream& os, SatSolverMode mode)
94
{
95
  switch(mode)
96
  {
97
    case SatSolverMode::MINISAT: return os << "SatSolverMode::MINISAT";
98
    case SatSolverMode::CADICAL: return os << "SatSolverMode::CADICAL";
99
    case SatSolverMode::CRYPTOMINISAT: return os << "SatSolverMode::CRYPTOMINISAT";
100
    case SatSolverMode::KISSAT: return os << "SatSolverMode::KISSAT";
101
    default: Unreachable();
102
  }
103
  return os;
104
}
105
18
SatSolverMode stringToSatSolverMode(const std::string& optarg)
106
{
107
18
  if (optarg == "minisat") return SatSolverMode::MINISAT;
108
16
  else if (optarg == "cadical") return SatSolverMode::CADICAL;
109
12
  else if (optarg == "cryptominisat") return SatSolverMode::CRYPTOMINISAT;
110
2
  else if (optarg == "kissat") return SatSolverMode::KISSAT;
111
2
  else if (optarg == "help")
112
  {
113
    std::cerr << R"FOOBAR(
114
  SAT solver for bit-blasting backend.
115
Available modes for --bv-sat-solver are:
116
)FOOBAR";
117
    std::exit(1);
118
  }
119
4
  throw OptionException(std::string("unknown option for --bv-sat-solver: `") +
120
6
                        optarg + "'.  Try --bv-sat-solver=help.");
121
}
122
std::ostream& operator<<(std::ostream& os, BVSolver mode)
123
{
124
  switch(mode)
125
  {
126
    case BVSolver::BITBLAST: return os << "BVSolver::BITBLAST";
127
    case BVSolver::BITBLAST_INTERNAL: return os << "BVSolver::BITBLAST_INTERNAL";
128
    case BVSolver::LAYERED: return os << "BVSolver::LAYERED";
129
    default: Unreachable();
130
  }
131
  return os;
132
}
133
48
BVSolver stringToBVSolver(const std::string& optarg)
134
{
135
48
  if (optarg == "bitblast") return BVSolver::BITBLAST;
136
24
  else if (optarg == "bitblast-internal") return BVSolver::BITBLAST_INTERNAL;
137
4
  else if (optarg == "layered") return BVSolver::LAYERED;
138
  else if (optarg == "help")
139
  {
140
    std::cerr << R"FOOBAR(
141
  Bit-vector solvers.
142
Available modes for --bv-solver are:
143
+ bitblast (default)
144
  Enables bitblasting solver.
145
+ bitblast-internal
146
  Enables bitblasting to internal SAT solver with proof support.
147
+ layered
148
  Enables the layered BV solver.
149
)FOOBAR";
150
    std::exit(1);
151
  }
152
  throw OptionException(std::string("unknown option for --bv-solver: `") +
153
                        optarg + "'.  Try --bv-solver=help.");
154
}
155
// clang-format on
156
157
namespace bv
158
{
159
// clang-format off
160
void setDefaultBitblastMode(Options& opts, BitblastMode value)
161
{
162
    if (!opts.bv.bitblastModeWasSetByUser) opts.bv.bitblastMode = value;
163
}
164
void setDefaultBitvectorAig(Options& opts, bool value)
165
{
166
    if (!opts.bv.bitvectorAigWasSetByUser) opts.bv.bitvectorAig = value;
167
}
168
void setDefaultBitwiseEq(Options& opts, bool value)
169
{
170
    if (!opts.bv.bitwiseEqWasSetByUser) opts.bv.bitwiseEq = value;
171
}
172
void setDefaultBoolToBitvector(Options& opts, BoolToBVMode value)
173
{
174
    if (!opts.bv.boolToBitvectorWasSetByUser) opts.bv.boolToBitvector = value;
175
}
176
void setDefaultBvAbstraction(Options& opts, bool value)
177
{
178
    if (!opts.bv.bvAbstractionWasSetByUser) opts.bv.bvAbstraction = value;
179
}
180
void setDefaultBitvectorAigSimplifications(Options& opts, std::string value)
181
{
182
    if (!opts.bv.bitvectorAigSimplificationsWasSetByUser) opts.bv.bitvectorAigSimplifications = value;
183
}
184
void setDefaultBitvectorAlgebraicBudget(Options& opts, uint64_t value)
185
{
186
    if (!opts.bv.bitvectorAlgebraicBudgetWasSetByUser) opts.bv.bitvectorAlgebraicBudget = value;
187
}
188
void setDefaultBitvectorAlgebraicSolver(Options& opts, bool value)
189
{
190
    if (!opts.bv.bitvectorAlgebraicSolverWasSetByUser) opts.bv.bitvectorAlgebraicSolver = value;
191
}
192
void setDefaultBvAssertInput(Options& opts, bool value)
193
{
194
    if (!opts.bv.bvAssertInputWasSetByUser) opts.bv.bvAssertInput = value;
195
}
196
void setDefaultBvEagerExplanations(Options& opts, bool value)
197
{
198
    if (!opts.bv.bvEagerExplanationsWasSetByUser) opts.bv.bvEagerExplanations = value;
199
}
200
void setDefaultBitvectorEqualitySolver(Options& opts, bool value)
201
{
202
    if (!opts.bv.bitvectorEqualitySolverWasSetByUser) opts.bv.bitvectorEqualitySolver = value;
203
}
204
void setDefaultBvExtractArithRewrite(Options& opts, bool value)
205
{
206
    if (!opts.bv.bvExtractArithRewriteWasSetByUser) opts.bv.bvExtractArithRewrite = value;
207
}
208
void setDefaultBvGaussElim(Options& opts, bool value)
209
{
210
    if (!opts.bv.bvGaussElimWasSetByUser) opts.bv.bvGaussElim = value;
211
}
212
void setDefaultBitvectorInequalitySolver(Options& opts, bool value)
213
{
214
    if (!opts.bv.bitvectorInequalitySolverWasSetByUser) opts.bv.bitvectorInequalitySolver = value;
215
}
216
void setDefaultBvIntroducePow2(Options& opts, bool value)
217
{
218
    if (!opts.bv.bvIntroducePow2WasSetByUser) opts.bv.bvIntroducePow2 = value;
219
}
220
void setDefaultBvNumFunc(Options& opts, uint64_t value)
221
{
222
    if (!opts.bv.bvNumFuncWasSetByUser) opts.bv.bvNumFunc = value;
223
}
224
void setDefaultBvPrintConstsAsIndexedSymbols(Options& opts, bool value)
225
{
226
    if (!opts.bv.bvPrintConstsAsIndexedSymbolsWasSetByUser) opts.bv.bvPrintConstsAsIndexedSymbols = value;
227
}
228
void setDefaultBitvectorPropagate(Options& opts, bool value)
229
{
230
    if (!opts.bv.bitvectorPropagateWasSetByUser) opts.bv.bitvectorPropagate = value;
231
}
232
void setDefaultBitvectorQuickXplain(Options& opts, bool value)
233
{
234
    if (!opts.bv.bitvectorQuickXplainWasSetByUser) opts.bv.bitvectorQuickXplain = value;
235
}
236
void setDefaultBvSatSolver(Options& opts, SatSolverMode value)
237
{
238
    if (!opts.bv.bvSatSolverWasSetByUser) opts.bv.bvSatSolver = value;
239
}
240
void setDefaultSkolemizeArguments(Options& opts, bool value)
241
{
242
    if (!opts.bv.skolemizeArgumentsWasSetByUser) opts.bv.skolemizeArguments = value;
243
}
244
void setDefaultBvSolver(Options& opts, BVSolver value)
245
{
246
    if (!opts.bv.bvSolverWasSetByUser) opts.bv.bvSolver = value;
247
}
248
void setDefaultBitvectorToBool(Options& opts, bool value)
249
{
250
    if (!opts.bv.bitvectorToBoolWasSetByUser) opts.bv.bitvectorToBool = value;
251
}
252
// clang-format on
253
}
254
255
29577
}  // namespace cvc5::options