Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Bitwuzla solver support #71

Merged
merged 72 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
2a26cd9
Fp 16 fixes && eval for fp.add
Saloed Jan 25, 2023
f348bea
Fix fp 16
Saloed Jan 27, 2023
878ba3e
KAst structural equality methods
Saloed Jan 17, 2023
28708b9
tmp
Saloed Jan 17, 2023
642d517
KInternedObject
Saloed Jan 18, 2023
1961d8a
Optimizations
Saloed Jan 18, 2023
e328f36
ConcurrentWeakHashMap
Saloed Jan 18, 2023
84806be
Ast interner
Saloed Jan 18, 2023
88cd4eb
remove caffeine
Saloed Jan 18, 2023
d5d3120
Faster cache
Saloed Jan 19, 2023
e39833f
Parametrize ast management modes
Saloed Jan 19, 2023
4c093d9
Single thread weak caches
Saloed Jan 19, 2023
d472ffd
Bv compare
Saloed Jan 31, 2023
80c6f7e
Fix after rebase
Saloed Feb 2, 2023
2517bd8
Comment empty arith add simplified args
Saloed Feb 17, 2023
e723c10
JNA to JNI migration (#69)
DKARAGODIN Feb 6, 2023
3f6d231
Initial native part fix
Saloed Feb 6, 2023
69d26f4
Timeouts
Saloed Feb 6, 2023
006b789
check exception handling
Saloed Feb 7, 2023
f9d5c18
better timeout handling
Saloed Feb 7, 2023
b66c9d4
enable ipo
Saloed Feb 7, 2023
0b29768
Fix default array value handling
Saloed Feb 7, 2023
f54375d
Jni bindings
Saloed Feb 7, 2023
8ee97cc
Fix Native documentation
Saloed Feb 7, 2023
fbd04c3
Enum wrappers
Saloed Feb 7, 2023
4d68757
Cleanup
Saloed Feb 7, 2023
825f3fc
Remove dummy test
Saloed Feb 7, 2023
7361b30
Fix timeout test
Saloed Feb 7, 2023
be4759d
Fix detekt issues
Saloed Feb 7, 2023
bc30f08
Rework unsupported theories for Bitwuzla
Saloed Feb 7, 2023
8ffea7a
Support quantifiers in bitwuzla
Saloed Feb 7, 2023
34f93d2
Fix nested quantifiers conversion
Saloed Feb 7, 2023
8f2c173
Small fixes
Saloed Feb 7, 2023
e0240c1
Better Bitwuzla bv bits api
Saloed Feb 7, 2023
f068d93
New API based converter
Saloed Feb 7, 2023
8c0550d
New API based internalizer
Saloed Feb 7, 2023
df32c30
Update docs
Saloed Feb 7, 2023
8ed1ea2
axioms
Saloed Feb 7, 2023
304feae
Minor
Saloed Feb 8, 2023
8979662
fix bigInt to bits
Saloed Feb 8, 2023
c844f24
fix bigInt to bits
Saloed Feb 8, 2023
bba6a02
Fix fp64 conversion
Saloed Feb 8, 2023
1dc5633
Use KSMT based model evaluation
Saloed Feb 8, 2023
9a5671c
Better model evaluator for partial functions
Saloed Feb 8, 2023
aede677
Fix bv bit utils
Saloed Feb 8, 2023
96cf82b
Better handling of as-array expressions in model evaluator
Saloed Feb 8, 2023
8fbcedf
Fix bit utils
Saloed Feb 8, 2023
1ce7211
Better doc for bits
Saloed Feb 8, 2023
affaf0b
m
Saloed Feb 8, 2023
e8d5c0e
Fix as-array rewrite loops
Saloed Feb 8, 2023
67708ba
Special test data-source for Bitwuzla model conversion
Saloed Feb 8, 2023
f04efda
Fix detekt issues
Saloed Feb 8, 2023
103267f
Ensure bitwuzla ctx is active
Saloed Feb 8, 2023
825dc43
Rebase
Saloed Feb 10, 2023
5aa72de
Skip Z3 fma failures
Saloed Feb 10, 2023
ebec86d
Skip fp max/min with +/- 0
Saloed Feb 10, 2023
a39692e
Fix Z3 fma test issues
Saloed Feb 10, 2023
fc2a859
minor change
Saloed Feb 10, 2023
0118ddc
fix vars management
Saloed Feb 10, 2023
3637e72
Move comment
Saloed Feb 13, 2023
ec7a9dd
Use unsat assumptions instead of core
Saloed Feb 13, 2023
82f0e34
Support for uninterpreted sorts
Saloed Feb 13, 2023
8b2e66e
Rework declaration scoping
Saloed Feb 13, 2023
525574c
Better tests parametrization
Saloed Feb 13, 2023
2854d7d
Fix model detach
Saloed Feb 13, 2023
14f5976
Fix detekt issues
Saloed Feb 13, 2023
a855f76
Minor fix
Saloed Feb 14, 2023
284eda3
Use adapter for uninterpreted sort conversion
Saloed Feb 14, 2023
c83e78f
rebase
Saloed Feb 14, 2023
3597679
Fix pointer formatting
Saloed Feb 17, 2023
e8c95dc
Fixes
Saloed Feb 17, 2023
e73a487
Rebase
Saloed Feb 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
JNA to JNI migration (#69)
  • Loading branch information
DKARAGODIN authored and Saloed committed Feb 17, 2023
commit e723c109bdfb1b2904ff6360dca0449457ef7004
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/org.ksmt.ksmt-base.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tasks.withType<KotlinCompile> {
}

tasks.getByName<KotlinCompile>("compileKotlin") {
kotlinOptions.allWarningsAsErrors = true
kotlinOptions.allWarningsAsErrors = false
}

tasks.withType<Test> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.sun.jna.Pointer
import org.ksmt.decl.KDecl
import org.ksmt.expr.KExpr
import org.ksmt.solver.KSolverException
import org.ksmt.solver.bitwuzla.bindings.BitwuzlaException
import org.ksmt.solver.bitwuzla.bindings.BitwuzlaSort
import org.ksmt.solver.bitwuzla.bindings.BitwuzlaTerm
import org.ksmt.solver.bitwuzla.bindings.Native
Expand Down Expand Up @@ -119,7 +120,7 @@ open class KBitwuzlaContext : AutoCloseable {
/**
* Keep strong reference to bitwuzla timeout callback to avoid sigsegv.
* */
private var timeoutTerminator: BitwuzlaTimeout? = null
//private var timeoutTerminator: BitwuzlaTimeout? = null

@OptIn(ExperimentalTime::class)
fun <T> withTimeout(timeout: Duration, body: () -> T): T {
Expand All @@ -130,21 +131,21 @@ open class KBitwuzlaContext : AutoCloseable {

val currentTime = TimeSource.Monotonic.markNow()
val finishTime = currentTime + timeout
timeoutTerminator = BitwuzlaTimeout(finishTime)
//timeoutTerminator = BitwuzlaTimeout(finishTime)

try {
Native.bitwuzlaSetTerminationCallback(bitwuzla, timeoutTerminator, state = null)
//Native.bitwuzlaSetTerminationCallback(bitwuzla, timeoutTerminator, state = null)
return body()
} finally {
timeoutTerminator = null
Native.bitwuzlaResetTerminationCallback(bitwuzla)
//timeoutTerminator = null
//Native.bitwuzlaResetTerminationCallback(bitwuzla)
}
}

inline fun <reified T> bitwuzlaTry(body: () -> T): T = try {
ensureActive()
body()
} catch (ex: Native.BitwuzlaException) {
} catch (ex: BitwuzlaException) {
throw KSolverException(ex)
}

Expand Down Expand Up @@ -221,8 +222,8 @@ open class KBitwuzlaContext : AutoCloseable {
constants[decl to sort] ?: parent.mkConstant(decl, sort)
}

@OptIn(ExperimentalTime::class)
/* @OptIn(ExperimentalTime::class)
class BitwuzlaTimeout(private val finishTime: TimeMark) : Native.BitwuzlaTerminationCallback {
override fun terminate(state: Pointer?): Int = if (finishTime.hasNotPassedNow()) 0 else 1
}
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ open class KBitwuzlaExprConverter(

@Suppress("LongMethod", "ComplexMethod")
override fun convertNativeExpr(expr: BitwuzlaTerm): ExprConversionResult = with(ctx) {
when (val kind = Native.bitwuzlaTermGetKind(expr)) {
when (val kind = BitwuzlaKind.fromValue(Native.bitwuzlaTermGetKind(expr))) {
// constants, functions, values
BitwuzlaKind.BITWUZLA_KIND_CONST -> convertConst(expr)
BitwuzlaKind.BITWUZLA_KIND_APPLY -> convertFunctionApp(expr)
Expand Down Expand Up @@ -927,34 +927,34 @@ open class KBitwuzlaExprConverter(
op: (KExpr<A0>) -> KExpr<T>
): ExprConversionResult {
val args = Native.bitwuzlaTermGetChildren(this)
return convert(args, op)
return convert(Array(args.size) { args[it] }, op)
}

inline fun <T : KSort, A0 : KSort, A1 : KSort> BitwuzlaTerm.convert(
op: (KExpr<A0>, KExpr<A1>) -> KExpr<T>
): ExprConversionResult {
val args = Native.bitwuzlaTermGetChildren(this)
return convert(args, op)
return convert(Array(args.size) { args[it] }, op)
}

inline fun <T : KSort, A0 : KSort, A1 : KSort, A2 : KSort> BitwuzlaTerm.convert(
op: (KExpr<A0>, KExpr<A1>, KExpr<A2>) -> KExpr<T>
): ExprConversionResult {
val args = Native.bitwuzlaTermGetChildren(this)
return convert(args, op)
return convert(Array(args.size) { args[it] }, op)
}

inline fun <T : KSort, A0 : KSort, A1 : KSort, A2 : KSort, A3 : KSort> BitwuzlaTerm.convert(
op: (KExpr<A0>, KExpr<A1>, KExpr<A2>, KExpr<A3>) -> KExpr<T>
): ExprConversionResult {
val args = Native.bitwuzlaTermGetChildren(this)
return convert(args, op)
return convert(Array(args.size) { args[it] }, op)
}

inline fun <T : KSort, A : KSort> BitwuzlaTerm.convertList(
op: (List<KExpr<A>>) -> KExpr<T>
): ExprConversionResult {
val args = Native.bitwuzlaTermGetChildren(this)
return convertList(args, op)
return convertList(Array(args.size) { args[it] }, op)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ open class KBitwuzlaExprInternalizer(
// Save only constants
if (expr !is KInterpretedValue<*>) return

val kind = Native.bitwuzlaTermGetKind(term)
val kind = BitwuzlaKind.fromValue(Native.bitwuzlaTermGetKind(term))

/*
* Save internalized values for [KBitwuzlaExprConverter] needs
Expand All @@ -229,7 +229,7 @@ open class KBitwuzlaExprInternalizer(
val const = bitwuzlaCtx.mkConstant(decl, decl.bitwuzlaFunctionSort())
val termArgs = (listOf(const) + args).toTypedArray()

Native.bitwuzlaMkTerm(bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_APPLY, termArgs)
Native.bitwuzlaMkTerm(bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_APPLY.value, termArgs.toLongArray())
}
}

Expand All @@ -243,7 +243,7 @@ open class KBitwuzlaExprInternalizer(
0 -> bitwuzlaCtx.trueTerm
1 -> args[0]
else -> Native.bitwuzlaMkTerm(
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_AND, args
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_AND.value, args.toLongArray()
)
}
}
Expand All @@ -255,7 +255,7 @@ open class KBitwuzlaExprInternalizer(
0 -> bitwuzlaCtx.falseTerm
1 -> args[0]
else -> Native.bitwuzlaMkTerm(
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_OR, args
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_OR.value, args.toLongArray()
)
}
}
Expand Down Expand Up @@ -284,7 +284,7 @@ open class KBitwuzlaExprInternalizer(
override fun <T : KSort> transform(expr: KDistinctExpr<T>) = with(expr) {
transformList(args) { args: Array<BitwuzlaTerm> ->
Native.bitwuzlaMkTerm(
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_DISTINCT, args
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_DISTINCT.value, args.toLongArray()
)
}
}
Expand Down Expand Up @@ -332,7 +332,7 @@ open class KBitwuzlaExprInternalizer(
)
Native.bitwuzlaMkTerm2(
bitwuzlaCtx.bitwuzla,
BitwuzlaKind.BITWUZLA_KIND_BV_CONCAT,
BitwuzlaKind.BITWUZLA_KIND_BV_CONCAT.value,
higherBitsTerm,
lowerBitsTerm
).also { bitwuzlaCtx.saveInternalizedValue(expr, it) }
Expand All @@ -345,7 +345,7 @@ open class KBitwuzlaExprInternalizer(
bitwuzlaCtx.bitwuzla,
sort.internalizeSort(),
stringValue,
BitwuzlaBVBase.BITWUZLA_BV_BASE_BIN
BitwuzlaBVBase.BITWUZLA_BV_BASE_BIN.value
).also { bitwuzlaCtx.saveInternalizedValue(expr, it) }
}
}
Expand Down Expand Up @@ -461,7 +461,7 @@ open class KBitwuzlaExprInternalizer(
override fun transform(expr: KBvExtractExpr) = with(expr) {
transform(value) { arg: BitwuzlaTerm ->
Native.bitwuzlaMkTerm1Indexed2(
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_BV_EXTRACT,
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_BV_EXTRACT.value,
arg,
high, low
)
Expand All @@ -471,7 +471,7 @@ open class KBitwuzlaExprInternalizer(
override fun transform(expr: KBvSignExtensionExpr) = with(expr) {
transform(value) { arg: BitwuzlaTerm ->
Native.bitwuzlaMkTerm1Indexed1(
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_BV_SIGN_EXTEND,
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_BV_SIGN_EXTEND.value,
arg,
extensionSize
)
Expand All @@ -481,7 +481,7 @@ open class KBitwuzlaExprInternalizer(
override fun transform(expr: KBvZeroExtensionExpr) = with(expr) {
transform(value) { arg: BitwuzlaTerm ->
Native.bitwuzlaMkTerm1Indexed1(
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_BV_ZERO_EXTEND,
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_BV_ZERO_EXTEND.value,
arg,
extensionSize
)
Expand All @@ -491,7 +491,7 @@ open class KBitwuzlaExprInternalizer(
override fun transform(expr: KBvRepeatExpr) = with(expr) {
transform(value) { arg: BitwuzlaTerm ->
Native.bitwuzlaMkTerm1Indexed1(
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_BV_REPEAT,
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_BV_REPEAT.value,
arg,
repeatNumber
)
Expand Down Expand Up @@ -521,7 +521,7 @@ open class KBitwuzlaExprInternalizer(
override fun <T : KBvSort> transform(expr: KBvRotateLeftIndexedExpr<T>) = with(expr) {
transform(value) { arg: BitwuzlaTerm ->
Native.bitwuzlaMkTerm1Indexed1(
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_BV_ROLI,
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_BV_ROLI.value,
arg,
rotationNumber
)
Expand All @@ -531,7 +531,7 @@ open class KBitwuzlaExprInternalizer(
override fun <T : KBvSort> transform(expr: KBvRotateRightIndexedExpr<T>) = with(expr) {
transform(value) { arg: BitwuzlaTerm ->
Native.bitwuzlaMkTerm1Indexed1(
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_BV_RORI,
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_BV_RORI.value,
arg,
rotationNumber
)
Expand Down Expand Up @@ -600,7 +600,7 @@ open class KBitwuzlaExprInternalizer(
val body = with(bodyInternalizer) {
body.internalize()
}
val bodyKind = Native.bitwuzlaTermGetKind(body)
val bodyKind = BitwuzlaKind.fromValue(Native.bitwuzlaTermGetKind(body))

if (bodyKind == BitwuzlaKind.BITWUZLA_KIND_ARRAY_SELECT) {
val selectArgs = Native.bitwuzlaTermGetChildren(body)
Expand All @@ -623,13 +623,13 @@ open class KBitwuzlaExprInternalizer(
override fun transform(
expr: KExistentialQuantifier
): KExpr<KBoolSort> = expr.internalizeQuantifier { args ->
Native.bitwuzlaMkTerm(bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_EXISTS, args)
Native.bitwuzlaMkTerm(bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_EXISTS.value, args.toLongArray())
}

override fun transform(
expr: KUniversalQuantifier
): KExpr<KBoolSort> = expr.internalizeQuantifier { args ->
Native.bitwuzlaMkTerm(bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_FORALL, args)
Native.bitwuzlaMkTerm(bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_FORALL.value, args.toLongArray())
}

override fun transform(expr: KBv2IntExpr): KExpr<KIntSort> {
Expand Down Expand Up @@ -740,11 +740,11 @@ open class KBitwuzlaExprInternalizer(
override fun transform(expr: KFpRoundingModeExpr): KExpr<KFpRoundingModeSort> = with(expr) {
transform {
val rmMode = when (value) {
KFpRoundingMode.RoundNearestTiesToEven -> BitwuzlaRoundingMode.BITWUZLA_RM_RNE
KFpRoundingMode.RoundNearestTiesToAway -> BitwuzlaRoundingMode.BITWUZLA_RM_RNA
KFpRoundingMode.RoundTowardPositive -> BitwuzlaRoundingMode.BITWUZLA_RM_RTP
KFpRoundingMode.RoundTowardNegative -> BitwuzlaRoundingMode.BITWUZLA_RM_RTN
KFpRoundingMode.RoundTowardZero -> BitwuzlaRoundingMode.BITWUZLA_RM_RTZ
KFpRoundingMode.RoundNearestTiesToEven -> BitwuzlaRoundingMode.BITWUZLA_RM_RNE.value
KFpRoundingMode.RoundNearestTiesToAway -> BitwuzlaRoundingMode.BITWUZLA_RM_RNA.value
KFpRoundingMode.RoundTowardPositive -> BitwuzlaRoundingMode.BITWUZLA_RM_RTP.value
KFpRoundingMode.RoundTowardNegative -> BitwuzlaRoundingMode.BITWUZLA_RM_RTN.value
KFpRoundingMode.RoundTowardZero -> BitwuzlaRoundingMode.BITWUZLA_RM_RTZ.value
}
Native.bitwuzlaMkRmValue(bitwuzlaCtx.bitwuzla, rmMode)
}
Expand Down Expand Up @@ -849,7 +849,7 @@ open class KBitwuzlaExprInternalizer(
override fun <T : KFpSort> transform(expr: KFpToBvExpr<T>): KExpr<KBvSort> = with(expr) {
transform(roundingMode, value) { rm: BitwuzlaTerm, value: BitwuzlaTerm ->
val operation = if (isSigned) BitwuzlaKind.BITWUZLA_KIND_FP_TO_SBV else BitwuzlaKind.BITWUZLA_KIND_FP_TO_UBV
Native.bitwuzlaMkTerm2Indexed1(bitwuzlaCtx.bitwuzla, operation, rm, value, bvSize)
Native.bitwuzlaMkTerm2Indexed1(bitwuzlaCtx.bitwuzla, operation.value, rm, value, bvSize)
}
}

Expand All @@ -861,7 +861,7 @@ open class KBitwuzlaExprInternalizer(
transform(roundingMode, value) { rm: BitwuzlaTerm, value: BitwuzlaTerm ->
Native.bitwuzlaMkTerm2Indexed2(
bitwuzlaCtx.bitwuzla,
BitwuzlaKind.BITWUZLA_KIND_FP_TO_FP_FROM_FP,
BitwuzlaKind.BITWUZLA_KIND_FP_TO_FP_FROM_FP.value,
rm,
value,
sort.exponentBits.toInt(),
Expand All @@ -877,7 +877,7 @@ open class KBitwuzlaExprInternalizer(
significand
) { sign: BitwuzlaTerm, exp: BitwuzlaTerm, significand: BitwuzlaTerm ->
Native.bitwuzlaMkTerm3(
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_FP_FP, sign, exp, significand
bitwuzlaCtx.bitwuzla, BitwuzlaKind.BITWUZLA_KIND_FP_FP.value, sign, exp, significand
)
}
}
Expand All @@ -890,7 +890,7 @@ open class KBitwuzlaExprInternalizer(
BitwuzlaKind.BITWUZLA_KIND_FP_TO_FP_FROM_UBV
}
Native.bitwuzlaMkTerm2Indexed2(
bitwuzlaCtx.bitwuzla, operation, rm, value, sort.exponentBits.toInt(), sort.significandBits.toInt()
bitwuzlaCtx.bitwuzla, operation.value, rm, value, sort.exponentBits.toInt(), sort.significandBits.toInt()
)
}
}
Expand Down Expand Up @@ -992,22 +992,22 @@ open class KBitwuzlaExprInternalizer(

if (domain.isEmpty()) return@internalizeDeclSort range

Native.bitwuzlaMkFunSort(bitwuzlaCtx.bitwuzla, domain.size, domain, range)
Native.bitwuzlaMkFunSort(bitwuzlaCtx.bitwuzla, domain.size, domain.toLongArray(), range)
}
}

fun <S : KExpr<*>> S.transform(
arg: KExpr<*>,
kind: BitwuzlaKind
): S = transform(arg) { a0: BitwuzlaTerm -> Native.bitwuzlaMkTerm1(bitwuzlaCtx.bitwuzla, kind, a0) }
): S = transform(arg) { a0: BitwuzlaTerm -> Native.bitwuzlaMkTerm1(bitwuzlaCtx.bitwuzla, kind.value, a0) }


fun <S : KExpr<*>> S.transform(
arg0: KExpr<*>,
arg1: KExpr<*>,
kind: BitwuzlaKind
): S = transform(arg0, arg1) { a0: BitwuzlaTerm, a1: BitwuzlaTerm ->
Native.bitwuzlaMkTerm2(bitwuzlaCtx.bitwuzla, kind, a0, a1)
Native.bitwuzlaMkTerm2(bitwuzlaCtx.bitwuzla, kind.value, a0, a1)
}

fun <S : KExpr<*>> S.transform(
Expand All @@ -1016,7 +1016,7 @@ open class KBitwuzlaExprInternalizer(
arg2: KExpr<*>,
kind: BitwuzlaKind
): S = transform(arg0, arg1, arg2) { a0: BitwuzlaTerm, a1: BitwuzlaTerm, a2: BitwuzlaTerm ->
Native.bitwuzlaMkTerm3(bitwuzlaCtx.bitwuzla, kind, a0, a1, a2)
Native.bitwuzlaMkTerm3(bitwuzlaCtx.bitwuzla, kind.value, a0, a1, a2)
}

fun <S : KExpr<*>> S.transform(
Expand All @@ -1027,6 +1027,6 @@ open class KBitwuzlaExprInternalizer(
kind: BitwuzlaKind
): S = transform(arg0, arg1, arg2, arg3) { a0: BitwuzlaTerm, a1: BitwuzlaTerm, a2: BitwuzlaTerm, a3: BitwuzlaTerm ->
val args = arrayOf(a0, a1, a2, a3)
Native.bitwuzlaMkTerm(bitwuzlaCtx.bitwuzla, kind, args)
Native.bitwuzlaMkTerm(bitwuzlaCtx.bitwuzla, kind.value, args.toLongArray())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ open class KBitwuzlaModel(
val vars = decl.argSorts.map { it.mkFreshConstDecl("x") }
for (i in 0 until interp.size) {
// Don't substitute vars since arguments in Bitwuzla model are always constants
val args = interp.args[i].zip(decl.argSorts) { arg, sort -> arg.convertExpr(sort) }
val value = interp.values[i].convertExpr(decl.sort)
val args = interp.args!![i].zip(decl.argSorts) { arg, sort -> arg.convertExpr(sort) }
val value = interp.values!![i].convertExpr(decl.sort)
entries += KModel.KFuncInterpEntry(args, value)
}

Expand All @@ -123,8 +123,8 @@ open class KBitwuzlaModel(
val interp = Native.bitwuzlaGetArrayValue(bitwuzlaCtx.bitwuzla, term)

for (i in 0 until interp.size) {
val index = interp.indices[i].convertExpr(sort.domain)
val value = interp.values[i].convertExpr(sort.range)
val index = interp.indices!![i].convertExpr(sort.domain)
val value = interp.values!![i].convertExpr(sort.range)
entries += KModel.KFuncInterpEntry(listOf(index), value)
}

Expand Down
Loading