// unused function set for deprecation // interesting code - it has annonymous function vector< tstamp_ptr > integer::get_trace(const z3::model& m) const { vector<tstamp_ptr> result; for (auto l : tstamp_map) result.push_back(get<1>(l)); sort(result.begin(), result.end(), [&](const tstamp_ptr & a, const tstamp_ptr & b) -> bool { return m.eval(((z3::expr)(*a)) > *b).get_bool(); }); return result; }
vector<hb_ptr> encoding::get_hbs( z3::model& m ) { vector<hb_ptr> result; //todo: how does the following code knows to read from which solver? // the following looks in the context, not in solver ?? z3::expr_vector asserted = z3.c.collect_last_asserted_linear_constr(); z3::expr_vector asserted_po = z3.c.collect_last_asserted_po_constr(); for( unsigned i = 0; i<asserted.size(); i++ ) { z3::expr atom = asserted[i]; auto hb = get_hb( atom ); if( hb && !hb->loc1->special && !hb->loc2->special && hb->loc1->thread != hb->loc2->thread ) { if( hb->e1 && hb->e2 ) { // for compatibility of the earlier version of tara z3::expr v1 = m.eval( hb->e1->guard ); z3::expr v2 = m.eval( hb->e2->guard ); if( Z3_get_bool_value( v1.ctx(), v1) != Z3_L_TRUE || Z3_get_bool_value( v2.ctx(), v2) != Z3_L_TRUE ) { continue; } } assert(eval_hb(m, hb->loc1, hb->loc2)); hb_ptr h = make_shared<hb_enc::hb>(*hb); result.push_back(h); } } for( unsigned i = 0; i < asserted_po.size(); i++ ) { z3::expr atom = asserted_po[i]; // std::cout << atom << std::endl; auto hb = get_hb( atom ); if( hb && !hb->loc1->special && !hb->loc2->special && hb->loc1->thread != hb->loc2->thread ) { if( hb->e1 && hb->e2 ) { // for compatibility of the earlier version of tara z3::expr v1 = m.eval( hb->e1->guard ); z3::expr v2 = m.eval( hb->e2->guard ); if( Z3_get_bool_value( v1.ctx(), v1) != Z3_L_TRUE || Z3_get_bool_value( v2.ctx(), v2) != Z3_L_TRUE ) { continue; } } hb_ptr h = make_shared<hb_enc::hb>(*hb); result.push_back(h); // std::cerr << atom << "\n"; } } // current_rf_map.clear(); //get rf hbs for( auto& it : rf_map ) { std::string bname = std::get<0>(it); z3::expr b = z3.c.bool_const( bname.c_str() ); z3::expr bv = m.eval( b ); if( Z3_get_bool_value( bv.ctx(), bv) == Z3_L_TRUE ) { hb_enc::se_ptr wr = std::get<1>(it); hb_enc::se_ptr rd = std::get<2>(it); // z3::expr bp = z3::implies(wr->guard && rd->guard, b ); // z3::expr bp = z3::implies(wr->guard, b ); z3::expr bp = b; hb_ptr h = make_shared<hb_enc::hb>(wr, rd, bp, false, hb_t::rf); result.push_back( h ); current_rf_map.insert( std::make_pair( bname, h ) ); } } return result; }
bool integer::eval_hb(const z3::model& model, hb_enc::tstamp_ptr loc1, hb_enc::tstamp_ptr loc2) const { return model.eval(make_hb(loc1, loc2)).get_bool(); }
bool integer::eval_hb(const z3::model& model, std::shared_ptr< const hb_enc::location > loc1, std::shared_ptr< const hb_enc::location > loc2) const { return model.eval(make_hb(loc1, loc2)).get_bool(); }