cvc5.mbt

    Native MoonBit bindings for the cvc5 SMT solver

    smt
    solver
    cvc5
    ffi
    native
    Download zip
    Author
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    8 hours ago
    Downloads
    2

    #Yu-zh/cvc5.mbt

    Native MoonBit bindings for cvc5, pinned to 1.3.4, using its public C API and a C11 shim. The API follows the TermManager / Solver organization of cvc5-rs.

    #Quick start

    Install a current MoonBit toolchain, Node.js 18 or newer, a C11 compiler, curl, and unzip. Then, in this repository:

    moon test moon run cmd/main

    The first build downloads a pinned upstream shared-library archive and checks its SHA-256 against the digest in build.js. Later builds reuse .cvc5/ and work offline. No global cvc5 installation is needed. The cvc5 executable alone is not sufficient: a binding also needs the headers and native libraries.

    This first version follows the C API's error behavior: invalid upstream API calls can terminate the process. Cvc5Error covers binding-level checks only; see Error handling before using untrusted expressions or options.

    Prebuilt archives are configured for macOS and Linux, on arm64 and x86-64. Local validation was performed on macOS arm64. Windows, browser/Wasm backends, cross-compilation, and static linking are not supported by this version. Linux binaries require the glibc and C++ runtime supported by the upstream archive; use a source build on systems where that archive is incompatible.

    For a consuming project, add the module dependency:

    moon add Yu-zh/cvc5.mbt

    Then import it in moon.pkg with the alias cvc5:

    ///|
    import {
    "Yu-zh/cvc5.mbt" @cvc5,
    }

    Build that project with --target native or set preferred_target = "native" in its moon.mod. There are no consumer-side compiler or linker settings. The local tests/consumer workspace demonstrates dependency usage:

    moon -C tests/consumer run . moon -C tests/consumer run . --release

    #Example

    ///|
    test "README: solve an integer equation" {
    let tm = @cvc5.TermManager::new()
    let solver = @cvc5.Solver::new(tm)
    solver.set_logic("QF_LIA")
    solver.set_option("produce-models", "true")
    let x = tm.mk_const(tm.integer_sort(), "x")
    let equation = tm.mk_term(Equal, [
    tm.mk_term(Add, [x, tm.mk_integer(1)]),
    tm.mk_integer(43),
    ])
    solver.assert_formula(equation)
    assert_true(solver.check_sat() is Sat)
    assert_eq(solver.get_value(x).get_int64_value(), 42)
    }

    #Building cvc5 from source

    The same MoonBit prebuild hook can build cvc5 and its dependencies:

    CVC5_BUILD=source moon test

    This requires Git, CMake (3.31 or newer recommended), Make, a C/C++17 toolchain, and Python (3.11 or newer recommended). The hook fetches the 1.3.4 tag, verifies its pinned Git commit, configures a Production shared-library build with GPL features disabled and LibPoly enabled, then runs CMake's build and install steps. cvc5 downloads and verifies GMP, CaDiCaL, SymFPU, and LibPoly as needed. The initial build can take several minutes. Build output goes to stderr. cvc5 itself is still implemented in C++; the binding does not require a C++ compiler when using prebuilt libraries or CVC5_PREFIX.

    The installation and intermediate build directory are cached separately from MoonBit's _build, so moon clean does not rebuild cvc5. Failed compilations retain their build directory and can resume. Changing compiler settings creates a separate cache entry. Builds for the same cache entry are serialized.

    To build a local cvc5 1.3.4 checkout:

    CVC5_SOURCE_DIR=/absolute/path/to/cvc5 moon test

    If you modify that checkout after a successful build, choose a fresh CVC5_CACHE_DIR to rebuild it; the completed dependency cache is not a source file watcher.

    You can also use an existing shared-library installation:

    CVC5_PREFIX=/absolute/path/to/cvc5/install moon test

    It must contain include/cvc5/c/cvc5.h and lib/libcvc5.dylib (macOS), lib/libcvc5.so (Linux), or the corresponding lib64 directory. Use 1.3.4; compile-time checks reject changes to the enum ABI. A custom installation's dependency libraries must also be available to the dynamic loader.

    VariablePurpose
    CVC5_BUILDprebuilt (default) or source
    CVC5_PREFIXExisting installation; takes priority over building/downloading
    CVC5_SOURCE_DIRLocal 1.3.4 source checkout; implies source mode
    CVC5_CACHE_DIRDependency cache; defaults to this module's .cvc5/
    CVC5_JOBSSource-build parallelism; defaults to at most 8 workers
    CVC5_CMAKECMake executable for a source build
    CVC5_PYTHONPython interpreter passed to CMake
    CCC compiler for the binding shim and source builds; defaults to cc
    CXXC++ compiler for building cvc5 itself; not used to compile the shim

    Downloads respect the usual HTTPS_PROXY / HTTP_PROXY environment variables. If an abruptly terminated build leaves a .lock directory, first verify no build is using it, then remove that specific lock before retrying.

    The executables use an rpath to the selected installation. To distribute an executable to another machine, bundle the native libraries and configure the loader paths for that bundle. The cached shared libraries are not embedded in the executable. Bundling libraries also requires complying with their licenses; see License and third-party notices.

    #API and ownership

    • TermManager constructs sorts, literals, constants, variables, terms, and indexed Op values. mk_term exposes all cvc5 1.3.4 term kinds; each kind retains its upstream arity and sort requirements.
    • Solver supports options and logics, assertions, satisfiability checks, temporary assumptions, incremental scopes, simplification, models, and unsat cores, plus full proofs in Cooperating Proof Calculus (CPC) format.
    • Term supports children, sorts, symbols, substitution, SMT-LIB display, and typed literal extraction. Arbitrary integers and exact rationals can be exchanged as strings. String literals preserve embedded NULs and Unicode scalar values up to U+2FFFF.
    • SatResult distinguishes Sat, Unsat, and Unknown(reason).

    Terms, sorts, operators, and solvers retain their term manager automatically. There is no manual delete, close, or clone requirement. Combining objects from different managers raises Cvc5Error::ApiError. Handles are intended for single-threaded use; reference counting does not make the solver thread-safe.

    The C11 shim uses cvc5_*_copy / cvc5_*_release and MoonBit external-object finalizers. Each native value is released before its retained term manager. Solver results are copied into lifetime-independent snapshots, and temporary C API strings and arrays are copied before their storage can be reused. Every non-primitive FFI parameter has an explicit borrowing annotation.

    #CPC proof retrieval

    Enable produce-proofs before solving, then call get_proof_cpc() immediately after an Unsat result from check_sat() or check_sat_assuming(). It returns the full refutation as an owned String, which remains valid after further solver calls or destruction of the solver. Retrieve it before changing assertions or scopes: cvc5 1.3.4 can abort if retrieval follows reset_assertions(). Calling it without proof production enabled or outside the unsatisfiable solver state is also a fatal upstream API error.

    ///|
    test "README: retrieve a CPC proof" {
    let tm = @cvc5.TermManager::new()
    let solver = @cvc5.Solver::new(tm)
    solver.set_logic("QF_UF")
    solver.set_option("produce-proofs", "true")
    solver.set_option("proof-format-mode", "cpc")
    solver.set_option("proof-granularity", "dsl-rewrite")
    let p = tm.mk_const(tm.boolean_sort(), "p")
    solver.assert_formula(p)
    solver.assert_formula(tm.mk_term(Not, [p]))
    assert_true(solver.check_sat() is Unsat)
    let proof = solver.get_proof_cpc()
    assert_true(proof.contains("false :rule contra"))
    }

    get_proof_cpc() explicitly selects CPC, regardless of proof-format-mode. Other proof options still apply; the optional proof-granularity=dsl-rewrite setting gives more detailed rewrite steps. Set these options before solving. No dump-proofs option is needed for API retrieval.

    CPC proofs can be checked with Ethos. Unsupported proof rules can appear as trust steps, causing Ethos to report incomplete rather than correct; more detail does not guarantee a proof without trust steps. See the cvc5 CPC documentation.

    See proof checking and replay for implementation options and effort estimates.

    #Error handling

    cvc5 1.3.4's C API prints a diagnostic and exits on invalid operations, including wrong term sorts or arities, invalid options, and invalid solver states. These errors cannot be caught with MoonBit try ... catch in this version. Sat, Unsat, and Unknown(reason) remain ordinary solver results, not errors. See the upstream error implementation.

    Public signatures retain raise Cvc5Error for binding-level checks, such as mixing managers, mismatched substitution arrays, or invalid string conversion. This is not a general validation layer for cvc5 inputs. Recoverable upstream API errors are deferred to a later version.

    Symbol names, logic/option strings, and numeric text cannot contain embedded NUL characters because the C API accepts them as NUL-terminated strings. The binding rejects those inputs instead of truncating them. String literals created with mk_string preserve NULs and Unicode scalar values within the SMT-LIB alphabet, U+0000–U+2FFFF. Code points above U+2FFFF and unpaired UTF-16 surrogates raise Cvc5Error instead of silently changing the string. MoonBit encodes and decodes SMT-LIB Unicode escapes, passing Bytes across the FFI boundary to work around the C API's lack of length-bearing string access.

    This is an initial binding, not full cvc5-rs API parity. Dedicated datatype, floating-point, finite-field, and collection-value constructors, SMT-LIB parsing, SyGuS, proof-node inspection, other proof formats, and statistics are not wrapped yet. No binding to cvc5's parser library is required for the current API.

    #Build-system design and development

    moon.mod registers build.js using MoonBit's experimental --moonbit-unstable-prebuild hook. The script supplies include flags through ${build.CVC5_STUB_FLAGS} and propagates libraries/rpaths through link_configs. moon.pkg compiles only cvc5_stub.c; CMake handles cvc5's own source tree. The hook also runs when this module is used as a dependency.

    This uses the module configuration approach from Kaida-Amethyst/llvm 0.5.0. mizchi/wasmtime 0.1.6 provides a source-build example, but documents that its package pre-build hook must be invoked explicitly by consumers. See MoonBit's prebuild protocol. That protocol is experimental and may require updates with future toolchains.

    moon check --deny-warn moon test moon test --release node scripts/test-c-api-errors.js moon -C tests/consumer run . --release moon info && moon fmt

    The checked-in interfaces are generated by moon info. To update enum declarations and their C ABI assertions together:

    node scripts/generate-kinds.js /path/to/cvc5/include/cvc5/cvc5_kind.h moon info && moon fmt

    The generator preserves cvc5's copyright and BSD-3-Clause attribution in all three generated files. When updating the pinned cvc5 version, also update its notice, the upstream copies in licenses/cvc5/, and THIRD_PARTY_NOTICES.md.

    tests/fatal-api contains deliberately invalid calls and is not part of the ordinary test suite. scripts/test-c-api-errors.js builds that fixture and executes each case in a separate child process, checking for cvc5's diagnostic and exit status. Do not run its tests directly expecting a successful exit.

    #License

    The original binding code is licensed under Apache-2.0. The generated cvc5 API definitions retain cvc5's BSD-3-Clause license and author attribution. See THIRD_PARTY_NOTICES.md for the affected files and their upstream source. Neither license implies endorsement by the upstream projects.

    The Git source distribution and Mooncakes package do not include native cvc5 libraries. build.js downloads an upstream archive or builds the libraries separately; dependency caches are excluded from Git and the package.

    ENABLE_GPL=OFF disables optional GPL features, not LGPL dependencies. The configured source build still uses GMP and LibPoly, available under LGPLv3 terms. A custom CVC5_PREFIX can have different dependencies or features.

    If you redistribute native libraries or linked executables, review the exact build's licenses, include the required notices and license texts, provide the required corresponding library-source access, and preserve users' ability to replace or relink the LGPL components. Dynamic linking does not remove these obligations. The redistribution checklist is a starting point, not legal clearance for a binary release.

    Cvc5Error

    pub(all) suberror Cvc5Error {
    ApiError(String)
    } derive(Eq,
    Debug
    )

    A binding-level validation error, such as mixing term managers or an unsupported embedded NUL in a C string argument. This does not catch errors raised inside cvc5: the cvc5 1.3.4 C API terminates the process on API misuse.

    Cvc5Error::equal

    fn Cvc5Error::equal(Cvc5Error, Cvc5Error) -> Bool

    Cvc5Error::not_equal

    fn Cvc5Error::not_equal(x : Cvc5Error, y : Cvc5Error) -> Bool

    Kind

    pub(all) enum Kind {
    InternalKind
    UndefinedKind
    NullTerm
    UninterpretedSortValue
    Equal
    Distinct
    Constant
    Variable
    Skolem
    Sexpr
    Lambda
    Witness
    ConstBoolean
    Not
    And
    Implies
    Or
    Xor
    Ite
    ApplyUf
    CardinalityConstraint
    HoApply
    Add
    Mult
    Iand
    Piand
    Pow2
    Log2
    Sub
    Neg
    Division
    DivisionTotal
    IntsDivision
    IntsDivisionTotal
    IntsModulus
    IntsModulusTotal
    Abs
    Pow
    Exponential
    Sine
    Cosine
    Tangent
    Cosecant
    Secant
    Cotangent
    Arcsine
    Arccosine
    Arctangent
    Arccosecant
    Arcsecant
    Arccotangent
    Sqrt
    Divisible
    ConstRational
    ConstInteger
    Lt
    Leq
    Gt
    Geq
    IsInteger
    ToInteger
    ToReal
    Pi
    ConstBitVector
    BitVectorConcat
    BitVectorAnd
    BitVectorOr
    BitVectorXor
    BitVectorNot
    BitVectorNand
    BitVectorNor
    BitVectorXnor
    BitVectorComp
    BitVectorMult
    BitVectorAdd
    BitVectorSub
    BitVectorNeg
    BitVectorUdiv
    BitVectorUrem
    BitVectorSdiv
    BitVectorSrem
    BitVectorSmod
    BitVectorShl
    BitVectorLshr
    BitVectorAshr
    BitVectorUlt
    BitVectorUle
    BitVectorUgt
    BitVectorUge
    BitVectorSlt
    BitVectorSle
    BitVectorSgt
    BitVectorSge
    BitVectorUltbv
    BitVectorSltbv
    BitVectorIte
    BitVectorRedor
    BitVectorRedand
    BitVectorNego
    BitVectorUaddo
    BitVectorSaddo
    BitVectorUmulo
    BitVectorSmulo
    BitVectorUsubo
    BitVectorSsubo
    BitVectorSdivo
    BitVectorExtract
    BitVectorRepeat
    BitVectorZeroExtend
    BitVectorSignExtend
    BitVectorRotateLeft
    BitVectorRotateRight
    IntToBitVector
    BitVectorToNat
    BitVectorUbvToInt
    BitVectorSbvToInt
    BitVectorFromBools
    BitVectorBit
    ConstFiniteField
    FiniteFieldNeg
    FiniteFieldAdd
    FiniteFieldBitsum
    FiniteFieldMult
    ConstFloatingPoint
    ConstRoundingmode
    FloatingPointFp
    FloatingPointEq
    FloatingPointAbs
    FloatingPointNeg
    FloatingPointAdd
    FloatingPointSub
    FloatingPointMult
    FloatingPointDiv
    FloatingPointFma
    FloatingPointSqrt
    FloatingPointRem
    FloatingPointRti
    FloatingPointMin
    FloatingPointMax
    FloatingPointLeq
    FloatingPointLt
    FloatingPointGeq
    FloatingPointGt
    FloatingPointIsNormal
    FloatingPointIsSubnormal
    FloatingPointIsZero
    FloatingPointIsInf
    FloatingPointIsNan
    FloatingPointIsNeg
    FloatingPointIsPos
    FloatingPointToFpFromIeeeBv
    FloatingPointToFpFromFp
    FloatingPointToFpFromReal
    FloatingPointToFpFromSbv
    FloatingPointToFpFromUbv
    FloatingPointToUbv
    FloatingPointToSbv
    FloatingPointToReal
    Select
    Store
    ConstArray
    EqRange
    ApplyConstructor
    ApplySelector
    ApplyTester
    ApplyUpdater
    Match
    MatchCase
    MatchBindCase
    TupleProject
    NullableLift
    SepNil
    SepEmp
    SepPto
    SepStar
    SepWand
    SetEmpty
    SetUnion
    SetInter
    SetMinus
    SetSubset
    SetMember
    SetSingleton
    SetInsert
    SetCard
    SetComplement
    SetUniverse
    SetComprehension
    SetChoose
    SetIsEmpty
    SetIsSingleton
    SetMap
    SetFilter
    SetAll
    SetSome
    SetFold
    RelationJoin
    RelationTableJoin
    RelationProduct
    RelationTranspose
    RelationTclosure
    RelationJoinImage
    RelationIden
    RelationGroup
    RelationAggregate
    RelationProject
    BagEmpty
    BagUnionMax
    BagUnionDisjoint
    BagInterMin
    BagDifferenceSubtract
    BagDifferenceRemove
    BagSubbag
    BagCount
    BagMember
    BagSetof
    BagMake
    BagCard
    BagChoose
    BagMap
    BagFilter
    BagAll
    BagSome
    BagFold
    BagPartition
    TableProduct
    TableProject
    TableAggregate
    TableJoin
    TableGroup
    StringConcat
    StringInRegexp
    StringLength
    StringSubstr
    StringUpdate
    StringCharat
    StringContains
    StringIndexof
    StringIndexofRe
    StringReplace
    StringReplaceAll
    StringReplaceRe
    StringReplaceReAll
    StringToLower
    StringToUpper
    StringRev
    StringToCode
    StringFromCode
    StringLt
    StringLeq
    StringPrefix
    StringSuffix
    StringIsDigit
    StringFromInt
    StringToInt
    ConstString
    StringToRegexp
    RegexpConcat
    RegexpUnion
    RegexpInter
    RegexpDiff
    RegexpStar
    RegexpPlus
    RegexpOpt
    RegexpRange
    RegexpRepeat
    RegexpLoop
    RegexpNone
    RegexpAll
    RegexpAllchar
    RegexpComplement
    SeqConcat
    SeqLength
    SeqExtract
    SeqUpdate
    SeqAt
    SeqContains
    SeqIndexof
    SeqReplace
    SeqReplaceAll
    SeqRev
    SeqPrefix
    SeqSuffix
    ConstSequence
    SeqUnit
    SeqNth
    Forall
    Exists
    VariableList
    InstPattern
    InstNoPattern
    InstPool
    InstAddToPool
    SkolemAddToPool
    InstAttribute
    InstPatternList
    } derive(Eq,
    Debug
    )

    cvc5 1.3.4 term kinds. See the upstream API for arities and sorts. Generated by scripts/generate-kinds.js; checked against the C headers.

    Kind::equal

    fn Kind::equal(Kind, Kind) -> Bool

    Kind::not_equal

    fn Kind::not_equal(x : Kind, y : Kind) -> Bool

    Kind::to_repr

    Native

    type Native

    Native C storage with a finalizer. Only checked handles reach the public API.
    pub struct Op {
    // private fields
    }

    An operator, optionally indexed (for example, bit-vector extraction).
    impl Eq for Op
    impl Show for Op

    Op::equal

    fn Op::equal(self : Op, other : Op) -> Bool

    Op::kind

    fn Op::kind(self : Op) -> Kind

    Op::not_equal

    fn Op::not_equal(x : Op, y : Op) -> Bool

    Op::output

    fn Op::output(self : Op, logger : &Logger) -> Unit

    Op::to_string

    fn Op::to_string(self : Op) -> String

    SatResult

    pub(all) enum SatResult {
    Sat
    Unsat
    Unknown(String)
    } derive(Eq,
    Debug
    )

    A satisfiability result, independent of the lifetime of the solver.

    SatResult::equal

    fn SatResult::equal(SatResult, SatResult) -> Bool

    SatResult::is_sat

    fn SatResult::is_sat(self : SatResult) -> Bool

    SatResult::is_unknown

    fn SatResult::is_unknown(self : SatResult) -> Bool

    SatResult::is_unsat

    fn SatResult::is_unsat(self : SatResult) -> Bool

    SatResult::not_equal

    fn SatResult::not_equal(x : SatResult, y : SatResult) -> Bool

    Solver

    pub struct Solver {
    // private fields
    }

    A solver sharing a term manager. Multiple solvers may share the same manager.

    Solver::assert_formula

    fn Solver::assert_formula(self : Solver, formula : Term) -> Unit raise Cvc5Error

    Assert a Boolean formula from the solver's term manager.

    Solver::check_sat

    fn Solver::check_sat(self : Solver) -> SatResult raise Cvc5Error

    Solver::check_sat_assuming

    fn Solver::check_sat_assuming(self : Solver, assumptions : ArrayView[Term]) -> SatResult raise Cvc5Error

    Check satisfiability under temporary assumptions, without asserting them.

    Solver::get_assertions

    fn Solver::get_assertions(self : Solver) -> Array[Term] raise Cvc5Error

    Solver::get_option

    fn Solver::get_option(self : Solver, option : String) -> String raise Cvc5Error

    Solver::get_proof_cpc

    fn Solver::get_proof_cpc(self : Solver) -> String raise Cvc5Error

    Return the full refutation in Cooperating Proof Calculus (CPC) format. Enable "produce-proofs" before solving and call immediately after an Unsat result from check_sat or check_sat_assuming, before changing assertions or scopes. Invalid upstream solver states terminate the process; cvc5 1.3.4 can abort if a proof is requested after reset_assertions.

    Always selects CPC, regardless of "proof-format-mode". Configure other proof options before solving, such as "proof-granularity" = "dsl-rewrite" for more detailed rewrite steps. Unsupported rules may still appear as trust steps. The returned string owns its storage and remains valid after later solver operations or destruction of the solver.

    Solver::get_unsat_core

    fn Solver::get_unsat_core(self : Solver) -> Array[Term] raise Cvc5Error

    Requires "produce-unsat-cores" and an unsatisfiable result.

    Solver::get_value

    fn Solver::get_value(self : Solver, term : Term) -> Term raise Cvc5Error

    Evaluate a term in the current model. Requires "produce-models" and Sat.

    Solver::get_values

    fn Solver::get_values(self : Solver, terms : ArrayView[Term]) -> Array[Term] raise Cvc5Error

    Evaluate several terms in the current model, preserving order.

    Solver::new

    fn Solver::new(tm : TermManager) -> Solver raise Cvc5Error

    Create a solver. Configure its logic and options before asserting formulas.

    Solver::pop

    fn Solver::pop(self : Solver, levels? : UInt) -> Unit raise Cvc5Error

    Pop assertion scopes. The C API terminates the process if there are too few.

    Solver::push

    fn Solver::push(self : Solver, levels? : UInt) -> Unit raise Cvc5Error

    Push assertion scopes. Enable the "incremental" option before solving.

    Solver::reset_assertions

    fn Solver::reset_assertions(self : Solver) -> Unit raise Cvc5Error

    Solver::set_logic

    fn Solver::set_logic(self : Solver, logic : String) -> Unit raise Cvc5Error

    Solver::set_option

    fn Solver::set_option(self : Solver, option : String, value : String) -> Unit raise Cvc5Error

    Set an upstream cvc5 option, such as "produce-models" or "incremental".

    Solver::simplify

    fn Solver::simplify(self : Solver, term : Term, apply_substitutions? : Bool) -> Term raise Cvc5Error

    Solver::version

    fn Solver::version(self : Solver) -> String raise Cvc5Error

    The version of the linked cvc5 library.

    Sort

    pub struct Sort {
    // private fields
    }

    The type of a term. Sorts from different managers cannot be combined.
    impl Eq for Sort
    impl Show for Sort

    Sort::bit_vector_size

    fn Sort::bit_vector_size(self : Sort) -> UInt raise Cvc5Error

    Read the width of a bit-vector sort. The C API terminates the process for other sorts.

    Sort::equal

    fn Sort::equal(self : Sort, other : Sort) -> Bool

    Sort::kind

    fn Sort::kind(self : Sort) -> SortKind

    Sort::not_equal

    fn Sort::not_equal(x : Sort, y : Sort) -> Bool

    Sort::output

    fn Sort::output(self : Sort, logger : &Logger) -> Unit

    Sort::to_string

    fn Sort::to_string(self : Sort) -> String

    SortKind

    pub(all) enum SortKind {
    InternalSortKind
    UndefinedSortKind
    NullSort
    AbstractSort
    ArraySort
    BagSort
    BooleanSort
    BitVectorSort
    DatatypeSort
    FiniteFieldSort
    FloatingPointSort
    FunctionSort
    IntegerSort
    RealSort
    ReglanSort
    RoundingmodeSort
    SequenceSort
    SetSort
    StringSort
    TupleSort
    NullableSort
    UninterpretedSort
    } derive(Eq,
    Debug
    )

    cvc5 1.3.4 sort kinds. See the upstream API for arities and sorts. Generated by scripts/generate-kinds.js; checked against the C headers.

    SortKind::equal

    fn SortKind::equal(SortKind, SortKind) -> Bool

    SortKind::not_equal

    fn SortKind::not_equal(x : SortKind, y : SortKind) -> Bool

    SortKind::to_repr

    Term

    pub struct Term {
    // private fields
    }

    An immutable expression. Its manager remains alive as long as the term does.
    impl Eq for Term
    impl Show for Term

    Term::children

    fn Term::children(self : Term) -> Array[Term] raise Cvc5Error

    The immediate children of the expression, in order.

    Term::equal

    fn Term::equal(self : Term, other : Term) -> Bool

    Term::get_bit_vector_value

    fn Term::get_bit_vector_value(self : Term, base? : UInt) -> String raise Cvc5Error

    Read an unsigned bit-vector value in base 2, 10, or 16.

    Term::get_boolean_value

    fn Term::get_boolean_value(self : Term) -> Bool raise Cvc5Error

    Read a Boolean literal. The C API terminates the process for other values.

    Term::get_int64_value

    fn Term::get_int64_value(self : Term) -> Int64 raise Cvc5Error

    Read an integral value that fits in Int64. The C API terminates the process on overflow or if the term is not an integral value.

    Term::get_integer_value

    fn Term::get_integer_value(self : Term) -> String raise Cvc5Error

    Read an arbitrary-precision integral value as decimal digits.

    Term::get_real_value

    fn Term::get_real_value(self : Term) -> String raise Cvc5Error

    Read an exact rational value as a string, without rounding to floating point.

    Term::get_string_value

    fn Term::get_string_value(self : Term) -> String raise Cvc5Error

    Read the literal Unicode contents, without SMT-LIB quotes or escapes.

    Term::kind

    fn Term::kind(self : Term) -> Kind

    Term::not_equal

    fn Term::not_equal(x : Term, y : Term) -> Bool

    Term::output

    fn Term::output(self : Term, logger : &Logger) -> Unit

    Term::sort

    fn Term::sort(self : Term) -> Sort raise Cvc5Error

    Term::substitute

    fn Term::substitute(self : Term, from : ArrayView[Term], to : ArrayView[Term]) -> Term raise Cvc5Error

    Simultaneously substitute terms. Both lists must have equal length.

    Term::symbol

    fn Term::symbol(self : Term) -> String? raise Cvc5Error

    Term::to_string

    fn Term::to_string(self : Term) -> String

    Render a term as SMT-LIB text.

    TermManager

    pub struct TermManager {
    // private fields
    }

    Creates sorts, terms, and operators. Derived objects keep this manager alive.

    TermManager::array_sort

    fn TermManager::array_sort(self : TermManager, index : Sort, element : Sort) -> Sort raise Cvc5Error

    Create an array sort with the given index and element sorts.

    TermManager::bit_vector_sort

    fn TermManager::bit_vector_sort(self : TermManager, width : UInt) -> Sort raise Cvc5Error

    Create a bit-vector sort with a positive width.

    TermManager::boolean_sort

    fn TermManager::boolean_sort(self : TermManager) -> Sort raise Cvc5Error

    The boolean sort.

    TermManager::function_sort

    fn TermManager::function_sort(self : TermManager, domain : ArrayView[Sort], codomain : Sort) -> Sort raise Cvc5Error

    Create a function sort. The domain must be nonempty.

    TermManager::integer_sort

    fn TermManager::integer_sort(self : TermManager) -> Sort raise Cvc5Error

    The integer sort.

    TermManager::mk_bit_vector

    fn TermManager::mk_bit_vector(self : TermManager, width : UInt, value : UInt64) -> Term raise Cvc5Error

    Create a bit vector. Values must fit in the specified positive width.

    TermManager::mk_bit_vector_str

    fn TermManager::mk_bit_vector_str(self : TermManager, width : UInt, value : String, base? : UInt) -> Term raise Cvc5Error

    Create a bit vector of arbitrary width from base 2, 10, or 16 digits.

    TermManager::mk_boolean

    fn TermManager::mk_boolean(self : TermManager, value : Bool) -> Term raise Cvc5Error

    Create a Boolean literal.

    TermManager::mk_const

    fn TermManager::mk_const(self : TermManager, sort : Sort, symbol : String) -> Term raise Cvc5Error

    Create a fresh free constant. Reusing a name does not reuse a constant. The name must not contain embedded NUL characters.

    TermManager::mk_const_array

    fn TermManager::mk_const_array(self : TermManager, sort : Sort, value : Term) -> Term raise Cvc5Error

    Create an array whose every element has the supplied value.

    TermManager::mk_integer

    fn TermManager::mk_integer(self : TermManager, value : Int64) -> Term raise Cvc5Error

    Create an integer literal from a signed 64-bit value.

    TermManager::mk_integer_str

    fn TermManager::mk_integer_str(self : TermManager, value : String) -> Term raise Cvc5Error

    Create an arbitrary-precision integer from a decimal string.

    TermManager::mk_op

    fn TermManager::mk_op(self : TermManager, kind : Kind, indices : ArrayView[UInt]) -> Op raise Cvc5Error

    Create an operator with indices, for example BitVectorExtract with [7, 0].

    TermManager::mk_real

    fn TermManager::mk_real(self : TermManager, value : String) -> Term raise Cvc5Error

    Create an exact real literal from an integer, decimal, or rational such as "1/3".

    TermManager::mk_string

    fn TermManager::mk_string(self : TermManager, value : String) -> Term raise Cvc5Error

    Create a Unicode string literal, preserving embedded NULs. Backslashes are literal. Only Unicode scalar values in the SMT-LIB range U+0000–U+2FFFF are supported. Code points above U+2FFFF and unpaired UTF-16 surrogates raise Cvc5Error.

    TermManager::mk_term

    fn TermManager::mk_term(self : TermManager, kind : Kind, children : ArrayView[Term]) -> Term raise Cvc5Error

    Create an expression. cvc5 checks the kind, number of children, and their sorts.

    TermManager::mk_term_from_op

    fn TermManager::mk_term_from_op(self : TermManager, op : Op, children : ArrayView[Term]) -> Term raise Cvc5Error

    Apply a previously created operator to its children.

    TermManager::mk_var

    fn TermManager::mk_var(self : TermManager, sort : Sort, symbol : String) -> Term raise Cvc5Error

    Create a bound variable for quantifiers and lambdas. The name must not contain embedded NUL characters.

    TermManager::new

    fn TermManager::new() -> TermManager raise Cvc5Error

    Create a term manager; derived objects retain it automatically.

    TermManager::real_sort

    fn TermManager::real_sort(self : TermManager) -> Sort raise Cvc5Error

    The real sort.

    TermManager::regexp_sort

    fn TermManager::regexp_sort(self : TermManager) -> Sort raise Cvc5Error

    The regexp sort.

    TermManager::rounding_mode_sort

    fn TermManager::rounding_mode_sort(self : TermManager) -> Sort raise Cvc5Error

    The rounding mode sort.

    TermManager::sequence_sort

    fn TermManager::sequence_sort(self : TermManager, element : Sort) -> Sort raise Cvc5Error

    Create a sequence sort.

    TermManager::set_sort

    fn TermManager::set_sort(self : TermManager, element : Sort) -> Sort raise Cvc5Error

    Create a set sort.

    TermManager::string_sort

    fn TermManager::string_sort(self : TermManager) -> Sort raise Cvc5Error

    The string sort.

    TermManager::uninterpreted_sort

    fn TermManager::uninterpreted_sort(self : TermManager, symbol : String) -> Sort raise Cvc5Error

    Create a fresh uninterpreted sort with a display name. The name must not contain embedded NUL characters.