Skip to content

Commit 81ec9b5

Browse files
authored
Upgrade cvc5 to 1.1.2 (#158)
1 parent d941124 commit 81ec9b5

31 files changed

+601
-643
lines changed

Diff for: README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Get the most out of SMT solving with KSMT features:
1111
* Streamlined [solver delivery](#ksmt-distribution) with no need for building a solver or implementing JVM bindings
1212

1313
[![KSMT: build](https://github.com/UnitTestBot/ksmt/actions/workflows/build-and-run-tests.yml/badge.svg)](https://github.com/UnitTestBot/ksmt/actions/workflows/build-and-run-tests.yml)
14-
[![Maven Central](https://img.shields.io/maven-central/v/io.ksmt/ksmt-core)](https://central.sonatype.com/artifact/io.ksmt/ksmt-core/0.5.22)
14+
[![Maven Central](https://img.shields.io/maven-central/v/io.ksmt/ksmt-core)](https://central.sonatype.com/artifact/io.ksmt/ksmt-core/0.5.23)
1515
[![javadoc](https://javadoc.io/badge2/io.ksmt/ksmt-core/javadoc.svg)](https://javadoc.io/doc/io.ksmt/ksmt-core)
1616

1717
## Get started
@@ -20,9 +20,9 @@ To start using KSMT, install it via [Gradle](https://gradle.org/):
2020

2121
```kotlin
2222
// core
23-
implementation("io.ksmt:ksmt-core:0.5.22")
23+
implementation("io.ksmt:ksmt-core:0.5.23")
2424
// z3 solver
25-
implementation("io.ksmt:ksmt-z3:0.5.22")
25+
implementation("io.ksmt:ksmt-z3:0.5.23")
2626
```
2727

2828
Find basic instructions in the [Getting started](docs/getting-started.md) guide and try it out with the

Diff for: buildSrc/src/main/kotlin/io.ksmt.ksmt-base.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ plugins {
1111
}
1212

1313
group = "io.ksmt"
14-
version = "0.5.22"
14+
version = "0.5.23"
1515

1616
repositories {
1717
mavenCentral()

Diff for: docs/getting-started.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ repositories {
3434
```kotlin
3535
dependencies {
3636
// core
37-
implementation("io.ksmt:ksmt-core:0.5.22")
37+
implementation("io.ksmt:ksmt-core:0.5.23")
3838
}
3939
```
4040

@@ -43,9 +43,9 @@ dependencies {
4343
```kotlin
4444
dependencies {
4545
// z3
46-
implementation("io.ksmt:ksmt-z3:0.5.22")
46+
implementation("io.ksmt:ksmt-z3:0.5.23")
4747
// bitwuzla
48-
implementation("io.ksmt:ksmt-bitwuzla:0.5.22")
48+
implementation("io.ksmt:ksmt-bitwuzla:0.5.23")
4949
}
5050
```
5151

Diff for: examples/build.gradle.kts

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ repositories {
99

1010
dependencies {
1111
// core
12-
implementation("io.ksmt:ksmt-core:0.5.22")
12+
implementation("io.ksmt:ksmt-core:0.5.23")
1313
// z3 solver
14-
implementation("io.ksmt:ksmt-z3:0.5.22")
14+
implementation("io.ksmt:ksmt-z3:0.5.23")
1515
// Runner and portfolio solver
16-
implementation("io.ksmt:ksmt-runner:0.5.22")
16+
implementation("io.ksmt:ksmt-runner:0.5.23")
1717
}
1818

1919
java {

Diff for: ksmt-core/src/main/kotlin/io/ksmt/KContext.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -2675,16 +2675,16 @@ open class KContext(
26752675
private val zeroExtensionExprCache = mkAstInterner<KBvZeroExtensionExpr>()
26762676

26772677
/**
2678-
* Create BitVec signed extension (`signext`) expression.
2679-
* Returns a BitVec expression with [extensionSize] extra sign (leftmost, highest) bits.
2678+
* Create BitVec zero extension (`zeroext`) expression.
2679+
* Returns a BitVec expression with [extensionSize] extra zero bits.
26802680
* The extra bits are prepended to the provided [value].
26812681
* */
26822682
open fun <T : KBvSort> mkBvZeroExtensionExpr(extensionSize: Int, value: KExpr<T>): KExpr<KBvSort> =
26832683
mkSimplified(extensionSize, value, KContext::simplifyBvZeroExtensionExpr, ::mkBvZeroExtensionExprNoSimplify)
26842684

26852685
/**
2686-
* Create BitVec signed extension (`signext`) expression.
2687-
* Returns a BitVec expression with [extensionSize] extra sign (leftmost, highest) bits.
2686+
* Create BitVec zero extension (`zeroext`) expression.
2687+
* Returns a BitVec expression with [extensionSize] extra zero bits.
26882688
* The extra bits are prepended to the provided [value].
26892689
* */
26902690
open fun <T : KBvSort> mkBvZeroExtensionExprNoSimplify(

Diff for: ksmt-cvc5/dist/build.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
### Build details
22

3+
Build is based on the cvc5 fork: https://github.com/Saloed/cvc5/tree/ksmt
4+
This fork provides fixed Java API and buildscripts (`build_(linux|windows|mac).sh`)
5+
36
We build cvc5 with the following configuration:
47
```shell
58
./configure.sh production --auto-download --ipo --no-static --no-cln --no-glpk --no-editline --cryptominisat --java-bindings

Diff for: ksmt-cvc5/dist/cvc5-1.0.2.jar

-54 KB
Binary file not shown.

Diff for: ksmt-cvc5/dist/cvc5-1.1.2.jar

78.4 KB
Binary file not shown.

Diff for: ksmt-cvc5/dist/cvc5-native-linux-x86-64-1.0.2.zip

-5.74 MB
Binary file not shown.

Diff for: ksmt-cvc5/dist/cvc5-native-osx-arm64-1.0.2.zip

-7.51 MB
Binary file not shown.

Diff for: ksmt-cvc5/dist/cvc5-native-osx-arm64-1.1.2.zip

7.95 MB
Binary file not shown.

Diff for: ksmt-cvc5/dist/cvc5-native-win-x86-64-1.1.2.zip

13.3 MB
Binary file not shown.

Diff for: ksmt-cvc5/ksmt-cvc5-core/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repositories {
1111
mavenCentral()
1212
}
1313

14-
val cvc5Version = "1.0.2"
14+
val cvc5Version = "1.1.2"
1515
val cvc5Jar = distDir.resolve("cvc5-$cvc5Version.jar")
1616

1717
dependencies {

Diff for: ksmt-cvc5/ksmt-cvc5-core/src/main/kotlin/io/github/cvc5/SolverUtils.kt

-100
This file was deleted.

Diff for: ksmt-cvc5/ksmt-cvc5-core/src/main/kotlin/io/ksmt/solver/cvc5/KCvc5Context.kt

+6-10
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ import io.ksmt.sort.KRealSort
3030
import io.ksmt.sort.KSort
3131
import io.ksmt.sort.KSortVisitor
3232
import io.ksmt.sort.KUninterpretedSort
33-
import java.util.TreeMap
3433

3534
class KCvc5Context(
36-
private val solver: Solver,
37-
private val ctx: KContext
35+
val termManager: KCvc5TermManager,
36+
val ctx: KContext
3837
) : AutoCloseable {
3938
private var isClosed = false
4039

@@ -62,11 +61,11 @@ class KCvc5Context(
6261
private val currentScopeExpressions = HashMap<KExpr<*>, Term>()
6362
private val expressions = HashMap<KExpr<*>, Term>()
6463
// we can't use HashMap with Term and Sort (hashcode is not implemented)
65-
private val cvc5Expressions = TreeMap<Term, KExpr<*>>()
64+
private val cvc5Expressions = KCvc5TermMap<KExpr<*>>()
6665
private val sorts = HashMap<KSort, Sort>()
67-
private val cvc5Sorts = TreeMap<Sort, KSort>()
66+
private val cvc5Sorts = KCvc5SortMap<KSort>()
6867
private val decls = HashMap<KDecl<*>, Term>()
69-
private val cvc5Decls = TreeMap<Term, KDecl<*>>()
68+
private val cvc5Decls = KCvc5TermMap<KDecl<*>>()
7069

7170
private var currentLevelUninterpretedSorts = hashSetOf<KUninterpretedSort>()
7271
private val uninterpretedSorts = mutableListOf(currentLevelUninterpretedSorts)
@@ -91,9 +90,6 @@ class KCvc5Context(
9190
*/
9291
fun declarations(): List<Set<KDecl<*>>> = declarations
9392

94-
val nativeSolver: Solver
95-
get() = solver
96-
9793
val isActive: Boolean
9894
get() = !isClosed
9995

@@ -287,7 +283,7 @@ class KCvc5Context(
287283
val interpreter = uninterpretedSortValueInterpreter[value.value.sort]
288284
?: error("Interpreter was not registered for sort: ${value.value.sort}")
289285

290-
val constraintLhs = solver.mkTerm(Kind.APPLY_UF, arrayOf(interpreter, value.nativeValueTerm))
286+
val constraintLhs = termManager.mkTerm(Kind.APPLY_UF, arrayOf(interpreter, value.nativeValueTerm))
291287
val constraint = constraintLhs.eqTerm(value.nativeUniqueValueDescriptor)
292288

293289
solver.assertFormula(constraint)
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.ksmt.solver.cvc5
22

3+
import io.github.cvc5.Solver
34
import io.github.cvc5.Term
45
import io.ksmt.decl.KConstDecl
56
import io.ksmt.decl.KDeclVisitor
@@ -8,8 +9,10 @@ import io.ksmt.sort.KSort
89

910
open class KCvc5DeclInternalizer(
1011
private val cvc5Ctx: KCvc5Context,
12+
private val solver: Solver,
1113
private val sortInternalizer: KCvc5SortInternalizer
1214
) : KDeclVisitor<Term> {
15+
private val tm = cvc5Ctx.termManager
1316

1417
override fun <S : KSort> visit(decl: KFuncDecl<S>): Term = cvc5Ctx.internalizeDecl(decl) {
1518
// declarations incremental collection optimization
@@ -18,17 +21,17 @@ open class KCvc5DeclInternalizer(
1821
val domainSorts = decl.argSorts.map { it.accept(sortInternalizer) }
1922
val rangeSort = decl.sort.accept(sortInternalizer)
2023

21-
cvc5Ctx.nativeSolver.declareFun(
24+
solver.declareFun(
2225
decl.name,
2326
domainSorts.toTypedArray(),
2427
rangeSort
25-
)
28+
).also { tm.registerPointer(it) }
2629
}
2730

2831
override fun <S : KSort> visit(decl: KConstDecl<S>): Term = cvc5Ctx.internalizeDecl(decl) {
2932
cvc5Ctx.addDeclaration(decl)
3033

3134
val sort = decl.sort.accept(sortInternalizer)
32-
cvc5Ctx.nativeSolver.mkConst(sort, decl.name)
35+
tm.builder { mkConst(sort, decl.name) }
3336
}
3437
}

0 commit comments

Comments
 (0)