mirror of
https://github.com/Z3Prover/z3
synced 2025-06-20 04:43:39 +00:00
z3str3: add smt.str.fixed_length_naive_cex option for naive length-based counterexamples
This commit is contained in:
parent
c1e7d7788e
commit
cf3f271f5b
4 changed files with 39 additions and 21 deletions
|
@ -92,6 +92,7 @@ def_module_params(module_name='smt',
|
||||||
('str.regex_automata_length_attempt_threshold', UINT, 10, 'number of length/path constraint attempts before checking unsatisfiability of regex terms'),
|
('str.regex_automata_length_attempt_threshold', UINT, 10, 'number of length/path constraint attempts before checking unsatisfiability of regex terms'),
|
||||||
('str.fixed_length_models', BOOL, True, 'use fixed-length equation solver to construct models (Z3str3 only)'),
|
('str.fixed_length_models', BOOL, True, 'use fixed-length equation solver to construct models (Z3str3 only)'),
|
||||||
('str.fixed_length_refinement', BOOL, False, 'use abstraction refinement in fixed-length equation solver (Z3str3 only)'),
|
('str.fixed_length_refinement', BOOL, False, 'use abstraction refinement in fixed-length equation solver (Z3str3 only)'),
|
||||||
|
('str.fixed_length_naive_cex', BOOL, True, 'construct naive counterexamples when fixed-length model construction fails for a given length assignment (Z3str3 only)'),
|
||||||
('core.minimize', BOOL, False, 'minimize unsat core produced by SMT context'),
|
('core.minimize', BOOL, False, 'minimize unsat core produced by SMT context'),
|
||||||
('core.extend_patterns', BOOL, False, 'extend unsat core with literals that trigger (potential) quantifier instances'),
|
('core.extend_patterns', BOOL, False, 'extend unsat core with literals that trigger (potential) quantifier instances'),
|
||||||
('core.extend_patterns.max_distance', UINT, UINT_MAX, 'limits the distance of a pattern-extended unsat core'),
|
('core.extend_patterns.max_distance', UINT, UINT_MAX, 'limits the distance of a pattern-extended unsat core'),
|
||||||
|
|
|
@ -39,6 +39,7 @@ void theory_str_params::updt_params(params_ref const & _p) {
|
||||||
m_RegexAutomata_LengthAttemptThreshold = p.str_regex_automata_length_attempt_threshold();
|
m_RegexAutomata_LengthAttemptThreshold = p.str_regex_automata_length_attempt_threshold();
|
||||||
m_FixedLengthModels = p.str_fixed_length_models();
|
m_FixedLengthModels = p.str_fixed_length_models();
|
||||||
m_FixedLengthRefinement = p.str_fixed_length_refinement();
|
m_FixedLengthRefinement = p.str_fixed_length_refinement();
|
||||||
|
m_FixedLengthNaiveCounterexamples = p.str_fixed_length_naive_cex();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DISPLAY_PARAM(X) out << #X"=" << X << std::endl;
|
#define DISPLAY_PARAM(X) out << #X"=" << X << std::endl;
|
||||||
|
@ -61,4 +62,5 @@ void theory_str_params::display(std::ostream & out) const {
|
||||||
DISPLAY_PARAM(m_RegexAutomata_FailedIntersectionThreshold);
|
DISPLAY_PARAM(m_RegexAutomata_FailedIntersectionThreshold);
|
||||||
DISPLAY_PARAM(m_RegexAutomata_LengthAttemptThreshold);
|
DISPLAY_PARAM(m_RegexAutomata_LengthAttemptThreshold);
|
||||||
DISPLAY_PARAM(m_FixedLengthModels);
|
DISPLAY_PARAM(m_FixedLengthModels);
|
||||||
|
DISPLAY_PARAM(m_FixedLengthNaiveCounterexamples);
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,13 @@ struct theory_str_params {
|
||||||
*/
|
*/
|
||||||
bool m_FixedLengthRefinement;
|
bool m_FixedLengthRefinement;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If FixedLengthNaiveCounterexamples is true and the fixed-length equation solver is enabled,
|
||||||
|
* Z3str3 will only construct simple counterexamples to block unsatisfiable length assignments
|
||||||
|
* instead of attempting to learn more complex lessons.
|
||||||
|
*/
|
||||||
|
bool m_FixedLengthNaiveCounterexamples;
|
||||||
|
|
||||||
theory_str_params(params_ref const & p = params_ref()):
|
theory_str_params(params_ref const & p = params_ref()):
|
||||||
m_StrongArrangements(true),
|
m_StrongArrangements(true),
|
||||||
m_AggressiveLengthTesting(false),
|
m_AggressiveLengthTesting(false),
|
||||||
|
@ -149,7 +156,8 @@ struct theory_str_params {
|
||||||
m_RegexAutomata_FailedIntersectionThreshold(10),
|
m_RegexAutomata_FailedIntersectionThreshold(10),
|
||||||
m_RegexAutomata_LengthAttemptThreshold(10),
|
m_RegexAutomata_LengthAttemptThreshold(10),
|
||||||
m_FixedLengthModels(true),
|
m_FixedLengthModels(true),
|
||||||
m_FixedLengthRefinement(false)
|
m_FixedLengthRefinement(false),
|
||||||
|
m_FixedLengthNaiveCounterexamples(true)
|
||||||
{
|
{
|
||||||
updt_params(p);
|
updt_params(p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -875,8 +875,14 @@ namespace smt {
|
||||||
|
|
||||||
return l_true;
|
return l_true;
|
||||||
} else if (subproblem_status == l_false) {
|
} else if (subproblem_status == l_false) {
|
||||||
// TODO replace this with something simpler for now
|
if (m_params.m_FixedLengthNaiveCounterexamples) {
|
||||||
NOT_IMPLEMENTED_YET();
|
TRACE("str_fl", tout << "subsolver found UNSAT; constructing length counterexample" << std::endl;);
|
||||||
|
for (auto e : fixed_length_used_len_terms) {
|
||||||
|
expr * var = &e.get_key();
|
||||||
|
cex.push_back(m.mk_eq(u.str.mk_length(var), mk_int(e.get_value())));
|
||||||
|
}
|
||||||
|
return l_false;
|
||||||
|
} else {
|
||||||
TRACE("str_fl", tout << "subsolver found UNSAT; reconstructing unsat core" << std::endl;);
|
TRACE("str_fl", tout << "subsolver found UNSAT; reconstructing unsat core" << std::endl;);
|
||||||
TRACE("str_fl", tout << "unsat core has size " << subsolver.get_unsat_core_size() << std::endl;);
|
TRACE("str_fl", tout << "unsat core has size " << subsolver.get_unsat_core_size() << std::endl;);
|
||||||
bool negate_pre = false;
|
bool negate_pre = false;
|
||||||
|
@ -898,6 +904,7 @@ namespace smt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return l_false;
|
return l_false;
|
||||||
|
}
|
||||||
} else { // l_undef
|
} else { // l_undef
|
||||||
TRACE("str_fl", tout << "WARNING: subsolver found UNKNOWN" << std::endl;);
|
TRACE("str_fl", tout << "WARNING: subsolver found UNKNOWN" << std::endl;);
|
||||||
return l_undef;
|
return l_undef;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue