@@ -5,7 +5,11 @@ import org.scalatest.funsuite.AnyFunSuite
5
5
import smtlib .trees .Commands ._
6
6
import smtlib .trees .CommandsResponses ._
7
7
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
9
13
10
14
/** Checks that formula build with theories module are correctly handled by solvers */
11
15
class TheoriesBuilderTests extends AnyFunSuite with TestHelpers {
@@ -57,6 +61,50 @@ class TheoriesBuilderTests extends AnyFunSuite with TestHelpers {
57
61
} else {
58
62
ignore(cvc5Test) {}
59
63
}
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
+ }
60
108
}
61
109
62
110
@@ -221,8 +269,8 @@ class TheoriesBuilderTests extends AnyFunSuite with TestHelpers {
221
269
val f18 = Equals (Add (BitVectorConstant (1 , 32 ), BitVectorConstant (2 , 32 ), BitVectorConstant (3 , 32 ), BitVectorConstant (4 , 32 )), BitVectorConstant (10 , 32 ))
222
270
mkTest(f18, SatStatus , uniqueName())
223
271
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())
226
274
}
227
275
228
276
{
0 commit comments