void CoreSMTSolver::verifyModel() { #ifdef DREAL_DEBUG bool failed = false; #endif for (int i = 0; i < clauses.size(); i++) { assert(clauses[i]->mark() == 0); Clause& c = *clauses[i]; for (int j = 0; j < c.size(); j++) if (modelValue(c[j]) == l_True || (config.nra_short_sat && modelValue(c[j]) != l_False)) goto next; reportf("unsatisfied clause: "); printClause(*clauses[i]); printSMTClause( cerr, *clauses[i] ); reportf("\n"); #ifdef DREAL_DEBUG failed = true; #endif next:; } #ifdef DREAL_DEBUG assert(!failed); #endif // Removed line // reportf("Verified %d original clauses.\n", clauses.size()); }
void CoreSMTSolver::dumpCNF( ) { const char * name = "cnf.smt2"; std::ofstream dump_out( name ); egraph.dumpHeaderToFile( dump_out ); dump_out << "(assert" << endl; dump_out << "(and" << endl; for ( int i = 0 ; i < clauses.size( ) ; i ++ ) { Clause & c = *clauses[ i ]; if ( c.mark( ) == 1 ) continue; printSMTClause( dump_out, c ); dump_out << endl; } // // Also dump the trail which contains clauses of size 1 // for ( int i = 0 ; i < trail.size( ) ; i ++ ) { Var v = var(trail[i]); if ( v <= 1 ) continue; Enode * e = theory_handler->varToEnode( v ); dump_out << (sign(trail[i])?"(not ":" ") << e << (sign(trail[i])?") ":" ") << endl; } dump_out << "))" << endl; dump_out << "(check-sat)" << endl; dump_out << "(exit)" << endl; dump_out.close( ); cerr << "[Dumped " << name << "]" << endl; }
// // Prints resolution proof graph to a dot file, // with proper colors // If skeleton is true then prints propositional variables, otherwise full SMT formulae void ProofGraph::printProofAsDotty( ostream & out, bool skeleton ) { // Visited nodes vector vector< bool > visited_dotty( graph.size( ), false ); // Visit proof graph from sink via DFS vector< ProofNode * > q; q.push_back(graph[root]); out << "digraph proof {" << endl; while( !q.empty( ) ) { ProofNode * node = q.back( ); // Remove node q.pop_back( ); // Node not yet visited if( !visited_dotty.at( node->getId() ) ) { //Clean //clauseSort(node->clause); // Print node //0 if original, 1 if lemma, 2 if axiom inst, 3 if deduced, 4 if magenta string typ; string color=""; switch( node->getType() ) { case 0: { typ = "cls_"; out << typ << node->getId() << "[shape=plaintext, label=\"c" << node->getId() <<" : "; //solver.printSMTClause( out, node->getClause(), true ); if(skeleton) printClause(node, out); else printSMTClause(node, out); if( node->getPartialInterpolant( ) ) out << "\\\\n" << node->getPartialInterpolant( ); out << "\", color=\"blue\", fontcolor=\"white\", style=\"filled\"]" << endl; } break; case 1: { typ = "lem_"; out << typ << node->getId() << "[shape=plaintext, label=\"c" << node->getId() <<" : "; if(skeleton) printClause(node, out); else printSMTClause(node, out); if( node->getPartialInterpolant( ) ) out << "\\\\n" << node->getPartialInterpolant( ); out << "\", color=\"green\""; out << ", style=\"filled\"]" << endl; } break; case 2: { typ = "axi_"; out << typ << node->getId() << "[shape=plaintext, label=\"c" << node->getId() <<" : "; if(skeleton) printClause(node, out); else printSMTClause(node, out); if( node->getPartialInterpolant( ) ) out << "\\\\n" << node->getPartialInterpolant( ); out << "\", color=\"red\""; out << ", style=\"filled\"]" << endl; } break; case 3: { typ = "ded_"; out << typ << node->getId() << "[shape=plaintext, label=\"c" << node->getId() <<" : "; if( !node->getClause().empty( ) ) { if(skeleton) printClause(node, out); else printSMTClause(node, out); } else out << "+"; // learnt clause //out << "\", color=\"grey\""; if( node->getPartialInterpolant( ) ) out << "\\\\n" << node->getPartialInterpolant( ); out << "\", color=\"grey\""; out << ", style=\"filled\"]" << endl; } break; case 4: { typ = "mag_"; out << typ << node->getId() << "[shape=plaintext, label=\"c" << node->getId() <<" : "; if( !node->getClause().empty( ) ) { if(skeleton) printClause(node, out); else printSMTClause(node, out); } else out << "+"; // magenta clause if( node->getPartialInterpolant( ) ) out << "\\\\n" << node->getPartialInterpolant( ); out << "\", color=\"purple\""; out << ", style=\"filled\"]" << endl; } break; case 5: { typ = "der_"; out << typ << node->getId() << "[shape=plaintext, label=\"c" << node->getId() <<" : "; if( !node->getClause().empty( ) ) { if(skeleton) printClause(node, out); else printSMTClause(node, out); } else out << "+"; // internal ded clause clause if( node->getPartialInterpolant( ) ) out << "\\\\n" << node->getPartialInterpolant( ); out << "\", color=\"orange\""; out << ", style=\"filled\"]" << endl; } break; default: typ=""; break; } // Print edges from parents (if existing) string t1,t2; ProofNode * r1 = node->getAnt1(); ProofNode * r2 = node->getAnt2(); if( r1 != NULL && r2 != NULL) { switch( r1->getType() ) { case 0: t1 = "cls_"; break; case 1: t1 = "lem_"; break; case 2: t1 = "axi_"; break; case 3: t1 = "ded_"; break; case 4: t1 = "mag_"; break; case 5: t1 = "der_"; break; default: t1 = ""; break; } switch( r2->getType() ) { case 0: t2 = "cls_"; break; case 1: t2 = "lem_"; break; case 2: t2 = "axi_"; break; case 3: t2 = "ded_"; break; case 4: t2 = "mag_"; break; case 5: t2 = "der_"; break; default: t2 = ""; break; } out << t1 << r1->getId() << " -> " << typ << node->getId(); out << " [label=\"(" << node->pivot << ")\", fontsize=10]" << endl; out << t2 << r2->getId() << " -> " << typ << node->getId(); out << " [label=\"(" << node->pivot << ")\", fontsize=10]" << endl; // Enqueue parents q.push_back( r1 ); q.push_back( r2 ); } //Mark node as visited visited_dotty[ node->getId() ] = true; } } out << "}" << endl; }