Exemplo n.º 1
0
bool
Component::checkFoundedStatus()
{    
    for( unsigned int i = 0; i < variablesInComponent.size(); i++ )
    {
        unsigned int var = variablesInComponent[ i ];
        assert( solver.getComponent( var )->getId() == this->id );        
        assert_msg( !variablesWithoutSourcePointer.existElement( var ), "VariablesWithoutSourcePointer contains " << Literal( var, POSITIVE ) );
        assert_msg( getGUSData( var ).isFounded(), Literal( var, POSITIVE ) << " is not founded" );
        assert_msg( !getGUSData( var ).isInQueue(), Literal( var, POSITIVE ) << " is in queue" );

        assert_msg( !getGUSData( var ).isAux() || getGUSData( var ).numberOfSupporting == 0, Literal( var, POSITIVE ) << " - Number of supporting: " << getGUSData( var ).numberOfSupporting );
        if( getGUSData( var ).isAux() )
            continue;

        if( solver.isFalse( var ) )
            return true;
            
        assert_msg( getGUSData( var ).sourcePointer != Literal::null, Literal( var, POSITIVE ) << " has no source pointer" );
        assert_msg( !solver.isFalse( getGUSData( var ).sourcePointer ), getGUSData( var ).sourcePointer << " is a source pointer of " << Literal( var, POSITIVE ) << " but it is false" );
            
        if( solver.getComponent( getGUSData( var ).sourcePointer.getVariable() ) != this )
            return true;

        assert_msg( getGUSData( getGUSData( var ).sourcePointer.getVariable() ).isFounded(), getGUSData( var ).sourcePointer << " is a source pointer of " << Literal( var, POSITIVE ) << " but it is unfounded" );
    }

    //Return always true!
    return true;
}
Exemplo n.º 2
0
void

