Skip to content

Commit

Permalink
Upgrade KSMT and add solver theory specialization for jvm (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saloed authored Oct 21, 2024
1 parent 0acf657 commit 158ad96
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object Versions {
const val kotlinx_collections = "0.3.5"
const val kotlinx_coroutines = "1.6.4"
const val kotlinx_serialization = "1.4.1"
const val ksmt = "0.5.21"
const val ksmt = "0.5.26"
const val logback = "1.4.8"
const val mockk = "1.13.4"
const val rd = "2023.2.0"
Expand Down
29 changes: 25 additions & 4 deletions usvm-jvm/src/main/kotlin/org/usvm/machine/JcSolverFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.usvm.machine
import io.ksmt.KContext
import io.ksmt.solver.KSolver
import io.ksmt.solver.KSolverConfiguration
import io.ksmt.solver.KTheory
import io.ksmt.solver.runner.KSolverRunnerManager
import io.ksmt.solver.yices.KYicesSolver
import io.ksmt.solver.yices.KYicesSolverConfiguration
Expand Down Expand Up @@ -30,8 +31,18 @@ private object SameProcessSolverFactory : SolverFactory {
solverType: SolverType
): KSolver<out KSolverConfiguration> = when (solverType) {
// Yices with Fp support via SymFpu
SolverType.YICES -> KSymFpuSolver(KYicesSolver(ctx), ctx)
SolverType.Z3 -> KZ3Solver(ctx)
SolverType.YICES -> KSymFpuSolver(KYicesSolver(ctx), ctx).apply {
configure {
// Fp theory is handled by the SymFpu
optimizeForTheories(setOf(KTheory.Array, KTheory.BV, KTheory.UF))
}
}

SolverType.Z3 -> KZ3Solver(ctx).apply {
configure {
optimizeForTheories(setOf(KTheory.Array, KTheory.BV, KTheory.UF, KTheory.FP))
}
}
}

override fun close() {
Expand All @@ -52,8 +63,18 @@ private class AnotherProcessSolverFactory : SolverFactory {
solverType: SolverType
): KSolver<out KSolverConfiguration> = when (solverType) {
// Yices with Fp support via SymFpu
SolverType.YICES -> solverManager.createSolver(ctx, YicesWithSymFpu::class)
SolverType.Z3 -> solverManager.createSolver(ctx, KZ3Solver::class)
SolverType.YICES -> solverManager.createSolver(ctx, YicesWithSymFpu::class).apply {
configure {
// Fp theory is handled by the SymFpu
optimizeForTheories(setOf(KTheory.Array, KTheory.BV, KTheory.UF))
}
}

SolverType.Z3 -> solverManager.createSolver(ctx, KZ3Solver::class).apply {
configure {
optimizeForTheories(setOf(KTheory.Array, KTheory.BV, KTheory.UF, KTheory.FP))
}
}
}

override fun close() {
Expand Down

0 comments on commit 158ad96

Please sign in to comment.