main.io.ksmt.solver.cvc5.KCvc5DeclInternalizer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ksmt-cvc5-core Show documentation
Show all versions of ksmt-cvc5-core Show documentation
Kotlin API for various SMT solvers
The newest version!
package io.ksmt.solver.cvc5
import io.github.cvc5.Solver
import io.github.cvc5.Term
import io.ksmt.decl.KConstDecl
import io.ksmt.decl.KDeclVisitor
import io.ksmt.decl.KFuncDecl
import io.ksmt.sort.KSort
open class KCvc5DeclInternalizer(
private val cvc5Ctx: KCvc5Context,
private val solver: Solver,
private val sortInternalizer: KCvc5SortInternalizer
) : KDeclVisitor {
private val tm = cvc5Ctx.termManager
override fun visit(decl: KFuncDecl): Term = cvc5Ctx.internalizeDecl(decl) {
// declarations incremental collection optimization
cvc5Ctx.addDeclaration(decl)
val domainSorts = decl.argSorts.map { it.accept(sortInternalizer) }
val rangeSort = decl.sort.accept(sortInternalizer)
solver.declareFun(
decl.name,
domainSorts.toTypedArray(),
rangeSort
).also { tm.registerPointer(it) }
}
override fun visit(decl: KConstDecl): Term = cvc5Ctx.internalizeDecl(decl) {
cvc5Ctx.addDeclaration(decl)
val sort = decl.sort.accept(sortInternalizer)
tm.builder { mkConst(sort, decl.name) }
}
}