HCComponent::iterationExternalLiterals(
    vector< Literal >& assumptions )
{
    int j = 0;
    for( unsigned int i = 0; i < externalLiterals.size(); i++ )
    {
        Literal lit = externalLiterals[ j ] = externalLiterals[ i ];
        assert( getCheckerVarFromExternalLiteral( lit ) != UINT_MAX );
        if( solver.getDecisionLevel( lit ) > 0 || solver.isUndefined( lit ) )
        {
            assumptions.push_back( Literal( getCheckerVarFromExternalLiteral( lit ), solver.isTrue( lit ) ? POSITIVE : NEGATIVE ) );
            j++;
        }
        else
        {
            isConflictual = !checker.addClauseRuntime( Literal( getCheckerVarFromExternalLiteral( lit ), solver.isTrue( lit ) ? POSITIVE : NEGATIVE ) );
            if( isConflictual )
                return;
        }
    }
    externalLiterals.resize( j );
    
    statistics( &checker, assumptions( assumptions.size() ) );
}
Exemplo n.º 3
0
void
Component::removeFalseAtomsAndPropagateUnfoundedness()
{
    trace_msg( unfoundedset, 1, "Removing false atoms from variables without source pointers" );
    unsigned int k = 0;
    for( unsigned int i = 0; i < variablesWithoutSourcePointer.size(); i++ )
    {
        Var variable = variablesWithoutSourcePointer[ k ] = variablesWithoutSourcePointer[ i ];
        
        if( solver.isFalse( variable ) )
            setFounded( variable );
        
        if( getGUSData( variable ).isFounded() )
        {
            trace_msg( unfoundedset, 1, "Variable " << Literal( variable, POSITIVE ) << " is founded or false" );            
            getGUSData( variable ).setOutQueue();
            continue;
        }
        
        assert( !solver.isFalse( variable ) );

        k++;
        if( getGUSData( variable ).isPropagated() )
            continue;

        trace_msg( unfoundedset, 1, "Variable " << Literal( variable, POSITIVE ) << " lost the source pointer" );
        getGUSData( variable ).setPropagated();
        propagateLiteralLostSourcePointer( Literal( variable ) );
    }
    variablesWithoutSourcePointer.shrink( k );
}
Exemplo n.º 4
0
void
Component::foundSourcePointer(
    Var variableWithSourcePointer )
{
    assert( getGUSData( variableWithSourcePointer ).isFounded() );
    for( unsigned int i = 0; i < getGUSData( variableWithSourcePointer ).possiblySupportedByThis[ POSITIVE ].size(); i++ )
    {
        Var var = getGUSData( variableWithSourcePointer ).possiblySupportedByThis[ POSITIVE ][ i ];
        assert( solver.getComponent( var ) == this );
        if( !solver.isFalse( var ) && !getGUSData( var ).isFounded() )
        {
            trace_msg( unfoundedset, 1, "Literal " << Literal( variableWithSourcePointer ) << " is a source pointer of " << Literal( var, POSITIVE ) );            
            propagateSourcePointer( var, Literal( variableWithSourcePointer ) );
        }
    }
    
    for( unsigned int i = 0; i < getGUSData( variableWithSourcePointer ).auxVariablesSupportedByThis[ POSITIVE ].size(); i++ )
    {        
        Var var = getGUSData( variableWithSourcePointer ).auxVariablesSupportedByThis[ POSITIVE ][ i ];
        assert( solver.getComponent( var ) == this );
        if( solver.isFalse( var ) )
            continue;
        
        trace_msg( unfoundedset, 1, "Literal " << Literal( variableWithSourcePointer ) << " is a source pointer of " << Literal( var, POSITIVE ) );        
        assert_msg( !getGUSData( var ).isFounded(), "Variable " << Literal( var, POSITIVE ) << " is founded" );
        propagateSourcePointer( var, Literal( variableWithSourcePointer ) );        
    }
}
Exemplo n.º 5
0
Arquivo: clause.c Projeto: ombt/ombt
int
Clause::isInClause(const Literal &key) const
{
	if (key.isNegated())
		return(negativeClause.retrieve(Literal(key)) == OK);
	else
		return(positiveClause.retrieve(Literal(key)) == OK);
}
Exemplo n.º 6
0
  void rewriteCopysign(Binary* curr) {
    Literal signBit, otherBits;
    UnaryOp int2float, float2int;
    BinaryOp bitAnd, bitOr;
    switch (curr->op) {
      case CopySignFloat32:
        float2int = ReinterpretFloat32;
        int2float = ReinterpretInt32;
        bitAnd = AndInt32;
        bitOr = OrInt32;
        signBit = Literal(uint32_t(1 << 31));
        otherBits = Literal(uint32_t(1 << 31) - 1);
        break;

      case CopySignFloat64:
        float2int = ReinterpretFloat64;
        int2float = ReinterpretInt64;
        bitAnd = AndInt64;
        bitOr = OrInt64;
        signBit = Literal(uint64_t(1) << 63);
        otherBits = Literal((uint64_t(1) << 63) - 1);
        break;

      default: return;
    }

    replaceCurrent(
      builder->makeUnary(
        int2float,
        builder->makeBinary(
          bitOr,
          builder->makeBinary(
            bitAnd,
            builder->makeUnary(
              float2int,
              curr->left
            ),
            builder->makeConst(otherBits)
          ),
          builder->makeBinary(
            bitAnd,
            builder->makeUnary(
              float2int,
              curr->right
            ),
            builder->makeConst(signBit)
          )
        )
      )
    );
  }
