* The substitution map now substitutes for (IFF SYMBOL SYMBOL)
* sim.smt2 is the test case to check the above substitution is working.
* The ArrayTransformer creates fewer new nodes.
git-svn-id: https://stp-fast-prover.svn.sourceforge.net/svnroot/stp-fast-prover/trunk/stp@889
e59a4935-1847-0410-ae03-
e826735625c1
o.push_back(TransformTerm(*it));
}
- result = nf->CreateTerm(k, width, o);
- result.SetIndexWidth(indexwidth);
+ if (c!=o)
+ {
+ result = nf->CreateTerm(k, width, o);
+ result.SetIndexWidth(indexwidth);
+ }
+ else
+ result = term;
const Kind k = result.GetKind();
// == BVCONST)))
return 1;
- if (SYMBOL == k1 && (BVCONST == k2 || TRUE == k2 || FALSE == k2))
+ if (SYMBOL == k1 && (BVCONST == k2 || TRUE == k2 || FALSE == k2 || SYMBOL ==k2))
return 1;
//b is of the form READ(Arr,const), and a is const, or
if (SYMBOL == k2
&& (BVCONST == k1
|| TRUE == k1
- || FALSE == k1))
+ || FALSE == k1
+ || SYMBOL == k1
+ ))
return -1;
return 0;
} //End of TermOrder()
-//This finds everything which is (= SYMBOL BVCONST) and everything that is (READ SYMBOL BVCONST).
+//This finds everything which is: (= SYMBOL BVCONST), (READ SYMBOL BVCONST),
+// (IFF SYMBOL TRUE), (IFF SYMBOL FALSE), (IFF SYMBOL SYMBOL), (=SYMBOL SYMBOL)
+// or (=SYMBOL BVCONST).
+// The bvsolver goes to a lot more trouble to make similar substitutions, the
+// main advantage that the below function has is that it doesn't need to check
+// (much) if the symbol being substituted for is on the RHS.
+//The UpdateSubstitionMap() function does all the checking that's needed.
+//
//i.e. anything that has a termorder of 1 or -1.
// The bvsolver puts expressions of the form (= SYMBOL TERM) into the solverMap.
if (IFF == k || EQ == k)
{
- ASTVec c = a.GetChildren();
- SortByArith(c);
+ ASTVec c = a.GetChildren();
+ SortByArith(c);
+
+ if (c[0] == c[1])
+ return ASTTrue;
ASTNode c1;
if (EQ == k)
assert(e0.GetValueWidth() == e1.GetValueWidth());
assert(e0.GetIndexWidth() == e1.GetIndexWidth());
+ if (SYMBOL == e1.GetKind() && CheckSubstitutionMap(e1))
+ {
+ // if we didn't check this, scenarios like:
+ // a <-> b
+ // b <-> a
+ // would cause a loop.
+ return false;
+ }
+
//e0 is of the form READ(Arr,const), and e1 is const, or
//e0 is of the form var, and e1 is const
if (1 == i && !CheckSubstitutionMap(e0)) {
assert((e1.GetKind() == TRUE) ||
(e1.GetKind() == FALSE) ||
+ (e1.GetKind() == SYMBOL) ||
(e1.GetKind() == BVCONST));
(*SolverMap)[e0] = e1;
return true;
if (-1 == i && !CheckSubstitutionMap(e1)) {
assert((e0.GetKind() == TRUE) ||
(e0.GetKind() == FALSE) ||
+ (e0.GetKind() == SYMBOL) ||
(e0.GetKind() == BVCONST));
(*SolverMap)[e1] = e0;
return true;
+++ /dev/null
-p cnf 1 2
-1 0
-1 0
--- /dev/null
+
+(set-logic QF_BV)
+(set-info :smt-lib-version 2.0)
+(set-info :category "check")
+(set-info :status sat)
+(declare-fun v0 () Bool )
+(declare-fun v1 () Bool )
+(declare-fun v2 () Bool )
+(declare-fun v3 () Bool )
+
+; not xor is iff.
+
+(assert (not (xor v0 v1)))
+(assert (not (xor v1 v2)))
+(assert (not (xor v2 v3)))
+
+(check-sat)
+(exit)
+
+
#Each file should be simplified down to either true or false, so the CNF generated should
#be very small if simplifications are working as they should.
-rm output_*.cnf
+rm -f output_*.cnf
files=`ls -1 -S *.smt2`
for f in $files; do