Solve satisfiability modulo theories (SMT) problems using the bundled OpenSMT solver, described in Hyvärinen, Marescotti, Alt and Sharygina (2016) <doi:10.1007/978-3-319-40970-2_35>. Problems are writ
翻譯準備中
開發工具C++ · RGitHub @pedrobtz上線中營運者未確認
試用過了嗎? 點一下就好,不需要登入。
尚未偵測到更新。GitHub 發布版本後會顯示在這裡。
個人 GitHub 帳號下公開儲存庫的擁有者可以登入並驗證所有權,自行管理介紹,無需管理員核准。
登入並產生驗證檔案,在 30 分鐘內將其提交至此儲存庫的預設分支。其他分支或分叉儲存庫中的檔案無效。然後在下方檢查檔案,即可無需管理員核准直接管理專案。請保留檔案以維持管理權限。
如需登入,將前往登入頁面。登入後請回到此處,再次點擊所選的驗證按鈕。
在專案資料夾中執行 /nomorevibe verify,即可驗證所有權並自行管理介紹。
一分鐘完成驗證Solve satisfiability modulo theories (SMT) problems using the bundled OpenSMT solver, described in Hyvärinen, Marescotti, Alt and Sharygina (2016) <doi:10.1007/978-3-319-40970-2_35>. Problems are written in the SMT-LIB standard language and answers come back as R values, with model values carrying the solver's exact rational alongside the double. Supported theories include uninterpreted functions, linear integer and real arithmetic and their combinations, difference logic, and arrays. The solver
翻譯準備中
取自儲存庫 README
正在載入完整 README。 以下為已儲存的摘錄。
An SMT solver in R. zusmt bundles OpenSMT
and exposes it through a small R interface: you write problems in SMT-LIB2 and get answers back as R
values. There is no separate solver to install and nothing to configure — the solver is compiled into
the package.
Building from source needs a C++20 compiler and GMP with its C++ bindings
(libgmp-dev on Debian and Ubuntu, gmp-devel on Fedora, brew install gmp on macOS; Rtools
supplies it on Windows).
Three people need distinct meeting slots between 9 and 17, Alice before Bob, and Carol two hours
after Bob:檢視完整 README ↗An SMT solver in R. zusmt bundles OpenSMT and exposes it through a small R interface: you write problems in SMT-LIB2 and get answers back as R values. There is no separate solver to install and nothing to configure — the solver is compiled into the package.
install.packages("zusmt")
Or the development version:
# install.packages("pak")
pak::pak("pedrobtz/zusmt")
Building from source needs a C++20 compiler and GMP with its C++ bindings
(libgmp-dev on Debian and Ubuntu, gmp-devel on Fedora, brew install gmp on macOS; Rtools
supplies it on Windows).
Three people need distinct meeting slots between 9 and 17, Alice before Bob, and Carol two hours after Bob:
library(zusmt)
s <- smt_solver("QF_LIA")
smt_assert(s, "
(declare-const alice Int)
(declare-const bob Int)
(declare-const carol Int)
(assert (and (>= alice 9) (<= alice 17)))
(assert (and (>= bob 9) (<= bob 17)))
(assert (and (>= carol 9) (<= carol 17)))
(assert (distinct alice bob carol))
(assert (< alice bob))
(assert (= carol (+ bob 2)))
")
smt_check(s)
#> [1] "sat"
smt_model(s)
#> $alice
#> [1] 9
#> $bob
#> [1] 10
#> $carol
#> [1] 12
When a problem has no solution, you are told so rather than given a wrong answer. 2x = 3 has no
integer solution:
u <- smt_solver("QF_LIA")
smt_assert(u, "(declare-const x Int) (assert (= (* 2 x) 3))")
smt_check(u)
#> [1] "unsat"
Solvers work in rationals, and not every rational is a double. Model values carry the solver's exact
answer alongside the numeric one, so you can compute with the double and still see what was meant:
r <- smt_solver("QF_LRA")
smt_assert(r, "(declare-const third Real) (assert (= (* 3.0 third) 1.0))")
smt_check(r)
#> [1] "sat"
value <- smt_model(r)$third
value
#> [1] 0.3333333
attr(value, "exact")
#> [1] "1/3"
smt_logics()
#> [1] "QF_UF" "QF_LIA" "QF_LRA" "QF_UFLIA" "QF_UFLRA" "QF_IDL" "QF_RDL"
#> [8] "QF_AX"
Uninterpreted functions, linear integer and real arithmetic and their combinations, difference logic,
and arrays. smt_assert() accepts any SMT-LIB2 command, not only assert — push, pop,
declarations and options all work, so a script written for another solver usually runs unchanged.
A long search can be interrupted: Ctrl-C stops it and raises an R condition, rather than leaving
the session wedged in the solver.
OpenSMT v2.9.2, under src/opensmt/, imported by tools/vendor.sh and recorded in
tools/vendor/manifest.tsv. Both zusmt and OpenSMT are MIT licensed; see LICENSE.note for the
bundled copyright notices. The vendored sources carry a small set of patches, applied mechanically by
tools/patches.sh, so that the solver writes to R's console rather than to stdout, raises exceptions
instead of calling exit(), and stops when you interrupt it.