@@ -151,17 +151,11 @@ import io.ksmt.expr.KUnaryMinusArithExpr
151
151
import io.ksmt.expr.KUninterpretedSortValue
152
152
import io.ksmt.expr.KUniversalQuantifier
153
153
import io.ksmt.expr.KXorExpr
154
- import io.ksmt.expr.rewrite.simplify.rewriteBvAddNoUnderflowExpr
155
- import io.ksmt.expr.rewrite.simplify.rewriteBvMulNoUnderflowExpr
156
154
import io.ksmt.expr.rewrite.simplify.rewriteBvNegNoOverflowExpr
157
155
import io.ksmt.expr.rewrite.simplify.rewriteBvSubNoUnderflowExpr
158
156
import io.ksmt.solver.KSolverUnsupportedFeatureException
159
- import org.ksmt.solver.bitwuzla.bindings.Bitwuzla
160
- import org.ksmt.solver.bitwuzla.bindings.BitwuzlaKind
161
- import org.ksmt.solver.bitwuzla.bindings.BitwuzlaRoundingMode
162
- import org.ksmt.solver.bitwuzla.bindings.BitwuzlaSort
163
- import org.ksmt.solver.bitwuzla.bindings.BitwuzlaTerm
164
- import org.ksmt.solver.bitwuzla.bindings.Native
157
+ import io.ksmt.solver.bitwuzla.KBitwuzlaExprInternalizer.BvOverflowCheckMode.OVERFLOW
158
+ import io.ksmt.solver.bitwuzla.KBitwuzlaExprInternalizer.BvOverflowCheckMode.UNDERFLOW
165
159
import io.ksmt.solver.util.KExprLongInternalizerBase
166
160
import io.ksmt.sort.KArithSort
167
161
import io.ksmt.sort.KArray2Sort
@@ -186,7 +180,13 @@ import io.ksmt.sort.KRealSort
186
180
import io.ksmt.sort.KSort
187
181
import io.ksmt.sort.KSortVisitor
188
182
import io.ksmt.sort.KUninterpretedSort
183
+ import org.ksmt.solver.bitwuzla.bindings.Bitwuzla
184
+ import org.ksmt.solver.bitwuzla.bindings.BitwuzlaKind
185
+ import org.ksmt.solver.bitwuzla.bindings.BitwuzlaRoundingMode
186
+ import org.ksmt.solver.bitwuzla.bindings.BitwuzlaSort
187
+ import org.ksmt.solver.bitwuzla.bindings.BitwuzlaTerm
189
188
import org.ksmt.solver.bitwuzla.bindings.BitwuzlaTermArray
189
+ import org.ksmt.solver.bitwuzla.bindings.Native
190
190
import java.math.BigInteger
191
191
192
192
@Suppress(" LargeClass" )
@@ -726,7 +726,7 @@ open class KBitwuzlaExprInternalizer(val bitwuzlaCtx: KBitwuzlaContext) : KExprL
726
726
override fun <T : KBvSort > transform (expr : KBvAddNoOverflowExpr <T >) = with (expr) {
727
727
transform(arg0, arg1) { a0: BitwuzlaTerm , a1: BitwuzlaTerm ->
728
728
if (isSigned) {
729
- mkBvAddSignedNoOverflowTerm(arg0.sort.sizeBits.toInt(), a0, a1, BvOverflowCheckMode . OVERFLOW )
729
+ mkBvAddSignedNoOverflowTerm(arg0.sort.sizeBits.toInt(), a0, a1, OVERFLOW )
730
730
} else {
731
731
val overflowCheck = Native .bitwuzlaMkTerm2(
732
732
bitwuzla, BitwuzlaKind .BITWUZLA_KIND_BV_UADD_OVERFLOW , a0, a1
@@ -738,20 +738,20 @@ open class KBitwuzlaExprInternalizer(val bitwuzlaCtx: KBitwuzlaContext) : KExprL
738
738
739
739
override fun <T : KBvSort > transform (expr : KBvAddNoUnderflowExpr <T >) = with (expr) {
740
740
transform(arg0, arg1) { a0: BitwuzlaTerm , a1: BitwuzlaTerm ->
741
- mkBvAddSignedNoOverflowTerm(arg0.sort.sizeBits.toInt(), a0, a1, BvOverflowCheckMode . UNDERFLOW )
741
+ mkBvAddSignedNoOverflowTerm(arg0.sort.sizeBits.toInt(), a0, a1, UNDERFLOW )
742
742
}
743
743
}
744
744
745
745
override fun <T : KBvSort > transform (expr : KBvSubNoOverflowExpr <T >) = with (expr) {
746
746
transform(arg0, arg1) { a0: BitwuzlaTerm , a1: BitwuzlaTerm ->
747
- mkBvSubSignedNoOverflowTerm(arg0.sort.sizeBits.toInt(), a0, a1, BvOverflowCheckMode . OVERFLOW )
747
+ mkBvSubSignedNoOverflowTerm(arg0.sort.sizeBits.toInt(), a0, a1, OVERFLOW )
748
748
}
749
749
}
750
750
751
751
override fun <T : KBvSort > transform (expr : KBvSubNoUnderflowExpr <T >) = with (expr) {
752
752
if (isSigned) {
753
753
transform(arg0, arg1) { a0: BitwuzlaTerm , a1: BitwuzlaTerm ->
754
- mkBvSubSignedNoOverflowTerm(arg0.sort.sizeBits.toInt(), a0, a1, BvOverflowCheckMode . UNDERFLOW )
754
+ mkBvSubSignedNoOverflowTerm(arg0.sort.sizeBits.toInt(), a0, a1, UNDERFLOW )
755
755
}
756
756
} else {
757
757
transform {
@@ -776,7 +776,7 @@ open class KBitwuzlaExprInternalizer(val bitwuzlaCtx: KBitwuzlaContext) : KExprL
776
776
override fun <T : KBvSort > transform (expr : KBvMulNoOverflowExpr <T >) = with (expr) {
777
777
transform(arg0, arg1) { a0: BitwuzlaTerm , a1: BitwuzlaTerm ->
778
778
if (isSigned) {
779
- mkBvMulSignedNoOverflowTerm(arg0.sort.sizeBits.toInt(), a0, a1, BvOverflowCheckMode . OVERFLOW )
779
+ mkBvMulSignedNoOverflowTerm(arg0.sort.sizeBits.toInt(), a0, a1, OVERFLOW )
780
780
} else {
781
781
val overflowCheck = Native .bitwuzlaMkTerm2(
782
782
bitwuzla, BitwuzlaKind .BITWUZLA_KIND_BV_UMUL_OVERFLOW , a0, a1
@@ -788,7 +788,7 @@ open class KBitwuzlaExprInternalizer(val bitwuzlaCtx: KBitwuzlaContext) : KExprL
788
788
789
789
override fun <T : KBvSort > transform (expr : KBvMulNoUnderflowExpr <T >) = with (expr) {
790
790
transform(arg0, arg1) { a0: BitwuzlaTerm , a1: BitwuzlaTerm ->
791
- mkBvMulSignedNoOverflowTerm(arg0.sort.sizeBits.toInt(), a0, a1, BvOverflowCheckMode . UNDERFLOW )
791
+ mkBvMulSignedNoOverflowTerm(arg0.sort.sizeBits.toInt(), a0, a1, UNDERFLOW )
792
792
}
793
793
}
794
794
@@ -813,7 +813,7 @@ open class KBitwuzlaExprInternalizer(val bitwuzlaCtx: KBitwuzlaContext) : KExprL
813
813
a1,
814
814
BitwuzlaKind .BITWUZLA_KIND_BV_SADD_OVERFLOW
815
815
) { a0Sign, a1Sign ->
816
- if (mode == BvOverflowCheckMode . OVERFLOW ) {
816
+ if (mode == OVERFLOW ) {
817
817
// Both positive
818
818
mkAndTerm(longArrayOf(mkNotTerm(a0Sign), mkNotTerm(a1Sign)))
819
819
} else {
@@ -833,7 +833,7 @@ open class KBitwuzlaExprInternalizer(val bitwuzlaCtx: KBitwuzlaContext) : KExprL
833
833
a1,
834
834
BitwuzlaKind .BITWUZLA_KIND_BV_SSUB_OVERFLOW
835
835
) { a0Sign, a1Sign ->
836
- if (mode == BvOverflowCheckMode . OVERFLOW ) {
836
+ if (mode == OVERFLOW ) {
837
837
// Positive sub negative
838
838
mkAndTerm(longArrayOf(mkNotTerm(a0Sign), a1Sign))
839
839
} else {
@@ -853,7 +853,7 @@ open class KBitwuzlaExprInternalizer(val bitwuzlaCtx: KBitwuzlaContext) : KExprL
853
853
a1,
854
854
BitwuzlaKind .BITWUZLA_KIND_BV_SMUL_OVERFLOW
855
855
) { a0Sign, a1Sign ->
856
- if (mode == BvOverflowCheckMode . OVERFLOW ) {
856
+ if (mode == OVERFLOW ) {
857
857
// Overflow is possible when sign bits are equal
858
858
mkEqTerm(bitwuzlaCtx.ctx.boolSort, a0Sign, a1Sign)
859
859
} else {
@@ -1401,6 +1401,8 @@ open class KBitwuzlaExprInternalizer(val bitwuzlaCtx: KBitwuzlaContext) : KExprL
1401
1401
}
1402
1402
1403
1403
override fun transform (expr : KUninterpretedSortValue ): KExpr <KUninterpretedSort > = expr.transform {
1404
+ // register it for uninterpreted sort universe
1405
+ bitwuzlaCtx.registerDeclaration(expr.decl)
1404
1406
Native .bitwuzlaMkBvValueUint32(
1405
1407
bitwuzla,
1406
1408
expr.sort.internalizeSort(),
0 commit comments