Skip to content

Commit 08d5dfa

Browse files
committed
Do not proceed if the SMT ground truth is not Sat
1 parent ce11d9e commit 08d5dfa

File tree

1 file changed

+31
-26
lines changed

1 file changed

+31
-26
lines changed

booster/library/Booster/SMT/Interface.hs

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -431,29 +431,34 @@ checkPredicates ctxt givenPs givenSubst psToCheck
431431
-- assert ground truth
432432
mapM_ smtRun smtGiven
433433

434-
consistent <- smtRun CheckSat
435-
unless (consistent == Sat) $ do
436-
let errMsg = ("Inconsistent ground truth, check returns Nothing" :: Text)
437-
Log.logMessage errMsg
438-
let ifConsistent check = if (consistent == Sat) then check else pure Unsat
439-
440-
-- save ground truth for 2nd check
441-
smtRun_ Push
442-
443-
-- run check for K ∧ P and then for K ∧ !P
444-
let allToCheck = SMT.List (Atom "and" : sexprsToCheck)
445-
446-
positive <- ifConsistent $ do
447-
smtRun_ $ Assert "P" allToCheck
448-
smtRun CheckSat
449-
smtRun_ Pop
450-
negative <- ifConsistent $ do
451-
smtRun_ $ Assert "not P" (SMT.smtnot allToCheck)
452-
smtRun CheckSat
453-
smtRun_ Pop
454-
455-
Log.logMessage $
456-
"Check of Given ∧ P and Given ∧ !P produced "
457-
<> pack (show (positive, negative))
458-
459-
pure (positive, negative)
434+
groundTruthCheckSmtResult <- smtRun CheckSat
435+
Log.logMessage ("Ground truth check returned: " <> show groundTruthCheckSmtResult)
436+
case groundTruthCheckSmtResult of
437+
Unsat -> do
438+
Log.logMessage ("Inconsistent ground truth" :: Text)
439+
pure (Unsat, Unsat)
440+
Unknown -> do
441+
Log.logMessage ("Unknown ground truth" :: Text)
442+
pure (Unknown, Unknown)
443+
_ -> do
444+
-- save ground truth for 2nd check
445+
smtRun_ Push
446+
447+
-- run check for K ∧ P and then for K ∧ !P
448+
let allToCheck = SMT.List (Atom "and" : sexprsToCheck)
449+
450+
positive <- do
451+
smtRun_ $ Assert "P" allToCheck
452+
smtRun CheckSat
453+
smtRun_ Pop
454+
455+
negative <- do
456+
smtRun_ $ Assert "not P" (SMT.smtnot allToCheck)
457+
smtRun CheckSat
458+
smtRun_ Pop
459+
460+
Log.logMessage $
461+
"Check of Given ∧ P and Given ∧ !P produced "
462+
<> pack (show (positive, negative))
463+
464+
pure (positive, negative)

0 commit comments

Comments
 (0)