Skip to content

Commit

Permalink
Fail when checking definition with Z3 returns Unknown (#3628)
Browse files Browse the repository at this point in the history
Fixes #3619
The definition provided in the above issue now throws the following
error after re-trying once with quadruple the smt timeout:

```
kore-rpc: [4462799] Error (ErrorException):
    The definitions sent to the solver may not be consistent (Z3 timed out).
    CallStack (from HasCallStack):
      error, called at src/Kore/Rewrite/SMT/Lemma.hs:180:9 in kore-0.60.0.0-inplace:Kore.Rewrite.SMT.Lemma
```
  • Loading branch information
goodlyrottenapple authored Jul 28, 2023
1 parent 3ac2c87 commit 389d130
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions kore/src/Kore/Rewrite/SMT/Lemma.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Control.Monad.Except
import Control.Monad.State qualified as State
import Data.Functor.Foldable qualified as Recursive
import Data.Generics.Product.Fields
import Data.Limit (Limit (..))
import Data.Map.Strict qualified as Map
import Data.Text qualified as Text
import Kore.Attribute.Axiom qualified as Attribute
Expand Down Expand Up @@ -52,8 +53,10 @@ import SMT (
MonadSMT (..),
Result (..),
SExpr (..),
TimeOut (..),
assert,
check,
localTimeOut,
)

getSMTLemmas ::
Expand Down Expand Up @@ -84,9 +87,22 @@ declareSMTLemmas ::
declareSMTLemmas tools lemmas = do
declareSortsSymbols $ smtData tools
mapM_ declareRule lemmas
isUnsatisfiable <- fmap (Unsat ==) <$> SMT.check
when (fromMaybe False isUnsatisfiable) errorInconsistentDefinitions
SMT.check >>= \case
Nothing -> pure ()
Just Sat -> pure ()
Just Unsat -> errorInconsistentDefinitions
Just Unknown -> do
SMT.localTimeOut quadrupleTimeOut $
SMT.check >>= \case
Nothing -> pure ()
Just Sat -> pure ()
Just Unsat -> errorInconsistentDefinitions
Just Unknown -> errorPossiblyInconsistentDefinitions
where
quadrupleTimeOut :: SMT.TimeOut -> SMT.TimeOut
quadrupleTimeOut (SMT.TimeOut Unlimited) = SMT.TimeOut Unlimited
quadrupleTimeOut (SMT.TimeOut (Limit r)) = SMT.TimeOut (Limit (4 * r))

declareRule ::
SentenceAxiom (TermLike VariableName) ->
m (Maybe ())
Expand Down Expand Up @@ -173,6 +189,8 @@ declareSMTLemmas tools lemmas = do

~errorInconsistentDefinitions =
error "The definitions sent to the solver are inconsistent."
~errorPossiblyInconsistentDefinitions =
error "The definitions sent to the solver may not be consistent (Z3 timed out)."

translateUninterpreted ::
( Ord variable
Expand Down

0 comments on commit 389d130

Please sign in to comment.