ASTNode Simplifier::FlattenOneLevel(const ASTNode& a)
{
const Kind k = a.GetKind();
- if (!(BVPLUS == k || AND == k || OR == k
+ if (!(BVPLUS == k || AND == k || OR == k || BVMULT == k
//|| BVAND == k
//|| BVOR == k
))
return output;
} //end of flattenonelevel()
+
+ ASTNode
+ Simplifier::makeTower(const Kind k, const BEEV::ASTVec &children)
+ {
+ deque<ASTNode> names;
+
+ for (unsigned i = 0; i < children.size(); i++)
+ names.push_back(children[i]);
+
+ while (names.size() > 2)
+ {
+ ASTNode a = names.front();
+ names.pop_front();
+
+ ASTNode b = names.front();
+ names.pop_front();
+
+ ASTNode n = nf->CreateTerm(k, a.GetValueWidth(), a, b);
+ names.push_back(n);
+ }
+
+ // last two now.
+ assert(names.size() == 2);
+
+ ASTNode a = names.front();
+ names.pop_front();
+
+ ASTNode b = names.front();
+ names.pop_front();
+
+ return nf->CreateTerm(k, a.GetValueWidth(), a, b);
+ }
+
+
//This function simplifies terms based on their kind
ASTNode
Simplifier::SimplifyTerm(const ASTNode& actualInputterm,
output = inputterm;
break;
case BVMULT:
-
- assert(2 == inputterm.Degree());
- // follow on.
+ // follow on.
case BVPLUS:
{
const ASTNode &n = Flatten(inputterm);
}
}
-
-
- if (BVMULT == output.GetKind() || BVPLUS == output.GetKind())
+ if (BVMULT == output.GetKind())
+ {
+ output = makeTower(BVMULT,output.GetChildren());
+ }
+ else if ( BVPLUS == output.GetKind())
{
ASTVec d = output.GetChildren();
SortByArith(d);