Skip to content

Commit 3cf099b

Browse files
committed
SMTChecker: Upgrade CVC4 to cvc5
Instead of compiling `solc` itself with CVC4 support, it is now enough to have `cvc5` executable on PATH when running the compiler. Instead of using API of CVC4, we now use SMT-LIB2 interface. That means we write the queries to temporary SMT-LIB2 files and call the solver process directly to run on the file.
1 parent 816b588 commit 3cf099b

File tree

26 files changed

+88
-525
lines changed

26 files changed

+88
-525
lines changed

CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,15 @@ elseif (${Z3_FOUND})
133133
message("Z3 SMT solver found. This enables optional SMT checking with Z3.")
134134
endif()
135135

136-
find_package(CVC4 QUIET)
137-
if (${CVC4_FOUND})
138-
add_definitions(-DHAVE_CVC4)
139-
message("CVC4 SMT solver found. This enables optional SMT checking with CVC4.")
136+
find_program(CVC5_PATH cvc5)
137+
if (CVC5_PATH)
138+
add_compile_definitions(CVC5_PATH=${CVC5_PATH})
139+
message("cvc5 SMT solver found. This enables optional SMT checking with cvc5.")
140140
endif()
141141

142-
if (NOT (${Z3_FOUND} OR ${CVC4_FOUND}))
142+
if (NOT (${Z3_FOUND} OR CVC5_PATH))
143143
message("No SMT solver found (or it has been forcefully disabled). Optional SMT checking will not be available.\
144-
\nPlease install Z3 or CVC4 or remove the option disabling them (USE_Z3, USE_CVC4).")
144+
\nPlease install Z3 or cvc5 or remove the option disabling them (USE_Z3).")
145145
endif()
146146

147147
add_subdirectory(libsolutil)

cmake/EthCompilerSettings.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ option(USE_Z3 "Allow compiling with Z3 SMT solver integration" ON)
266266
if(UNIX AND NOT APPLE)
267267
option(USE_Z3_DLOPEN "Dynamically load the Z3 SMT solver instead of linking against it." OFF)
268268
endif()
269-
option(USE_CVC4 "Allow compiling with CVC4 SMT solver integration" ON)
270269

271270
if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
272271
option(USE_LD_GOLD "Use GNU gold linker" ON)

cmake/FindCVC4.cmake

Lines changed: 0 additions & 33 deletions
This file was deleted.

docs/installing-solidity.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,7 @@ The following are dependencies for all builds of Solidity:
333333
+-----------------------------------+-------------------------------------------------------+
334334
| `z3`_ (version 4.8.16+, Optional) | For use with SMT checker. |
335335
+-----------------------------------+-------------------------------------------------------+
336-
| `cvc4`_ (Optional) | For use with SMT checker. |
337-
+-----------------------------------+-------------------------------------------------------+
338336

339-
.. _cvc4: https://cvc4.cs.stanford.edu/web/
340337
.. _Git: https://git-scm.com/download
341338
.. _Boost: https://www.boost.org
342339
.. _CMake: https://cmake.org/download/
@@ -543,12 +540,6 @@ Inside the build folder you can disable them, since they are enabled by default:
543540
# disables only Z3 SMT Solver.
544541
cmake .. -DUSE_Z3=OFF
545542
546-
# disables only CVC4 SMT Solver.
547-
cmake .. -DUSE_CVC4=OFF
548-
549-
# disables both Z3 and CVC4
550-
cmake .. -DUSE_CVC4=OFF -DUSE_Z3=OFF
551-
552543
The Version String in Detail
553544
============================
554545

docs/smtchecker.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,10 +822,10 @@ which is primarily an SMT solver and makes `Spacer
822822
<https://github.com/uuverifiers/eldarica>`_ which does both.
823823

824824
The user can choose which solvers should be used, if available, via the CLI
825-
option ``--model-checker-solvers {all,cvc4,eld,smtlib2,z3}`` or the JSON option
825+
option ``--model-checker-solvers {all,cvc5,eld,smtlib2,z3}`` or the JSON option
826826
``settings.modelChecker.solvers=[smtlib2,z3]``, where:
827827

828-
- ``cvc4`` is only available if the ``solc`` binary is compiled with it. Only BMC uses ``cvc4``.
828+
- ``cvc5`` is used via its binary which must be installed in the system. Only BMC uses ``cvc5``.
829829
- ``eld`` is used via its binary which must be installed in the system. Only CHC uses ``eld``, and only if ``z3`` is not enabled.
830830
- ``smtlib2`` outputs SMT/Horn queries in the `smtlib2 <http://smtlib.cs.uiowa.edu/>`_ format.
831831
These can be used together with the compiler's `callback mechanism <https://github.com/ethereum/solc-js>`_ so that
@@ -849,7 +849,7 @@ concerned about this option. More advanced users might apply this option to try
849849
alternative solvers on more complex problems.
850850

851851
Please note that certain combinations of chosen engine and solver will lead to
852-
the SMTChecker doing nothing, for example choosing CHC and ``cvc4``.
852+
the SMTChecker doing nothing, for example choosing CHC and ``cvc5``.
853853

854854
*******************************
855855
Abstraction and False Positives

docs/using-the-compiler.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ Input Description
485485
"showUnsupported": true,
486486
// Choose which solvers should be used, if available.
487487
// See the Formal Verification section for the solvers description.
488-
"solvers": ["cvc4", "smtlib2", "z3"],
488+
"solvers": ["cvc5", "smtlib2", "z3"],
489489
// Choose which targets should be checked: constantCondition,
490490
// underflow, overflow, divByZero, balance, assert, popEmptyArray, outOfBounds.
491491
// If the option is not given all targets are checked by default,

libsmtutil/CMakeLists.txt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ else()
2020
set(z3_SRCS)
2121
endif()
2222

23-
if (${CVC4_FOUND})
24-
set(cvc4_SRCS CVC4Interface.cpp CVC4Interface.h)
25-
else()
26-
set(cvc4_SRCS)
27-
endif()
28-
2923
if (${USE_Z3_DLOPEN})
3024
file(GLOB Z3_HEADERS ${Z3_HEADER_PATH}/z3*.h)
3125
set(Z3_WRAPPER ${CMAKE_CURRENT_BINARY_DIR}/z3wrapper.cpp)
@@ -38,7 +32,7 @@ if (${USE_Z3_DLOPEN})
3832
set(z3_SRCS ${z3_SRCS} ${Z3_WRAPPER} Z3Loader.cpp Z3Loader.h)
3933
endif()
4034

41-
add_library(smtutil ${sources} ${z3_SRCS} ${cvc4_SRCS})
35+
add_library(smtutil ${sources} ${z3_SRCS})
4236
target_link_libraries(smtutil PUBLIC solutil Boost::boost)
4337

4438
if (${USE_Z3_DLOPEN})
@@ -47,7 +41,3 @@ if (${USE_Z3_DLOPEN})
4741
elseif (${Z3_FOUND})
4842
target_link_libraries(smtutil PUBLIC z3::libz3)
4943
endif()
50-
51-
if (${CVC4_FOUND})
52-
target_link_libraries(smtutil PUBLIC CVC4::CVC4)
53-
endif()

0 commit comments

Comments
 (0)