From 0e956da9b32ce8a8fcf20ec65e5a2820b4e31324 Mon Sep 17 00:00:00 2001 From: ajreynol Date: Wed, 7 Dec 2016 10:18:16 -0600 Subject: [PATCH] Fix nf exp tracking for non-linear string equalities, fixes bug 768. --- src/theory/strings/theory_strings.cpp | 40 +++++++++++++++-------- test/regress/regress0/strings/Makefile.am | 3 +- test/regress/regress0/strings/bug768.smt2 | 10 ++++++ 3 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 test/regress/regress0/strings/bug768.smt2 diff --git a/src/theory/strings/theory_strings.cpp b/src/theory/strings/theory_strings.cpp index 8b44b5cac..db07a0b51 100644 --- a/src/theory/strings/theory_strings.cpp +++ b/src/theory/strings/theory_strings.cpp @@ -2071,6 +2071,27 @@ void TheoryStrings::normalizeEquivalenceClass( Node eqc ) { } } +void trackNfExpDependency( std::vector< Node >& nf_exp_n, std::map< Node, std::map< bool, int > >& nf_exp_depend_n, Node exp, int new_val, int new_rev_val ){ + if( std::find( nf_exp_n.begin(), nf_exp_n.end(), exp )==nf_exp_n.end() ){ + nf_exp_n.push_back( exp ); + } + for( unsigned k=0; k<2; k++ ){ + int val = k==0 ? new_val : new_rev_val; + std::map< bool, int >::iterator itned = nf_exp_depend_n[exp].find( k==1 ); + if( itned==nf_exp_depend_n[exp].end() ){ + Trace("strings-process-debug") << "Deps : set dependency on " << exp << " to " << val << " isRev=" << (k==0) << std::endl; + nf_exp_depend_n[exp][k==1] = val; + }else{ + Trace("strings-process-debug") << "Deps : Multiple dependencies on " << exp << " : " << itned->second << " " << val << " isRev=" << (k==0) << std::endl; + //if we already have a dependency (in the case of non-linear string equalities), it is min/max + bool cmp = val > itned->second; + if( cmp==(k==1) ){ + nf_exp_depend_n[exp][k==1] = val; + } + } + } +} + void TheoryStrings::getNormalForms( Node &eqc, std::vector< std::vector< Node > > &normal_forms, std::vector< Node > &normal_form_src, std::vector< std::vector< Node > > &normal_forms_exp, std::vector< std::map< Node, std::map< bool, int > > >& normal_forms_exp_depend ) { //constant for equivalence class @@ -2115,25 +2136,16 @@ void TheoryStrings::getNormalForms( Node &eqc, std::vector< std::vector< Node > for( unsigned j=0; j