Beispiel #1
0
void SimpSMTSolver::toDimacs(const char* file)
{
  assert(decisionLevel() == 0);
  FILE* f = fopen(file, "wr");
  if (f != NULL){

    // Cannot use removeClauses here because it is not safe
    // to deallocate them at this point. Could be improved.
    int cnt = 0;
    for (int i = 0; i < clauses.size(); i++)
      if (!satisfied(*clauses[i]))
	cnt++;

    fprintf(f, "p cnf %d %d\n", nVars(), cnt);

    for (int i = 0; i < clauses.size(); i++)
      toDimacs(f, *clauses[i]);

    fprintf(stderr, "Wrote %d clauses...\n", clauses.size());
  }else
    fprintf(stderr, "could not open file %s\n", file);
}
bool SimpSolver::asymm(Var v, Clause& c)
{
    assert(decisionLevel() == 0);

    if (c.mark() || satisfied(c)) return true;

    trail_lim.push(trail.size());
    Lit l = lit_Undef;
    for (int i = 0; i < c.size(); i++)
        if (var(c[i]) != v && value(c[i]) != l_False)
            uncheckedEnqueue(~c[i]);
        else
            l = c[i];

    if (propagate() != NULL){
        cancelUntil(0);
        asymm_lits++;
        if (!strengthenClause(c, l))
            return false;
    }else
        cancelUntil(0);

    return true;
}
Beispiel #3
0
void ClauseCleaner::removeSatisfied(vec<Clause*>& cs, ClauseSetType type,
                                    const unsigned limit)
{
#ifdef DEBUG_CLEAN
  assert(solver.decisionLevel() == 0);
#endif

  if (lastNumUnitarySat[type] + limit >= solver.get_unitary_learnts_num())
    return;

  Clause** i, **j, **end;
  for (i = j = cs.getData(), end = i + cs.size(); i != end; i++)
  {
    if (i + 1 != end)
      __builtin_prefetch(*(i + 1), 0, 0);
    if (satisfied(**i))
      solver.removeClause(**i);
    else
      *j++ = *i;
  }
  cs.shrink(i - j);

  lastNumUnitarySat[type] = solver.get_unitary_learnts_num();
}
Beispiel #4
0
 bool satisfied(const permission_level& permission, uint16_t depth = 0) {
    return has_permission( permission.actor ) ||
           satisfied(permission_to_authority(permission), depth);
 }