bool SimpSolver::addClause(vec<Lit>& ps)
{
    for (int i = 0; i < ps.size(); i++)
        if (isEliminated(var(ps[i])))
            remember(var(ps[i]));

    int nclauses = clauses.size();

    if (redundancy_check && implied(ps))
        return true;

    if (!Solver::addClause(ps))
        return false;

    if (use_simplification && clauses.size() == nclauses + 1){
        Clause& c = *clauses.last();

        subsumption_queue.insert(&c);

        for (int i = 0; i < c.size(); i++){
            assert(occurs.size() > var(c[i]));
            assert(!find(occurs[var(c[i])], &c));

            occurs[var(c[i])].push(&c);
            n_occ[toInt(c[i])]++;
            touched[var(c[i])] = 1;
            assert(elimtable[var(c[i])].order == 0);
            if (elim_heap.inHeap(var(c[i])))
                elim_heap.increase_(var(c[i]));
        }
    }

    return true;
}
Exemple #2
0
bool SimpSMTSolver::addClause( vec<Lit> & ps
#ifdef PRODUCE_PROOF
                             , const ipartitions_t & in 
#endif
			     )
{
  //=================================================================================================
  // Added code

  if ( !use_simplification )
#ifdef PRODUCE_PROOF
    return CoreSMTSolver::addClause( ps, in );
#else
    return CoreSMTSolver::addClause( ps );
#endif

  // Added code
  //=================================================================================================

  for (int i = 0; i < ps.size(); i++)
    if (isEliminated(var(ps[i])))
      remember(var(ps[i]));

  int nclauses = clauses.size();

  if (redundancy_check && implied(ps))
    return true;

  //=================================================================================================
  // Added code

  //
  // Hack to consider clauses of size 1 that
  // wouldn't otherwise be considered by
  // MiniSAT
  //
  if ( config.sat_preprocess_theory != 0
      && ps.size( ) == 1   // Consider unit clauses
      && var(ps[0]) >= 2 ) // Don't consider true/false
  {
    Var v = var( ps[0] );
    cerr << "XXX skipped handling of unary theory literal?" << endl;
/*
    Enode * e = theory_handler->varToEnode( v );
    if ( e->isTAtom( ) )
    {
      Clause * uc = Clause_new(ps, false);
      unary_to_remove.push_back( uc );
      Clause &c = *(unary_to_remove.back( ));
      Enode * x, * y;
      getDLVars( e, sign(ps[0]), &x, &y );
      assert( x->isVar( ) );
      assert( y->isVar( ) );
      t_pos[ x->getId( ) ].push_back( &c );
      t_neg[ y->getId( ) ].push_back( &c );
      t_var[ x ].insert( y->getId( ) );
      t_var[ y ].insert( x->getId( ) );
    }
*/
  }
  // Added code
  //=================================================================================================

  if (!CoreSMTSolver::addClause(ps))
    return false;

  if (use_simplification && clauses.size() == nclauses + 1)
  {
    Clause& c = *clauses.last();

    subsumption_queue.insert(&c);

    for (int i = 0; i < c.size(); i++)
    {
      assert(occurs.size() > var(c[i]));
      assert(!find(occurs[var(c[i])], &c));

      occurs[var(c[i])].push(&c);
      n_occ[toInt(c[i])]++;
      touched[var(c[i])] = 1;
      assert(elimtable[var(c[i])].order == 0);
      if (elim_heap.inHeap(var(c[i])))
	elim_heap.increase_(var(c[i]));

    }
  }

  return true;
}