diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index cc164ec3b..4918c999b 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -27,6 +27,10 @@ namespace smt { theory_str::theory_str(ast_manager & m): theory(m.mk_family_id("str")), + /* Options */ + opt_AggressiveLengthTesting(true), + opt_AggressiveValueTesting(true), + /* Internal setup */ search_started(false), m_autil(m), m_strutil(m), @@ -344,6 +348,14 @@ void theory_str::check_and_init_cut_var(expr * node) { } } +literal theory_str::mk_literal(expr* _e) { + ast_manager & m = get_manager(); + expr_ref e(_e, m); + context& ctx = get_context(); + ensure_enode(e); + return ctx.get_literal(e); +} + app * theory_str::mk_int(int n) { return m_autil.mk_numeral(rational(n), true); } @@ -3513,6 +3525,160 @@ inline expr * theory_str::getMostRightNodeInConcat(expr * node) { } } +void theory_str::trace_ctx_dep(std::ofstream & tout, + std::map & aliasIndexMap, + std::map & var_eq_constStr_map, + std::map > & var_eq_concat_map, + std::map & concat_eq_constStr_map, + std::map > & concat_eq_concat_map) { +#ifdef _TRACE + ast_manager & mgr = get_manager(); + { + tout << "(0) alias: variables" << std::endl; + std::map > aliasSumMap; + std::map::iterator itor0 = aliasIndexMap.begin(); + for (; itor0 != aliasIndexMap.end(); itor0++) { + aliasSumMap[itor0->second][itor0->first] = 1; + } + std::map >::iterator keyItor = aliasSumMap.begin(); + for (; keyItor != aliasSumMap.end(); keyItor++) { + tout << " * "; + tout << mk_pp(keyItor->first, mgr); + tout << " : "; + std::map::iterator innerItor = keyItor->second.begin(); + for (; innerItor != keyItor->second.end(); innerItor++) { + tout << mk_pp(innerItor->first, mgr); + tout << ", "; + } + tout << std::endl; + } + tout << std::endl; + } + + { + tout << "(1) var = constStr:" << std::endl; + std::map::iterator itor1 = var_eq_constStr_map.begin(); + for (; itor1 != var_eq_constStr_map.end(); itor1++) { + tout << " * "; + tout << mk_pp(itor1->first, mgr); + tout << " = "; + tout << mk_pp(itor1->second, mgr); + if (!in_same_eqc(itor1->first, itor1->second)) { + tout << " (not true in ctx)"; + } + tout << std::endl; + } + tout << std::endl; + } + + { + tout << "(2) var = concat:" << std::endl; + std::map >::iterator itor2 = var_eq_concat_map.begin(); + for (; itor2 != var_eq_concat_map.end(); itor2++) { + tout << " * "; + tout << mk_pp(itor2->first, mgr); + tout << " = { "; + std::map::iterator i_itor = itor2->second.begin(); + for (; i_itor != itor2->second.end(); i_itor++) { + tout << mk_pp(i_itor->first, mgr); + tout << ", "; + } + tout << std::endl; + } + tout << std::endl; + } +/*// TODO + { + __debugPrint(logFile, "(3) var = unrollFunc:\n"); + std::map >::iterator itor2 = var_eq_unroll_map.begin(); + for (; itor2 != var_eq_unroll_map.end(); itor2++) { + __debugPrint(logFile, " * "); + printZ3Node(t, itor2->first); + __debugPrint(logFile, " = { "); + std::map::iterator i_itor = itor2->second.begin(); + for (; i_itor != itor2->second.end(); i_itor++) { + printZ3Node(t, i_itor->first); + __debugPrint(logFile, ", "); + } + __debugPrint(logFile, " }\n"); + } + __debugPrint(logFile, "\n"); + } +*/ + { + tout << "(4) concat = constStr:" << std::endl; + std::map::iterator itor3 = concat_eq_constStr_map.begin(); + for (; itor3 != concat_eq_constStr_map.end(); itor3++) { + tout << " * "; + tout << mk_pp(itor3->first, mgr); + tout << " = "; + tout << mk_pp(itor3->second, mgr); + tout << std::endl; + + } + tout << std::endl; + } + + { + tout << "(5) eq concats:" << std::endl; + std::map >::iterator itor4 = concat_eq_concat_map.begin(); + for (; itor4 != concat_eq_concat_map.end(); itor4++) { + if (itor4->second.size() > 1) { + std::map::iterator i_itor = itor4->second.begin(); + tout << " * "; + for (; i_itor != itor4->second.end(); i_itor++) { + tout << mk_pp(i_itor->first, mgr); + tout << " , "; + } + tout << std::endl; + } + } + tout << std::endl; + } +/*// TODO + { + __debugPrint(logFile, "(6) eq unrolls:\n"); + std::map >::iterator itor5 = unrollGroupMap.begin(); + for (; itor5 != unrollGroupMap.end(); itor5++) { + __debugPrint(logFile, " * "); + std::set::iterator i_itor = itor5->second.begin(); + for (; i_itor != itor5->second.end(); i_itor++) { + printZ3Node(t, *i_itor); + __debugPrint(logFile, ", "); + } + __debugPrint(logFile, "\n"); + } + __debugPrint(logFile, "\n"); + } + + { + __debugPrint(logFile, "(7) unroll = concats:\n"); + std::map >::iterator itor5 = unrollGroupMap.begin(); + for (; itor5 != unrollGroupMap.end(); itor5++) { + __debugPrint(logFile, " * "); + Z3_ast unroll = itor5->first; + printZ3Node(t, unroll); + __debugPrint(logFile, "\n"); + Z3_ast curr = unroll; + do { + if (isConcatFunc(t, curr)) { + __debugPrint(logFile, " >>> "); + printZ3Node(t, curr); + __debugPrint(logFile, "\n"); + } + curr = Z3_theory_get_eqc_next(t, curr); + }while (curr != unroll); + __debugPrint(logFile, "\n"); + } + __debugPrint(logFile, "\n"); + } + */ +#else + return; +#endif // _TRACE +} + + /* * Dependence analysis from current context assignment * - "freeVarMap" contains a set of variables that doesn't constrained by Concats. @@ -3747,7 +3913,9 @@ int theory_str::ctx_dep_analysis(std::map & strVarMap, std::map & strVarMap, std::map & freeVarMap, std::map > & unrollGroupMap); + void trace_ctx_dep(std::ofstream & tout, + std::map & aliasIndexMap, + std::map & var_eq_constStr_map, + std::map > & var_eq_concat_map, + std::map & concat_eq_constStr_map, + std::map > & concat_eq_concat_map); + void classify_ast_by_type(expr * node, std::map & varMap, std::map & concatMap, std::map & unrollMap); void classify_ast_by_type_in_positive_context(std::map & varMap,