cloud9_root/src/third_party/stp/src/simplifier/simplifier.cpp
// recursively simplify things that are of type array.
recursively simplify things that are of type array.
recursively simplify things that are of type array .
ASTNode
  Simplifier::SimplifyArrayTerm(const ASTNode& term, ASTNodeMap* VarConstMap)
  {
    const unsigned iw = term.GetIndexWidth();
    assert(iw > 0);
    ASTNode output;
    if (CheckSimplifyMap(term, output, false))
      {
        return output;
      }
    switch (term.GetKind())
      {
    case SYMBOL:
      return term;
    case ITE:
      {
        output = CreateSimplifiedTermITE(SimplifyFormula(term[0], VarConstMap), SimplifyArrayTerm(term[1], VarConstMap),
            SimplifyArrayTerm(term[2], VarConstMap));
        assert(output.GetIndexWidth() == iw);
      }
      break;
    case WRITE:
      {
        ASTNode array = SimplifyArrayTerm(term[0], VarConstMap);
        ASTNode idx = SimplifyTerm(term[1]);
        ASTNode val = SimplifyTerm(term[2]);
        output = nf->CreateArrayTerm(WRITE, iw, term.GetValueWidth(), array, idx, val);
      }
      break;
    default:
      FatalError("2313456331");
      }
    UpdateSimplifyMap(term, output, false);
    assert(term.GetIndexWidth() == output.GetIndexWidth());
    assert(BVTypeCheck(output));
    return output;
  }
ASTNode Simplifier :: SimplifyArrayTerm ( const ASTNode & term , ASTNodeMap * VarConstMap ) { const unsigned iw = term . GetIndexWidth ( ) ; assert ( iw > 0 ) ; ASTNode output ; if ( CheckSimplifyMap ( term , output , false ) ) { return output ; } switch ( term . GetKind ( ) ) { case SYMBOL : return term ; case ITE : { output = CreateSimplifiedTermITE ( SimplifyFormula ( term [ 0 ] , VarConstMap ) , SimplifyArrayTerm ( term [ 1 ] , VarConstMap ) , SimplifyArrayTerm ( term [ 2 ] , VarConstMap ) ) ; assert ( output . GetIndexWidth ( ) == iw ) ; } break ; case WRITE : { ASTNode array = SimplifyArrayTerm ( term [ 0 ] , VarConstMap ) ; ASTNode idx = SimplifyTerm ( term [ 1 ] ) ; ASTNode val = SimplifyTerm ( term [ 2 ] ) ; output = nf -> CreateArrayTerm ( WRITE , iw , term . GetValueWidth ( ) , array , idx , val ) ; } break ; default : FatalError ( " " ) ; } UpdateSimplifyMap ( term , output , false ) ; assert ( term . GetIndexWidth ( ) == output . GetIndexWidth ( ) ) ; assert ( BVTypeCheck ( output ) ) ; return output ; }
recursively simplify things that are of type array.
recursively simplify things that are of type array .