Exemplo n.º 7
0
Literal Lookahead::heuristic(Solver& s) {
	if (s.value(score.best) != value_free) {
		// no candidate available
		return posLit(0);
	}
	ScoreLook& sc = score;
	Literal choice= Literal(sc.best, sc.score[sc.best].prefSign());
	if (!sc.deps.empty() && sc.mode == ScoreLook::score_max_min) {
		// compute heuristic values for candidates skipped during last lookahead
		uint32 min, max;
		sc.score[sc.best].score(max, min);
		sc.addDeps = false;
		bool ok    = true;
		LitVec::size_type i = 0;
		do {
			Var v        = sc.deps[i];
			VarScore& vs = sc.score[v];
			if (s.value(v) == value_free) {
				uint32 vMin, vMax;
				vs.score(vMax, vMin);
				if (vMin == 0 || vMin > min || (vMin == min && vMax > max)) {
					uint32 neg = vs.score(negLit(v)) > 0 ? vs.score(negLit(v)) : max+1;
					uint32 pos = vs.score(posLit(v)) > 0 ? vs.score(posLit(v)) : max+1;
					if (!vs.tested(negLit(v))) {
						ok  = ok && s.test(negLit(v), this);
						neg = vs.score(negLit(v));
					}
					if ((neg > min || (neg == min && pos > max)) && !vs.tested(posLit(v))) {
						ok  = ok && s.test(posLit(v), this);
					}
				}
				if (vs.testedBoth() && sc.greaterMaxMin(v, max, min)) {
					vs.score(max, min);
					choice = Literal(v, vs.prefSign());
				}
			}
		} while (++i != sc.deps.size() && ok);
		if (!ok) {
			// One of the candidates failed. Since none of them failed
			// during previous propagation, this indicates that
			// either some post propagator has wrong priority or
			// parallel solving is active and a stop conflict was set.
			// Since we can't resolve the problem here, we simply return the
			// literal that caused the conflict
			assert(s.hasConflict());
			return negLit(0);
		}
	}
	return choice;
}
Exemplo n.º 8
0
bool Nepomuk::Types::PropertyPrivate::addProperty( const QUrl& property, const Soprano::Node& value )
{
    // we avoid subclassing loops (as created for crappy inferencing) by checking for our own uri
    if( value.isResource() &&
        value.uri() != uri &&
        property == Soprano::Vocabulary::RDFS::subPropertyOf() ) {
        parents.append( value.uri() );
        return true;
    }

    else if( property == Soprano::Vocabulary::RDFS::domain() ) {
        domain = value.uri();
        return true;
    }

    else if( property == Soprano::Vocabulary::RDFS::range() ) {
        if ( value.toString().startsWith( Soprano::Vocabulary::XMLSchema::xsdNamespace().toString() ) ) {
            literalRange = Literal( value.uri() );
        }
        else if ( value.uri() == Soprano::Vocabulary::RDFS::Literal()) {
            literalRange = Literal( value.uri() );
        }
        else {
            range = value.uri();
        }
        return true;
    }

    else if( property == Soprano::Vocabulary::NRL::minCardinality() ) {
        minCardinality = value.literal().toInt();
        return true;
    }

    else if( property == Soprano::Vocabulary::NRL::maxCardinality() ) {
        maxCardinality = value.literal().toInt();
        return true;
    }

    else if ( property == Soprano::Vocabulary::NRL::cardinality() ) {
        cardinality = value.literal().toInt();
        return true;
    }

    else if ( property == Soprano::Vocabulary::NRL::inverseProperty() ) {
        inverse = value.uri();
        return true;
    }

    return false;
}
Exemplo n.º 9
0
 void optimizeMemoryAccess(Expression*& ptr, Address& offset) {
   while (1) {
     auto* add = ptr->dynCast<Binary>();
     if (!add) break;
     if (add->op != AddInt32) break;
     auto* left = add->left->dynCast<Const>();
     auto* right = add->right->dynCast<Const>();
     // note: in optimized code, we shouldn't see an add of two constants, so don't worry about that much
     // (precompute would optimize that)
     if (left) {
       auto value = left->value.geti32();
       if (value >= 0 && value < SAFE_MAX) {
         offset = offset + value;
         ptr = add->right;
         continue;
       }
     }
     if (right) {
       auto value = right->value.geti32();
       if (value >= 0 && value < SAFE_MAX) {
         offset = offset + value;
         ptr = add->left;
         continue;
       }
     }
     break;
   }
   // finally ptr may be a const, but it isn't worth folding that in (we still have a const); in fact,
   // it's better to do the opposite for gzip purposes as well as for readability.
   auto* last = ptr->dynCast<Const>();
   if (last) {
     last->value = Literal(int32_t(last->value.geti32() + offset));
     offset = 0;
   }
 }
