Skip to content

Commit

Permalink
Remove unnecessary calls to mkTypedTerm.
Browse files Browse the repository at this point in the history
This is a step toward fixing #718.

The use of mkTypedTerm is redundant in these cases in the
SAWScript.Prover modules, as the computed schema in all cases
is only used to check that the return type is Bool, and the
prior calls to `propToPredicate` already ensure that.
  • Loading branch information
Brian Huffman committed May 19, 2020
1 parent eeef9a1 commit f7bb948
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 20 deletions.
7 changes: 2 additions & 5 deletions src/SAWScript/Prover/ABC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ module SAWScript.Prover.ABC (proveABC) where
import qualified Data.AIG as AIG

import Verifier.SAW.SharedTerm
import Verifier.SAW.TypedTerm
import Verifier.SAW.FiniteValue
import qualified Verifier.SAW.Simulator.BitBlast as BBSim

import SAWScript.Proof(Prop, propToPredicate)
import SAWScript.Prover.SolverStats (SolverStats, solverStats)
import SAWScript.Prover.Rewrite(rewriteEqs)
import SAWScript.Prover.Util
(liftCexBB, bindAllExts, checkBooleanSchema)
(liftCexBB, bindAllExts)

-- | Bit-blast a proposition and check its validity using ABC.
proveABC ::
Expand All @@ -23,9 +22,7 @@ proveABC ::
IO (Maybe [(String, FirstOrderValue)], SolverStats)
proveABC proxy sc goal =
do t0 <- propToPredicate sc goal
TypedTerm schema t <-
(bindAllExts sc t0 >>= rewriteEqs sc >>= mkTypedTerm sc)
checkBooleanSchema schema
t <- bindAllExts sc t0 >>= rewriteEqs sc
BBSim.withBitBlastedPred proxy sc mempty t $
\be lit0 shapes ->
do let lit = AIG.not lit0
Expand Down
5 changes: 1 addition & 4 deletions src/SAWScript/Prover/RME.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Verifier.SAW.FiniteValue

import qualified Verifier.SAW.Simulator.RME as RME
import qualified Verifier.SAW.Simulator.RME.Base as RME
import Verifier.SAW.TypedTerm(TypedTerm(..), mkTypedTerm)
import Verifier.SAW.Recognizer(asPiList)

import SAWScript.Proof(Prop, propToPredicate)
Expand All @@ -22,9 +21,7 @@ proveRME ::
IO (Maybe [(String, FirstOrderValue)], SolverStats)
proveRME sc goal =
do t0 <- propToPredicate sc goal
TypedTerm schema t <-
bindAllExts sc t0 >>= rewriteEqs sc >>= mkTypedTerm sc
checkBooleanSchema schema
t <- bindAllExts sc t0 >>= rewriteEqs sc
tp <- scWhnf sc =<< scTypeOf sc t
let (args, _) = asPiList tp
argNames = map fst args
Expand Down
7 changes: 1 addition & 6 deletions src/SAWScript/Prover/SBV.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ import qualified Verifier.SAW.Simulator.SBV as SBVSim

import Verifier.SAW.SharedTerm
import Verifier.SAW.FiniteValue
import Verifier.SAW.TypedTerm(TypedTerm(..), mkTypedTerm)
import Verifier.SAW.Recognizer(asPi, asPiList)

import SAWScript.Proof(Prop, propToPredicate)
import SAWScript.Prover.SolverStats
import SAWScript.Prover.Rewrite(rewriteEqs)
import SAWScript.Prover.Util(checkBooleanSchema)



-- | Bit-blast a proposition and check its validity using SBV.
Expand Down Expand Up @@ -93,10 +90,8 @@ prepNegatedSBV sc unints goal =
let nonFun e = fmap ((== Nothing) . asPi) (scWhnf sc (ecType e))
exts <- filterM nonFun (getAllExts t0)

TypedTerm schema t' <-
scAbstractExts sc exts t0 >>= rewriteEqs sc >>= mkTypedTerm sc
t' <- scAbstractExts sc exts t0 >>= rewriteEqs sc

checkBooleanSchema schema
(labels, lit) <- SBVSim.sbvSolve sc mempty unints t'
let lit' = liftM SBV.svNot lit
return (t', labels, lit')
Expand Down
6 changes: 1 addition & 5 deletions src/SAWScript/Prover/What4.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ import Data.Maybe (catMaybes)
import Verifier.SAW.SharedTerm
import Verifier.SAW.FiniteValue

import Verifier.SAW.TypedTerm(TypedTerm(..), mkTypedTerm)
import Verifier.SAW.Recognizer(asPi)

import SAWScript.Proof(Prop, propToPredicate)
import SAWScript.Prover.Rewrite(rewriteEqs)
import SAWScript.Prover.SolverStats
import SAWScript.Prover.Util

import Data.Parameterized.Nonce

Expand Down Expand Up @@ -119,10 +117,8 @@ prepWhat4 sym sc unints t0 = do
let nonFun e = fmap ((== Nothing) . asPi) (scWhnf sc (ecType e))
exts <- filterM nonFun (getAllExts t0)

TypedTerm schema t' <-
scAbstractExts sc exts t0 >>= rewriteEqs sc >>= mkTypedTerm sc
t' <- scAbstractExts sc exts t0 >>= rewriteEqs sc

checkBooleanSchema schema
(argNames, lit) <- W.w4Solve sym sc mempty unints t'
return (t', argNames, lit)

Expand Down

0 comments on commit f7bb948

Please sign in to comment.