Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyex Optimisations Iteration 2 #113

Merged
merged 7 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleaning; comments; mimor fix
  • Loading branch information
vhavlena committed Jan 16, 2024
commit 8de5f2c8a4a9675d589a8a0998413e6544712b65
2 changes: 1 addition & 1 deletion src/smt/theory_str_noodler/expr_cases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bool is_replace_indexof(expr* rpl_str, expr* rpl_find, ast_manager& m, seq_util&
if(m_util_s.str.is_extract(rpl_str, sub_str, sub_start, sub_len)) {
expr*ind_str = nullptr, *ind_find = nullptr, *ind_start = nullptr, *add = nullptr;
rational one(1);
if(m_util_a.is_zero(sub_start) && m_util_a.is_add(sub_len, add, ind) && m_util_a.is_numeral(add, one) && m_util_s.str.is_index(ind, ind_str, ind_find, ind_start)) {
if(m_util_a.is_zero(sub_start) && m_util_a.is_add(sub_len, add, ind) && m_util_a.is_numeral(add, one) && m_util_s.str.is_index(ind, ind_str, ind_find, ind_start) && one.get_int32() == 1) {
if(ind_find->hash() != rpl_find->hash() || sub_str->hash() != ind_str->hash() || !m_util_a.is_zero(ind_start)) {
return false;
}
Expand Down
27 changes: 25 additions & 2 deletions src/smt/theory_str_noodler/expr_cases.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,33 @@ namespace smt::noodler::expr_cases {
*/
bool is_contains_index(expr* e, expr*& ind, ast_manager& m, seq_util& m_util_s, arith_util& m_util_a);


/**
* @brief Check if the given constraint @p rpl_str is of the form
* (str.substr s 0 (1 + str.indexof s ( @p rpl_find ) 0))
*
* @param rpl_str Constraint of the replace
* @param rpl_find Replace find
* @param m Ast manager
* @param m_util_s string ast util
* @param m_util_a arith ast util
* @param[out] ind Extracted (str.indexof s ( @p rpl_find ) 0)
* @return true <-> if of the particular form.
*/
bool is_replace_indexof(expr* rpl_str, expr* rpl_find, ast_manager& m, seq_util& m_util_s, arith_util& m_util_a, expr*& ind);


/**
* @brief Check if the given contraint @p e is of the form
* (( @p val ) + (str.indexof ( @p index_str ) ( @p ind_find ) n )
*
* @param e Constraint to be checked
* @param index_str Required index of parameter
* @param m Ast manager
* @param m_util_s string ast util
* @param m_util_a arith ast util
* @param[out] val Extracted addition value
* @param[out] ind_find Extracted indexof find
* @return true <-> if of the particular form.
*/
bool is_indexof_add(expr* e, expr* index_str, ast_manager& m, seq_util& m_util_s, arith_util& m_util_a, expr*& val, expr*& ind_find);


Expand Down
10 changes: 0 additions & 10 deletions src/smt/theory_str_noodler/theory_str_noodler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1127,10 +1127,6 @@ namespace smt::noodler {
expr_ref zero(m_util_a.mk_int(0), m);
expr_ref eps(m_util_s.str.mk_string(""), m);

// expr_ref iplusl(m_util_a.mk_add(l, i), m);
// m_rewrite(iplusl);
// literal nopost = mk_literal(m_util_a.mk_ge(m_util_a.mk_sub(iplusl, ls), zero));

literal i_ge_0 = mk_literal(m_util_a.mk_ge(i, zero));
literal ls_le_i = mk_literal(m_util_a.mk_le(mk_sub(i, ls), zero));
literal li_ge_ls = mk_literal(m_util_a.mk_ge(ls_minus_i_l, zero));
Expand Down Expand Up @@ -1240,8 +1236,6 @@ namespace smt::noodler {
// substr(s, i, n) = v
add_axiom({mk_eq(v, e, false)});

// add_axiom({~nopost, mk_eq(y, eps, false)});

// add the replacement substr -> v
this->predicate_replace.insert(e, v.get());
// update length variables
Expand Down Expand Up @@ -1370,8 +1364,6 @@ namespace smt::noodler {
expr_ref zero(m_util_a.mk_int(0), m);
expr_ref eps(m_util_s.str.mk_string(""), m);

// expr_ref iplusl(m_util_a.mk_add(i, l), m);
// literal nopost = mk_literal(m_util_a.mk_ge(m_util_a.mk_sub(iplusl, ls), zero));
literal i_ge_0 = mk_literal(m_util_a.mk_ge(i, zero));
literal ls_le_i = mk_literal(m_util_a.mk_le(mk_sub(i, ls), zero));
literal li_ge_ls = mk_literal(m_util_a.mk_ge(ls_minus_i_l, zero));
Expand Down Expand Up @@ -1407,8 +1399,6 @@ namespace smt::noodler {
// substr(s, i, n) = v
add_axiom({mk_eq(v, e, false)});

// add_axiom({~nopost, mk_eq(y, eps, false)});

// add the replacement substr -> v
this->predicate_replace.insert(e, v.get());
// update length variables
Expand Down