Exemplo n.º 10
0
Clause*
QueryInterface::computeClauseFromCandidates()
{
    Clause* clause = new Clause();
    unsigned int j = 0;
    for( unsigned int i = 0; i < candidates.size(); i++ )
    {
        Var v = candidates[ j ] = candidates[ i ];
        assert( !solver.isUndefined( v ) );
        if( !solver.isTrue( v ) )
            continue;
        
        if( solver.getDecisionLevel( v ) == 0 )
            addAnswer( v );
        else
        {
            clause->addLiteral( Literal( v, NEGATIVE ) );
            j++;
        }
    }    
    candidates.shrink( j );
    clause->setCanBeDeleted( false );
    printCandidates();
    return clause;
}
Exemplo n.º 11
0
void
Component::iterationOnAuxSupportedByThis(
    Literal lit )
{
    trace_msg( unfoundedset, 2, "Iterating on aux variable supported by literal " << lit );
    vector< Var >& vec = getGUSData( lit.getVariable() ).auxVariablesSupportedByThis[ lit.getSign() ];
    
    for( unsigned int i = 0; i < vec.size(); i++ )
    {
        Var variable = vec[ i ];
        assert( getGUSData( variable ).isAux() );
        trace_msg( unfoundedset, 3, "Considering variable " << Literal( variable, POSITIVE ) << " which is " << ( solver.isFalse( variable ) ? "false" : "true/undefined" ) << " and " << ( ( getGUSData( variable ).isInQueue() ) ? "in queue" : "not in queue" ) );
        if( solver.isFalse( variable ) )
            continue;

        assert( solver.getComponent( variable ) == this );
        assert( !getGUSData( variable ).isInQueue() || variablesWithoutSourcePointer.existElement( variable ) );
        if( !getGUSData( variable ).isInQueue() )
            variableHasNoSourcePointer( variable );
        else if( getGUSData( variable ).isFounded() )
            setUnfounded( variable );

        assert( !getGUSData( variable ).isFounded() );
        getGUSData( variable ).numberOfSupporting++;
    }
}
Exemplo n.º 12
0
bool
Component::iterationOnSupportedByThisInternal(
    Literal lit )
{
    trace_msg( unfoundedset, 2, "Iterating on variable supported by literal " << lit << " internally" );
    Vector< Var >& wl = getGUSData( lit.getVariable() ).supportedByThisInternalRule[ lit.getSign() ];

    unsigned i = 0;
    unsigned j = 0;
    for( ; i < wl.size(); ++i )
    {
        Var variable = wl[ j ] = wl[ i ];
        assert( solver.getComponent( variable ) != NULL && solver.getComponent( variable )->getId() == id );
        trace_msg( unfoundedset, 3, "Considering variable " << Literal( variable, POSITIVE ) << " which is " << ( solver.isFalse( variable ) ? "false" : "true" ) << " and " << ( ( getGUSData( variable ).isInQueue() ) ? "in queue" : "not in queue" ) );
        assert( !getGUSData( variable ).isInQueue() || variablesWithoutSourcePointer.existElement( variable ) );
        if( solver.isFalse( variable ) )
        {
            ++j;
            continue;
        }

        if( !getGUSData( variable ).isInQueue() )
            variableHasNoSourcePointer( variable );
        else if( getGUSData( variable ).isFounded() )
            setUnfounded( variable );
        else
            ++j;        
        assert( !getGUSData( variable ).isFounded() );
    }
    wl.shrink( j );
    return i != j;
}
Exemplo n.º 13
0
vector<ExpressionNode*> Parser::LiteralList()
{
    ExpressionNode * value=Literal();
    vector<ExpressionNode*> list=LiteralListPrime();
    list.insert(list.begin(),value);
    return list;
}
Exemplo n.º 14
0
ExpressionNode* Parser::Factors()
{
    if(currenttoken->type == Id)
            return Variable();
    else if(currenttoken->type == OpenParenthesis){
            ConsumeToken();
            ExpressionNode * value = Expresion();
            if(currenttoken->type != CloseParenthesis)
                throw invalid_argument("Se esperaba ).  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
            ConsumeToken();
            return value;
    }
    else if(IsLiteral(currenttoken))
    {
        return Literal();
    }
    else if(currenttoken->type == Verdadero)
    {
        ConsumeToken();
        return new ConstantBooleanNode(true);
    }
    else if(currenttoken->type == Falso)
    {
        ConsumeToken();
        return new ConstantBooleanNode(false);
    }

}
Exemplo n.º 15
0
void
HCComponent::initDataStructures()
{
    trace_msg( modelchecker, 2, "First call. Removing unused variables" );
    for( unsigned i = 1; i < inUnfoundedSet.size(); ++i )
    {
        if( inUnfoundedSet[ i ] == 0 )
            checker.addClause( Literal( i, POSITIVE ) );
        else
            inUnfoundedSet[ i ] = 0;        
    }
    #ifndef NDEBUG
    bool result = 
    #endif    
    checker.preprocessing();
    assert( result );

    checker.turnOffSimplifications();
    createInitialClauseAndSimplifyHCVars();
    if( wasp::Options::bumpActivityAfterPartialCheck )
    {
        checker.setComputeUnsatCores( true );
        checker.setMinimizeUnsatCore( false );
    }        
}
Exemplo n.º 16
0
const exprt qbf_squolem_coret::f_get(literalt l)
{
  if(squolem->isUniversal(l.var_no()))
  {
    assert(l.var_no()!=0);
    variable_mapt::const_iterator it=variable_map.find(l.var_no());

    if(it==variable_map.end())
      throw "Variable map error";

    const exprt &sym=it->second.first;
    unsigned index=it->second.second;

    exprt extract_expr(ID_extractbit, typet(ID_bool));
    extract_expr.copy_to_operands(sym);
    typet uint_type(ID_unsignedbv);
    uint_type.set(ID_width, 32);
    extract_expr.copy_to_operands(from_integer(index, uint_type));

    if(l.sign()) extract_expr.negate();

    return extract_expr;
  }

  function_cachet::const_iterator it=function_cache.find(l.var_no());
  if(it!=function_cache.end())
  {
    #if 0
    std::cout << "CACHE HIT for " << l.dimacs() << std::endl;
    #endif

    if(l.sign())
      return not_exprt(it->second);
    else
      return it->second;
  }
  else
  {
    WitnessStack *wsp = squolem->getModelFunction(Literal(l.dimacs()));
    exprt res;

    if(wsp==NULL || wsp->empty())
    {
//      res=exprt(ID_nondet_bool, typet(ID_bool));
      res=false_exprt(); // just set it to zero
    }
    else if(wsp->pSize<=wsp->nSize)
      res=f_get_cnf(wsp);
    else
      res=f_get_dnf(wsp);

    function_cache[l.var_no()] = res;

    if(l.sign())
      return not_exprt(res);
    else
      return res;
  }
}
Exemplo n.º 17
0
void AusgabeBelegung(FILE* const fp) {
  assert(fp);
  extern enum Ausgabeformat Format;
  const char* Einrueckung = 0;

  if (Format == Dimacs_Format)
    fprintf(fp, "v");
  else {
    assert(Format == XML_Format);
    extern bool Dateiausgabe;
    Einrueckung = (Dateiausgabe) ? "" : " ";
    fprintf(fp, "%s<solution>\n", Einrueckung);
  }

  if (EinerKlausel)
    for (unsigned int i = 0; i < InitEinerRed; ++i) {
      assert(Pfad0[i] > INT_MIN);
      const unsigned int v = abs(Pfad0[i]);
      const VZ e = (Pfad0[i] > 0) ? Pos : Neg;
      if (Format == Dimacs_Format) {
        if (e == Neg)
          fprintf(fp, " %s", Symbol1(v));
        else
          fprintf(fp, " -%s", Symbol1(v));
      }
      else {
        assert(Einrueckung);
        fprintf(fp, "%s  <value var = \"%s\"> %d </value>\n", Einrueckung, Symbol1(v), e);
      }
    }
  {
    const Pfadinfo* const Z = Tiefe;
    for (Tiefe = Pfad; Tiefe < Z; ++Tiefe) {
      const LIT l = PfadLit(); const VAR v = Var(l);
      const VZ e = (l == Literal(v, Pos)) ? Pos : Neg;
      if (Format == Dimacs_Format) {
        if (e == Neg)
          fprintf(fp, " %s", Symbol(v));
        else
          fprintf(fp, " -%s", Symbol(v));
      }
      else {
        assert(Einrueckung);
        fprintf(fp, "%s  <value var = \"%s\"> %d </value>\n", Einrueckung, Symbol(v), e);
      }
    }
    Tiefe = (Pfadinfo*) Z;
  }

  if (Format == Dimacs_Format)
    fprintf(fp, " 0\n");
  else {
    assert(Einrueckung);
    fprintf(fp, "%s</solution>\n", Einrueckung);
    extern bool Dateiausgabe;
    if (! Dateiausgabe)
      fprintf(fp, "</SAT-Solver.output>\n");
  }
}
Exemplo n.º 18
0
//=========================================================
bool Parser::Value () {
    PrintRule rule("Value");
    return rule.Accept(
        Literal()       ||
        NameReference() ||
        GroupedExpression()
    );
}
Exemplo n.º 19
0
void
Component::printVariablesWithoutSourcePointer()
{
    cout << "Variables:";
    for( unsigned int i = 0; i < variablesWithoutSourcePointer.size(); i++ )
        cout << " " << Literal( variablesWithoutSourcePointer[ i ], POSITIVE );
    cout << endl;
}
Exemplo n.º 20
0
/*!
  \brief In monitoring mode, output branching literal x (with the given
  depth in the search tree).

  Currently output actually only happens if output of a satisfying assignment
  is enabled.
*/
__inline__ static void Verzweigungsliteralausgabe(const LIT x, const unsigned int Tiefe) {
  const VAR v = Var(x);
  const VZ e = (x == Literal(v, Pos)) ? Pos : Neg;
  if (Belegung) {
    fprintf(fpmo, "# %-6d %7s %d\n", Tiefe, Symbol(v), e);
  }
  fflush(NULL);
}
Exemplo n.º 21
0
void
QueryInterface::addAnswer(
    Var v )
{
    if( wasp::Options::queryVerbosity >= 1 )
        cout << "Certain answer: " << Literal( v, POSITIVE ) << endl;
    answers.push_back( v );
}
Exemplo n.º 22
0
void
HCComponent::createInitialClauseAndSimplifyHCVars()
{
    trace_msg( modelchecker, 1, "Simplifying Head Cycle variables" );
    Clause* clause = new Clause();

    bool satisfied = false;
    int j = 0;
    for( unsigned int i = 0; i < hcVariables.size(); i++ )
    {
        Var v = hcVariables[ j ] = hcVariables[ i ];
        if( solver.isTrue( v ) && solver.getDecisionLevel( v ) == 0 )
        {
            Literal lit = Literal( v, NEGATIVE );
            unfoundedSetCandidates.push_back( lit );            
            removedHCVars++;
            trace_msg( modelchecker, 2, "Variable " << Literal( v ) << " is true at level 0: removed" );
            if( !satisfied )
                satisfied = !addLiteralInClause( lit, clause );
        }
        else
            j++;
    }
    hcVariables.resize( j );        
    
    trace_msg( modelchecker, 2, "Clause before adding a fresh variable " << *clause << ", which is " << ( satisfied ? "" : "not" ) << " satisfied");
    if( clause->size() == 0 || satisfied )
    {
        trace_msg( modelchecker, 3, "Removed" );
        delete clause;
    }
    else
    {
        statistics( &checker, setTrueAtLevelZero( removedHCVars ) );
        assert( clause != NULL );
        Var newVar = addFreshVariable();
        literalToAdd = Literal( newVar, NEGATIVE );
        clause->addLiteral( literalToAdd.getOppositeLiteral() );
        
        trace_msg( modelchecker, 3, "Clause to add " << *clause );
        if( !isConflictual )
            isConflictual = !checker.addClauseRuntime( clause );        
    }    
    
    assert( removedHCVars == unfoundedSetCandidates.size() );
}
Exemplo n.º 23
0
void posix_words() {
    Primitive( "getwd", &_getwd );
    Colon( "pwd" ); c("getwd"); c("type"); c("cr"); End();

    Primitive( "(getenv)", &_getenv );
    Primitive( "(setenv)", &_setenv );
    Colon( "getenv" ); c("parse-word"); c("(getenv)"); End();
    Colon( "setenv" ); c("parse-word"); c("parse-word"); c("(setenv)"); End();
    Colon( "printenv" );
          c("parse-word"); c("2dup"); c("type");
          Literal((Cell)'='); c("emit");
          c("(getenv)"); If(); c("type"); Then(); c("cr"); End();

    Primitive( "(system)", &_system );
    Primitive( "(exec)",   &_exec );

    /* mmap() protection */
    Constant( "PROT_EXEC",  (Cell)PROT_EXEC );
    Constant( "PROT_READ",  (Cell)PROT_READ );
    Constant( "PROT_WRITE", (Cell)PROT_WRITE );
    Constant( "PROT_NONE",  (Cell)PROT_NONE );

    /* mmap() Flags */
    Constant( "MAP_FIXED",   (Cell)MAP_FIXED );
    Constant( "MAP_SHARED",  (Cell)MAP_SHARED );
    Constant( "MAP_PRIVATE", (Cell)MAP_PRIVATE );

    Primitive( "mmap", &do_mmap );

    Primitive( "getpid", &_getpid );
    Primitive( "getppid", &_getppid );

    /* Signals for kill */
    Constant( "SIGHUP",    (Cell)SIGHUP );
    Constant( "SIGINT",    (Cell)SIGINT );
    Constant( "SIGQUIT",   (Cell)SIGQUIT );
    Constant( "SIGILL",    (Cell)SIGILL );
    Constant( "SIGTRAP",   (Cell)SIGTRAP );
    Constant( "SIGABRT",   (Cell)SIGABRT );
    Constant( "SIGIOT",    (Cell)SIGIOT );
    Constant( "SIGBUS",    (Cell)SIGBUS );
    Constant( "SIGFPE",    (Cell)SIGFPE );
    Constant( "SIGKILL",   (Cell)SIGKILL );
    Constant( "SIGUSR1",   (Cell)SIGUSR1 );
    Constant( "SIGSEGV",   (Cell)SIGSEGV );
    Constant( "SIGUSR2",   (Cell)SIGUSR2 );
    Constant( "SIGPIPE",   (Cell)SIGPIPE );
    Constant( "SIGALRM",   (Cell)SIGALRM );
    Constant( "SIGTERM",   (Cell)SIGTERM );
    // Constant( "SIGSTKFLT", (Cell)SIGSTKFLT );
    // Constant( "SIGCLD",    (Cell)SIGCLD );
    Constant( "SIGCHLD",   (Cell)SIGCHLD );
    Constant( "SIGCONT",   (Cell)SIGCONT );
    Constant( "SIGSTOP",   (Cell)SIGSTOP );
    Constant( "SIGTSTP",   (Cell)SIGTSTP );

    Primitive( "kill", &_kill );
}
Exemplo n.º 24
0
Literal ClaspVmtf::getLiteral(const Solver& s, Var v) const {
	Literal r;
	if ( (r = savedLiteral(s, v)) == posLit(0) ) {
		r = score_[v].occ_== 0
			? s.preferredLiteralByType(v)
			: Literal(v, score_[v].occ_ < 0 );
	}
	return r;
}
Exemplo n.º 25
0
void
HCComponent::iterationInternalLiterals(
    vector< Literal >& assumptions )
{
    bool hasToAddClause = true;
    Clause* clause = new Clause();    
    for( unsigned int i = 0; i < hcVariables.size(); i++ )
    {
        Literal lit = Literal( hcVariables[ i ], NEGATIVE );
        if( solver.isFalse( hcVariables[ i ] ) )
            assumptions.push_back( lit );            
        else
        {
            unfoundedSetCandidates.push_back( lit );
            if( !hasToAddClause )
                continue;
            hasToAddClause = addLiteralInClause( lit, clause );
        }
    }
    
    if( hasToAddClause && literalToAdd != Literal::null )
        hasToAddClause = addLiteralInClause( literalToAdd, clause );
    
    if( !hasToAddClause )
    {
        delete clause;
        return;
    }
    
    Var addedVar = addFreshVariable();
    assumptionLiteral = Literal( addedVar, POSITIVE );
    clause->addLiteral( assumptionLiteral.getOppositeLiteral() );
    assumptions.push_back( assumptionLiteral );

    trace_msg( modelchecker, 2, "Adding clause " << *clause );
    #ifndef NDEBUG
    bool result =
    #endif
    checker.addClauseRuntime( clause );
    assert( result );
    statistics( &checker, assumptionsOR( clause->size() ) );            
    trace_msg( modelchecker, 3, "Adding " << assumptionLiteral << " as assumption" );    
}
Exemplo n.º 26
0
 void visitCallImport(CallImport* curr) {
   // special asm.js imports can be optimized
   auto* import = getModule()->getImport(curr->target);
   if (import->module == GLOBAL_MATH) {
     if (import->base == POW) {
       if (auto* exponent = curr->operands[1]->dynCast<Const>()) {
         if (exponent->value == Literal(double(2.0))) {
           // This is just a square operation, do a multiply
           Localizer localizer(curr->operands[0], getFunction(), getModule());
           Builder builder(*getModule());
           replaceCurrent(builder.makeBinary(MulFloat64, localizer.expr, builder.makeGetLocal(localizer.index, localizer.expr->type)));
         } else if (exponent->value == Literal(double(0.5))) {
           // This is just a square root operation
           replaceCurrent(Builder(*getModule()).makeUnary(SqrtFloat64, curr->operands[0]));
         }
       }
     }
   }
 }
Exemplo n.º 27
0
// normalization
// 10/09/2002, Manchester
void Literal::normalize ()
{ 
  Atom a (atom());
  a.normalize();
  if (a == atom()) {
    return;
  }

  *this = Literal (sign(),a);
} // Literal::normalize ()
Exemplo n.º 28
0
// build literal list from a kernel literal list
// 28/09/2002 Manchester
LiteralList::LiteralList (const VampireKernel::Literal* literal, 
		  const VampireKernel& kernel)
{
  if (! literal) {
    _data = 0;
    return;
  }

  _data = new LstData<Literal> ( Literal (literal, kernel),
		     LiteralList (literal->next(), kernel) );
} // Literal::Literal (const VampireKernel::Literal* lit, ...)
Exemplo n.º 29
0
/* Annule les changements faits par propagateVariable dans les clauses contenant la variable.
   Cette fonction doit être appelée lors du backtrack. */
void Variable::deductedFromAssigned(void)
{
    const Literal lit = Literal(this, _varState);
    const std::vector<Clause*>& cTrue  = _varState ? _litTrue : _litFalse;
    const std::vector<Clause*>& cFalse = _varState ? _litFalse : _litTrue;
    std::vector<Clause*>::const_iterator it;

    for(it = cTrue.begin(); it != cTrue.end(); ++it)
        (*it)->freeLitTrue(lit);

    for(it = cFalse.begin(); it != cFalse.end(); ++it)
        (*it)->freeLitFalse(lit);
}
Exemplo n.º 30
0
bool
Component::checkSourcePointersStatus()
{
    for( unsigned int i = 0; i < variablesInComponent.size(); i++ )
    {
        unsigned int id = variablesInComponent[ i ];                
        assert( solver.getComponent( id )->getId() == this->id );
        if( !getGUSData( id ).isFounded() )
        {
            cerr << "Variable " << Literal( id, POSITIVE ) << " is not founded " << getGUSData( id ).numberOfSupporting << endl;
            return false;
        }

        if( getGUSData( id ).numberOfSupporting != 0 )
        {
            cerr << "Variable " << Literal( id, POSITIVE ) << " has a number of supporting greater than 0" << endl;
            return false;
        }
    }

    return true;
}