mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add option divModWithSlacks
This commit is contained in:
@@ -112,6 +112,13 @@ struct ModelCheckerTargets
|
||||
struct ModelCheckerSettings
|
||||
{
|
||||
ModelCheckerContracts contracts = ModelCheckerContracts::Default();
|
||||
/// Currently division and modulo are replaced by multiplication with slack vars, such that
|
||||
/// a / b <=> a = b * k + m
|
||||
/// where k and m are slack variables.
|
||||
/// This is the default because Spacer prefers that over precise / and mod.
|
||||
/// This option allows disabling this mechanism since other solvers
|
||||
/// might prefer the precise encoding.
|
||||
bool divModNoSlacks = false;
|
||||
ModelCheckerEngine engine = ModelCheckerEngine::None();
|
||||
bool showUnproved = false;
|
||||
smtutil::SMTSolverChoice solvers = smtutil::SMTSolverChoice::All();
|
||||
@@ -123,6 +130,7 @@ struct ModelCheckerSettings
|
||||
{
|
||||
return
|
||||
contracts == _other.contracts &&
|
||||
divModNoSlacks == _other.divModNoSlacks &&
|
||||
engine == _other.engine &&
|
||||
showUnproved == _other.showUnproved &&
|
||||
solvers == _other.solvers &&
|
||||
|
||||
@@ -1916,6 +1916,9 @@ pair<smtutil::Expression, smtutil::Expression> SMTEncoder::divModWithSlacks(
|
||||
IntegerType const& _type
|
||||
)
|
||||
{
|
||||
if (m_settings.divModNoSlacks)
|
||||
return {_left / _right, _left % _right};
|
||||
|
||||
IntegerType const* intType = &_type;
|
||||
string suffix = "div_mod_" + to_string(m_context.newUniqueId());
|
||||
smt::SymbolicIntVariable dSymb(intType, intType, "d_" + suffix, m_context);
|
||||
|
||||
Reference in New Issue
Block a user