SubstitutionMap::~SubstitutionMap()
{
delete SolverMap;
+ delete nf;
}
// if false. Don't simplify while creating the substitution map.
else if (XOR == k)
{
if (a.Degree() !=2)
- return output;
+ return output;
int to = TermOrder(a[0],a[1]);
if (0 == to)
- return output;
-
- ASTNode symbol,rhs;
- if (to==1)
- {
- symbol = a[0];
- rhs = a[1];
- }
+ {
+ if (a[0].GetKind() == NOT && a[0][0].GetKind() == EQ && a[0][0][0].GetValueWidth() ==1 && a[0][0][1].GetKind() == SYMBOL)
+ {
+ // (XOR (NOT(= (1 v))) ... )
+ const ASTNode& symbol = a[0][0][1];
+ const ASTNode newN = nf->CreateTerm(ITE, 1, a[1], a[0][0][0], nf->CreateTerm(BVNEG, 1,a[0][0][0]));
+
+ if (UpdateSolverMap(symbol, newN))
+ output = ASTTrue;
+ }
+ else if (a[0].GetKind() == EQ && a[0][0].GetValueWidth() ==1 && a[0][1].GetKind() == SYMBOL)
+ {
+ // XOR ((= 1 v) ... )
+
+ const ASTNode& symbol = a[0][1];
+ const ASTNode newN = nf->CreateTerm(ITE, 1, a[1], nf->CreateTerm(BVNEG, 1,a[0][0]), a[0][0]);
+
+ if (UpdateSolverMap(symbol, newN))
+ output = ASTTrue;
+ }
+ else
+ return output;
+ }
else
- {
- symbol = a[0];
- rhs = a[1];
- }
-
- assert(symbol.GetKind() == SYMBOL);
-
- // If either side is already solved for.
- if (CheckSubstitutionMap(symbol) || CheckSubstitutionMap(rhs))
- {}
- else if (UpdateSolverMap(symbol, bm->CreateNode(NOT, rhs)))
- output = ASTTrue;
+ {
+ ASTNode symbol,rhs;
+ if (to==1)
+ {
+ symbol = a[0];
+ rhs = a[1];
+ }
+ else
+ {
+ symbol = a[1];
+ rhs = a[0];
+ }
+
+ assert(symbol.GetKind() == SYMBOL);
+
+ if (UpdateSolverMap(symbol, nf->CreateNode(NOT, rhs)))
+ output = ASTTrue;
+ }
}
else if (AND == k)
{
else if (o.size() == 1)
output = o[0];
else if (o != c)
- output = bm->CreateNode(AND, o);
+ output = nf->CreateNode(AND, o);
else
output = a;
}
{
bm->GetRunTimes()->start(RunTimes::ApplyingSubstitutions);
ASTNodeMap cache;
- SimplifyingNodeFactory nf(*bm->hashingNodeFactory, *bm);
- ASTNode result = replace(n,*SolverMap,cache,&nf, false);
+ ASTNode result = replace(n,*SolverMap,cache,nf, false);
// NB. This is an expensive check. Remove it after it's been idempotent
// for a while.
{
bm->GetRunTimes()->start(RunTimes::ApplyingSubstitutions);
ASTNodeMap cache;
- SimplifyingNodeFactory nf(*bm->hashingNodeFactory, *bm);
- ASTNode result = replace(n,*SolverMap,cache,&nf, true);
+ ASTNode result = replace(n,*SolverMap,cache,nf, true);
bm->GetRunTimes()->stop(RunTimes::ApplyingSubstitutions);
return result;
}
Simplifier *simp;
STPMgr* bm;
ASTNode ASTTrue, ASTFalse, ASTUndefined;
+ NodeFactory *nf;
// These are used to avoid substituting {x = f(y,z), z = f(x)}
typedef hash_map<ASTNode, Symbols*,ASTNode::ASTNodeHasher> DependsType;
VariablesInExpression vars;
- SubstitutionMap(Simplifier *_simp, STPMgr* _bm) {
+ SubstitutionMap(Simplifier *_simp, STPMgr* _bm)
+ {
simp = _simp;
bm = _bm;
SolverMap = new ASTNodeMap(INITIAL_TABLE_SIZE);
loopCount = 0;
substitutionsLastApplied =0;
+ nf = new SimplifyingNodeFactory (*bm->hashingNodeFactory, *bm);
}
void clear()