sbv 0.9.21 → 0.9.22
raw patch · 68 files changed
+5724/−796 lines, 68 filessetup-changed
Files
- Data/SBV.hs +20/−16
- Data/SBV/BitVectors/Data.hs +47/−15
- Data/SBV/BitVectors/Model.hs +41/−23
- Data/SBV/BitVectors/Polynomial.hs +69/−16
- Data/SBV/BitVectors/PrettyNum.hs +2/−3
- Data/SBV/BitVectors/STree.hs +4/−4
- Data/SBV/BitVectors/SignCast.hs +1/−0
- Data/SBV/Compilers/C.hs +157/−125
- Data/SBV/Compilers/CodeGen.hs +47/−16
- Data/SBV/Examples/Basics/BasicTests.hs +6/−6
- Data/SBV/Examples/Basics/Higher.hs +1/−1
- Data/SBV/Examples/Basics/Index.hs +13/−13
- Data/SBV/Examples/Basics/ProofTests.hs +6/−2
- Data/SBV/Examples/Basics/QRem.hs +2/−2
- Data/SBV/Examples/BitPrecise/Legato.hs +2/−2
- Data/SBV/Examples/BitPrecise/PrefixSum.hs +10/−9
- Data/SBV/Examples/CRC/CCITT.hs +4/−4
- Data/SBV/Examples/CRC/CCITT_Unidir.hs +3/−3
- Data/SBV/Examples/CRC/GenPoly.hs +4/−4
- Data/SBV/Examples/CRC/USB5.hs +3/−3
- Data/SBV/Examples/CodeGeneration/CRC_USB5.hs +86/−0
- Data/SBV/Examples/Crypto/AES.hs +7/−7
- Data/SBV/Examples/Crypto/RC4.hs +2/−3
- Data/SBV/Examples/Existentials/CRCPolynomial.hs +99/−0
- Data/SBV/Examples/Puzzles/Counts.hs +2/−2
- Data/SBV/Examples/Puzzles/DogCatMouse.hs +7/−2
- Data/SBV/Examples/Puzzles/Euler185.hs +1/−1
- Data/SBV/Examples/Puzzles/MagicSquare.hs +3/−3
- Data/SBV/Examples/Puzzles/NQueens.hs +1/−1
- Data/SBV/Examples/Puzzles/PowerSet.hs +1/−1
- Data/SBV/Examples/Puzzles/Sudoku.hs +5/−3
- Data/SBV/Examples/Puzzles/Temperature.hs +2/−2
- Data/SBV/Examples/Puzzles/U2Bridge.hs +8/−8
- Data/SBV/Internals.hs +2/−2
- Data/SBV/Provers/Prover.hs +108/−95
- Data/SBV/Provers/SExpr.hs +4/−2
- Data/SBV/Provers/Yices.hs +22/−28
- Data/SBV/Provers/Z3.hs +94/−0
- Data/SBV/SMT/SMT.hs +107/−45
- Data/SBV/SMT/SMTLib.hs +31/−206
- Data/SBV/SMT/SMTLib1.hs +225/−0
- Data/SBV/SMT/SMTLib2.hs +312/−0
- Data/SBV/TestSuite/Basics/Arithmetic.hs +4/−4
- Data/SBV/TestSuite/Basics/ProofTests.hs +8/−9
- Data/SBV/TestSuite/CRC/GenPoly.hs +6/−1
- Data/SBV/TestSuite/CodeGeneration/CRC_USB5.hs +28/−0
- Data/SBV/TestSuite/Existentials/CRCPolynomial.hs +32/−0
- Data/SBV/TestSuite/Puzzles/DogCatMouse.hs +5/−1
- Data/SBV/TestSuite/Puzzles/MagicSquare.hs +1/−1
- Data/SBV/TestSuite/Puzzles/NQueens.hs +1/−1
- Data/SBV/TestSuite/Puzzles/PowerSet.hs +1/−1
- Data/SBV/TestSuite/Puzzles/Sudoku.hs +1/−1
- Data/SBV/TestSuite/Puzzles/Temperature.hs +1/−1
- Data/SBV/TestSuite/Puzzles/U2Bridge.hs +3/−3
- README +18/−13
- SBVUnitTest/GoldFiles/aes128Dec.gold +3/−3
- SBVUnitTest/GoldFiles/aes128Enc.gold +3/−3
- SBVUnitTest/GoldFiles/aes128Lib.gold +9/−9
- SBVUnitTest/GoldFiles/codeGen1.gold +3/−3
- SBVUnitTest/GoldFiles/crcPolyExist.gold +3532/−0
- SBVUnitTest/GoldFiles/crcUSB5_1.gold +177/−0
- SBVUnitTest/GoldFiles/crcUSB5_2.gold +216/−0
- SBVUnitTest/GoldFiles/dogCatMouse.gold +5/−4
- SBVUnitTest/GoldFiles/euler185.gold +2/−1
- SBVUnitTest/SBVUnitTest.hs +74/−55
- SBVUnitTest/SBVUnitTestBuildTime.hs +5/−0
- Setup.hs +2/−1
- sbv.cabal +13/−3
Data/SBV.hs view
@@ -43,7 +43,7 @@ -- -- * 'SArray', 'SFunArray': Flat arrays of symbolic values ----- * Symbolic polynomials over GF(2^n), and polynomial arithmetic+-- * Symbolic polynomials over GF(2^n), polynomial arithmetic, and CRCs -- -- * Uninterpreted constants and functions over symbolic values, with user -- defined SMT-Lib axioms@@ -60,8 +60,10 @@ -- -- * proven correct via an external SMT solver (the 'prove' function) ----- * checked for satisfiability (the 'sat' and 'allSat' functions)+-- * checked for satisfiability (the 'sat', 'allSat' functions) --+-- * used in synthesis (the `sat` function with existentials)+-- -- * quick-checked -- -- If a predicate is not valid, 'prove' will return a counterexample: An@@ -72,20 +74,19 @@ -- The sbv library uses third-party SMT solvers via the standard SMT-Lib interface: -- <http://goedel.cs.uiowa.edu/smtlib/>. ----- While the library is designed to work with any SMT-Lib compliant SMT-solver,--- solver specific support is required for parsing counter-example/model data since--- there is currently no agreed upon format for getting models from arbitrary SMT--- solvers. (The SMT-Lib2 initiative will potentially address this issue in the--- future, at which point the sbv library can be generalized as well.) Currently, we--- only support the Yices SMT solver from SRI as far as the counter-example--- and model generation support is concerned: <http://yices.csl.sri.com/>.--- However, other solvers can be hooked up with relative ease.+-- The SBV library is designed to work with any SMT-Lib compliant SMT-solver.+-- Currently, we support the Yices SMT solver from SRI: <http://yices.csl.sri.com/>,+-- and the Z3 SMT solver from Microsoft: <http://research.microsoft.com/en-us/um/redmond/projects/z3/>. -- -- You /should/ download and install Yices on your machine, and make sure the -- @yices@ executable is in your path before using the sbv library, as it is the -- current default solver. Alternatively, you can specify the location of yices -- executable in the environment variable @SBV_YICES@ and the options to yices--- in @SBV_YICES_OPTIONS@. (The default for the latter is '\"-m -f\"'.)+-- in @SBV_YICES_OPTIONS@.+--+-- Use of quantified variables require an installation of z3. Again,+-- z3 must be in your path. Or, you can use the @SBV_Z3@ and @SBV_Z3_OPTIONS@+-- environment variables to set the executable and the options. --------------------------------------------------------------------------------- module Data.SBV (@@ -115,8 +116,8 @@ , Splittable(..) -- *** Sign-casting , SignCast(..)- -- ** Polynomial arithmetic- , Polynomial(..)+ -- ** Polynomial arithmetic and CRCs+ , Polynomial(..), crcBV, crc -- ** Conditionals: Mergeable values , Mergeable(..) -- ** Symbolic equality@@ -149,6 +150,7 @@ , sat, satWith, isSatisfiable, isSatisfiableWithin -- ** Finding all satisfying assignments , allSat, allSatWith, numberOfModels+ -- * Model extraction -- $modelExtraction @@ -161,8 +163,7 @@ , SatModel(..), getModel, displayModels -- * SMT Interface: Configurations and solvers- , SMTConfig(..), SMTSolver(..), defaultSMTCfg, verboseSMTCfg, timingSMTCfg, verboseTimingSMTCfg, timeout- , yices+ , SMTConfig(..), SMTSolver(..), yices, z3 -- * Symbolic computations , Symbolic, output, SymWord(..)@@ -175,7 +176,7 @@ , SBVCodeGen -- ** Setting code-generation options- , cgPerformRTCs, cgSetDriverValues+ , cgPerformRTCs, cgSetDriverValues, cgGenerateDriver -- ** Designating inputs , cgInput, cgInputArr@@ -185,6 +186,9 @@ -- ** Designating return values , cgReturn, cgReturnArr++ -- ** Code generation with uninterpreted functions+ , cgAddPrototype, cgAddDecl, cgAddLDFlags -- ** Compilation to C , compileToC, compileToCLib
Data/SBV/BitVectors/Data.hs view
@@ -32,6 +32,8 @@ , cache, uncache, uncacheAI, HasSignAndSize(..) , Op(..), NamedSymVar, UnintKind(..), getTableIndex, Pgm, Symbolic, runSymbolic, runSymbolic', State, Size, Outputtable(..), Result(..) , SBVType(..), newUninterpreted, unintFnUIKind, addAxiom+ , Quantifier(..), needsExistentials+ , SMTLibPgm(..), SMTLibVersion(..) ) where import Control.DeepSeq (NFData(..))@@ -81,6 +83,11 @@ newtype NodeId = NodeId Int deriving (Eq, Ord) data SW = SW (Bool, Size) NodeId deriving (Eq, Ord) +data Quantifier = ALL | EX deriving Eq++needsExistentials :: [Quantifier] -> Bool+needsExistentials = (EX `elem`)+ falseSW, trueSW :: SW falseSW = SW (False, 1) $ NodeId (-2) trueSW = SW (False, 1) $ NodeId (-1)@@ -222,7 +229,7 @@ deriving Show -- | Result of running a symbolic computation-data Result = Result [NamedSymVar] -- inputs+data Result = Result [(Quantifier, NamedSymVar)] -- inputs (possibly existential) [(SW, CW)] -- constants [((Int, (Bool, Int), (Bool, Int)), [SW])] -- tables (automatically constructed) (tableno, index-type, result-type) elts [(Int, ArrayInfo)] -- arrays (user specified)@@ -255,8 +262,10 @@ where shs sw = show sw ++ " :: " ++ showType sw sht ((i, at, rt), es) = " Table " ++ show i ++ " : " ++ show at ++ "->" ++ show rt ++ " = " ++ show es shc (sw, cw) = " " ++ show sw ++ " = " ++ show cw- shn (sw, nm) = " " ++ ni ++ " :: " ++ showType sw ++ alias+ shn (q, (sw, nm)) = " " ++ ni ++ " :: " ++ showType sw ++ ex ++ alias where ni = show sw+ ex | q == ALL = ""+ | True = ", existential" alias | ni == nm = "" | True = ", aliasing " ++ show nm sha (i, (nm, (ai, bi), ctx)) = " " ++ ni ++ " :: " ++ mkT ai ++ " -> " ++ mkT bi ++ alias@@ -303,7 +312,7 @@ external (ArrayMerge{}) = False data State = State { rctr :: IORef Int- , rinps :: IORef [NamedSymVar]+ , rinps :: IORef [(Quantifier, NamedSymVar)] , routs :: IORef [SW] , rtblMap :: IORef TableMap , spgm :: IORef Pgm@@ -435,15 +444,15 @@ -- state of the computation, layered on top of IO for creating unique -- references to hold onto intermediate results. newtype Symbolic a = Symbolic (ReaderT State IO a)- deriving (Monad, MonadIO, MonadReader State)+ deriving (Functor, Monad, MonadIO, MonadReader State) -mkSymSBV :: (Bool, Size) -> Maybe String -> Symbolic (SBV a)-mkSymSBV sgnsz mbNm = do+mkSymSBV :: Quantifier -> (Bool, Size) -> Maybe String -> Symbolic (SBV a)+mkSymSBV q sgnsz mbNm = do st <- ask ctr <- liftIO $ incCtr st let nm = maybe ('s':show ctr) id mbNm sw = SW sgnsz (NodeId ctr)- liftIO $ modifyIORef (rinps st) ((sw, nm):)+ liftIO $ modifyIORef (rinps st) ((q, (sw, nm)):) return $ SBV sgnsz $ Right $ cache (const (return sw)) sbvToSymSW :: SBV a -> Symbolic SW@@ -553,14 +562,20 @@ -- in casual uses with 'prove', 'sat', 'allSat' etc, as default instances automatically -- provide the necessary bits. ----- Minimal complete definiton: free, free_, literal, fromCW+-- Minimal complete definiton: forall, forall_, exists, exists_, literal, fromCW class (Bounded a, Ord a) => SymWord a where- -- | Create a user named input- free :: String -> Symbolic (SBV a)+ -- | Create a user named input (universal)+ forall :: String -> Symbolic (SBV a) -- | Create an automatically named input- free_ :: Symbolic (SBV a)+ forall_ :: Symbolic (SBV a) -- | Get a bunch of new words- mkFreeVars :: Int -> Symbolic [SBV a]+ mkForallVars :: Int -> Symbolic [SBV a]+ -- | Create an existential variable+ exists :: String -> Symbolic (SBV a)+ -- | Create an automatically named existential variable+ exists_ :: Symbolic (SBV a)+ -- | Create a bunch of existentials+ mkExistVars :: Int -> Symbolic [SBV a] -- | Turn a literal constant to symbolic literal :: a -> SBV a -- | Extract a literal, if the value is concrete@@ -574,8 +589,9 @@ -- | Does it concretely satisfy the given predicate? isConcretely :: SBV a -> (a -> Bool) -> Bool - -- minimal complete definiton: free, free_, literal, fromCW- mkFreeVars n = mapM (const free_) [1 .. n]+ -- minimal complete definiton: forall, forall_, exists, exists_, literal, fromCW+ mkForallVars n = mapM (const forall_) [1 .. n]+ mkExistVars n = mapM (const exists_) [1 .. n] unliteral (SBV _ (Left c)) = Just $ fromCW c unliteral _ = Nothing isConcrete (SBV _ (Left _)) = True@@ -739,7 +755,22 @@ r `seq` modifyIORef rCache (IMap.insertWith (++) h [(sn, r)]) return r --- Technicalities..+-- Representation of SMTLib Programs+data SMTLibVersion = SMTLib1+ | SMTLib2+ deriving Eq++-- in between pre and post goes the refuted models+data SMTLibPgm = SMTLibPgm SMTLibVersion ( [(String, SW)] -- alias table+ , [String] -- pre: declarations.+ , [String]) -- post: formula+instance NFData SMTLibVersion+instance NFData SMTLibPgm++instance Show SMTLibPgm where+ show (SMTLibPgm _ (_, pre, post)) = intercalate "\n" $ pre ++ post++-- Other Technicalities.. instance NFData CW where rnf (CW x y z) = x `seq` y `seq` z `seq` () @@ -750,6 +781,7 @@ instance NFData ArrayContext instance NFData Pgm instance NFData SW+instance NFData Quantifier instance NFData SBVType instance NFData UnintKind instance NFData a => NFData (Cached a) where
Data/SBV/BitVectors/Model.hs view
@@ -22,7 +22,7 @@ module Data.SBV.BitVectors.Model ( Mergeable(..), EqSymbolic(..), OrdSymbolic(..), BVDivisible(..), Uninterpreted(..) , bitValue, setBitTo, allEqual, allDifferent, oneIf, blastBE, blastLE- , lsb, msb, SBVUF, sbvUFName, genFree, genFree_+ , lsb, msb, SBVUF, sbvUFName, genVar, genVar_, forall, forall_, exists, exists_ ) where @@ -91,11 +91,11 @@ -- Symbolic-Word class instances -genFree :: (Bool, Size) -> String -> Symbolic (SBV a)-genFree s = mkSymSBV s . Just+genVar :: Quantifier -> (Bool, Size) -> String -> Symbolic (SBV a)+genVar q s = mkSymSBV q s . Just -genFree_ :: (Bool, Size) -> Symbolic (SBV a)-genFree_ s = mkSymSBV s Nothing+genVar_ :: Quantifier -> (Bool, Size) -> Symbolic (SBV a)+genVar_ b s = mkSymSBV b s Nothing genLiteral :: Integral a => (Bool,Size) -> a -> SBV b genLiteral s = SBV s . Left . mkConstCW s@@ -104,56 +104,74 @@ genFromCW x = fromInteger (cwVal x) instance SymWord Bool where- free = genFree (False, 1)- free_ = genFree_ (False, 1)+ forall = genVar ALL (False, 1)+ forall_ = genVar_ ALL (False, 1)+ exists = genVar EX (False, 1)+ exists_ = genVar_ EX (False, 1) literal x = genLiteral (False, 1) (if x then (1::Integer) else 0) fromCW = cwToBool instance SymWord Word8 where- free = genFree (False, 8)- free_ = genFree_ (False, 8)+ forall = genVar ALL (False, 8)+ forall_ = genVar_ ALL (False, 8)+ exists = genVar EX (False, 8)+ exists_ = genVar_ EX (False, 8) literal = genLiteral (False, 8) fromCW = genFromCW instance SymWord Int8 where- free = genFree (True, 8)- free_ = genFree_ (True, 8)+ forall = genVar ALL (True, 8)+ forall_ = genVar_ ALL (True, 8)+ exists = genVar EX (True, 8)+ exists_ = genVar_ EX (True, 8) literal = genLiteral (True, 8) fromCW = genFromCW instance SymWord Word16 where- free = genFree (False, 16)- free_ = genFree_ (False, 16)+ forall = genVar ALL (False, 16)+ forall_ = genVar_ ALL (False, 16)+ exists = genVar EX (False, 16)+ exists_ = genVar_ EX (False, 16) literal = genLiteral (False, 16) fromCW = genFromCW instance SymWord Int16 where- free = genFree (True, 16)- free_ = genFree_ (True, 16)+ forall = genVar ALL (True, 16)+ forall_ = genVar_ ALL (True, 16)+ exists = genVar EX (True, 16)+ exists_ = genVar_ EX (True, 16) literal = genLiteral (True, 16) fromCW = genFromCW instance SymWord Word32 where- free = genFree (False, 32)- free_ = genFree_ (False, 32)+ forall = genVar ALL (False, 32)+ forall_ = genVar_ ALL (False, 32)+ exists = genVar EX (False, 32)+ exists_ = genVar_ EX (False, 32) literal = genLiteral (False, 32) fromCW = genFromCW instance SymWord Int32 where- free = genFree (True, 32)- free_ = genFree_ (True, 32)+ forall = genVar ALL (True, 32)+ forall_ = genVar_ ALL (True, 32)+ exists = genVar EX (True, 32)+ exists_ = genVar_ EX (True, 32) literal = genLiteral (True, 32) fromCW = genFromCW instance SymWord Word64 where- free = genFree (False, 64)- free_ = genFree_ (False, 64)+ forall = genVar ALL (False, 64)+ forall_ = genVar_ ALL (False, 64)+ exists = genVar EX (False, 64)+ exists_ = genVar_ EX (False, 64) literal = genLiteral (False, 64) fromCW = genFromCW instance SymWord Int64 where- free = genFree (True, 64)- free_ = genFree_ (True, 64)+ forall = genVar ALL (True, 64)+ forall_ = genVar_ ALL (True, 64)+ exists = genVar EX (True, 64)+ exists_ = genVar_ EX (True, 64) literal = genLiteral (True, 64) fromCW = genFromCW
Data/SBV/BitVectors/Polynomial.hs view
@@ -15,7 +15,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE PatternGuards #-} -module Data.SBV.BitVectors.Polynomial (Polynomial(..)) where+module Data.SBV.BitVectors.Polynomial (Polynomial(..), crc, crcBV) where import Data.Bits (Bits(..)) import Data.List (genericTake)@@ -34,7 +34,7 @@ -- -- for all @x@ (including @0@) ----- Minimal complete definiton: 'pMult', 'pDivMod', 'showPoly'+-- Minimal complete definiton: 'pMult', 'pDivMod', 'showPolynomial' class Bits a => Polynomial a where -- | Given bit-positions to be set, create a polynomial -- For instance@@ -62,24 +62,29 @@ pMod :: a -> a -> a -- | Division and modulus packed together pDivMod :: a -> a -> (a, a)- -- | Display a polynomial like a mathematician would (over the monomial @x@)+ -- | Display a polynomial like a mathematician would (over the monomial @x@), with a type showPoly :: a -> String+ -- | Display a polynomial like a mathematician would (over the monomial @x@), the first argument+ -- controls if the final type is shown as well.+ showPolynomial :: Bool -> a -> String - -- defaults.. Minumum complete definition: pMult, pDivMod, showPoly+ -- defaults.. Minumum complete definition: pMult, pDivMod, showPolynomial polynomial = foldr (flip setBit) 0 pAdd = xor pDiv x y = fst (pDivMod x y) pMod x y = snd (pDivMod x y)+ showPoly = showPolynomial False -instance Polynomial Word8 where {showPoly = sp; pMult = lift polyMult; pDivMod = liftC polyDivMod}-instance Polynomial Word16 where {showPoly = sp; pMult = lift polyMult; pDivMod = liftC polyDivMod}-instance Polynomial Word32 where {showPoly = sp; pMult = lift polyMult; pDivMod = liftC polyDivMod}-instance Polynomial Word64 where {showPoly = sp; pMult = lift polyMult; pDivMod = liftC polyDivMod}-instance Polynomial SWord8 where {showPoly = liftS sp; pMult = polyMult; pDivMod = polyDivMod}-instance Polynomial SWord16 where {showPoly = liftS sp; pMult = polyMult; pDivMod = polyDivMod}-instance Polynomial SWord32 where {showPoly = liftS sp; pMult = polyMult; pDivMod = polyDivMod}-instance Polynomial SWord64 where {showPoly = liftS sp; pMult = polyMult; pDivMod = polyDivMod} +instance Polynomial Word8 where {showPolynomial = sp; pMult = lift polyMult; pDivMod = liftC polyDivMod}+instance Polynomial Word16 where {showPolynomial = sp; pMult = lift polyMult; pDivMod = liftC polyDivMod}+instance Polynomial Word32 where {showPolynomial = sp; pMult = lift polyMult; pDivMod = liftC polyDivMod}+instance Polynomial Word64 where {showPolynomial = sp; pMult = lift polyMult; pDivMod = liftC polyDivMod}+instance Polynomial SWord8 where {showPolynomial b = liftS (sp b); pMult = polyMult; pDivMod = polyDivMod}+instance Polynomial SWord16 where {showPolynomial b = liftS (sp b); pMult = polyMult; pDivMod = polyDivMod}+instance Polynomial SWord32 where {showPolynomial b = liftS (sp b); pMult = polyMult; pDivMod = polyDivMod}+instance Polynomial SWord64 where {showPolynomial b = liftS (sp b); pMult = polyMult; pDivMod = polyDivMod}+ lift :: SymWord a => ((SBV a, SBV a, [Int]) -> SBV a) -> (a, a, [Int]) -> a lift f (x, y, z) = fromJust $ unliteral $ f (literal x, literal y, z) liftC :: SymWord a => (SBV a -> SBV a -> (SBV a, SBV a)) -> a -> a -> (a, a)@@ -90,11 +95,12 @@ | True = show s -- | Pretty print as a polynomial-sp :: Bits a => a -> String-sp a- | null cs = "0" ++ t+sp :: Bits a => Bool -> a -> String+sp st a+ | null cs = '0' : t | True = foldr (\x y -> sh x ++ " + " ++ y) (sh (last cs)) (init cs) ++ t- where t = " :: GF(2^" ++ show n ++ ")"+ where t | st = " :: GF(2^" ++ show n ++ ")"+ | True = "" n = bitSize a is = [n-1, n-2 .. 0] cs = map fst $ filter snd $ zip is (map (testBit a) is)@@ -171,3 +177,50 @@ where q = xs `idx` i xs' = ites q (xs `addPoly` ys') xs (qs, rs) = divx (n-1) (i-1) xs' (tail ys')++-- | Compute CRCs over bit-vectors. The call @crcBV n m p@ computes+-- the CRC of the message @m@ with respect to polynomial @p@. The+-- inputs are assumed to be blasted big-endian. The number+-- @n@ specifies how many bits of CRC is needed. Note that @n@+-- is actually the degree of the polynomial @p@, and thus it seems+-- redundant to pass it in. However, in a typical proof context,+-- the polynomial can be symbolic, so we cannot compute the degree+-- easily. While this can be worked-around by generating code that+-- accounts for all possible degrees, the resulting code would+-- be unnecessarily big and complicated, and much harder to reason+-- with. (Also note that a CRC is just the remainder from the+-- polynomial division, but this routine is much faster in practice.)+--+-- NB. The @n@th bit of the polynomial @p@ /must/ be set for the CRC+-- to be computed correctly. Note that the polynomial argument 'p' will+-- not even have this bit present most of the time, as it will typically+-- contain bits @0@ through @n-1@ as usual in the CRC literature. The higher+-- order @n@th bit is simply assumed to be set, as it does not make+-- sense to use a polynomial of a lesser degree. This is usually not a problem+-- since CRC polynomials are designed and expressed this way.+--+-- NB. The literature on CRC's has many variants on how CRC's are computed.+-- We follow the painless guide (<http://www.ross.net/crc/download/crc_v3.txt>)+-- and compute the CRC as follows:+--+-- * Extend the message 'm' by adding 'n' 0 bits on the right+--+-- * Divide the polynomial thus obtained by the 'p'+--+-- * The remainder is the CRC value.+--+-- There are many variants on final XOR's, reversed polynomials etc., so+-- it is essential to double check you use the correct /algorithm/.+crcBV :: Int -> [SBool] -> [SBool] -> [SBool]+crcBV n m p = take n $ go (replicate n false) (m ++ replicate n false)+ where mask = drop (length p - n) p+ go c [] = c+ go c (b:bs) = go next bs+ where c' = drop 1 c ++ [b]+ next = ite (head c) (zipWith (<+>) c' mask) c'++-- | Compute CRC's over polynomials, i.e., symbolic words. The first+-- 'Int' argument plays the same role as the one in the 'crcBV' function.+crc :: (FromBits (SBV a), FromBits (SBV b), Bits a, Bits b, SymWord a, SymWord b) => Int -> SBV a -> SBV b -> SBV b+crc n m p = fromBitsBE $ replicate (sz - n) false ++ crcBV n (blastBE m) (blastBE p)+ where sz = sizeOf p
Data/SBV/BitVectors/PrettyNum.hs view
@@ -12,7 +12,6 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeSynonymInstances #-}-{-# LANGUAGE PatternGuards #-} module Data.SBV.BitVectors.PrettyNum (PrettyNum(..), readBin, shex, sbin) where @@ -81,7 +80,7 @@ shex :: (Integral a) => Bool -> Bool -> (Bool, Size) -> a -> String shex shType shPre (signed, size) a | a < 0- = "-" ++ pre ++ pad l (s16 (abs ((fromIntegral a) :: Integer))) ++ t+ = "-" ++ pre ++ pad l (s16 (abs (fromIntegral a :: Integer))) ++ t | True = pre ++ pad l (s16 a) ++ t where t | shType = " :: " ++ (if signed then "Int" else "Word") ++ show size@@ -93,7 +92,7 @@ sbin :: (Integral a) => Bool -> Bool -> (Bool, Size) -> a -> String sbin shType shPre (signed,size) a | a < 0- = "-" ++ pre ++ pad size (s2 (abs ((fromIntegral a) :: Integer))) ++ t+ = "-" ++ pre ++ pad size (s2 (abs (fromIntegral a :: Integer))) ++ t | True = pre ++ pad size (s2 a) ++ t where t | shType = " :: " ++ (if signed then "Int" else "Word") ++ show size
Data/SBV/BitVectors/STree.hs view
@@ -11,10 +11,10 @@ -- time access to elements. Both reads and writes are supported. ----------------------------------------------------------------------------- -{-# LANGUAGE BangPatterns #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-} module Data.SBV.BitVectors.STree (STree, readSTree, writeSTree, mkSTree) where @@ -40,7 +40,7 @@ instance (SymWord e, Mergeable (SBV e)) => Mergeable (STree i e) where symbolicMerge b (SLeaf i) (SLeaf j) = SLeaf (ite b i j) symbolicMerge b (SBin l r) (SBin l' r') = SBin (ite b l l') (ite b r r')- symbolicMerge _ _ _ = error $ "SBV.STree.symbolicMerge: Impossible happened while merging states"+ symbolicMerge _ _ _ = error "SBV.STree.symbolicMerge: Impossible happened while merging states" -- | Reading a value. We bit-blast the index and descend down the full tree -- according to bit-values.@@ -63,8 +63,8 @@ mkSTree ivals | reqd /= given = error $ "SBV.STree.mkSTree: Required " ++ show reqd ++ " elements, received: " ++ show given | True = go ivals- where reqd = 2 ^ (sizeOf (undefined :: i))+ where reqd = 2 ^ sizeOf (undefined :: i) given = length ivals- go [] = error $ "SBV.STree.mkSTree: Impossible happened, ran out of elements"+ go [] = error "SBV.STree.mkSTree: Impossible happened, ran out of elements" go [l] = SLeaf l go ns = let (l, r) = splitAt (length ns `div` 2) ns in SBin (go l) (go r)
Data/SBV/BitVectors/SignCast.hs view
@@ -15,6 +15,7 @@ {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE PatternGuards #-}+{-# LANGUAGE FlexibleInstances #-} module Data.SBV.BitVectors.SignCast (SignCast(..)) where
Data/SBV/Compilers/C.hs view
@@ -15,6 +15,7 @@ module Data.SBV.Compilers.C(compileToC, compileToCLib, compileToC', compileToCLib') where import Data.Char (isSpace)+import Data.List (nub) import Data.Maybe (isJust) import qualified Data.Foldable as F (toList) import Text.PrettyPrint.HughesPJ@@ -45,7 +46,7 @@ -- | Lower level version of 'compileToC', producing a 'CgPgmBundle' compileToC' :: String -> SBVCodeGen () -> IO CgPgmBundle-compileToC' nm f = do rands <- newStdGen >>= return . randoms+compileToC' nm f = do rands <- randoms `fmap` newStdGen codeGen SBVToC (defaultCgConfig { cgDriverVals = rands }) nm f -- | Create code to generate a library archive (.a) from given symbolic functions. Useful when generating code@@ -84,22 +85,32 @@ tbd :: String -> a tbd msg = error $ "SBV->C: Not yet supported: " ++ msg -cgen :: Bool -> [Integer] -> String -> CgState -> Result -> CgPgmBundle-cgen rtc randVals nm st sbvProg = CgPgmBundle- [ ("Makefile", (CgMakefile, [genMake nm nmd]))- , (nm ++ ".h", (CgHeader [sig], [genHeader nm [sig]]))- , (nmd ++ ".c", (CgDriver, genDriver randVals nm ins outs mbRet))- , (nm ++ ".c", (CgSource, genCProg rtc nm sig sbvProg ins outs mbRet))- ]- where nmd = nm ++ "_driver"- sig = pprCFunHeader nm ins outs mbRet+cgen :: CgConfig -> String -> CgState -> Result -> CgPgmBundle+cgen cfg nm st sbvProg = CgPgmBundle $ filt [ ("Makefile", (CgMakefile flags, [genMake driver nm nmd flags]))+ , (nm ++ ".h", (CgHeader [sig], [genHeader nm [sig] extProtos]))+ , (nmd ++ ".c", (CgDriver, genDriver randVals nm ins outs mbRet))+ , (nm ++ ".c", (CgSource, genCProg rtc nm sig sbvProg ins outs mbRet extDecls))+ ]+ where rtc = cgRTC cfg+ randVals = cgDriverVals cfg+ driver = cgGenDriver cfg+ filt xs = if driver then xs else filter (not . isCgDriver . fst . snd) xs+ nmd = nm ++ "_driver"+ sig = pprCFunHeader nm ins outs mbRet ins = cgInputs st outs = cgOutputs st mbRet = case cgReturns st of [] -> Nothing [CgAtomic o] -> Just o- [CgArray _] -> tbd $ "Non-atomic return values"- _ -> tbd $ "Multiple return values"+ [CgArray _] -> tbd "Non-atomic return values"+ _ -> tbd "Multiple return values"+ extProtos = case cgPrototypes st of+ [] -> empty+ xs -> vcat $ text "/* User given prototypes: */" : map text xs+ extDecls = case cgDecls st of+ [] -> empty+ xs -> vcat $ text "/* User given declarations: */" : map text xs ++ [text ""]+ flags = cgLDFlags st -- | Pretty print a functions type. If there is only one output, we compile it -- as a function that returns that value. Otherwise, we compile it as a void function@@ -112,16 +123,16 @@ mkParam, mkPParam :: (String, CgVal) -> Doc mkParam (n, CgAtomic sw) = let sgsz = (hasSign sw, sizeOf sw) in pprCWord True sgsz <+> text n-mkParam (_, CgArray []) = die $ "mkParam: CgArray with no elements!"+mkParam (_, CgArray []) = die "mkParam: CgArray with no elements!" mkParam (n, CgArray (sw:_)) = let sgsz = (hasSign sw, sizeOf sw) in pprCWord True sgsz <+> text "*" <> text n mkPParam (n, CgAtomic sw) = let sgsz = (hasSign sw, sizeOf sw) in pprCWord False sgsz <+> text "*" <> text n-mkPParam (_, CgArray []) = die $ "mPkParam: CgArray with no elements!"+mkPParam (_, CgArray []) = die "mPkParam: CgArray with no elements!" mkPParam (n, CgArray (sw:_)) = let sgsz = (hasSign sw, sizeOf sw) in pprCWord False sgsz <+> text "*" <> text n -- | Renders as "const SWord8 s0", etc. the first parameter is the width of the typefield declSW :: Int -> SW -> Doc declSW w sw@(SW sgsz _) = text "const" <+> pad (showCType sgsz) <+> text (show sw)- where pad s = text $ s ++ take (w - length s) (repeat ' ')+ where pad s = text $ s ++ replicate (w - length s) ' ' -- | Renders as "s0", etc, or the corresponding constant showSW :: [(SW, CW)] -> SW -> Doc@@ -177,35 +188,40 @@ showConst :: CW -> Doc showConst cw = mkConst (cwVal cw) (hasSign cw, sizeOf cw) --- | Generate a makefile-genMake :: String -> String -> Doc-genMake fn dn =- text "# Makefile for" <+> nm <> text ". Automatically generated by SBV. Do not edit!"- $$ text ""- $$ text "# include any user-defined .mk file in the current directory."- $$ text "-include *.mk"- $$ text ""- $$ text "CC=gcc"- $$ text "CCFLAGS?=-Wall -O3 -DNDEBUG -fomit-frame-pointer"- $$ text ""- $$ text "all:" <+> nmd- $$ text ""- $$ nmo <> text (": " ++ ppSameLine (hsep [nmc, nmh]))- $$ text "\t${CC} ${CCFLAGS}" <+> text "-c $< -o $@"- $$ text ""- $$ nmdo <> text ":" <+> nmdc- $$ text "\t${CC} ${CCFLAGS}" <+> text "-c $< -o $@"- $$ text ""- $$ nmd <> text (": " ++ ppSameLine (hsep [nmo, nmdo]))- $$ text "\t${CC} ${CCFLAGS}" <+> text "$^ -o $@"- $$ text ""- $$ text "clean:"- $$ text "\trm -f *.o"- $$ text ""- $$ text "veryclean: clean"- $$ text "\trm -f" <+> nmd- $$ text ""- where nm = text fn+-- | Generate a makefile. The first argument is True if we have a driver.+genMake :: Bool -> String -> String -> [String] -> Doc+genMake ifdr fn dn ldFlags = foldr1 ($$) [l | (True, l) <- lns]+ where ifld = not (null ldFlags)+ ld | ifld = text "${LDFLAGS}"+ | True = empty+ lns = [ (True, text "# Makefile for" <+> nm <> text ". Automatically generated by SBV. Do not edit!")+ , (True, text "")+ , (True, text "# include any user-defined .mk file in the current directory.")+ , (True, text "-include *.mk")+ , (True, text "")+ , (True, text "CC=gcc")+ , (True, text "CCFLAGS?=-Wall -O3 -DNDEBUG -fomit-frame-pointer")+ , (ifld, text "LDFLAGS?=" <> text (unwords ldFlags))+ , (True, text "")+ , (ifdr, text "all:" <+> nmd)+ , (ifdr, text "")+ , (True, nmo <> text (": " ++ ppSameLine (hsep [nmc, nmh])))+ , (True, text "\t${CC} ${CCFLAGS}" <+> text "-c $< -o $@")+ , (True, text "")+ , (ifdr, nmdo <> text ":" <+> nmdc)+ , (ifdr, text "\t${CC} ${CCFLAGS}" <+> text "-c $< -o $@")+ , (ifdr, text "")+ , (ifdr, nmd <> text (": " ++ ppSameLine (hsep [nmo, nmdo])))+ , (ifdr, text "\t${CC} ${CCFLAGS}" <+> text "$^ -o $@" <+> ld)+ , (ifdr, text "")+ , (True, text "clean:")+ , (True, text "\trm -f *.o")+ , (True, text "")+ , (ifdr, text "veryclean: clean")+ , (ifdr, text "\trm -f" <+> nmd)+ , (ifdr, text "")+ ]+ nm = text fn nmd = text dn nmh = nm <> text ".h" nmc = nm <> text ".c"@@ -214,8 +230,8 @@ nmdo = nmd <> text ".o" -- | Generate the header-genHeader :: String -> [Doc] -> Doc-genHeader fn sigs =+genHeader :: String -> [Doc] -> Doc -> Doc+genHeader fn sigs protos = text "/* Header file for" <+> nm <> text ". Automatically generated by SBV. Do not edit! */" $$ text "" $$ text "#ifndef" <+> tag@@ -240,6 +256,7 @@ $$ text ("/* Entry point prototype" ++ plu ++ ": */") $$ vcat (map (<> semi) sigs) $$ text ""+ $$ protos $$ text "#endif /*" <+> tag <+> text "*/" $$ text "" where nm = text fn@@ -280,13 +297,13 @@ $$ text "" nm = text fn pairedInputs = matchRands (map abs randVals) inps- matchRands _ [] = []- matchRands [] _ = die $ "Run out of driver values!"- matchRands (r:rs) ((n, CgAtomic sw) : cs) = ([mkRVal sw r], n, CgAtomic sw) : matchRands rs cs- matchRands _ ((n, CgArray []) : _ ) = die $ "Unsupported empty array input " ++ show n- matchRands rs ((n, a@(CgArray sws@((sw:_)))) : cs)- | length frs /= l = die $ "Run out of driver values!"- | True = (map (mkRVal sw) frs, n, a) : matchRands srs cs+ matchRands _ [] = []+ matchRands [] _ = die "Run out of driver values!"+ matchRands (r:rs) ((n, CgAtomic sw) : cs) = ([mkRVal sw r], n, CgAtomic sw) : matchRands rs cs+ matchRands _ ((n, CgArray []) : _ ) = die $ "Unsupported empty array input " ++ show n+ matchRands rs ((n, a@(CgArray sws@(sw:_))) : cs)+ | length frs /= l = die "Run out of driver values!"+ | True = (map (mkRVal sw) frs, n, a) : matchRands srs cs where l = length sws (frs, srs) = splitAt l rs mkRVal sw r = mkConst ival sgsz@@ -327,7 +344,7 @@ <> text "\\n") <> comma <+> text n) <> semi display (n, CgArray []) = die $ "Unsupported empty array value for " ++ show n display (n, CgArray sws@(sw:_)) = text "int" <+> nctr <> semi- $$ text "for(" <> nctr <+> text "= 0; " <+> nctr <+> text "<" <+> int (length sws) <+> text "; ++" <> nctr <> text ")"+ $$ text "for(" <> nctr <+> text "= 0;" <+> nctr <+> text "<" <+> int (length sws) <+> text "; ++" <> nctr <> text ")" $$ nest 2 (text "printf" <> parens (printQuotes (text " " <+> entrySpec <+> text "=" <+> spec <> text "\\n") <> comma <+> nctr <+> comma <> entry) <> semi) where nctr = text n <> text "_ctr"@@ -336,30 +353,29 @@ spec = specifier (hasSign sw, sizeOf sw) -- | Generate the C program-genCProg :: Bool -> String -> Doc -> Result -> [(String, CgVal)] -> [(String, CgVal)] -> Maybe SW -> [Doc]-genCProg rtc fn proto (Result _ preConsts tbls arrs uints axms asgns _) inVars outVars mbRet- | not (null arrs) = tbd "User specified arrays"- | not (null uints) = tbd "Uninterpreted constants"- | not (null axms) = tbd "User given axioms"- | True- = [pre, header, post]+genCProg :: Bool -> String -> Doc -> Result -> [(String, CgVal)] -> [(String, CgVal)] -> Maybe SW -> Doc -> [Doc]+genCProg rtc fn proto (Result ins preConsts tbls arrs _ _ asgns _) inVars outVars mbRet extDecls+ | not (null arrs) = tbd "User specified arrays"+ | needsExistentials (map fst ins) = error "SBV->C: Cannot compile functions with existentially quantified variables."+ | True = [pre, header, post] where pre = text "/* File:" <+> doubleQuotes (nm <> text ".c") <> text ". Automatically generated by SBV. Do not edit! */" $$ text "" $$ text "#include <inttypes.h>" $$ text "#include <stdint.h>" header = text "#include" <+> doubleQuotes (nm <> text ".h")- post = text ""- $$ proto- $$ text "{"- $$ text ""- $$ nest 2 ( vcat (concatMap (genIO True) inVars)- $$ vcat (merge (map genTbl tbls) (map genAsgn assignments))- $$ sepIf (not (null assignments) || not (null tbls))- $$ vcat (concatMap (genIO False) outVars)- $$ maybe empty mkRet mbRet- )- $$ text "}"- $$ text ""+ post = text ""+ $$ extDecls+ $$ proto+ $$ text "{"+ $$ text ""+ $$ nest 2 ( vcat (concatMap (genIO True) inVars)+ $$ vcat (merge (map genTbl tbls) (map genAsgn assignments))+ $$ sepIf (not (null assignments) || not (null tbls))+ $$ vcat (concatMap (genIO False) outVars)+ $$ maybe empty mkRet mbRet+ )+ $$ text "}"+ $$ text "" nm = text fn assignments = F.toList asgns typeWidth = getMax 0 [len (hasSign s, sizeOf s) | (s, _) <- assignments]@@ -406,16 +422,23 @@ , (LessThan, "<"), (GreaterThan, ">"), (LessEq, "<="), (GreaterEq, ">=") , (And, "&"), (Or, "|"), (XOr, "^") ]- p (ArrRead _) _ = tbd $ "User specified arrays (ArrRead)"- p (ArrEq _ _) _ = tbd $ "User specified arrays (ArrEq)"- p (Uninterpreted s) _ = tbd $ "Uninterpreted constants (" ++ show s ++ ")"- p (Extract i j) [a] = extract i j (let s = head opArgs in (hasSign s, sizeOf s)) a- p Join [a, b] = join (let (s1 : s2 : _) = opArgs in ((hasSign s1, sizeOf s1), (hasSign s2, sizeOf s2), a, b))- p (Rol i) [a] = rotate True i a (let s = head opArgs in (hasSign s, sizeOf s))- p (Ror i) [a] = rotate False i a (let s = head opArgs in (hasSign s, sizeOf s))- p (Shl i) [a] = shift True i a (let s = head opArgs in (hasSign s, sizeOf s))- p (Shr i) [a] = shift False i a (let s = head opArgs in (hasSign s, sizeOf s))- p Not [a] = text "~" <> a+ p (ArrRead _) _ = tbd "User specified arrays (ArrRead)"+ p (ArrEq _ _) _ = tbd "User specified arrays (ArrEq)"+ p (Uninterpreted s) [] = text "/* Uninterpreted constant */" <+> text s+ p (Uninterpreted s) as = text "/* Uninterpreted function */" <+> text s <> parens (fsep (punctuate comma as))+ p (Extract i j) [a] = extract i j (let s = head opArgs in (hasSign s, sizeOf s)) a+ p Join [a, b] = join (let (s1 : s2 : _) = opArgs in ((hasSign s1, sizeOf s1), (hasSign s2, sizeOf s2), a, b))+ p (Rol i) [a] = rotate True i a (let s = head opArgs in (hasSign s, sizeOf s))+ p (Ror i) [a] = rotate False i a (let s = head opArgs in (hasSign s, sizeOf s))+ p (Shl i) [a] = shift True i a (let s = head opArgs in (hasSign s, sizeOf s))+ p (Shr i) [a] = shift False i a (let s = head opArgs in (hasSign s, sizeOf s))+ p Not [a]+ -- be careful about booleans, bitwise complement is not correct for them!+ | s == 1+ = parens (text "~" <> a) <+> text "&" <+> text "0x01U"+ | True+ = text "~" <> a+ where s = sizeOf (head opArgs) p Ite [a, b, c] = a <+> text "?" <+> b <+> text ":" <+> c p (LkUp (t, (as, at), _, len) ind def) [] | not rtc = lkUp -- ignore run-time-checks per user request@@ -429,8 +452,8 @@ checkLeft = index <+> text "< 0" checkRight = index <+> text ">=" <+> int len checkBoth = parens (checkLeft <+> text "||" <+> checkRight)- (needsCheckL, needsCheckR) | as = (True, (2::Integer)^(at-1)-1 >= (fromIntegral len))- | True = (False, (2::Integer)^(at) -1 >= (fromIntegral len))+ (needsCheckL, needsCheckR) | as = (True, (2::Integer)^(at-1)-1 >= fromIntegral len)+ | True = (False, (2::Integer)^at -1 >= fromIntegral len) -- Div/Rem should be careful on 0, in the SBV world x `div` 0 is 0, x `rem` 0 is x p Quot [a, b] = parens (b <+> text "== 0") <+> text "?" <+> text "0" <+> text ":" <+> parens (a <+> text "/" <+> b) p Rem [a, b] = parens (b <+> text "== 0") <+> text "?" <+> a <+> text ":" <+> parens (a <+> text "%" <+> b)@@ -458,11 +481,11 @@ | True = (">>", "<<") -- TBD: below we only support the values that SBV actually currently generates. -- we would need to add new ones if we generate others. (Check instances in Data/SBV/BitVectors/Splittable.hs).- extract 63 32 (False, 64) a = text "(SWord32)" <+> (parens (a <+> text ">> 32"))+ extract 63 32 (False, 64) a = text "(SWord32)" <+> parens (a <+> text ">> 32") extract 31 0 (False, 64) a = text "(SWord32)" <+> a- extract 31 16 (False, 32) a = text "(SWord16)" <+> (parens (a <+> text ">> 16"))+ extract 31 16 (False, 32) a = text "(SWord16)" <+> parens (a <+> text ">> 16") extract 15 0 (False, 32) a = text "(SWord16)" <+> a- extract 15 8 (False, 16) a = text "(SWord8)" <+> (parens (a <+> text ">> 8"))+ extract 15 8 (False, 16) a = text "(SWord8)" <+> parens (a <+> text ">> 8") extract 7 0 (False, 16) a = text "(SWord8)" <+> a -- the followings are used by sign-conversions. (Check instances in Data/SBV/BitVectors/SignCast.hs). extract 63 0 (False, 64) a = text "(SInt64)" <+> a@@ -475,9 +498,9 @@ extract 7 0 (True, 8) a = text "(SWord8)" <+> a extract i j (sg, sz) _ = tbd $ "extract with " ++ show (i, j, (sg, sz)) -- TBD: ditto here for join, just like extract above- join ((False, 8), (False, 8), a, b) = parens ((parens (text "(SWord16)" <+> a)) <+> text "<< 8") <+> text "|" <+> parens (text "(SWord16)" <+> b)- join ((False, 16), (False, 16), a, b) = parens ((parens (text "(SWord32)" <+> a)) <+> text "<< 16") <+> text "|" <+> parens (text "(SWord32)" <+> b)- join ((False, 32), (False, 32), a, b) = parens ((parens (text "(SWord64)" <+> a)) <+> text "<< 32") <+> text "|" <+> parens (text "(SWord64)" <+> b)+ join ((False, 8), (False, 8), a, b) = parens (parens (text "(SWord16)" <+> a) <+> text "<< 8") <+> text "|" <+> parens (text "(SWord16)" <+> b)+ join ((False, 16), (False, 16), a, b) = parens (parens (text "(SWord32)" <+> a) <+> text "<< 16") <+> text "|" <+> parens (text "(SWord32)" <+> b)+ join ((False, 32), (False, 32), a, b) = parens (parens (text "(SWord64)" <+> a) <+> text "<< 32") <+> text "|" <+> parens (text "(SWord64)" <+> b) join (sgsz1, sgsz2, _, _) = tbd $ "join with " ++ show (sgsz1, sgsz2) -- same as doubleQuotes, except we have to make sure there are no line breaks..@@ -498,54 +521,63 @@ align ds = map (text . pad) ss where ss = map render ds l = maximum (0 : map length ss)- pad s = take (l - length s) (repeat ' ') ++ s+ pad s = replicate (l - length s) ' ' ++ s -- | Merge a bunch of bundles to generate code for a library mergeToLib :: String -> [CgPgmBundle] -> CgPgmBundle-mergeToLib libName bundles = CgPgmBundle $ sources ++ [libHeader, libDriver, libMake]+mergeToLib libName bundles = CgPgmBundle $ sources ++ libHeader : [libDriver | anyDriver] ++ [libMake] where files = concat [fs | CgPgmBundle fs <- bundles] sigs = concat [ss | (_, (CgHeader ss, _)) <- files] drivers = [ds | (_, (CgDriver, ds)) <- files]+ anyDriver = not (null drivers)+ mkFlags = nub (concat [xs | (_, (CgMakefile xs, _)) <- files]) sources = [(f, (CgSource, [pre, libHInclude, post])) | (f, (CgSource, [pre, _, post])) <- files] sourceNms = map fst sources- libHeader = (libName ++ ".h", (CgHeader sigs, [genHeader libName sigs]))+ libHeader = (libName ++ ".h", (CgHeader sigs, [genHeader libName sigs empty])) libHInclude = text "#include" <+> text (show (libName ++ ".h"))- libMake = ("Makefile", (CgMakefile, [genLibMake libName sourceNms]))+ libMake = ("Makefile", (CgMakefile mkFlags, [genLibMake anyDriver libName sourceNms mkFlags])) libDriver = (libName ++ "_driver.c", (CgDriver, mergeDrivers libName libHInclude (zip (map takeBaseName sourceNms) drivers))) -- | Create a Makefile for the library-genLibMake :: String -> [String] -> Doc-genLibMake libName fs =- text "# Makefile for" <+> nm <> text ". Automatically generated by SBV. Do not edit!"- $$ text ""- $$ text "# include any user-defined .mk file in the current directory."- $$ text "-include *.mk"- $$ text ""- $$ text "CC=gcc"- $$ text "CCFLAGS?=-Wall -O3 -DNDEBUG -fomit-frame-pointer"- $$ text "AR=ar"- $$ text "ARFLAGS=cr"- $$ text ""- $$ text ("all: " ++ unwords [liba, libd])- $$ text ""- $$ text liba <> text (": " ++ unwords os)- $$ text "\t${AR} ${ARFLAGS} $@ $^"- $$ text ""- $$ text libd <> text (": " ++ unwords [libd ++ ".c", libh])- $$ text ("\t${CC} ${CCFLAGS} $< -o $@ " ++ liba)- $$ text ""- $$ vcat (zipWith mkObj os fs)- $$ text "clean:"- $$ text "\trm -f *.o"- $$ text ""- $$ text "veryclean: clean"- $$ text "\trm -f" <+> text (unwords [liba, libd])- $$ text ""- where nm = text libName+genLibMake :: Bool -> String -> [String] -> [String] -> Doc+genLibMake ifdr libName fs ldFlags = foldr1 ($$) [l | (True, l) <- lns]+ where ifld = not (null ldFlags)+ ld | ifld = text "${LDFLAGS}"+ | True = empty+ lns = [ (True, text "# Makefile for" <+> nm <> text ". Automatically generated by SBV. Do not edit!")+ , (True, text "")+ , (True, text "# include any user-defined .mk file in the current directory.")+ , (True, text "-include *.mk")+ , (True, text "")+ , (True, text "CC=gcc")+ , (True, text "CCFLAGS?=-Wall -O3 -DNDEBUG -fomit-frame-pointer")+ , (ifld, text "LDFLAGS?=" <> text (unwords ldFlags))+ , (True, text "AR=ar")+ , (True, text "ARFLAGS=cr")+ , (True, text "")+ , (not ifdr, text ("all: " ++ liba))+ , (ifdr, text ("all: " ++ unwords [liba, libd]))+ , (True, text "")+ , (True, text liba <> text (": " ++ unwords os))+ , (True, text "\t${AR} ${ARFLAGS} $@ $^")+ , (True, text "")+ , (ifdr, text libd <> text (": " ++ unwords [libd ++ ".c", libh]))+ , (ifdr, text ("\t${CC} ${CCFLAGS} $< -o $@ " ++ liba) <+> ld)+ , (ifdr, text "")+ , (True, vcat (zipWith mkObj os fs))+ , (True, text "clean:")+ , (True, text "\trm -f *.o")+ , (True, text "")+ , (True, text "veryclean: clean")+ , (not ifdr, text "\trm -f" <+> text liba)+ , (ifdr, text "\trm -f" <+> text (unwords [liba, libd]))+ , (True, text "")+ ]+ nm = text libName liba = libName ++ ".a" libh = libName ++ ".h" libd = libName ++ "_driver"- os = map (flip replaceExtension ".o") fs+ os = map (`replaceExtension` ".o") fs mkObj o f = text o <> text (": " ++ unwords [f, libh]) $$ text "\t${CC} ${CCFLAGS} -c $< -o $@" $$ text ""@@ -579,5 +611,5 @@ $$ text "" where tag = "** Driver run for " ++ f ++ ":" ptag = "printf(\"" ++ tag ++ "\\n\");"- lsep = take (length tag) (repeat '=')+ lsep = replicate (length tag) '=' psep = "printf(\"" ++ lsep ++ "\\n\");"
Data/SBV/Compilers/CodeGen.hs view
@@ -18,7 +18,7 @@ import Control.Monad.Trans import Control.Monad.State.Lazy import Data.Char (toLower)-import Data.List (nub, isPrefixOf, intersperse, (\\))+import Data.List (nub, isPrefixOf, intercalate, (\\)) import System.Directory (createDirectory, doesDirectoryExist, doesFileExist) import System.FilePath ((</>)) import Text.PrettyPrint.HughesPJ (Doc, render, vcat)@@ -28,17 +28,18 @@ -- | Abstract over code generation for different languages class CgTarget a where targetName :: a -> String- translate :: a -> Bool -> [Integer] -> String -> CgState -> Result -> CgPgmBundle+ translate :: a -> CgConfig -> String -> CgState -> Result -> CgPgmBundle -- | Options for code-generation. data CgConfig = CgConfig { cgRTC :: Bool -- ^ If 'True', perform run-time-checks for index-out-of-bounds or shifting-by-large values etc. , cgDriverVals :: [Integer] -- ^ Values to use for the driver program generated, useful for generating non-random drivers.+ , cgGenDriver :: Bool -- ^ If 'True', will generate a driver program } -- | Default options for code generation. The run-time checks are turned-off, and the driver values are completely random. defaultCgConfig :: CgConfig-defaultCgConfig = CgConfig { cgRTC = False, cgDriverVals = [] }+defaultCgConfig = CgConfig { cgRTC = False, cgDriverVals = [], cgGenDriver = True } -- | Abstraction of target language values data CgVal = CgAtomic SW@@ -48,6 +49,9 @@ cgInputs :: [(String, CgVal)] , cgOutputs :: [(String, CgVal)] , cgReturns :: [CgVal]+ , cgPrototypes :: [String] -- extra stuff that goes into the header+ , cgDecls :: [String] -- extra stuff that goes into the top of the file+ , cgLDFlags :: [String] -- extra options that go to the linker , cgFinalConfig :: CgConfig } @@ -56,6 +60,9 @@ cgInputs = [] , cgOutputs = [] , cgReturns = []+ , cgPrototypes = []+ , cgDecls = []+ , cgLDFlags = [] , cgFinalConfig = defaultCgConfig } @@ -73,17 +80,38 @@ cgSBVToSW :: SBV a -> SBVCodeGen SW cgSBVToSW = liftSymbolic . sbvToSymSW --- | Sets RTC (run-time-checks) for index-out-of-bounds, shift-with-large value etc. on/off.+-- | Sets RTC (run-time-checks) for index-out-of-bounds, shift-with-large value etc. on/off. Default: 'False'. cgPerformRTCs :: Bool -> SBVCodeGen () cgPerformRTCs b = modify (\s -> s { cgFinalConfig = (cgFinalConfig s) { cgRTC = b } }) --- | Sets driver program run time values, useful for generating programs with fixed drivers for testing.+-- | Should we generate a driver program? Default: 'True'. When a library is generated, then it will have+-- a driver if any of the contituent functions has a driver. (See 'compileToCLib'.)+cgGenerateDriver :: Bool -> SBVCodeGen ()+cgGenerateDriver b = modify (\s -> s { cgFinalConfig = (cgFinalConfig s) { cgGenDriver = b } })++-- | Sets driver program run time values, useful for generating programs with fixed drivers for testing. Default: None, i.e., use random values. cgSetDriverValues :: [Integer] -> SBVCodeGen () cgSetDriverValues vs = modify (\s -> s { cgFinalConfig = (cgFinalConfig s) { cgDriverVals = vs } }) +-- | Adds the given lines to the header file generated, useful for generating programs with uninterpreted functions.+cgAddPrototype :: [String] -> SBVCodeGen ()+cgAddPrototype ss = modify (\s -> let old = cgPrototypes s+ new = if null old then ss else old ++ [""] ++ ss+ in s { cgPrototypes = new })++-- | Adds the given lines to the program file generated, useful for generating programs with uninterpreted functions.+cgAddDecl :: [String] -> SBVCodeGen ()+cgAddDecl ss = modify (\s -> let old = cgDecls s+ new = if null old then ss else old ++ [""] ++ ss+ in s { cgDecls = new })++-- | Adds the given words to the compiler options in the generated Makefile, useful for linking extra stuff in+cgAddLDFlags :: [String] -> SBVCodeGen ()+cgAddLDFlags ss = modify (\s -> s { cgLDFlags = cgLDFlags s ++ ss })+ -- | Creates an atomic input in the generated code. cgInput :: (HasSignAndSize a, SymWord a) => String -> SBVCodeGen (SBV a)-cgInput nm = do r <- liftSymbolic free_+cgInput nm = do r <- liftSymbolic forall_ sw <- cgSBVToSW r modify (\s -> s { cgInputs = (nm, CgAtomic sw) : cgInputs s }) return r@@ -92,7 +120,7 @@ cgInputArr :: (HasSignAndSize a, SymWord a) => Int -> String -> SBVCodeGen [SBV a] cgInputArr sz nm | sz < 1 = error $ "SBV.cgInputArr: Array inputs must have at least one element, given " ++ show sz ++ " for " ++ show nm- | True = do rs <- liftSymbolic $ (mapM (const free_) [1..sz])+ | True = do rs <- liftSymbolic $ mapM (const forall_) [1..sz] sws <- mapM cgSBVToSW rs modify (\s -> s { cgInputs = (nm, CgArray sws) : cgInputs s }) return rs@@ -131,13 +159,17 @@ newtype CgPgmBundle = CgPgmBundle [(FilePath, (CgPgmKind, [Doc]))] -- | Different kinds of "files" we can produce. Currently this is quite "C" specific.-data CgPgmKind = CgMakefile+data CgPgmKind = CgMakefile [String] | CgHeader [Doc] | CgSource | CgDriver +isCgDriver :: CgPgmKind -> Bool+isCgDriver CgDriver = True+isCgDriver _ = False+ instance Show CgPgmBundle where- show (CgPgmBundle fs) = concat $ intersperse "\n" $ map showFile fs+ show (CgPgmBundle fs) = intercalate "\n" $ map showFile fs showFile :: (FilePath, (CgPgmKind, [Doc])) -> String showFile (f, (_, ds)) = "== BEGIN: " ++ show f ++ " ================\n"@@ -152,22 +184,21 @@ } allNamedVars = map fst (cgInputs st ++ cgOutputs st) dupNames = allNamedVars \\ nub allNamedVars- when (not (null dupNames)) $ do+ unless (null dupNames) $ error $ "SBV.codeGen: " ++ show nm ++ " has following argument names duplicated: " ++ unwords dupNames- let finalCfg = cgFinalConfig st- return $ translate l (cgRTC finalCfg) (cgDriverVals finalCfg) nm st res+ return $ translate l (cgFinalConfig st) nm st res renderCgPgmBundle :: Maybe FilePath -> CgPgmBundle -> IO ()-renderCgPgmBundle Nothing bundle = putStrLn $ show bundle+renderCgPgmBundle Nothing bundle = print bundle renderCgPgmBundle (Just dirName) (CgPgmBundle files) = do b <- doesDirectoryExist dirName- when (not b) $ do putStrLn $ "Creating directory " ++ show dirName ++ ".."- createDirectory dirName+ unless b $ do putStrLn $ "Creating directory " ++ show dirName ++ ".."+ createDirectory dirName dups <- filterM (\fn -> doesFileExist (dirName </> fn)) (map fst files) goOn <- case dups of [] -> return True _ -> do putStrLn $ "Code generation would override the following " ++ (if length dups == 1 then "file:" else "files:")- mapM_ (\fn -> putStrLn ("\t" ++ fn)) dups+ mapM_ (\fn -> putStrLn ('\t' : fn)) dups putStr "Continue? [yn] " resp <- getLine return $ map toLower resp `isPrefixOf` "yes"
Data/SBV/Examples/Basics/BasicTests.hs view
@@ -26,16 +26,16 @@ y = literal (2 :: Word8) output $ f x y test2 f = runSymbolic $ do let x = literal (3 :: Word8)- y :: SWord8 <- free "y"+ y :: SWord8 <- forall "y" output $ f x y-test3 f = runSymbolic $ do x :: SWord8 <- free "x"- y :: SWord8 <- free "y"+test3 f = runSymbolic $ do x :: SWord8 <- forall "x"+ y :: SWord8 <- forall "y" output $ f x y-test4 f = runSymbolic $ do x :: SWord8 <- free "x"+test4 f = runSymbolic $ do x :: SWord8 <- forall "x" output $ f x x-test5 f = runSymbolic $ do x :: SWord8 <- free "x"+test5 f = runSymbolic $ do x :: SWord8 <- forall "x" let r = f x x- q :: SWord8 <- free "q"+ q :: SWord8 <- forall "q" _ <- output q output r
Data/SBV/Examples/Basics/Higher.hs view
@@ -39,7 +39,7 @@ t :: IO [ThmResult]-t = sequence $ [+t = sequence [ f11 === f11 , f12 === f12 , f21 === f21
Data/SBV/Examples/Basics/Index.hs view
@@ -17,10 +17,10 @@ -- prove that the "select" primitive is working correctly test1 :: Int -> IO Bool test1 n = isTheorem $ do- elts <- mkFreeVars n- err <- free_- ind <- free_- ind2 <- free_+ elts <- mkForallVars n+ err <- forall_+ ind <- forall_+ ind2 <- forall_ let r1 = (select :: [SWord8] -> SWord8 -> SInt8 -> SWord8) elts err ind r2 = (select :: [SWord8] -> SWord8 -> SWord8 -> SWord8) elts err ind2 r3 = slowSearch elts err ind@@ -32,14 +32,14 @@ test2 :: Int -> IO Bool test2 n = isTheorem $ do- elts1 <- mkFreeVars n- elts2 <- mkFreeVars n+ elts1 <- mkForallVars n+ elts2 <- mkForallVars n let elts = zip elts1 elts2- err1 <- free_- err2 <- free_+ err1 <- forall_+ err2 <- forall_ let err = (err1, err2)- ind <- free_- ind2 <- free_+ ind <- forall_+ ind2 <- forall_ let r1 = (select :: [(SWord8, SWord8)] -> (SWord8, SWord8) -> SInt8 -> (SWord8, SWord8)) elts err ind r2 = (select :: [(SWord8, SWord8)] -> (SWord8, SWord8) -> SWord8 -> (SWord8, SWord8)) elts err ind2 r3 = slowSearch elts err ind@@ -51,11 +51,11 @@ test3 :: Int -> IO Bool test3 n = isTheorem $ do- eltsI <- mkFreeVars n+ eltsI <- mkForallVars n let elts = map Left eltsI- errI <- free_+ errI <- forall_ let err = Left errI- ind <- free_+ ind <- forall_ let r1 = (select :: [Either SWord8 SWord8] -> Either SWord8 SWord8 -> SInt8 -> Either SWord8 SWord8) elts err ind r2 = slowSearch elts err ind return $ r1 .== r2
Data/SBV/Examples/Basics/ProofTests.hs view
@@ -40,5 +40,9 @@ print =<< prove f1eqf3 -- No print =<< prove f3eqf4 -- QED print =<< prove f1Single -- QED- print =<< sat f1eqf2 -- yes. any output ok- print =<< sat f1eqf3 -- yes, 0;0+ print =<< sat (do x <- exists "x"+ y <- exists "y"+ return $ f1 x y .== f2 x (y :: SWord8)) -- yes, any output OK+ print =<< sat (do x <- exists "x"+ y <- exists "y"+ return $ f1 x y .== f3 x (y:: SWord8)) -- yes, 0;0
Data/SBV/Examples/Basics/QRem.hs view
@@ -22,5 +22,5 @@ where (a, b) = x `bvQuotRem` y check :: IO ()-check = do print =<< prove (qrem :: SWord8 -> SWord8 -> SBool)- -- print =<< prove (qrem :: SWord16 -> SWord16 -> SBool) -- takes too long!+check = print =<< prove (qrem :: SWord8 -> SWord8 -> SBool)+ -- print =<< prove (qrem :: SWord16 -> SWord16 -> SBool) -- takes too long!
Data/SBV/Examples/BitPrecise/Legato.hs view
@@ -121,7 +121,7 @@ checkOverflow :: SWord8 -> SWord8 -> SBool -> SBool checkOverflow x y c = s .< x ||| s .< y ||| s' .< s where s = x + y- s' = s + (ite c 1 0)+ s' = s + ite c 1 0 -- | Correctness theorem for our `checkOverflow` implementation. --@@ -285,7 +285,7 @@ -- On a decent MacBook Pro, this proof takes about 3 minutes with the 'SFunArray' memory model -- and about 30 minutes with the 'SArray' model. correctnessTheorem :: IO ThmResult-correctnessTheorem = proveWith timingSMTCfg $+correctnessTheorem = proveWith yices{timing = True} $ forAll ["mem", "addrX", "x", "addrY", "y", "addrLow", "regX", "regA", "memVals", "flagC", "flagZ"] legatoIsCorrect
Data/SBV/Examples/BitPrecise/PrefixSum.hs view
@@ -19,6 +19,7 @@ module Data.SBV.Examples.BitPrecise.PrefixSum where import Data.SBV+import qualified Data.SBV.Provers.Yices as Yices import Data.SBV.Internals(runSymbolic) ----------------------------------------------------------------------@@ -79,7 +80,7 @@ -- | Correctness theorem, for a powerlist of given size, an associative operator, and its left-unit element. flIsCorrect :: Int -> (forall a. (OrdSymbolic a, Bits a) => (a, a -> a -> a)) -> Symbolic SBool flIsCorrect n zf = do- args :: PowerList SWord32 <- mkFreeVars n+ args :: PowerList SWord32 <- mkForallVars n return $ ps zf args .== lf zf args -- | Proves Ladner-Fischer is equivalent to reference specification for addition.@@ -127,7 +128,7 @@ -- Also, the unit @0@ is clearly not a left-unit for @flOp@, as the third -- equation for @flOp@ will simply map many elements to @0@. thm3 :: IO ThmResult-thm3 = prove $ do args :: PowerList SWord32 <- mkFreeVars 8+thm3 = prove $ do args :: PowerList SWord32 <- mkForallVars 8 return $ ps (u, op) args .== lf (u, op) args where op :: SWord32 -> SWord32 -> SWord32 op = uninterpret "flOp"@@ -141,7 +142,7 @@ -- the necessary axioms for associativity and left-unit. The first argument states how wide the power list should be. genPrefixSumInstance :: Int -> Symbolic SBool genPrefixSumInstance n = do- args :: PowerList SWord32 <- mkFreeVars n+ args :: PowerList SWord32 <- mkForallVars n addAxiom "flOp is associative" $ assocAxiom (sbvUFName opH) addAxiom "u is left-unit for flOp" $ leftUnitAxiom (sbvUFName opH) (sbvUFName uH) return $ ps (u, op) args .== lf (u, op) args@@ -204,10 +205,10 @@ = error $ "prefixSum: input must be a power of 2 larger than 2, received: " ++ show i | True = proveWith cfg $ genPrefixSumInstance i- where cfg = defaultSMTCfg { solver = yices' }- yices' = yices { options = ["-tc", "-smt", "-e"]- , executable = "/usr/local/yices-1.0.29/bin/yices"- }+ where cfg = yices { solver = yices' }+ yices' = Yices.yices { options = ["-tc", "-smt", "-e"]+ , executable = "yices-1.0.29"+ } ---------------------------------------------------------------------- -- * Inspecting symbolic traces@@ -257,7 +258,7 @@ -- s18 ladnerFischerTrace :: Int -> IO () ladnerFischerTrace n = gen >>= print- where gen = runSymbolic $ do args :: [SWord8] <- mkFreeVars n+ where gen = runSymbolic $ do args :: [SWord8] <- mkForallVars n mapM_ output $ lf (0, (+)) args -- | Trace generator for the reference spec. It clearly demonstrates that the reference@@ -300,5 +301,5 @@ -- scanlTrace :: Int -> IO () scanlTrace n = gen >>= print- where gen = runSymbolic $ do args :: [SWord8] <- mkFreeVars n+ where gen = runSymbolic $ do args :: [SWord8] <- mkForallVars n mapM_ output $ ps (0, (+)) args
Data/SBV/Examples/CRC/CCITT.hs view
@@ -22,10 +22,10 @@ extendData (h, l) = h # l # 0 mkFrame :: SWord48 -> SWord64-mkFrame msg@(h, l) = h # l # crc msg+mkFrame msg@(h, l) = h # l # crc_48_16 msg -crc :: SWord48 -> SWord16-crc msg = res+crc_48_16 :: SWord48 -> SWord16+crc_48_16 msg = res where msg64, divisor :: SWord64 msg64 = extendData msg divisor = polynomial [16, 12, 5, 0]@@ -37,7 +37,7 @@ where count [] = 0 count (b:bs) = let r = count bs in ite b r (1+r) --- Claim: If there is an undetected corruption, it must be at least at 4 bits; i.e. HD is 3+-- Claim: If there is an undetected corruption, it must be at least at 4 bits; i.e. HD is 4 crcGood :: SWord48 -> SWord48 -> SBool crcGood sent received = sent ./= received ==> diffCount frameSent frameReceived .> 3
Data/SBV/Examples/CRC/CCITT_Unidir.hs view
@@ -23,10 +23,10 @@ extendData (h, l) = h # l # 0 mkFrame :: SWord48 -> SWord64-mkFrame msg@(h, l) = h # l # crc msg+mkFrame msg@(h, l) = h # l # crc_48_16 msg -crc :: SWord48 -> SWord16-crc msg = res+crc_48_16 :: SWord48 -> SWord16+crc_48_16 msg = res where msg64, divisor :: SWord64 msg64 = extendData msg divisor = polynomial [16, 12, 5, 0]
Data/SBV/Examples/CRC/GenPoly.hs view
@@ -22,10 +22,10 @@ extendData (h, l) = h # l # 0 mkFrame :: SWord64 -> SWord48 -> SWord64-mkFrame poly msg@(h, l) = h # l # crc msg poly+mkFrame poly msg@(h, l) = h # l # crc_48_16 msg poly -crc :: SWord48 -> SWord64 -> SWord16-crc msg poly = res+crc_48_16 :: SWord48 -> SWord64 -> SWord16+crc_48_16 msg poly = res where msg64 = extendData msg crc64 = pMod msg64 poly (_, res) = split (snd (split crc64))@@ -56,7 +56,7 @@ mapM_ (\(i, s) -> putStrLn (show i ++ ". " ++ showPoly (mkPoly s))) (zip [(1::Integer)..] res) putStrLn $ "*** Skipped the followings, proof exceeded timeout value of " ++ show waitFor mapM_ (\(i, s) -> putStrLn (show i ++ ". " ++ showPoly (mkPoly s))) (zip [(1::Integer)..] skipped)- putStrLn $ "*** Done."+ putStrLn "*** Done." where go :: SWord16 -> [SWord16] -> [SWord16] -> IO ([SWord16], [SWord16]) go poly skip acc | poly == maxBound = return (skip, acc)
Data/SBV/Examples/CRC/USB5.hs view
@@ -26,11 +26,11 @@ extendData (S11 w) = w `shiftL` 5 mkFrame :: SWord11 -> SWord16-mkFrame w = extendData w .|. crc w+mkFrame w = extendData w .|. crc_11_16 w -- crc returns 16 bits, but the first 11 are always 0-crc :: SWord11 -> SWord16-crc msg = crc16 .&. 0x1F -- just get the last 5 bits+crc_11_16 :: SWord11 -> SWord16+crc_11_16 msg = crc16 .&. 0x1F -- just get the last 5 bits where divisor :: SWord16 divisor = polynomial [5, 2, 0] crc16 = pMod (extendData msg) divisor
+ Data/SBV/Examples/CodeGeneration/CRC_USB5.hs view
@@ -0,0 +1,86 @@+-----------------------------------------------------------------------------+-- |+-- Module : Data.SBV.Examples.CodeGeneration.CRC_USB5+-- Copyright : (c) Levent Erkok+-- License : BSD3+-- Maintainer : erkokl@gmail.com+-- Stability : experimental+-- Portability : portable+--+-- Computing the CRC symbolically, using the USB polynomial. We also+-- generating C code for it as well. This example demonstrates the+-- use of the 'crcBV' function, along with how CRC's can be computed+-- mathematically using polynomial division. While the results are the+-- same (i.e., proven equivalent, see 'crcGood' below), the internal+-- CRC implementation generates much better code, compare 'cg1' vs 'cg2' below.+-----------------------------------------------------------------------------++module Data.SBV.Examples.CodeGeneration.CRC_USB5 where++import Data.SBV++-----------------------------------------------------------------------------+-- * The USB polynomial+-----------------------------------------------------------------------------++-- | The USB CRC polynomial: @x^5 + x^2 + 1@.+-- Although this polynomial needs just 6 bits to represent (5 if higher+-- order bit is implicitly assumed to be set), we'll simply use a 16 bit+-- number for its representation to keep things simple for code generation+-- purposes.+usb5 :: SWord16+usb5 = polynomial [5, 2, 0]++-----------------------------------------------------------------------------+-- * Computing CRCs+-----------------------------------------------------------------------------++-- | Given an 11 bit message, compute the CRC of it using the USB polynomial,+-- which is 5 bits, and then append it to the msg to get a 16-bit word. Again,+-- the incoming 11-bits is represented as a 16-bit word, with 5 highest bits+-- essentially ignored for input purposes.+crcUSB :: SWord16 -> SWord16+crcUSB i = fromBitsBE (ib ++ cb)+ where ib = drop 5 (blastBE i) -- only the last 11 bits needed+ pb = drop 11 (blastBE usb5) -- only the last 5 bits needed+ cb = crcBV 5 ib pb++-- | Alternate method for computing the CRC, /mathematically/. We shift+-- the number to the left by 5, and then compute the remainder from the+-- polynomial division by the USB polynomial. The result is then appended+-- to the end of the message.+crcUSB' :: SWord16 -> SWord16+crcUSB' i' = i .|. pMod i usb5+ where i = i' `shiftL` 5++-----------------------------------------------------------------------------+-- * Correctness+-----------------------------------------------------------------------------++-- | Prove that the custom 'crcBV' function is equivalent to the mathematical+-- definition of CRC's for 11 bit messages. We have:+--+-- >>> crcGood+-- Q.E.D.+crcGood :: IO ThmResult+crcGood = prove $ \i -> crcUSB i .== crcUSB' i++-----------------------------------------------------------------------------+-- * Code generation+-----------------------------------------------------------------------------++-- | Generate a C function to compute the USB CRC, using the internal CRC+-- function.+cg1 :: IO ()+cg1 = compileToC (Just "crcUSB1") "crcUSB1" $ do+ msg <- cgInput "msg"+ cgOutput "crc" (crcUSB msg)++-- | Generate a C function to compute the USB CRC, using the mathematical+-- definition of the CRCs. Whule this version generates functionally eqivalent+-- C code, it's less efficient; it has about 30% more code. So, the above+-- version is preferable for code generation purposes.+cg2 :: IO ()+cg2 = compileToC (Just "crcUSB2") "crcUSB2" $ do+ msg <- cgInput "msg"+ cgOutput "crc" (crcUSB' msg)
Data/SBV/Examples/Crypto/AES.hs view
@@ -155,8 +155,8 @@ chop4 xs = let (f, r) = splitAt 4 xs in f : chop4 r nextWord :: Int -> SWord32 -> SWord32 -> SWord32 nextWord i prev old- | i `mod` nk == 0 = old `xor` (subWordRcon (prev `rotateL` 8) (roundConstants !! (i `div` nk)))- | i `mod` nk == 4 && nk > 6 = old `xor` (subWordRcon prev 0)+ | i `mod` nk == 0 = old `xor` subWordRcon (prev `rotateL` 8) (roundConstants !! (i `div` nk))+ | i `mod` nk == 4 && nk > 6 = old `xor` subWordRcon prev 0 | True = old `xor` prev subWordRcon :: SWord32 -> GF28 -> SWord32 subWordRcon w rc = fromBytes [a `xor` rc, b, c, d]@@ -278,11 +278,11 @@ aesRound isFinal s key = d `addRoundKey` key where d = map (f isFinal) [0..3] a = map toBytes s- f True j = fromBytes $ [ sbox (a !! ((j+0) `mod` 4) !! 0)- , sbox (a !! ((j+1) `mod` 4) !! 1)- , sbox (a !! ((j+2) `mod` 4) !! 2)- , sbox (a !! ((j+3) `mod` 4) !! 3)- ]+ f True j = fromBytes [ sbox (a !! ((j+0) `mod` 4) !! 0)+ , sbox (a !! ((j+1) `mod` 4) !! 1)+ , sbox (a !! ((j+2) `mod` 4) !! 2)+ , sbox (a !! ((j+3) `mod` 4) !! 3)+ ] f False j = e0 `xor` e1 `xor` e2 `xor` e3 where e0 = t0 (a !! ((j+0) `mod` 4) !! 0) e1 = t1 (a !! ((j+1) `mod` 4) !! 1)
Data/SBV/Examples/Crypto/RC4.hs view
@@ -17,7 +17,6 @@ ----------------------------------------------------------------------------- {-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE PatternGuards #-} module Data.SBV.Examples.Crypto.RC4 where @@ -137,8 +136,8 @@ -- large symbolic trace. rc4IsCorrect :: IO ThmResult rc4IsCorrect = prove $ do- key <- mkFreeVars 5- pt <- mkFreeVars 5+ key <- mkForallVars 5+ pt <- mkForallVars 5 let ks = keySchedule key ct = zipWith xor ks pt pt' = zipWith xor ks ct
+ Data/SBV/Examples/Existentials/CRCPolynomial.hs view
@@ -0,0 +1,99 @@+-----------------------------------------------------------------------------+-- |+-- Module : Data.SBV.Examples.Existentials.CRCPolynomial+-- Copyright : (c) Levent Erkok+-- License : BSD3+-- Maintainer : erkokl@gmail.com+-- Stability : experimental+-- Portability : portable+--+-- This program demonstrates the use of the existentials and the QBVF (quantified+-- bit-vector solver). We generate CRC polynomials of degree 16 that can be used+-- for messages of size 48-bits. The query finds all such polynomials that have hamming+-- distance is at least 4. That is, if the CRC can't tell two different 48-bit messages+-- apart, then they must differ in at least 4 bits.+-----------------------------------------------------------------------------++module Data.SBV.Examples.Existentials.CRCPolynomial where++import Data.SBV++-----------------------------------------------------------------------------+-- * Modeling 48 bit words+-----------------------------------------------------------------------------+-- | SBV doesn't support 48 bit words natively. So, we represent them+-- as a tuple, 32 high-bits and 16 low-bits.+type SWord48 = (SWord32, SWord16)++-- | Compute the 16 bit CRC of a 48 bit message, using the given polynomial+crc_48_16 :: SWord48 -> SWord16 -> [SBool]+crc_48_16 msg poly = crcBV 16 msgBits polyBits+ where (hi, lo) = msg+ msgBits = blastBE hi ++ blastBE lo+ polyBits = blastBE poly++-- | Count the differing bits in the message and the corresponding CRC+diffCount :: (SWord48, [SBool]) -> (SWord48, [SBool]) -> SWord8+diffCount ((h1, l1), crc1) ((h2, l2), crc2) = count xorBits+ where bits1 = blastBE h1 ++ blastBE l1 ++ crc1+ bits2 = blastBE h2 ++ blastBE l2 ++ crc2+ -- xor will give us a false if bits match, true if they differ+ xorBits = zipWith (<+>) bits1 bits2+ count [] = 0+ count (b:bs) = let r = count bs in ite b (1+r) r++-- | Given a hamming distance value @hd@, 'crcGood' returns @true@ if+-- the 16 bit polynomial can distinguish all messages that has at most+-- @hd@ different bits. Note that we express this conversely: If the+-- @sent@ and @received@ messages are different, then it must be the+-- case that that must differ from each other (including CRCs), in+-- more than @hd@ bits.+crcGood :: SWord8 -> SWord16 -> SWord48 -> SWord48 -> SBool+crcGood hd poly sent received =+ sent ./= received ==> diffCount (sent, crcSent) (received, crcReceived) .>= hd+ where crcSent = crc_48_16 sent poly+ crcReceived = crc_48_16 received poly++-- | Generate good CRC polynomials for 48-bit words, given the hamming distance @hd@.+genPoly :: SWord8 -> IO ()+genPoly hd = do res <- allSatWith z3 $ do+ -- the polynomial is existentially specified+ p <- exists "polynomial"+ -- sent word, universal+ s <- do sh <- forall "sh"+ sl <- forall "sl"+ return (sh, sl)+ -- received word, universal+ r <- do rh <- forall "rh"+ rl <- forall "rl"+ return (rh, rl)+ -- assert that the polynomial @p@ is good. Note+ -- that we also supply the extra information that+ -- the least significant bit must be set in the+ -- polynomial, as all CRC polynomials have the "+1"+ -- term in them set. This simplifies the query.+ return $ bitValue p 0 &&& crcGood hd p s r+ cnt <- displayModels disp res+ putStrLn $ "Found: " ++ show cnt ++ " polynomail(s)."+ where disp :: Int -> Word16 -> IO ()+ disp n s = do putStrLn $ "Polynomial #" ++ show n ++ ". x^16 + " ++ showPolynomial False s++-- | Find and display all degree 16 polynomials with hamming distance at least 4, for 48 bit messages.+--+-- When run, this function prints:+--+-- @+-- Polynomial #1. x^16 + x^2 + x + 1+-- Polynomial #2. x^16 + x^15 + x^2 + 1+-- Polynomial #3. x^16 + x^15 + x^14 + 1+-- Polynomial #4. x^16 + x^15 + x^2 + x + 1+-- Polynomial #5. x^16 + x^14 + x + 1+-- ...+-- @+--+-- Note that different runs can produce different results, depending on the random+-- numbers used by the solver, solver version, etc. (Also, the solver will take some+-- time to generate these results. On my machine, the first five polynomials were+-- generated in about 5 minutes.)+findHD4Polynomials :: IO ()+findHD4Polynomials = genPoly 4
Data/SBV/Examples/Puzzles/Counts.hs view
@@ -52,7 +52,7 @@ puzzle :: Counts -> SBool puzzle cnt = cnt .== last css where ones = replicate 10 1 -- all digits occur once to start with- css = [ones] ++ zipWith count cnt css+ css = ones : zipWith count cnt css -- | Finds all two known solutions to this puzzle. We have: --@@ -63,7 +63,7 @@ -- In this sentence, the number of occurrences of 0 is 1, of 1 is 7, of 2 is 3, of 3 is 2, of 4 is 1, of 5 is 1, of 6 is 1, of 7 is 2, of 8 is 1, of 9 is 1. -- Found: 2 solution(s). solve :: IO ()-solve = do res <- allSat $ mkFreeVars 10 >>= return . puzzle+solve = do res <- allSat $ puzzle `fmap` mkExistVars 10 cnt <- displayModels disp res putStrLn $ "Found: " ++ show cnt ++ " solution(s)." where disp n s = do putStrLn $ "Solution #" ++ show n
Data/SBV/Examples/Puzzles/DogCatMouse.hs view
@@ -33,9 +33,14 @@ -- | Prints the only solution: -- -- >>> solve--- Only one solution found:+-- Solution #1: -- dog = 3 :: SWord16 -- cat = 41 :: SWord16 -- mouse = 56 :: SWord16+-- This is the only solution. solve :: IO AllSatResult-solve = allSat $ forAll ["dog", "cat", "mouse"] puzzle+solve = allSat $ do+ d <- exists "dog"+ c <- exists "cat"+ m <- exists "mouse"+ return $ puzzle d c m
Data/SBV/Examples/Puzzles/Euler185.hs view
@@ -32,7 +32,7 @@ -- generated by zipping the alleged solution with each guess, and making sure the -- number of matching digits match what's given in the problem statement. euler185 :: Symbolic SBool-euler185 = do soln <- mkFreeVars 16+euler185 = do soln <- mkExistVars 16 return $ bAll digit soln &&& bAnd (map (genConstr soln) guesses) where genConstr a (b, c) = sum (zipWith eq a b) .== (c :: SWord8) digit x = (x :: SWord8) .>= 0 &&& x .<= 9
Data/SBV/Examples/Puzzles/MagicSquare.hs view
@@ -58,7 +58,7 @@ magic n | n < 0 = putStrLn $ "n must be non-negative, received: " ++ show n | True = do putStrLn $ "Finding all " ++ show n ++ "-magic squares.."- res <- allSat $ mkFreeVars n2 >>= return . isMagic . chunk n+ res <- allSat $ (isMagic . chunk n) `fmap` mkExistVars n2 cnt <- displayModels disp res putStrLn $ "Found: " ++ show cnt ++ " solution(s)." where n2 = n * n@@ -71,7 +71,7 @@ putStrLn $ "Valid Check: " ++ show (isMagic sboard) putStrLn "Done." where lmod = length model- board = chunk n $ model+ board = chunk n model sboard = map (map literal) board sh2 z = let s = show z in if length s < 2 then ' ':s else s- printRow r = putStr " " >> mapM_ (\x -> putStr ((sh2 x) ++ " ")) r >> putStrLn ""+ printRow r = putStr " " >> mapM_ (\x -> putStr (sh2 x ++ " ")) r >> putStrLn ""
Data/SBV/Examples/Puzzles/NQueens.hs view
@@ -34,7 +34,7 @@ nQueens n | n < 0 = putStrLn $ "n must be non-negative, received: " ++ show n | True = do putStrLn $ "Finding all " ++ show n ++ "-queens solutions.."- res <- allSat $ mkFreeVars n >>= return . isValid n+ res <- allSat $ isValid n `fmap` mkExistVars n cnt <- displayModels disp res putStrLn $ "Found: " ++ show cnt ++ " solution(s)." where disp i s = do putStr $ "Solution #" ++ show i ++ ": "
Data/SBV/Examples/Puzzles/PowerSet.hs view
@@ -24,7 +24,7 @@ powerSet :: [Word8] -> IO () powerSet xs = do putStrLn $ "Finding all subsets of " ++ show xs- res <- allSat $ mkFreeVars n >>= return . genPowerSet+ res <- allSat $ genPowerSet `fmap` mkExistVars n cnt <- displayModels disp res putStrLn $ "Found: " ++ show cnt ++ " subset(s)." where n = length xs
Data/SBV/Examples/Puzzles/Sudoku.hs view
@@ -54,8 +54,10 @@ -- | Solve a given puzzle and print the results solve :: Puzzle -> IO () solve p@(i, f) = do putStrLn "Solving the puzzle.."- SatResult res <- sat $ mkFreeVars i >>= return . valid . f- dispSolution p (getModel res)+ model <- getModel `fmap` sat ((valid . f) `fmap` mkExistVars i)+ case model of+ Right sln -> dispSolution p sln+ Left m -> putStrLn $ "Unsolvable puzzle: " ++ m -- | Helper function to display results nicely, not really needed, but helps presentation dispSolution :: Puzzle -> [Word8] -> IO ()@@ -72,7 +74,7 @@ -- | Find all solutions to a puzzle solveAll :: Puzzle -> IO () solveAll p@(i, f) = do putStrLn "Finding all solutions.."- res <- allSat $ mkFreeVars i >>= return . valid . f+ res <- allSat $ (valid . f) `fmap` mkExistVars i cnt <- displayModels disp res putStrLn $ "Found: " ++ show cnt ++ " solution(s)." where disp n s = do putStrLn $ "Solution #" ++ show n
Data/SBV/Examples/Puzzles/Temperature.hs view
@@ -31,10 +31,10 @@ swap (a, b) = (b, a) solve :: IO ()-solve = do res <- allSat $ free_ >>= return . revOf+solve = do res <- allSat $ revOf `fmap` exists_ cnt <- displayModels disp res putStrLn $ "Found " ++ show cnt ++ " solutions." where disp :: Int -> Word16 -> IO ()- disp _ x = putStrLn $ " " ++ show x ++ "C --> " ++ show ((round f) :: Integer) ++ "F (exact value: " ++ show f ++ "F)"+ disp _ x = putStrLn $ " " ++ show x ++ "C --> " ++ show (round f :: Integer) ++ "F (exact value: " ++ show f ++ "F)" where f :: Double f = 32 + (9 * fromIntegral x) / 5
Data/SBV/Examples/Puzzles/U2Bridge.hs view
@@ -12,10 +12,10 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeSynonymInstances #-}-{-# LANGUAGE PatternGuards #-} module Data.SBV.Examples.Puzzles.U2Bridge where +import Control.Monad (unless) import Control.Monad.State (State, runState, put, get, modify, evalState) import Data.Maybe (fromJust) @@ -179,7 +179,7 @@ -- | Run a sequence of given actions. run :: Actions -> Move [Status]-run = sequence . map step+run = mapM step where step (b, p1, p2) = ite b (move1 p1) (move2 p1 p2) >> get -------------------------------------------------------------@@ -211,11 +211,11 @@ -- | See if there is a solution that has precisely @n@ steps solveN :: Int -> IO Bool solveN n = do putStrLn $ "Checking for solutions with " ++ show n ++ " move" ++ plu n ++ "."- let genAct = do b <- free_- p1 <- free_- p2 <- free_+ let genAct = do b <- exists_+ p1 <- exists_+ p2 <- exists_ return (b, p1, p2)- res <- allSat $ mapM (const genAct) [1..n] >>= return . isValid+ res <- allSat $ isValid `fmap` mapM (const genAct) [1..n] cnt <- displayModels disp res if cnt == 0 then return False else do putStrLn $ "Found: " ++ show cnt ++ " solution" ++ plu cnt ++ " with " ++ show n ++ " move" ++ plu n ++ "."@@ -263,8 +263,8 @@ -- Total time: 17 -- Found: 2 solutions with 5 moves. ----- Finding the all 2 possible solutions to the puzzle.+-- Finding all possible solutions to the puzzle. solveU2 :: IO () solveU2 = go 1 where go i = do p <- solveN i- if p then return () else go (i+1)+ unless p $ go (i+1)
Data/SBV/Internals.hs view
@@ -16,7 +16,7 @@ -- * Running symbolic programs /manually/ Result, runSymbolic -- * Other internal structures useful for low-level programming- , SBV(..), HasSignAndSize(..), CW, mkConstCW, genFree, genFree_+ , SBV(..), HasSignAndSize(..), CW, mkConstCW, genVar, genVar_ -- * Compilation to C , compileToC', compileToCLib', CgPgmBundle(..), CgPgmKind(..) -- * Integrating with the test framework@@ -25,7 +25,7 @@ ) where import Data.SBV.BitVectors.Data (Result, runSymbolic, SBV(..), HasSignAndSize(..), CW, mkConstCW)-import Data.SBV.BitVectors.Model (genFree, genFree_)+import Data.SBV.BitVectors.Model (genVar, genVar_) import Data.SBV.Compilers.C (compileToC', compileToCLib') import Data.SBV.Compilers.CodeGen (CgPgmBundle(..), CgPgmKind(..)) import Data.SBV.Utils.SBVTest
Data/SBV/Provers/Prover.hs view
@@ -27,15 +27,16 @@ , sat, satWith , allSat, allSatWith , SatModel(..), getModel, displayModels- , defaultSMTCfg, verboseSMTCfg, timingSMTCfg, verboseTimingSMTCfg- , Yices.yices- , timeout+ , yices, z3 , compileToSMTLib ) where -import Control.Monad (when)+import qualified Control.Exception as E+ import Control.Concurrent (forkIO) import Control.Concurrent.Chan.Strict (newChan, writeChan, getChanContents)+import Control.Monad (when)+import Data.List (intercalate) import Data.Maybe (fromJust, isJust, catMaybes) import System.Time (getClockTime) @@ -44,32 +45,16 @@ import Data.SBV.SMT.SMT import Data.SBV.SMT.SMTLib import qualified Data.SBV.Provers.Yices as Yices+import qualified Data.SBV.Provers.Z3 as Z3 import Data.SBV.Utils.TDiff --- | Default configuration for the SMT solver. Non-verbose, non-timing, prints results in base 10, and uses--- the Yices SMT solver.-defaultSMTCfg :: SMTConfig-defaultSMTCfg = SMTConfig {verbose = False, timing = False, printBase = 10, solver = Yices.yices}---- | Same as 'defaultSMTCfg', except verbose-verboseSMTCfg :: SMTConfig-verboseSMTCfg = defaultSMTCfg {verbose=True}---- | Same as 'defaultSMTCfg', except prints timing info-timingSMTCfg :: SMTConfig-timingSMTCfg = defaultSMTCfg {timing=True}---- | Same as 'defaultSMTCfg', except both verbose and timing info-verboseTimingSMTCfg :: SMTConfig-verboseTimingSMTCfg = timingSMTCfg {verbose=True}+-- | Default configuration for the Yices SMT Solver.+yices :: SMTConfig+yices = SMTConfig {verbose = False, timing = False, timeOut = Nothing, printBase = 10, smtFile = Nothing, solver = Yices.yices, useSMTLib2 = False} --- We might need a better system if we add more backend solvers--- | Adds a time out of @n@ seconds to a given solver configuration-timeout :: Int -> SMTConfig -> SMTConfig-timeout n s- | nm == name Yices.yices = s{solver = Yices.timeout n (solver s)}- | True = error $ "SBV.Prover.timeout: Solver " ++ show nm ++ " does not support time-outs"- where nm = name (solver s)+-- | Default configuration for the Z3 SMT solver+z3 :: SMTConfig+z3 = yices { solver = Z3.z3, useSMTLib2 = True } -- | A predicate is a symbolic program that returns a (symbolic) boolean value. For all intents and -- purposes, it can be treated as an n-ary function from symbolic-values to a boolean. The 'Symbolic'@@ -94,7 +79,7 @@ -- @x@ will be named @s0@ and @y@ will be named @s1@. forAll_ :: a -> Predicate -- | Turns a value into a predicate, allowing users to provide names for the inputs.- -- If the user does not provide enough number of names for the free variables, the remaining ones+ -- If the user does not provide enough number of names for the variables, the remaining ones -- will be internally generated. Note that the names are only used for printing models and has no -- other significance; in particular, we do not check that they are unique. Example: --@@ -124,8 +109,8 @@ -- Functions instance (SymWord a, Provable p) => Provable (SBV a -> p) where- forAll_ k = free_ >>= \a -> forAll_ $ k a- forAll (s:ss) k = free s >>= \a -> forAll ss $ k a+ forAll_ k = forall_ >>= \a -> forAll_ $ k a+ forAll (s:ss) k = forall s >>= \a -> forAll ss $ k a forAll [] k = forAll_ k -- Arrays (memory)@@ -136,49 +121,49 @@ -- 2 Tuple instance (SymWord a, SymWord b, Provable p) => Provable ((SBV a, SBV b) -> p) where- forAll_ k = free_ >>= \a -> forAll_ $ \b -> k (a, b)- forAll (s:ss) k = free s >>= \a -> forAll ss $ \b -> k (a, b)+ forAll_ k = forall_ >>= \a -> forAll_ $ \b -> k (a, b)+ forAll (s:ss) k = forall s >>= \a -> forAll ss $ \b -> k (a, b) forAll [] k = forAll_ k -- 3 Tuple instance (SymWord a, SymWord b, SymWord c, Provable p) => Provable ((SBV a, SBV b, SBV c) -> p) where- forAll_ k = free_ >>= \a -> forAll_ $ \b c -> k (a, b, c)- forAll (s:ss) k = free s >>= \a -> forAll ss $ \b c -> k (a, b, c)+ forAll_ k = forall_ >>= \a -> forAll_ $ \b c -> k (a, b, c)+ forAll (s:ss) k = forall s >>= \a -> forAll ss $ \b c -> k (a, b, c) forAll [] k = forAll_ k -- 4 Tuple instance (SymWord a, SymWord b, SymWord c, SymWord d, Provable p) => Provable ((SBV a, SBV b, SBV c, SBV d) -> p) where- forAll_ k = free_ >>= \a -> forAll_ $ \b c d -> k (a, b, c, d)- forAll (s:ss) k = free s >>= \a -> forAll ss $ \b c d -> k (a, b, c, d)+ forAll_ k = forall_ >>= \a -> forAll_ $ \b c d -> k (a, b, c, d)+ forAll (s:ss) k = forall s >>= \a -> forAll ss $ \b c d -> k (a, b, c, d) forAll [] k = forAll_ k -- 5 Tuple instance (SymWord a, SymWord b, SymWord c, SymWord d, SymWord e, Provable p) => Provable ((SBV a, SBV b, SBV c, SBV d, SBV e) -> p) where- forAll_ k = free_ >>= \a -> forAll_ $ \b c d e -> k (a, b, c, d, e)- forAll (s:ss) k = free s >>= \a -> forAll ss $ \b c d e -> k (a, b, c, d, e)+ forAll_ k = forall_ >>= \a -> forAll_ $ \b c d e -> k (a, b, c, d, e)+ forAll (s:ss) k = forall s >>= \a -> forAll ss $ \b c d e -> k (a, b, c, d, e) forAll [] k = forAll_ k -- 6 Tuple instance (SymWord a, SymWord b, SymWord c, SymWord d, SymWord e, SymWord f, Provable p) => Provable ((SBV a, SBV b, SBV c, SBV d, SBV e, SBV f) -> p) where- forAll_ k = free_ >>= \a -> forAll_ $ \b c d e f -> k (a, b, c, d, e, f)- forAll (s:ss) k = free s >>= \a -> forAll ss $ \b c d e f -> k (a, b, c, d, e, f)+ forAll_ k = forall_ >>= \a -> forAll_ $ \b c d e f -> k (a, b, c, d, e, f)+ forAll (s:ss) k = forall s >>= \a -> forAll ss $ \b c d e f -> k (a, b, c, d, e, f) forAll [] k = forAll_ k -- 7 Tuple instance (SymWord a, SymWord b, SymWord c, SymWord d, SymWord e, SymWord f, SymWord g, Provable p) => Provable ((SBV a, SBV b, SBV c, SBV d, SBV e, SBV f, SBV g) -> p) where- forAll_ k = free_ >>= \a -> forAll_ $ \b c d e f g -> k (a, b, c, d, e, f, g)- forAll (s:ss) k = free s >>= \a -> forAll ss $ \b c d e f g -> k (a, b, c, d, e, f, g)+ forAll_ k = forall_ >>= \a -> forAll_ $ \b c d e f g -> k (a, b, c, d, e, f, g)+ forAll (s:ss) k = forall s >>= \a -> forAll ss $ \b c d e f g -> k (a, b, c, d, e, f, g) forAll [] k = forAll_ k --- | Prove a predicate, equivalent to @'proveWith' 'defaultSMTCfg'@+-- | Prove a predicate, equivalent to @'proveWith' 'yices'@ prove :: Provable a => a -> IO ThmResult-prove = proveWith defaultSMTCfg+prove = proveWith yices --- | Find a satisfying assignment for a predicate, equivalent to @'satWith' 'defaultSMTCfg'@+-- | Find a satisfying assignment for a predicate, equivalent to @'satWith' 'yices'@ sat :: Provable a => a -> IO SatResult-sat = satWith defaultSMTCfg+sat = satWith yices --- | Return all satisfying assignments for a predicate, equivalent to @'allSatWith' 'defaultSMTCfg'@.+-- | Return all satisfying assignments for a predicate, equivalent to @'allSatWith' 'yices'@. -- Satisfying assignments are constructed lazily, so they will be available as returned by the solver -- and on demand. --@@ -187,7 +172,7 @@ -- array inputs will be returned. This is due to the limitation of not having a robust means of getting a -- function counter-example back from the SMT solver. allSat :: Provable a => a -> IO AllSatResult-allSat = allSatWith defaultSMTCfg+allSat = allSatWith yices -- Decision procedures (with optional timeout) checkTheorem :: Provable a => Maybe Int -> a -> IO (Maybe Bool)@@ -197,7 +182,7 @@ ThmResult (Satisfiable _ _) -> return $ Just False ThmResult (TimeOut _) -> return Nothing _ -> error $ "SBV.isTheorem: Received:\n" ++ show r- where pr = maybe prove (\i -> proveWith (timeout i defaultSMTCfg)) mbTo+ where pr = maybe prove (\i -> proveWith (yices{timeOut = Just i})) mbTo checkSatisfiable :: Provable a => Maybe Int -> a -> IO (Maybe Bool) checkSatisfiable mbTo p = do r <- s p@@ -206,7 +191,7 @@ SatResult (Unsatisfiable _) -> return $ Just False SatResult (TimeOut _) -> return Nothing _ -> error $ "SBV.isSatisfiable: Received: " ++ show r- where s = maybe sat (\i -> satWith (timeout i defaultSMTCfg)) mbTo+ where s = maybe sat (\i -> satWith yices{timeOut = Just i}) mbTo -- | Checks theoremhood within the given time limit of @i@ seconds. -- Returns @Nothing@ if times out, or the result wrapped in a @Just@ otherwise.@@ -232,67 +217,87 @@ -- computing it might take quite long, as it literally generates and counts -- the number of satisfying models. numberOfModels :: Provable a => a -> IO Int-numberOfModels p = do AllSatResult rs <- allSat p- return $ sum $ map walk rs- where walk (Satisfiable{}) = 1- -- shouldn't happen, but just in case- walk r = error $ "numberOfModels: Unexpected result from an allSat check: " ++ show (AllSatResult [r])+numberOfModels p = do AllSatResult (_, rs) <- allSat p+ return $ length rs -- | Compiles to SMT-Lib and returns the resulting program as a string. Useful for saving -- the result to a file for off-line analysis, for instance if you have an SMT solver that's not natively--- supported out-of-the box by the SBV library.-compileToSMTLib :: Provable a => a -> IO String-compileToSMTLib a = do+-- supported out-of-the box by the SBV library. If 'smtLib2' parameter is False, then we will generate+-- SMTLib1 output, otherwise we will generate SMTLib2 output+compileToSMTLib :: Provable a => Bool -> a -> IO String+compileToSMTLib smtLib2 a = do t <- getClockTime let comments = ["Created on " ++ show t]- (_, _, smtLibPgm) <- generateTrace defaultSMTCfg False comments a+ cvt = if smtLib2 then toSMTLib2 else toSMTLib1+ (_, _, _, smtLibPgm) <- simulate cvt yices False comments a return $ show smtLibPgm ++ "\n" -- | Proves the predicate using the given SMT-solver proveWith :: Provable a => SMTConfig -> a -> IO ThmResult-proveWith config a = generateTrace config False [] a >>= callSolver [] "Checking Theoremhood.." ThmResult config+proveWith config a = simulate cvt config False [] a >>= callSolver False "Checking Theoremhood.." ThmResult config+ where cvt = if useSMTLib2 config then toSMTLib2 else toSMTLib1 -- | Find a satisfying assignment using the given SMT-solver satWith :: Provable a => SMTConfig -> a -> IO SatResult-satWith config a = generateTrace config True [] a >>= callSolver [] "Checking Satisfiability.." SatResult config+satWith config a = simulate cvt config True [] a >>= callSolver True "Checking Satisfiability.." SatResult config+ where cvt = if useSMTLib2 config then toSMTLib2 else toSMTLib1 -- | Find all satisfying assignments using the given SMT-solver allSatWith :: Provable a => SMTConfig -> a -> IO AllSatResult-allSatWith config p = do when (verbose config) $ putStrLn "** Checking Satisfiability, all solutions.."- sbvPgm <- generateTrace config True [] p- resChan <- newChan- let add = writeChan resChan . Just- stop = writeChan resChan Nothing- final r = add r >> stop- -- only fork if non-verbose.. otherwise stdout gets garbled- fork io = if verbose config then io else forkIO io >> return ()- fork $ go sbvPgm add stop final (1::Int) []- results <- getChanContents resChan- return $ AllSatResult $ map fromJust $ takeWhile isJust results- where go sbvPgm add stop final = loop+allSatWith config p = do+ let converter = if useSMTLib2 config then toSMTLib2 else toSMTLib1+ msg "Checking Satisfiability, all solutions.."+ sbvPgm@(qinps, _, _, _) <- simulate converter config True [] p+ resChan <- newChan+ let add = writeChan resChan . Just+ stop = writeChan resChan Nothing+ final r = add r >> stop+ die m = final (ProofError config [m])+ -- only fork if non-verbose.. otherwise stdout gets garbled+ fork io = if verbose config then io else forkIO io >> return ()+ fork $ E.catch (go sbvPgm add stop final (1::Int) [])+ (\e -> die (show (e::E.SomeException)))+ results <- getChanContents resChan+ -- See if there are any existentials below any universals+ -- If such is the case, then the solutions are unique upto prefix existentials+ let w = ALL `elem` map fst qinps+ return $ AllSatResult (w, map fromJust (takeWhile isJust results))+ where msg = when (verbose config) . putStrLn . ("** " ++)+ go sbvPgm add stop final = loop where loop !n nonEqConsts = do- SatResult r <- callSolver nonEqConsts ("Looking for solution " ++ show n) SatResult config sbvPgm- case r of- Satisfiable _ (SMTModel [] _ _) -> final r- Unknown _ (SMTModel [] _ _) -> final r- ProofError _ _ -> final r- TimeOut _ -> stop- Unsatisfiable _ -> stop- Satisfiable _ model -> add r >> loop (n+1) (modelAssocs model : nonEqConsts)- Unknown _ model -> add r >> loop (n+1) (modelAssocs model : nonEqConsts)+ curResult <- invoke nonEqConsts n sbvPgm+ case curResult of+ Nothing -> stop+ Just (SatResult r) -> case r of+ Satisfiable _ (SMTModel [] _ _) -> final r+ Unknown _ (SMTModel [] _ _) -> final r+ ProofError _ _ -> final r+ TimeOut _ -> stop+ Unsatisfiable _ -> stop+ Satisfiable _ model -> add r >> loop (n+1) (modelAssocs model : nonEqConsts)+ Unknown _ model -> add r >> loop (n+1) (modelAssocs model : nonEqConsts)+ invoke nonEqConsts n (qinps, modelMap, skolemMap, smtLibPgm) = do+ msg $ "Looking for solution " ++ show n+ case addNonEqConstraints qinps nonEqConsts smtLibPgm of+ Nothing -> -- no new constraints added, stop+ return Nothing+ Just finalPgm -> do msg $ "Generated SMTLib program:\n" ++ finalPgm+ smtAnswer <- engine (solver config) config True qinps modelMap skolemMap finalPgm+ msg "Done.."+ return $ Just $ SatResult smtAnswer -callSolver :: [[(String, CW)]] -> String -> (SMTResult -> b) -> SMTConfig -> ([NamedSymVar], [(String, UnintKind)], SMTLibPgm) -> IO b-callSolver nonEqConstraints checkMsg wrap config (inps, modelMap, smtLibPgm) = do- let msg = when (verbose config) . putStrLn . ("** " ++)- msg checkMsg- let finalPgm = addNonEqConstraints nonEqConstraints smtLibPgm- msg $ "Generated SMTLib program:\n" ++ finalPgm- smtAnswer <- engine (solver config) config inps modelMap finalPgm- msg "Done.."- return $ wrap smtAnswer+callSolver :: Bool -> String -> (SMTResult -> b) -> SMTConfig -> ([(Quantifier, NamedSymVar)], [(String, UnintKind)], [Either SW (SW, [SW])], SMTLibPgm) -> IO b+callSolver isSat checkMsg wrap config (qinps, modelMap, skolemMap, smtLibPgm) = do+ let msg = when (verbose config) . putStrLn . ("** " ++)+ msg checkMsg+ let finalPgm = intercalate "\n" (pre ++ post) where SMTLibPgm _ (_, pre, post) = smtLibPgm+ msg $ "Generated SMTLib program:\n" ++ finalPgm+ smtAnswer <- engine (solver config) config isSat qinps modelMap skolemMap finalPgm+ msg "Done.."+ return $ wrap smtAnswer -generateTrace :: Provable a => SMTConfig -> Bool -> [String] -> a -> IO ([NamedSymVar], [(String, UnintKind)], SMTLibPgm)-generateTrace config isSat comments predicate = do+simulate :: Provable a => SMTLibConverter -> SMTConfig -> Bool -> [String] -> a -> IO ([(Quantifier, NamedSymVar)], [(String, UnintKind)], [Either SW (SW, [SW])], SMTLibPgm)+simulate converter config isSat comments predicate = do let msg = when (verbose config) . putStrLn . ("** " ++) isTiming = timing config msg "Starting symbolic simulation.."@@ -301,8 +306,16 @@ msg "Translating to SMT-Lib.." case res of Result is consts tbls arrs uis axs pgm [o@(SW (False, 1) _)] | sizeOf o == 1 ->- timeIf isTiming "translation" $ let uiMap = catMaybes (map arrayUIKind arrs) ++ map unintFnUIKind uis- in return (is, uiMap, toSMTLib isSat comments is consts tbls arrs uis axs pgm o)+ timeIf isTiming "translation" $ do let uiMap = catMaybes (map arrayUIKind arrs) ++ map unintFnUIKind uis+ skolemMap = skolemize (if isSat then is else map flipQ is)+ where flipQ (ALL, x) = (EX, x)+ flipQ (EX, x) = (ALL, x)+ skolemize :: [(Quantifier, NamedSymVar)] -> [Either SW (SW, [SW])]+ skolemize qinps = go qinps ([], [])+ where go [] (_, sofar) = reverse sofar+ go ((ALL, (v, _)):rest) (us, sofar) = go rest (v:us, Left v : sofar)+ go ((EX, (v, _)):rest) (us, sofar) = go rest (us, Right (v, reverse us) : sofar)+ return (is, uiMap, skolemMap, converter isSat comments is skolemMap consts tbls arrs uis axs pgm o) Result _is _consts _tbls _arrs _uis _axs _pgm os -> case length os of 0 -> error $ "Impossible happened, unexpected non-outputting result\n" ++ show res 1 -> error $ "Impossible happened, non-boolean output in " ++ show os
Data/SBV/Provers/SExpr.hs view
@@ -14,7 +14,7 @@ import Control.Monad.Error () -- for Monad (Either String) instance import Data.Char (isDigit, ord)-import Numeric (readInt, readDec)+import Numeric (readInt, readDec, readHex) data SExpr = S_Con String | S_Num Integer@@ -46,7 +46,9 @@ parseApp toks (t : sofar) pTok ('0':'b':r) = mkNum $ readInt 2 (`elem` "01") (\c -> ord c - ord '0') r pTok ('b':'v':r) = mkNum $ readDec (takeWhile (/= '[') r)+ pTok ('#':'b':r) = mkNum $ readInt 2 (`elem` "01") (\c -> ord c - ord '0') r+ pTok ('#':'x':r) = mkNum $ readHex r pTok n | all isDigit n = mkNum $ readDec n- pTok n = return $ S_Con $ n+ pTok n = return $ S_Con n mkNum [(n, "")] = return $ S_Num n mkNum _ = die "cannot read number"
Data/SBV/Provers/Yices.hs view
@@ -12,16 +12,17 @@ {-# LANGUAGE PatternGuards #-} -module Data.SBV.Provers.Yices(yices, timeout) where+module Data.SBV.Provers.Yices(yices) where import Data.Char (isDigit) import Data.List (sortBy, isPrefixOf, intercalate, transpose, partition)-import Data.Maybe (catMaybes, isJust, fromJust)+import Data.Maybe (mapMaybe, isNothing, fromJust) import System.Environment (getEnv) import Data.SBV.BitVectors.Data import Data.SBV.Provers.SExpr import Data.SBV.SMT.SMT+import Data.SBV.SMT.SMTLib -- | The description of the Yices SMT solver -- The default executable is @\"yices\"@, which must be in your path. You can use the @SBV_YICES@ environment variable to point to the executable on your system.@@ -32,31 +33,24 @@ , executable = "yices" -- , options = ["-tc", "-smt", "-e"] -- For Yices1 , options = ["-m", "-f"] -- For Yices2- , engine = \cfg inps modelMap pgm -> do- execName <- getEnv "SBV_YICES" `catch` (\_ -> return (executable (solver cfg)))- execOpts <- (words `fmap` (getEnv "SBV_YICES_OPTIONS")) `catch` (\_ -> return (options (solver cfg)))- let cfg' = cfg { solver = (solver cfg) {executable = execName, options = execOpts} }- standardSolver cfg' pgm (ProofError cfg) (interpret cfg inps modelMap)+ , engine = \cfg _isSat qinps modelMap _skolemMap pgm -> do+ execName <- getEnv "SBV_YICES" `catch` (\_ -> return (executable (solver cfg)))+ execOpts <- (words `fmap` getEnv "SBV_YICES_OPTIONS") `catch` (\_ -> return (options (solver cfg)))+ let cfg' = cfg { solver = (solver cfg) {executable = execName, options = addTimeOut (timeOut cfg) execOpts} }+ script = SMTScript { scriptBody = pgm, scriptModel = Nothing }+ standardSolver cfg' script id (ProofError cfg) (interpretSolverOutput cfg (extractMap (map snd qinps) modelMap)) }--timeout :: Int -> SMTSolver -> SMTSolver-timeout n s- | n <= 0 = error $ "Yices.timeout value should be > 0, received: " ++ show n- | True = s{options = options s ++ ["-t", show n]}+ where addTimeOut Nothing o = o+ addTimeOut (Just i) o+ | i < 0 = error $ "Yices: Timeout value must be non-negative, received: " ++ show i+ | True = o ++ ["-t", show i] sortByNodeId :: [(Int, a)] -> [(Int, a)] sortByNodeId = sortBy (\(x, _) (y, _) -> compare x y) -interpret :: SMTConfig -> [NamedSymVar] -> [(String, UnintKind)] -> [String] -> SMTResult-interpret cfg _ _ ("unsat":_) = Unsatisfiable cfg-interpret cfg inps modelMap ("unknown":rest) = Unknown cfg $ extractMap inps modelMap rest-interpret cfg inps modelMap ("sat":rest) = Satisfiable cfg $ extractMap inps modelMap rest-interpret cfg _ _ ("timeout":_) = TimeOut cfg-interpret cfg _ _ ls = ProofError cfg $ ls- extractMap :: [NamedSymVar] -> [(String, UnintKind)] -> [String] -> SMTModel extractMap inps modelMap solverLines =- SMTModel { modelAssocs = map (\(_, y) -> y) $ sortByNodeId $ concatMap (getCounterExample inps) modelLines+ SMTModel { modelAssocs = map snd $ sortByNodeId $ concatMap (getCounterExample inps) modelLines , modelUninterps = [(n, ls) | (UFun _ n, ls) <- uis] , modelArrays = [(n, ls) | (UArr _ n, ls) <- uis] }@@ -88,9 +82,9 @@ extract _ = [] extractUnints :: [(String, UnintKind)] -> [String] -> [(UnintKind, [String])]-extractUnints modelMap = catMaybes . map (extractUnint modelMap) . chunks+extractUnints modelMap = mapMaybe (extractUnint modelMap) . chunks where chunks [] = []- chunks (x:xs) = let (f, r) = span (not . ("---" `isPrefixOf`)) xs in (x:f) : chunks r+ chunks (x:xs) = let (f, r) = break ("---" `isPrefixOf`) xs in (x:f) : chunks r -- Parsing the Yices output is done extremely crudely and designed -- mostly by observation of Yices output. Likely to have bugs and@@ -99,7 +93,7 @@ extractUnint _ [] = Nothing extractUnint mmap (tag : rest) | null tag' = Nothing- | not (isJust mbKnd) = Nothing+ | isNothing mbKnd = Nothing | True = mapM (getUIVal knd) rest >>= \xs -> return (knd, format knd xs) where mbKnd | "--- uninterpreted_" `isPrefixOf` tag = uf `lookup` mmap | True = af `lookup` mmap@@ -115,8 +109,8 @@ = getDefaultVal knd (dropWhile (/= ' ') s) | True = case parseSExpr s of- Right (S_App [S_Con "=", (S_App (S_Con _ : args)), S_Num i]) -> getCallVal knd args i- Right (S_App [S_Con "=", S_Con _, S_Num i]) -> getCallVal knd [] i+ Right (S_App [S_Con "=", S_App (S_Con _ : args), S_Num i]) -> getCallVal knd args i+ Right (S_App [S_Con "=", S_Con _, S_Num i]) -> getCallVal knd [] i _ -> Nothing getDefaultVal :: UnintKind -> String -> Maybe (String, [String], String)@@ -145,6 +139,6 @@ fmtFun :: [(String, [String], String)] -> [String] fmtFun ls = map fmt ls- where fmt (f, as, r) = f ++ " " ++ unwords (map align (zip as (lens ++ repeat 0))) ++ " = " ++ r- lens = map (maximum . (0:)) $ map (map length) $ transpose [as | (_, as, _) <- ls]- align (s, i) = take (i `max` length s) (s ++ repeat ' ')+ where fmt (f, as, r) = f ++ " " ++ unwords (zipWith align as (lens ++ repeat 0)) ++ " = " ++ r+ lens = map (maximum . (0:) . map length) $ transpose [as | (_, as, _) <- ls]+ align s i = take (i `max` length s) (s ++ repeat ' ')
+ Data/SBV/Provers/Z3.hs view
@@ -0,0 +1,94 @@+-----------------------------------------------------------------------------+-- |+-- Module : Data.SBV.Provers.Z3+-- Copyright : (c) Levent Erkok+-- License : BSD3+-- Maintainer : erkokl@gmail.com+-- Stability : experimental+-- Portability : portable+--+-- The connection to the Z3 SMT solver+-----------------------------------------------------------------------------++{-# LANGUAGE PatternGuards #-}++module Data.SBV.Provers.Z3(z3) where++import Data.Char (isDigit)+import Data.List (sortBy, intercalate, isPrefixOf)+import System.Environment (getEnv)+import qualified System.Info as S(os)++import Data.SBV.BitVectors.Data+import Data.SBV.Provers.SExpr+import Data.SBV.SMT.SMT+import Data.SBV.SMT.SMTLib++-- | The description of the Z3 SMT solver+-- The default executable is @\"z3\"@, which must be in your path. You can use the @SBV_Z3@ environment variable to point to the executable on your system.+-- The default options are @\"\/in \/smt2\"@, which is valid for Z3 3.2. You can use the @SBV_Z3_OPTIONS@ environment variable to override the options.+z3 :: SMTSolver+z3 = SMTSolver {+ name = "z3"+ , executable = "z3"+ , options = if S.os == "linux" then ["-in", "-smt2"] else ["/in", "/smt2"]+ , engine = \cfg isSat qinps modelMap skolemMap pgm -> do+ execName <- getEnv "SBV_Z3" `catch` (\_ -> return (executable (solver cfg)))+ execOpts <- (words `fmap` getEnv "SBV_Z3_OPTIONS") `catch` (\_ -> return (options (solver cfg)))+ let cfg' = cfg { solver = (solver cfg) {executable = execName, options = addTimeOut (timeOut cfg) execOpts} }+ script = SMTScript { scriptBody = "(set-option :mbqi true)\n" ++ pgm, scriptModel = Just (cont skolemMap)}+ standardSolver cfg' script cleanErrs (ProofError cfg) (interpretSolverOutput cfg (extractMap isSat qinps modelMap . zipWith match skolemMap))+ }+ where -- This is quite crude and failure prone.. But is necessary to get z3 working through Wine on Mac+ cleanErrs = intercalate "\n" . filter (not . junk) . lines+ junk "fixme:heap:HeapSetInformation 0x0 1 0x0 0" = True+ junk s | "WARNING:" `isPrefixOf` s = True+ junk _ = False+ zero :: Int -> String+ zero 1 = "#b0"+ zero sz = "#x" ++ replicate (sz `div` 4) '0'+ cont skolemMap = intercalate "\n" $ map extract skolemMap+ where extract (Left s) = "(echo \"((" ++ show s ++ " " ++ zero (sizeOf s) ++ "))\")"+ extract (Right (s, [])) = "(get-value (" ++ show s ++ "))"+ extract (Right (s, ss)) = "(eval (" ++ show s ++ concat [' ' : zero (sizeOf a) | a <- ss] ++ "))"+ match (Left _) l = l+ match (Right (_, [])) l = l+ match (Right (s, _)) l = "((" ++ show s ++ " " ++ l ++ "))"+ addTimeOut Nothing o = o+ addTimeOut (Just i) o+ | i < 0 = error $ "Z3: Timeout value must be non-negative, received: " ++ show i+ | S.os == "linux" = o ++ ["-T:" ++ show i]+ | True = o ++ ["/T:" ++ show i]++extractMap :: Bool -> [(Quantifier, NamedSymVar)] -> [(String, UnintKind)] -> [String] -> SMTModel+extractMap isSat qinps _modelMap solverLines =+ SMTModel { modelAssocs = map snd $ sortByNodeId $ concatMap (getCounterExample inps) solverLines+ , modelUninterps = []+ , modelArrays = []+ }+ where sortByNodeId :: [(Int, a)] -> [(Int, a)]+ sortByNodeId = sortBy (\(x, _) (y, _) -> compare x y)+ inps -- for "sat", display the prefix existentials. For completeness, we will drop+ -- only the trailing foralls. Exception: Don't drop anything if it's all a sequence of foralls+ | isSat = if all (== ALL) (map fst qinps)+ then map snd qinps+ else map snd $ reverse $ dropWhile ((== ALL) . fst) $ reverse qinps+ -- for "proof", just display the prefix universals+ | True = map snd $ takeWhile ((== ALL) . fst) qinps++getCounterExample :: [NamedSymVar] -> String -> [(Int, (String, CW))]+getCounterExample inps line = either err extract (parseSExpr line)+ where err r = error $ "*** Failed to parse SMT-Lib2 model output from: "+ ++ "*** " ++ show line ++ "\n"+ ++ "*** Reason: " ++ r ++ "\n"+ isInput ('s':v)+ | all isDigit v = let inpId :: Int+ inpId = read v+ in case [(s, nm) | (s@(SW _ (NodeId n)), nm) <- inps, n == inpId] of+ [] -> Nothing+ [(s, nm)] -> Just (inpId, s, nm)+ matches -> error $ "SBV.SMTLib2: Cannot uniquely identify value for "+ ++ 's':v ++ " in " ++ show matches+ isInput _ = Nothing+ extract (S_App [S_App [S_Con v, S_Num i]]) | Just (n, s, nm) <- isInput v = [(n, (nm, mkConstCW (hasSign s, sizeOf s) i))]+ extract _ = []
Data/SBV/SMT/SMT.hs view
@@ -14,29 +14,37 @@ module Data.SBV.SMT.SMT where -import Control.DeepSeq (NFData(..))-import Control.Monad (when, zipWithM)-import Data.Char (isSpace)-import Data.Int (Int8, Int16, Int32, Int64)-import Data.List (intercalate)-import Data.Word (Word8, Word16, Word32, Word64)-import System.Directory (findExecutable)-import System.Process (readProcessWithExitCode)-import System.Exit (ExitCode(..))+import qualified Control.Exception as C +import Control.Concurrent (newEmptyMVar, takeMVar, putMVar, forkIO)+import Control.DeepSeq (NFData(..))+import Control.Monad (when, zipWithM)+import Data.Char (isSpace)+import Data.Int (Int8, Int16, Int32, Int64)+import Data.List (intercalate, isPrefixOf)+import Data.Maybe (isNothing, fromJust)+import Data.Word (Word8, Word16, Word32, Word64)+import System.Directory (findExecutable)+import System.Process (readProcessWithExitCode, runInteractiveProcess, waitForProcess)+import System.Exit (ExitCode(..))+import System.IO (hClose, hFlush, hPutStr, hGetContents, hGetLine)+ import Data.SBV.BitVectors.Data import Data.SBV.BitVectors.PrettyNum import Data.SBV.Utils.TDiff -- | Solver configuration data SMTConfig = SMTConfig {- verbose :: Bool -- ^ Debug mode- , timing :: Bool -- ^ Print timing information on how long different phases took (construction, solving, etc.)- , printBase :: Int -- ^ Print literals in this base- , solver :: SMTSolver -- ^ The actual SMT solver+ verbose :: Bool -- ^ Debug mode+ , timing :: Bool -- ^ Print timing information on how long different phases took (construction, solving, etc.)+ , timeOut :: Maybe Int -- ^ How much time to give to the solver. (In seconds)+ , printBase :: Int -- ^ Print literals in this base+ , solver :: SMTSolver -- ^ The actual SMT solver+ , smtFile :: Maybe FilePath -- ^ If Just, the generated SMT script will be put in this file (for debugging purposes mostly)+ , useSMTLib2 :: Bool -- ^ If True, we'll treat the solver as using SMTLib2 input format. Otherwise, SMTLib1 } -type SMTEngine = SMTConfig -> [NamedSymVar] -> [(String, UnintKind)] -> String -> IO SMTResult+type SMTEngine = SMTConfig -> Bool -> [(Quantifier, NamedSymVar)] -> [(String, UnintKind)] -> [Either SW (SW, [SW])] -> String -> IO SMTResult -- | An SMT solver data SMTSolver = SMTSolver {@@ -65,6 +73,12 @@ | ProofError SMTConfig [String] -- ^ Prover errored out | TimeOut SMTConfig -- ^ Computation timed out (see the 'timeout' combinator) +-- | A script, to be passed to the solver.+data SMTScript = SMTScript {+ scriptBody :: String -- ^ Initial feed+ , scriptModel :: Maybe String -- ^ Optional continuation script, if the result is sat+ }+ resultConfig :: SMTResult -> SMTConfig resultConfig (Unsatisfiable c) = c resultConfig (Satisfiable c _) = c@@ -89,8 +103,9 @@ -- The reason for having a separate 'SatResult' is to have a more meaningful 'Show' instance. newtype SatResult = SatResult SMTResult --- | An 'allSat' call results in a 'AllSatResult'-newtype AllSatResult = AllSatResult [SMTResult]+-- | An 'allSat' call results in a 'AllSatResult'. The boolean says whether+-- we should warn the user about prefix-existentials.+newtype AllSatResult = AllSatResult (Bool, [SMTResult]) instance Show ThmResult where show (ThmResult r) = showSMTResult "Q.E.D."@@ -103,17 +118,25 @@ "Satisfiable" "Satisfiable. Model:\n" r +-- NB. The Show instance of AllSatResults have to be careful in being lazy enough+-- as the typical use case is to pull results out as they become available. instance Show AllSatResult where- show (AllSatResult []) = "No solutions found"- show (AllSatResult [s]) = "Only one solution found:\n" ++ shUnique s- where shUnique = showSMTResult "Unsatisfiable"- ("Unknown (No assignment to variables returned)") "Unknown. Potential assignment:\n" "" ""- show (AllSatResult ss) = "Multiple solutions found:\n" -- shouldn't display how-many; would be too slow/leak-space to compute everything..- ++ unlines (zipWith sh [(1::Int)..] ss)- ++ "Done."- where sh i = showSMTResult "Unsatisfiable"- ("Unknown #" ++ show i ++ "(No assignment to variables returned)") "Unknown. Potential assignment:\n"- ("Solution #" ++ show i ++ " (No assignment to variables returned)") ("Solution #" ++ show i ++ ":\n")+ show (AllSatResult (e, xs)) = go (0::Int) xs+ where uniqueWarn | e = " (Unique up to prefix existentials.)"+ | True = ""+ go c (s:ss) = let c' = c+1+ (ok, o) = sh c' s+ in c' `seq` if ok then o ++ "\n" ++ go c' ss else o+ go c [] = case c of+ 0 -> "No solutions found."+ 1 -> "This is the only solution." ++ uniqueWarn+ _ -> "Found " ++ show c ++ " different solutions." ++ uniqueWarn+ sh i c = (ok, showSMTResult "Unsatisfiable"+ ("Unknown #" ++ show i ++ "(No assignment to variables returned)") "Unknown. Potential assignment:\n"+ ("Solution #" ++ show i ++ " (No assignment to variables returned)") ("Solution #" ++ show i ++ ":\n") c)+ where ok = case c of+ Satisfiable{} -> True+ _ -> False -- | Instances of 'SatModel' can be automatically extracted from models returned by the -- solvers. The idea is that the sbv infrastructure provides a stream of 'CW''s (constant-words)@@ -205,22 +228,22 @@ return ((a, b, c, d, e, f, g), hs) -- | Given an 'SMTResult', extract an arbitrarily typed model from it, given a 'SatModel' instance-getModel :: SatModel a => SMTResult -> a-getModel (Unsatisfiable _) = error "SatModel.getModel: Unsatisfiable result"-getModel (Unknown _ _) = error "Impossible! Backend solver returned unknown for Bit-vector problem!"-getModel (ProofError _ s) = error $ unlines $ "An error happened: " : s-getModel (TimeOut _) = error $ "Timeout"-getModel (Satisfiable _ m) = case parseCWs [c | (_, c) <- modelAssocs m] of- Just (x, []) -> x- Just (_, ys) -> error $ "SBV.getModel: Partially constructed model; remaining elements: " ++ show ys- Nothing -> error $ "SBV.getModel: Cannot construct a model from: " ++ show m+getModel :: SatModel a => SatResult -> Either String a+getModel (SatResult (Unsatisfiable _)) = Left "SatModel.getModel: Unsatisfiable result"+getModel (SatResult (Unknown _ _)) = error "Impossible! Backend solver returned unknown for Bit-vector problem!"+getModel (SatResult (ProofError _ s)) = error $ unlines $ "Backend solver complains: " : s+getModel (SatResult (TimeOut _)) = Left "Timeout"+getModel (SatResult (Satisfiable _ m)) = case parseCWs [c | (_, c) <- modelAssocs m] of+ Just (x, []) -> Right x+ Just (_, ys) -> error $ "SBV.getModel: Partially constructed model; remaining elements: " ++ show ys+ Nothing -> error $ "SBV.getModel: Cannot construct a model from: " ++ show m -- | Given an 'allSat' call, we typically want to iterate over it and print the results in sequence. The -- 'displayModels' function automates this task by calling 'disp' on each result, consecutively. The first -- 'Int' argument to 'disp' 'is the current model number. displayModels :: SatModel a => (Int -> a -> IO ()) -> AllSatResult -> IO Int-displayModels disp (AllSatResult ms) = do- inds <- zipWithM display (map getModel ms) [(1::Int)..]+displayModels disp (AllSatResult (_, ms)) = do+ inds <- zipWithM display [a | Right a <- map (getModel . SatResult) ms] [(1::Int)..] return $ last (0:inds) where display r i = disp i r >> return i @@ -264,18 +287,19 @@ shUA (f, cases) = (" -- array: " ++ f) : map shC cases where shC s = " " ++ s -pipeProcess :: String -> String -> [String] -> String -> IO (Either String [String])-pipeProcess nm execName opts script = do+pipeProcess :: Bool -> String -> String -> [String] -> SMTScript -> (String -> String) -> IO (Either String [String])+pipeProcess verb nm execName opts script cleanErrs = do mbExecPath <- findExecutable execName case mbExecPath of Nothing -> return $ Left $ "Unable to locate executable for " ++ nm ++ "\nExecutable specified: " ++ show execName- Just execPath -> do (ec, contents, errors) <- readProcessWithExitCode execPath opts script+ Just execPath -> do (ec, contents, allErrors) <- runSolver verb execPath opts script+ let errors = dropWhile isSpace (cleanErrs allErrors) case ec of ExitSuccess -> if null errors then return $ Right $ map clean (filter (not . null) (lines contents)) else return $ Left errors- ExitFailure n -> let errors' = if null (dropWhile isSpace errors)+ ExitFailure n -> let errors' = if null errors then (if null (dropWhile isSpace contents) then "(No error message printed on stderr by the executable.)" else contents)@@ -290,10 +314,10 @@ ++ "\n" ++ line ++ "\nGiving up.." where clean = reverse . dropWhile isSpace . reverse . dropWhile isSpace- line = take 78 $ repeat '='+ line = replicate 78 '=' -standardSolver :: SMTConfig -> String -> ([String] -> a) -> ([String] -> a) -> IO a-standardSolver config script failure success = do+standardSolver :: SMTConfig -> SMTScript -> (String -> String) -> ([String] -> a) -> ([String] -> a) -> IO a+standardSolver config script cleanErrs failure success = do let msg = when (verbose config) . putStrLn . ("** " ++) smtSolver= solver config exec = executable smtSolver@@ -301,8 +325,46 @@ isTiming = timing config nmSolver = name smtSolver msg $ "Calling: " ++ show (unwords (exec:opts))- contents <- timeIf isTiming nmSolver $ pipeProcess nmSolver exec opts script+ case smtFile config of+ Nothing -> return ()+ Just f -> do putStrLn $ "** Saving the generated script in file: " ++ show f+ writeFile f (scriptBody script)+ contents <- timeIf isTiming nmSolver $ pipeProcess (verbose config) nmSolver exec opts script cleanErrs msg $ nmSolver ++ " output:\n" ++ either id (intercalate "\n") contents case contents of Left e -> return $ failure (lines e) Right xs -> return $ success xs++-- A variant of readProcessWithExitCode; except it knows about continuation strings+-- and can speak SMT-Lib2 (just a little)+runSolver :: Bool -> FilePath -> [String] -> SMTScript -> IO (ExitCode, String, String)+runSolver verb execPath opts script+ | isNothing $ scriptModel script+ = readProcessWithExitCode execPath opts (scriptBody script)+ | True+ = do (send, ask, cleanUp) <- do+ (inh, outh, errh, pid) <- runInteractiveProcess execPath opts Nothing Nothing+ let send l = hPutStr inh (l ++ "\n") >> hFlush inh+ recv = hGetLine outh+ ask l = send l >> recv+ cleanUp r = do outMVar <- newEmptyMVar+ out <- hGetContents outh+ _ <- forkIO $ C.evaluate (length out) >> putMVar outMVar ()+ err <- hGetContents errh+ _ <- forkIO $ C.evaluate (length err) >> putMVar outMVar ()+ hClose inh+ takeMVar outMVar+ takeMVar outMVar+ hClose outh+ hClose errh+ ex <- waitForProcess pid+ return (ex, r ++ "\n" ++ out, err)+ return (send, ask, cleanUp)+ mapM_ send (lines (scriptBody script))+ r <- ask "(check-sat)"+ when ("sat" `isPrefixOf` r) $ do+ let mls = lines (fromJust (scriptModel script))+ when verb $ do putStrLn "** Sending the following model extraction commands:"+ mapM_ putStrLn mls+ mapM_ send mls+ cleanUp r
Data/SBV/SMT/SMTLib.hs view
@@ -9,216 +9,41 @@ -- -- Conversion of symbolic programs to SMTLib format ------------------------------------------------------------------------------{-# LANGUAGE PatternGuards #-} -module Data.SBV.SMT.SMTLib(SMTLibPgm, toSMTLib, addNonEqConstraints) where--import Control.DeepSeq (NFData(..))-import qualified Data.Foldable as F (toList)-import Data.List (intercalate)+module Data.SBV.SMT.SMTLib(SMTLibPgm, SMTLibConverter, toSMTLib1, toSMTLib2, addNonEqConstraints, interpretSolverOutput) where import Data.SBV.BitVectors.Data--newtype SMTLibPgm = SMTLibPgm ([(String, SW)], [String], [String])-instance NFData SMTLibPgm--instance Show SMTLibPgm where- show (SMTLibPgm (_, pre, post)) = intercalate "\n" $ pre ++ post--addNonEqConstraints :: [[(String, CW)]] -> SMTLibPgm -> String-addNonEqConstraints nonEqConstraints (SMTLibPgm (aliasTable, pre, post)) = intercalate "\n" $- pre- ++ [ " ; --- refuted-models ---" ]- ++ concatMap nonEqs (map (map intName) nonEqConstraints)- ++ post- where intName (s, c)- | Just sw <- s `lookup` aliasTable = (show sw, c)- | True = (s, c)--toSMTLib :: Bool -- ^ is this a sat problem?- -> [String] -- ^ extra comments to place on top- -> [(SW, String)] -- ^ inputs and aliasing names- -> [(SW, CW)] -- ^ constants- -> [((Int, (Bool, Int), (Bool, Int)), [SW])] -- ^ auto-generated tables- -> [(Int, ArrayInfo)] -- ^ user specified arrays- -> [(String, SBVType)] -- ^ uninterpreted functions/constants- -> [(String, [String])] -- ^ user given axioms- -> Pgm -- ^ assignments- -> SW -- ^ output variable- -> SMTLibPgm-toSMTLib isSat comments inps consts tbls arrs uis axs asgnsSeq out = SMTLibPgm (aliasTable, pre, post)- where logic- | null tbls && null arrs && null uis = "QF_BV"- | True = "QF_AUFBV"- pre = [ "; Automatically generated by SBV. Do not edit." ]- ++ map ("; " ++) comments- ++ ["(benchmark sbv"- , " :logic " ++ logic- , " :status unknown"- , " ; --- inputs ---"- ]- ++ map decl (map fst inps)- ++ [ " ; --- declarations ---" ]- ++ map (decl . fst) consts- ++ map (decl . fst) asgns- ++ [ " ; --- constants ---" ]- ++ map cvtCnst consts- ++ [ " ; --- tables ---" ]- ++ concatMap mkTable tbls- ++ [ " ; --- arrays ---" ]- ++ concatMap declArray arrs- ++ [ " ; --- uninterpreted constants ---" ]- ++ concatMap declUI uis- ++ [ " ; --- user given axioms ---" ]- ++ map declAx axs- ++ [ " ; --- assignments ---" ]- ++ map cvtAsgn asgns- post = [ " ; --- formula ---" ]- ++ [mkFormula isSat out]- ++ [")"]- aliasTable = map (\(x, y) -> (y, x)) inps- asgns = F.toList asgnsSeq---- TODO: Does this work for SMT-Lib when the index/element types are signed?--- Currently we ignore the signedness of the arguments, as there appears to be no way--- to capture that in SMT-Lib; and likely it does not matter. Would be good to check--- explicitly though.-mkTable :: ((Int, (Bool, Int), (Bool, Int)), [SW]) -> [String]-mkTable ((i, (_, at), (_, rt)), elts) = (" :extrafuns ((" ++ t ++ " Array[" ++ show at ++ ":" ++ show rt ++ "]))") : zipWith mkElt elts [(0::Int)..]- where t = "table" ++ show i- mkElt x k = " :assumption (= (select " ++ t ++ " bv" ++ show k ++ "[" ++ show at ++ "]) " ++ show x ++ ")"--declArray :: (Int, ArrayInfo) -> [String]-declArray (i, (_, ((_, at), (_, rt)), ctx)) = adecl : ctxInfo- where nm = "array_" ++ show i- adecl = " :extrafuns ((" ++ nm ++ " Array[" ++ show at ++ ":" ++ show rt ++ "]))"- ctxInfo = case ctx of- ArrayFree Nothing -> []- ArrayFree (Just sw) -> declA sw- ArrayReset _ sw -> declA sw- ArrayMutate j a b -> [" :assumption (= " ++ nm ++ " (store array_" ++ show j ++ " " ++ show a ++ " " ++ show b ++ "))"]- ArrayMerge t j k -> [" :assumption (= " ++ nm ++ " (ite (= bv1[1] " ++ show t ++ ") array_" ++ show j ++ " array_" ++ show k ++ "))"]- declA sw = let iv = nm ++ "_freeInitializer"- in [ " :extrafuns ((" ++ iv ++ " BitVec[" ++ show at ++ "]))"- , " :assumption (= (select " ++ nm ++ " " ++ iv ++ ") " ++ show sw ++ ")"- ]--declAx :: (String, [String]) -> String-declAx (nm, ls) = (" ;; -- user given axiom: " ++ nm ++ "\n ") ++ intercalate "\n " ls--declUI :: (String, SBVType) -> [String]-declUI (i, t) = [" :extrafuns ((uninterpreted_" ++ i ++ " " ++ cvtType t ++ "))"]--mkFormula :: Bool -> SW -> String-mkFormula isSat s- | isSat = " :formula (= " ++ show s ++ " bv1[1])"- | True = " :formula (= " ++ show s ++ " bv0[1])"--nonEqs :: [(String, CW)] -> [String]-nonEqs [] = []-nonEqs [sc] = [" :assumption " ++ nonEq sc]-nonEqs (sc:r) = [" :assumption (or " ++ nonEq sc]- ++ map ((" " ++) . nonEq) r- ++ [" )"]--nonEq :: (String, CW) -> String-nonEq (s, c) = "(not (= " ++ s ++ " " ++ cvtCW c ++ "))"---- SMTLib represents signed/unsigned quantities with the same type-decl :: SW -> String-decl s = " :extrafuns ((" ++ show s ++ " BitVec[" ++ show (sizeOf s) ++ "]))"--cvtAsgn :: (SW, SBVExpr) -> String-cvtAsgn (s, e) = " :assumption (= " ++ show s ++ " " ++ cvtExp e ++ ")"--cvtCnst :: (SW, CW) -> String-cvtCnst (s, c) = " :assumption (= " ++ show s ++ " " ++ cvtCW c ++ ")"--cvtCW :: CW -> String-cvtCW x | not (hasSign x) = "bv" ++ show (cwVal x) ++ "[" ++ show (sizeOf x) ++ "]"--- signed numbers (with 2's complement representation) is problematic--- since there's no way to put a bvneg over a positive number to get minBound..--- Hence, we punt and use binary notation in that particular case-cvtCW x | cwVal x == least = mkMinBound (sizeOf x)- where least = negate (2 ^ sizeOf x)-cvtCW x = negIf (w < 0) $ "bv" ++ show (abs w) ++ "[" ++ show (sizeOf x) ++ "]"- where w = cwVal x--negIf :: Bool -> String -> String-negIf True a = "(bvneg " ++ a ++ ")"-negIf False a = a---- anamoly at the 2's complement min value! Have to use binary notation here--- as there is no positive value we can provide to make the bvneg work.. (see above)-mkMinBound :: Int -> String-mkMinBound i = "bv1" ++ take (i-1) (repeat '0') ++ "[" ++ show i ++ "]"+import Data.SBV.SMT.SMT+import qualified Data.SBV.SMT.SMTLib1 as SMT1+import qualified Data.SBV.SMT.SMTLib2 as SMT2 -rot :: String -> Int -> SW -> String-rot o c x = "(" ++ o ++ "[" ++ show c ++ "] " ++ show x ++ ")"+type SMTLibConverter = Bool -- ^ is this a sat problem?+ -> [String] -- ^ extra comments to place on top+ -> [(Quantifier, NamedSymVar)] -- ^ inputs and aliasing names+ -> [Either SW (SW, [SW])] -- ^ skolemized inputs+ -> [(SW, CW)] -- ^ constants+ -> [((Int, (Bool, Int), (Bool, Int)), [SW])] -- ^ auto-generated tables+ -> [(Int, ArrayInfo)] -- ^ user specified arrays+ -> [(String, SBVType)] -- ^ uninterpreted functions/constants+ -> [(String, [String])] -- ^ user given axioms+ -> Pgm -- ^ assignments+ -> SW -- ^ output variable+ -> SMTLibPgm -shft :: String -> String -> Int -> SW -> String-shft oW oS c x= "(" ++ o ++ " " ++ show x ++ " " ++ cvtCW c' ++ ")"- where s = hasSign x- c' = mkConstCW (s, sizeOf x) c- o = if hasSign x then oS else oW+toSMTLib1, toSMTLib2 :: SMTLibConverter+(toSMTLib1, toSMTLib2) = (cvt SMTLib1, cvt SMTLib2)+ where cvt v isSat comments qinps skolemMap consts tbls arrs uis axs asgnsSeq out = SMTLibPgm v (aliasTable, pre, post)+ where aliasTable = map (\(_, (x, y)) -> (y, x)) qinps+ converter = if v == SMTLib1 then SMT1.cvt else SMT2.cvt+ (pre, post) = converter isSat comments qinps skolemMap consts tbls arrs uis axs asgnsSeq out -cvtExp :: SBVExpr -> String-cvtExp (SBVApp Ite [a, b, c]) = "(ite (= bv1[1] " ++ show a ++ ") " ++ show b ++ " " ++ show c ++ ")"-cvtExp (SBVApp (Rol i) [a]) = rot "rotate_left" i a-cvtExp (SBVApp (Ror i) [a]) = rot "rotate_right" i a-cvtExp (SBVApp (Shl i) [a]) = shft "bvshl" "bvshl" i a-cvtExp (SBVApp (Shr i) [a]) = shft "bvlshr" "bvashr" i a-cvtExp (SBVApp (LkUp (t, (_, at), _, l) i e) [])- | needsCheck = "(ite " ++ cond ++ show e ++ " " ++ lkUp ++ ")"- | True = lkUp- where needsCheck = (2::Integer)^(at) > (fromIntegral l)- lkUp = "(select table" ++ show t ++ " " ++ show i ++ ")"- cond- | hasSign i = "(or " ++ le0 ++ " " ++ gtl ++ ") "- | True = gtl ++ " "- (less, leq) = if hasSign i then ("bvslt", "bvsle") else ("bvult", "bvule")- mkCnst = cvtCW . mkConstCW (hasSign i, sizeOf i)- le0 = "(" ++ less ++ " " ++ show i ++ " " ++ mkCnst 0 ++ ")"- gtl = "(" ++ leq ++ " " ++ mkCnst l ++ " " ++ show i ++ ")"-cvtExp (SBVApp (Extract i j) [a]) = "(extract[" ++ show i ++ ":" ++ show j ++ "] " ++ show a ++ ")"-cvtExp (SBVApp (ArrEq i j) []) = "(ite (= array_" ++ show i ++ " array_" ++ show j ++") bv1[1] bv0[1])"-cvtExp (SBVApp (ArrRead i) [a]) = "(select array_" ++ show i ++ " " ++ show a ++ ")"-cvtExp (SBVApp (Uninterpreted nm) []) = "uninterpreted_" ++ nm-cvtExp (SBVApp (Uninterpreted nm) args) = "(uninterpreted_" ++ nm ++ " " ++ intercalate " " (map show args) ++ ")"-cvtExp inp@(SBVApp op args)- | Just f <- lookup op smtOpTable- = f (any hasSign args) (map show args)- | True- = error $ "SBV.SMT.SMTLib.cvtExp: impossible happened; can't translate: " ++ show inp- where lift2 o _ [x, y] = "(" ++ o ++ " " ++ x ++ " " ++ y ++ ")"- lift2 o _ sbvs = error $ "SBV.SMTLib.cvtExp.lift2: Unexpected arguments: " ++ show (o, sbvs)- lift2B oU oS sgn sbvs- | sgn- = "(ite " ++ lift2 oS sgn sbvs ++ " bv1[1] bv0[1])"- | True- = "(ite " ++ lift2 oU sgn sbvs ++ " bv1[1] bv0[1])"- lift2N o sgn sbvs = "(bvnot " ++ lift2 o sgn sbvs ++ ")"- lift1 o _ [x] = "(" ++ o ++ " " ++ x ++ ")"- lift1 o _ sbvs = error $ "SBV.SMT.SMTLib.cvtExp.lift1: Unexpected arguments: " ++ show (o, sbvs)- smtOpTable = [ (Plus, lift2 "bvadd")- , (Minus, lift2 "bvsub")- , (Times, lift2 "bvmul")- , (Quot, lift2 "bvudiv")- , (Rem, lift2 "bvurem")- , (Equal, lift2 "bvcomp")- , (NotEqual, lift2N "bvcomp")- , (LessThan, lift2B "bvult" "bvslt")- , (GreaterThan, lift2B "bvugt" "bvsgt")- , (LessEq, lift2B "bvule" "bvsle")- , (GreaterEq, lift2B "bvuge" "bvsge")- , (And, lift2 "bvand")- , (Or, lift2 "bvor")- , (XOr, lift2 "bvxor")- , (Not, lift1 "bvnot")- , (Join, lift2 "concat")- ]+addNonEqConstraints :: [(Quantifier, NamedSymVar)] -> [[(String, CW)]] -> SMTLibPgm -> Maybe String+addNonEqConstraints _qinps cs p@(SMTLibPgm SMTLib1 _) = SMT1.addNonEqConstraints cs p+addNonEqConstraints qinps cs p@(SMTLibPgm SMTLib2 _) = SMT2.addNonEqConstraints qinps cs p -cvtType :: SBVType -> String-cvtType (SBVType []) = error "SBV.SMT.SMTLib.cvtType: internal: received an empty type!"-cvtType (SBVType xs) = intercalate " " $ map sh xs- where sh (_, s) = "BitVec[" ++ show s ++ "]"+interpretSolverOutput :: SMTConfig -> ([String] -> SMTModel) -> [String] -> SMTResult+interpretSolverOutput cfg _ ("unsat":_) = Unsatisfiable cfg+interpretSolverOutput cfg extractMap ("unknown":rest) = Unknown cfg $ extractMap rest+interpretSolverOutput cfg extractMap ("sat":rest) = Satisfiable cfg $ extractMap rest+interpretSolverOutput cfg _ ("timeout":_) = TimeOut cfg+interpretSolverOutput cfg _ ls = ProofError cfg ls
+ Data/SBV/SMT/SMTLib1.hs view
@@ -0,0 +1,225 @@+-----------------------------------------------------------------------------+-- |+-- Module : Data.SBV.SMT.SMTLib1+-- Copyright : (c) Levent Erkok+-- License : BSD3+-- Maintainer : erkokl@gmail.com+-- Stability : experimental+-- Portability : portable+--+-- Conversion of symbolic programs to SMTLib format, Using v1 of the standard+-----------------------------------------------------------------------------+{-# LANGUAGE PatternGuards #-}++module Data.SBV.SMT.SMTLib1(cvt, addNonEqConstraints) where++import qualified Data.Foldable as F (toList)+import Data.List (intercalate)++import Data.SBV.BitVectors.Data++addNonEqConstraints :: [[(String, CW)]] -> SMTLibPgm -> Maybe String+addNonEqConstraints nonEqConstraints (SMTLibPgm _ (aliasTable, pre, post)) = Just $ intercalate "\n" $+ pre+ ++ [ " ; --- refuted-models ---" ]+ ++ concatMap nonEqs (map (map intName) nonEqConstraints)+ ++ post+ where intName (s, c)+ | Just sw <- s `lookup` aliasTable = (show sw, c)+ | True = (s, c)++nonEqs :: [(String, CW)] -> [String]+nonEqs [] = []+nonEqs [sc] = [" :assumption " ++ nonEq sc]+nonEqs (sc:r) = [" :assumption (or " ++ nonEq sc]+ ++ map ((" " ++) . nonEq) r+ ++ [" )"]++nonEq :: (String, CW) -> String+nonEq (s, c) = "(not (= " ++ s ++ " " ++ cvtCW c ++ "))"++cvt :: Bool -- ^ is this a sat problem?+ -> [String] -- ^ extra comments to place on top+ -> [(Quantifier, NamedSymVar)] -- ^ inputs+ -> [Either SW (SW, [SW])] -- ^ skolemized version of the inputs+ -> [(SW, CW)] -- ^ constants+ -> [((Int, (Bool, Int), (Bool, Int)), [SW])] -- ^ auto-generated tables+ -> [(Int, ArrayInfo)] -- ^ user specified arrays+ -> [(String, SBVType)] -- ^ uninterpreted functions/constants+ -> [(String, [String])] -- ^ user given axioms+ -> Pgm -- ^ assignments+ -> SW -- ^ output variable+ -> ([String], [String])+cvt isSat comments qinps _skolemInps consts tbls arrs uis axs asgnsSeq out+ | not ((isSat && allExistential) || (not isSat && allUniversal))+ = error "SBV: The chosen solver does not support quantified variables. (Use z3 instead.)"+ | True+ = (pre, post)+ where quantifiers = map fst qinps+ allExistential = all (== EX) quantifiers+ allUniversal = all (== ALL) quantifiers+ logic+ | null tbls && null arrs && null uis = "QF_BV"+ | True = "QF_AUFBV"+ inps = map (fst . snd) qinps+ pre = [ "; Automatically generated by SBV. Do not edit." ]+ ++ map ("; " ++) comments+ ++ ["(benchmark sbv"+ , " :logic " ++ logic+ , " :status unknown"+ , " ; --- inputs ---"+ ]+ ++ map decl inps+ ++ [ " ; --- declarations ---" ]+ ++ map (decl . fst) consts+ ++ map (decl . fst) asgns+ ++ [ " ; --- constants ---" ]+ ++ map cvtCnst consts+ ++ [ " ; --- tables ---" ]+ ++ concatMap mkTable tbls+ ++ [ " ; --- arrays ---" ]+ ++ concatMap declArray arrs+ ++ [ " ; --- uninterpreted constants ---" ]+ ++ concatMap declUI uis+ ++ [ " ; --- user given axioms ---" ]+ ++ map declAx axs+ ++ [ " ; --- assignments ---" ]+ ++ map cvtAsgn asgns+ post = [ " ; --- formula ---" ]+ ++ [mkFormula isSat out]+ ++ [")"]+ asgns = F.toList asgnsSeq++-- TODO: Does this work for SMT-Lib when the index/element types are signed?+-- Currently we ignore the signedness of the arguments, as there appears to be no way+-- to capture that in SMT-Lib; and likely it does not matter. Would be good to check+-- explicitly though.+mkTable :: ((Int, (Bool, Int), (Bool, Int)), [SW]) -> [String]+mkTable ((i, (_, at), (_, rt)), elts) = (" :extrafuns ((" ++ t ++ " Array[" ++ show at ++ ":" ++ show rt ++ "]))") : zipWith mkElt elts [(0::Int)..]+ where t = "table" ++ show i+ mkElt x k = " :assumption (= (select " ++ t ++ " bv" ++ show k ++ "[" ++ show at ++ "]) " ++ show x ++ ")"++declArray :: (Int, ArrayInfo) -> [String]+declArray (i, (_, ((_, at), (_, rt)), ctx)) = adecl : ctxInfo+ where nm = "array_" ++ show i+ adecl = " :extrafuns ((" ++ nm ++ " Array[" ++ show at ++ ":" ++ show rt ++ "]))"+ ctxInfo = case ctx of+ ArrayFree Nothing -> []+ ArrayFree (Just sw) -> declA sw+ ArrayReset _ sw -> declA sw+ ArrayMutate j a b -> [" :assumption (= " ++ nm ++ " (store array_" ++ show j ++ " " ++ show a ++ " " ++ show b ++ "))"]+ ArrayMerge t j k -> [" :assumption (= " ++ nm ++ " (ite (= bv1[1] " ++ show t ++ ") array_" ++ show j ++ " array_" ++ show k ++ "))"]+ declA sw = let iv = nm ++ "_freeInitializer"+ in [ " :extrafuns ((" ++ iv ++ " BitVec[" ++ show at ++ "]))"+ , " :assumption (= (select " ++ nm ++ " " ++ iv ++ ") " ++ show sw ++ ")"+ ]++declAx :: (String, [String]) -> String+declAx (nm, ls) = (" ;; -- user given axiom: " ++ nm ++ "\n ") ++ intercalate "\n " ls++declUI :: (String, SBVType) -> [String]+declUI (i, t) = [" :extrafuns ((uninterpreted_" ++ i ++ " " ++ cvtType t ++ "))"]++mkFormula :: Bool -> SW -> String+mkFormula isSat s+ | isSat = " :formula (= " ++ show s ++ " bv1[1])"+ | True = " :formula (= " ++ show s ++ " bv0[1])"++-- SMTLib represents signed/unsigned quantities with the same type+decl :: SW -> String+decl s = " :extrafuns ((" ++ show s ++ " BitVec[" ++ show (sizeOf s) ++ "]))"++cvtAsgn :: (SW, SBVExpr) -> String+cvtAsgn (s, e) = " :assumption (= " ++ show s ++ " " ++ cvtExp e ++ ")"++cvtCnst :: (SW, CW) -> String+cvtCnst (s, c) = " :assumption (= " ++ show s ++ " " ++ cvtCW c ++ ")"++cvtCW :: CW -> String+cvtCW x | not (hasSign x) = "bv" ++ show (cwVal x) ++ "[" ++ show (sizeOf x) ++ "]"+-- signed numbers (with 2's complement representation) is problematic+-- since there's no way to put a bvneg over a positive number to get minBound..+-- Hence, we punt and use binary notation in that particular case+cvtCW x | cwVal x == least = mkMinBound (sizeOf x)+ where least = negate (2 ^ sizeOf x)+cvtCW x = negIf (w < 0) $ "bv" ++ show (abs w) ++ "[" ++ show (sizeOf x) ++ "]"+ where w = cwVal x++negIf :: Bool -> String -> String+negIf True a = "(bvneg " ++ a ++ ")"+negIf False a = a++-- anamoly at the 2's complement min value! Have to use binary notation here+-- as there is no positive value we can provide to make the bvneg work.. (see above)+mkMinBound :: Int -> String+mkMinBound i = "bv1" ++ replicate (i-1) '0' ++ "[" ++ show i ++ "]"++rot :: String -> Int -> SW -> String+rot o c x = "(" ++ o ++ "[" ++ show c ++ "] " ++ show x ++ ")"++shft :: String -> String -> Int -> SW -> String+shft oW oS c x= "(" ++ o ++ " " ++ show x ++ " " ++ cvtCW c' ++ ")"+ where s = hasSign x+ c' = mkConstCW (s, sizeOf x) c+ o = if hasSign x then oS else oW++cvtExp :: SBVExpr -> String+cvtExp (SBVApp Ite [a, b, c]) = "(ite (= bv1[1] " ++ show a ++ ") " ++ show b ++ " " ++ show c ++ ")"+cvtExp (SBVApp (Rol i) [a]) = rot "rotate_left" i a+cvtExp (SBVApp (Ror i) [a]) = rot "rotate_right" i a+cvtExp (SBVApp (Shl i) [a]) = shft "bvshl" "bvshl" i a+cvtExp (SBVApp (Shr i) [a]) = shft "bvlshr" "bvashr" i a+cvtExp (SBVApp (LkUp (t, (_, at), _, l) i e) [])+ | needsCheck = "(ite " ++ cond ++ show e ++ " " ++ lkUp ++ ")"+ | True = lkUp+ where needsCheck = (2::Integer)^at > fromIntegral l+ lkUp = "(select table" ++ show t ++ " " ++ show i ++ ")"+ cond+ | hasSign i = "(or " ++ le0 ++ " " ++ gtl ++ ") "+ | True = gtl ++ " "+ (less, leq) = if hasSign i then ("bvslt", "bvsle") else ("bvult", "bvule")+ mkCnst = cvtCW . mkConstCW (hasSign i, sizeOf i)+ le0 = "(" ++ less ++ " " ++ show i ++ " " ++ mkCnst 0 ++ ")"+ gtl = "(" ++ leq ++ " " ++ mkCnst l ++ " " ++ show i ++ ")"+cvtExp (SBVApp (Extract i j) [a]) = "(extract[" ++ show i ++ ":" ++ show j ++ "] " ++ show a ++ ")"+cvtExp (SBVApp (ArrEq i j) []) = "(ite (= array_" ++ show i ++ " array_" ++ show j ++") bv1[1] bv0[1])"+cvtExp (SBVApp (ArrRead i) [a]) = "(select array_" ++ show i ++ " " ++ show a ++ ")"+cvtExp (SBVApp (Uninterpreted nm) []) = "uninterpreted_" ++ nm+cvtExp (SBVApp (Uninterpreted nm) args) = "(uninterpreted_" ++ nm ++ " " ++ unwords (map show args) ++ ")"+cvtExp inp@(SBVApp op args)+ | Just f <- lookup op smtOpTable+ = f (any hasSign args) (map show args)+ | True+ = error $ "SBV.SMT.SMTLib1.cvtExp: impossible happened; can't translate: " ++ show inp+ where lift2 o _ [x, y] = "(" ++ o ++ " " ++ x ++ " " ++ y ++ ")"+ lift2 o _ sbvs = error $ "SBV.SMTLib1.cvtExp.lift2: Unexpected arguments: " ++ show (o, sbvs)+ lift2B oU oS sgn sbvs+ | sgn+ = "(ite " ++ lift2 oS sgn sbvs ++ " bv1[1] bv0[1])"+ | True+ = "(ite " ++ lift2 oU sgn sbvs ++ " bv1[1] bv0[1])"+ lift2N o sgn sbvs = "(bvnot " ++ lift2 o sgn sbvs ++ ")"+ lift1 o _ [x] = "(" ++ o ++ " " ++ x ++ ")"+ lift1 o _ sbvs = error $ "SBV.SMT.SMTLib1.cvtExp.lift1: Unexpected arguments: " ++ show (o, sbvs)+ smtOpTable = [ (Plus, lift2 "bvadd")+ , (Minus, lift2 "bvsub")+ , (Times, lift2 "bvmul")+ , (Quot, lift2 "bvudiv")+ , (Rem, lift2 "bvurem")+ , (Equal, lift2 "bvcomp")+ , (NotEqual, lift2N "bvcomp")+ , (LessThan, lift2B "bvult" "bvslt")+ , (GreaterThan, lift2B "bvugt" "bvsgt")+ , (LessEq, lift2B "bvule" "bvsle")+ , (GreaterEq, lift2B "bvuge" "bvsge")+ , (And, lift2 "bvand")+ , (Or, lift2 "bvor")+ , (XOr, lift2 "bvxor")+ , (Not, lift1 "bvnot")+ , (Join, lift2 "concat")+ ]++cvtType :: SBVType -> String+cvtType (SBVType []) = error "SBV.SMT.SMTLib1.cvtType: internal: received an empty type!"+cvtType (SBVType xs) = unwords $ map sh xs+ where sh (_, s) = "BitVec[" ++ show s ++ "]"
+ Data/SBV/SMT/SMTLib2.hs view
@@ -0,0 +1,312 @@+----------------------------------------------------------------------------+-- |+-- Module : Data.SBV.SMT.SMTLib2+-- Copyright : (c) Levent Erkok+-- License : BSD3+-- Maintainer : erkokl@gmail.com+-- Stability : experimental+-- Portability : portable+--+-- Conversion of symbolic programs to SMTLib format, Using v2 of the standard+-----------------------------------------------------------------------------+{-# LANGUAGE PatternGuards #-}++module Data.SBV.SMT.SMTLib2(cvt, addNonEqConstraints) where++import qualified Data.Foldable as F (toList)+import qualified Data.Map as M+import qualified Data.IntMap as IM+import Data.List (intercalate, partition)+import Numeric (showHex)++import Data.SBV.BitVectors.Data++addNonEqConstraints :: [(Quantifier, NamedSymVar)] -> [[(String, CW)]] -> SMTLibPgm -> Maybe String+addNonEqConstraints qinps allNonEqConstraints (SMTLibPgm _ (aliasTable, pre, post))+ | null allNonEqConstraints+ = Just $ intercalate "\n" $ pre ++ post+ | null refutedModel+ = Nothing+ | True+ = Just $ intercalate "\n" $ pre+ ++ [ "; --- refuted-models ---" ]+ ++ concatMap nonEqs (map (map intName) nonEqConstraints)+ ++ post+ where refutedModel = concatMap nonEqs (map (map intName) nonEqConstraints)+ intName (s, c)+ | Just sw <- s `lookup` aliasTable = (show sw, c)+ | True = (s, c)+ -- with existentials, we only add top-level existentials to the refuted-models list+ nonEqConstraints = filter (not . null) $ map (filter (\(s, _) -> s `elem` topUnivs)) allNonEqConstraints+ topUnivs = [s | (_, (_, s)) <- takeWhile (\p -> fst p == EX) qinps]++nonEqs :: [(String, CW)] -> [String]+nonEqs [] = []+nonEqs [sc] = ["(assert " ++ nonEq sc ++ ")"]+nonEqs (sc:r) = ["(assert (or " ++ nonEq sc]+ ++ map ((" " ++) . nonEq) r+ ++ [" ))"]++nonEq :: (String, CW) -> String+nonEq (s, c) = "(not (= " ++ s ++ " " ++ cvtCW c ++ "))"++tbd :: String -> a+tbd e = error $ "SBV.SMTLib2: Not-yet-supported: " ++ e++cvt :: Bool -- ^ is this a sat problem?+ -> [String] -- ^ extra comments to place on top+ -> [(Quantifier, NamedSymVar)] -- ^ inputs+ -> [Either SW (SW, [SW])] -- ^ skolemized version inputs+ -> [(SW, CW)] -- ^ constants+ -> [((Int, (Bool, Int), (Bool, Int)), [SW])] -- ^ auto-generated tables+ -> [(Int, ArrayInfo)] -- ^ user specified arrays+ -> [(String, SBVType)] -- ^ uninterpreted functions/constants+ -> [(String, [String])] -- ^ user given axioms+ -> Pgm -- ^ assignments+ -> SW -- ^ output variable+ -> ([String], [String])+cvt isSat comments _inps skolemInps consts tbls arrs uis axs asgnsSeq out = (pre, [])+ where -- the logic is an over-approaximation+ logic = qs ++ as ++ ufs+ where qs | null foralls && null axs = "QF_" -- axioms are likely to contain quantifiers+ | True = ""+ as | null arrs = ""+ | True = "A"+ ufs | null uis && null tbls = "" -- we represent tables as UFs+ | True = "UF"+ pre = ["; Automatically generated by SBV. Do not edit."]+ ++ map ("; " ++) comments+ ++ [ "(set-logic " ++ logic ++ "BV)"+ , "(set-option :produce-models true)"+ , "; --- literal constants ---"+ ]+ ++ map declConst consts+ ++ [ "; --- skolem constants ---" ]+ ++ [ "(declare-fun " ++ show s ++ " " ++ smtFunType ss s ++ ")" | Right (s, ss) <- skolemInps]+ ++ [ "; --- constant tables ---" ]+ ++ concatMap constTable constTables+ ++ [ "; --- skolemized tables ---" ]+ ++ map (skolemTable (unwords (map smtType foralls))) skolemTables+ ++ [ "; --- arrays ---" ]+ ++ concat arrayConstants+ ++ [ "; --- uninterpreted constants ---" ]+ ++ concatMap declUI uis+ ++ [ "; --- user given axioms ---" ]+ ++ map declAx axs+ ++ [ "; --- formula ---" ]+ ++ [if null foralls+ then "(assert ; no quantifiers"+ else "(assert (forall (" ++ intercalate "\n "+ ["(" ++ show s ++ " " ++ smtType s ++ ")" | s <- foralls] ++ ")"]+ ++ map (letAlign . mkLet) asgns+ ++ map letAlign (if null delayedEqualities then [] else ("(and " ++ deH) : map (align 5) deTs)+ ++ [ impAlign (letAlign assertOut) ++ replicate noOfCloseParens ')' ]+ noOfCloseParens = length asgns + (if null foralls then 1 else 2) + (if null delayedEqualities then 0 else 1)+ (constTables, skolemTables) = ([(t, d) | (t, Left d) <- allTables], [(t, d) | (t, Right d) <- allTables])+ allTables = [(t, genTableData skolemMap (not (null foralls), forallArgs) (map fst consts) t) | t <- tbls]+ (arrayConstants, allArrayDelayeds) = unzip $ map (declArray (not (null foralls)) (map fst consts) skolemMap) arrs+ delayedEqualities@(~(deH:deTs)) = concatMap snd skolemTables ++ concat allArrayDelayeds+ foralls = [s | Left s <- skolemInps]+ forallArgs = concatMap ((" " ++) . show) foralls+ letAlign s+ | null foralls = " " ++ s+ | True = " " ++ s+ impAlign s+ | null delayedEqualities = s+ | True = " " ++ s+ align n s = replicate n ' ' ++ s+ assertOut | isSat = "(= " ++ show out ++ " #b1)"+ | True = "(= " ++ show out ++ " #b0)"+ skolemMap = M.fromList [(s, ss) | Right (s, ss) <- skolemInps, not (null ss)]+ tableMap = IM.fromList $ map mkConstTable constTables ++ map mkSkTable skolemTables+ where mkConstTable (((t, _, _), _), _) = (t, "table" ++ show t)+ mkSkTable (((t, _, _), _), _) = (t, "table" ++ show t ++ forallArgs)+ asgns = F.toList asgnsSeq+ mkLet (s, e) = "(let ((" ++ show s ++ " " ++ cvtExp skolemMap tableMap e ++ "))"+ declConst (s, c) = "(define-fun " ++ show s ++ " " ++ smtFunType [] s ++ " " ++ cvtCW c ++ ")"++declUI :: (String, SBVType) -> [String]+declUI (i, t) = ["(declare-fun uninterpreted_" ++ i ++ " " ++ cvtType t ++ ")"]++-- NB. We perform no check to as to whether the axiom is meaningful in any way.+declAx :: (String, [String]) -> String+declAx (nm, ls) = (";; -- user given axiom: " ++ nm ++ "\n ") ++ intercalate "\n" ls++constTable :: (((Int, (Bool, Int), (Bool, Int)), [SW]), [String]) -> [String]+constTable (((i, (_, at), (_, rt)), _elts), is) = decl : map wrap is+ where t = "table" ++ show i+ bv sz = "(_ BitVec " ++ show sz ++ ")"+ decl = "(declare-fun " ++ t ++ " (" ++ bv at ++ ") " ++ bv rt ++ ")"+ wrap s = "(assert " ++ s ++ ")"++skolemTable :: String -> (((Int, (Bool, Int), (Bool, Int)), [SW]), [String]) -> String+skolemTable qs (((i, (_, at), (_, rt)), _elts), _) = decl+ where t = "table" ++ show i+ bv sz = "(_ BitVec " ++ show sz ++ ")"+ decl = "(declare-fun " ++ t ++ " (" ++ qs ++ " " ++ bv at ++ ") " ++ bv rt ++ ")"++-- Left if all constants, Right if otherwise+genTableData :: SkolemMap -> (Bool, String) -> [SW] -> ((Int, (Bool, Int), (Bool, Int)), [SW]) -> Either [String] [String]+genTableData skolemMap (quantified, args) consts ((i, (sa, at), (_, _rt)), elts)+ | null post = Left (map (topLevel . snd) pre)+ | True = Right (map (nested . snd) (pre ++ post))+ where ssw = cvtSW skolemMap+ (pre, post) = partition fst (zipWith mkElt elts [(0::Int)..])+ t = "table" ++ show i+ mkElt x k = (isReady, (idx, ssw x))+ where idx = cvtCW (mkConstCW (sa, at) k)+ isReady = not quantified || x `elem` consts+ topLevel (idx, v) = "(= (" ++ t ++ " " ++ idx ++ ") " ++ v ++ ")"+ nested (idx, v) = "(= (" ++ t ++ args ++ " " ++ idx ++ ") " ++ v ++ ")"++-- TODO: We currently do not support non-constant arrays when quantifiers are present, as+-- we might have to skolemize those. Implement this properly.+-- The difficulty is with the ArrayReset/Mutate/Merge: We have to postpone an init if+-- the components are themselves postponed, so this cannot be implemented as a simple map.+declArray :: Bool -> [SW] -> SkolemMap -> (Int, ArrayInfo) -> ([String], [String])+declArray quantified consts skolemMap (i, (_, ((_, at), (_, rt)), ctx)) = (adecl : map wrap pre, map snd post)+ where topLevel = not quantified || case ctx of+ ArrayFree Nothing -> True+ ArrayFree (Just sw) -> sw `elem` consts+ ArrayReset _ sw -> sw `elem` consts+ ArrayMutate _ a b -> all (`elem` consts) [a, b]+ ArrayMerge c _ _ -> c `elem` consts+ (pre, post) = partition fst ctxInfo+ nm = "array_" ++ show i+ ssw sw+ | topLevel || sw `elem` consts+ = cvtSW skolemMap sw+ | True+ = tbd "Non-constant array initializer in a quantified context"+ adecl = "(declare-fun " ++ nm ++ "() (Array (_ BitVec " ++ show at ++ ") (_ BitVec " ++ show rt ++ ")))"+ ctxInfo = case ctx of+ ArrayFree Nothing -> []+ ArrayFree (Just sw) -> declA sw+ ArrayReset _ sw -> declA sw+ ArrayMutate j a b -> [(all (`elem` consts) [a, b], "(= " ++ nm ++ " (store array_" ++ show j ++ " " ++ ssw a ++ " " ++ ssw b ++ "))")]+ ArrayMerge t j k -> [(t `elem` consts, "(= " ++ nm ++ " (ite (= #b1 " ++ ssw t ++ ") array_" ++ show j ++ " array_" ++ show k ++ "))")]+ declA sw = let iv = nm ++ "_freeInitializer"+ in [ (True, "(declare-fun " ++ iv ++ "() (_ BitVec " ++ show at ++ "))")+ , (sw `elem` consts, "(= (select " ++ nm ++ " " ++ iv ++ ") " ++ ssw sw ++ ")")+ ]+ wrap (False, s) = s+ wrap (True, s) = "(assert " ++ s ++ ")"++smtType :: SW -> String+smtType s = "(_ BitVec " ++ show (sizeOf s) ++ ")"++smtFunType :: [SW] -> SW -> String+smtFunType ss s = "(" ++ unwords (map smtType ss) ++ ") " ++ smtType s++cvtType :: SBVType -> String+cvtType (SBVType []) = error "SBV.SMT.SMTLib2.cvtType: internal: received an empty type!"+cvtType (SBVType xs) = "(" ++ unwords (map sh body) ++ ") " ++ sh ret+ where (body, ret) = (init xs, last xs)+ sh (_, s) = "(_ BitVec " ++ show s ++ ")"++type SkolemMap = M.Map SW [SW]+type TableMap = IM.IntMap String++cvtSW :: SkolemMap -> SW -> String+cvtSW skolemMap s+ | Just ss <- s `M.lookup` skolemMap+ = "(" ++ show s ++ concatMap ((" " ++) . show) ss ++ ")"+ | True+ = show s++-- NB. The following works with SMTLib2 since all sizes are multiples of 4 (or just 1, which is specially handled)+hex :: Int -> Integer -> String+hex 1 v = "#b" ++ show v+hex sz v = "#x" ++ pad (sz `div` 4) (showHex v "")+ where pad n s = replicate (n - length s) '0' ++ s++cvtCW :: CW -> String+cvtCW x | not (hasSign x) = hex (sizeOf x) (cwVal x)+-- signed numbers (with 2's complement representation) is problematic+-- since there's no way to put a bvneg over a positive number to get minBound..+-- Hence, we punt and use binary notation in that particular case+cvtCW x | cwVal x == least = mkMinBound (sizeOf x)+ where least = negate (2 ^ sizeOf x)+cvtCW x = negIf (w < 0) $ hex (sizeOf x) (abs w)+ where w = cwVal x++negIf :: Bool -> String -> String+negIf True a = "(bvneg " ++ a ++ ")"+negIf False a = a++-- anamoly at the 2's complement min value! Have to use binary notation here+-- as there is no positive value we can provide to make the bvneg work.. (see above)+mkMinBound :: Int -> String+mkMinBound i = "#b1" ++ replicate (i-1) '0'++getTable :: TableMap -> Int -> String+getTable m i+ | Just tn <- i `IM.lookup` m = tn+ | True = error $ "SBV.SMTLib2: Cannot locate table " ++ show i++cvtExp :: SkolemMap -> TableMap -> SBVExpr -> String+cvtExp skolemMap tableMap expr = sh expr+ where ssw = cvtSW skolemMap+ sh (SBVApp Ite [a, b, c]) = "(ite (= #b1 " ++ ssw a ++ ") " ++ ssw b ++ " " ++ ssw c ++ ")"+ sh (SBVApp (Rol i) [a]) = rot ssw "rotate_left" i a+ sh (SBVApp (Ror i) [a]) = rot ssw "rotate_right" i a+ sh (SBVApp (Shl i) [a]) = shft ssw "bvshl" "bvshl" i a+ sh (SBVApp (Shr i) [a]) = shft ssw "bvlshr" "bvashr" i a+ sh (SBVApp (LkUp (t, (_, at), _, l) i e) [])+ | needsCheck = "(ite " ++ cond ++ ssw e ++ " " ++ lkUp ++ ")"+ | True = lkUp+ where needsCheck = (2::Integer)^at > fromIntegral l+ lkUp = "(" ++ getTable tableMap t ++ " " ++ ssw i ++ ")"+ cond+ | hasSign i = "(or " ++ le0 ++ " " ++ gtl ++ ") "+ | True = gtl ++ " "+ (less, leq) = if hasSign i then ("bvslt", "bvsle") else ("bvult", "bvule")+ mkCnst = cvtCW . mkConstCW (hasSign i, sizeOf i)+ le0 = "(" ++ less ++ " " ++ ssw i ++ " " ++ mkCnst 0 ++ ")"+ gtl = "(" ++ leq ++ " " ++ mkCnst l ++ " " ++ ssw i ++ ")"+ sh (SBVApp (Extract i j) [a]) = "((_ extract " ++ show i ++ " " ++ show j ++ ") " ++ ssw a ++ ")"+ sh (SBVApp (ArrEq i j) []) = "(ite (= array_" ++ show i ++ " array_" ++ show j ++") #b1 #b0)"+ sh (SBVApp (ArrRead i) [a]) = "(select array_" ++ show i ++ " " ++ ssw a ++ ")"+ sh (SBVApp (Uninterpreted nm) []) = "uninterpreted_" ++ nm+ sh (SBVApp (Uninterpreted nm) args) = "(uninterpreted_" ++ nm ++ " " ++ unwords (map ssw args) ++ ")"+ sh inp@(SBVApp op args)+ | Just f <- lookup op smtOpTable+ = f (any hasSign args) (map ssw args)+ | True+ = error $ "SBV.SMT.SMTLib2.sh: impossible happened; can't translate: " ++ show inp+ where lift2 o _ [x, y] = "(" ++ o ++ " " ++ x ++ " " ++ y ++ ")"+ lift2 o _ sbvs = error $ "SBV.SMTLib2.sh.lift2: Unexpected arguments: " ++ show (o, sbvs)+ lift2B oU oS sgn sbvs+ | sgn+ = "(ite " ++ lift2 oS sgn sbvs ++ " #b1 #b0)"+ | True+ = "(ite " ++ lift2 oU sgn sbvs ++ " #b1 #b0)"+ lift2N o sgn sbvs = "(bvnot " ++ lift2 o sgn sbvs ++ ")"+ lift1 o _ [x] = "(" ++ o ++ " " ++ x ++ ")"+ lift1 o _ sbvs = error $ "SBV.SMT.SMTLib2.sh.lift1: Unexpected arguments: " ++ show (o, sbvs)+ smtOpTable = [ (Plus, lift2 "bvadd")+ , (Minus, lift2 "bvsub")+ , (Times, lift2 "bvmul")+ , (Quot, lift2 "bvudiv")+ , (Rem, lift2 "bvurem")+ , (Equal, lift2 "bvcomp")+ , (NotEqual, lift2N "bvcomp")+ , (LessThan, lift2B "bvult" "bvslt")+ , (GreaterThan, lift2B "bvugt" "bvsgt")+ , (LessEq, lift2B "bvule" "bvsle")+ , (GreaterEq, lift2B "bvuge" "bvsge")+ , (And, lift2 "bvand")+ , (Or, lift2 "bvor")+ , (XOr, lift2 "bvxor")+ , (Not, lift1 "bvnot")+ , (Join, lift2 "concat")+ ]++rot :: (SW -> String) -> String -> Int -> SW -> String+rot ssw o c x = "((_ " ++ o ++ " " ++ show c ++ ") " ++ ssw x ++ ")"++shft :: (SW -> String) -> String -> String -> Int -> SW -> String+shft ssw oW oS c x = "(" ++ o ++ " " ++ ssw x ++ " " ++ cvtCW c' ++ ")"+ where s = hasSign x+ c' = mkConstCW (s, sizeOf x) c+ o = if hasSign x then oS else oW
Data/SBV/TestSuite/Basics/Arithmetic.hs view
@@ -28,7 +28,7 @@ ++ genUnTest "signum" signum ++ genBinTest ".&." (.&.) ++ genBinTest ".|." (.|.)- ++ genBinTest "xor" (xor)+ ++ genBinTest "xor" xor ++ genUnTest "complement" complement ++ genIntTest "shift" shift ++ genIntTest "rotate" rotate@@ -52,7 +52,7 @@ ++ zipWith pair [(show x, show y, x `op` y) | x <- i16s, y <- i16s] [x `op` y | x <- si16s, y <- si16s] ++ zipWith pair [(show x, show y, x `op` y) | x <- i32s, y <- i32s] [x `op` y | x <- si32s, y <- si32s] ++ zipWith pair [(show x, show y, x `op` y) | x <- i64s, y <- i64s] [x `op` y | x <- si64s, y <- si64s]- where pair (x, y, a) b = (x, y, show ((fromIntegral a) `asTypeOf` b) == show b)+ where pair (x, y, a) b = (x, y, show (fromIntegral a `asTypeOf` b) == show b) mkTest (x, y, s) = "arithmetic-" ++ nm ++ "." ++ x ++ "_" ++ y ~: s `showsAs` "True" genUnTest :: String -> (forall a. Bits a => a -> a) -> [Test]@@ -65,7 +65,7 @@ ++ zipWith pair [(show x, op x) | x <- i16s] [op x | x <- si16s] ++ zipWith pair [(show x, op x) | x <- i32s] [op x | x <- si32s] ++ zipWith pair [(show x, op x) | x <- i64s] [op x | x <- si64s]- where pair (x, a) b = (x, show ((fromIntegral a) `asTypeOf` b) == show b)+ where pair (x, a) b = (x, show (fromIntegral a `asTypeOf` b) == show b) mkTest (x, s) = "arithmetic-" ++ nm ++ "." ++ x ~: s `showsAs` "True" genIntTest :: String -> (forall a. Bits a => a -> Int -> a) -> [Test]@@ -78,7 +78,7 @@ ++ zipWith pair [("s16", show x, show y, x `op` y) | x <- i16s, y <- is] [x `op` y | x <- si16s, y <- is] ++ zipWith pair [("s32", show x, show y, x `op` y) | x <- i32s, y <- is] [x `op` y | x <- si32s, y <- is] ++ zipWith pair [("s64", show x, show y, x `op` y) | x <- i64s, y <- is] [x `op` y | x <- si64s, y <- is]- where pair (t, x, y, a) b = (t, x, y, show a, show b, show ((fromIntegral a) `asTypeOf` b) == show b)+ where pair (t, x, y, a) b = (t, x, y, show a, show b, show (fromIntegral a `asTypeOf` b) == show b) mkTest (t, x, y, a, b, s) = "arithmetic-" ++ nm ++ "." ++ t ++ "_" ++ x ++ "_" ++ y ++ "_" ++ a ++ "_" ++ b ~: s `showsAs` "True" is = [-10 .. 10]
Data/SBV/TestSuite/Basics/ProofTests.hs view
@@ -23,13 +23,12 @@ , "proofs-2" ~: assert . not =<< isTheorem f1eqf3 , "proofs-3" ~: assert =<< isTheorem f3eqf4 , "proofs-4" ~: assert =<< isTheorem f1Single- , "proofs-5" ~: assert =<< isSatisfiable f1eqf2- , "proofs-6" ~: assert =<< isSatisfiable f1eqf3- , "proofs-7" ~: assert . not =<< isSatisfiable (\x -> x .== x + (1 :: SWord16))- , "proofs-8" ~: assert =<< isSatisfiable (\x -> x :: SBool)- , "proofs-9" ~: assert =<< isSatisfiable (\x -> return x :: Predicate)- , "proofs-10" ~: assert =<< isSatisfiable (forAll_ $ \x -> x :: SBool)- , "proofs-11" ~: assert =<< isSatisfiable (forAll_ $ \x -> return x :: Predicate)- , "proofs-12" ~: assert =<< isSatisfiable (forAll ["q"] $ \x -> x :: SBool)- , "proofs-13" ~: assert =<< isSatisfiable (forAll ["q"] $ \x -> return x :: Predicate)+ , "proofs-5" ~: assert =<< isSatisfiable (f1 `xyEq` f2)+ , "proofs-6" ~: assert =<< isSatisfiable (f1 `xyEq` f3)+ , "proofs-7" ~: assert . not =<< isSatisfiable (exists "x" >>= \x -> return (x .== x + (1 :: SWord16)))+ , "proofs-8" ~: assert =<< isSatisfiable (exists "x" >>= \x -> return (x :: SBool))+ , "proofs-9" ~: assert =<< isSatisfiable (exists "x" >>= \x -> return x :: Predicate) ]+ where func1 `xyEq` func2 = do x <- exists_+ y <- exists_+ return $ func1 x y .== func2 x (y :: SWord8)
Data/SBV/TestSuite/CRC/GenPoly.hs view
@@ -19,6 +19,11 @@ -- Test suite testSuite :: SBVTestSuite testSuite = mkTestSuite $ \_ -> test [- "crcGood" ~: assert =<< isSatisfiable (crcGood 3 0)+ "crcGood" ~: assert =<< isSatisfiable crcGoodE , "crcGood" ~: assert . not =<< isTheorem (crcGood 3 12) ]+ where crcGoodE = do x1 <- exists_+ x2 <- exists_+ y1 <- exists_+ y2 <- exists_+ return (crcGood 3 0 (x1,x2) (y1,y2))
+ Data/SBV/TestSuite/CodeGeneration/CRC_USB5.hs view
@@ -0,0 +1,28 @@+-----------------------------------------------------------------------------+-- |+-- Module : Data.SBV.TestSuite.CodeGeneration.CRC_USB5+-- Copyright : (c) Levent Erkok+-- License : BSD3+-- Maintainer : erkokl@gmail.com+-- Stability : experimental+-- Portability : portable+--+-- Test suite for Data.SBV.Examples.CodeGeneration.CRC_USB5+-----------------------------------------------------------------------------++module Data.SBV.TestSuite.CodeGeneration.CRC_USB5(testSuite) where++import Data.SBV+import Data.SBV.Internals+import Data.SBV.Examples.CodeGeneration.CRC_USB5++-- Test suite+testSuite :: SBVTestSuite+testSuite = mkTestSuite $ \goldCheck -> test [+ "crcUSB5-1" ~: genC crcUSB `goldCheck` "crcUSB5_1.gold"+ , "crcUSB5-2" ~: genC crcUSB' `goldCheck` "crcUSB5_2.gold"+ ]+ where genC f = compileToC' "crcUSB5" $ do+ cgSetDriverValues [0xFEDC]+ msg <- cgInput "msg"+ cgReturn $ f msg
+ Data/SBV/TestSuite/Existentials/CRCPolynomial.hs view
@@ -0,0 +1,32 @@+-----------------------------------------------------------------------------+-- |+-- Module : Data.SBV.TestSuite.Existentials.CRCPolynomial+-- Copyright : (c) Levent Erkok+-- License : BSD3+-- Maintainer : erkokl@gmail.com+-- Stability : experimental+-- Portability : portable+--+-- Test suite for Data.SBV.Examples.Existentials.CRCPolynomial+-----------------------------------------------------------------------------++module Data.SBV.TestSuite.Existentials.CRCPolynomial(testSuite) where++import Data.SBV+import Data.SBV.Internals+import Data.SBV.Examples.Existentials.CRCPolynomial++-- Test suite+testSuite :: SBVTestSuite+testSuite = mkTestSuite $ \goldCheck -> test [+ "crcPolyExist" ~: pgm `goldCheck` "crcPolyExist.gold"+ ]+ where pgm = runSymbolic $ do+ p <- exists "poly"+ s <- do sh <- forall "sh"+ sl <- forall "sl"+ return (sh, sl)+ r <- do rh <- forall "rh"+ rl <- forall "rl"+ return (rh, rl)+ output $ bitValue p 0 &&& crcGood 4 p s r
Data/SBV/TestSuite/Puzzles/DogCatMouse.hs view
@@ -19,5 +19,9 @@ -- Test suite testSuite :: SBVTestSuite testSuite = mkTestSuite $ \goldCheck -> test [- "dog cat mouse" ~: allSat puzzle `goldCheck` "dogCatMouse.gold"+ "dog cat mouse" ~: allSat p `goldCheck` "dogCatMouse.gold" ]+ where p = do d <- exists "d"+ c <- exists "c"+ m <- exists "m"+ return $ puzzle d c m
Data/SBV/TestSuite/Puzzles/MagicSquare.hs view
@@ -22,4 +22,4 @@ "magic 2" ~: assert . not =<< isSatisfiable (mkMagic 2) , "magic 3" ~: assert =<< isSatisfiable (mkMagic 3) ]- where mkMagic n = mkFreeVars (n*n) >>= return . isMagic . chunk n+ where mkMagic n = (isMagic . chunk n) `fmap` mkExistVars (n*n)
Data/SBV/TestSuite/Puzzles/NQueens.hs view
@@ -29,4 +29,4 @@ , "nQueens 7" ~: assert $ (== 40) `fmap` numberOfModels (mkQueens 7) , "nQueens 8" ~: assert $ (== 92) `fmap` numberOfModels (mkQueens 8) ]- where mkQueens n = mkFreeVars n >>= return . isValid n+ where mkQueens n = isValid n `fmap` mkExistVars n
Data/SBV/TestSuite/Puzzles/PowerSet.hs view
@@ -20,5 +20,5 @@ testSuite :: SBVTestSuite testSuite = mkTestSuite $ \_ -> test [ "powerSet " ++ show i ~: assert (pSet i) | i <- [0 .. 7] ] where pSet :: Int -> IO Bool- pSet n = do cnt <- numberOfModels $ mkFreeVars n >>= return . genPowerSet+ pSet n = do cnt <- numberOfModels $ genPowerSet `fmap` mkExistVars n return (cnt == 2^n)
Data/SBV/TestSuite/Puzzles/Sudoku.hs view
@@ -22,4 +22,4 @@ "sudoku " ++ show n ~: assert (checkPuzzle s) | (n, s) <- zip [(0::Int)..] [puzzle0, puzzle1, puzzle2, puzzle3, puzzle4, puzzle5, puzzle6] ]- where checkPuzzle (i, f) = isSatisfiable $ mkFreeVars i >>= return . valid . f+ where checkPuzzle (i, f) = isSatisfiable $ (valid . f) `fmap` mkExistVars i
Data/SBV/TestSuite/Puzzles/Temperature.hs view
@@ -19,5 +19,5 @@ -- Test suite testSuite :: SBVTestSuite testSuite = mkTestSuite $ \goldCheck -> test [- "temperature" ~: sat revOf `goldCheck` "temperature.gold"+ "temperature" ~: sat (revOf `fmap` exists_) `goldCheck` "temperature.gold" ]
Data/SBV/TestSuite/Puzzles/U2Bridge.hs view
@@ -26,6 +26,6 @@ , "U2Bridge-5" ~: solve 5 `goldCheck` "U2Bridge.gold" , "U2Bridge-6" ~: assert $ (0 ==) `fmap` count 6 ]- where act = do b <- free_; p1 <- free_; p2 <- free_; return (b, p1, p2)- count n = numberOfModels $ mapM (const act) [1..(n::Int)] >>= return . isValid- solve n = sat $ mapM (const act) [1..(n::Int)] >>= return . isValid+ where act = do b <- exists_; p1 <- exists_; p2 <- exists_; return (b, p1, p2)+ count n = numberOfModels $ isValid `fmap` mapM (const act) [1..(n::Int)]+ solve n = sat $ isValid `fmap` mapM (const act) [1..(n::Int)]
README view
@@ -40,7 +40,7 @@ - `SWord8`, `SWord16`, `SWord32`, `SWord64`: Symbolic Words (unsigned) - `SInt8`, `SInt16`, `SInt32`, `SInt64`: Symbolic Ints (signed) - Arrays of symbolic values- - Symbolic polynomials over GF(2^n ), and polynomial arithmetic+ - Symbolic polynomials over GF(2^n ), polynomial arithmetic, and CRCs - Uninterpreted constants and functions over symbolic values, with user defined SMT-Lib axioms @@ -53,7 +53,8 @@ Furthermore, predicates (i.e., functions that return `SBool`) built out of these types can also be: - proven correct via an external SMT solver (the `prove` function)- - checked for satisfiability (the `sat` and `allSat` functions)+ - checked for satisfiability (the `sat`, and `allSat` functions)+ - used in synthesis (the `sat` function with existentials) - quick-checked If a predicate is not valid, `prove` will return a counterexample: An @@ -69,15 +70,10 @@ The sbv library uses third-party SMT solvers via the standard SMT-Lib interface: [http://goedel.cs.uiowa.edu/smtlib/](http://goedel.cs.uiowa.edu/smtlib/) -While the library is designed to work with any SMT-Lib compliant SMT-solver,-solver specific support is required for parsing counter-example/model data since-there is currently no agreed upon format for getting models from arbitrary SMT-solvers. (The SMT-Lib2 initiative will potentially address this issue in the-future, at which point the sbv library can be generalized as well.) Currently, we-only support the Yices SMT solver from SRI as far as the counter-example-and model generation support is concerned:-[http://yices.csl.sri.com/](http://yices.csl.sri.com/) However, other solvers can-be hooked up with relative ease.+The SBV library is designed to work with any SMT-Lib compliant SMT-solver. +Currently, we support the Yices SMT solver from SRI:+[http://yices.csl.sri.com/](http://yices.csl.sri.com/) and the Z3 SMT solver+from Microsoft: [http://research.microsoft.com/en-us/um/redmond/projects/z3/](http://research.microsoft.com/en-us/um/redmond/projects/z3/) Prerequisites =============@@ -85,8 +81,16 @@ make sure the "yices" executable is in your path before using the sbv library, as it is the current default solver. Alternatively, you can specify the location of yices executable in the environment variable `SBV_YICES` and the options to yices-in `SBV_YICES_OPTIONS`. (The default for the latter is `"-m -f"`.)+in `SBV_YICES_OPTIONS`. The default for the latter is `"-m -f"`. +If quantified bit-vectors are to be used, you should also install+Microsoft's z3 SMT solver. Again, the environment variables +`SBV_Z3` and `SBV_Z3_OPTIONS` can be used for choosing executable location+and custom options. The default for the latter is `"/in /smt2"`. Microsoft+releases Z3 natively on Windows, and Linux for SMT-Comp purposes, and you can+also run it on Mac via Wine or similar emulators. You should download at least+version 3.2.+ Examples ========= Please see the files under the@@ -116,4 +120,5 @@ Thanks ====== The following people reported bugs, provided comments/feedback, or contributed to the development of SBV in various ways:-Ian Blumenfeld, Ian Calvert, Iavor Diatchki, Lee Pike, Austin Seipp, Don Stewart, Josef Svenningsson, and Nis Wegmann.+Ian Blumenfeld, Ian Calvert, Iavor Diatchki, Tom Hawkins, Lee Pike, Austin Seipp, Don Stewart, Josef Svenningsson,+and Nis Wegmann.
SBVUnitTest/GoldFiles/aes128Dec.gold view
@@ -68,7 +68,7 @@ printf("Contents of input array pt:\n"); int pt_ctr;- for(pt_ctr = 0; pt_ctr < 4 ; ++pt_ctr)+ for(pt_ctr = 0; pt_ctr < 4 ; ++pt_ctr) printf(" pt[%d] = 0x%08"PRIx32"UL\n", pt_ctr ,pt[pt_ctr]); const SWord32 key[4] = {@@ -77,7 +77,7 @@ printf("Contents of input array key:\n"); int key_ctr;- for(key_ctr = 0; key_ctr < 4 ; ++key_ctr)+ for(key_ctr = 0; key_ctr < 4 ; ++key_ctr) printf(" key[%d] = 0x%08"PRIx32"UL\n", key_ctr ,key[key_ctr]); SWord32 ct[4];@@ -86,7 +86,7 @@ printf("aes128Dec(pt, key, ct) ->\n"); int ct_ctr;- for(ct_ctr = 0; ct_ctr < 4 ; ++ct_ctr)+ for(ct_ctr = 0; ct_ctr < 4 ; ++ct_ctr) printf(" ct[%d] = 0x%08"PRIx32"UL\n", ct_ctr ,ct[ct_ctr]); return 0;
SBVUnitTest/GoldFiles/aes128Enc.gold view
@@ -68,7 +68,7 @@ printf("Contents of input array pt:\n"); int pt_ctr;- for(pt_ctr = 0; pt_ctr < 4 ; ++pt_ctr)+ for(pt_ctr = 0; pt_ctr < 4 ; ++pt_ctr) printf(" pt[%d] = 0x%08"PRIx32"UL\n", pt_ctr ,pt[pt_ctr]); const SWord32 key[4] = {@@ -77,7 +77,7 @@ printf("Contents of input array key:\n"); int key_ctr;- for(key_ctr = 0; key_ctr < 4 ; ++key_ctr)+ for(key_ctr = 0; key_ctr < 4 ; ++key_ctr) printf(" key[%d] = 0x%08"PRIx32"UL\n", key_ctr ,key[key_ctr]); SWord32 ct[4];@@ -86,7 +86,7 @@ printf("aes128Enc(pt, key, ct) ->\n"); int ct_ctr;- for(ct_ctr = 0; ct_ctr < 4 ; ++ct_ctr)+ for(ct_ctr = 0; ct_ctr < 4 ; ++ct_ctr) printf(" ct[%d] = 0x%08"PRIx32"UL\n", ct_ctr ,ct[ct_ctr]); return 0;
SBVUnitTest/GoldFiles/aes128Lib.gold view
@@ -3614,7 +3614,7 @@ printf("Contents of input array key:\n"); int key_ctr;- for(key_ctr = 0; key_ctr < 4 ; ++key_ctr)+ for(key_ctr = 0; key_ctr < 4 ; ++key_ctr) printf(" key[%d] = 0x%08"PRIx32"UL\n", key_ctr ,key[key_ctr]); SWord32 encKS[44];@@ -3624,10 +3624,10 @@ printf("aes128KeySchedule(key, encKS, decKS) ->\n"); int encKS_ctr;- for(encKS_ctr = 0; encKS_ctr < 44 ; ++encKS_ctr)+ for(encKS_ctr = 0; encKS_ctr < 44 ; ++encKS_ctr) printf(" encKS[%d] = 0x%08"PRIx32"UL\n", encKS_ctr ,encKS[encKS_ctr]); int decKS_ctr;- for(decKS_ctr = 0; decKS_ctr < 44 ; ++decKS_ctr)+ for(decKS_ctr = 0; decKS_ctr < 44 ; ++decKS_ctr) printf(" decKS[%d] = 0x%08"PRIx32"UL\n", decKS_ctr ,decKS[decKS_ctr]); } @@ -3639,7 +3639,7 @@ printf("Contents of input array pt:\n"); int pt_ctr;- for(pt_ctr = 0; pt_ctr < 4 ; ++pt_ctr)+ for(pt_ctr = 0; pt_ctr < 4 ; ++pt_ctr) printf(" pt[%d] = 0x%08"PRIx32"UL\n", pt_ctr ,pt[pt_ctr]); const SWord32 xkey[44] = {@@ -3658,7 +3658,7 @@ printf("Contents of input array xkey:\n"); int xkey_ctr;- for(xkey_ctr = 0; xkey_ctr < 44 ; ++xkey_ctr)+ for(xkey_ctr = 0; xkey_ctr < 44 ; ++xkey_ctr) printf(" xkey[%d] = 0x%08"PRIx32"UL\n", xkey_ctr ,xkey[xkey_ctr]); SWord32 ct[4];@@ -3667,7 +3667,7 @@ printf("aes128BlockEncrypt(pt, xkey, ct) ->\n"); int ct_ctr;- for(ct_ctr = 0; ct_ctr < 4 ; ++ct_ctr)+ for(ct_ctr = 0; ct_ctr < 4 ; ++ct_ctr) printf(" ct[%d] = 0x%08"PRIx32"UL\n", ct_ctr ,ct[ct_ctr]); } @@ -3679,7 +3679,7 @@ printf("Contents of input array ct:\n"); int ct_ctr;- for(ct_ctr = 0; ct_ctr < 4 ; ++ct_ctr)+ for(ct_ctr = 0; ct_ctr < 4 ; ++ct_ctr) printf(" ct[%d] = 0x%08"PRIx32"UL\n", ct_ctr ,ct[ct_ctr]); const SWord32 xkey[44] = {@@ -3698,7 +3698,7 @@ printf("Contents of input array xkey:\n"); int xkey_ctr;- for(xkey_ctr = 0; xkey_ctr < 44 ; ++xkey_ctr)+ for(xkey_ctr = 0; xkey_ctr < 44 ; ++xkey_ctr) printf(" xkey[%d] = 0x%08"PRIx32"UL\n", xkey_ctr ,xkey[xkey_ctr]); SWord32 pt[4];@@ -3707,7 +3707,7 @@ printf("aes128BlockDecrypt(ct, xkey, pt) ->\n"); int pt_ctr;- for(pt_ctr = 0; pt_ctr < 4 ; ++pt_ctr)+ for(pt_ctr = 0; pt_ctr < 4 ; ++pt_ctr) printf(" pt[%d] = 0x%08"PRIx32"UL\n", pt_ctr ,pt[pt_ctr]); }
SBVUnitTest/GoldFiles/codeGen1.gold view
@@ -83,7 +83,7 @@ printf("Contents of input array xArr:\n"); int xArr_ctr;- for(xArr_ctr = 0; xArr_ctr < 45 ; ++xArr_ctr)+ for(xArr_ctr = 0; xArr_ctr < 45 ; ++xArr_ctr) printf(" xArr[%d] = %"PRId64"LL\n", xArr_ctr ,xArr[xArr_ctr]); SWord16 z;@@ -95,10 +95,10 @@ printf("foo(0x0000, xArr, &z, zArr, yArr) = %"PRId16"\n", __result); printf(" z = 0x%04"PRIx16"U\n", z); int zArr_ctr;- for(zArr_ctr = 0; zArr_ctr < 7 ; ++zArr_ctr)+ for(zArr_ctr = 0; zArr_ctr < 7 ; ++zArr_ctr) printf(" zArr[%d] = %"PRId16"\n", zArr_ctr ,zArr[zArr_ctr]); int yArr_ctr;- for(yArr_ctr = 0; yArr_ctr < 45 ; ++yArr_ctr)+ for(yArr_ctr = 0; yArr_ctr < 45 ; ++yArr_ctr) printf(" yArr[%d] = %"PRId64"LL\n", yArr_ctr ,yArr[yArr_ctr]); return 0;
+ SBVUnitTest/GoldFiles/crcPolyExist.gold view
@@ -0,0 +1,3532 @@+INPUTS+ s0 :: SWord16, existential, aliasing "poly"+ s1 :: SWord32, aliasing "sh"+ s2 :: SWord16, aliasing "sl"+ s3 :: SWord32, aliasing "rh"+ s4 :: SWord16, aliasing "rl"+CONSTANTS+ s_2 = False+ s_1 = True+ s21 = 1 :: SWord8+ s3389 = 0 :: SWord8+ s3517 = 4 :: SWord8+ s5 = 1 :: SWord16+ s7 = 0 :: SWord16+ s208 = 32768 :: SWord16+ s214 = 16384 :: SWord16+ s220 = 8192 :: SWord16+ s226 = 4096 :: SWord16+ s232 = 2048 :: SWord16+ s238 = 1024 :: SWord16+ s244 = 512 :: SWord16+ s250 = 256 :: SWord16+ s256 = 128 :: SWord16+ s262 = 64 :: SWord16+ s268 = 32 :: SWord16+ s274 = 16 :: SWord16+ s280 = 8 :: SWord16+ s286 = 4 :: SWord16+ s292 = 2 :: SWord16+ s14 = 2147483648 :: SWord32+ s16 = 0 :: SWord32+ s22 = 1073741824 :: SWord32+ s28 = 536870912 :: SWord32+ s34 = 268435456 :: SWord32+ s40 = 134217728 :: SWord32+ s46 = 67108864 :: SWord32+ s52 = 33554432 :: SWord32+ s58 = 16777216 :: SWord32+ s64 = 8388608 :: SWord32+ s70 = 4194304 :: SWord32+ s76 = 2097152 :: SWord32+ s82 = 1048576 :: SWord32+ s88 = 524288 :: SWord32+ s94 = 262144 :: SWord32+ s100 = 131072 :: SWord32+ s106 = 65536 :: SWord32+ s112 = 32768 :: SWord32+ s118 = 16384 :: SWord32+ s124 = 8192 :: SWord32+ s130 = 4096 :: SWord32+ s136 = 2048 :: SWord32+ s142 = 1024 :: SWord32+ s148 = 512 :: SWord32+ s154 = 256 :: SWord32+ s160 = 128 :: SWord32+ s166 = 64 :: SWord32+ s172 = 32 :: SWord32+ s178 = 16 :: SWord32+ s184 = 8 :: SWord32+ s190 = 4 :: SWord32+ s196 = 2 :: SWord32+ s202 = 1 :: SWord32+TABLES+ARRAYS+UNINTERPRETED CONSTANTS+AXIOMS+DEFINE+ s6 :: SWord16 = s0 & s5+ s8 :: SBool = s6 /= s7+ s9 :: SBool = s1 == s3+ s10 :: SBool = s2 == s4+ s11 :: SBool = s9 & s10+ s12 :: SBool = ~ s11+ s13 :: SBool = ~ s12+ s15 :: SWord32 = s1 & s14+ s17 :: SBool = s15 /= s16+ s18 :: SWord32 = s3 & s14+ s19 :: SBool = s16 /= s18+ s20 :: SBool = s17 ^ s19+ s23 :: SWord32 = s1 & s22+ s24 :: SBool = s16 /= s23+ s25 :: SWord32 = s3 & s22+ s26 :: SBool = s16 /= s25+ s27 :: SBool = s24 ^ s26+ s29 :: SWord32 = s1 & s28+ s30 :: SBool = s16 /= s29+ s31 :: SWord32 = s3 & s28+ s32 :: SBool = s16 /= s31+ s33 :: SBool = s30 ^ s32+ s35 :: SWord32 = s1 & s34+ s36 :: SBool = s16 /= s35+ s37 :: SWord32 = s3 & s34+ s38 :: SBool = s16 /= s37+ s39 :: SBool = s36 ^ s38+ s41 :: SWord32 = s1 & s40+ s42 :: SBool = s16 /= s41+ s43 :: SWord32 = s3 & s40+ s44 :: SBool = s16 /= s43+ s45 :: SBool = s42 ^ s44+ s47 :: SWord32 = s1 & s46+ s48 :: SBool = s16 /= s47+ s49 :: SWord32 = s3 & s46+ s50 :: SBool = s16 /= s49+ s51 :: SBool = s48 ^ s50+ s53 :: SWord32 = s1 & s52+ s54 :: SBool = s16 /= s53+ s55 :: SWord32 = s3 & s52+ s56 :: SBool = s16 /= s55+ s57 :: SBool = s54 ^ s56+ s59 :: SWord32 = s1 & s58+ s60 :: SBool = s16 /= s59+ s61 :: SWord32 = s3 & s58+ s62 :: SBool = s16 /= s61+ s63 :: SBool = s60 ^ s62+ s65 :: SWord32 = s1 & s64+ s66 :: SBool = s16 /= s65+ s67 :: SWord32 = s3 & s64+ s68 :: SBool = s16 /= s67+ s69 :: SBool = s66 ^ s68+ s71 :: SWord32 = s1 & s70+ s72 :: SBool = s16 /= s71+ s73 :: SWord32 = s3 & s70+ s74 :: SBool = s16 /= s73+ s75 :: SBool = s72 ^ s74+ s77 :: SWord32 = s1 & s76+ s78 :: SBool = s16 /= s77+ s79 :: SWord32 = s3 & s76+ s80 :: SBool = s16 /= s79+ s81 :: SBool = s78 ^ s80+ s83 :: SWord32 = s1 & s82+ s84 :: SBool = s16 /= s83+ s85 :: SWord32 = s3 & s82+ s86 :: SBool = s16 /= s85+ s87 :: SBool = s84 ^ s86+ s89 :: SWord32 = s1 & s88+ s90 :: SBool = s16 /= s89+ s91 :: SWord32 = s3 & s88+ s92 :: SBool = s16 /= s91+ s93 :: SBool = s90 ^ s92+ s95 :: SWord32 = s1 & s94+ s96 :: SBool = s16 /= s95+ s97 :: SWord32 = s3 & s94+ s98 :: SBool = s16 /= s97+ s99 :: SBool = s96 ^ s98+ s101 :: SWord32 = s1 & s100+ s102 :: SBool = s16 /= s101+ s103 :: SWord32 = s3 & s100+ s104 :: SBool = s16 /= s103+ s105 :: SBool = s102 ^ s104+ s107 :: SWord32 = s1 & s106+ s108 :: SBool = s16 /= s107+ s109 :: SWord32 = s3 & s106+ s110 :: SBool = s16 /= s109+ s111 :: SBool = s108 ^ s110+ s113 :: SWord32 = s1 & s112+ s114 :: SBool = s16 /= s113+ s115 :: SWord32 = s3 & s112+ s116 :: SBool = s16 /= s115+ s117 :: SBool = s114 ^ s116+ s119 :: SWord32 = s1 & s118+ s120 :: SBool = s16 /= s119+ s121 :: SWord32 = s3 & s118+ s122 :: SBool = s16 /= s121+ s123 :: SBool = s120 ^ s122+ s125 :: SWord32 = s1 & s124+ s126 :: SBool = s16 /= s125+ s127 :: SWord32 = s3 & s124+ s128 :: SBool = s16 /= s127+ s129 :: SBool = s126 ^ s128+ s131 :: SWord32 = s1 & s130+ s132 :: SBool = s16 /= s131+ s133 :: SWord32 = s3 & s130+ s134 :: SBool = s16 /= s133+ s135 :: SBool = s132 ^ s134+ s137 :: SWord32 = s1 & s136+ s138 :: SBool = s16 /= s137+ s139 :: SWord32 = s3 & s136+ s140 :: SBool = s16 /= s139+ s141 :: SBool = s138 ^ s140+ s143 :: SWord32 = s1 & s142+ s144 :: SBool = s16 /= s143+ s145 :: SWord32 = s3 & s142+ s146 :: SBool = s16 /= s145+ s147 :: SBool = s144 ^ s146+ s149 :: SWord32 = s1 & s148+ s150 :: SBool = s16 /= s149+ s151 :: SWord32 = s3 & s148+ s152 :: SBool = s16 /= s151+ s153 :: SBool = s150 ^ s152+ s155 :: SWord32 = s1 & s154+ s156 :: SBool = s16 /= s155+ s157 :: SWord32 = s3 & s154+ s158 :: SBool = s16 /= s157+ s159 :: SBool = s156 ^ s158+ s161 :: SWord32 = s1 & s160+ s162 :: SBool = s16 /= s161+ s163 :: SWord32 = s3 & s160+ s164 :: SBool = s16 /= s163+ s165 :: SBool = s162 ^ s164+ s167 :: SWord32 = s1 & s166+ s168 :: SBool = s16 /= s167+ s169 :: SWord32 = s3 & s166+ s170 :: SBool = s16 /= s169+ s171 :: SBool = s168 ^ s170+ s173 :: SWord32 = s1 & s172+ s174 :: SBool = s16 /= s173+ s175 :: SWord32 = s3 & s172+ s176 :: SBool = s16 /= s175+ s177 :: SBool = s174 ^ s176+ s179 :: SWord32 = s1 & s178+ s180 :: SBool = s16 /= s179+ s181 :: SWord32 = s3 & s178+ s182 :: SBool = s16 /= s181+ s183 :: SBool = s180 ^ s182+ s185 :: SWord32 = s1 & s184+ s186 :: SBool = s16 /= s185+ s187 :: SWord32 = s3 & s184+ s188 :: SBool = s16 /= s187+ s189 :: SBool = s186 ^ s188+ s191 :: SWord32 = s1 & s190+ s192 :: SBool = s16 /= s191+ s193 :: SWord32 = s3 & s190+ s194 :: SBool = s16 /= s193+ s195 :: SBool = s192 ^ s194+ s197 :: SWord32 = s1 & s196+ s198 :: SBool = s16 /= s197+ s199 :: SWord32 = s3 & s196+ s200 :: SBool = s16 /= s199+ s201 :: SBool = s198 ^ s200+ s203 :: SWord32 = s1 & s202+ s204 :: SBool = s16 /= s203+ s205 :: SWord32 = s3 & s202+ s206 :: SBool = s16 /= s205+ s207 :: SBool = s204 ^ s206+ s209 :: SWord16 = s2 & s208+ s210 :: SBool = s7 /= s209+ s211 :: SWord16 = s4 & s208+ s212 :: SBool = s7 /= s211+ s213 :: SBool = s210 ^ s212+ s215 :: SWord16 = s2 & s214+ s216 :: SBool = s7 /= s215+ s217 :: SWord16 = s4 & s214+ s218 :: SBool = s7 /= s217+ s219 :: SBool = s216 ^ s218+ s221 :: SWord16 = s2 & s220+ s222 :: SBool = s7 /= s221+ s223 :: SWord16 = s4 & s220+ s224 :: SBool = s7 /= s223+ s225 :: SBool = s222 ^ s224+ s227 :: SWord16 = s2 & s226+ s228 :: SBool = s7 /= s227+ s229 :: SWord16 = s4 & s226+ s230 :: SBool = s7 /= s229+ s231 :: SBool = s228 ^ s230+ s233 :: SWord16 = s2 & s232+ s234 :: SBool = s7 /= s233+ s235 :: SWord16 = s4 & s232+ s236 :: SBool = s7 /= s235+ s237 :: SBool = s234 ^ s236+ s239 :: SWord16 = s2 & s238+ s240 :: SBool = s7 /= s239+ s241 :: SWord16 = s4 & s238+ s242 :: SBool = s7 /= s241+ s243 :: SBool = s240 ^ s242+ s245 :: SWord16 = s2 & s244+ s246 :: SBool = s7 /= s245+ s247 :: SWord16 = s4 & s244+ s248 :: SBool = s7 /= s247+ s249 :: SBool = s246 ^ s248+ s251 :: SWord16 = s2 & s250+ s252 :: SBool = s7 /= s251+ s253 :: SWord16 = s4 & s250+ s254 :: SBool = s7 /= s253+ s255 :: SBool = s252 ^ s254+ s257 :: SWord16 = s2 & s256+ s258 :: SBool = s7 /= s257+ s259 :: SWord16 = s4 & s256+ s260 :: SBool = s7 /= s259+ s261 :: SBool = s258 ^ s260+ s263 :: SWord16 = s2 & s262+ s264 :: SBool = s7 /= s263+ s265 :: SWord16 = s4 & s262+ s266 :: SBool = s7 /= s265+ s267 :: SBool = s264 ^ s266+ s269 :: SWord16 = s2 & s268+ s270 :: SBool = s7 /= s269+ s271 :: SWord16 = s4 & s268+ s272 :: SBool = s7 /= s271+ s273 :: SBool = s270 ^ s272+ s275 :: SWord16 = s2 & s274+ s276 :: SBool = s7 /= s275+ s277 :: SWord16 = s4 & s274+ s278 :: SBool = s7 /= s277+ s279 :: SBool = s276 ^ s278+ s281 :: SWord16 = s2 & s280+ s282 :: SBool = s7 /= s281+ s283 :: SWord16 = s4 & s280+ s284 :: SBool = s7 /= s283+ s285 :: SBool = s282 ^ s284+ s287 :: SWord16 = s2 & s286+ s288 :: SBool = s7 /= s287+ s289 :: SWord16 = s4 & s286+ s290 :: SBool = s7 /= s289+ s291 :: SBool = s288 ^ s290+ s293 :: SWord16 = s2 & s292+ s294 :: SBool = s7 /= s293+ s295 :: SWord16 = s4 & s292+ s296 :: SBool = s7 /= s295+ s297 :: SBool = s294 ^ s296+ s298 :: SWord16 = s2 & s5+ s299 :: SBool = s7 /= s298+ s300 :: SWord16 = s4 & s5+ s301 :: SBool = s7 /= s300+ s302 :: SBool = s299 ^ s301+ s303 :: SWord16 = s0 & s208+ s304 :: SBool = s7 /= s303+ s305 :: SBool = s24 ^ s304+ s306 :: SBool = if s17 then s305 else s24+ s307 :: SWord16 = s0 & s214+ s308 :: SBool = s7 /= s307+ s309 :: SBool = s30 ^ s308+ s310 :: SBool = if s17 then s309 else s30+ s311 :: SBool = s304 ^ s310+ s312 :: SBool = if s306 then s311 else s310+ s313 :: SWord16 = s0 & s220+ s314 :: SBool = s7 /= s313+ s315 :: SBool = s36 ^ s314+ s316 :: SBool = if s17 then s315 else s36+ s317 :: SBool = s308 ^ s316+ s318 :: SBool = if s306 then s317 else s316+ s319 :: SBool = s304 ^ s318+ s320 :: SBool = if s312 then s319 else s318+ s321 :: SWord16 = s0 & s226+ s322 :: SBool = s7 /= s321+ s323 :: SBool = s42 ^ s322+ s324 :: SBool = if s17 then s323 else s42+ s325 :: SBool = s314 ^ s324+ s326 :: SBool = if s306 then s325 else s324+ s327 :: SBool = s308 ^ s326+ s328 :: SBool = if s312 then s327 else s326+ s329 :: SBool = s304 ^ s328+ s330 :: SBool = if s320 then s329 else s328+ s331 :: SWord16 = s0 & s232+ s332 :: SBool = s7 /= s331+ s333 :: SBool = s48 ^ s332+ s334 :: SBool = if s17 then s333 else s48+ s335 :: SBool = s322 ^ s334+ s336 :: SBool = if s306 then s335 else s334+ s337 :: SBool = s314 ^ s336+ s338 :: SBool = if s312 then s337 else s336+ s339 :: SBool = s308 ^ s338+ s340 :: SBool = if s320 then s339 else s338+ s341 :: SBool = s304 ^ s340+ s342 :: SBool = if s330 then s341 else s340+ s343 :: SWord16 = s0 & s238+ s344 :: SBool = s7 /= s343+ s345 :: SBool = s54 ^ s344+ s346 :: SBool = if s17 then s345 else s54+ s347 :: SBool = s332 ^ s346+ s348 :: SBool = if s306 then s347 else s346+ s349 :: SBool = s322 ^ s348+ s350 :: SBool = if s312 then s349 else s348+ s351 :: SBool = s314 ^ s350+ s352 :: SBool = if s320 then s351 else s350+ s353 :: SBool = s308 ^ s352+ s354 :: SBool = if s330 then s353 else s352+ s355 :: SBool = s304 ^ s354+ s356 :: SBool = if s342 then s355 else s354+ s357 :: SWord16 = s0 & s244+ s358 :: SBool = s7 /= s357+ s359 :: SBool = s60 ^ s358+ s360 :: SBool = if s17 then s359 else s60+ s361 :: SBool = s344 ^ s360+ s362 :: SBool = if s306 then s361 else s360+ s363 :: SBool = s332 ^ s362+ s364 :: SBool = if s312 then s363 else s362+ s365 :: SBool = s322 ^ s364+ s366 :: SBool = if s320 then s365 else s364+ s367 :: SBool = s314 ^ s366+ s368 :: SBool = if s330 then s367 else s366+ s369 :: SBool = s308 ^ s368+ s370 :: SBool = if s342 then s369 else s368+ s371 :: SBool = s304 ^ s370+ s372 :: SBool = if s356 then s371 else s370+ s373 :: SWord16 = s0 & s250+ s374 :: SBool = s7 /= s373+ s375 :: SBool = s66 ^ s374+ s376 :: SBool = if s17 then s375 else s66+ s377 :: SBool = s358 ^ s376+ s378 :: SBool = if s306 then s377 else s376+ s379 :: SBool = s344 ^ s378+ s380 :: SBool = if s312 then s379 else s378+ s381 :: SBool = s332 ^ s380+ s382 :: SBool = if s320 then s381 else s380+ s383 :: SBool = s322 ^ s382+ s384 :: SBool = if s330 then s383 else s382+ s385 :: SBool = s314 ^ s384+ s386 :: SBool = if s342 then s385 else s384+ s387 :: SBool = s308 ^ s386+ s388 :: SBool = if s356 then s387 else s386+ s389 :: SBool = s304 ^ s388+ s390 :: SBool = if s372 then s389 else s388+ s391 :: SWord16 = s0 & s256+ s392 :: SBool = s7 /= s391+ s393 :: SBool = s72 ^ s392+ s394 :: SBool = if s17 then s393 else s72+ s395 :: SBool = s374 ^ s394+ s396 :: SBool = if s306 then s395 else s394+ s397 :: SBool = s358 ^ s396+ s398 :: SBool = if s312 then s397 else s396+ s399 :: SBool = s344 ^ s398+ s400 :: SBool = if s320 then s399 else s398+ s401 :: SBool = s332 ^ s400+ s402 :: SBool = if s330 then s401 else s400+ s403 :: SBool = s322 ^ s402+ s404 :: SBool = if s342 then s403 else s402+ s405 :: SBool = s314 ^ s404+ s406 :: SBool = if s356 then s405 else s404+ s407 :: SBool = s308 ^ s406+ s408 :: SBool = if s372 then s407 else s406+ s409 :: SBool = s304 ^ s408+ s410 :: SBool = if s390 then s409 else s408+ s411 :: SWord16 = s0 & s262+ s412 :: SBool = s7 /= s411+ s413 :: SBool = s78 ^ s412+ s414 :: SBool = if s17 then s413 else s78+ s415 :: SBool = s392 ^ s414+ s416 :: SBool = if s306 then s415 else s414+ s417 :: SBool = s374 ^ s416+ s418 :: SBool = if s312 then s417 else s416+ s419 :: SBool = s358 ^ s418+ s420 :: SBool = if s320 then s419 else s418+ s421 :: SBool = s344 ^ s420+ s422 :: SBool = if s330 then s421 else s420+ s423 :: SBool = s332 ^ s422+ s424 :: SBool = if s342 then s423 else s422+ s425 :: SBool = s322 ^ s424+ s426 :: SBool = if s356 then s425 else s424+ s427 :: SBool = s314 ^ s426+ s428 :: SBool = if s372 then s427 else s426+ s429 :: SBool = s308 ^ s428+ s430 :: SBool = if s390 then s429 else s428+ s431 :: SBool = s304 ^ s430+ s432 :: SBool = if s410 then s431 else s430+ s433 :: SWord16 = s0 & s268+ s434 :: SBool = s7 /= s433+ s435 :: SBool = s84 ^ s434+ s436 :: SBool = if s17 then s435 else s84+ s437 :: SBool = s412 ^ s436+ s438 :: SBool = if s306 then s437 else s436+ s439 :: SBool = s392 ^ s438+ s440 :: SBool = if s312 then s439 else s438+ s441 :: SBool = s374 ^ s440+ s442 :: SBool = if s320 then s441 else s440+ s443 :: SBool = s358 ^ s442+ s444 :: SBool = if s330 then s443 else s442+ s445 :: SBool = s344 ^ s444+ s446 :: SBool = if s342 then s445 else s444+ s447 :: SBool = s332 ^ s446+ s448 :: SBool = if s356 then s447 else s446+ s449 :: SBool = s322 ^ s448+ s450 :: SBool = if s372 then s449 else s448+ s451 :: SBool = s314 ^ s450+ s452 :: SBool = if s390 then s451 else s450+ s453 :: SBool = s308 ^ s452+ s454 :: SBool = if s410 then s453 else s452+ s455 :: SBool = s304 ^ s454+ s456 :: SBool = if s432 then s455 else s454+ s457 :: SWord16 = s0 & s274+ s458 :: SBool = s7 /= s457+ s459 :: SBool = s90 ^ s458+ s460 :: SBool = if s17 then s459 else s90+ s461 :: SBool = s434 ^ s460+ s462 :: SBool = if s306 then s461 else s460+ s463 :: SBool = s412 ^ s462+ s464 :: SBool = if s312 then s463 else s462+ s465 :: SBool = s392 ^ s464+ s466 :: SBool = if s320 then s465 else s464+ s467 :: SBool = s374 ^ s466+ s468 :: SBool = if s330 then s467 else s466+ s469 :: SBool = s358 ^ s468+ s470 :: SBool = if s342 then s469 else s468+ s471 :: SBool = s344 ^ s470+ s472 :: SBool = if s356 then s471 else s470+ s473 :: SBool = s332 ^ s472+ s474 :: SBool = if s372 then s473 else s472+ s475 :: SBool = s322 ^ s474+ s476 :: SBool = if s390 then s475 else s474+ s477 :: SBool = s314 ^ s476+ s478 :: SBool = if s410 then s477 else s476+ s479 :: SBool = s308 ^ s478+ s480 :: SBool = if s432 then s479 else s478+ s481 :: SBool = s304 ^ s480+ s482 :: SBool = if s456 then s481 else s480+ s483 :: SWord16 = s0 & s280+ s484 :: SBool = s7 /= s483+ s485 :: SBool = s96 ^ s484+ s486 :: SBool = if s17 then s485 else s96+ s487 :: SBool = s458 ^ s486+ s488 :: SBool = if s306 then s487 else s486+ s489 :: SBool = s434 ^ s488+ s490 :: SBool = if s312 then s489 else s488+ s491 :: SBool = s412 ^ s490+ s492 :: SBool = if s320 then s491 else s490+ s493 :: SBool = s392 ^ s492+ s494 :: SBool = if s330 then s493 else s492+ s495 :: SBool = s374 ^ s494+ s496 :: SBool = if s342 then s495 else s494+ s497 :: SBool = s358 ^ s496+ s498 :: SBool = if s356 then s497 else s496+ s499 :: SBool = s344 ^ s498+ s500 :: SBool = if s372 then s499 else s498+ s501 :: SBool = s332 ^ s500+ s502 :: SBool = if s390 then s501 else s500+ s503 :: SBool = s322 ^ s502+ s504 :: SBool = if s410 then s503 else s502+ s505 :: SBool = s314 ^ s504+ s506 :: SBool = if s432 then s505 else s504+ s507 :: SBool = s308 ^ s506+ s508 :: SBool = if s456 then s507 else s506+ s509 :: SBool = s304 ^ s508+ s510 :: SBool = if s482 then s509 else s508+ s511 :: SWord16 = s0 & s286+ s512 :: SBool = s7 /= s511+ s513 :: SBool = s102 ^ s512+ s514 :: SBool = if s17 then s513 else s102+ s515 :: SBool = s484 ^ s514+ s516 :: SBool = if s306 then s515 else s514+ s517 :: SBool = s458 ^ s516+ s518 :: SBool = if s312 then s517 else s516+ s519 :: SBool = s434 ^ s518+ s520 :: SBool = if s320 then s519 else s518+ s521 :: SBool = s412 ^ s520+ s522 :: SBool = if s330 then s521 else s520+ s523 :: SBool = s392 ^ s522+ s524 :: SBool = if s342 then s523 else s522+ s525 :: SBool = s374 ^ s524+ s526 :: SBool = if s356 then s525 else s524+ s527 :: SBool = s358 ^ s526+ s528 :: SBool = if s372 then s527 else s526+ s529 :: SBool = s344 ^ s528+ s530 :: SBool = if s390 then s529 else s528+ s531 :: SBool = s332 ^ s530+ s532 :: SBool = if s410 then s531 else s530+ s533 :: SBool = s322 ^ s532+ s534 :: SBool = if s432 then s533 else s532+ s535 :: SBool = s314 ^ s534+ s536 :: SBool = if s456 then s535 else s534+ s537 :: SBool = s308 ^ s536+ s538 :: SBool = if s482 then s537 else s536+ s539 :: SBool = s304 ^ s538+ s540 :: SBool = if s510 then s539 else s538+ s541 :: SWord16 = s0 & s292+ s542 :: SBool = s7 /= s541+ s543 :: SBool = s108 ^ s542+ s544 :: SBool = if s17 then s543 else s108+ s545 :: SBool = s512 ^ s544+ s546 :: SBool = if s306 then s545 else s544+ s547 :: SBool = s484 ^ s546+ s548 :: SBool = if s312 then s547 else s546+ s549 :: SBool = s458 ^ s548+ s550 :: SBool = if s320 then s549 else s548+ s551 :: SBool = s434 ^ s550+ s552 :: SBool = if s330 then s551 else s550+ s553 :: SBool = s412 ^ s552+ s554 :: SBool = if s342 then s553 else s552+ s555 :: SBool = s392 ^ s554+ s556 :: SBool = if s356 then s555 else s554+ s557 :: SBool = s374 ^ s556+ s558 :: SBool = if s372 then s557 else s556+ s559 :: SBool = s358 ^ s558+ s560 :: SBool = if s390 then s559 else s558+ s561 :: SBool = s344 ^ s560+ s562 :: SBool = if s410 then s561 else s560+ s563 :: SBool = s332 ^ s562+ s564 :: SBool = if s432 then s563 else s562+ s565 :: SBool = s322 ^ s564+ s566 :: SBool = if s456 then s565 else s564+ s567 :: SBool = s314 ^ s566+ s568 :: SBool = if s482 then s567 else s566+ s569 :: SBool = s308 ^ s568+ s570 :: SBool = if s510 then s569 else s568+ s571 :: SBool = s304 ^ s570+ s572 :: SBool = if s540 then s571 else s570+ s573 :: SBool = s8 ^ s114+ s574 :: SBool = if s17 then s573 else s114+ s575 :: SBool = s542 ^ s574+ s576 :: SBool = if s306 then s575 else s574+ s577 :: SBool = s512 ^ s576+ s578 :: SBool = if s312 then s577 else s576+ s579 :: SBool = s484 ^ s578+ s580 :: SBool = if s320 then s579 else s578+ s581 :: SBool = s458 ^ s580+ s582 :: SBool = if s330 then s581 else s580+ s583 :: SBool = s434 ^ s582+ s584 :: SBool = if s342 then s583 else s582+ s585 :: SBool = s412 ^ s584+ s586 :: SBool = if s356 then s585 else s584+ s587 :: SBool = s392 ^ s586+ s588 :: SBool = if s372 then s587 else s586+ s589 :: SBool = s374 ^ s588+ s590 :: SBool = if s390 then s589 else s588+ s591 :: SBool = s358 ^ s590+ s592 :: SBool = if s410 then s591 else s590+ s593 :: SBool = s344 ^ s592+ s594 :: SBool = if s432 then s593 else s592+ s595 :: SBool = s332 ^ s594+ s596 :: SBool = if s456 then s595 else s594+ s597 :: SBool = s322 ^ s596+ s598 :: SBool = if s482 then s597 else s596+ s599 :: SBool = s314 ^ s598+ s600 :: SBool = if s510 then s599 else s598+ s601 :: SBool = s308 ^ s600+ s602 :: SBool = if s540 then s601 else s600+ s603 :: SBool = s304 ^ s602+ s604 :: SBool = if s572 then s603 else s602+ s605 :: SBool = s8 ^ s120+ s606 :: SBool = if s306 then s605 else s120+ s607 :: SBool = s542 ^ s606+ s608 :: SBool = if s312 then s607 else s606+ s609 :: SBool = s512 ^ s608+ s610 :: SBool = if s320 then s609 else s608+ s611 :: SBool = s484 ^ s610+ s612 :: SBool = if s330 then s611 else s610+ s613 :: SBool = s458 ^ s612+ s614 :: SBool = if s342 then s613 else s612+ s615 :: SBool = s434 ^ s614+ s616 :: SBool = if s356 then s615 else s614+ s617 :: SBool = s412 ^ s616+ s618 :: SBool = if s372 then s617 else s616+ s619 :: SBool = s392 ^ s618+ s620 :: SBool = if s390 then s619 else s618+ s621 :: SBool = s374 ^ s620+ s622 :: SBool = if s410 then s621 else s620+ s623 :: SBool = s358 ^ s622+ s624 :: SBool = if s432 then s623 else s622+ s625 :: SBool = s344 ^ s624+ s626 :: SBool = if s456 then s625 else s624+ s627 :: SBool = s332 ^ s626+ s628 :: SBool = if s482 then s627 else s626+ s629 :: SBool = s322 ^ s628+ s630 :: SBool = if s510 then s629 else s628+ s631 :: SBool = s314 ^ s630+ s632 :: SBool = if s540 then s631 else s630+ s633 :: SBool = s308 ^ s632+ s634 :: SBool = if s572 then s633 else s632+ s635 :: SBool = s304 ^ s634+ s636 :: SBool = if s604 then s635 else s634+ s637 :: SBool = s8 ^ s126+ s638 :: SBool = if s312 then s637 else s126+ s639 :: SBool = s542 ^ s638+ s640 :: SBool = if s320 then s639 else s638+ s641 :: SBool = s512 ^ s640+ s642 :: SBool = if s330 then s641 else s640+ s643 :: SBool = s484 ^ s642+ s644 :: SBool = if s342 then s643 else s642+ s645 :: SBool = s458 ^ s644+ s646 :: SBool = if s356 then s645 else s644+ s647 :: SBool = s434 ^ s646+ s648 :: SBool = if s372 then s647 else s646+ s649 :: SBool = s412 ^ s648+ s650 :: SBool = if s390 then s649 else s648+ s651 :: SBool = s392 ^ s650+ s652 :: SBool = if s410 then s651 else s650+ s653 :: SBool = s374 ^ s652+ s654 :: SBool = if s432 then s653 else s652+ s655 :: SBool = s358 ^ s654+ s656 :: SBool = if s456 then s655 else s654+ s657 :: SBool = s344 ^ s656+ s658 :: SBool = if s482 then s657 else s656+ s659 :: SBool = s332 ^ s658+ s660 :: SBool = if s510 then s659 else s658+ s661 :: SBool = s322 ^ s660+ s662 :: SBool = if s540 then s661 else s660+ s663 :: SBool = s314 ^ s662+ s664 :: SBool = if s572 then s663 else s662+ s665 :: SBool = s308 ^ s664+ s666 :: SBool = if s604 then s665 else s664+ s667 :: SBool = s304 ^ s666+ s668 :: SBool = if s636 then s667 else s666+ s669 :: SBool = s8 ^ s132+ s670 :: SBool = if s320 then s669 else s132+ s671 :: SBool = s542 ^ s670+ s672 :: SBool = if s330 then s671 else s670+ s673 :: SBool = s512 ^ s672+ s674 :: SBool = if s342 then s673 else s672+ s675 :: SBool = s484 ^ s674+ s676 :: SBool = if s356 then s675 else s674+ s677 :: SBool = s458 ^ s676+ s678 :: SBool = if s372 then s677 else s676+ s679 :: SBool = s434 ^ s678+ s680 :: SBool = if s390 then s679 else s678+ s681 :: SBool = s412 ^ s680+ s682 :: SBool = if s410 then s681 else s680+ s683 :: SBool = s392 ^ s682+ s684 :: SBool = if s432 then s683 else s682+ s685 :: SBool = s374 ^ s684+ s686 :: SBool = if s456 then s685 else s684+ s687 :: SBool = s358 ^ s686+ s688 :: SBool = if s482 then s687 else s686+ s689 :: SBool = s344 ^ s688+ s690 :: SBool = if s510 then s689 else s688+ s691 :: SBool = s332 ^ s690+ s692 :: SBool = if s540 then s691 else s690+ s693 :: SBool = s322 ^ s692+ s694 :: SBool = if s572 then s693 else s692+ s695 :: SBool = s314 ^ s694+ s696 :: SBool = if s604 then s695 else s694+ s697 :: SBool = s308 ^ s696+ s698 :: SBool = if s636 then s697 else s696+ s699 :: SBool = s304 ^ s698+ s700 :: SBool = if s668 then s699 else s698+ s701 :: SBool = s8 ^ s138+ s702 :: SBool = if s330 then s701 else s138+ s703 :: SBool = s542 ^ s702+ s704 :: SBool = if s342 then s703 else s702+ s705 :: SBool = s512 ^ s704+ s706 :: SBool = if s356 then s705 else s704+ s707 :: SBool = s484 ^ s706+ s708 :: SBool = if s372 then s707 else s706+ s709 :: SBool = s458 ^ s708+ s710 :: SBool = if s390 then s709 else s708+ s711 :: SBool = s434 ^ s710+ s712 :: SBool = if s410 then s711 else s710+ s713 :: SBool = s412 ^ s712+ s714 :: SBool = if s432 then s713 else s712+ s715 :: SBool = s392 ^ s714+ s716 :: SBool = if s456 then s715 else s714+ s717 :: SBool = s374 ^ s716+ s718 :: SBool = if s482 then s717 else s716+ s719 :: SBool = s358 ^ s718+ s720 :: SBool = if s510 then s719 else s718+ s721 :: SBool = s344 ^ s720+ s722 :: SBool = if s540 then s721 else s720+ s723 :: SBool = s332 ^ s722+ s724 :: SBool = if s572 then s723 else s722+ s725 :: SBool = s322 ^ s724+ s726 :: SBool = if s604 then s725 else s724+ s727 :: SBool = s314 ^ s726+ s728 :: SBool = if s636 then s727 else s726+ s729 :: SBool = s308 ^ s728+ s730 :: SBool = if s668 then s729 else s728+ s731 :: SBool = s304 ^ s730+ s732 :: SBool = if s700 then s731 else s730+ s733 :: SBool = s8 ^ s144+ s734 :: SBool = if s342 then s733 else s144+ s735 :: SBool = s542 ^ s734+ s736 :: SBool = if s356 then s735 else s734+ s737 :: SBool = s512 ^ s736+ s738 :: SBool = if s372 then s737 else s736+ s739 :: SBool = s484 ^ s738+ s740 :: SBool = if s390 then s739 else s738+ s741 :: SBool = s458 ^ s740+ s742 :: SBool = if s410 then s741 else s740+ s743 :: SBool = s434 ^ s742+ s744 :: SBool = if s432 then s743 else s742+ s745 :: SBool = s412 ^ s744+ s746 :: SBool = if s456 then s745 else s744+ s747 :: SBool = s392 ^ s746+ s748 :: SBool = if s482 then s747 else s746+ s749 :: SBool = s374 ^ s748+ s750 :: SBool = if s510 then s749 else s748+ s751 :: SBool = s358 ^ s750+ s752 :: SBool = if s540 then s751 else s750+ s753 :: SBool = s344 ^ s752+ s754 :: SBool = if s572 then s753 else s752+ s755 :: SBool = s332 ^ s754+ s756 :: SBool = if s604 then s755 else s754+ s757 :: SBool = s322 ^ s756+ s758 :: SBool = if s636 then s757 else s756+ s759 :: SBool = s314 ^ s758+ s760 :: SBool = if s668 then s759 else s758+ s761 :: SBool = s308 ^ s760+ s762 :: SBool = if s700 then s761 else s760+ s763 :: SBool = s304 ^ s762+ s764 :: SBool = if s732 then s763 else s762+ s765 :: SBool = s8 ^ s150+ s766 :: SBool = if s356 then s765 else s150+ s767 :: SBool = s542 ^ s766+ s768 :: SBool = if s372 then s767 else s766+ s769 :: SBool = s512 ^ s768+ s770 :: SBool = if s390 then s769 else s768+ s771 :: SBool = s484 ^ s770+ s772 :: SBool = if s410 then s771 else s770+ s773 :: SBool = s458 ^ s772+ s774 :: SBool = if s432 then s773 else s772+ s775 :: SBool = s434 ^ s774+ s776 :: SBool = if s456 then s775 else s774+ s777 :: SBool = s412 ^ s776+ s778 :: SBool = if s482 then s777 else s776+ s779 :: SBool = s392 ^ s778+ s780 :: SBool = if s510 then s779 else s778+ s781 :: SBool = s374 ^ s780+ s782 :: SBool = if s540 then s781 else s780+ s783 :: SBool = s358 ^ s782+ s784 :: SBool = if s572 then s783 else s782+ s785 :: SBool = s344 ^ s784+ s786 :: SBool = if s604 then s785 else s784+ s787 :: SBool = s332 ^ s786+ s788 :: SBool = if s636 then s787 else s786+ s789 :: SBool = s322 ^ s788+ s790 :: SBool = if s668 then s789 else s788+ s791 :: SBool = s314 ^ s790+ s792 :: SBool = if s700 then s791 else s790+ s793 :: SBool = s308 ^ s792+ s794 :: SBool = if s732 then s793 else s792+ s795 :: SBool = s304 ^ s794+ s796 :: SBool = if s764 then s795 else s794+ s797 :: SBool = s8 ^ s156+ s798 :: SBool = if s372 then s797 else s156+ s799 :: SBool = s542 ^ s798+ s800 :: SBool = if s390 then s799 else s798+ s801 :: SBool = s512 ^ s800+ s802 :: SBool = if s410 then s801 else s800+ s803 :: SBool = s484 ^ s802+ s804 :: SBool = if s432 then s803 else s802+ s805 :: SBool = s458 ^ s804+ s806 :: SBool = if s456 then s805 else s804+ s807 :: SBool = s434 ^ s806+ s808 :: SBool = if s482 then s807 else s806+ s809 :: SBool = s412 ^ s808+ s810 :: SBool = if s510 then s809 else s808+ s811 :: SBool = s392 ^ s810+ s812 :: SBool = if s540 then s811 else s810+ s813 :: SBool = s374 ^ s812+ s814 :: SBool = if s572 then s813 else s812+ s815 :: SBool = s358 ^ s814+ s816 :: SBool = if s604 then s815 else s814+ s817 :: SBool = s344 ^ s816+ s818 :: SBool = if s636 then s817 else s816+ s819 :: SBool = s332 ^ s818+ s820 :: SBool = if s668 then s819 else s818+ s821 :: SBool = s322 ^ s820+ s822 :: SBool = if s700 then s821 else s820+ s823 :: SBool = s314 ^ s822+ s824 :: SBool = if s732 then s823 else s822+ s825 :: SBool = s308 ^ s824+ s826 :: SBool = if s764 then s825 else s824+ s827 :: SBool = s304 ^ s826+ s828 :: SBool = if s796 then s827 else s826+ s829 :: SBool = s8 ^ s162+ s830 :: SBool = if s390 then s829 else s162+ s831 :: SBool = s542 ^ s830+ s832 :: SBool = if s410 then s831 else s830+ s833 :: SBool = s512 ^ s832+ s834 :: SBool = if s432 then s833 else s832+ s835 :: SBool = s484 ^ s834+ s836 :: SBool = if s456 then s835 else s834+ s837 :: SBool = s458 ^ s836+ s838 :: SBool = if s482 then s837 else s836+ s839 :: SBool = s434 ^ s838+ s840 :: SBool = if s510 then s839 else s838+ s841 :: SBool = s412 ^ s840+ s842 :: SBool = if s540 then s841 else s840+ s843 :: SBool = s392 ^ s842+ s844 :: SBool = if s572 then s843 else s842+ s845 :: SBool = s374 ^ s844+ s846 :: SBool = if s604 then s845 else s844+ s847 :: SBool = s358 ^ s846+ s848 :: SBool = if s636 then s847 else s846+ s849 :: SBool = s344 ^ s848+ s850 :: SBool = if s668 then s849 else s848+ s851 :: SBool = s332 ^ s850+ s852 :: SBool = if s700 then s851 else s850+ s853 :: SBool = s322 ^ s852+ s854 :: SBool = if s732 then s853 else s852+ s855 :: SBool = s314 ^ s854+ s856 :: SBool = if s764 then s855 else s854+ s857 :: SBool = s308 ^ s856+ s858 :: SBool = if s796 then s857 else s856+ s859 :: SBool = s304 ^ s858+ s860 :: SBool = if s828 then s859 else s858+ s861 :: SBool = s8 ^ s168+ s862 :: SBool = if s410 then s861 else s168+ s863 :: SBool = s542 ^ s862+ s864 :: SBool = if s432 then s863 else s862+ s865 :: SBool = s512 ^ s864+ s866 :: SBool = if s456 then s865 else s864+ s867 :: SBool = s484 ^ s866+ s868 :: SBool = if s482 then s867 else s866+ s869 :: SBool = s458 ^ s868+ s870 :: SBool = if s510 then s869 else s868+ s871 :: SBool = s434 ^ s870+ s872 :: SBool = if s540 then s871 else s870+ s873 :: SBool = s412 ^ s872+ s874 :: SBool = if s572 then s873 else s872+ s875 :: SBool = s392 ^ s874+ s876 :: SBool = if s604 then s875 else s874+ s877 :: SBool = s374 ^ s876+ s878 :: SBool = if s636 then s877 else s876+ s879 :: SBool = s358 ^ s878+ s880 :: SBool = if s668 then s879 else s878+ s881 :: SBool = s344 ^ s880+ s882 :: SBool = if s700 then s881 else s880+ s883 :: SBool = s332 ^ s882+ s884 :: SBool = if s732 then s883 else s882+ s885 :: SBool = s322 ^ s884+ s886 :: SBool = if s764 then s885 else s884+ s887 :: SBool = s314 ^ s886+ s888 :: SBool = if s796 then s887 else s886+ s889 :: SBool = s308 ^ s888+ s890 :: SBool = if s828 then s889 else s888+ s891 :: SBool = s304 ^ s890+ s892 :: SBool = if s860 then s891 else s890+ s893 :: SBool = s8 ^ s174+ s894 :: SBool = if s432 then s893 else s174+ s895 :: SBool = s542 ^ s894+ s896 :: SBool = if s456 then s895 else s894+ s897 :: SBool = s512 ^ s896+ s898 :: SBool = if s482 then s897 else s896+ s899 :: SBool = s484 ^ s898+ s900 :: SBool = if s510 then s899 else s898+ s901 :: SBool = s458 ^ s900+ s902 :: SBool = if s540 then s901 else s900+ s903 :: SBool = s434 ^ s902+ s904 :: SBool = if s572 then s903 else s902+ s905 :: SBool = s412 ^ s904+ s906 :: SBool = if s604 then s905 else s904+ s907 :: SBool = s392 ^ s906+ s908 :: SBool = if s636 then s907 else s906+ s909 :: SBool = s374 ^ s908+ s910 :: SBool = if s668 then s909 else s908+ s911 :: SBool = s358 ^ s910+ s912 :: SBool = if s700 then s911 else s910+ s913 :: SBool = s344 ^ s912+ s914 :: SBool = if s732 then s913 else s912+ s915 :: SBool = s332 ^ s914+ s916 :: SBool = if s764 then s915 else s914+ s917 :: SBool = s322 ^ s916+ s918 :: SBool = if s796 then s917 else s916+ s919 :: SBool = s314 ^ s918+ s920 :: SBool = if s828 then s919 else s918+ s921 :: SBool = s308 ^ s920+ s922 :: SBool = if s860 then s921 else s920+ s923 :: SBool = s304 ^ s922+ s924 :: SBool = if s892 then s923 else s922+ s925 :: SBool = s8 ^ s180+ s926 :: SBool = if s456 then s925 else s180+ s927 :: SBool = s542 ^ s926+ s928 :: SBool = if s482 then s927 else s926+ s929 :: SBool = s512 ^ s928+ s930 :: SBool = if s510 then s929 else s928+ s931 :: SBool = s484 ^ s930+ s932 :: SBool = if s540 then s931 else s930+ s933 :: SBool = s458 ^ s932+ s934 :: SBool = if s572 then s933 else s932+ s935 :: SBool = s434 ^ s934+ s936 :: SBool = if s604 then s935 else s934+ s937 :: SBool = s412 ^ s936+ s938 :: SBool = if s636 then s937 else s936+ s939 :: SBool = s392 ^ s938+ s940 :: SBool = if s668 then s939 else s938+ s941 :: SBool = s374 ^ s940+ s942 :: SBool = if s700 then s941 else s940+ s943 :: SBool = s358 ^ s942+ s944 :: SBool = if s732 then s943 else s942+ s945 :: SBool = s344 ^ s944+ s946 :: SBool = if s764 then s945 else s944+ s947 :: SBool = s332 ^ s946+ s948 :: SBool = if s796 then s947 else s946+ s949 :: SBool = s322 ^ s948+ s950 :: SBool = if s828 then s949 else s948+ s951 :: SBool = s314 ^ s950+ s952 :: SBool = if s860 then s951 else s950+ s953 :: SBool = s308 ^ s952+ s954 :: SBool = if s892 then s953 else s952+ s955 :: SBool = s304 ^ s954+ s956 :: SBool = if s924 then s955 else s954+ s957 :: SBool = s8 ^ s186+ s958 :: SBool = if s482 then s957 else s186+ s959 :: SBool = s542 ^ s958+ s960 :: SBool = if s510 then s959 else s958+ s961 :: SBool = s512 ^ s960+ s962 :: SBool = if s540 then s961 else s960+ s963 :: SBool = s484 ^ s962+ s964 :: SBool = if s572 then s963 else s962+ s965 :: SBool = s458 ^ s964+ s966 :: SBool = if s604 then s965 else s964+ s967 :: SBool = s434 ^ s966+ s968 :: SBool = if s636 then s967 else s966+ s969 :: SBool = s412 ^ s968+ s970 :: SBool = if s668 then s969 else s968+ s971 :: SBool = s392 ^ s970+ s972 :: SBool = if s700 then s971 else s970+ s973 :: SBool = s374 ^ s972+ s974 :: SBool = if s732 then s973 else s972+ s975 :: SBool = s358 ^ s974+ s976 :: SBool = if s764 then s975 else s974+ s977 :: SBool = s344 ^ s976+ s978 :: SBool = if s796 then s977 else s976+ s979 :: SBool = s332 ^ s978+ s980 :: SBool = if s828 then s979 else s978+ s981 :: SBool = s322 ^ s980+ s982 :: SBool = if s860 then s981 else s980+ s983 :: SBool = s314 ^ s982+ s984 :: SBool = if s892 then s983 else s982+ s985 :: SBool = s308 ^ s984+ s986 :: SBool = if s924 then s985 else s984+ s987 :: SBool = s304 ^ s986+ s988 :: SBool = if s956 then s987 else s986+ s989 :: SBool = s8 ^ s192+ s990 :: SBool = if s510 then s989 else s192+ s991 :: SBool = s542 ^ s990+ s992 :: SBool = if s540 then s991 else s990+ s993 :: SBool = s512 ^ s992+ s994 :: SBool = if s572 then s993 else s992+ s995 :: SBool = s484 ^ s994+ s996 :: SBool = if s604 then s995 else s994+ s997 :: SBool = s458 ^ s996+ s998 :: SBool = if s636 then s997 else s996+ s999 :: SBool = s434 ^ s998+ s1000 :: SBool = if s668 then s999 else s998+ s1001 :: SBool = s412 ^ s1000+ s1002 :: SBool = if s700 then s1001 else s1000+ s1003 :: SBool = s392 ^ s1002+ s1004 :: SBool = if s732 then s1003 else s1002+ s1005 :: SBool = s374 ^ s1004+ s1006 :: SBool = if s764 then s1005 else s1004+ s1007 :: SBool = s358 ^ s1006+ s1008 :: SBool = if s796 then s1007 else s1006+ s1009 :: SBool = s344 ^ s1008+ s1010 :: SBool = if s828 then s1009 else s1008+ s1011 :: SBool = s332 ^ s1010+ s1012 :: SBool = if s860 then s1011 else s1010+ s1013 :: SBool = s322 ^ s1012+ s1014 :: SBool = if s892 then s1013 else s1012+ s1015 :: SBool = s314 ^ s1014+ s1016 :: SBool = if s924 then s1015 else s1014+ s1017 :: SBool = s308 ^ s1016+ s1018 :: SBool = if s956 then s1017 else s1016+ s1019 :: SBool = s304 ^ s1018+ s1020 :: SBool = if s988 then s1019 else s1018+ s1021 :: SBool = s8 ^ s198+ s1022 :: SBool = if s540 then s1021 else s198+ s1023 :: SBool = s542 ^ s1022+ s1024 :: SBool = if s572 then s1023 else s1022+ s1025 :: SBool = s512 ^ s1024+ s1026 :: SBool = if s604 then s1025 else s1024+ s1027 :: SBool = s484 ^ s1026+ s1028 :: SBool = if s636 then s1027 else s1026+ s1029 :: SBool = s458 ^ s1028+ s1030 :: SBool = if s668 then s1029 else s1028+ s1031 :: SBool = s434 ^ s1030+ s1032 :: SBool = if s700 then s1031 else s1030+ s1033 :: SBool = s412 ^ s1032+ s1034 :: SBool = if s732 then s1033 else s1032+ s1035 :: SBool = s392 ^ s1034+ s1036 :: SBool = if s764 then s1035 else s1034+ s1037 :: SBool = s374 ^ s1036+ s1038 :: SBool = if s796 then s1037 else s1036+ s1039 :: SBool = s358 ^ s1038+ s1040 :: SBool = if s828 then s1039 else s1038+ s1041 :: SBool = s344 ^ s1040+ s1042 :: SBool = if s860 then s1041 else s1040+ s1043 :: SBool = s332 ^ s1042+ s1044 :: SBool = if s892 then s1043 else s1042+ s1045 :: SBool = s322 ^ s1044+ s1046 :: SBool = if s924 then s1045 else s1044+ s1047 :: SBool = s314 ^ s1046+ s1048 :: SBool = if s956 then s1047 else s1046+ s1049 :: SBool = s308 ^ s1048+ s1050 :: SBool = if s988 then s1049 else s1048+ s1051 :: SBool = s304 ^ s1050+ s1052 :: SBool = if s1020 then s1051 else s1050+ s1053 :: SBool = s8 ^ s204+ s1054 :: SBool = if s572 then s1053 else s204+ s1055 :: SBool = s542 ^ s1054+ s1056 :: SBool = if s604 then s1055 else s1054+ s1057 :: SBool = s512 ^ s1056+ s1058 :: SBool = if s636 then s1057 else s1056+ s1059 :: SBool = s484 ^ s1058+ s1060 :: SBool = if s668 then s1059 else s1058+ s1061 :: SBool = s458 ^ s1060+ s1062 :: SBool = if s700 then s1061 else s1060+ s1063 :: SBool = s434 ^ s1062+ s1064 :: SBool = if s732 then s1063 else s1062+ s1065 :: SBool = s412 ^ s1064+ s1066 :: SBool = if s764 then s1065 else s1064+ s1067 :: SBool = s392 ^ s1066+ s1068 :: SBool = if s796 then s1067 else s1066+ s1069 :: SBool = s374 ^ s1068+ s1070 :: SBool = if s828 then s1069 else s1068+ s1071 :: SBool = s358 ^ s1070+ s1072 :: SBool = if s860 then s1071 else s1070+ s1073 :: SBool = s344 ^ s1072+ s1074 :: SBool = if s892 then s1073 else s1072+ s1075 :: SBool = s332 ^ s1074+ s1076 :: SBool = if s924 then s1075 else s1074+ s1077 :: SBool = s322 ^ s1076+ s1078 :: SBool = if s956 then s1077 else s1076+ s1079 :: SBool = s314 ^ s1078+ s1080 :: SBool = if s988 then s1079 else s1078+ s1081 :: SBool = s308 ^ s1080+ s1082 :: SBool = if s1020 then s1081 else s1080+ s1083 :: SBool = s304 ^ s1082+ s1084 :: SBool = if s1052 then s1083 else s1082+ s1085 :: SBool = s8 ^ s210+ s1086 :: SBool = if s604 then s1085 else s210+ s1087 :: SBool = s542 ^ s1086+ s1088 :: SBool = if s636 then s1087 else s1086+ s1089 :: SBool = s512 ^ s1088+ s1090 :: SBool = if s668 then s1089 else s1088+ s1091 :: SBool = s484 ^ s1090+ s1092 :: SBool = if s700 then s1091 else s1090+ s1093 :: SBool = s458 ^ s1092+ s1094 :: SBool = if s732 then s1093 else s1092+ s1095 :: SBool = s434 ^ s1094+ s1096 :: SBool = if s764 then s1095 else s1094+ s1097 :: SBool = s412 ^ s1096+ s1098 :: SBool = if s796 then s1097 else s1096+ s1099 :: SBool = s392 ^ s1098+ s1100 :: SBool = if s828 then s1099 else s1098+ s1101 :: SBool = s374 ^ s1100+ s1102 :: SBool = if s860 then s1101 else s1100+ s1103 :: SBool = s358 ^ s1102+ s1104 :: SBool = if s892 then s1103 else s1102+ s1105 :: SBool = s344 ^ s1104+ s1106 :: SBool = if s924 then s1105 else s1104+ s1107 :: SBool = s332 ^ s1106+ s1108 :: SBool = if s956 then s1107 else s1106+ s1109 :: SBool = s322 ^ s1108+ s1110 :: SBool = if s988 then s1109 else s1108+ s1111 :: SBool = s314 ^ s1110+ s1112 :: SBool = if s1020 then s1111 else s1110+ s1113 :: SBool = s308 ^ s1112+ s1114 :: SBool = if s1052 then s1113 else s1112+ s1115 :: SBool = s304 ^ s1114+ s1116 :: SBool = if s1084 then s1115 else s1114+ s1117 :: SBool = s8 ^ s216+ s1118 :: SBool = if s636 then s1117 else s216+ s1119 :: SBool = s542 ^ s1118+ s1120 :: SBool = if s668 then s1119 else s1118+ s1121 :: SBool = s512 ^ s1120+ s1122 :: SBool = if s700 then s1121 else s1120+ s1123 :: SBool = s484 ^ s1122+ s1124 :: SBool = if s732 then s1123 else s1122+ s1125 :: SBool = s458 ^ s1124+ s1126 :: SBool = if s764 then s1125 else s1124+ s1127 :: SBool = s434 ^ s1126+ s1128 :: SBool = if s796 then s1127 else s1126+ s1129 :: SBool = s412 ^ s1128+ s1130 :: SBool = if s828 then s1129 else s1128+ s1131 :: SBool = s392 ^ s1130+ s1132 :: SBool = if s860 then s1131 else s1130+ s1133 :: SBool = s374 ^ s1132+ s1134 :: SBool = if s892 then s1133 else s1132+ s1135 :: SBool = s358 ^ s1134+ s1136 :: SBool = if s924 then s1135 else s1134+ s1137 :: SBool = s344 ^ s1136+ s1138 :: SBool = if s956 then s1137 else s1136+ s1139 :: SBool = s332 ^ s1138+ s1140 :: SBool = if s988 then s1139 else s1138+ s1141 :: SBool = s322 ^ s1140+ s1142 :: SBool = if s1020 then s1141 else s1140+ s1143 :: SBool = s314 ^ s1142+ s1144 :: SBool = if s1052 then s1143 else s1142+ s1145 :: SBool = s308 ^ s1144+ s1146 :: SBool = if s1084 then s1145 else s1144+ s1147 :: SBool = s304 ^ s1146+ s1148 :: SBool = if s1116 then s1147 else s1146+ s1149 :: SBool = s8 ^ s222+ s1150 :: SBool = if s668 then s1149 else s222+ s1151 :: SBool = s542 ^ s1150+ s1152 :: SBool = if s700 then s1151 else s1150+ s1153 :: SBool = s512 ^ s1152+ s1154 :: SBool = if s732 then s1153 else s1152+ s1155 :: SBool = s484 ^ s1154+ s1156 :: SBool = if s764 then s1155 else s1154+ s1157 :: SBool = s458 ^ s1156+ s1158 :: SBool = if s796 then s1157 else s1156+ s1159 :: SBool = s434 ^ s1158+ s1160 :: SBool = if s828 then s1159 else s1158+ s1161 :: SBool = s412 ^ s1160+ s1162 :: SBool = if s860 then s1161 else s1160+ s1163 :: SBool = s392 ^ s1162+ s1164 :: SBool = if s892 then s1163 else s1162+ s1165 :: SBool = s374 ^ s1164+ s1166 :: SBool = if s924 then s1165 else s1164+ s1167 :: SBool = s358 ^ s1166+ s1168 :: SBool = if s956 then s1167 else s1166+ s1169 :: SBool = s344 ^ s1168+ s1170 :: SBool = if s988 then s1169 else s1168+ s1171 :: SBool = s332 ^ s1170+ s1172 :: SBool = if s1020 then s1171 else s1170+ s1173 :: SBool = s322 ^ s1172+ s1174 :: SBool = if s1052 then s1173 else s1172+ s1175 :: SBool = s314 ^ s1174+ s1176 :: SBool = if s1084 then s1175 else s1174+ s1177 :: SBool = s308 ^ s1176+ s1178 :: SBool = if s1116 then s1177 else s1176+ s1179 :: SBool = s304 ^ s1178+ s1180 :: SBool = if s1148 then s1179 else s1178+ s1181 :: SBool = s8 ^ s228+ s1182 :: SBool = if s700 then s1181 else s228+ s1183 :: SBool = s542 ^ s1182+ s1184 :: SBool = if s732 then s1183 else s1182+ s1185 :: SBool = s512 ^ s1184+ s1186 :: SBool = if s764 then s1185 else s1184+ s1187 :: SBool = s484 ^ s1186+ s1188 :: SBool = if s796 then s1187 else s1186+ s1189 :: SBool = s458 ^ s1188+ s1190 :: SBool = if s828 then s1189 else s1188+ s1191 :: SBool = s434 ^ s1190+ s1192 :: SBool = if s860 then s1191 else s1190+ s1193 :: SBool = s412 ^ s1192+ s1194 :: SBool = if s892 then s1193 else s1192+ s1195 :: SBool = s392 ^ s1194+ s1196 :: SBool = if s924 then s1195 else s1194+ s1197 :: SBool = s374 ^ s1196+ s1198 :: SBool = if s956 then s1197 else s1196+ s1199 :: SBool = s358 ^ s1198+ s1200 :: SBool = if s988 then s1199 else s1198+ s1201 :: SBool = s344 ^ s1200+ s1202 :: SBool = if s1020 then s1201 else s1200+ s1203 :: SBool = s332 ^ s1202+ s1204 :: SBool = if s1052 then s1203 else s1202+ s1205 :: SBool = s322 ^ s1204+ s1206 :: SBool = if s1084 then s1205 else s1204+ s1207 :: SBool = s314 ^ s1206+ s1208 :: SBool = if s1116 then s1207 else s1206+ s1209 :: SBool = s308 ^ s1208+ s1210 :: SBool = if s1148 then s1209 else s1208+ s1211 :: SBool = s304 ^ s1210+ s1212 :: SBool = if s1180 then s1211 else s1210+ s1213 :: SBool = s8 ^ s234+ s1214 :: SBool = if s732 then s1213 else s234+ s1215 :: SBool = s542 ^ s1214+ s1216 :: SBool = if s764 then s1215 else s1214+ s1217 :: SBool = s512 ^ s1216+ s1218 :: SBool = if s796 then s1217 else s1216+ s1219 :: SBool = s484 ^ s1218+ s1220 :: SBool = if s828 then s1219 else s1218+ s1221 :: SBool = s458 ^ s1220+ s1222 :: SBool = if s860 then s1221 else s1220+ s1223 :: SBool = s434 ^ s1222+ s1224 :: SBool = if s892 then s1223 else s1222+ s1225 :: SBool = s412 ^ s1224+ s1226 :: SBool = if s924 then s1225 else s1224+ s1227 :: SBool = s392 ^ s1226+ s1228 :: SBool = if s956 then s1227 else s1226+ s1229 :: SBool = s374 ^ s1228+ s1230 :: SBool = if s988 then s1229 else s1228+ s1231 :: SBool = s358 ^ s1230+ s1232 :: SBool = if s1020 then s1231 else s1230+ s1233 :: SBool = s344 ^ s1232+ s1234 :: SBool = if s1052 then s1233 else s1232+ s1235 :: SBool = s332 ^ s1234+ s1236 :: SBool = if s1084 then s1235 else s1234+ s1237 :: SBool = s322 ^ s1236+ s1238 :: SBool = if s1116 then s1237 else s1236+ s1239 :: SBool = s314 ^ s1238+ s1240 :: SBool = if s1148 then s1239 else s1238+ s1241 :: SBool = s308 ^ s1240+ s1242 :: SBool = if s1180 then s1241 else s1240+ s1243 :: SBool = s304 ^ s1242+ s1244 :: SBool = if s1212 then s1243 else s1242+ s1245 :: SBool = s8 ^ s240+ s1246 :: SBool = if s764 then s1245 else s240+ s1247 :: SBool = s542 ^ s1246+ s1248 :: SBool = if s796 then s1247 else s1246+ s1249 :: SBool = s512 ^ s1248+ s1250 :: SBool = if s828 then s1249 else s1248+ s1251 :: SBool = s484 ^ s1250+ s1252 :: SBool = if s860 then s1251 else s1250+ s1253 :: SBool = s458 ^ s1252+ s1254 :: SBool = if s892 then s1253 else s1252+ s1255 :: SBool = s434 ^ s1254+ s1256 :: SBool = if s924 then s1255 else s1254+ s1257 :: SBool = s412 ^ s1256+ s1258 :: SBool = if s956 then s1257 else s1256+ s1259 :: SBool = s392 ^ s1258+ s1260 :: SBool = if s988 then s1259 else s1258+ s1261 :: SBool = s374 ^ s1260+ s1262 :: SBool = if s1020 then s1261 else s1260+ s1263 :: SBool = s358 ^ s1262+ s1264 :: SBool = if s1052 then s1263 else s1262+ s1265 :: SBool = s344 ^ s1264+ s1266 :: SBool = if s1084 then s1265 else s1264+ s1267 :: SBool = s332 ^ s1266+ s1268 :: SBool = if s1116 then s1267 else s1266+ s1269 :: SBool = s322 ^ s1268+ s1270 :: SBool = if s1148 then s1269 else s1268+ s1271 :: SBool = s314 ^ s1270+ s1272 :: SBool = if s1180 then s1271 else s1270+ s1273 :: SBool = s308 ^ s1272+ s1274 :: SBool = if s1212 then s1273 else s1272+ s1275 :: SBool = s304 ^ s1274+ s1276 :: SBool = if s1244 then s1275 else s1274+ s1277 :: SBool = s8 ^ s246+ s1278 :: SBool = if s796 then s1277 else s246+ s1279 :: SBool = s542 ^ s1278+ s1280 :: SBool = if s828 then s1279 else s1278+ s1281 :: SBool = s512 ^ s1280+ s1282 :: SBool = if s860 then s1281 else s1280+ s1283 :: SBool = s484 ^ s1282+ s1284 :: SBool = if s892 then s1283 else s1282+ s1285 :: SBool = s458 ^ s1284+ s1286 :: SBool = if s924 then s1285 else s1284+ s1287 :: SBool = s434 ^ s1286+ s1288 :: SBool = if s956 then s1287 else s1286+ s1289 :: SBool = s412 ^ s1288+ s1290 :: SBool = if s988 then s1289 else s1288+ s1291 :: SBool = s392 ^ s1290+ s1292 :: SBool = if s1020 then s1291 else s1290+ s1293 :: SBool = s374 ^ s1292+ s1294 :: SBool = if s1052 then s1293 else s1292+ s1295 :: SBool = s358 ^ s1294+ s1296 :: SBool = if s1084 then s1295 else s1294+ s1297 :: SBool = s344 ^ s1296+ s1298 :: SBool = if s1116 then s1297 else s1296+ s1299 :: SBool = s332 ^ s1298+ s1300 :: SBool = if s1148 then s1299 else s1298+ s1301 :: SBool = s322 ^ s1300+ s1302 :: SBool = if s1180 then s1301 else s1300+ s1303 :: SBool = s314 ^ s1302+ s1304 :: SBool = if s1212 then s1303 else s1302+ s1305 :: SBool = s308 ^ s1304+ s1306 :: SBool = if s1244 then s1305 else s1304+ s1307 :: SBool = s304 ^ s1306+ s1308 :: SBool = if s1276 then s1307 else s1306+ s1309 :: SBool = s8 ^ s252+ s1310 :: SBool = if s828 then s1309 else s252+ s1311 :: SBool = s542 ^ s1310+ s1312 :: SBool = if s860 then s1311 else s1310+ s1313 :: SBool = s512 ^ s1312+ s1314 :: SBool = if s892 then s1313 else s1312+ s1315 :: SBool = s484 ^ s1314+ s1316 :: SBool = if s924 then s1315 else s1314+ s1317 :: SBool = s458 ^ s1316+ s1318 :: SBool = if s956 then s1317 else s1316+ s1319 :: SBool = s434 ^ s1318+ s1320 :: SBool = if s988 then s1319 else s1318+ s1321 :: SBool = s412 ^ s1320+ s1322 :: SBool = if s1020 then s1321 else s1320+ s1323 :: SBool = s392 ^ s1322+ s1324 :: SBool = if s1052 then s1323 else s1322+ s1325 :: SBool = s374 ^ s1324+ s1326 :: SBool = if s1084 then s1325 else s1324+ s1327 :: SBool = s358 ^ s1326+ s1328 :: SBool = if s1116 then s1327 else s1326+ s1329 :: SBool = s344 ^ s1328+ s1330 :: SBool = if s1148 then s1329 else s1328+ s1331 :: SBool = s332 ^ s1330+ s1332 :: SBool = if s1180 then s1331 else s1330+ s1333 :: SBool = s322 ^ s1332+ s1334 :: SBool = if s1212 then s1333 else s1332+ s1335 :: SBool = s314 ^ s1334+ s1336 :: SBool = if s1244 then s1335 else s1334+ s1337 :: SBool = s308 ^ s1336+ s1338 :: SBool = if s1276 then s1337 else s1336+ s1339 :: SBool = s304 ^ s1338+ s1340 :: SBool = if s1308 then s1339 else s1338+ s1341 :: SBool = s8 ^ s258+ s1342 :: SBool = if s860 then s1341 else s258+ s1343 :: SBool = s542 ^ s1342+ s1344 :: SBool = if s892 then s1343 else s1342+ s1345 :: SBool = s512 ^ s1344+ s1346 :: SBool = if s924 then s1345 else s1344+ s1347 :: SBool = s484 ^ s1346+ s1348 :: SBool = if s956 then s1347 else s1346+ s1349 :: SBool = s458 ^ s1348+ s1350 :: SBool = if s988 then s1349 else s1348+ s1351 :: SBool = s434 ^ s1350+ s1352 :: SBool = if s1020 then s1351 else s1350+ s1353 :: SBool = s412 ^ s1352+ s1354 :: SBool = if s1052 then s1353 else s1352+ s1355 :: SBool = s392 ^ s1354+ s1356 :: SBool = if s1084 then s1355 else s1354+ s1357 :: SBool = s374 ^ s1356+ s1358 :: SBool = if s1116 then s1357 else s1356+ s1359 :: SBool = s358 ^ s1358+ s1360 :: SBool = if s1148 then s1359 else s1358+ s1361 :: SBool = s344 ^ s1360+ s1362 :: SBool = if s1180 then s1361 else s1360+ s1363 :: SBool = s332 ^ s1362+ s1364 :: SBool = if s1212 then s1363 else s1362+ s1365 :: SBool = s322 ^ s1364+ s1366 :: SBool = if s1244 then s1365 else s1364+ s1367 :: SBool = s314 ^ s1366+ s1368 :: SBool = if s1276 then s1367 else s1366+ s1369 :: SBool = s308 ^ s1368+ s1370 :: SBool = if s1308 then s1369 else s1368+ s1371 :: SBool = s304 ^ s1370+ s1372 :: SBool = if s1340 then s1371 else s1370+ s1373 :: SBool = s8 ^ s264+ s1374 :: SBool = if s892 then s1373 else s264+ s1375 :: SBool = s542 ^ s1374+ s1376 :: SBool = if s924 then s1375 else s1374+ s1377 :: SBool = s512 ^ s1376+ s1378 :: SBool = if s956 then s1377 else s1376+ s1379 :: SBool = s484 ^ s1378+ s1380 :: SBool = if s988 then s1379 else s1378+ s1381 :: SBool = s458 ^ s1380+ s1382 :: SBool = if s1020 then s1381 else s1380+ s1383 :: SBool = s434 ^ s1382+ s1384 :: SBool = if s1052 then s1383 else s1382+ s1385 :: SBool = s412 ^ s1384+ s1386 :: SBool = if s1084 then s1385 else s1384+ s1387 :: SBool = s392 ^ s1386+ s1388 :: SBool = if s1116 then s1387 else s1386+ s1389 :: SBool = s374 ^ s1388+ s1390 :: SBool = if s1148 then s1389 else s1388+ s1391 :: SBool = s358 ^ s1390+ s1392 :: SBool = if s1180 then s1391 else s1390+ s1393 :: SBool = s344 ^ s1392+ s1394 :: SBool = if s1212 then s1393 else s1392+ s1395 :: SBool = s332 ^ s1394+ s1396 :: SBool = if s1244 then s1395 else s1394+ s1397 :: SBool = s322 ^ s1396+ s1398 :: SBool = if s1276 then s1397 else s1396+ s1399 :: SBool = s314 ^ s1398+ s1400 :: SBool = if s1308 then s1399 else s1398+ s1401 :: SBool = s308 ^ s1400+ s1402 :: SBool = if s1340 then s1401 else s1400+ s1403 :: SBool = s304 ^ s1402+ s1404 :: SBool = if s1372 then s1403 else s1402+ s1405 :: SBool = s8 ^ s270+ s1406 :: SBool = if s924 then s1405 else s270+ s1407 :: SBool = s542 ^ s1406+ s1408 :: SBool = if s956 then s1407 else s1406+ s1409 :: SBool = s512 ^ s1408+ s1410 :: SBool = if s988 then s1409 else s1408+ s1411 :: SBool = s484 ^ s1410+ s1412 :: SBool = if s1020 then s1411 else s1410+ s1413 :: SBool = s458 ^ s1412+ s1414 :: SBool = if s1052 then s1413 else s1412+ s1415 :: SBool = s434 ^ s1414+ s1416 :: SBool = if s1084 then s1415 else s1414+ s1417 :: SBool = s412 ^ s1416+ s1418 :: SBool = if s1116 then s1417 else s1416+ s1419 :: SBool = s392 ^ s1418+ s1420 :: SBool = if s1148 then s1419 else s1418+ s1421 :: SBool = s374 ^ s1420+ s1422 :: SBool = if s1180 then s1421 else s1420+ s1423 :: SBool = s358 ^ s1422+ s1424 :: SBool = if s1212 then s1423 else s1422+ s1425 :: SBool = s344 ^ s1424+ s1426 :: SBool = if s1244 then s1425 else s1424+ s1427 :: SBool = s332 ^ s1426+ s1428 :: SBool = if s1276 then s1427 else s1426+ s1429 :: SBool = s322 ^ s1428+ s1430 :: SBool = if s1308 then s1429 else s1428+ s1431 :: SBool = s314 ^ s1430+ s1432 :: SBool = if s1340 then s1431 else s1430+ s1433 :: SBool = s308 ^ s1432+ s1434 :: SBool = if s1372 then s1433 else s1432+ s1435 :: SBool = s304 ^ s1434+ s1436 :: SBool = if s1404 then s1435 else s1434+ s1437 :: SBool = s8 ^ s276+ s1438 :: SBool = if s956 then s1437 else s276+ s1439 :: SBool = s542 ^ s1438+ s1440 :: SBool = if s988 then s1439 else s1438+ s1441 :: SBool = s512 ^ s1440+ s1442 :: SBool = if s1020 then s1441 else s1440+ s1443 :: SBool = s484 ^ s1442+ s1444 :: SBool = if s1052 then s1443 else s1442+ s1445 :: SBool = s458 ^ s1444+ s1446 :: SBool = if s1084 then s1445 else s1444+ s1447 :: SBool = s434 ^ s1446+ s1448 :: SBool = if s1116 then s1447 else s1446+ s1449 :: SBool = s412 ^ s1448+ s1450 :: SBool = if s1148 then s1449 else s1448+ s1451 :: SBool = s392 ^ s1450+ s1452 :: SBool = if s1180 then s1451 else s1450+ s1453 :: SBool = s374 ^ s1452+ s1454 :: SBool = if s1212 then s1453 else s1452+ s1455 :: SBool = s358 ^ s1454+ s1456 :: SBool = if s1244 then s1455 else s1454+ s1457 :: SBool = s344 ^ s1456+ s1458 :: SBool = if s1276 then s1457 else s1456+ s1459 :: SBool = s332 ^ s1458+ s1460 :: SBool = if s1308 then s1459 else s1458+ s1461 :: SBool = s322 ^ s1460+ s1462 :: SBool = if s1340 then s1461 else s1460+ s1463 :: SBool = s314 ^ s1462+ s1464 :: SBool = if s1372 then s1463 else s1462+ s1465 :: SBool = s308 ^ s1464+ s1466 :: SBool = if s1404 then s1465 else s1464+ s1467 :: SBool = s304 ^ s1466+ s1468 :: SBool = if s1436 then s1467 else s1466+ s1469 :: SBool = s8 ^ s282+ s1470 :: SBool = if s988 then s1469 else s282+ s1471 :: SBool = s542 ^ s1470+ s1472 :: SBool = if s1020 then s1471 else s1470+ s1473 :: SBool = s512 ^ s1472+ s1474 :: SBool = if s1052 then s1473 else s1472+ s1475 :: SBool = s484 ^ s1474+ s1476 :: SBool = if s1084 then s1475 else s1474+ s1477 :: SBool = s458 ^ s1476+ s1478 :: SBool = if s1116 then s1477 else s1476+ s1479 :: SBool = s434 ^ s1478+ s1480 :: SBool = if s1148 then s1479 else s1478+ s1481 :: SBool = s412 ^ s1480+ s1482 :: SBool = if s1180 then s1481 else s1480+ s1483 :: SBool = s392 ^ s1482+ s1484 :: SBool = if s1212 then s1483 else s1482+ s1485 :: SBool = s374 ^ s1484+ s1486 :: SBool = if s1244 then s1485 else s1484+ s1487 :: SBool = s358 ^ s1486+ s1488 :: SBool = if s1276 then s1487 else s1486+ s1489 :: SBool = s344 ^ s1488+ s1490 :: SBool = if s1308 then s1489 else s1488+ s1491 :: SBool = s332 ^ s1490+ s1492 :: SBool = if s1340 then s1491 else s1490+ s1493 :: SBool = s322 ^ s1492+ s1494 :: SBool = if s1372 then s1493 else s1492+ s1495 :: SBool = s314 ^ s1494+ s1496 :: SBool = if s1404 then s1495 else s1494+ s1497 :: SBool = s308 ^ s1496+ s1498 :: SBool = if s1436 then s1497 else s1496+ s1499 :: SBool = s304 ^ s1498+ s1500 :: SBool = if s1468 then s1499 else s1498+ s1501 :: SBool = s8 ^ s288+ s1502 :: SBool = if s1020 then s1501 else s288+ s1503 :: SBool = s542 ^ s1502+ s1504 :: SBool = if s1052 then s1503 else s1502+ s1505 :: SBool = s512 ^ s1504+ s1506 :: SBool = if s1084 then s1505 else s1504+ s1507 :: SBool = s484 ^ s1506+ s1508 :: SBool = if s1116 then s1507 else s1506+ s1509 :: SBool = s458 ^ s1508+ s1510 :: SBool = if s1148 then s1509 else s1508+ s1511 :: SBool = s434 ^ s1510+ s1512 :: SBool = if s1180 then s1511 else s1510+ s1513 :: SBool = s412 ^ s1512+ s1514 :: SBool = if s1212 then s1513 else s1512+ s1515 :: SBool = s392 ^ s1514+ s1516 :: SBool = if s1244 then s1515 else s1514+ s1517 :: SBool = s374 ^ s1516+ s1518 :: SBool = if s1276 then s1517 else s1516+ s1519 :: SBool = s358 ^ s1518+ s1520 :: SBool = if s1308 then s1519 else s1518+ s1521 :: SBool = s344 ^ s1520+ s1522 :: SBool = if s1340 then s1521 else s1520+ s1523 :: SBool = s332 ^ s1522+ s1524 :: SBool = if s1372 then s1523 else s1522+ s1525 :: SBool = s322 ^ s1524+ s1526 :: SBool = if s1404 then s1525 else s1524+ s1527 :: SBool = s314 ^ s1526+ s1528 :: SBool = if s1436 then s1527 else s1526+ s1529 :: SBool = s308 ^ s1528+ s1530 :: SBool = if s1468 then s1529 else s1528+ s1531 :: SBool = s304 ^ s1530+ s1532 :: SBool = if s1500 then s1531 else s1530+ s1533 :: SBool = s8 ^ s294+ s1534 :: SBool = if s1052 then s1533 else s294+ s1535 :: SBool = s542 ^ s1534+ s1536 :: SBool = if s1084 then s1535 else s1534+ s1537 :: SBool = s512 ^ s1536+ s1538 :: SBool = if s1116 then s1537 else s1536+ s1539 :: SBool = s484 ^ s1538+ s1540 :: SBool = if s1148 then s1539 else s1538+ s1541 :: SBool = s458 ^ s1540+ s1542 :: SBool = if s1180 then s1541 else s1540+ s1543 :: SBool = s434 ^ s1542+ s1544 :: SBool = if s1212 then s1543 else s1542+ s1545 :: SBool = s412 ^ s1544+ s1546 :: SBool = if s1244 then s1545 else s1544+ s1547 :: SBool = s392 ^ s1546+ s1548 :: SBool = if s1276 then s1547 else s1546+ s1549 :: SBool = s374 ^ s1548+ s1550 :: SBool = if s1308 then s1549 else s1548+ s1551 :: SBool = s358 ^ s1550+ s1552 :: SBool = if s1340 then s1551 else s1550+ s1553 :: SBool = s344 ^ s1552+ s1554 :: SBool = if s1372 then s1553 else s1552+ s1555 :: SBool = s332 ^ s1554+ s1556 :: SBool = if s1404 then s1555 else s1554+ s1557 :: SBool = s322 ^ s1556+ s1558 :: SBool = if s1436 then s1557 else s1556+ s1559 :: SBool = s314 ^ s1558+ s1560 :: SBool = if s1468 then s1559 else s1558+ s1561 :: SBool = s308 ^ s1560+ s1562 :: SBool = if s1500 then s1561 else s1560+ s1563 :: SBool = s304 ^ s1562+ s1564 :: SBool = if s1532 then s1563 else s1562+ s1565 :: SBool = s8 ^ s299+ s1566 :: SBool = if s1084 then s1565 else s299+ s1567 :: SBool = s542 ^ s1566+ s1568 :: SBool = if s1116 then s1567 else s1566+ s1569 :: SBool = s512 ^ s1568+ s1570 :: SBool = if s1148 then s1569 else s1568+ s1571 :: SBool = s484 ^ s1570+ s1572 :: SBool = if s1180 then s1571 else s1570+ s1573 :: SBool = s458 ^ s1572+ s1574 :: SBool = if s1212 then s1573 else s1572+ s1575 :: SBool = s434 ^ s1574+ s1576 :: SBool = if s1244 then s1575 else s1574+ s1577 :: SBool = s412 ^ s1576+ s1578 :: SBool = if s1276 then s1577 else s1576+ s1579 :: SBool = s392 ^ s1578+ s1580 :: SBool = if s1308 then s1579 else s1578+ s1581 :: SBool = s374 ^ s1580+ s1582 :: SBool = if s1340 then s1581 else s1580+ s1583 :: SBool = s358 ^ s1582+ s1584 :: SBool = if s1372 then s1583 else s1582+ s1585 :: SBool = s344 ^ s1584+ s1586 :: SBool = if s1404 then s1585 else s1584+ s1587 :: SBool = s332 ^ s1586+ s1588 :: SBool = if s1436 then s1587 else s1586+ s1589 :: SBool = s322 ^ s1588+ s1590 :: SBool = if s1468 then s1589 else s1588+ s1591 :: SBool = s314 ^ s1590+ s1592 :: SBool = if s1500 then s1591 else s1590+ s1593 :: SBool = s308 ^ s1592+ s1594 :: SBool = if s1532 then s1593 else s1592+ s1595 :: SBool = s304 ^ s1594+ s1596 :: SBool = if s1564 then s1595 else s1594+ s1597 :: SBool = if s1116 then s8 else s_2+ s1598 :: SBool = s542 ^ s1597+ s1599 :: SBool = if s1148 then s1598 else s1597+ s1600 :: SBool = s512 ^ s1599+ s1601 :: SBool = if s1180 then s1600 else s1599+ s1602 :: SBool = s484 ^ s1601+ s1603 :: SBool = if s1212 then s1602 else s1601+ s1604 :: SBool = s458 ^ s1603+ s1605 :: SBool = if s1244 then s1604 else s1603+ s1606 :: SBool = s434 ^ s1605+ s1607 :: SBool = if s1276 then s1606 else s1605+ s1608 :: SBool = s412 ^ s1607+ s1609 :: SBool = if s1308 then s1608 else s1607+ s1610 :: SBool = s392 ^ s1609+ s1611 :: SBool = if s1340 then s1610 else s1609+ s1612 :: SBool = s374 ^ s1611+ s1613 :: SBool = if s1372 then s1612 else s1611+ s1614 :: SBool = s358 ^ s1613+ s1615 :: SBool = if s1404 then s1614 else s1613+ s1616 :: SBool = s344 ^ s1615+ s1617 :: SBool = if s1436 then s1616 else s1615+ s1618 :: SBool = s332 ^ s1617+ s1619 :: SBool = if s1468 then s1618 else s1617+ s1620 :: SBool = s322 ^ s1619+ s1621 :: SBool = if s1500 then s1620 else s1619+ s1622 :: SBool = s314 ^ s1621+ s1623 :: SBool = if s1532 then s1622 else s1621+ s1624 :: SBool = s308 ^ s1623+ s1625 :: SBool = if s1564 then s1624 else s1623+ s1626 :: SBool = s304 ^ s1625+ s1627 :: SBool = if s1596 then s1626 else s1625+ s1628 :: SBool = s26 ^ s304+ s1629 :: SBool = if s19 then s1628 else s26+ s1630 :: SBool = s32 ^ s308+ s1631 :: SBool = if s19 then s1630 else s32+ s1632 :: SBool = s304 ^ s1631+ s1633 :: SBool = if s1629 then s1632 else s1631+ s1634 :: SBool = s38 ^ s314+ s1635 :: SBool = if s19 then s1634 else s38+ s1636 :: SBool = s308 ^ s1635+ s1637 :: SBool = if s1629 then s1636 else s1635+ s1638 :: SBool = s304 ^ s1637+ s1639 :: SBool = if s1633 then s1638 else s1637+ s1640 :: SBool = s44 ^ s322+ s1641 :: SBool = if s19 then s1640 else s44+ s1642 :: SBool = s314 ^ s1641+ s1643 :: SBool = if s1629 then s1642 else s1641+ s1644 :: SBool = s308 ^ s1643+ s1645 :: SBool = if s1633 then s1644 else s1643+ s1646 :: SBool = s304 ^ s1645+ s1647 :: SBool = if s1639 then s1646 else s1645+ s1648 :: SBool = s50 ^ s332+ s1649 :: SBool = if s19 then s1648 else s50+ s1650 :: SBool = s322 ^ s1649+ s1651 :: SBool = if s1629 then s1650 else s1649+ s1652 :: SBool = s314 ^ s1651+ s1653 :: SBool = if s1633 then s1652 else s1651+ s1654 :: SBool = s308 ^ s1653+ s1655 :: SBool = if s1639 then s1654 else s1653+ s1656 :: SBool = s304 ^ s1655+ s1657 :: SBool = if s1647 then s1656 else s1655+ s1658 :: SBool = s56 ^ s344+ s1659 :: SBool = if s19 then s1658 else s56+ s1660 :: SBool = s332 ^ s1659+ s1661 :: SBool = if s1629 then s1660 else s1659+ s1662 :: SBool = s322 ^ s1661+ s1663 :: SBool = if s1633 then s1662 else s1661+ s1664 :: SBool = s314 ^ s1663+ s1665 :: SBool = if s1639 then s1664 else s1663+ s1666 :: SBool = s308 ^ s1665+ s1667 :: SBool = if s1647 then s1666 else s1665+ s1668 :: SBool = s304 ^ s1667+ s1669 :: SBool = if s1657 then s1668 else s1667+ s1670 :: SBool = s62 ^ s358+ s1671 :: SBool = if s19 then s1670 else s62+ s1672 :: SBool = s344 ^ s1671+ s1673 :: SBool = if s1629 then s1672 else s1671+ s1674 :: SBool = s332 ^ s1673+ s1675 :: SBool = if s1633 then s1674 else s1673+ s1676 :: SBool = s322 ^ s1675+ s1677 :: SBool = if s1639 then s1676 else s1675+ s1678 :: SBool = s314 ^ s1677+ s1679 :: SBool = if s1647 then s1678 else s1677+ s1680 :: SBool = s308 ^ s1679+ s1681 :: SBool = if s1657 then s1680 else s1679+ s1682 :: SBool = s304 ^ s1681+ s1683 :: SBool = if s1669 then s1682 else s1681+ s1684 :: SBool = s68 ^ s374+ s1685 :: SBool = if s19 then s1684 else s68+ s1686 :: SBool = s358 ^ s1685+ s1687 :: SBool = if s1629 then s1686 else s1685+ s1688 :: SBool = s344 ^ s1687+ s1689 :: SBool = if s1633 then s1688 else s1687+ s1690 :: SBool = s332 ^ s1689+ s1691 :: SBool = if s1639 then s1690 else s1689+ s1692 :: SBool = s322 ^ s1691+ s1693 :: SBool = if s1647 then s1692 else s1691+ s1694 :: SBool = s314 ^ s1693+ s1695 :: SBool = if s1657 then s1694 else s1693+ s1696 :: SBool = s308 ^ s1695+ s1697 :: SBool = if s1669 then s1696 else s1695+ s1698 :: SBool = s304 ^ s1697+ s1699 :: SBool = if s1683 then s1698 else s1697+ s1700 :: SBool = s74 ^ s392+ s1701 :: SBool = if s19 then s1700 else s74+ s1702 :: SBool = s374 ^ s1701+ s1703 :: SBool = if s1629 then s1702 else s1701+ s1704 :: SBool = s358 ^ s1703+ s1705 :: SBool = if s1633 then s1704 else s1703+ s1706 :: SBool = s344 ^ s1705+ s1707 :: SBool = if s1639 then s1706 else s1705+ s1708 :: SBool = s332 ^ s1707+ s1709 :: SBool = if s1647 then s1708 else s1707+ s1710 :: SBool = s322 ^ s1709+ s1711 :: SBool = if s1657 then s1710 else s1709+ s1712 :: SBool = s314 ^ s1711+ s1713 :: SBool = if s1669 then s1712 else s1711+ s1714 :: SBool = s308 ^ s1713+ s1715 :: SBool = if s1683 then s1714 else s1713+ s1716 :: SBool = s304 ^ s1715+ s1717 :: SBool = if s1699 then s1716 else s1715+ s1718 :: SBool = s80 ^ s412+ s1719 :: SBool = if s19 then s1718 else s80+ s1720 :: SBool = s392 ^ s1719+ s1721 :: SBool = if s1629 then s1720 else s1719+ s1722 :: SBool = s374 ^ s1721+ s1723 :: SBool = if s1633 then s1722 else s1721+ s1724 :: SBool = s358 ^ s1723+ s1725 :: SBool = if s1639 then s1724 else s1723+ s1726 :: SBool = s344 ^ s1725+ s1727 :: SBool = if s1647 then s1726 else s1725+ s1728 :: SBool = s332 ^ s1727+ s1729 :: SBool = if s1657 then s1728 else s1727+ s1730 :: SBool = s322 ^ s1729+ s1731 :: SBool = if s1669 then s1730 else s1729+ s1732 :: SBool = s314 ^ s1731+ s1733 :: SBool = if s1683 then s1732 else s1731+ s1734 :: SBool = s308 ^ s1733+ s1735 :: SBool = if s1699 then s1734 else s1733+ s1736 :: SBool = s304 ^ s1735+ s1737 :: SBool = if s1717 then s1736 else s1735+ s1738 :: SBool = s86 ^ s434+ s1739 :: SBool = if s19 then s1738 else s86+ s1740 :: SBool = s412 ^ s1739+ s1741 :: SBool = if s1629 then s1740 else s1739+ s1742 :: SBool = s392 ^ s1741+ s1743 :: SBool = if s1633 then s1742 else s1741+ s1744 :: SBool = s374 ^ s1743+ s1745 :: SBool = if s1639 then s1744 else s1743+ s1746 :: SBool = s358 ^ s1745+ s1747 :: SBool = if s1647 then s1746 else s1745+ s1748 :: SBool = s344 ^ s1747+ s1749 :: SBool = if s1657 then s1748 else s1747+ s1750 :: SBool = s332 ^ s1749+ s1751 :: SBool = if s1669 then s1750 else s1749+ s1752 :: SBool = s322 ^ s1751+ s1753 :: SBool = if s1683 then s1752 else s1751+ s1754 :: SBool = s314 ^ s1753+ s1755 :: SBool = if s1699 then s1754 else s1753+ s1756 :: SBool = s308 ^ s1755+ s1757 :: SBool = if s1717 then s1756 else s1755+ s1758 :: SBool = s304 ^ s1757+ s1759 :: SBool = if s1737 then s1758 else s1757+ s1760 :: SBool = s92 ^ s458+ s1761 :: SBool = if s19 then s1760 else s92+ s1762 :: SBool = s434 ^ s1761+ s1763 :: SBool = if s1629 then s1762 else s1761+ s1764 :: SBool = s412 ^ s1763+ s1765 :: SBool = if s1633 then s1764 else s1763+ s1766 :: SBool = s392 ^ s1765+ s1767 :: SBool = if s1639 then s1766 else s1765+ s1768 :: SBool = s374 ^ s1767+ s1769 :: SBool = if s1647 then s1768 else s1767+ s1770 :: SBool = s358 ^ s1769+ s1771 :: SBool = if s1657 then s1770 else s1769+ s1772 :: SBool = s344 ^ s1771+ s1773 :: SBool = if s1669 then s1772 else s1771+ s1774 :: SBool = s332 ^ s1773+ s1775 :: SBool = if s1683 then s1774 else s1773+ s1776 :: SBool = s322 ^ s1775+ s1777 :: SBool = if s1699 then s1776 else s1775+ s1778 :: SBool = s314 ^ s1777+ s1779 :: SBool = if s1717 then s1778 else s1777+ s1780 :: SBool = s308 ^ s1779+ s1781 :: SBool = if s1737 then s1780 else s1779+ s1782 :: SBool = s304 ^ s1781+ s1783 :: SBool = if s1759 then s1782 else s1781+ s1784 :: SBool = s98 ^ s484+ s1785 :: SBool = if s19 then s1784 else s98+ s1786 :: SBool = s458 ^ s1785+ s1787 :: SBool = if s1629 then s1786 else s1785+ s1788 :: SBool = s434 ^ s1787+ s1789 :: SBool = if s1633 then s1788 else s1787+ s1790 :: SBool = s412 ^ s1789+ s1791 :: SBool = if s1639 then s1790 else s1789+ s1792 :: SBool = s392 ^ s1791+ s1793 :: SBool = if s1647 then s1792 else s1791+ s1794 :: SBool = s374 ^ s1793+ s1795 :: SBool = if s1657 then s1794 else s1793+ s1796 :: SBool = s358 ^ s1795+ s1797 :: SBool = if s1669 then s1796 else s1795+ s1798 :: SBool = s344 ^ s1797+ s1799 :: SBool = if s1683 then s1798 else s1797+ s1800 :: SBool = s332 ^ s1799+ s1801 :: SBool = if s1699 then s1800 else s1799+ s1802 :: SBool = s322 ^ s1801+ s1803 :: SBool = if s1717 then s1802 else s1801+ s1804 :: SBool = s314 ^ s1803+ s1805 :: SBool = if s1737 then s1804 else s1803+ s1806 :: SBool = s308 ^ s1805+ s1807 :: SBool = if s1759 then s1806 else s1805+ s1808 :: SBool = s304 ^ s1807+ s1809 :: SBool = if s1783 then s1808 else s1807+ s1810 :: SBool = s104 ^ s512+ s1811 :: SBool = if s19 then s1810 else s104+ s1812 :: SBool = s484 ^ s1811+ s1813 :: SBool = if s1629 then s1812 else s1811+ s1814 :: SBool = s458 ^ s1813+ s1815 :: SBool = if s1633 then s1814 else s1813+ s1816 :: SBool = s434 ^ s1815+ s1817 :: SBool = if s1639 then s1816 else s1815+ s1818 :: SBool = s412 ^ s1817+ s1819 :: SBool = if s1647 then s1818 else s1817+ s1820 :: SBool = s392 ^ s1819+ s1821 :: SBool = if s1657 then s1820 else s1819+ s1822 :: SBool = s374 ^ s1821+ s1823 :: SBool = if s1669 then s1822 else s1821+ s1824 :: SBool = s358 ^ s1823+ s1825 :: SBool = if s1683 then s1824 else s1823+ s1826 :: SBool = s344 ^ s1825+ s1827 :: SBool = if s1699 then s1826 else s1825+ s1828 :: SBool = s332 ^ s1827+ s1829 :: SBool = if s1717 then s1828 else s1827+ s1830 :: SBool = s322 ^ s1829+ s1831 :: SBool = if s1737 then s1830 else s1829+ s1832 :: SBool = s314 ^ s1831+ s1833 :: SBool = if s1759 then s1832 else s1831+ s1834 :: SBool = s308 ^ s1833+ s1835 :: SBool = if s1783 then s1834 else s1833+ s1836 :: SBool = s304 ^ s1835+ s1837 :: SBool = if s1809 then s1836 else s1835+ s1838 :: SBool = s110 ^ s542+ s1839 :: SBool = if s19 then s1838 else s110+ s1840 :: SBool = s512 ^ s1839+ s1841 :: SBool = if s1629 then s1840 else s1839+ s1842 :: SBool = s484 ^ s1841+ s1843 :: SBool = if s1633 then s1842 else s1841+ s1844 :: SBool = s458 ^ s1843+ s1845 :: SBool = if s1639 then s1844 else s1843+ s1846 :: SBool = s434 ^ s1845+ s1847 :: SBool = if s1647 then s1846 else s1845+ s1848 :: SBool = s412 ^ s1847+ s1849 :: SBool = if s1657 then s1848 else s1847+ s1850 :: SBool = s392 ^ s1849+ s1851 :: SBool = if s1669 then s1850 else s1849+ s1852 :: SBool = s374 ^ s1851+ s1853 :: SBool = if s1683 then s1852 else s1851+ s1854 :: SBool = s358 ^ s1853+ s1855 :: SBool = if s1699 then s1854 else s1853+ s1856 :: SBool = s344 ^ s1855+ s1857 :: SBool = if s1717 then s1856 else s1855+ s1858 :: SBool = s332 ^ s1857+ s1859 :: SBool = if s1737 then s1858 else s1857+ s1860 :: SBool = s322 ^ s1859+ s1861 :: SBool = if s1759 then s1860 else s1859+ s1862 :: SBool = s314 ^ s1861+ s1863 :: SBool = if s1783 then s1862 else s1861+ s1864 :: SBool = s308 ^ s1863+ s1865 :: SBool = if s1809 then s1864 else s1863+ s1866 :: SBool = s304 ^ s1865+ s1867 :: SBool = if s1837 then s1866 else s1865+ s1868 :: SBool = s8 ^ s116+ s1869 :: SBool = if s19 then s1868 else s116+ s1870 :: SBool = s542 ^ s1869+ s1871 :: SBool = if s1629 then s1870 else s1869+ s1872 :: SBool = s512 ^ s1871+ s1873 :: SBool = if s1633 then s1872 else s1871+ s1874 :: SBool = s484 ^ s1873+ s1875 :: SBool = if s1639 then s1874 else s1873+ s1876 :: SBool = s458 ^ s1875+ s1877 :: SBool = if s1647 then s1876 else s1875+ s1878 :: SBool = s434 ^ s1877+ s1879 :: SBool = if s1657 then s1878 else s1877+ s1880 :: SBool = s412 ^ s1879+ s1881 :: SBool = if s1669 then s1880 else s1879+ s1882 :: SBool = s392 ^ s1881+ s1883 :: SBool = if s1683 then s1882 else s1881+ s1884 :: SBool = s374 ^ s1883+ s1885 :: SBool = if s1699 then s1884 else s1883+ s1886 :: SBool = s358 ^ s1885+ s1887 :: SBool = if s1717 then s1886 else s1885+ s1888 :: SBool = s344 ^ s1887+ s1889 :: SBool = if s1737 then s1888 else s1887+ s1890 :: SBool = s332 ^ s1889+ s1891 :: SBool = if s1759 then s1890 else s1889+ s1892 :: SBool = s322 ^ s1891+ s1893 :: SBool = if s1783 then s1892 else s1891+ s1894 :: SBool = s314 ^ s1893+ s1895 :: SBool = if s1809 then s1894 else s1893+ s1896 :: SBool = s308 ^ s1895+ s1897 :: SBool = if s1837 then s1896 else s1895+ s1898 :: SBool = s304 ^ s1897+ s1899 :: SBool = if s1867 then s1898 else s1897+ s1900 :: SBool = s8 ^ s122+ s1901 :: SBool = if s1629 then s1900 else s122+ s1902 :: SBool = s542 ^ s1901+ s1903 :: SBool = if s1633 then s1902 else s1901+ s1904 :: SBool = s512 ^ s1903+ s1905 :: SBool = if s1639 then s1904 else s1903+ s1906 :: SBool = s484 ^ s1905+ s1907 :: SBool = if s1647 then s1906 else s1905+ s1908 :: SBool = s458 ^ s1907+ s1909 :: SBool = if s1657 then s1908 else s1907+ s1910 :: SBool = s434 ^ s1909+ s1911 :: SBool = if s1669 then s1910 else s1909+ s1912 :: SBool = s412 ^ s1911+ s1913 :: SBool = if s1683 then s1912 else s1911+ s1914 :: SBool = s392 ^ s1913+ s1915 :: SBool = if s1699 then s1914 else s1913+ s1916 :: SBool = s374 ^ s1915+ s1917 :: SBool = if s1717 then s1916 else s1915+ s1918 :: SBool = s358 ^ s1917+ s1919 :: SBool = if s1737 then s1918 else s1917+ s1920 :: SBool = s344 ^ s1919+ s1921 :: SBool = if s1759 then s1920 else s1919+ s1922 :: SBool = s332 ^ s1921+ s1923 :: SBool = if s1783 then s1922 else s1921+ s1924 :: SBool = s322 ^ s1923+ s1925 :: SBool = if s1809 then s1924 else s1923+ s1926 :: SBool = s314 ^ s1925+ s1927 :: SBool = if s1837 then s1926 else s1925+ s1928 :: SBool = s308 ^ s1927+ s1929 :: SBool = if s1867 then s1928 else s1927+ s1930 :: SBool = s304 ^ s1929+ s1931 :: SBool = if s1899 then s1930 else s1929+ s1932 :: SBool = s8 ^ s128+ s1933 :: SBool = if s1633 then s1932 else s128+ s1934 :: SBool = s542 ^ s1933+ s1935 :: SBool = if s1639 then s1934 else s1933+ s1936 :: SBool = s512 ^ s1935+ s1937 :: SBool = if s1647 then s1936 else s1935+ s1938 :: SBool = s484 ^ s1937+ s1939 :: SBool = if s1657 then s1938 else s1937+ s1940 :: SBool = s458 ^ s1939+ s1941 :: SBool = if s1669 then s1940 else s1939+ s1942 :: SBool = s434 ^ s1941+ s1943 :: SBool = if s1683 then s1942 else s1941+ s1944 :: SBool = s412 ^ s1943+ s1945 :: SBool = if s1699 then s1944 else s1943+ s1946 :: SBool = s392 ^ s1945+ s1947 :: SBool = if s1717 then s1946 else s1945+ s1948 :: SBool = s374 ^ s1947+ s1949 :: SBool = if s1737 then s1948 else s1947+ s1950 :: SBool = s358 ^ s1949+ s1951 :: SBool = if s1759 then s1950 else s1949+ s1952 :: SBool = s344 ^ s1951+ s1953 :: SBool = if s1783 then s1952 else s1951+ s1954 :: SBool = s332 ^ s1953+ s1955 :: SBool = if s1809 then s1954 else s1953+ s1956 :: SBool = s322 ^ s1955+ s1957 :: SBool = if s1837 then s1956 else s1955+ s1958 :: SBool = s314 ^ s1957+ s1959 :: SBool = if s1867 then s1958 else s1957+ s1960 :: SBool = s308 ^ s1959+ s1961 :: SBool = if s1899 then s1960 else s1959+ s1962 :: SBool = s304 ^ s1961+ s1963 :: SBool = if s1931 then s1962 else s1961+ s1964 :: SBool = s8 ^ s134+ s1965 :: SBool = if s1639 then s1964 else s134+ s1966 :: SBool = s542 ^ s1965+ s1967 :: SBool = if s1647 then s1966 else s1965+ s1968 :: SBool = s512 ^ s1967+ s1969 :: SBool = if s1657 then s1968 else s1967+ s1970 :: SBool = s484 ^ s1969+ s1971 :: SBool = if s1669 then s1970 else s1969+ s1972 :: SBool = s458 ^ s1971+ s1973 :: SBool = if s1683 then s1972 else s1971+ s1974 :: SBool = s434 ^ s1973+ s1975 :: SBool = if s1699 then s1974 else s1973+ s1976 :: SBool = s412 ^ s1975+ s1977 :: SBool = if s1717 then s1976 else s1975+ s1978 :: SBool = s392 ^ s1977+ s1979 :: SBool = if s1737 then s1978 else s1977+ s1980 :: SBool = s374 ^ s1979+ s1981 :: SBool = if s1759 then s1980 else s1979+ s1982 :: SBool = s358 ^ s1981+ s1983 :: SBool = if s1783 then s1982 else s1981+ s1984 :: SBool = s344 ^ s1983+ s1985 :: SBool = if s1809 then s1984 else s1983+ s1986 :: SBool = s332 ^ s1985+ s1987 :: SBool = if s1837 then s1986 else s1985+ s1988 :: SBool = s322 ^ s1987+ s1989 :: SBool = if s1867 then s1988 else s1987+ s1990 :: SBool = s314 ^ s1989+ s1991 :: SBool = if s1899 then s1990 else s1989+ s1992 :: SBool = s308 ^ s1991+ s1993 :: SBool = if s1931 then s1992 else s1991+ s1994 :: SBool = s304 ^ s1993+ s1995 :: SBool = if s1963 then s1994 else s1993+ s1996 :: SBool = s8 ^ s140+ s1997 :: SBool = if s1647 then s1996 else s140+ s1998 :: SBool = s542 ^ s1997+ s1999 :: SBool = if s1657 then s1998 else s1997+ s2000 :: SBool = s512 ^ s1999+ s2001 :: SBool = if s1669 then s2000 else s1999+ s2002 :: SBool = s484 ^ s2001+ s2003 :: SBool = if s1683 then s2002 else s2001+ s2004 :: SBool = s458 ^ s2003+ s2005 :: SBool = if s1699 then s2004 else s2003+ s2006 :: SBool = s434 ^ s2005+ s2007 :: SBool = if s1717 then s2006 else s2005+ s2008 :: SBool = s412 ^ s2007+ s2009 :: SBool = if s1737 then s2008 else s2007+ s2010 :: SBool = s392 ^ s2009+ s2011 :: SBool = if s1759 then s2010 else s2009+ s2012 :: SBool = s374 ^ s2011+ s2013 :: SBool = if s1783 then s2012 else s2011+ s2014 :: SBool = s358 ^ s2013+ s2015 :: SBool = if s1809 then s2014 else s2013+ s2016 :: SBool = s344 ^ s2015+ s2017 :: SBool = if s1837 then s2016 else s2015+ s2018 :: SBool = s332 ^ s2017+ s2019 :: SBool = if s1867 then s2018 else s2017+ s2020 :: SBool = s322 ^ s2019+ s2021 :: SBool = if s1899 then s2020 else s2019+ s2022 :: SBool = s314 ^ s2021+ s2023 :: SBool = if s1931 then s2022 else s2021+ s2024 :: SBool = s308 ^ s2023+ s2025 :: SBool = if s1963 then s2024 else s2023+ s2026 :: SBool = s304 ^ s2025+ s2027 :: SBool = if s1995 then s2026 else s2025+ s2028 :: SBool = s8 ^ s146+ s2029 :: SBool = if s1657 then s2028 else s146+ s2030 :: SBool = s542 ^ s2029+ s2031 :: SBool = if s1669 then s2030 else s2029+ s2032 :: SBool = s512 ^ s2031+ s2033 :: SBool = if s1683 then s2032 else s2031+ s2034 :: SBool = s484 ^ s2033+ s2035 :: SBool = if s1699 then s2034 else s2033+ s2036 :: SBool = s458 ^ s2035+ s2037 :: SBool = if s1717 then s2036 else s2035+ s2038 :: SBool = s434 ^ s2037+ s2039 :: SBool = if s1737 then s2038 else s2037+ s2040 :: SBool = s412 ^ s2039+ s2041 :: SBool = if s1759 then s2040 else s2039+ s2042 :: SBool = s392 ^ s2041+ s2043 :: SBool = if s1783 then s2042 else s2041+ s2044 :: SBool = s374 ^ s2043+ s2045 :: SBool = if s1809 then s2044 else s2043+ s2046 :: SBool = s358 ^ s2045+ s2047 :: SBool = if s1837 then s2046 else s2045+ s2048 :: SBool = s344 ^ s2047+ s2049 :: SBool = if s1867 then s2048 else s2047+ s2050 :: SBool = s332 ^ s2049+ s2051 :: SBool = if s1899 then s2050 else s2049+ s2052 :: SBool = s322 ^ s2051+ s2053 :: SBool = if s1931 then s2052 else s2051+ s2054 :: SBool = s314 ^ s2053+ s2055 :: SBool = if s1963 then s2054 else s2053+ s2056 :: SBool = s308 ^ s2055+ s2057 :: SBool = if s1995 then s2056 else s2055+ s2058 :: SBool = s304 ^ s2057+ s2059 :: SBool = if s2027 then s2058 else s2057+ s2060 :: SBool = s8 ^ s152+ s2061 :: SBool = if s1669 then s2060 else s152+ s2062 :: SBool = s542 ^ s2061+ s2063 :: SBool = if s1683 then s2062 else s2061+ s2064 :: SBool = s512 ^ s2063+ s2065 :: SBool = if s1699 then s2064 else s2063+ s2066 :: SBool = s484 ^ s2065+ s2067 :: SBool = if s1717 then s2066 else s2065+ s2068 :: SBool = s458 ^ s2067+ s2069 :: SBool = if s1737 then s2068 else s2067+ s2070 :: SBool = s434 ^ s2069+ s2071 :: SBool = if s1759 then s2070 else s2069+ s2072 :: SBool = s412 ^ s2071+ s2073 :: SBool = if s1783 then s2072 else s2071+ s2074 :: SBool = s392 ^ s2073+ s2075 :: SBool = if s1809 then s2074 else s2073+ s2076 :: SBool = s374 ^ s2075+ s2077 :: SBool = if s1837 then s2076 else s2075+ s2078 :: SBool = s358 ^ s2077+ s2079 :: SBool = if s1867 then s2078 else s2077+ s2080 :: SBool = s344 ^ s2079+ s2081 :: SBool = if s1899 then s2080 else s2079+ s2082 :: SBool = s332 ^ s2081+ s2083 :: SBool = if s1931 then s2082 else s2081+ s2084 :: SBool = s322 ^ s2083+ s2085 :: SBool = if s1963 then s2084 else s2083+ s2086 :: SBool = s314 ^ s2085+ s2087 :: SBool = if s1995 then s2086 else s2085+ s2088 :: SBool = s308 ^ s2087+ s2089 :: SBool = if s2027 then s2088 else s2087+ s2090 :: SBool = s304 ^ s2089+ s2091 :: SBool = if s2059 then s2090 else s2089+ s2092 :: SBool = s8 ^ s158+ s2093 :: SBool = if s1683 then s2092 else s158+ s2094 :: SBool = s542 ^ s2093+ s2095 :: SBool = if s1699 then s2094 else s2093+ s2096 :: SBool = s512 ^ s2095+ s2097 :: SBool = if s1717 then s2096 else s2095+ s2098 :: SBool = s484 ^ s2097+ s2099 :: SBool = if s1737 then s2098 else s2097+ s2100 :: SBool = s458 ^ s2099+ s2101 :: SBool = if s1759 then s2100 else s2099+ s2102 :: SBool = s434 ^ s2101+ s2103 :: SBool = if s1783 then s2102 else s2101+ s2104 :: SBool = s412 ^ s2103+ s2105 :: SBool = if s1809 then s2104 else s2103+ s2106 :: SBool = s392 ^ s2105+ s2107 :: SBool = if s1837 then s2106 else s2105+ s2108 :: SBool = s374 ^ s2107+ s2109 :: SBool = if s1867 then s2108 else s2107+ s2110 :: SBool = s358 ^ s2109+ s2111 :: SBool = if s1899 then s2110 else s2109+ s2112 :: SBool = s344 ^ s2111+ s2113 :: SBool = if s1931 then s2112 else s2111+ s2114 :: SBool = s332 ^ s2113+ s2115 :: SBool = if s1963 then s2114 else s2113+ s2116 :: SBool = s322 ^ s2115+ s2117 :: SBool = if s1995 then s2116 else s2115+ s2118 :: SBool = s314 ^ s2117+ s2119 :: SBool = if s2027 then s2118 else s2117+ s2120 :: SBool = s308 ^ s2119+ s2121 :: SBool = if s2059 then s2120 else s2119+ s2122 :: SBool = s304 ^ s2121+ s2123 :: SBool = if s2091 then s2122 else s2121+ s2124 :: SBool = s8 ^ s164+ s2125 :: SBool = if s1699 then s2124 else s164+ s2126 :: SBool = s542 ^ s2125+ s2127 :: SBool = if s1717 then s2126 else s2125+ s2128 :: SBool = s512 ^ s2127+ s2129 :: SBool = if s1737 then s2128 else s2127+ s2130 :: SBool = s484 ^ s2129+ s2131 :: SBool = if s1759 then s2130 else s2129+ s2132 :: SBool = s458 ^ s2131+ s2133 :: SBool = if s1783 then s2132 else s2131+ s2134 :: SBool = s434 ^ s2133+ s2135 :: SBool = if s1809 then s2134 else s2133+ s2136 :: SBool = s412 ^ s2135+ s2137 :: SBool = if s1837 then s2136 else s2135+ s2138 :: SBool = s392 ^ s2137+ s2139 :: SBool = if s1867 then s2138 else s2137+ s2140 :: SBool = s374 ^ s2139+ s2141 :: SBool = if s1899 then s2140 else s2139+ s2142 :: SBool = s358 ^ s2141+ s2143 :: SBool = if s1931 then s2142 else s2141+ s2144 :: SBool = s344 ^ s2143+ s2145 :: SBool = if s1963 then s2144 else s2143+ s2146 :: SBool = s332 ^ s2145+ s2147 :: SBool = if s1995 then s2146 else s2145+ s2148 :: SBool = s322 ^ s2147+ s2149 :: SBool = if s2027 then s2148 else s2147+ s2150 :: SBool = s314 ^ s2149+ s2151 :: SBool = if s2059 then s2150 else s2149+ s2152 :: SBool = s308 ^ s2151+ s2153 :: SBool = if s2091 then s2152 else s2151+ s2154 :: SBool = s304 ^ s2153+ s2155 :: SBool = if s2123 then s2154 else s2153+ s2156 :: SBool = s8 ^ s170+ s2157 :: SBool = if s1717 then s2156 else s170+ s2158 :: SBool = s542 ^ s2157+ s2159 :: SBool = if s1737 then s2158 else s2157+ s2160 :: SBool = s512 ^ s2159+ s2161 :: SBool = if s1759 then s2160 else s2159+ s2162 :: SBool = s484 ^ s2161+ s2163 :: SBool = if s1783 then s2162 else s2161+ s2164 :: SBool = s458 ^ s2163+ s2165 :: SBool = if s1809 then s2164 else s2163+ s2166 :: SBool = s434 ^ s2165+ s2167 :: SBool = if s1837 then s2166 else s2165+ s2168 :: SBool = s412 ^ s2167+ s2169 :: SBool = if s1867 then s2168 else s2167+ s2170 :: SBool = s392 ^ s2169+ s2171 :: SBool = if s1899 then s2170 else s2169+ s2172 :: SBool = s374 ^ s2171+ s2173 :: SBool = if s1931 then s2172 else s2171+ s2174 :: SBool = s358 ^ s2173+ s2175 :: SBool = if s1963 then s2174 else s2173+ s2176 :: SBool = s344 ^ s2175+ s2177 :: SBool = if s1995 then s2176 else s2175+ s2178 :: SBool = s332 ^ s2177+ s2179 :: SBool = if s2027 then s2178 else s2177+ s2180 :: SBool = s322 ^ s2179+ s2181 :: SBool = if s2059 then s2180 else s2179+ s2182 :: SBool = s314 ^ s2181+ s2183 :: SBool = if s2091 then s2182 else s2181+ s2184 :: SBool = s308 ^ s2183+ s2185 :: SBool = if s2123 then s2184 else s2183+ s2186 :: SBool = s304 ^ s2185+ s2187 :: SBool = if s2155 then s2186 else s2185+ s2188 :: SBool = s8 ^ s176+ s2189 :: SBool = if s1737 then s2188 else s176+ s2190 :: SBool = s542 ^ s2189+ s2191 :: SBool = if s1759 then s2190 else s2189+ s2192 :: SBool = s512 ^ s2191+ s2193 :: SBool = if s1783 then s2192 else s2191+ s2194 :: SBool = s484 ^ s2193+ s2195 :: SBool = if s1809 then s2194 else s2193+ s2196 :: SBool = s458 ^ s2195+ s2197 :: SBool = if s1837 then s2196 else s2195+ s2198 :: SBool = s434 ^ s2197+ s2199 :: SBool = if s1867 then s2198 else s2197+ s2200 :: SBool = s412 ^ s2199+ s2201 :: SBool = if s1899 then s2200 else s2199+ s2202 :: SBool = s392 ^ s2201+ s2203 :: SBool = if s1931 then s2202 else s2201+ s2204 :: SBool = s374 ^ s2203+ s2205 :: SBool = if s1963 then s2204 else s2203+ s2206 :: SBool = s358 ^ s2205+ s2207 :: SBool = if s1995 then s2206 else s2205+ s2208 :: SBool = s344 ^ s2207+ s2209 :: SBool = if s2027 then s2208 else s2207+ s2210 :: SBool = s332 ^ s2209+ s2211 :: SBool = if s2059 then s2210 else s2209+ s2212 :: SBool = s322 ^ s2211+ s2213 :: SBool = if s2091 then s2212 else s2211+ s2214 :: SBool = s314 ^ s2213+ s2215 :: SBool = if s2123 then s2214 else s2213+ s2216 :: SBool = s308 ^ s2215+ s2217 :: SBool = if s2155 then s2216 else s2215+ s2218 :: SBool = s304 ^ s2217+ s2219 :: SBool = if s2187 then s2218 else s2217+ s2220 :: SBool = s8 ^ s182+ s2221 :: SBool = if s1759 then s2220 else s182+ s2222 :: SBool = s542 ^ s2221+ s2223 :: SBool = if s1783 then s2222 else s2221+ s2224 :: SBool = s512 ^ s2223+ s2225 :: SBool = if s1809 then s2224 else s2223+ s2226 :: SBool = s484 ^ s2225+ s2227 :: SBool = if s1837 then s2226 else s2225+ s2228 :: SBool = s458 ^ s2227+ s2229 :: SBool = if s1867 then s2228 else s2227+ s2230 :: SBool = s434 ^ s2229+ s2231 :: SBool = if s1899 then s2230 else s2229+ s2232 :: SBool = s412 ^ s2231+ s2233 :: SBool = if s1931 then s2232 else s2231+ s2234 :: SBool = s392 ^ s2233+ s2235 :: SBool = if s1963 then s2234 else s2233+ s2236 :: SBool = s374 ^ s2235+ s2237 :: SBool = if s1995 then s2236 else s2235+ s2238 :: SBool = s358 ^ s2237+ s2239 :: SBool = if s2027 then s2238 else s2237+ s2240 :: SBool = s344 ^ s2239+ s2241 :: SBool = if s2059 then s2240 else s2239+ s2242 :: SBool = s332 ^ s2241+ s2243 :: SBool = if s2091 then s2242 else s2241+ s2244 :: SBool = s322 ^ s2243+ s2245 :: SBool = if s2123 then s2244 else s2243+ s2246 :: SBool = s314 ^ s2245+ s2247 :: SBool = if s2155 then s2246 else s2245+ s2248 :: SBool = s308 ^ s2247+ s2249 :: SBool = if s2187 then s2248 else s2247+ s2250 :: SBool = s304 ^ s2249+ s2251 :: SBool = if s2219 then s2250 else s2249+ s2252 :: SBool = s8 ^ s188+ s2253 :: SBool = if s1783 then s2252 else s188+ s2254 :: SBool = s542 ^ s2253+ s2255 :: SBool = if s1809 then s2254 else s2253+ s2256 :: SBool = s512 ^ s2255+ s2257 :: SBool = if s1837 then s2256 else s2255+ s2258 :: SBool = s484 ^ s2257+ s2259 :: SBool = if s1867 then s2258 else s2257+ s2260 :: SBool = s458 ^ s2259+ s2261 :: SBool = if s1899 then s2260 else s2259+ s2262 :: SBool = s434 ^ s2261+ s2263 :: SBool = if s1931 then s2262 else s2261+ s2264 :: SBool = s412 ^ s2263+ s2265 :: SBool = if s1963 then s2264 else s2263+ s2266 :: SBool = s392 ^ s2265+ s2267 :: SBool = if s1995 then s2266 else s2265+ s2268 :: SBool = s374 ^ s2267+ s2269 :: SBool = if s2027 then s2268 else s2267+ s2270 :: SBool = s358 ^ s2269+ s2271 :: SBool = if s2059 then s2270 else s2269+ s2272 :: SBool = s344 ^ s2271+ s2273 :: SBool = if s2091 then s2272 else s2271+ s2274 :: SBool = s332 ^ s2273+ s2275 :: SBool = if s2123 then s2274 else s2273+ s2276 :: SBool = s322 ^ s2275+ s2277 :: SBool = if s2155 then s2276 else s2275+ s2278 :: SBool = s314 ^ s2277+ s2279 :: SBool = if s2187 then s2278 else s2277+ s2280 :: SBool = s308 ^ s2279+ s2281 :: SBool = if s2219 then s2280 else s2279+ s2282 :: SBool = s304 ^ s2281+ s2283 :: SBool = if s2251 then s2282 else s2281+ s2284 :: SBool = s8 ^ s194+ s2285 :: SBool = if s1809 then s2284 else s194+ s2286 :: SBool = s542 ^ s2285+ s2287 :: SBool = if s1837 then s2286 else s2285+ s2288 :: SBool = s512 ^ s2287+ s2289 :: SBool = if s1867 then s2288 else s2287+ s2290 :: SBool = s484 ^ s2289+ s2291 :: SBool = if s1899 then s2290 else s2289+ s2292 :: SBool = s458 ^ s2291+ s2293 :: SBool = if s1931 then s2292 else s2291+ s2294 :: SBool = s434 ^ s2293+ s2295 :: SBool = if s1963 then s2294 else s2293+ s2296 :: SBool = s412 ^ s2295+ s2297 :: SBool = if s1995 then s2296 else s2295+ s2298 :: SBool = s392 ^ s2297+ s2299 :: SBool = if s2027 then s2298 else s2297+ s2300 :: SBool = s374 ^ s2299+ s2301 :: SBool = if s2059 then s2300 else s2299+ s2302 :: SBool = s358 ^ s2301+ s2303 :: SBool = if s2091 then s2302 else s2301+ s2304 :: SBool = s344 ^ s2303+ s2305 :: SBool = if s2123 then s2304 else s2303+ s2306 :: SBool = s332 ^ s2305+ s2307 :: SBool = if s2155 then s2306 else s2305+ s2308 :: SBool = s322 ^ s2307+ s2309 :: SBool = if s2187 then s2308 else s2307+ s2310 :: SBool = s314 ^ s2309+ s2311 :: SBool = if s2219 then s2310 else s2309+ s2312 :: SBool = s308 ^ s2311+ s2313 :: SBool = if s2251 then s2312 else s2311+ s2314 :: SBool = s304 ^ s2313+ s2315 :: SBool = if s2283 then s2314 else s2313+ s2316 :: SBool = s8 ^ s200+ s2317 :: SBool = if s1837 then s2316 else s200+ s2318 :: SBool = s542 ^ s2317+ s2319 :: SBool = if s1867 then s2318 else s2317+ s2320 :: SBool = s512 ^ s2319+ s2321 :: SBool = if s1899 then s2320 else s2319+ s2322 :: SBool = s484 ^ s2321+ s2323 :: SBool = if s1931 then s2322 else s2321+ s2324 :: SBool = s458 ^ s2323+ s2325 :: SBool = if s1963 then s2324 else s2323+ s2326 :: SBool = s434 ^ s2325+ s2327 :: SBool = if s1995 then s2326 else s2325+ s2328 :: SBool = s412 ^ s2327+ s2329 :: SBool = if s2027 then s2328 else s2327+ s2330 :: SBool = s392 ^ s2329+ s2331 :: SBool = if s2059 then s2330 else s2329+ s2332 :: SBool = s374 ^ s2331+ s2333 :: SBool = if s2091 then s2332 else s2331+ s2334 :: SBool = s358 ^ s2333+ s2335 :: SBool = if s2123 then s2334 else s2333+ s2336 :: SBool = s344 ^ s2335+ s2337 :: SBool = if s2155 then s2336 else s2335+ s2338 :: SBool = s332 ^ s2337+ s2339 :: SBool = if s2187 then s2338 else s2337+ s2340 :: SBool = s322 ^ s2339+ s2341 :: SBool = if s2219 then s2340 else s2339+ s2342 :: SBool = s314 ^ s2341+ s2343 :: SBool = if s2251 then s2342 else s2341+ s2344 :: SBool = s308 ^ s2343+ s2345 :: SBool = if s2283 then s2344 else s2343+ s2346 :: SBool = s304 ^ s2345+ s2347 :: SBool = if s2315 then s2346 else s2345+ s2348 :: SBool = s8 ^ s206+ s2349 :: SBool = if s1867 then s2348 else s206+ s2350 :: SBool = s542 ^ s2349+ s2351 :: SBool = if s1899 then s2350 else s2349+ s2352 :: SBool = s512 ^ s2351+ s2353 :: SBool = if s1931 then s2352 else s2351+ s2354 :: SBool = s484 ^ s2353+ s2355 :: SBool = if s1963 then s2354 else s2353+ s2356 :: SBool = s458 ^ s2355+ s2357 :: SBool = if s1995 then s2356 else s2355+ s2358 :: SBool = s434 ^ s2357+ s2359 :: SBool = if s2027 then s2358 else s2357+ s2360 :: SBool = s412 ^ s2359+ s2361 :: SBool = if s2059 then s2360 else s2359+ s2362 :: SBool = s392 ^ s2361+ s2363 :: SBool = if s2091 then s2362 else s2361+ s2364 :: SBool = s374 ^ s2363+ s2365 :: SBool = if s2123 then s2364 else s2363+ s2366 :: SBool = s358 ^ s2365+ s2367 :: SBool = if s2155 then s2366 else s2365+ s2368 :: SBool = s344 ^ s2367+ s2369 :: SBool = if s2187 then s2368 else s2367+ s2370 :: SBool = s332 ^ s2369+ s2371 :: SBool = if s2219 then s2370 else s2369+ s2372 :: SBool = s322 ^ s2371+ s2373 :: SBool = if s2251 then s2372 else s2371+ s2374 :: SBool = s314 ^ s2373+ s2375 :: SBool = if s2283 then s2374 else s2373+ s2376 :: SBool = s308 ^ s2375+ s2377 :: SBool = if s2315 then s2376 else s2375+ s2378 :: SBool = s304 ^ s2377+ s2379 :: SBool = if s2347 then s2378 else s2377+ s2380 :: SBool = s8 ^ s212+ s2381 :: SBool = if s1899 then s2380 else s212+ s2382 :: SBool = s542 ^ s2381+ s2383 :: SBool = if s1931 then s2382 else s2381+ s2384 :: SBool = s512 ^ s2383+ s2385 :: SBool = if s1963 then s2384 else s2383+ s2386 :: SBool = s484 ^ s2385+ s2387 :: SBool = if s1995 then s2386 else s2385+ s2388 :: SBool = s458 ^ s2387+ s2389 :: SBool = if s2027 then s2388 else s2387+ s2390 :: SBool = s434 ^ s2389+ s2391 :: SBool = if s2059 then s2390 else s2389+ s2392 :: SBool = s412 ^ s2391+ s2393 :: SBool = if s2091 then s2392 else s2391+ s2394 :: SBool = s392 ^ s2393+ s2395 :: SBool = if s2123 then s2394 else s2393+ s2396 :: SBool = s374 ^ s2395+ s2397 :: SBool = if s2155 then s2396 else s2395+ s2398 :: SBool = s358 ^ s2397+ s2399 :: SBool = if s2187 then s2398 else s2397+ s2400 :: SBool = s344 ^ s2399+ s2401 :: SBool = if s2219 then s2400 else s2399+ s2402 :: SBool = s332 ^ s2401+ s2403 :: SBool = if s2251 then s2402 else s2401+ s2404 :: SBool = s322 ^ s2403+ s2405 :: SBool = if s2283 then s2404 else s2403+ s2406 :: SBool = s314 ^ s2405+ s2407 :: SBool = if s2315 then s2406 else s2405+ s2408 :: SBool = s308 ^ s2407+ s2409 :: SBool = if s2347 then s2408 else s2407+ s2410 :: SBool = s304 ^ s2409+ s2411 :: SBool = if s2379 then s2410 else s2409+ s2412 :: SBool = s8 ^ s218+ s2413 :: SBool = if s1931 then s2412 else s218+ s2414 :: SBool = s542 ^ s2413+ s2415 :: SBool = if s1963 then s2414 else s2413+ s2416 :: SBool = s512 ^ s2415+ s2417 :: SBool = if s1995 then s2416 else s2415+ s2418 :: SBool = s484 ^ s2417+ s2419 :: SBool = if s2027 then s2418 else s2417+ s2420 :: SBool = s458 ^ s2419+ s2421 :: SBool = if s2059 then s2420 else s2419+ s2422 :: SBool = s434 ^ s2421+ s2423 :: SBool = if s2091 then s2422 else s2421+ s2424 :: SBool = s412 ^ s2423+ s2425 :: SBool = if s2123 then s2424 else s2423+ s2426 :: SBool = s392 ^ s2425+ s2427 :: SBool = if s2155 then s2426 else s2425+ s2428 :: SBool = s374 ^ s2427+ s2429 :: SBool = if s2187 then s2428 else s2427+ s2430 :: SBool = s358 ^ s2429+ s2431 :: SBool = if s2219 then s2430 else s2429+ s2432 :: SBool = s344 ^ s2431+ s2433 :: SBool = if s2251 then s2432 else s2431+ s2434 :: SBool = s332 ^ s2433+ s2435 :: SBool = if s2283 then s2434 else s2433+ s2436 :: SBool = s322 ^ s2435+ s2437 :: SBool = if s2315 then s2436 else s2435+ s2438 :: SBool = s314 ^ s2437+ s2439 :: SBool = if s2347 then s2438 else s2437+ s2440 :: SBool = s308 ^ s2439+ s2441 :: SBool = if s2379 then s2440 else s2439+ s2442 :: SBool = s304 ^ s2441+ s2443 :: SBool = if s2411 then s2442 else s2441+ s2444 :: SBool = s8 ^ s224+ s2445 :: SBool = if s1963 then s2444 else s224+ s2446 :: SBool = s542 ^ s2445+ s2447 :: SBool = if s1995 then s2446 else s2445+ s2448 :: SBool = s512 ^ s2447+ s2449 :: SBool = if s2027 then s2448 else s2447+ s2450 :: SBool = s484 ^ s2449+ s2451 :: SBool = if s2059 then s2450 else s2449+ s2452 :: SBool = s458 ^ s2451+ s2453 :: SBool = if s2091 then s2452 else s2451+ s2454 :: SBool = s434 ^ s2453+ s2455 :: SBool = if s2123 then s2454 else s2453+ s2456 :: SBool = s412 ^ s2455+ s2457 :: SBool = if s2155 then s2456 else s2455+ s2458 :: SBool = s392 ^ s2457+ s2459 :: SBool = if s2187 then s2458 else s2457+ s2460 :: SBool = s374 ^ s2459+ s2461 :: SBool = if s2219 then s2460 else s2459+ s2462 :: SBool = s358 ^ s2461+ s2463 :: SBool = if s2251 then s2462 else s2461+ s2464 :: SBool = s344 ^ s2463+ s2465 :: SBool = if s2283 then s2464 else s2463+ s2466 :: SBool = s332 ^ s2465+ s2467 :: SBool = if s2315 then s2466 else s2465+ s2468 :: SBool = s322 ^ s2467+ s2469 :: SBool = if s2347 then s2468 else s2467+ s2470 :: SBool = s314 ^ s2469+ s2471 :: SBool = if s2379 then s2470 else s2469+ s2472 :: SBool = s308 ^ s2471+ s2473 :: SBool = if s2411 then s2472 else s2471+ s2474 :: SBool = s304 ^ s2473+ s2475 :: SBool = if s2443 then s2474 else s2473+ s2476 :: SBool = s8 ^ s230+ s2477 :: SBool = if s1995 then s2476 else s230+ s2478 :: SBool = s542 ^ s2477+ s2479 :: SBool = if s2027 then s2478 else s2477+ s2480 :: SBool = s512 ^ s2479+ s2481 :: SBool = if s2059 then s2480 else s2479+ s2482 :: SBool = s484 ^ s2481+ s2483 :: SBool = if s2091 then s2482 else s2481+ s2484 :: SBool = s458 ^ s2483+ s2485 :: SBool = if s2123 then s2484 else s2483+ s2486 :: SBool = s434 ^ s2485+ s2487 :: SBool = if s2155 then s2486 else s2485+ s2488 :: SBool = s412 ^ s2487+ s2489 :: SBool = if s2187 then s2488 else s2487+ s2490 :: SBool = s392 ^ s2489+ s2491 :: SBool = if s2219 then s2490 else s2489+ s2492 :: SBool = s374 ^ s2491+ s2493 :: SBool = if s2251 then s2492 else s2491+ s2494 :: SBool = s358 ^ s2493+ s2495 :: SBool = if s2283 then s2494 else s2493+ s2496 :: SBool = s344 ^ s2495+ s2497 :: SBool = if s2315 then s2496 else s2495+ s2498 :: SBool = s332 ^ s2497+ s2499 :: SBool = if s2347 then s2498 else s2497+ s2500 :: SBool = s322 ^ s2499+ s2501 :: SBool = if s2379 then s2500 else s2499+ s2502 :: SBool = s314 ^ s2501+ s2503 :: SBool = if s2411 then s2502 else s2501+ s2504 :: SBool = s308 ^ s2503+ s2505 :: SBool = if s2443 then s2504 else s2503+ s2506 :: SBool = s304 ^ s2505+ s2507 :: SBool = if s2475 then s2506 else s2505+ s2508 :: SBool = s8 ^ s236+ s2509 :: SBool = if s2027 then s2508 else s236+ s2510 :: SBool = s542 ^ s2509+ s2511 :: SBool = if s2059 then s2510 else s2509+ s2512 :: SBool = s512 ^ s2511+ s2513 :: SBool = if s2091 then s2512 else s2511+ s2514 :: SBool = s484 ^ s2513+ s2515 :: SBool = if s2123 then s2514 else s2513+ s2516 :: SBool = s458 ^ s2515+ s2517 :: SBool = if s2155 then s2516 else s2515+ s2518 :: SBool = s434 ^ s2517+ s2519 :: SBool = if s2187 then s2518 else s2517+ s2520 :: SBool = s412 ^ s2519+ s2521 :: SBool = if s2219 then s2520 else s2519+ s2522 :: SBool = s392 ^ s2521+ s2523 :: SBool = if s2251 then s2522 else s2521+ s2524 :: SBool = s374 ^ s2523+ s2525 :: SBool = if s2283 then s2524 else s2523+ s2526 :: SBool = s358 ^ s2525+ s2527 :: SBool = if s2315 then s2526 else s2525+ s2528 :: SBool = s344 ^ s2527+ s2529 :: SBool = if s2347 then s2528 else s2527+ s2530 :: SBool = s332 ^ s2529+ s2531 :: SBool = if s2379 then s2530 else s2529+ s2532 :: SBool = s322 ^ s2531+ s2533 :: SBool = if s2411 then s2532 else s2531+ s2534 :: SBool = s314 ^ s2533+ s2535 :: SBool = if s2443 then s2534 else s2533+ s2536 :: SBool = s308 ^ s2535+ s2537 :: SBool = if s2475 then s2536 else s2535+ s2538 :: SBool = s304 ^ s2537+ s2539 :: SBool = if s2507 then s2538 else s2537+ s2540 :: SBool = s8 ^ s242+ s2541 :: SBool = if s2059 then s2540 else s242+ s2542 :: SBool = s542 ^ s2541+ s2543 :: SBool = if s2091 then s2542 else s2541+ s2544 :: SBool = s512 ^ s2543+ s2545 :: SBool = if s2123 then s2544 else s2543+ s2546 :: SBool = s484 ^ s2545+ s2547 :: SBool = if s2155 then s2546 else s2545+ s2548 :: SBool = s458 ^ s2547+ s2549 :: SBool = if s2187 then s2548 else s2547+ s2550 :: SBool = s434 ^ s2549+ s2551 :: SBool = if s2219 then s2550 else s2549+ s2552 :: SBool = s412 ^ s2551+ s2553 :: SBool = if s2251 then s2552 else s2551+ s2554 :: SBool = s392 ^ s2553+ s2555 :: SBool = if s2283 then s2554 else s2553+ s2556 :: SBool = s374 ^ s2555+ s2557 :: SBool = if s2315 then s2556 else s2555+ s2558 :: SBool = s358 ^ s2557+ s2559 :: SBool = if s2347 then s2558 else s2557+ s2560 :: SBool = s344 ^ s2559+ s2561 :: SBool = if s2379 then s2560 else s2559+ s2562 :: SBool = s332 ^ s2561+ s2563 :: SBool = if s2411 then s2562 else s2561+ s2564 :: SBool = s322 ^ s2563+ s2565 :: SBool = if s2443 then s2564 else s2563+ s2566 :: SBool = s314 ^ s2565+ s2567 :: SBool = if s2475 then s2566 else s2565+ s2568 :: SBool = s308 ^ s2567+ s2569 :: SBool = if s2507 then s2568 else s2567+ s2570 :: SBool = s304 ^ s2569+ s2571 :: SBool = if s2539 then s2570 else s2569+ s2572 :: SBool = s8 ^ s248+ s2573 :: SBool = if s2091 then s2572 else s248+ s2574 :: SBool = s542 ^ s2573+ s2575 :: SBool = if s2123 then s2574 else s2573+ s2576 :: SBool = s512 ^ s2575+ s2577 :: SBool = if s2155 then s2576 else s2575+ s2578 :: SBool = s484 ^ s2577+ s2579 :: SBool = if s2187 then s2578 else s2577+ s2580 :: SBool = s458 ^ s2579+ s2581 :: SBool = if s2219 then s2580 else s2579+ s2582 :: SBool = s434 ^ s2581+ s2583 :: SBool = if s2251 then s2582 else s2581+ s2584 :: SBool = s412 ^ s2583+ s2585 :: SBool = if s2283 then s2584 else s2583+ s2586 :: SBool = s392 ^ s2585+ s2587 :: SBool = if s2315 then s2586 else s2585+ s2588 :: SBool = s374 ^ s2587+ s2589 :: SBool = if s2347 then s2588 else s2587+ s2590 :: SBool = s358 ^ s2589+ s2591 :: SBool = if s2379 then s2590 else s2589+ s2592 :: SBool = s344 ^ s2591+ s2593 :: SBool = if s2411 then s2592 else s2591+ s2594 :: SBool = s332 ^ s2593+ s2595 :: SBool = if s2443 then s2594 else s2593+ s2596 :: SBool = s322 ^ s2595+ s2597 :: SBool = if s2475 then s2596 else s2595+ s2598 :: SBool = s314 ^ s2597+ s2599 :: SBool = if s2507 then s2598 else s2597+ s2600 :: SBool = s308 ^ s2599+ s2601 :: SBool = if s2539 then s2600 else s2599+ s2602 :: SBool = s304 ^ s2601+ s2603 :: SBool = if s2571 then s2602 else s2601+ s2604 :: SBool = s8 ^ s254+ s2605 :: SBool = if s2123 then s2604 else s254+ s2606 :: SBool = s542 ^ s2605+ s2607 :: SBool = if s2155 then s2606 else s2605+ s2608 :: SBool = s512 ^ s2607+ s2609 :: SBool = if s2187 then s2608 else s2607+ s2610 :: SBool = s484 ^ s2609+ s2611 :: SBool = if s2219 then s2610 else s2609+ s2612 :: SBool = s458 ^ s2611+ s2613 :: SBool = if s2251 then s2612 else s2611+ s2614 :: SBool = s434 ^ s2613+ s2615 :: SBool = if s2283 then s2614 else s2613+ s2616 :: SBool = s412 ^ s2615+ s2617 :: SBool = if s2315 then s2616 else s2615+ s2618 :: SBool = s392 ^ s2617+ s2619 :: SBool = if s2347 then s2618 else s2617+ s2620 :: SBool = s374 ^ s2619+ s2621 :: SBool = if s2379 then s2620 else s2619+ s2622 :: SBool = s358 ^ s2621+ s2623 :: SBool = if s2411 then s2622 else s2621+ s2624 :: SBool = s344 ^ s2623+ s2625 :: SBool = if s2443 then s2624 else s2623+ s2626 :: SBool = s332 ^ s2625+ s2627 :: SBool = if s2475 then s2626 else s2625+ s2628 :: SBool = s322 ^ s2627+ s2629 :: SBool = if s2507 then s2628 else s2627+ s2630 :: SBool = s314 ^ s2629+ s2631 :: SBool = if s2539 then s2630 else s2629+ s2632 :: SBool = s308 ^ s2631+ s2633 :: SBool = if s2571 then s2632 else s2631+ s2634 :: SBool = s304 ^ s2633+ s2635 :: SBool = if s2603 then s2634 else s2633+ s2636 :: SBool = s8 ^ s260+ s2637 :: SBool = if s2155 then s2636 else s260+ s2638 :: SBool = s542 ^ s2637+ s2639 :: SBool = if s2187 then s2638 else s2637+ s2640 :: SBool = s512 ^ s2639+ s2641 :: SBool = if s2219 then s2640 else s2639+ s2642 :: SBool = s484 ^ s2641+ s2643 :: SBool = if s2251 then s2642 else s2641+ s2644 :: SBool = s458 ^ s2643+ s2645 :: SBool = if s2283 then s2644 else s2643+ s2646 :: SBool = s434 ^ s2645+ s2647 :: SBool = if s2315 then s2646 else s2645+ s2648 :: SBool = s412 ^ s2647+ s2649 :: SBool = if s2347 then s2648 else s2647+ s2650 :: SBool = s392 ^ s2649+ s2651 :: SBool = if s2379 then s2650 else s2649+ s2652 :: SBool = s374 ^ s2651+ s2653 :: SBool = if s2411 then s2652 else s2651+ s2654 :: SBool = s358 ^ s2653+ s2655 :: SBool = if s2443 then s2654 else s2653+ s2656 :: SBool = s344 ^ s2655+ s2657 :: SBool = if s2475 then s2656 else s2655+ s2658 :: SBool = s332 ^ s2657+ s2659 :: SBool = if s2507 then s2658 else s2657+ s2660 :: SBool = s322 ^ s2659+ s2661 :: SBool = if s2539 then s2660 else s2659+ s2662 :: SBool = s314 ^ s2661+ s2663 :: SBool = if s2571 then s2662 else s2661+ s2664 :: SBool = s308 ^ s2663+ s2665 :: SBool = if s2603 then s2664 else s2663+ s2666 :: SBool = s304 ^ s2665+ s2667 :: SBool = if s2635 then s2666 else s2665+ s2668 :: SBool = s8 ^ s266+ s2669 :: SBool = if s2187 then s2668 else s266+ s2670 :: SBool = s542 ^ s2669+ s2671 :: SBool = if s2219 then s2670 else s2669+ s2672 :: SBool = s512 ^ s2671+ s2673 :: SBool = if s2251 then s2672 else s2671+ s2674 :: SBool = s484 ^ s2673+ s2675 :: SBool = if s2283 then s2674 else s2673+ s2676 :: SBool = s458 ^ s2675+ s2677 :: SBool = if s2315 then s2676 else s2675+ s2678 :: SBool = s434 ^ s2677+ s2679 :: SBool = if s2347 then s2678 else s2677+ s2680 :: SBool = s412 ^ s2679+ s2681 :: SBool = if s2379 then s2680 else s2679+ s2682 :: SBool = s392 ^ s2681+ s2683 :: SBool = if s2411 then s2682 else s2681+ s2684 :: SBool = s374 ^ s2683+ s2685 :: SBool = if s2443 then s2684 else s2683+ s2686 :: SBool = s358 ^ s2685+ s2687 :: SBool = if s2475 then s2686 else s2685+ s2688 :: SBool = s344 ^ s2687+ s2689 :: SBool = if s2507 then s2688 else s2687+ s2690 :: SBool = s332 ^ s2689+ s2691 :: SBool = if s2539 then s2690 else s2689+ s2692 :: SBool = s322 ^ s2691+ s2693 :: SBool = if s2571 then s2692 else s2691+ s2694 :: SBool = s314 ^ s2693+ s2695 :: SBool = if s2603 then s2694 else s2693+ s2696 :: SBool = s308 ^ s2695+ s2697 :: SBool = if s2635 then s2696 else s2695+ s2698 :: SBool = s304 ^ s2697+ s2699 :: SBool = if s2667 then s2698 else s2697+ s2700 :: SBool = s8 ^ s272+ s2701 :: SBool = if s2219 then s2700 else s272+ s2702 :: SBool = s542 ^ s2701+ s2703 :: SBool = if s2251 then s2702 else s2701+ s2704 :: SBool = s512 ^ s2703+ s2705 :: SBool = if s2283 then s2704 else s2703+ s2706 :: SBool = s484 ^ s2705+ s2707 :: SBool = if s2315 then s2706 else s2705+ s2708 :: SBool = s458 ^ s2707+ s2709 :: SBool = if s2347 then s2708 else s2707+ s2710 :: SBool = s434 ^ s2709+ s2711 :: SBool = if s2379 then s2710 else s2709+ s2712 :: SBool = s412 ^ s2711+ s2713 :: SBool = if s2411 then s2712 else s2711+ s2714 :: SBool = s392 ^ s2713+ s2715 :: SBool = if s2443 then s2714 else s2713+ s2716 :: SBool = s374 ^ s2715+ s2717 :: SBool = if s2475 then s2716 else s2715+ s2718 :: SBool = s358 ^ s2717+ s2719 :: SBool = if s2507 then s2718 else s2717+ s2720 :: SBool = s344 ^ s2719+ s2721 :: SBool = if s2539 then s2720 else s2719+ s2722 :: SBool = s332 ^ s2721+ s2723 :: SBool = if s2571 then s2722 else s2721+ s2724 :: SBool = s322 ^ s2723+ s2725 :: SBool = if s2603 then s2724 else s2723+ s2726 :: SBool = s314 ^ s2725+ s2727 :: SBool = if s2635 then s2726 else s2725+ s2728 :: SBool = s308 ^ s2727+ s2729 :: SBool = if s2667 then s2728 else s2727+ s2730 :: SBool = s304 ^ s2729+ s2731 :: SBool = if s2699 then s2730 else s2729+ s2732 :: SBool = s8 ^ s278+ s2733 :: SBool = if s2251 then s2732 else s278+ s2734 :: SBool = s542 ^ s2733+ s2735 :: SBool = if s2283 then s2734 else s2733+ s2736 :: SBool = s512 ^ s2735+ s2737 :: SBool = if s2315 then s2736 else s2735+ s2738 :: SBool = s484 ^ s2737+ s2739 :: SBool = if s2347 then s2738 else s2737+ s2740 :: SBool = s458 ^ s2739+ s2741 :: SBool = if s2379 then s2740 else s2739+ s2742 :: SBool = s434 ^ s2741+ s2743 :: SBool = if s2411 then s2742 else s2741+ s2744 :: SBool = s412 ^ s2743+ s2745 :: SBool = if s2443 then s2744 else s2743+ s2746 :: SBool = s392 ^ s2745+ s2747 :: SBool = if s2475 then s2746 else s2745+ s2748 :: SBool = s374 ^ s2747+ s2749 :: SBool = if s2507 then s2748 else s2747+ s2750 :: SBool = s358 ^ s2749+ s2751 :: SBool = if s2539 then s2750 else s2749+ s2752 :: SBool = s344 ^ s2751+ s2753 :: SBool = if s2571 then s2752 else s2751+ s2754 :: SBool = s332 ^ s2753+ s2755 :: SBool = if s2603 then s2754 else s2753+ s2756 :: SBool = s322 ^ s2755+ s2757 :: SBool = if s2635 then s2756 else s2755+ s2758 :: SBool = s314 ^ s2757+ s2759 :: SBool = if s2667 then s2758 else s2757+ s2760 :: SBool = s308 ^ s2759+ s2761 :: SBool = if s2699 then s2760 else s2759+ s2762 :: SBool = s304 ^ s2761+ s2763 :: SBool = if s2731 then s2762 else s2761+ s2764 :: SBool = s8 ^ s284+ s2765 :: SBool = if s2283 then s2764 else s284+ s2766 :: SBool = s542 ^ s2765+ s2767 :: SBool = if s2315 then s2766 else s2765+ s2768 :: SBool = s512 ^ s2767+ s2769 :: SBool = if s2347 then s2768 else s2767+ s2770 :: SBool = s484 ^ s2769+ s2771 :: SBool = if s2379 then s2770 else s2769+ s2772 :: SBool = s458 ^ s2771+ s2773 :: SBool = if s2411 then s2772 else s2771+ s2774 :: SBool = s434 ^ s2773+ s2775 :: SBool = if s2443 then s2774 else s2773+ s2776 :: SBool = s412 ^ s2775+ s2777 :: SBool = if s2475 then s2776 else s2775+ s2778 :: SBool = s392 ^ s2777+ s2779 :: SBool = if s2507 then s2778 else s2777+ s2780 :: SBool = s374 ^ s2779+ s2781 :: SBool = if s2539 then s2780 else s2779+ s2782 :: SBool = s358 ^ s2781+ s2783 :: SBool = if s2571 then s2782 else s2781+ s2784 :: SBool = s344 ^ s2783+ s2785 :: SBool = if s2603 then s2784 else s2783+ s2786 :: SBool = s332 ^ s2785+ s2787 :: SBool = if s2635 then s2786 else s2785+ s2788 :: SBool = s322 ^ s2787+ s2789 :: SBool = if s2667 then s2788 else s2787+ s2790 :: SBool = s314 ^ s2789+ s2791 :: SBool = if s2699 then s2790 else s2789+ s2792 :: SBool = s308 ^ s2791+ s2793 :: SBool = if s2731 then s2792 else s2791+ s2794 :: SBool = s304 ^ s2793+ s2795 :: SBool = if s2763 then s2794 else s2793+ s2796 :: SBool = s8 ^ s290+ s2797 :: SBool = if s2315 then s2796 else s290+ s2798 :: SBool = s542 ^ s2797+ s2799 :: SBool = if s2347 then s2798 else s2797+ s2800 :: SBool = s512 ^ s2799+ s2801 :: SBool = if s2379 then s2800 else s2799+ s2802 :: SBool = s484 ^ s2801+ s2803 :: SBool = if s2411 then s2802 else s2801+ s2804 :: SBool = s458 ^ s2803+ s2805 :: SBool = if s2443 then s2804 else s2803+ s2806 :: SBool = s434 ^ s2805+ s2807 :: SBool = if s2475 then s2806 else s2805+ s2808 :: SBool = s412 ^ s2807+ s2809 :: SBool = if s2507 then s2808 else s2807+ s2810 :: SBool = s392 ^ s2809+ s2811 :: SBool = if s2539 then s2810 else s2809+ s2812 :: SBool = s374 ^ s2811+ s2813 :: SBool = if s2571 then s2812 else s2811+ s2814 :: SBool = s358 ^ s2813+ s2815 :: SBool = if s2603 then s2814 else s2813+ s2816 :: SBool = s344 ^ s2815+ s2817 :: SBool = if s2635 then s2816 else s2815+ s2818 :: SBool = s332 ^ s2817+ s2819 :: SBool = if s2667 then s2818 else s2817+ s2820 :: SBool = s322 ^ s2819+ s2821 :: SBool = if s2699 then s2820 else s2819+ s2822 :: SBool = s314 ^ s2821+ s2823 :: SBool = if s2731 then s2822 else s2821+ s2824 :: SBool = s308 ^ s2823+ s2825 :: SBool = if s2763 then s2824 else s2823+ s2826 :: SBool = s304 ^ s2825+ s2827 :: SBool = if s2795 then s2826 else s2825+ s2828 :: SBool = s8 ^ s296+ s2829 :: SBool = if s2347 then s2828 else s296+ s2830 :: SBool = s542 ^ s2829+ s2831 :: SBool = if s2379 then s2830 else s2829+ s2832 :: SBool = s512 ^ s2831+ s2833 :: SBool = if s2411 then s2832 else s2831+ s2834 :: SBool = s484 ^ s2833+ s2835 :: SBool = if s2443 then s2834 else s2833+ s2836 :: SBool = s458 ^ s2835+ s2837 :: SBool = if s2475 then s2836 else s2835+ s2838 :: SBool = s434 ^ s2837+ s2839 :: SBool = if s2507 then s2838 else s2837+ s2840 :: SBool = s412 ^ s2839+ s2841 :: SBool = if s2539 then s2840 else s2839+ s2842 :: SBool = s392 ^ s2841+ s2843 :: SBool = if s2571 then s2842 else s2841+ s2844 :: SBool = s374 ^ s2843+ s2845 :: SBool = if s2603 then s2844 else s2843+ s2846 :: SBool = s358 ^ s2845+ s2847 :: SBool = if s2635 then s2846 else s2845+ s2848 :: SBool = s344 ^ s2847+ s2849 :: SBool = if s2667 then s2848 else s2847+ s2850 :: SBool = s332 ^ s2849+ s2851 :: SBool = if s2699 then s2850 else s2849+ s2852 :: SBool = s322 ^ s2851+ s2853 :: SBool = if s2731 then s2852 else s2851+ s2854 :: SBool = s314 ^ s2853+ s2855 :: SBool = if s2763 then s2854 else s2853+ s2856 :: SBool = s308 ^ s2855+ s2857 :: SBool = if s2795 then s2856 else s2855+ s2858 :: SBool = s304 ^ s2857+ s2859 :: SBool = if s2827 then s2858 else s2857+ s2860 :: SBool = s8 ^ s301+ s2861 :: SBool = if s2379 then s2860 else s301+ s2862 :: SBool = s542 ^ s2861+ s2863 :: SBool = if s2411 then s2862 else s2861+ s2864 :: SBool = s512 ^ s2863+ s2865 :: SBool = if s2443 then s2864 else s2863+ s2866 :: SBool = s484 ^ s2865+ s2867 :: SBool = if s2475 then s2866 else s2865+ s2868 :: SBool = s458 ^ s2867+ s2869 :: SBool = if s2507 then s2868 else s2867+ s2870 :: SBool = s434 ^ s2869+ s2871 :: SBool = if s2539 then s2870 else s2869+ s2872 :: SBool = s412 ^ s2871+ s2873 :: SBool = if s2571 then s2872 else s2871+ s2874 :: SBool = s392 ^ s2873+ s2875 :: SBool = if s2603 then s2874 else s2873+ s2876 :: SBool = s374 ^ s2875+ s2877 :: SBool = if s2635 then s2876 else s2875+ s2878 :: SBool = s358 ^ s2877+ s2879 :: SBool = if s2667 then s2878 else s2877+ s2880 :: SBool = s344 ^ s2879+ s2881 :: SBool = if s2699 then s2880 else s2879+ s2882 :: SBool = s332 ^ s2881+ s2883 :: SBool = if s2731 then s2882 else s2881+ s2884 :: SBool = s322 ^ s2883+ s2885 :: SBool = if s2763 then s2884 else s2883+ s2886 :: SBool = s314 ^ s2885+ s2887 :: SBool = if s2795 then s2886 else s2885+ s2888 :: SBool = s308 ^ s2887+ s2889 :: SBool = if s2827 then s2888 else s2887+ s2890 :: SBool = s304 ^ s2889+ s2891 :: SBool = if s2859 then s2890 else s2889+ s2892 :: SBool = if s2411 then s8 else s_2+ s2893 :: SBool = s542 ^ s2892+ s2894 :: SBool = if s2443 then s2893 else s2892+ s2895 :: SBool = s512 ^ s2894+ s2896 :: SBool = if s2475 then s2895 else s2894+ s2897 :: SBool = s484 ^ s2896+ s2898 :: SBool = if s2507 then s2897 else s2896+ s2899 :: SBool = s458 ^ s2898+ s2900 :: SBool = if s2539 then s2899 else s2898+ s2901 :: SBool = s434 ^ s2900+ s2902 :: SBool = if s2571 then s2901 else s2900+ s2903 :: SBool = s412 ^ s2902+ s2904 :: SBool = if s2603 then s2903 else s2902+ s2905 :: SBool = s392 ^ s2904+ s2906 :: SBool = if s2635 then s2905 else s2904+ s2907 :: SBool = s374 ^ s2906+ s2908 :: SBool = if s2667 then s2907 else s2906+ s2909 :: SBool = s358 ^ s2908+ s2910 :: SBool = if s2699 then s2909 else s2908+ s2911 :: SBool = s344 ^ s2910+ s2912 :: SBool = if s2731 then s2911 else s2910+ s2913 :: SBool = s332 ^ s2912+ s2914 :: SBool = if s2763 then s2913 else s2912+ s2915 :: SBool = s322 ^ s2914+ s2916 :: SBool = if s2795 then s2915 else s2914+ s2917 :: SBool = s314 ^ s2916+ s2918 :: SBool = if s2827 then s2917 else s2916+ s2919 :: SBool = s308 ^ s2918+ s2920 :: SBool = if s2859 then s2919 else s2918+ s2921 :: SBool = s304 ^ s2920+ s2922 :: SBool = if s2891 then s2921 else s2920+ s2923 :: SBool = s1627 ^ s2922+ s2924 :: SBool = if s1148 then s8 else s_2+ s2925 :: SBool = s542 ^ s2924+ s2926 :: SBool = if s1180 then s2925 else s2924+ s2927 :: SBool = s512 ^ s2926+ s2928 :: SBool = if s1212 then s2927 else s2926+ s2929 :: SBool = s484 ^ s2928+ s2930 :: SBool = if s1244 then s2929 else s2928+ s2931 :: SBool = s458 ^ s2930+ s2932 :: SBool = if s1276 then s2931 else s2930+ s2933 :: SBool = s434 ^ s2932+ s2934 :: SBool = if s1308 then s2933 else s2932+ s2935 :: SBool = s412 ^ s2934+ s2936 :: SBool = if s1340 then s2935 else s2934+ s2937 :: SBool = s392 ^ s2936+ s2938 :: SBool = if s1372 then s2937 else s2936+ s2939 :: SBool = s374 ^ s2938+ s2940 :: SBool = if s1404 then s2939 else s2938+ s2941 :: SBool = s358 ^ s2940+ s2942 :: SBool = if s1436 then s2941 else s2940+ s2943 :: SBool = s344 ^ s2942+ s2944 :: SBool = if s1468 then s2943 else s2942+ s2945 :: SBool = s332 ^ s2944+ s2946 :: SBool = if s1500 then s2945 else s2944+ s2947 :: SBool = s322 ^ s2946+ s2948 :: SBool = if s1532 then s2947 else s2946+ s2949 :: SBool = s314 ^ s2948+ s2950 :: SBool = if s1564 then s2949 else s2948+ s2951 :: SBool = s308 ^ s2950+ s2952 :: SBool = if s1596 then s2951 else s2950+ s2953 :: SBool = if s2443 then s8 else s_2+ s2954 :: SBool = s542 ^ s2953+ s2955 :: SBool = if s2475 then s2954 else s2953+ s2956 :: SBool = s512 ^ s2955+ s2957 :: SBool = if s2507 then s2956 else s2955+ s2958 :: SBool = s484 ^ s2957+ s2959 :: SBool = if s2539 then s2958 else s2957+ s2960 :: SBool = s458 ^ s2959+ s2961 :: SBool = if s2571 then s2960 else s2959+ s2962 :: SBool = s434 ^ s2961+ s2963 :: SBool = if s2603 then s2962 else s2961+ s2964 :: SBool = s412 ^ s2963+ s2965 :: SBool = if s2635 then s2964 else s2963+ s2966 :: SBool = s392 ^ s2965+ s2967 :: SBool = if s2667 then s2966 else s2965+ s2968 :: SBool = s374 ^ s2967+ s2969 :: SBool = if s2699 then s2968 else s2967+ s2970 :: SBool = s358 ^ s2969+ s2971 :: SBool = if s2731 then s2970 else s2969+ s2972 :: SBool = s344 ^ s2971+ s2973 :: SBool = if s2763 then s2972 else s2971+ s2974 :: SBool = s332 ^ s2973+ s2975 :: SBool = if s2795 then s2974 else s2973+ s2976 :: SBool = s322 ^ s2975+ s2977 :: SBool = if s2827 then s2976 else s2975+ s2978 :: SBool = s314 ^ s2977+ s2979 :: SBool = if s2859 then s2978 else s2977+ s2980 :: SBool = s308 ^ s2979+ s2981 :: SBool = if s2891 then s2980 else s2979+ s2982 :: SBool = s2952 ^ s2981+ s2983 :: SBool = if s1180 then s8 else s_2+ s2984 :: SBool = s542 ^ s2983+ s2985 :: SBool = if s1212 then s2984 else s2983+ s2986 :: SBool = s512 ^ s2985+ s2987 :: SBool = if s1244 then s2986 else s2985+ s2988 :: SBool = s484 ^ s2987+ s2989 :: SBool = if s1276 then s2988 else s2987+ s2990 :: SBool = s458 ^ s2989+ s2991 :: SBool = if s1308 then s2990 else s2989+ s2992 :: SBool = s434 ^ s2991+ s2993 :: SBool = if s1340 then s2992 else s2991+ s2994 :: SBool = s412 ^ s2993+ s2995 :: SBool = if s1372 then s2994 else s2993+ s2996 :: SBool = s392 ^ s2995+ s2997 :: SBool = if s1404 then s2996 else s2995+ s2998 :: SBool = s374 ^ s2997+ s2999 :: SBool = if s1436 then s2998 else s2997+ s3000 :: SBool = s358 ^ s2999+ s3001 :: SBool = if s1468 then s3000 else s2999+ s3002 :: SBool = s344 ^ s3001+ s3003 :: SBool = if s1500 then s3002 else s3001+ s3004 :: SBool = s332 ^ s3003+ s3005 :: SBool = if s1532 then s3004 else s3003+ s3006 :: SBool = s322 ^ s3005+ s3007 :: SBool = if s1564 then s3006 else s3005+ s3008 :: SBool = s314 ^ s3007+ s3009 :: SBool = if s1596 then s3008 else s3007+ s3010 :: SBool = if s2475 then s8 else s_2+ s3011 :: SBool = s542 ^ s3010+ s3012 :: SBool = if s2507 then s3011 else s3010+ s3013 :: SBool = s512 ^ s3012+ s3014 :: SBool = if s2539 then s3013 else s3012+ s3015 :: SBool = s484 ^ s3014+ s3016 :: SBool = if s2571 then s3015 else s3014+ s3017 :: SBool = s458 ^ s3016+ s3018 :: SBool = if s2603 then s3017 else s3016+ s3019 :: SBool = s434 ^ s3018+ s3020 :: SBool = if s2635 then s3019 else s3018+ s3021 :: SBool = s412 ^ s3020+ s3022 :: SBool = if s2667 then s3021 else s3020+ s3023 :: SBool = s392 ^ s3022+ s3024 :: SBool = if s2699 then s3023 else s3022+ s3025 :: SBool = s374 ^ s3024+ s3026 :: SBool = if s2731 then s3025 else s3024+ s3027 :: SBool = s358 ^ s3026+ s3028 :: SBool = if s2763 then s3027 else s3026+ s3029 :: SBool = s344 ^ s3028+ s3030 :: SBool = if s2795 then s3029 else s3028+ s3031 :: SBool = s332 ^ s3030+ s3032 :: SBool = if s2827 then s3031 else s3030+ s3033 :: SBool = s322 ^ s3032+ s3034 :: SBool = if s2859 then s3033 else s3032+ s3035 :: SBool = s314 ^ s3034+ s3036 :: SBool = if s2891 then s3035 else s3034+ s3037 :: SBool = s3009 ^ s3036+ s3038 :: SBool = if s1212 then s8 else s_2+ s3039 :: SBool = s542 ^ s3038+ s3040 :: SBool = if s1244 then s3039 else s3038+ s3041 :: SBool = s512 ^ s3040+ s3042 :: SBool = if s1276 then s3041 else s3040+ s3043 :: SBool = s484 ^ s3042+ s3044 :: SBool = if s1308 then s3043 else s3042+ s3045 :: SBool = s458 ^ s3044+ s3046 :: SBool = if s1340 then s3045 else s3044+ s3047 :: SBool = s434 ^ s3046+ s3048 :: SBool = if s1372 then s3047 else s3046+ s3049 :: SBool = s412 ^ s3048+ s3050 :: SBool = if s1404 then s3049 else s3048+ s3051 :: SBool = s392 ^ s3050+ s3052 :: SBool = if s1436 then s3051 else s3050+ s3053 :: SBool = s374 ^ s3052+ s3054 :: SBool = if s1468 then s3053 else s3052+ s3055 :: SBool = s358 ^ s3054+ s3056 :: SBool = if s1500 then s3055 else s3054+ s3057 :: SBool = s344 ^ s3056+ s3058 :: SBool = if s1532 then s3057 else s3056+ s3059 :: SBool = s332 ^ s3058+ s3060 :: SBool = if s1564 then s3059 else s3058+ s3061 :: SBool = s322 ^ s3060+ s3062 :: SBool = if s1596 then s3061 else s3060+ s3063 :: SBool = if s2507 then s8 else s_2+ s3064 :: SBool = s542 ^ s3063+ s3065 :: SBool = if s2539 then s3064 else s3063+ s3066 :: SBool = s512 ^ s3065+ s3067 :: SBool = if s2571 then s3066 else s3065+ s3068 :: SBool = s484 ^ s3067+ s3069 :: SBool = if s2603 then s3068 else s3067+ s3070 :: SBool = s458 ^ s3069+ s3071 :: SBool = if s2635 then s3070 else s3069+ s3072 :: SBool = s434 ^ s3071+ s3073 :: SBool = if s2667 then s3072 else s3071+ s3074 :: SBool = s412 ^ s3073+ s3075 :: SBool = if s2699 then s3074 else s3073+ s3076 :: SBool = s392 ^ s3075+ s3077 :: SBool = if s2731 then s3076 else s3075+ s3078 :: SBool = s374 ^ s3077+ s3079 :: SBool = if s2763 then s3078 else s3077+ s3080 :: SBool = s358 ^ s3079+ s3081 :: SBool = if s2795 then s3080 else s3079+ s3082 :: SBool = s344 ^ s3081+ s3083 :: SBool = if s2827 then s3082 else s3081+ s3084 :: SBool = s332 ^ s3083+ s3085 :: SBool = if s2859 then s3084 else s3083+ s3086 :: SBool = s322 ^ s3085+ s3087 :: SBool = if s2891 then s3086 else s3085+ s3088 :: SBool = s3062 ^ s3087+ s3089 :: SBool = if s1244 then s8 else s_2+ s3090 :: SBool = s542 ^ s3089+ s3091 :: SBool = if s1276 then s3090 else s3089+ s3092 :: SBool = s512 ^ s3091+ s3093 :: SBool = if s1308 then s3092 else s3091+ s3094 :: SBool = s484 ^ s3093+ s3095 :: SBool = if s1340 then s3094 else s3093+ s3096 :: SBool = s458 ^ s3095+ s3097 :: SBool = if s1372 then s3096 else s3095+ s3098 :: SBool = s434 ^ s3097+ s3099 :: SBool = if s1404 then s3098 else s3097+ s3100 :: SBool = s412 ^ s3099+ s3101 :: SBool = if s1436 then s3100 else s3099+ s3102 :: SBool = s392 ^ s3101+ s3103 :: SBool = if s1468 then s3102 else s3101+ s3104 :: SBool = s374 ^ s3103+ s3105 :: SBool = if s1500 then s3104 else s3103+ s3106 :: SBool = s358 ^ s3105+ s3107 :: SBool = if s1532 then s3106 else s3105+ s3108 :: SBool = s344 ^ s3107+ s3109 :: SBool = if s1564 then s3108 else s3107+ s3110 :: SBool = s332 ^ s3109+ s3111 :: SBool = if s1596 then s3110 else s3109+ s3112 :: SBool = if s2539 then s8 else s_2+ s3113 :: SBool = s542 ^ s3112+ s3114 :: SBool = if s2571 then s3113 else s3112+ s3115 :: SBool = s512 ^ s3114+ s3116 :: SBool = if s2603 then s3115 else s3114+ s3117 :: SBool = s484 ^ s3116+ s3118 :: SBool = if s2635 then s3117 else s3116+ s3119 :: SBool = s458 ^ s3118+ s3120 :: SBool = if s2667 then s3119 else s3118+ s3121 :: SBool = s434 ^ s3120+ s3122 :: SBool = if s2699 then s3121 else s3120+ s3123 :: SBool = s412 ^ s3122+ s3124 :: SBool = if s2731 then s3123 else s3122+ s3125 :: SBool = s392 ^ s3124+ s3126 :: SBool = if s2763 then s3125 else s3124+ s3127 :: SBool = s374 ^ s3126+ s3128 :: SBool = if s2795 then s3127 else s3126+ s3129 :: SBool = s358 ^ s3128+ s3130 :: SBool = if s2827 then s3129 else s3128+ s3131 :: SBool = s344 ^ s3130+ s3132 :: SBool = if s2859 then s3131 else s3130+ s3133 :: SBool = s332 ^ s3132+ s3134 :: SBool = if s2891 then s3133 else s3132+ s3135 :: SBool = s3111 ^ s3134+ s3136 :: SBool = if s1276 then s8 else s_2+ s3137 :: SBool = s542 ^ s3136+ s3138 :: SBool = if s1308 then s3137 else s3136+ s3139 :: SBool = s512 ^ s3138+ s3140 :: SBool = if s1340 then s3139 else s3138+ s3141 :: SBool = s484 ^ s3140+ s3142 :: SBool = if s1372 then s3141 else s3140+ s3143 :: SBool = s458 ^ s3142+ s3144 :: SBool = if s1404 then s3143 else s3142+ s3145 :: SBool = s434 ^ s3144+ s3146 :: SBool = if s1436 then s3145 else s3144+ s3147 :: SBool = s412 ^ s3146+ s3148 :: SBool = if s1468 then s3147 else s3146+ s3149 :: SBool = s392 ^ s3148+ s3150 :: SBool = if s1500 then s3149 else s3148+ s3151 :: SBool = s374 ^ s3150+ s3152 :: SBool = if s1532 then s3151 else s3150+ s3153 :: SBool = s358 ^ s3152+ s3154 :: SBool = if s1564 then s3153 else s3152+ s3155 :: SBool = s344 ^ s3154+ s3156 :: SBool = if s1596 then s3155 else s3154+ s3157 :: SBool = if s2571 then s8 else s_2+ s3158 :: SBool = s542 ^ s3157+ s3159 :: SBool = if s2603 then s3158 else s3157+ s3160 :: SBool = s512 ^ s3159+ s3161 :: SBool = if s2635 then s3160 else s3159+ s3162 :: SBool = s484 ^ s3161+ s3163 :: SBool = if s2667 then s3162 else s3161+ s3164 :: SBool = s458 ^ s3163+ s3165 :: SBool = if s2699 then s3164 else s3163+ s3166 :: SBool = s434 ^ s3165+ s3167 :: SBool = if s2731 then s3166 else s3165+ s3168 :: SBool = s412 ^ s3167+ s3169 :: SBool = if s2763 then s3168 else s3167+ s3170 :: SBool = s392 ^ s3169+ s3171 :: SBool = if s2795 then s3170 else s3169+ s3172 :: SBool = s374 ^ s3171+ s3173 :: SBool = if s2827 then s3172 else s3171+ s3174 :: SBool = s358 ^ s3173+ s3175 :: SBool = if s2859 then s3174 else s3173+ s3176 :: SBool = s344 ^ s3175+ s3177 :: SBool = if s2891 then s3176 else s3175+ s3178 :: SBool = s3156 ^ s3177+ s3179 :: SBool = if s1308 then s8 else s_2+ s3180 :: SBool = s542 ^ s3179+ s3181 :: SBool = if s1340 then s3180 else s3179+ s3182 :: SBool = s512 ^ s3181+ s3183 :: SBool = if s1372 then s3182 else s3181+ s3184 :: SBool = s484 ^ s3183+ s3185 :: SBool = if s1404 then s3184 else s3183+ s3186 :: SBool = s458 ^ s3185+ s3187 :: SBool = if s1436 then s3186 else s3185+ s3188 :: SBool = s434 ^ s3187+ s3189 :: SBool = if s1468 then s3188 else s3187+ s3190 :: SBool = s412 ^ s3189+ s3191 :: SBool = if s1500 then s3190 else s3189+ s3192 :: SBool = s392 ^ s3191+ s3193 :: SBool = if s1532 then s3192 else s3191+ s3194 :: SBool = s374 ^ s3193+ s3195 :: SBool = if s1564 then s3194 else s3193+ s3196 :: SBool = s358 ^ s3195+ s3197 :: SBool = if s1596 then s3196 else s3195+ s3198 :: SBool = if s2603 then s8 else s_2+ s3199 :: SBool = s542 ^ s3198+ s3200 :: SBool = if s2635 then s3199 else s3198+ s3201 :: SBool = s512 ^ s3200+ s3202 :: SBool = if s2667 then s3201 else s3200+ s3203 :: SBool = s484 ^ s3202+ s3204 :: SBool = if s2699 then s3203 else s3202+ s3205 :: SBool = s458 ^ s3204+ s3206 :: SBool = if s2731 then s3205 else s3204+ s3207 :: SBool = s434 ^ s3206+ s3208 :: SBool = if s2763 then s3207 else s3206+ s3209 :: SBool = s412 ^ s3208+ s3210 :: SBool = if s2795 then s3209 else s3208+ s3211 :: SBool = s392 ^ s3210+ s3212 :: SBool = if s2827 then s3211 else s3210+ s3213 :: SBool = s374 ^ s3212+ s3214 :: SBool = if s2859 then s3213 else s3212+ s3215 :: SBool = s358 ^ s3214+ s3216 :: SBool = if s2891 then s3215 else s3214+ s3217 :: SBool = s3197 ^ s3216+ s3218 :: SBool = if s1340 then s8 else s_2+ s3219 :: SBool = s542 ^ s3218+ s3220 :: SBool = if s1372 then s3219 else s3218+ s3221 :: SBool = s512 ^ s3220+ s3222 :: SBool = if s1404 then s3221 else s3220+ s3223 :: SBool = s484 ^ s3222+ s3224 :: SBool = if s1436 then s3223 else s3222+ s3225 :: SBool = s458 ^ s3224+ s3226 :: SBool = if s1468 then s3225 else s3224+ s3227 :: SBool = s434 ^ s3226+ s3228 :: SBool = if s1500 then s3227 else s3226+ s3229 :: SBool = s412 ^ s3228+ s3230 :: SBool = if s1532 then s3229 else s3228+ s3231 :: SBool = s392 ^ s3230+ s3232 :: SBool = if s1564 then s3231 else s3230+ s3233 :: SBool = s374 ^ s3232+ s3234 :: SBool = if s1596 then s3233 else s3232+ s3235 :: SBool = if s2635 then s8 else s_2+ s3236 :: SBool = s542 ^ s3235+ s3237 :: SBool = if s2667 then s3236 else s3235+ s3238 :: SBool = s512 ^ s3237+ s3239 :: SBool = if s2699 then s3238 else s3237+ s3240 :: SBool = s484 ^ s3239+ s3241 :: SBool = if s2731 then s3240 else s3239+ s3242 :: SBool = s458 ^ s3241+ s3243 :: SBool = if s2763 then s3242 else s3241+ s3244 :: SBool = s434 ^ s3243+ s3245 :: SBool = if s2795 then s3244 else s3243+ s3246 :: SBool = s412 ^ s3245+ s3247 :: SBool = if s2827 then s3246 else s3245+ s3248 :: SBool = s392 ^ s3247+ s3249 :: SBool = if s2859 then s3248 else s3247+ s3250 :: SBool = s374 ^ s3249+ s3251 :: SBool = if s2891 then s3250 else s3249+ s3252 :: SBool = s3234 ^ s3251+ s3253 :: SBool = if s1372 then s8 else s_2+ s3254 :: SBool = s542 ^ s3253+ s3255 :: SBool = if s1404 then s3254 else s3253+ s3256 :: SBool = s512 ^ s3255+ s3257 :: SBool = if s1436 then s3256 else s3255+ s3258 :: SBool = s484 ^ s3257+ s3259 :: SBool = if s1468 then s3258 else s3257+ s3260 :: SBool = s458 ^ s3259+ s3261 :: SBool = if s1500 then s3260 else s3259+ s3262 :: SBool = s434 ^ s3261+ s3263 :: SBool = if s1532 then s3262 else s3261+ s3264 :: SBool = s412 ^ s3263+ s3265 :: SBool = if s1564 then s3264 else s3263+ s3266 :: SBool = s392 ^ s3265+ s3267 :: SBool = if s1596 then s3266 else s3265+ s3268 :: SBool = if s2667 then s8 else s_2+ s3269 :: SBool = s542 ^ s3268+ s3270 :: SBool = if s2699 then s3269 else s3268+ s3271 :: SBool = s512 ^ s3270+ s3272 :: SBool = if s2731 then s3271 else s3270+ s3273 :: SBool = s484 ^ s3272+ s3274 :: SBool = if s2763 then s3273 else s3272+ s3275 :: SBool = s458 ^ s3274+ s3276 :: SBool = if s2795 then s3275 else s3274+ s3277 :: SBool = s434 ^ s3276+ s3278 :: SBool = if s2827 then s3277 else s3276+ s3279 :: SBool = s412 ^ s3278+ s3280 :: SBool = if s2859 then s3279 else s3278+ s3281 :: SBool = s392 ^ s3280+ s3282 :: SBool = if s2891 then s3281 else s3280+ s3283 :: SBool = s3267 ^ s3282+ s3284 :: SBool = if s1404 then s8 else s_2+ s3285 :: SBool = s542 ^ s3284+ s3286 :: SBool = if s1436 then s3285 else s3284+ s3287 :: SBool = s512 ^ s3286+ s3288 :: SBool = if s1468 then s3287 else s3286+ s3289 :: SBool = s484 ^ s3288+ s3290 :: SBool = if s1500 then s3289 else s3288+ s3291 :: SBool = s458 ^ s3290+ s3292 :: SBool = if s1532 then s3291 else s3290+ s3293 :: SBool = s434 ^ s3292+ s3294 :: SBool = if s1564 then s3293 else s3292+ s3295 :: SBool = s412 ^ s3294+ s3296 :: SBool = if s1596 then s3295 else s3294+ s3297 :: SBool = if s2699 then s8 else s_2+ s3298 :: SBool = s542 ^ s3297+ s3299 :: SBool = if s2731 then s3298 else s3297+ s3300 :: SBool = s512 ^ s3299+ s3301 :: SBool = if s2763 then s3300 else s3299+ s3302 :: SBool = s484 ^ s3301+ s3303 :: SBool = if s2795 then s3302 else s3301+ s3304 :: SBool = s458 ^ s3303+ s3305 :: SBool = if s2827 then s3304 else s3303+ s3306 :: SBool = s434 ^ s3305+ s3307 :: SBool = if s2859 then s3306 else s3305+ s3308 :: SBool = s412 ^ s3307+ s3309 :: SBool = if s2891 then s3308 else s3307+ s3310 :: SBool = s3296 ^ s3309+ s3311 :: SBool = if s1436 then s8 else s_2+ s3312 :: SBool = s542 ^ s3311+ s3313 :: SBool = if s1468 then s3312 else s3311+ s3314 :: SBool = s512 ^ s3313+ s3315 :: SBool = if s1500 then s3314 else s3313+ s3316 :: SBool = s484 ^ s3315+ s3317 :: SBool = if s1532 then s3316 else s3315+ s3318 :: SBool = s458 ^ s3317+ s3319 :: SBool = if s1564 then s3318 else s3317+ s3320 :: SBool = s434 ^ s3319+ s3321 :: SBool = if s1596 then s3320 else s3319+ s3322 :: SBool = if s2731 then s8 else s_2+ s3323 :: SBool = s542 ^ s3322+ s3324 :: SBool = if s2763 then s3323 else s3322+ s3325 :: SBool = s512 ^ s3324+ s3326 :: SBool = if s2795 then s3325 else s3324+ s3327 :: SBool = s484 ^ s3326+ s3328 :: SBool = if s2827 then s3327 else s3326+ s3329 :: SBool = s458 ^ s3328+ s3330 :: SBool = if s2859 then s3329 else s3328+ s3331 :: SBool = s434 ^ s3330+ s3332 :: SBool = if s2891 then s3331 else s3330+ s3333 :: SBool = s3321 ^ s3332+ s3334 :: SBool = if s1468 then s8 else s_2+ s3335 :: SBool = s542 ^ s3334+ s3336 :: SBool = if s1500 then s3335 else s3334+ s3337 :: SBool = s512 ^ s3336+ s3338 :: SBool = if s1532 then s3337 else s3336+ s3339 :: SBool = s484 ^ s3338+ s3340 :: SBool = if s1564 then s3339 else s3338+ s3341 :: SBool = s458 ^ s3340+ s3342 :: SBool = if s1596 then s3341 else s3340+ s3343 :: SBool = if s2763 then s8 else s_2+ s3344 :: SBool = s542 ^ s3343+ s3345 :: SBool = if s2795 then s3344 else s3343+ s3346 :: SBool = s512 ^ s3345+ s3347 :: SBool = if s2827 then s3346 else s3345+ s3348 :: SBool = s484 ^ s3347+ s3349 :: SBool = if s2859 then s3348 else s3347+ s3350 :: SBool = s458 ^ s3349+ s3351 :: SBool = if s2891 then s3350 else s3349+ s3352 :: SBool = s3342 ^ s3351+ s3353 :: SBool = if s1500 then s8 else s_2+ s3354 :: SBool = s542 ^ s3353+ s3355 :: SBool = if s1532 then s3354 else s3353+ s3356 :: SBool = s512 ^ s3355+ s3357 :: SBool = if s1564 then s3356 else s3355+ s3358 :: SBool = s484 ^ s3357+ s3359 :: SBool = if s1596 then s3358 else s3357+ s3360 :: SBool = if s2795 then s8 else s_2+ s3361 :: SBool = s542 ^ s3360+ s3362 :: SBool = if s2827 then s3361 else s3360+ s3363 :: SBool = s512 ^ s3362+ s3364 :: SBool = if s2859 then s3363 else s3362+ s3365 :: SBool = s484 ^ s3364+ s3366 :: SBool = if s2891 then s3365 else s3364+ s3367 :: SBool = s3359 ^ s3366+ s3368 :: SBool = if s1532 then s8 else s_2+ s3369 :: SBool = s542 ^ s3368+ s3370 :: SBool = if s1564 then s3369 else s3368+ s3371 :: SBool = s512 ^ s3370+ s3372 :: SBool = if s1596 then s3371 else s3370+ s3373 :: SBool = if s2827 then s8 else s_2+ s3374 :: SBool = s542 ^ s3373+ s3375 :: SBool = if s2859 then s3374 else s3373+ s3376 :: SBool = s512 ^ s3375+ s3377 :: SBool = if s2891 then s3376 else s3375+ s3378 :: SBool = s3372 ^ s3377+ s3379 :: SBool = if s1564 then s8 else s_2+ s3380 :: SBool = s542 ^ s3379+ s3381 :: SBool = if s1596 then s3380 else s3379+ s3382 :: SBool = if s2859 then s8 else s_2+ s3383 :: SBool = s542 ^ s3382+ s3384 :: SBool = if s2891 then s3383 else s3382+ s3385 :: SBool = s3381 ^ s3384+ s3386 :: SBool = if s1596 then s8 else s_2+ s3387 :: SBool = if s2891 then s8 else s_2+ s3388 :: SBool = s3386 ^ s3387+ s3390 :: SWord8 = if s3388 then s21 else s3389+ s3391 :: SWord8 = s21 + s3390+ s3392 :: SWord8 = if s3385 then s3391 else s3390+ s3393 :: SWord8 = s21 + s3392+ s3394 :: SWord8 = if s3378 then s3393 else s3392+ s3395 :: SWord8 = s21 + s3394+ s3396 :: SWord8 = if s3367 then s3395 else s3394+ s3397 :: SWord8 = s21 + s3396+ s3398 :: SWord8 = if s3352 then s3397 else s3396+ s3399 :: SWord8 = s21 + s3398+ s3400 :: SWord8 = if s3333 then s3399 else s3398+ s3401 :: SWord8 = s21 + s3400+ s3402 :: SWord8 = if s3310 then s3401 else s3400+ s3403 :: SWord8 = s21 + s3402+ s3404 :: SWord8 = if s3283 then s3403 else s3402+ s3405 :: SWord8 = s21 + s3404+ s3406 :: SWord8 = if s3252 then s3405 else s3404+ s3407 :: SWord8 = s21 + s3406+ s3408 :: SWord8 = if s3217 then s3407 else s3406+ s3409 :: SWord8 = s21 + s3408+ s3410 :: SWord8 = if s3178 then s3409 else s3408+ s3411 :: SWord8 = s21 + s3410+ s3412 :: SWord8 = if s3135 then s3411 else s3410+ s3413 :: SWord8 = s21 + s3412+ s3414 :: SWord8 = if s3088 then s3413 else s3412+ s3415 :: SWord8 = s21 + s3414+ s3416 :: SWord8 = if s3037 then s3415 else s3414+ s3417 :: SWord8 = s21 + s3416+ s3418 :: SWord8 = if s2982 then s3417 else s3416+ s3419 :: SWord8 = s21 + s3418+ s3420 :: SWord8 = if s2923 then s3419 else s3418+ s3421 :: SWord8 = s21 + s3420+ s3422 :: SWord8 = if s302 then s3421 else s3420+ s3423 :: SWord8 = s21 + s3422+ s3424 :: SWord8 = if s297 then s3423 else s3422+ s3425 :: SWord8 = s21 + s3424+ s3426 :: SWord8 = if s291 then s3425 else s3424+ s3427 :: SWord8 = s21 + s3426+ s3428 :: SWord8 = if s285 then s3427 else s3426+ s3429 :: SWord8 = s21 + s3428+ s3430 :: SWord8 = if s279 then s3429 else s3428+ s3431 :: SWord8 = s21 + s3430+ s3432 :: SWord8 = if s273 then s3431 else s3430+ s3433 :: SWord8 = s21 + s3432+ s3434 :: SWord8 = if s267 then s3433 else s3432+ s3435 :: SWord8 = s21 + s3434+ s3436 :: SWord8 = if s261 then s3435 else s3434+ s3437 :: SWord8 = s21 + s3436+ s3438 :: SWord8 = if s255 then s3437 else s3436+ s3439 :: SWord8 = s21 + s3438+ s3440 :: SWord8 = if s249 then s3439 else s3438+ s3441 :: SWord8 = s21 + s3440+ s3442 :: SWord8 = if s243 then s3441 else s3440+ s3443 :: SWord8 = s21 + s3442+ s3444 :: SWord8 = if s237 then s3443 else s3442+ s3445 :: SWord8 = s21 + s3444+ s3446 :: SWord8 = if s231 then s3445 else s3444+ s3447 :: SWord8 = s21 + s3446+ s3448 :: SWord8 = if s225 then s3447 else s3446+ s3449 :: SWord8 = s21 + s3448+ s3450 :: SWord8 = if s219 then s3449 else s3448+ s3451 :: SWord8 = s21 + s3450+ s3452 :: SWord8 = if s213 then s3451 else s3450+ s3453 :: SWord8 = s21 + s3452+ s3454 :: SWord8 = if s207 then s3453 else s3452+ s3455 :: SWord8 = s21 + s3454+ s3456 :: SWord8 = if s201 then s3455 else s3454+ s3457 :: SWord8 = s21 + s3456+ s3458 :: SWord8 = if s195 then s3457 else s3456+ s3459 :: SWord8 = s21 + s3458+ s3460 :: SWord8 = if s189 then s3459 else s3458+ s3461 :: SWord8 = s21 + s3460+ s3462 :: SWord8 = if s183 then s3461 else s3460+ s3463 :: SWord8 = s21 + s3462+ s3464 :: SWord8 = if s177 then s3463 else s3462+ s3465 :: SWord8 = s21 + s3464+ s3466 :: SWord8 = if s171 then s3465 else s3464+ s3467 :: SWord8 = s21 + s3466+ s3468 :: SWord8 = if s165 then s3467 else s3466+ s3469 :: SWord8 = s21 + s3468+ s3470 :: SWord8 = if s159 then s3469 else s3468+ s3471 :: SWord8 = s21 + s3470+ s3472 :: SWord8 = if s153 then s3471 else s3470+ s3473 :: SWord8 = s21 + s3472+ s3474 :: SWord8 = if s147 then s3473 else s3472+ s3475 :: SWord8 = s21 + s3474+ s3476 :: SWord8 = if s141 then s3475 else s3474+ s3477 :: SWord8 = s21 + s3476+ s3478 :: SWord8 = if s135 then s3477 else s3476+ s3479 :: SWord8 = s21 + s3478+ s3480 :: SWord8 = if s129 then s3479 else s3478+ s3481 :: SWord8 = s21 + s3480+ s3482 :: SWord8 = if s123 then s3481 else s3480+ s3483 :: SWord8 = s21 + s3482+ s3484 :: SWord8 = if s117 then s3483 else s3482+ s3485 :: SWord8 = s21 + s3484+ s3486 :: SWord8 = if s111 then s3485 else s3484+ s3487 :: SWord8 = s21 + s3486+ s3488 :: SWord8 = if s105 then s3487 else s3486+ s3489 :: SWord8 = s21 + s3488+ s3490 :: SWord8 = if s99 then s3489 else s3488+ s3491 :: SWord8 = s21 + s3490+ s3492 :: SWord8 = if s93 then s3491 else s3490+ s3493 :: SWord8 = s21 + s3492+ s3494 :: SWord8 = if s87 then s3493 else s3492+ s3495 :: SWord8 = s21 + s3494+ s3496 :: SWord8 = if s81 then s3495 else s3494+ s3497 :: SWord8 = s21 + s3496+ s3498 :: SWord8 = if s75 then s3497 else s3496+ s3499 :: SWord8 = s21 + s3498+ s3500 :: SWord8 = if s69 then s3499 else s3498+ s3501 :: SWord8 = s21 + s3500+ s3502 :: SWord8 = if s63 then s3501 else s3500+ s3503 :: SWord8 = s21 + s3502+ s3504 :: SWord8 = if s57 then s3503 else s3502+ s3505 :: SWord8 = s21 + s3504+ s3506 :: SWord8 = if s51 then s3505 else s3504+ s3507 :: SWord8 = s21 + s3506+ s3508 :: SWord8 = if s45 then s3507 else s3506+ s3509 :: SWord8 = s21 + s3508+ s3510 :: SWord8 = if s39 then s3509 else s3508+ s3511 :: SWord8 = s21 + s3510+ s3512 :: SWord8 = if s33 then s3511 else s3510+ s3513 :: SWord8 = s21 + s3512+ s3514 :: SWord8 = if s27 then s3513 else s3512+ s3515 :: SWord8 = s21 + s3514+ s3516 :: SWord8 = if s20 then s3515 else s3514+ s3518 :: SBool = s3516 > s3517+ s3519 :: SBool = s13 | s3518+ s3520 :: SBool = s8 & s3519+OUTPUTS+ s3520
+ SBVUnitTest/GoldFiles/crcUSB5_1.gold view
@@ -0,0 +1,177 @@+== BEGIN: "Makefile" ================+# Makefile for crcUSB5. Automatically generated by SBV. Do not edit!++# include any user-defined .mk file in the current directory.+-include *.mk++CC=gcc+CCFLAGS?=-Wall -O3 -DNDEBUG -fomit-frame-pointer++all: crcUSB5_driver++crcUSB5.o: crcUSB5.c crcUSB5.h+ ${CC} ${CCFLAGS} -c $< -o $@++crcUSB5_driver.o: crcUSB5_driver.c+ ${CC} ${CCFLAGS} -c $< -o $@++crcUSB5_driver: crcUSB5.o crcUSB5_driver.o+ ${CC} ${CCFLAGS} $^ -o $@++clean:+ rm -f *.o++veryclean: clean+ rm -f crcUSB5_driver+== END: "Makefile" ==================+== BEGIN: "crcUSB5.h" ================+/* Header file for crcUSB5. Automatically generated by SBV. Do not edit! */++#ifndef __crcUSB5__HEADER_INCLUDED__+#define __crcUSB5__HEADER_INCLUDED__++#include <inttypes.h>+#include <stdint.h>++/* Unsigned bit-vectors */+typedef uint8_t SBool ;+typedef uint8_t SWord8 ;+typedef uint16_t SWord16;+typedef uint32_t SWord32;+typedef uint64_t SWord64;++/* Signed bit-vectors */+typedef int8_t SInt8 ;+typedef int16_t SInt16;+typedef int32_t SInt32;+typedef int64_t SInt64;++/* Entry point prototype: */+SWord16 crcUSB5(const SWord16 msg);++#endif /* __crcUSB5__HEADER_INCLUDED__ */+== END: "crcUSB5.h" ==================+== BEGIN: "crcUSB5_driver.c" ================+/* Example driver program for crcUSB5. */+/* Automatically generated by SBV. Edit as you see fit! */++#include <inttypes.h>+#include <stdint.h>+#include <stdio.h>+#include "crcUSB5.h"++int main(void)+{+ const SWord16 __result = crcUSB5(0xfedcU);+ + printf("crcUSB5(0xfedcU) = 0x%04"PRIx16"U\n", __result);++ return 0;+}+== END: "crcUSB5_driver.c" ==================+== BEGIN: "crcUSB5.c" ================+/* File: "crcUSB5.c". Automatically generated by SBV. Do not edit! */++#include <inttypes.h>+#include <stdint.h>+#include "crcUSB5.h"++SWord16 crcUSB5(const SWord16 msg)+{+ const SWord16 s0 = msg;+ const SWord16 s2 = s0 & 0x0400U;+ const SBool s4 = s2 != 0x0000U;+ const SWord16 s6 = s0 & 0x0200U;+ const SBool s7 = 0x0000U != s6;+ const SWord16 s9 = s0 & 0x0100U;+ const SBool s10 = 0x0000U != s9;+ const SWord16 s12 = s0 & 0x0080U;+ const SBool s13 = 0x0000U != s12;+ const SWord16 s15 = s0 & 0x0040U;+ const SBool s16 = 0x0000U != s15;+ const SWord16 s18 = s0 & 0x0020U;+ const SBool s19 = 0x0000U != s18;+ const SWord16 s21 = s0 & 0x0010U;+ const SBool s22 = 0x0000U != s21;+ const SWord16 s24 = s0 & 0x0008U;+ const SBool s25 = 0x0000U != s24;+ const SWord16 s27 = s0 & 0x0004U;+ const SBool s28 = 0x0000U != s27;+ const SWord16 s30 = s0 & 0x0002U;+ const SBool s31 = 0x0000U != s30;+ const SWord16 s33 = s0 & 0x0001U;+ const SBool s34 = 0x0000U != s33;+ const SBool s35 = (~s13) & 0x01U;+ const SBool s36 = s4 ? s35 : s13;+ const SBool s37 = (~s16) & 0x01U;+ const SBool s38 = s7 ? s37 : s16;+ const SBool s39 = (~s19) & 0x01U;+ const SBool s40 = s4 ? s39 : s19;+ const SBool s41 = (~s40) & 0x01U;+ const SBool s42 = s10 ? s41 : s40;+ const SBool s43 = (~s22) & 0x01U;+ const SBool s44 = s7 ? s43 : s22;+ const SBool s45 = (~s44) & 0x01U;+ const SBool s46 = s36 ? s45 : s44;+ const SBool s47 = (~s25) & 0x01U;+ const SBool s48 = s10 ? s47 : s25;+ const SBool s49 = (~s48) & 0x01U;+ const SBool s50 = s38 ? s49 : s48;+ const SBool s51 = (~s28) & 0x01U;+ const SBool s52 = s36 ? s51 : s28;+ const SBool s53 = (~s52) & 0x01U;+ const SBool s54 = s42 ? s53 : s52;+ const SBool s55 = (~s31) & 0x01U;+ const SBool s56 = s38 ? s55 : s31;+ const SBool s57 = (~s56) & 0x01U;+ const SBool s58 = s46 ? s57 : s56;+ const SBool s59 = (~s34) & 0x01U;+ const SBool s60 = s42 ? s59 : s34;+ const SBool s61 = (~s60) & 0x01U;+ const SBool s62 = s50 ? s61 : s60;+ const SBool s63 = s46 ? 1 : 0;+ const SBool s64 = (~s63) & 0x01U;+ const SBool s65 = s54 ? s64 : s63;+ const SBool s66 = s50 ? 1 : 0;+ const SBool s67 = (~s66) & 0x01U;+ const SBool s68 = s58 ? s67 : s66;+ const SBool s69 = s54 ? 1 : 0;+ const SBool s70 = (~s69) & 0x01U;+ const SBool s71 = s62 ? s70 : s69;+ const SBool s72 = s58 ? 1 : 0;+ const SBool s73 = s62 ? 1 : 0;+ const SWord16 s74 = s73 ? 0x0001U : 0x0000U;+ const SWord16 s75 = 0x0002U | s74;+ const SWord16 s76 = s72 ? s75 : s74;+ const SWord16 s77 = 0x0004U | s76;+ const SWord16 s78 = s71 ? s77 : s76;+ const SWord16 s79 = 0x0008U | s78;+ const SWord16 s80 = s68 ? s79 : s78;+ const SWord16 s81 = 0x0010U | s80;+ const SWord16 s82 = s65 ? s81 : s80;+ const SWord16 s83 = 0x0020U | s82;+ const SWord16 s84 = s34 ? s83 : s82;+ const SWord16 s85 = 0x0040U | s84;+ const SWord16 s86 = s31 ? s85 : s84;+ const SWord16 s87 = 0x0080U | s86;+ const SWord16 s88 = s28 ? s87 : s86;+ const SWord16 s89 = 0x0100U | s88;+ const SWord16 s90 = s25 ? s89 : s88;+ const SWord16 s91 = 0x0200U | s90;+ const SWord16 s92 = s22 ? s91 : s90;+ const SWord16 s93 = 0x0400U | s92;+ const SWord16 s94 = s19 ? s93 : s92;+ const SWord16 s96 = s94 | 0x0800U;+ const SWord16 s97 = s16 ? s96 : s94;+ const SWord16 s99 = s97 | 0x1000U;+ const SWord16 s100 = s13 ? s99 : s97;+ const SWord16 s102 = s100 | 0x2000U;+ const SWord16 s103 = s10 ? s102 : s100;+ const SWord16 s105 = s103 | 0x4000U;+ const SWord16 s106 = s7 ? s105 : s103;+ const SWord16 s108 = s106 | 0x8000U;+ const SWord16 s109 = s4 ? s108 : s106;+ + return s109;+}+== END: "crcUSB5.c" ==================
+ SBVUnitTest/GoldFiles/crcUSB5_2.gold view
@@ -0,0 +1,216 @@+== BEGIN: "Makefile" ================+# Makefile for crcUSB5. Automatically generated by SBV. Do not edit!++# include any user-defined .mk file in the current directory.+-include *.mk++CC=gcc+CCFLAGS?=-Wall -O3 -DNDEBUG -fomit-frame-pointer++all: crcUSB5_driver++crcUSB5.o: crcUSB5.c crcUSB5.h+ ${CC} ${CCFLAGS} -c $< -o $@++crcUSB5_driver.o: crcUSB5_driver.c+ ${CC} ${CCFLAGS} -c $< -o $@++crcUSB5_driver: crcUSB5.o crcUSB5_driver.o+ ${CC} ${CCFLAGS} $^ -o $@++clean:+ rm -f *.o++veryclean: clean+ rm -f crcUSB5_driver+== END: "Makefile" ==================+== BEGIN: "crcUSB5.h" ================+/* Header file for crcUSB5. Automatically generated by SBV. Do not edit! */++#ifndef __crcUSB5__HEADER_INCLUDED__+#define __crcUSB5__HEADER_INCLUDED__++#include <inttypes.h>+#include <stdint.h>++/* Unsigned bit-vectors */+typedef uint8_t SBool ;+typedef uint8_t SWord8 ;+typedef uint16_t SWord16;+typedef uint32_t SWord32;+typedef uint64_t SWord64;++/* Signed bit-vectors */+typedef int8_t SInt8 ;+typedef int16_t SInt16;+typedef int32_t SInt32;+typedef int64_t SInt64;++/* Entry point prototype: */+SWord16 crcUSB5(const SWord16 msg);++#endif /* __crcUSB5__HEADER_INCLUDED__ */+== END: "crcUSB5.h" ==================+== BEGIN: "crcUSB5_driver.c" ================+/* Example driver program for crcUSB5. */+/* Automatically generated by SBV. Edit as you see fit! */++#include <inttypes.h>+#include <stdint.h>+#include <stdio.h>+#include "crcUSB5.h"++int main(void)+{+ const SWord16 __result = crcUSB5(0xfedcU);+ + printf("crcUSB5(0xfedcU) = 0x%04"PRIx16"U\n", __result);++ return 0;+}+== END: "crcUSB5_driver.c" ==================+== BEGIN: "crcUSB5.c" ================+/* File: "crcUSB5.c". Automatically generated by SBV. Do not edit! */++#include <inttypes.h>+#include <stdint.h>+#include "crcUSB5.h"++SWord16 crcUSB5(const SWord16 msg)+{+ const SWord16 s0 = msg;+ const SWord16 s1 = s0 << 5;+ const SWord16 s3 = s1 & 0x8000U;+ const SBool s5 = s3 != 0x0000U;+ const SWord16 s7 = s1 & 0x4000U;+ const SBool s8 = 0x0000U != s7;+ const SWord16 s10 = s1 & 0x2000U;+ const SBool s11 = 0x0000U != s10;+ const SWord16 s13 = s1 & 0x1000U;+ const SBool s14 = 0x0000U != s13;+ const SBool s15 = (~s14) & 0x01U;+ const SBool s16 = s5 ? s15 : s14;+ const SWord16 s18 = s1 & 0x0800U;+ const SBool s19 = 0x0000U != s18;+ const SBool s20 = (~s19) & 0x01U;+ const SBool s21 = s8 ? s20 : s19;+ const SWord16 s23 = s1 & 0x0400U;+ const SBool s24 = 0x0000U != s23;+ const SBool s25 = (~s24) & 0x01U;+ const SBool s26 = s5 ? s25 : s24;+ const SBool s27 = (~s26) & 0x01U;+ const SBool s28 = s11 ? s27 : s26;+ const SWord16 s30 = s1 & 0x0200U;+ const SBool s31 = 0x0000U != s30;+ const SBool s32 = (~s31) & 0x01U;+ const SBool s33 = s8 ? s32 : s31;+ const SBool s34 = (~s33) & 0x01U;+ const SBool s35 = s16 ? s34 : s33;+ const SWord16 s37 = s1 & 0x0100U;+ const SBool s38 = 0x0000U != s37;+ const SBool s39 = (~s38) & 0x01U;+ const SBool s40 = s11 ? s39 : s38;+ const SBool s41 = (~s40) & 0x01U;+ const SBool s42 = s21 ? s41 : s40;+ const SWord16 s44 = s1 & 0x0080U;+ const SBool s45 = 0x0000U != s44;+ const SBool s46 = (~s45) & 0x01U;+ const SBool s47 = s16 ? s46 : s45;+ const SBool s48 = (~s47) & 0x01U;+ const SBool s49 = s28 ? s48 : s47;+ const SWord16 s51 = s1 & 0x0040U;+ const SBool s52 = 0x0000U != s51;+ const SBool s53 = (~s52) & 0x01U;+ const SBool s54 = s21 ? s53 : s52;+ const SBool s55 = (~s54) & 0x01U;+ const SBool s56 = s35 ? s55 : s54;+ const SWord16 s58 = s1 & 0x0020U;+ const SBool s59 = 0x0000U != s58;+ const SBool s60 = (~s59) & 0x01U;+ const SBool s61 = s28 ? s60 : s59;+ const SBool s62 = (~s61) & 0x01U;+ const SBool s63 = s42 ? s62 : s61;+ const SBool s64 = (~s5) & 0x01U;+ const SBool s65 = s5 ? s64 : s5;+ const SBool s66 = (~s8) & 0x01U;+ const SBool s67 = s8 ? s66 : s8;+ const SBool s68 = (~s11) & 0x01U;+ const SBool s69 = s11 ? s68 : s11;+ const SBool s70 = (~s16) & 0x01U;+ const SBool s71 = s16 ? s70 : s16;+ const SBool s72 = (~s21) & 0x01U;+ const SBool s73 = s21 ? s72 : s21;+ const SBool s74 = (~s28) & 0x01U;+ const SBool s75 = s28 ? s74 : s28;+ const SBool s76 = (~s35) & 0x01U;+ const SBool s77 = s35 ? s76 : s35;+ const SBool s78 = (~s42) & 0x01U;+ const SBool s79 = s42 ? s78 : s42;+ const SBool s80 = (~s49) & 0x01U;+ const SBool s81 = s49 ? s80 : s49;+ const SBool s82 = (~s56) & 0x01U;+ const SBool s83 = s56 ? s82 : s56;+ const SBool s84 = (~s63) & 0x01U;+ const SBool s85 = s63 ? s84 : s63;+ const SWord16 s87 = s1 & 0x0010U;+ const SBool s88 = 0x0000U != s87;+ const SBool s89 = (~s88) & 0x01U;+ const SBool s90 = s35 ? s89 : s88;+ const SBool s91 = (~s90) & 0x01U;+ const SBool s92 = s49 ? s91 : s90;+ const SWord16 s94 = s1 & 0x0008U;+ const SBool s95 = 0x0000U != s94;+ const SBool s96 = (~s95) & 0x01U;+ const SBool s97 = s42 ? s96 : s95;+ const SBool s98 = (~s97) & 0x01U;+ const SBool s99 = s56 ? s98 : s97;+ const SWord16 s101 = s1 & 0x0004U;+ const SBool s102 = 0x0000U != s101;+ const SBool s103 = (~s102) & 0x01U;+ const SBool s104 = s49 ? s103 : s102;+ const SBool s105 = (~s104) & 0x01U;+ const SBool s106 = s63 ? s105 : s104;+ const SWord16 s108 = s1 & 0x0002U;+ const SBool s109 = 0x0000U != s108;+ const SBool s110 = (~s109) & 0x01U;+ const SBool s111 = s56 ? s110 : s109;+ const SWord16 s113 = s1 & 0x0001U;+ const SBool s114 = 0x0000U != s113;+ const SBool s115 = (~s114) & 0x01U;+ const SBool s116 = s63 ? s115 : s114;+ const SWord16 s117 = s116 ? 0x0001U : 0x0000U;+ const SWord16 s118 = 0x0002U | s117;+ const SWord16 s119 = s111 ? s118 : s117;+ const SWord16 s120 = 0x0004U | s119;+ const SWord16 s121 = s106 ? s120 : s119;+ const SWord16 s122 = 0x0008U | s121;+ const SWord16 s123 = s99 ? s122 : s121;+ const SWord16 s124 = 0x0010U | s123;+ const SWord16 s125 = s92 ? s124 : s123;+ const SWord16 s126 = 0x0020U | s125;+ const SWord16 s127 = s85 ? s126 : s125;+ const SWord16 s128 = 0x0040U | s127;+ const SWord16 s129 = s83 ? s128 : s127;+ const SWord16 s130 = 0x0080U | s129;+ const SWord16 s131 = s81 ? s130 : s129;+ const SWord16 s132 = 0x0100U | s131;+ const SWord16 s133 = s79 ? s132 : s131;+ const SWord16 s134 = 0x0200U | s133;+ const SWord16 s135 = s77 ? s134 : s133;+ const SWord16 s136 = 0x0400U | s135;+ const SWord16 s137 = s75 ? s136 : s135;+ const SWord16 s138 = 0x0800U | s137;+ const SWord16 s139 = s73 ? s138 : s137;+ const SWord16 s140 = 0x1000U | s139;+ const SWord16 s141 = s71 ? s140 : s139;+ const SWord16 s142 = 0x2000U | s141;+ const SWord16 s143 = s69 ? s142 : s141;+ const SWord16 s144 = 0x4000U | s143;+ const SWord16 s145 = s67 ? s144 : s143;+ const SWord16 s146 = 0x8000U | s145;+ const SWord16 s147 = s65 ? s146 : s145;+ const SWord16 s148 = s1 | s147;+ + return s148;+}+== END: "crcUSB5.c" ==================
SBVUnitTest/GoldFiles/dogCatMouse.gold view
@@ -1,4 +1,5 @@-Only one solution found:- s0 = 3 :: SWord16- s1 = 41 :: SWord16- s2 = 56 :: SWord16+Solution #1:+ d = 3 :: SWord16+ c = 41 :: SWord16+ m = 56 :: SWord16+This is the only solution.
SBVUnitTest/GoldFiles/euler185.gold view
@@ -1,4 +1,4 @@-Only one solution found:+Solution #1: s0 = 4 :: SWord8 s1 = 6 :: SWord8 s2 = 4 :: SWord8@@ -15,3 +15,4 @@ s13 = 5 :: SWord8 s14 = 3 :: SWord8 s15 = 3 :: SWord8+This is the only solution.
SBVUnitTest/SBVUnitTest.hs view
@@ -12,7 +12,7 @@ module Main(main, createGolds) where -import Control.Monad (when)+import Control.Monad (unless, when) import System.Directory (doesDirectoryExist, findExecutable) import System.Environment (getArgs, getEnv) import System.Exit (exitWith, ExitCode(..))@@ -20,10 +20,15 @@ import System.Process (readProcessWithExitCode) import Test.HUnit (Test(..), Counts(..), runTestTT) +import Data.List (isPrefixOf) import Data.SBV (yices, SMTSolver(..)) import Data.SBV.Utils.SBVTest (SBVTestSuite(..), generateGoldCheck) import Paths_sbv (getDataDir) +import SBVUnitTest.SBVUnitTestBuildTime (buildTime)++import qualified Data.SBV.Provers.Yices as Yices+ -- To add a new collection of tests, import below and add to testCollection variable import qualified Data.SBV.TestSuite.Arrays.Memory as T01_01(testSuite) import qualified Data.SBV.TestSuite.Basics.Arithmetic as T02_01(testSuite)@@ -42,24 +47,26 @@ import qualified Data.SBV.TestSuite.CRC.USB5 as T04_05(testSuite) import qualified Data.SBV.TestSuite.CodeGeneration.AddSub as T05_01(testSuite) import qualified Data.SBV.TestSuite.CodeGeneration.CgTests as T05_02(testSuite)-import qualified Data.SBV.TestSuite.CodeGeneration.Fibonacci as T05_03(testSuite)-import qualified Data.SBV.TestSuite.CodeGeneration.GCD as T05_04(testSuite)-import qualified Data.SBV.TestSuite.CodeGeneration.PopulationCount as T05_05(testSuite)+import qualified Data.SBV.TestSuite.CodeGeneration.CRC_USB5 as T05_03(testSuite)+import qualified Data.SBV.TestSuite.CodeGeneration.Fibonacci as T05_04(testSuite)+import qualified Data.SBV.TestSuite.CodeGeneration.GCD as T05_05(testSuite)+import qualified Data.SBV.TestSuite.CodeGeneration.PopulationCount as T05_06(testSuite) import qualified Data.SBV.TestSuite.Crypto.AES as T06_01(testSuite) import qualified Data.SBV.TestSuite.Crypto.RC4 as T06_02(testSuite)-import qualified Data.SBV.TestSuite.Polynomials.Polynomials as T07_01(testSuite)-import qualified Data.SBV.TestSuite.Puzzles.Counts as T08_01(testSuite)-import qualified Data.SBV.TestSuite.Puzzles.DogCatMouse as T08_02(testSuite)-import qualified Data.SBV.TestSuite.Puzzles.Euler185 as T08_03(testSuite)-import qualified Data.SBV.TestSuite.Puzzles.MagicSquare as T08_04(testSuite)-import qualified Data.SBV.TestSuite.Puzzles.NQueens as T08_05(testSuite)-import qualified Data.SBV.TestSuite.Puzzles.PowerSet as T08_06(testSuite)-import qualified Data.SBV.TestSuite.Puzzles.Sudoku as T08_07(testSuite)-import qualified Data.SBV.TestSuite.Puzzles.Temperature as T08_08(testSuite)-import qualified Data.SBV.TestSuite.Puzzles.U2Bridge as T08_09(testSuite)-import qualified Data.SBV.TestSuite.Uninterpreted.AUF as T09_01(testSuite)-import qualified Data.SBV.TestSuite.Uninterpreted.Function as T09_02(testSuite)-import qualified Data.SBV.TestSuite.Uninterpreted.Uninterpreted as T09_03(testSuite)+import qualified Data.SBV.TestSuite.Existentials.CRCPolynomial as T07_01(testSuite)+import qualified Data.SBV.TestSuite.Polynomials.Polynomials as T08_01(testSuite)+import qualified Data.SBV.TestSuite.Puzzles.Counts as T09_01(testSuite)+import qualified Data.SBV.TestSuite.Puzzles.DogCatMouse as T09_02(testSuite)+import qualified Data.SBV.TestSuite.Puzzles.Euler185 as T09_03(testSuite)+import qualified Data.SBV.TestSuite.Puzzles.MagicSquare as T09_04(testSuite)+import qualified Data.SBV.TestSuite.Puzzles.NQueens as T09_05(testSuite)+import qualified Data.SBV.TestSuite.Puzzles.PowerSet as T09_06(testSuite)+import qualified Data.SBV.TestSuite.Puzzles.Sudoku as T09_07(testSuite)+import qualified Data.SBV.TestSuite.Puzzles.Temperature as T09_08(testSuite)+import qualified Data.SBV.TestSuite.Puzzles.U2Bridge as T09_09(testSuite)+import qualified Data.SBV.TestSuite.Uninterpreted.AUF as T10_01(testSuite)+import qualified Data.SBV.TestSuite.Uninterpreted.Function as T10_02(testSuite)+import qualified Data.SBV.TestSuite.Uninterpreted.Uninterpreted as T10_03(testSuite) testCollection :: [(String, SBVTestSuite)] testCollection = [@@ -80,72 +87,85 @@ , ("usb5", T04_05.testSuite) , ("addSub", T05_01.testSuite) , ("cgtest", T05_02.testSuite)- , ("fib", T05_03.testSuite)- , ("gcd", T05_04.testSuite)- , ("popCount", T05_05.testSuite)+ , ("cgUSB5", T05_03.testSuite)+ , ("fib", T05_04.testSuite)+ , ("gcd", T05_05.testSuite)+ , ("popCount", T05_06.testSuite) , ("aes", T06_01.testSuite) , ("rc4", T06_02.testSuite)- , ("poly", T07_01.testSuite)- , ("counts", T08_01.testSuite)- , ("dogCatMouse", T08_02.testSuite)- , ("euler185", T08_03.testSuite)- , ("magicSquare", T08_04.testSuite)- , ("nQueens", T08_05.testSuite)- , ("powerset", T08_06.testSuite)- , ("sudoku", T08_07.testSuite)- , ("temperature", T08_08.testSuite)- , ("u2bridge", T08_09.testSuite)- , ("auf1", T09_01.testSuite)- , ("auf2", T09_02.testSuite)- , ("unint", T09_03.testSuite)+ , ("existPoly", T07_01.testSuite)+ , ("poly", T08_01.testSuite)+ , ("counts", T09_01.testSuite)+ , ("dogCatMouse", T09_02.testSuite)+ , ("euler185", T09_03.testSuite)+ , ("magicSquare", T09_04.testSuite)+ , ("nQueens", T09_05.testSuite)+ , ("powerset", T09_06.testSuite)+ , ("sudoku", T09_07.testSuite)+ , ("temperature", T09_08.testSuite)+ , ("u2bridge", T09_09.testSuite)+ , ("auf1", T10_01.testSuite)+ , ("auf2", T10_02.testSuite)+ , ("unint", T10_03.testSuite) ] -- No user serviceable parts below.. main :: IO ()-main = do tgts <- getArgs- run tgts False []+main = do putStrLn $ "*** SBVUnitTester, built: " ++ buildTime+ tgts <- getArgs+ case tgts of+ [x] | x `elem` ["-h", "--help", "-?"]+ -> putStrLn "Usage: SBVUnitTests [-l] [targets]" -- Not quite right, but sufficient+ ["-l"] -> showTargets+ _ -> run tgts False [] createGolds :: String -> IO () createGolds tgts = run (words tgts) True ["SBVUnitTest/GoldFiles"] checkGoldDir :: FilePath -> IO () checkGoldDir gd = do e <- doesDirectoryExist gd- when (not e) $- do putStrLn $ "*** Cannot locate gold file repository!"- putStrLn $ "*** Please call with one argument, the directory name of the gold files."- putStrLn $ "*** Cannot run test cases, exiting."- exitWith $ ExitFailure 1+ unless e $ do putStrLn "*** Cannot locate gold file repository!"+ putStrLn "*** Please call with one argument, the directory name of the gold files."+ putStrLn "*** Cannot run test cases, exiting."+ exitWith $ ExitFailure 1 checkYices :: IO ()-checkYices = do ex <- getEnv "SBV_YICES" `catch` (\_ -> return (executable yices))+checkYices = do ex <- getEnv "SBV_YICES" `catch` (\_ -> return (executable Yices.yices)) mbP <- findExecutable ex case mbP of Nothing -> do putStrLn $ "*** Cannot find default SMT solver executable for " ++ nm putStrLn $ "*** Please make sure the executable " ++ show ex- putStrLn $ "*** is installed and is in your path."- putStrLn $ "*** Cannot run test cases, exiting."+ putStrLn "*** is installed and is in your path."+ putStrLn "*** Cannot run test cases, exiting." exitWith $ ExitFailure 1 Just p -> do putStrLn $ "*** Using solver : " ++ nm ++ " (" ++ show p ++ ")" checkYicesVersion p- where nm = name yices+ where nm = name Yices.yices checkYicesVersion :: FilePath -> IO () checkYicesVersion p = do (ec, yOut, _yErr) <- readProcessWithExitCode p ["-V"] "" case ec of- ExitFailure _ -> do putStrLn $ "*** Cannot determine Yices version. Please install Yices version 2.X first."+ ExitFailure _ -> do putStrLn "*** Cannot determine Yices version. Please install Yices version 2.X first." exitWith $ ExitFailure 1- ExitSuccess -> do let isYices1 = take 2 yOut == "1." -- crude test; might fail..- when isYices1 $ putStrLn $ "*** Yices version 1.X is detected. Version 2.X is strongly recommended!"- opts <- getEnv "SBV_YICES_OPTIONS" `catch` (\_ -> return (unwords (options yices)))+ ExitSuccess -> do let isYices1 = "1." `isPrefixOf` yOut -- crude test; might fail..+ when isYices1 $ putStrLn "*** Yices version 1.X is detected. Version 2.X is strongly recommended!"+ opts <- getEnv "SBV_YICES_OPTIONS" `catch` (\_ -> return (unwords (options Yices.yices))) when (isYices1 && opts /= "-tc -smt -e") $ do- putStrLn $ "*** Either install Yices 2.X, or set the environment variable:"- putStrLn $ "*** SBV_YICES_OPTIONS=\"-tc -smt -e\""- putStrLn $ "*** To use Yices 1.X with SBV."- putStrLn $ "*** However, upgrading to Yices 2.X is highly recommended!"+ putStrLn "*** Either install Yices 2.X, or set the environment variable:"+ putStrLn "*** SBV_YICES_OPTIONS=\"-tc -smt -e\""+ putStrLn "*** To use Yices 1.X with SBV."+ putStrLn "*** However, upgrading to Yices 2.X is highly recommended!" exitWith $ ExitFailure 1 +allTargets :: [String]+allTargets = map fst testCollection++showTargets :: IO ()+showTargets = do putStrLn "Known test targets are:"+ mapM_ (putStrLn . ("\t" ++)) allTargets+ run :: [String] -> Bool -> [String] -> IO () run targets shouldCreate [gd] = do mapM_ checkTgt targets@@ -159,7 +179,6 @@ checkTgt t | t `elem` allTargets = return () | True = do putStrLn $ "*** Unknown test target: " ++ show t exitWith $ ExitFailure 1- allTargets = map fst testCollection run targets shouldCreate [] = getDataDir >>= \d -> run targets shouldCreate [d </> "SBVUnitTest" </> "GoldFiles"] run _ _ _ = error "SBVUnitTests.run: impossible happened!" @@ -168,9 +187,9 @@ when (c /= t) $ putStrLn $ "*** Not all test cases were tried. (Only tested " ++ show t ++ " of " ++ show c ++ ")" when (e /= 0) $ putStrLn $ "*** " ++ show e ++ " (of " ++ show c ++ ") test cases in error." when (f /= 0) $ putStrLn $ "*** " ++ show f ++ " (of " ++ show c ++ ") test cases failed."- if (c == t && e == 0 && f == 0)+ if c == t && e == 0 && f == 0 then do if shouldCreate then putStrLn $ "All " ++ show c ++ " test cases executed in gold-file generation mode." else putStrLn $ "All " ++ show c ++ " test cases successfully passed."- exitWith $ ExitSuccess+ exitWith ExitSuccess else exitWith $ ExitFailure 2
+ SBVUnitTest/SBVUnitTestBuildTime.hs view
@@ -0,0 +1,5 @@+-- Auto-generated, don't edit+module SBVUnitTest.SBVUnitTestBuildTime (buildTime) where++buildTime :: String+buildTime = "Sun Nov 13 11:20:47 PST 2011"
Setup.hs view
@@ -17,7 +17,8 @@ import System.Directory (findExecutable) import System.Exit (exitWith, ExitCode(..)) -import Data.SBV.Provers.Prover (SMTSolver(..), yices)+import Data.SBV.Provers.Prover (SMTSolver(..))+import Data.SBV.Provers.Yices (yices) main :: IO () main = defaultMainWithHooks simpleUserHooks{ postInst = checkDefSolver }
sbv.cabal view
@@ -1,5 +1,5 @@ Name: sbv-Version: 0.9.21+Version: 0.9.22 Category: Formal Methods, Theorem Provers, Bit vectors, Symbolic Computation, Math Synopsis: Symbolic bit vectors: Bit-precise verification and automatic C-code generation. Description: Express properties about bit-precise Haskell programs and automatically prove@@ -37,8 +37,10 @@ . * proven correct via an external SMT solver (the 'prove' function) .- * checked for satisfiability (the 'sat' and 'allSat' functions)+ * checked for satisfiability (the 'sat', 'allSat', and 'qbvf' functions) .+ * used in synthesis (the 'qbvf' function)+ . * quick-checked . The SBV library can also compile Haskell functions that manipulate symbolic@@ -53,7 +55,7 @@ . The following people reported bugs, provided comments/feedback, or contributed to the development of SBV in various ways: Ian Blumenfeld, Ian Calvert, Iavor Diatchki,- Lee Pike, Austin Seipp, Don Stewart, Josef Svenningsson, and Nis Wegmann.+ Tom Hawkins, Lee Pike, Austin Seipp, Don Stewart, Josef Svenningsson, and Nis Wegmann. Copyright: Levent Erkok, 2010-2011 License: BSD3@@ -95,11 +97,13 @@ , Data.SBV.Examples.BitPrecise.Legato , Data.SBV.Examples.BitPrecise.PrefixSum , Data.SBV.Examples.CodeGeneration.AddSub+ , Data.SBV.Examples.CodeGeneration.CRC_USB5 , Data.SBV.Examples.CodeGeneration.Fibonacci , Data.SBV.Examples.CodeGeneration.GCD , Data.SBV.Examples.CodeGeneration.PopulationCount , Data.SBV.Examples.Crypto.AES , Data.SBV.Examples.Crypto.RC4+ , Data.SBV.Examples.Existentials.CRCPolynomial , Data.SBV.Examples.Polynomials.Polynomials , Data.SBV.Examples.Puzzles.Counts , Data.SBV.Examples.Puzzles.DogCatMouse@@ -121,9 +125,12 @@ , Data.SBV.Compilers.CodeGen , Data.SBV.SMT.SMT , Data.SBV.SMT.SMTLib+ , Data.SBV.SMT.SMTLib1+ , Data.SBV.SMT.SMTLib2 , Data.SBV.Provers.Prover , Data.SBV.Provers.SExpr , Data.SBV.Provers.Yices+ , Data.SBV.Provers.Z3 , Data.SBV.Utils.Boolean , Data.SBV.Utils.TDiff , Data.SBV.Utils.SBVTest@@ -154,11 +161,13 @@ , Data.SBV.TestSuite.BitPrecise.PrefixSum , Data.SBV.TestSuite.CodeGeneration.AddSub , Data.SBV.TestSuite.CodeGeneration.CgTests+ , Data.SBV.TestSuite.CodeGeneration.CRC_USB5 , Data.SBV.TestSuite.CodeGeneration.Fibonacci , Data.SBV.TestSuite.CodeGeneration.GCD , Data.SBV.TestSuite.CodeGeneration.PopulationCount , Data.SBV.TestSuite.Crypto.AES , Data.SBV.TestSuite.Crypto.RC4+ , Data.SBV.TestSuite.Existentials.CRCPolynomial , Data.SBV.TestSuite.CRC.CCITT , Data.SBV.TestSuite.CRC.CCITT_Unidir , Data.SBV.TestSuite.CRC.GenPoly@@ -180,3 +189,4 @@ Executable SBVUnitTests main-is : SBVUnitTest/SBVUnitTest.hs+ Other-modules : SBVUnitTest.SBVUnitTestBuildTime