Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CVC4 from Macports in OS X does not work with SAW/SBV #146

Closed
robby-phd opened this issue Jun 9, 2016 · 7 comments
Closed

CVC4 from Macports in OS X does not work with SAW/SBV #146

robby-phd opened this issue Jun 9, 2016 · 7 comments
Labels
type: bug Issues reporting bugs or unexpected/unwanted behavior

Comments

@robby-phd
Copy link
Contributor

robby-phd commented Jun 9, 2016

In OS X, SAW complains that it cannot find CVC4 executable if CVC4 is installed using Macports. A quick inspection indicates that it seems SBV cannot find CVC4 in /opt/local/bin, although it's installed there by Macports. Oddly, it works if one installs CVC4 pre-compiled binary downloaded from the CVC4 website (which interestingly, is created using Macports).

@brianhuffman
Copy link
Contributor

Do you get a similar error with the Cryptol REPL if you use :set prover=cvc4?

@robby-phd
Copy link
Contributor Author

Yup.

Main> :set prover=cvc4
Warning: cvc4 installation not found
Main> :prove correctSpeck32_64
*** An error occurred.
*** Failed to start the external solver: fd:54: hGetLine: end of file
*** Make sure you can start "/opt/local/bin/cvc4"
*** from the command line without issues.

@brianhuffman
Copy link
Contributor

The relevant SBV code is at
https://github.com/LeventErkok/sbv/blob/master/Data/SBV/SMT/SMT.hs#L396 and
https://github.com/LeventErkok/sbv/blob/master/Data/SBV/SMT/SMT.hs#L495 .

It doesn't look like SBV is doing anything weird; it's possible the library functions for finding and running the executable are at fault. The relevant library functions are

  • findExecutable from module System.Directory in package directory
  • runInteractiveProcess from module System.Process in package process

Perhaps you could try running findExecutable "cvc4" from ghci on your system and see what you get?

@robby-phd
Copy link
Contributor Author

findExecutable found the CVC4 executable at /opt/local/bin. Also, runInteractiveProcess seems to work using the following program (note: I'm not that familiar with Haskell):

import System.Process
import Control.Concurrent
import System.IO

main = do
  putStrLn "Running cvc4 ..."
  (inp, out, err, pid) <- runInteractiveProcess "cvc4" [] Nothing Nothing
  forkIO (hPutStrLn inp "EXIT;" >> hClose inp)
  forkIO (putStrLn =<< hGetContents out)
  forkIO (putStrLn =<< hGetContents err)
  threadDelay 1000000
  return ()

@robby-phd
Copy link
Contributor Author

I tried the following SMT2 query. CVC4 works using runInteractiveProcess (but still does not work in Cryptol/SAW/SBV):

import System.Process
import Control.Concurrent
import System.IO

main = do
  putStrLn "Running cvc4 ..."
  (inp, out, err, pid) <- runInteractiveProcess "cvc4" ["--language", "smt2"] Nothing Nothing
  forkIO (hPutStrLn inp "(set-logic AUFLIA) \
                        \(declare-const l_n Int) \
                        \(declare-const l_r_0 Int) \
                        \(declare-const l_r Int) \
                        \(declare-const l_r_1 Int) \
                        \(assert (not (=> (and (> l_n (- 128)) (or (and (> l_n 0) (and (= l_r_0 0) (= l_r l_n))) (and (not (> l_n 0)) (and (= l_r_1 0) (= l_r (- l_n)))))) (>= l_r 0)))) \
                        \(check-sat)" >> hClose inp)
  forkIO (putStrLn =<< hGetContents out)
  forkIO (putStrLn =<< hGetContents err)
  threadDelay 1000000
  return ()

@atomb atomb added the type: bug Issues reporting bugs or unexpected/unwanted behavior label May 2, 2017
@atomb
Copy link
Contributor

atomb commented Aug 7, 2017

I think this is ultimately a problem with the MacPorts version of CVC4. The version I've compiled from source seems to work fine with the latest Cryptol, SAW, and SBV. In my experience, the MacPorts version of CVC4 has frequently crashed, while from-source builds from the latest GitHub code seem pretty stable. Feel free to re-open with more information if you still see this happening.

@atomb atomb closed this as completed Aug 7, 2017
@linesthatinterlace
Copy link

I am having a similar issues with the Linux version of CVC4 (within WSL2, but that shouldn't make a difference). Cryptol and SAW cannot find CVC4, but findExecutable finds it, the above program runs (with a small modification, but not relevant I think...)

Is CVC4 still supported?

brianhuffman pushed a commit that referenced this issue Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Issues reporting bugs or unexpected/unwanted behavior
Projects
None yet
Development

No branches or pull requests

4 participants