Skip to content

Commit 61b0aac

Browse files
Filter tests for bitwuzla by compatibility
1 parent 4e36f80 commit 61b0aac

File tree

1 file changed

+51
-3
lines changed

1 file changed

+51
-3
lines changed

src/it/scala/smtlib/it/TheoriesBuilderTests.scala

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import org.scalatest.funsuite.AnyFunSuite
55
import smtlib.trees.Commands._
66
import smtlib.trees.CommandsResponses._
77
import smtlib.trees.Terms._
8-
8+
import smtlib.theories.FloatingPoint.FloatingPointSort
9+
import smtlib.theories.FixedSizeBitVectors.BitVectorSort
10+
import smtlib.trees.TreesOps
11+
import smtlib.trees.Tree
12+
import smtlib.theories.FixedSizeBitVectors
913

1014
/** Checks that formula build with theories module are correctly handled by solvers */
1115
class TheoriesBuilderTests extends AnyFunSuite with TestHelpers {
@@ -57,6 +61,50 @@ class TheoriesBuilderTests extends AnyFunSuite with TestHelpers {
5761
} else {
5862
ignore(cvc5Test) {}
5963
}
64+
65+
/**
66+
* Is test in the fragment supported by bitwuzla?
67+
*
68+
* May not contain ints, reals, arrays, ADTs
69+
*
70+
*/
71+
def testIsBitwuzlaCompatible: Boolean =
72+
def isCompat(term: Term): Boolean =
73+
def violatingTerm(term: Tree, children: Seq[Boolean]): Boolean = {
74+
import smtlib.theories.*
75+
term match
76+
case FixedSizeBitVectors.BitVectorConstant(_, _) => false // internally contains IntNumeral, but in a valid place
77+
case Ints.NumeralLit(_) => true
78+
case Reals.DecimalLit(_) => true
79+
case FixedSizeBitVectors.Int2BV(_, _) => true
80+
case FixedSizeBitVectors.BV2Nat(_) => true
81+
// this is enough to rule out the current problematic tests,
82+
// but may need refinement
83+
case _ => children.contains(true)
84+
}
85+
!TreesOps.fold(violatingTerm)(term)
86+
87+
def compatibleCommand(cmd: Command): Boolean =
88+
cmd match
89+
case DeclareFun(_, paramSorts, sort) => (sort +: paramSorts).forall {
90+
case BitVectorSort(_) => true
91+
case FloatingPointSort(_, _) => true
92+
case _ => false
93+
}
94+
case DeclareSort(_, _) => false
95+
case DeclareDatatypes(_) => false
96+
case Assert(term) => isCompat(term)
97+
case _ => true // may need refinement
98+
cmds.forall(compatibleCommand) && (isCompat(formula))
99+
100+
val bitwuzlaTest = prefix + ": with Bitwuzla"
101+
if (isBitwuzlaAvailable && testIsBitwuzlaCompatible) {
102+
test(bitwuzlaTest) {
103+
runAndCheck(getBitwuzlaInterpreter)
104+
}
105+
} else {
106+
ignore(bitwuzlaTest) {}
107+
}
60108
}
61109

62110

@@ -221,8 +269,8 @@ class TheoriesBuilderTests extends AnyFunSuite with TestHelpers {
221269
val f18 = Equals(Add(BitVectorConstant(1, 32), BitVectorConstant(2, 32), BitVectorConstant(3, 32), BitVectorConstant(4, 32)), BitVectorConstant(10, 32))
222270
mkTest(f18, SatStatus, uniqueName())
223271

224-
val f20 = Equals(Mul(BitVectorConstant(1, 32), BitVectorConstant(2, 32), BitVectorConstant(3, 32), BitVectorConstant(4, 32)), BitVectorConstant(24, 32))
225-
mkTest(f20, SatStatus, uniqueName())
272+
val f19 = Equals(Mul(BitVectorConstant(1, 32), BitVectorConstant(2, 32), BitVectorConstant(3, 32), BitVectorConstant(4, 32)), BitVectorConstant(24, 32))
273+
mkTest(f19, SatStatus, uniqueName())
226274
}
227275

228276
{

0 commit comments

Comments
 (0)