diff --git a/.gitattributes b/.gitattributes
index 3cf319f25..584961e8b 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2,7 +2,6 @@
# in statistics about this repo
#
src/Parsec/** linguist-vendored
-src/vendor/stp/src/** linguist-vendored
testsuite/** linguist-vendored
doc/** linguist-documentation
diff --git a/.github/workflows/build-and-test-macos.yml b/.github/workflows/build-and-test-macos.yml
index 3130c3674..1ac06b4ef 100644
--- a/.github/workflows/build-and-test-macos.yml
+++ b/.github/workflows/build-and-test-macos.yml
@@ -101,7 +101,7 @@ jobs:
popd
# Check that .ghci has all the right flags to load the source.
# This is important for text editor integration & tools like ghcid
- # NB stp, yices and htcl must be built first, so do this after Build.
+ # NB yices and htcl must be built first, so do this after Build.
- name: Check GHCI :load
run: |
cd src/comp
diff --git a/.github/workflows/build-and-test-ubuntu.yml b/.github/workflows/build-and-test-ubuntu.yml
index c1092dff1..b6fcba699 100644
--- a/.github/workflows/build-and-test-ubuntu.yml
+++ b/.github/workflows/build-and-test-ubuntu.yml
@@ -86,7 +86,7 @@ jobs:
popd
# Check that .ghci has all the right flags to load the source.
# This is important for text editor integration & tools like ghcid
- # NB stp, yices and htcl must be built first, so do this after Build.
+ # NB yices and htcl must be built first, so do this after Build.
- name: Check GHCI :load
run: |
cd src/comp
diff --git a/COPYING b/COPYING
index 9f4ba0def..0ef403df8 100644
--- a/COPYING
+++ b/COPYING
@@ -3,15 +3,6 @@ under the BSD-3-Clause license, as indicated at the end of this file.
Individual files or directories may specify their own copyright and
license. The following are known to have other authors and licenses:
-* STP - Constraint solver
- * The files in src/vendor/stp/src/ are adapted from a snapshot of STP
- * See LICENSES/LICENSE.stp and LICENSES/LICENSE.stp_components
- * The source and license were obtained from the SVN repository [1]
- at revision 1643 on 2012-04-18. A patch at [2] obtained on
- 2014-04-21 was also applied.
- [1] https://stp-fast-prover.svn.sourceforge.net/svnroot/stp-fast-prover/trunk/stp
- [2] https://github.com/stp/stp/commit/ece1a55fb367bd905078baca38476e35b4df06c3
-
* The Yices SMT Solver
* The files in src/vendor/yices/ define a Haskell interface for using
the Yices library (via its C API); there is also code for a
diff --git a/INSTALL.md b/INSTALL.md
index cac6ca94d..10128c5bb 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -147,18 +147,6 @@ library to compile:
autoconf \
gperf
-Building the BSC tools will also recurse into a directory for the STP SMT
-solver. This is currently an old snapshot of the STP source code, including the
-code for various libraries that it uses. In the future, this may be replaced
-with a submodule instantiation of the repository for [the STP SMT
-solver](https://github.com/stp/stp). When that happens, additional requirements
-from that repository will be added.
-Building the STP library is optional (see below).
-The current snapshot requires Perl, to
-generate two source files. It also needs flex and bison:
-
- $ apt-get install flex bison
-
The `check-smoke` target runs a test using an external Verilog simulator, which is
[Icarus Verilog] by default. You can install Icarus on Debian/Ubuntu with:
@@ -226,29 +214,6 @@ compile in parallel, define `GHCJOBS` in the environment to that number:
$ make GHCJOBS=4
-### Optionally avoiding the compile of STP or Yices
-
-The BSC tools expect to dynamically link with specific versions of STP and Yices,
-found in `inst/lib/SAT/`. By default, the build process will compile both
-libraries and install them in that directory. However, the BSC tools only need
-one SMT solver; Yices is used by default, and STP can be selected via a flag.
-Most users will never need to switch solvers, or even be aware of the option.
-Thus, the build process offers the option of not compiling the STP library,
-and instead installing a stub file, that the BSC tools will recognize and will
-not allow the user to select that solver. This option is chosen by assigning
-a non-empty value to `STP_STUB`:
-
- $ make STP_STUB=1
-
-This can be used if STP does not build on your system or if you want to avoid
-the work of building the library. A similar `YICES_STUB` option exists, for
-skipping the build of the Yices library:
-
- $ make YICES_STUB=1
-
-The BSC tools do need at least one SMT solver, so only one of these options
-should be used.
-
## Test the BSC toolchain
The following command will run a smoke test to ensure the compiler and
diff --git a/LICENSES/LICENSE.stp b/LICENSES/LICENSE.stp
deleted file mode 100644
index 0891de8fb..000000000
--- a/LICENSES/LICENSE.stp
+++ /dev/null
@@ -1,30 +0,0 @@
-/********************************************************************
- * PROGRAM NAME: STP (Simple Theorem Prover)
- *
- * AUTHORS: Vijay Ganesh
- *
- * BEGIN DATE: November, 2005
- ********************************************************************/
-
-The MIT License
-
-Copyright (c) 2008 Vijay Ganesh
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/LICENSES/LICENSE.stp_components b/LICENSES/LICENSE.stp_components
deleted file mode 100644
index 6d3ba5559..000000000
--- a/LICENSES/LICENSE.stp_components
+++ /dev/null
@@ -1,174 +0,0 @@
-STP links to copyrighted librarys:
- * Minisat Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson.
- * Bit::Vector Copyright (c) 1995 - 2004 by Steffen Beyer.
- * CVC's SMT-LIB Parser Copyright (C) 2004 by the Board of Trustees of Leland Stanford Junior University and by New York University.
- * CryptoMinisat Copyright (c) 2009 Mate Soos
- * ocaml-wrapper Copyright BitBlaze, 2007. All rights reserved.
- * ABC by Alan Mishchenko
- * Boost by various: http://www.boost.org/
-
-MINISAT
- /****************************************************************************************
- MiniSat -- Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
- associated documentation files (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge, publish, distribute,
- sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all copies or
- substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
- NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
- OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- **************************************************************************************************/
-
-Bit::Vector
- /*****************************************************************************/
- /* LICENSE: */
- /*****************************************************************************/
- /* */
- /* This library is free software; you can redistribute it and/or */
- /* modify it under the terms of the GNU Library General Public */
- /* License as published by the Free Software Foundation; either */
- /* version 2 of the License, || (at your option) any later version. */
- /* */
- /* This library is distributed in the hope that it will be useful, */
- /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
- /* MERCHANTABILITY || FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
- /* Library General Public License for more details. */
- /* */
- /* You should have received a copy of the GNU Library General Public */
- /* License along with this library; if not, write to the */
- /* Free Software Foundation, Inc., */
- /* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
- /* */
- /* || download a copy from ftp://ftp.gnu.org/pub/gnu/COPYING.LIB-2.0 */
- /* */
- /*****************************************************************************/
-
-CVC's SMT-LIB Parser
- /********************************************************************
- *
- * \file smtlib.y
- *
- * Author: Sergey Berezin, Clark Barrett
- *
- * Created: Apr 30 2005
- *
- *
- * Copyright (C) 2004 by the Board of Trustees of Leland Stanford
- * Junior University and by New York University.
- *
- * License to use, copy, modify, sell and/or distribute this software
- * and its documentation for any purpose is hereby granted without
- * royalty, subject to the terms and conditions defined in the \ref
- * LICENSE file provided with this distribution. In particular:
- *
- * - The above copyright notice and this permission notice must appear
- * in all copies of the software and related documentation.
- *
- * - THE SOFTWARE IS PROVIDED "AS-IS", WITHOUT ANY WARRANTIES,
- * EXPRESSED OR IMPLIED. USE IT AT YOUR OWN RISK.
- *
- *
- ********************************************************************/
-
-Cryptominisat
- CryptoMiniSat -- Copyright (c) 2009 Mate Soos
-
- Permission is hereby granted, free of charge, to any person obtaining a
- copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
-ocaml-wrapper
- //////////////////////////////////////////////////////////
- //
- // Owned and copyright BitBlaze, 2007. All rights reserved.
- //
- //////////////////////////////////////////////////////////
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-ABC
- Copyright (c) The Regents of the University of California. All rights reserved.
-
- Permission is hereby granted, without written agreement and without license or
- royalty fees, to use, copy, modify, and distribute this software and its
- documentation for any purpose, provided that the above copyright notice and
- the following two paragraphs appear in all copies of this software.
-
- IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
- DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
- THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
- CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
- AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
- SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-
-
-
-Boost
- Boost Software License - Version 1.0 - August 17th, 2003
-
- Permission is hereby granted, free of charge, to any person or organization
- obtaining a copy of the software and accompanying documentation covered by
- this license (the "Software") to use, reproduce, display, distribute,
- execute, and transmit the Software, and to prepare derivative works of the
- Software, and to permit third-parties to whom the Software is furnished to
- do so, all subject to the following:
-
- The copyright notices in the Software and this entire statement, including
- the above license grant, this restriction and the following disclaimer,
- must be included in all copies of the Software, in whole or in part, and
- all derivative works of the Software, unless such copies or derivative
- works are solely in the form of machine-executable object code generated by
- a source language processor.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
- SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
- FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
diff --git a/doc/user_guide/user_guide.tex b/doc/user_guide/user_guide.tex
index 8856057c0..149a42e02 100644
--- a/doc/user_guide/user_guide.tex
+++ b/doc/user_guide/user_guide.tex
@@ -2171,7 +2171,6 @@ \subsection{Compiler optimizations}
\label{flag-optundeterminedvals}
\begin{centerboxverbatim}
-opt-undetermined-vals aggressive optimization of undetermined values
--sat-stp use STP SMT for disjoint testing and SAT
-sat-yices use Yices SMT for disjoint testing and SAT
\end{centerboxverbatim}
@@ -2191,7 +2190,6 @@ \subsection{Compiler optimizations}
flag on may produce better hardware in Verilog, but can result in the
Bluesim and Verilog simulations producing different intermediate values.
-\index{-sat-stp@\te{-sat-stp} (compiler flag)}
\index{-sat-yices@\te{-sat-yices} (compiler flag)}
It is possible to change the underlying proof engine used by the
compiler. You should not use these flags
diff --git a/release/Makefile b/release/Makefile
index d4ff31457..1bad758bf 100644
--- a/release/Makefile
+++ b/release/Makefile
@@ -26,8 +26,6 @@ LICFILES = $(addprefix $(LICDIR)/, \
LICENSE.ghc \
LICENSE.hbc \
LICENSE.parsec \
- LICENSE.stp \
- LICENSE.stp_components \
LICENSE.yices \
LICENSE.yices-painless \
)
diff --git a/release/tarball-COPYING b/release/tarball-COPYING
index 5c4998fda..b6a4f1833 100644
--- a/release/tarball-COPYING
+++ b/release/tarball-COPYING
@@ -11,12 +11,8 @@ indicated in the files themselves. If not otherwise specified, they
are copyright Bluespec Inc and licensed under the BSD-3-Clause
license, as indicated at the end of this file.
-The library objects in the SAT directory, for STP and Yices, are
-licensed and copyright as follows:
-
-* STP - Constraint solver
- * The library is built from an adapted snapshot of STP
- * See LICENSES/LICENSE.stp and LICENSES/LICENSE.stp_components
+The library objects in the SAT directory for Yices are licensed
+and copyright as follows:
* The Yices SMT Solver
* The library is built from the Yices GitHub repository
@@ -28,10 +24,6 @@ under the BSD-3-Clause license, as indicated at the end of this file.
They are also built with the following code or APIs with their own
copyright and licensing:
-* STP - Constraint solver
- * BSC tools are linked with the library
- * See LICENSES/LICENSE.stp
-
* The Yices SMT Solver
* BSC tools are linked with the library
* See LICENSES/LICENSE.yices
diff --git a/src/Makefile b/src/Makefile
index 13b36104b..bf3869540 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -9,12 +9,10 @@ ifndef NO_DEPS_CHECKS
CC_TOOLS=$(CC) $(CXX) $(LD)
BSC_TOOLS=ghc ghc-pkg
YICES_TOOLS=gperf autoconf
-STP_TOOLS=flex bison
TOOLS=$(CC_TOOLS) \
$(BSC_TOOLS) \
- $(YICES_TOOLS) \
- $(STP_TOOLS) \
+ $(YICES_TOOLS)
GHC_PKGS=regex-compat syb old-time split
@@ -54,7 +52,6 @@ all: install
.PHONY: install clean full_clean
install clean full_clean:
- $(MAKE) -C vendor/stp PREFIX=$(PREFIX) $@
$(MAKE) -C vendor/yices PREFIX=$(PREFIX) $@
$(MAKE) -C vendor/htcl PREFIX=$(PREFIX) $@
# we need to build targets from here sequentially, as they operate in the same workspace
@@ -68,4 +65,3 @@ install clean full_clean:
$(MAKE) -C bluetcl PREFIX=$(PREFIX) $@
$(MAKE) -C bluesim PREFIX=$(PREFIX) $@
$(MAKE) -C Verilator PREFIX=$(PREFIX) $@
-
diff --git a/src/comp/.ghci b/src/comp/.ghci
index c8edd0a8f..28cb976bd 100644
--- a/src/comp/.ghci
+++ b/src/comp/.ghci
@@ -23,7 +23,6 @@
:set -i../comp:../comp/Libs:../comp/GHC:../comp/GHC/posix:../Parsec
-- Shared libraries and FFI bindings
-:set -i../vendor/stp/include_hs
:set -i../vendor/yices/include_hs
:set -i../vendor/htcl
@@ -31,9 +30,6 @@
:set -L../vendor/htcl
:set -lhtcl
-:set -L../vendor/stp/lib
-:set -lstp
-
:set -L../vendor/yices/lib
:set -lyices
diff --git a/src/comp/AExpr2STP.hs b/src/comp/AExpr2STP.hs
deleted file mode 100644
index ce45f26cd..000000000
--- a/src/comp/AExpr2STP.hs
+++ /dev/null
@@ -1,986 +0,0 @@
-module AExpr2STP(
- SState,
- initSState,
- addADefToSState,
-
- checkDisjointExpr,
- checkDisjointRulePair,
-
- checkBiImplication,
- isConstExpr,
- checkEq,
- checkNotEq
-) where
-
-import Control.Monad(when)
-import Control.Monad.State(StateT, runStateT, liftIO,
- gets, get, put, modify)
-import qualified Data.Map as M
-import qualified STP as S
-
-import Data.Maybe(fromMaybe)
-
-import ErrorUtil(internalError)
-import Flags
-import Id(getIdBaseString, dummy_id)
-import Prim
-import IntLit
-import ASyntax
-import ASyntaxUtil(aAnds)
-import VModInfo(VModInfo)
-import PFPrint
-import Util(itos, map_insertMany, makePairs)
-import TopUtils(withElapsed)
-
-import AExpr2Util(getMethodOutputPort)
-
-import Debug.Trace(traceM)
-import IOUtil(progArgs)
-
-traceTest :: Bool
-traceTest = "-trace-smt-test" `elem` progArgs
-
-traceConv :: Bool
-traceConv = "-trace-smt-conv" `elem` progArgs
-
--- -------------------------
-
-initSState :: String -> Flags -> Bool ->
- [ADef] -> [AVInst] -> [RuleTriple] -> IO SState
-initSState str flags doHardFail ds avis rs = do
- ctx <- S.mkContext
- falseE <- S.mkFalse ctx
- return (SState { context = ctx,
- --flags = flags,
- hardFail = doHardFail,
-
- defMap = M.fromList [(i,d) | d@(ADef i _ _ _) <- ds],
- ruleMap = M.fromList [(i,r) | r@(i,_,_) <- rs],
- stateMap = M.fromList [(avi_vname avi, avi_vmi avi)
- | avi <- avis],
- proofMap = M.empty,
- proofMapS = M.empty,
-
- anyId = 0,
- unknownId = 0,
-
- falseExpr = falseE,
-
- defSExprMap = M.empty,
- portSExprMap = M.empty,
- expSExprMap = M.empty
- })
-
-
-addADefToSState :: SState -> [ADef] -> IO SState
-addADefToSState s ds = do
- let defmap = defMap s
- defmap' = map_insertMany [(id, d) | d@(ADef id _ _ _) <- ds] defmap
- return (s { defMap = defmap' })
-
-withTraceTest :: PPrint a => SM a -> SM a
-withTraceTest m =
- if traceTest
- then withElapsed $ do
- res <- m
- liftIO $ putStr ("result: " ++ ppReadable res)
- return res
- else m
-
--- -------------------------
-
-checkDisjointExpr :: SState -> AExpr -> AExpr -> IO (Maybe Bool, SState)
-checkDisjointExpr s e1 e2 = runStateT (checkDisjointExprM e1 e2) s
-
-checkDisjointExprM :: AExpr -> AExpr -> SM (Maybe Bool)
-checkDisjointExprM e1 e2 = withTraceTest $ do
-
- when traceTest $ traceM("comparing exprs: " ++ ppString (e1, e2))
- when traceConv $ traceM(" e1 = " ++ show e1)
- when traceConv $ traceM(" e2 = " ++ show e2)
-
- let doProof = do
- ctx <- gets context
- liftIO $ S.ctxPush ctx
- --
- (ye1, _) <- convAExpr2SExpr_Force True e1
- --when traceTest $ traceM("conv1 done")
- (ye2, _) <- convAExpr2SExpr_Force True e2
- --when traceTest $ traceM("conv2 done")
-
- liftIO $ S.assert ctx ye1
- liftIO $ S.assert ctx ye2
-
- yf <- gets falseExpr
- sat_res <- liftIO $ S.query ctx yf
- liftIO $ S.ctxPop ctx
- --
- addToProofMap e1 e2 sat_res
- return sat_res
-
- memRes <- lookupProofMap e1 e2
- sat_res <- case memRes of
- Just r -> return r
- Nothing -> doProof
-
- -- if query(False) is Valid, then there is an inconsistency
- -- when both "e1" and "e2" are asserted, so they are ME
- return $ case (sat_res) of
- S.Invalid -> Just False
- S.Valid -> Just True
- S.Timeout -> Nothing
- S.Error -> internalError ("STP query error")
-
-checkDisjointRulePair :: SState -> (ARuleId, ARuleId) -> IO (Maybe Bool, SState)
-checkDisjointRulePair s rp = runStateT (checkDisjointRulePairM rp) s
-
-checkDisjointRulePairM :: (ARuleId, ARuleId) -> SM (Maybe Bool)
-checkDisjointRulePairM (r1, r2) = do
- when traceTest $ traceM("comparing rules: " ++ ppString (r1,r2))
- c1 <- getRuleCond r1
- c2 <- getRuleCond r2
- checkDisjointExprM c1 c2
-
-getRuleCond :: ARuleId -> SM AExpr
-getRuleCond rid = do
- rulemap <- gets ruleMap
- case (M.lookup rid rulemap) of
- Just (_, cond, _) -> return (aAnds cond)
- Nothing -> internalError ("getRuleCond: cannot find rule: " ++
- ppReadable rid)
-
--- -------------------------
-
-checkBiImplication :: SState -> AExpr -> AExpr -> IO ((Bool, Bool), SState)
-checkBiImplication s e1 e2 = runStateT (checkBiImplicationM e1 e2) s
-
-checkBiImplicationM :: AExpr -> AExpr -> SM (Bool, Bool)
-checkBiImplicationM e1 e2 = withTraceTest $ do
-
- when traceTest $ traceM("checking bi-implication: " ++ ppString (e1, e2))
- when traceConv $ traceM(" e1 = " ++ show e1)
- when traceConv $ traceM(" e2 = " ++ show e2)
- (ye1, _) <- convAExpr2SExpr_Force True e1
- when traceTest $ traceM("conv1 done")
- (ye2, _) <- convAExpr2SExpr_Force True e2
- --when traceTest $ traceM("conv2 done")
- e1_implies_e2 <- checkImplication ye1 ye2
- when traceTest $ traceM("e1_implies_e2")
- e2_implies_e1 <- checkImplication ye2 ye1
- when traceTest $ traceM("e2_implies_e1")
- return $ (e1_implies_e2, e2_implies_e1)
-
-checkImplication :: S.Expr -> S.Expr -> SM Bool
-{-
--- STP has a built in implication operator, so use it instead of this
-checkImplication ye1 ye2 = do
- ctx <- gets context
- -- If (!a || b) is True, then a implies b
- not_ye1 <- liftIO $ S.mkNot ctx ye1
- yor <- liftIO $ S.mkOr ctx not_ye1 ye2
- when traceTest $ traceM("checking if implication is true")
- isTrueSExpr yor >>= return . fromMaybe False
--}
-checkImplication ye1 ye2 = do
- ctx <- gets context
- yimp <- liftIO $ S.mkImplies ctx ye1 ye2
- when traceTest $ traceM("checking if implication is true")
- isTrueSExpr yimp >>= return . fromMaybe False
-
-isConstExpr :: SState -> AExpr -> IO (Maybe Bool, SState)
-isConstExpr s e = runStateT (isConstExprM e) s
-
-isConstExprM :: AExpr -> SM (Maybe Bool)
-isConstExprM e = withTraceTest $ do
-
- when traceTest $ traceM("checking is-constant: " ++ ppString e)
- when traceConv $ traceM(" e = " ++ show e)
- (ye, _) <- convAExpr2SExpr_Force True e
- isConstSExpr ye
-
-isConstSExpr :: S.Expr -> SM (Maybe Bool)
-isConstSExpr ye = do
- is_true <- isTrueSExpr ye
- case (is_true) of
- Just True -> return $ Just True
- otherwise -> do is_false <- isFalseSExpr ye
- case (is_false) of
- Just True -> return $ Just False
- otherwise -> return Nothing
-
-isTrueSExpr :: S.Expr -> SM (Maybe Bool)
-isTrueSExpr ye = do
- ctx <- gets context
- not_ye <- liftIO $ S.mkNot ctx ye
- isFalseSExpr not_ye
-
-isFalseSExpr :: S.Expr -> SM (Maybe Bool)
-isFalseSExpr ye = do
- let doProof = do
- ctx <- gets context
- liftIO $ S.ctxPush ctx
- liftIO $ S.assert ctx ye
- --
- yf <- gets falseExpr
- sat_res <- liftIO $ S.query ctx yf
- liftIO $ S.ctxPop ctx
- addToProofMapS ye sat_res
- return sat_res
-
- memRes <- lookupProofMapS ye
- sat_res <- case memRes of
- Just r -> return r
- Nothing -> doProof
-
- -- if query(False) is Valid, then there is an inconsistency,
- -- so the expression is False
- let res = case (sat_res) of
- S.Invalid -> Just False
- S.Valid -> Just True
- S.Timeout -> Nothing
- S.Error -> internalError ("STP query error")
- return res
-
-checkEq :: SState -> AExpr -> AExpr -> IO (Maybe Bool, SState)
-checkEq s e1 e2 = runStateT (checkEqM e1 e2) s
-
-checkNotEq :: SState -> AExpr -> AExpr -> IO (Maybe Bool, SState)
-checkNotEq s e1 e2 = runStateT (checkNotEqM e1 e2) s
-
-checkEqM :: AExpr -> AExpr -> SM (Maybe Bool)
-checkEqM e1 e2 = withTraceTest $ do
-
- when traceTest $ traceM("checking eq: " ++ ppString (e1,e2))
- when traceConv $ traceM(" e1 = " ++ show e1)
- when traceConv $ traceM(" e2 = " ++ show e2)
- -- force the exprs to be of the same type
- (y_e1, ty_e1) <- convAExpr2SExpr Nothing e1
- --when traceTest $ traceM("conv1 done")
- (y_e2, _) <- convAExpr2SExpr (Just ty_e1) e2 >>= convType (Just ty_e1)
- --when traceTest $ traceM("conv2 done")
- ctx <- gets context
-
- -- mkEq segfaults on Bool inputs, so use iff
- let eqFn = if (ty_e1 == SBool) then S.mkIff else S.mkEq
- yeq <- liftIO $ eqFn ctx y_e1 y_e2
-
- isTrueSExpr yeq
-
-
-checkNotEqM :: AExpr -> AExpr -> SM (Maybe Bool)
-checkNotEqM e1 e2 = withTraceTest $ do
-
- when traceTest $ traceM("checking not eq: " ++ ppString (e1,e2))
- when traceConv $ traceM(" e1 = " ++ show e1)
- when traceConv $ traceM(" e2 = " ++ show e2)
- -- force the exprs to be of the same type
- (y_e1, ty_e1) <- convAExpr2SExpr Nothing e1
- --when traceTest $ traceM("conv1 done")
- (y_e2, _) <- convAExpr2SExpr (Just ty_e1) e2 >>= convType (Just ty_e1)
- --when traceTest $ traceM("conv2 done")
- ctx <- gets context
-
- -- mkEq segfaults on Bool inputs, so use iff
- let eqFn = if (ty_e1 == SBool) then S.mkIff else S.mkEq
- yeq <- liftIO $ eqFn ctx y_e1 y_e2
-
- isFalseSExpr yeq
-
-
--- -------------------------
-
-data SState =
- SState {
- context :: S.Context,
- --flags :: Flags,
- hardFail :: Bool,
-
- defMap :: M.Map AId ADef,
- ruleMap :: M.Map ARuleId RuleTriple,
- stateMap :: M.Map AId VModInfo,
- proofMap :: M.Map (AExpr, AExpr) S.Result,
- proofMapS :: M.Map S.Expr S.Result,
-
- anyId :: Integer,
- unknownId :: Integer,
-
- falseExpr :: S.Expr,
-
- defSExprMap :: M.Map AId (S.Expr, SType),
- portSExprMap :: M.Map AId (S.Expr, SType),
- -- for expressions which we treat as variables
- expSExprMap :: M.Map AExpr (S.Expr, SType)
- }
-
-type SM = StateT SState IO
-
-type RuleTriple = (ARuleId, [AExpr], Maybe ARuleId)
-
--- AExpr has no separate Bool type, and instead uses Bit#(1),
--- while STP requires a conversion between the two.
--- So we have to keep track of types, to insert conversion when necessary.
-data SType = SBits Integer | SBool deriving (Show, Eq)
-
-instance PPrint SType where
- pPrint d p t = text (show t)
-
-
--- -------------------------
-
--- Use these functions to make sure that info is added to the most recent maps.
--- If you have a local copy of the map around, but then call monadic functions,
--- the local copy may become stale, and you'll lose info if you write back the
--- stale copy.
-
-addToExpMap :: AExpr -> (S.Expr, SType) -> SM ()
-addToExpMap e res = do
- s <- get
- let emap = expSExprMap s
- emap' = M.insert e res emap
- put (s { expSExprMap = emap' })
-
-addToDefMap :: AId -> (S.Expr, SType) -> SM ()
-addToDefMap d res = do
- s <- get
- let dmap = defSExprMap s
- dmap' = M.insert d res dmap
- put (s { defSExprMap = dmap' })
-
-addToPortMap :: AId -> (S.Expr, SType) -> SM ()
-addToPortMap p res = do
- s <- get
- let pmap = portSExprMap s
- pmap' = M.insert p res pmap
- put (s { portSExprMap = pmap' })
-
-addToProofMap :: AExpr -> AExpr -> S.Result -> SM()
-addToProofMap e1 e2 res = do
- rmap <- gets proofMap
- -- insert both orderings for expressions
- let rmap1 = M.insert (e1,e2) res rmap
- rmapX = M.insert (e2,e1) res rmap1
- modify (\s -> s {proofMap = rmapX})
-
-lookupProofMap :: AExpr -> AExpr -> SM (Maybe S.Result)
-lookupProofMap e1 e2 = do
- rmap <- gets proofMap
- return $ M.lookup (e1,e2) rmap
-
-addToProofMapS :: S.Expr -> S.Result -> SM()
-addToProofMapS e1 res = do
- rmap <- gets proofMapS
- let rmapX = M.insert e1 res rmap
- modify (\s -> s {proofMapS = rmapX})
-
-lookupProofMapS :: S.Expr -> SM (Maybe S.Result)
-lookupProofMapS e1 = do
- rmap <- gets proofMapS
- return $ M.lookup e1 rmap
-
--- -------------------------
-
-getAnyName :: SM String
-getAnyName = do
- s <- get
- let n = anyId s
- -- XXX we need to check for name clash with the defs, ports, etc
- let str = "__any_" ++ itos n
- put (s { anyId = n + 1 })
- return str
-
-getUnknownName :: SM String
-getUnknownName = do
- s <- get
- let n = unknownId s
- -- XXX we need to check for name clash
- let str = "__unknown_" ++ itos n
- put (s { unknownId = n + 1})
- return str
-
-{-
-assertDef :: AId -> (S.Expr, SType) -> SM (S.Expr, SType)
-assertDef i (y_e, ty_e) = do
- ctx <- gets context
- let width = case ty_e of { SBool -> 1; SBits w -> w }
- -- XXX we need to check for name clash
- let str = "__def_" ++ ppString i
- var@(y_var, _) <- makeDeclAndVar (Just ty_e) str width
- yeq <- liftIO $ S.mkEq ctx y_var y_e
- liftIO $ S.assert ctx yeq
- return var
--}
-
-makeDeclAndVar :: Maybe SType -> String -> Integer -> SM (S.Expr, SType)
--- If the context expects Bool, create a Bool variable
-makeDeclAndVar (Just SBool) str width = do
- when (width /= 1) $
- internalError ("makeDeclAndVar: invalid width: " ++ ppReadable width)
- ctx <- gets context
- ty <- liftIO $ S.mkBoolType ctx
- var <- liftIO $ S.mkVar ctx str ty
- return (var, SBool)
-makeDeclAndVar _ str width = do
- ctx <- gets context
- ty <- liftIO $ S.mkBitVectorType ctx (fromInteger width)
- var <- liftIO $ S.mkVar ctx str ty
- return (var, SBits width)
-
-addUnknownExpr :: Maybe SType -> AExpr -> Integer -> SM (S.Expr, SType)
-addUnknownExpr mty e width = do
- when traceConv $ traceM("addUnknownExpr: " ++ ppString e)
- emap <- gets expSExprMap
- case (M.lookup e emap) of
- Just res -> do when traceConv $ traceM(" reusing.")
- return res
- Nothing -> do
- when traceConv $ traceM(" making new var.")
- str <- getUnknownName
- res <- makeDeclAndVar mty str width
- addToExpMap e res
- return res
-
-convType :: Maybe SType -> (S.Expr, SType) -> SM (S.Expr, SType)
-convType Nothing res = return res
-convType (Just (SBool)) res@(_, SBool) = return res
-convType (Just (SBits _)) res@(_, SBits _) = return res
-convType (Just (SBool)) (ye, SBits width) = do
- when traceConv $ traceM("converting Bits to Bool")
- when (width /= 1) $
- internalError ("convType: invalid width: " ++ ppReadable width)
- ctx <- gets context
- -- XXX Can this be memoized?
- yb <- liftIO $ S.mkBVConstantFromInteger ctx 1 1
- yeq <- liftIO $ S.mkEq ctx ye yb
- return (yeq, SBool)
-{-
- -- this built-in conversion might be better?
- yconv <- liftIO $ S.mkBVBoolExtract ctx 0 ye
- return (yconv, SBool)
--}
-convType (Just (SBits width)) (ye, SBool) = do
- when traceConv $ traceM("converting Bool to Bits")
- when (width /= 1) $
- internalError ("convType: invalid width: " ++ ppReadable width)
- ctx <- gets context
- -- XXX Can this be memoized?
- yb1 <- liftIO $ S.mkBVConstantFromInteger ctx 1 1
- yb0 <- liftIO $ S.mkBVConstantFromInteger ctx 1 0
- yif <- liftIO $ S.mkIte ctx ye yb1 yb0
- return (yif, SBits width)
-{-
- -- STP has a built-in conversion function
- yconv <- liftIO $ S.mkBoolToBitVector ctx ye
- return (yconv, SBits width)
--}
-
-toBool :: (S.Expr, SType) -> SM (S.Expr, SType)
-toBool res@(_, SBool) = return res
-toBool res@(_, SBits 1) = convType (Just SBool) res
-toBool res@(_, SBits n) = internalError("toBool: wrong size: " ++ ppReadable n)
-
-toBits :: (S.Expr, SType) -> SM (S.Expr, SType)
-toBits res@(_, SBits _) = return res
-toBits res = convType (Just (SBits 1)) res
-
--- This is needed because we pass an expected type that includes the width,
--- rather than just saying whether we expect Bits or Bool (with no size)
-getBitType :: AExpr -> SType
-getBitType e = case (ae_type e) of
- ATBit w -> SBits w
- t -> internalError ("getBitType: " ++ ppReadable t)
-
--- -------------------------
-
-convAExpr2SExpr :: Maybe SType -> AExpr -> SM (S.Expr, SType)
-
--- If the context expects Bool, create a Bool value
-convAExpr2SExpr (Just SBool) (ASInt _ (ATBit width) (IntLit _ _ ilValue)) = do
- when traceConv $ traceM("conv IntLit (Bool)" ++ itos ilValue)
- when (width /= 1) $
- internalError ("convAExpr2SExpr: invalid width: " ++ ppReadable width)
- ctx <- gets context
- ye <- liftIO $ if (ilValue == 0)
- then S.mkFalse ctx
- else if (ilValue == 1)
- then S.mkTrue ctx
- else internalError ("convAExpr2SExpr: invalid Bool" ++
- ppReadable ilValue)
- return (ye, SBool)
-convAExpr2SExpr _ (ASInt _ (ATBit width) (IntLit _ _ ilValue)) = do
- when traceConv $ traceM("conv IntLit " ++ itos ilValue)
- ctx <- gets context
- ye <- liftIO $ S.mkBVConstantFromInteger ctx width ilValue
- return (ye, SBits width)
-
-convAExpr2SExpr mty e@(ASDef (ATBit width) aid) = do
- when traceConv $ traceM("conv def " ++ ppString aid)
- ymap <- gets defSExprMap
- case (M.lookup aid ymap) of
- Just res -> do when traceConv $ traceM(" reusing.")
- return res
- Nothing -> do
- when traceConv $ traceM(" converting new.")
- dmap <- gets defMap
- case (M.lookup aid dmap) of
- Just (ADef { adef_expr = e' }) -> do
- when traceConv $ traceM(" e' = " ++ show e')
- -- Go ahead and give it the current context
- -- XXX This is just a heuristic
- res_e <- convAExpr2SExpr mty e'
-
-{- -- XXX This appears to hurt more than it helps
- -- assert it as a variable, to speed up the SMT solver
- def <- assertDef aid res_e
--}
- let def = res_e
-
- -- memoize the result
- addToDefMap aid def
- return def
- Nothing -> do
- doHardFail <- gets hardFail
- if (doHardFail)
- then internalError ("convAExpr2SExpr: missing def: " ++
- ppReadable aid)
- else addUnknownExpr mty e width
-
-convAExpr2SExpr mty (ASPort (ATBit width) aid) = do
- when traceConv $ traceM("conv port " ++ ppReadable aid)
- -- We could use "getVarDeclFromName" to see if a decl exists for this yet,
- -- but we avoid the foreign call (two calls!) and keep our own map
- ymap <- gets portSExprMap
- case (M.lookup aid ymap) of
- Just res -> do when traceConv $ traceM(" reusing.")
- return res
- Nothing -> do
- when traceConv $ traceM(" making new var.")
- let str = getIdBaseString aid
- -- Go ahead and give it the current context
- -- XXX This is just a heuristic
- res <- makeDeclAndVar mty str width
- addToPortMap aid res
- return res
-
-convAExpr2SExpr mty (ASParam t@(ATBit _) aid) =
- convAExpr2SExpr mty (ASPort t aid)
-
--- For ASAny, create an independent variable.
--- If it has a tagged value, don't use it! That's not part of the formal
--- meaning, it's an implementation optimization.
-convAExpr2SExpr mty (ASAny (ATBit width) _) = do
- when traceConv $ traceM("conv any")
- str <- getAnyName
- makeDeclAndVar mty str width
-
-convAExpr2SExpr mty (APrim i (ATBit width) p args) = do
- when traceConv $ traceM("conv prim " ++ ppString p)
- convPrim2SExpr mty p i width args
-
--- Method calls create independent variables, with given width
--- XXX Passing the current context is just a heuristic
--- XXX TODO: some methods calls may be mutex, such as FIFO.full and FIFO.empty
-convAExpr2SExpr mty (AMethCall ty@(ATBit width) modId methId args) = do
- -- get the actual port name, so that methods which share the same output port
- -- will appear logically equivalent
- smap <- gets stateMap
- let portId = getMethodOutputPort smap modId methId
- e = (AMethCall ty modId portId args)
- -- XXX This could be an unevaluated function, applied to converted arguments
- addUnknownExpr mty e width
-convAExpr2SExpr mty (AMethValue ty@(ATBit width) modId methId) = do
- -- get the actual port name, so that methods which share the same output port
- -- will appear logically equivalent
- smap <- gets stateMap
- let portId = getMethodOutputPort smap modId methId
- e = (AMethValue ty modId portId)
- -- XXX This could be an unevaluated function, applied to converted arguments
- addUnknownExpr mty e width
-
-convAExpr2SExpr mty e@(AMGate (ATBit 1) _ _) =
- -- Gates are used as Bool, so the current context should be SBool,
- -- but pass the current context just to be safe
- -- XXX Passing the current context is just a heuristic
- addUnknownExpr mty e 1
-
--- For these unknown types, be safe and create an independent variable vector
--- of the specified size.
--- XXX Passing the current context is just a heuristic
-convAExpr2SExpr mty e@(ASStr _ (ATString (Just width)) _ ) =
- addUnknownExpr mty e width
-convAExpr2SExpr mty e@(ANoInlineFunCall (ATBit width) _ _ _ ) =
- -- XXX This could be an unevaluated function, applied to converted arguments
- addUnknownExpr mty e width
-convAExpr2SExpr mty e@(AFunCall (ATBit width) _ _ _ _ ) =
- -- XXX This could be an unevaluated function, applied to converted arguments
- addUnknownExpr mty e width
-convAExpr2SExpr mty e@(ATaskValue (ATBit width) _ _ _ _) =
- addUnknownExpr mty e width
-
--- For unknown abstract types, error out
-convAExpr2SExpr _ e =
- internalError ("unexpected expr/type in convAExpr2SExpr: " ++ show e)
-
-
-convAExpr2SExpr_Force :: Bool -> AExpr -> SM (S.Expr, SType)
-convAExpr2SExpr_Force True e = convAExpr2SExpr (Just SBool) e >>= toBool
-convAExpr2SExpr_Force False e =
- convAExpr2SExpr (Just (getBitType e)) e >>= toBits
-
-convPrim2SExpr :: Maybe SType ->
- PrimOp -> AId -> Integer -> [AExpr] -> SM (S.Expr, SType)
-convPrim2SExpr mty PrimIf _ _ [c, t, f] = do
- -- force "c" to be Bool
- (yc, _) <- convAExpr2SExpr_Force True c
- res0_t@(y0_t, ty0_t) <- convAExpr2SExpr mty t
- res0_f@(y0_f, ty0_f) <- convAExpr2SExpr mty f
- -- if the types of the arms don't match, force them to the expected type
- (yt, yf, ty) <- if (ty0_t == ty0_f)
- then return (y0_t, y0_f, ty0_t)
- else do (y1_t, ty1_t) <- convType mty res0_t
- -- feed in ty1_t, in case mty is Nothing,
- -- so that at least both arms match
- (y1_f, ty1_f) <- convType (Just ty1_t) res0_f
- return (y1_t, y1_f, ty1_f)
- ctx <- gets context
- yif <- liftIO $ S.mkIte ctx yc yt yf
- return (yif, ty)
-
--- XXX what if the type of the case is String etc?
-convPrim2SExpr mty PrimCase i w (idx : dflt : ces) =
- -- in the absence of a "case" construct, just convert to if-then-else
- let foldFn (v, e) res =
- let c = APrim i aTBool PrimEQ [idx, v]
- in APrim i (ATBit w) PrimIf [c, e, res]
- in convAExpr2SExpr mty (foldr foldFn dflt (makePairs ces))
-{-
- -- force "idx" to be Bits
- (yidx, _) <- convAExpr2SExpr_Force False idx
- let (cs, es) = split (makePairs ces)
- -- force the conditions to be Bits
- ycs <- mapM (convAExpr2SExpr_Force False) cs >>= mapM (return . fst)
- -- convert the arms
- res0_es <- mapM (convAExpr2SExpr mty) es
- -- convert the default
- res0_dflt@(y0_dflt, ty0_dflt) <- convAExpr2SExpr mty dflt
- -- make sure that all the arms and default have the same type
- (y_dflt, y_es, ty) <-
- -- do all of the types of the arms match?
- if (allSame (map snd) res0_es)
- then do -- make sure the default has the same type
- let mty_arms =
- case res0_es of
- ((_,ty):_) -> Just ty
- _ -> mty -- no arms? use the expected type
- (y_dflt, ty) <- convType mty_arms res0_dflt
- return (y_dflt, map fst res0_es, ty)
- else do -- force them all to the expected type
- -- (if no expected type, use the first type)
- let mty_arms =
- if (isJust mty)
- then mty
- else case res0_es of
- ((_,ty):_) -> Just ty
- _ -> -- can't be no arms if they differ!
- internalError ("convPrim2SExpr: case")
- res_es <- map (convType mty_arms) res0_es
- (y_dflt, ty) <- convType mty_arms res0_dflt
- return (y_dflt, map fst res_es, ty)
- -- put it all together
--}
-
-convPrim2SExpr mty PrimArrayDynSelect i w args =
- case args of
- [APrim _ _ PrimBuildArray es, idx] ->
- -- in the absence of a "case" construct, just convert to if-then-else
- let foldFn (n, e) res =
- let n_lit = ASInt i (ae_type idx) (ilDec n)
- c = APrim i aTBool PrimEQ [idx, n_lit]
- in APrim i (ATBit w) PrimIf [c, e, res]
- -- number of arms is the min of the elems and the max index
- idx_ty = ae_type idx
- max_idx = case idx_ty of
- ATBit sz -> (2^sz) - 1
- _ -> internalError ("convPrim2SExpr: idx_ty")
- arms = zip [0..max_idx] es
- -- default (even if it's not reachable)
- dflt = ASAny (ATBit w) Nothing
- in convAExpr2SExpr mty (foldr foldFn dflt arms)
- [ASDef _ i_def, idx] -> do
- dmap <- gets defMap
- case (M.lookup i_def dmap) of
- Just (ADef { adef_expr = e_def }) ->
- convPrim2SExpr mty PrimArrayDynSelect i w [e_def, idx]
- _ -> internalError ("convPrim2SExpr: PrimArrayDynSelect: " ++
- ppReadable args)
- _ -> internalError ("convPrim2SExpr: PrimArrayDynSelect: " ++
- ppReadable args)
-
--- Arguments must be the same type (either Bits or Bool), result is Bool
-convPrim2SExpr _ PrimEQ _ _ args =
- case args of
- [arg1, arg2] -> do
- -- force the arms to be of the same type
- (y_arg1, ty_arg1) <- convAExpr2SExpr Nothing arg1
- (y_arg2, _) <- convAExpr2SExpr (Just ty_arg1) arg2
- >>= convType (Just ty_arg1)
- ctx <- gets context
-
- -- mkEq segfaults on Bool inputs, so use iff
- let eqFn = if (ty_arg1 == SBool) then S.mkIff else S.mkEq
-
- yeq <- liftIO $ eqFn ctx y_arg1 y_arg2
- return (yeq, SBool)
- _ -> internalError ("convPrim2SExpr: PrimEQ: wrong number of args: " ++
- ppReadable args)
-
--- Bool arguments, Bool result
-convPrim2SExpr _ PrimBOr _ w args = doBinManyPrim_BoolBool S.mkOrMany args
-convPrim2SExpr _ PrimBAnd _ w args = doBinManyPrim_BoolBool S.mkAndMany args
-convPrim2SExpr _ PrimBNot _ w args = doUnPrim_BoolBool S.mkNot args
-
--- Bit arguments, Bool result
-convPrim2SExpr _ PrimULE _ w args = doBinPrim_BitsBool S.mkBVLe args
-convPrim2SExpr _ PrimULT _ w args = doBinPrim_BitsBool S.mkBVLt args
-convPrim2SExpr _ PrimSLE _ w args = doBinPrim_BitsBool S.mkBVSle args
-convPrim2SExpr _ PrimSLT _ w args = doBinPrim_BitsBool S.mkBVSlt args
-
--- Bit arguments, Bit result
-convPrim2SExpr _ PrimAnd _ w args = doBinPrim_BitsBits w S.mkBVAnd args
-convPrim2SExpr _ PrimOr _ w args = doBinPrim_BitsBits w S.mkBVOr args
-convPrim2SExpr _ PrimXor _ w args = doBinPrim_BitsBits w S.mkBVXor args
--- bitwise negation
-convPrim2SExpr _ PrimInv _ w args = doUnPrim_BitsBits w S.mkBVNot args
-
--- Bit arguments, Bit result
--- STP requires the arguments to be the same size
--- (and the same size as the operator?)
--- So Mul needs to have its arguments extended to the result size;
--- Div and Rem need to have their arguments extended to the larger size,
--- and the result truncated if the larger size is not the result size.
-convPrim2SExpr _ PrimAdd _ w args = doBinPrimSz_BitsBits w S.mkBVAdd args
-convPrim2SExpr _ PrimSub _ w args = doBinPrimSz_BitsBits w S.mkBVSub args
-convPrim2SExpr _ PrimMul _ w args =
- let args' = map (aZeroExtend w) args
- in doBinPrimSz_BitsBits w S.mkBVMul args'
-convPrim2SExpr _ PrimQuot _ w args =
- let arg_size = maximum $ map (getWidth . ae_type) args
- args' = map (aZeroExtend arg_size) args
- in doBinPrimSz_BitsBits arg_size S.mkBVDiv args' >>= sTruncate w
-convPrim2SExpr _ PrimRem _ w args =
- let arg_size = maximum $ map (getWidth . ae_type) args
- args' = map (aZeroExtend arg_size) args
- in doBinPrimSz_BitsBits arg_size S.mkBVMod args' >>= sTruncate w
--- arith negation
-convPrim2SExpr _ PrimNeg _ w args = doUnPrim_BitsBits w S.mkBVMinus args
-
--- Bit argument, static Int argument, Bit result
-convPrim2SExpr _ PrimSL _ w [e, n@(ASInt {})] =
- doBinIntPrim_BitsBits w S.mkBVShiftLeft e (extractInt n)
-convPrim2SExpr _ PrimSRL i w [e, n@(ASInt {})] =
- doBinIntPrim_BitsBits w S.mkBVShiftRight e (extractInt n)
-
--- Dynamic Shifting must extend all arguments to same size
-convPrim2SExpr mty PrimSL i w args =
- let arg_size = maximum $ map (getWidth . ae_type) args
- args' = map (aZeroExtend arg_size) args
- in doBinPrimSz_BitsBits arg_size S.mkBVShiftLeftExpr args' >>= sTruncate w
-
-convPrim2SExpr mty PrimSRL i w args =
- let arg_size = maximum $ map (getWidth . ae_type) args
- args' = map (aZeroExtend arg_size) args
- in doBinPrimSz_BitsBits arg_size S.mkBVShiftRightExpr args' >>= sTruncate w
-
--- For signed shift right, the left operator must be sign extended...
-convPrim2SExpr mty PrimSRA i w [e1,e2] =
- let arg_size = maximum $ map (getWidth . ae_type) [e1,e2]
- e1' = aSignExtend arg_size e1
- e2' = aZeroExtend arg_size e2
- in doBinPrimSz_BitsBits arg_size S.mkBVSignedShiftRightExpr [e1',e2'] >>= sTruncate w
-
-
--- Bit argument, identical static Int arguments, Bool result
-convPrim2SExpr (Just SBool) PrimExtract _ _
- [e, ub@(ASInt {}), lb@(ASInt {})] | (yub == ylb) = do
- (ye, _) <- convAExpr2SExpr_Force False e
- ctx <- gets context
- yext <- liftIO $ S.mkBVBoolExtract ctx ylb ye
- return (yext, SBool)
- where yub = extractInt ub
- ylb = extractInt lb
--- Bit argument, static Int arguments, Bit result
-convPrim2SExpr _ PrimExtract _ _ [e, ub@(ASInt {}), lb@(ASInt {})] = do
- let yub = extractInt ub
- ylb = extractInt lb
- width = toInteger (yub - ylb + 1)
- ty = SBits width
- (ye, _) <- convAExpr2SExpr_Force False e
- ctx <- gets context
- yext <- liftIO $ S.mkBVExtract ctx ylb yub ye
- return (yext, ty)
--- Don't handle dynamic extraction
--- XXX We could implement the logic for this?
-convPrim2SExpr mty PrimExtract i w args =
- -- XXX This could be an unevaluated function, applied to converted arguments
- addUnknownExpr mty (APrim i (ATBit w) PrimExtract args) w
-
--- Bit arguments, Bit result
-convPrim2SExpr _ PrimConcat i w args@[_, _] =
- doBinPrim_BitsBits w S.mkBVConcat args
-convPrim2SExpr _ PrimConcat i width (a1:args) =
- let a1width = case (ae_type a1) of
- ATBit n -> n
- t -> internalError ("convPrim2SExpr: PrimConcat width: " ++
- ppReadable t)
- a2width = width - a1width
- a2 = APrim i (ATBit a2width) PrimConcat args
- in doBinPrim_BitsBits width S.mkBVConcat [a1, a2]
-
--- Sign extend, sizes take from argument and return type
-convPrim2SExpr _ PrimSignExt i w [e] =
- doBinIntPrim_BitsBits w S.mkBVSignExtend e (fromInteger w)
-
-convPrim2SExpr mty p i w args =
- addUnknownExpr mty (APrim i (ATBit w) p args) w
- --internalError ("unexpected prim: " ++ ppReadable (p, args))
-
-
--- -----
-
-doBinManyPrim_BoolBool :: (S.Context -> [S.Expr] -> IO S.Expr) -> [AExpr]
- -> SM (S.Expr, SType)
-doBinManyPrim_BoolBool mkFn args =
- boolArgs args >>= doBinManyPrim mkFn >>= boolRes
-
-doUnPrim_BoolBool :: (S.Context -> S.Expr -> IO S.Expr) -> [AExpr]
- -> SM (S.Expr, SType)
-doUnPrim_BoolBool mkFn args =
- boolArgs args >>= doUnPrim mkFn >>= boolRes
-
-doBinPrim_BitsBool :: (S.Context -> S.Expr -> S.Expr -> IO S.Expr) -> [AExpr]
- -> SM (S.Expr, SType)
-doBinPrim_BitsBool mkFn args =
- bitsArgs args >>= doBinPrim mkFn >>= boolRes
-
-doBinPrim_BitsBits :: Integer
- -> (S.Context -> S.Expr -> S.Expr -> IO S.Expr)
- -> [AExpr]
- -> SM (S.Expr, SType)
-doBinPrim_BitsBits w mkFn args =
- bitsArgs args >>= doBinPrim mkFn >>= bitsRes w
-
-doBinPrimSz_BitsBits :: Integer
- -> (S.Context -> Int -> S.Expr -> S.Expr -> IO S.Expr)
- -> [AExpr]
- -> SM (S.Expr, SType)
-doBinPrimSz_BitsBits w mkFn args =
- bitsArgs args >>=
- doBinPrim (\ctx -> mkFn ctx (fromInteger w)) >>=
- bitsRes w
-
-doUnPrim_BitsBits :: Integer
- -> (S.Context -> S.Expr -> IO S.Expr)
- -> [AExpr]
- -> SM (S.Expr, SType)
-doUnPrim_BitsBits w mkFn args =
- bitsArgs args >>= doUnPrim mkFn >>= bitsRes w
-
-doBinIntPrim_BitsBits :: Integer
- -> (S.Context -> S.Expr -> Int -> IO S.Expr)
- -> AExpr
- -> Int
- -> StateT SState IO (S.Expr, SType)
-doBinIntPrim_BitsBits w mkFn e n = do
- (ye, _) <- convAExpr2SExpr_Force False e
- yp <- doBinIntPrim mkFn ye n
- bitsRes w yp
-
-
-boolArgs :: [AExpr] -> SM [S.Expr]
-boolArgs = mapM (\ a -> convAExpr2SExpr_Force True a >>= return . fst)
-bitsArgs :: [AExpr] -> SM [S.Expr]
-bitsArgs = mapM (\ a -> convAExpr2SExpr_Force False a >>= return . fst)
-
-boolRes :: Monad m => a -> m (a, SType)
-boolRes ye = return (ye, SBool)
-bitsRes :: Monad m => Integer -> a -> m (a, SType)
-bitsRes w ye = return (ye, SBits w)
-
-
-doUnPrim :: (S.Context -> S.Expr -> IO S.Expr) -> [S.Expr] -> SM S.Expr
-doUnPrim mkFn [y_arg] = do
- ctx <- gets context
- liftIO $ mkFn ctx y_arg
-doUnPrim _ args =
- internalError ("doUnPrim: wrong number of args: " ++
- ppReadable (length args))
-
-doBinPrim :: (S.Context -> S.Expr -> S.Expr -> IO S.Expr) ->
- [S.Expr] -> SM S.Expr
-doBinPrim mkFn [y_arg1, y_arg2] = do
- ctx <- gets context
- liftIO $ mkFn ctx y_arg1 y_arg2
-doBinPrim _ args =
- internalError ("doBinPrim: wrong number of args: " ++
- ppReadable (length args))
-
-doBinManyPrim :: (S.Context -> [S.Expr] -> IO S.Expr) ->
- [S.Expr] -> SM S.Expr
-doBinManyPrim _ args | (length args < 2) =
- internalError ("doBinManyPrim: wrong number of args: " ++
- ppReadable (length args))
-doBinManyPrim mkFn ys_args = do
- ctx <- gets context
- liftIO $ mkFn ctx ys_args
-
--- Second argument cannot be dynamic
-doBinIntPrim :: (S.Context -> S.Expr -> Int -> IO S.Expr) ->
- S.Expr -> Int -> SM S.Expr
-doBinIntPrim mkFn y_arg1 n_arg2 = do
- ctx <- gets context
- liftIO $ mkFn ctx y_arg1 n_arg2
-
-
--- -----
-
-extractInt :: AExpr -> Int
-extractInt (ASInt _ _ (IntLit _ _ val)) = fromInteger val
-extractInt e = internalError ("extractInt: unexpected pattern: " ++ show e)
-
-
--- -----
-
-getWidth :: AType -> Integer
-getWidth (ATBit w) = w
-getWidth t = internalError ("AExpr2STP.getWidth: " ++ ppReadable t)
-
--- copied from similar function in AOpt
-aZeroExtend :: Integer -> AExpr -> AExpr
-aZeroExtend w e =
- let e_size = getWidth (ae_type e)
- pad_size = w - e_size
- in case (compare pad_size 0) of
- EQ -> e
- GT -> APrim dummy_id (ATBit w) PrimConcat
- [ASInt defaultAId (ATBit pad_size) (ilDec 0), e]
- LT -> internalError ("AExpr2STP.aZeroExtend: " ++ ppReadable (w, e))
-
-aSignExtend :: Integer -> AExpr -> AExpr
-aSignExtend w e =
- let e_size = getWidth (ae_type e)
- pad_size = w - e_size
- in case (compare pad_size 0) of
- EQ -> e
- GT -> APrim dummy_id (ATBit w) PrimSignExt [e]
- LT -> internalError ("AExpr2STP.aSignExtend: " ++ ppReadable (w, e))
-
-sTruncate :: Integer -> (S.Expr, SType) -> SM (S.Expr, SType)
-sTruncate w res@(ye, SBits e_sz) | w == e_sz = return res
-sTruncate w (ye, SBits e_sz) | e_sz > w =
- do ctx <- gets context
- ytrunc <- liftIO $ S.mkBVExtract ctx 0 (fromInteger (w-1)) ye
- return (ytrunc, SBits w)
-sTruncate w (ye, yt) =
- internalError ("AExpr2STP.sTruncate: " ++ ppReadable (w, yt))
-
-
--- -------------------------
diff --git a/src/comp/DisjointTest.hs b/src/comp/DisjointTest.hs
index 88d177c79..2b75e6bcb 100644
--- a/src/comp/DisjointTest.hs
+++ b/src/comp/DisjointTest.hs
@@ -27,9 +27,6 @@ import VModInfo(VModInfo)
import AExpr2Util(getMethodOutputPort)
--import Debug.Trace(trace)
-import qualified AExpr2STP as STP
- (SState, initSState, addADefToSState,
- checkDisjointRulePair, checkDisjointExpr)
import qualified AExpr2Yices as Yices
(YState, initYState, addADefToYState,
checkDisjointRulePair, checkDisjointExpr)
@@ -40,7 +37,6 @@ type RuleDisjointTest = ARuleId -> ARuleId -> Bool
-- A single data type for either of the disjoint-testing state
data DisjointTestState = DTS_Yices DSupportMap Yices.YState
- | DTS_STP DSupportMap STP.SState
-- -------------------------
@@ -54,9 +50,6 @@ initDisjointTestState str errh flags ds avis rs = do
SAT_Yices -> do
yices_state <- Yices.initYState str flags True ds avis rs
return (DTS_Yices supportMap yices_state)
- SAT_STP -> do
- stp_state <- STP.initSState str flags True ds avis rs
- return (DTS_STP supportMap stp_state)
addADefToDisjointTestState :: DisjointTestState -> [ADef] ->
@@ -64,9 +57,6 @@ addADefToDisjointTestState :: DisjointTestState -> [ADef] ->
addADefToDisjointTestState (DTS_Yices m yices_state) ds = do
yices_state' <- Yices.addADefToYState yices_state ds
return (DTS_Yices m yices_state')
-addADefToDisjointTestState (DTS_STP m stp_state) ds = do
- stp_state' <- STP.addADefToSState stp_state ds
- return (DTS_STP m stp_state')
-- -------------------------
@@ -75,9 +65,6 @@ checkDisjointExpr :: DisjointTestState -> AExpr -> AExpr ->
checkDisjointExpr (DTS_Yices m yices_state) e1 e2 = do
(res, yices_state') <- Yices.checkDisjointExpr yices_state e1 e2
return (res, DTS_Yices m yices_state')
-checkDisjointExpr (DTS_STP m stp_state) e1 e2 = do
- (res, stp_state') <- STP.checkDisjointExpr stp_state e1 e2
- return (res, DTS_STP m stp_state')
-- When testing conditions on methods inside one rule (or two rules),
-- we also want to consider the predicates of the rules; the conditions
@@ -157,9 +144,6 @@ checkDisjointRulePair :: DisjointTestState -> (ARuleId, ARuleId) ->
checkDisjointRulePair s@(DTS_Yices m yices_state) p = do
(res, yices_state') <- Yices.checkDisjointRulePair yices_state p
return (res, DTS_Yices m yices_state')
-checkDisjointRulePair s@(DTS_STP m stp_state) p = do
- (res, stp_state') <- STP.checkDisjointRulePair stp_state p
- return (res, DTS_STP m stp_state')
-- -------------------------
@@ -285,7 +269,6 @@ buildSupportMap adefs avis rs = --trace ("XXX support map:" ++ ppReadable res) $
-- -------------------------
getSupportMap :: DisjointTestState -> DSupportMap
getSupportMap (DTS_Yices m _) = m
-getSupportMap (DTS_STP m _) = m
instance PPrint ASupport where
diff --git a/src/comp/Flags.hs b/src/comp/Flags.hs
index 5ba682b58..c03f23725 100644
--- a/src/comp/Flags.hs
+++ b/src/comp/Flags.hs
@@ -292,7 +292,6 @@ data ResourceFlag
data SATFlag
= SAT_Yices
- | SAT_STP
deriving (Eq, Show)
data MsgListFlag = AllMsgs | SomeMsgs [String]
diff --git a/src/comp/FlagsDecode.hs b/src/comp/FlagsDecode.hs
index 61162eff5..4f284e7dd 100644
--- a/src/comp/FlagsDecode.hs
+++ b/src/comp/FlagsDecode.hs
@@ -1523,11 +1523,6 @@ externalFlags = [
(Arg "dir" (\f s -> Left (f {cdir = Just s})) (Just (FRTMaybeString cdir)),
"output directory for Bluesim intermediate files", Visible)),
- ("sat-stp",
- (NoArg (\f -> Left $ f { satBackend = SAT_STP })
- (showIfEq satBackend SAT_STP),
- "use STP SMT for disjoint testing and SAT", Visible)),
-
("sat-yices",
(NoArg (\f -> Left $ f { satBackend = SAT_Yices })
(showIfEq satBackend SAT_Yices),
diff --git a/src/comp/GenABin.hs b/src/comp/GenABin.hs
index de7264716..7cec97232 100644
--- a/src/comp/GenABin.hs
+++ b/src/comp/GenABin.hs
@@ -524,11 +524,9 @@ instance Bin Verbosity where
instance Bin SATFlag where
writeBytes SAT_Yices = putI 1
- writeBytes SAT_STP = putI 2
readBytes = do i <- getI
case i of
1 -> return SAT_Yices
- 2 -> return SAT_STP
n -> internalError $ "GenABin.Bin(SATFlag).readBytes: " ++ show n
instance Bin MsgListFlag where
diff --git a/src/comp/Makefile b/src/comp/Makefile
index ac57e3e55..3bf8159ba 100644
--- a/src/comp/Makefile
+++ b/src/comp/Makefile
@@ -45,11 +45,6 @@ BUILDDIR=$(TOP)/build/comp
# Parsec
PARSEC_HS = ../Parsec
-# STP
-STP_HS = ../vendor/stp/include_hs
-STP_INC_FLAGS = -I../vendor/stp/include
-STP_LIB_FLAGS = -L../vendor/stp/lib -lstp
-
# Yices
YICES_HS = ../vendor/yices/include_hs
YICES_INC_FLAGS = -I../vendor/yices/include
@@ -164,7 +159,6 @@ GHCRTSFLAGS ?= +RTS -M4G -A128m -RTS
GHCINCLUDES = \
-iGHC/posix -iLibs \
-i$(PARSEC_HS) \
- -i$(STP_HS) \
-i$(YICES_HS) \
-i$(HTCL_HS)
GHCTMP = '-tmpdir $(TMPDIR)'
@@ -188,7 +182,6 @@ GHCFLAGS = \
# To avoid recompiling the shared modules each time we compile a tool,
# we provide the -I flags for all tools in every use of GHC.
GHCFLAGS += \
- $(STP_INC_FLAGS) \
$(YICES_INC_FLAGS) \
$(HTCL_INC_FLAGS) \
$(TCL_INC_FLAGS) \
@@ -226,7 +219,6 @@ SOURCES_WO_EXTRA_BUILDVERSION = \
Libs/*.hs \
GHC/posix/*.hs \
$(PARSEC_HS)/*.hs \
- $(STP_HS)/*.hs \
$(YICES_HS)/*.hs \
$(HTCL_HS)/*.hs
@@ -262,7 +254,6 @@ POSTBUILDCOMMAND = $(BUILDDONE)
# (to avoid creating binaries with unnecessary library requirements)
#
BSC_BUILDLIBS = \
- $(STP_LIB_FLAGS) \
$(YICES_LIB_FLAGS) \
BLUETCL_BUILDLIBS = \
@@ -388,7 +379,7 @@ install-showrules: $(addprefix $(BINDIR)/core/,$(SHOWRULESEXES))
# Other targets
tags: *hs */*hs bluewish.hs
- $(FIND) . $(PARSEC_HS) $(STP_HS) $(YICES_HS) $(HTCL_HS) \
+ $(FIND) . $(PARSEC_HS) $(YICES_HS) $(HTCL_HS) \
-type f -name \*hs | xargs hasktags
mv tags tags.tmpfile
sort tags.tmpfile > tags
diff --git a/src/comp/Pred2STP.hs b/src/comp/Pred2STP.hs
deleted file mode 100644
index e209080d1..000000000
--- a/src/comp/Pred2STP.hs
+++ /dev/null
@@ -1,510 +0,0 @@
-module Pred2STP(
- SState,
- initSState,
- solvePred
-) where
-
-import Control.Monad(when)
-import Control.Monad.State(StateT, liftIO, gets, get, put, runStateT)
-import qualified Data.Map as M
-import qualified STP as S
-
-import ErrorUtil(internalError)
---import Flags
-import PFPrint
-import Id
-import PreIds
-import CType
-import Type
-import Pred
-import Util(itos)
-
-import Debug.Trace(traceM)
-import IOUtil(progArgs)
-
-traceTest :: Bool
-traceTest = "-trace-smt-test" `elem` progArgs
-
-traceConv :: Bool
-traceConv = "-trace-smt-conv" `elem` progArgs
-
--- -------------------------
-
-data SState =
- SState {
- context :: S.Context,
- --flags :: Flags,
-
- -- source of unique identifiers
- unknownId :: Integer,
-
- -- all BSV types will be represented by one type in STP,
- -- so keep a handle to the type
- intType :: S.Type,
-
- -- a map from types to their converted form
- -- (this is used both to avoid duplicate conversion
- -- and as a list of possible terms for solving)
- typeSExprMap :: M.Map Type (S.Expr, [S.Expr])
- }
-
-type SM = StateT SState IO
-
--- represent numeric types as 32-bit vectors
--- (since that provides a division operator and log/exp via shifting)
-intWidth :: (Integral t) => t
-intWidth = 32
-
--- -------------------------
-
-initSState :: IO SState
-initSState = do
- ctx <- liftIO $ S.mkContext
- int_ty <- liftIO $ S.mkBitVectorType ctx intWidth
- return (SState { context = ctx,
- --flags = flags,
- unknownId = 0,
- intType = int_ty,
- typeSExprMap = M.empty
- })
-
--- -------------------------
-
-{-
--- XXX We'll eventually want to test that user-given provisos are satisfiable
--- XXX and give a user error if not. We'll also want to test, before reporting
--- XXX that additional provisos are needed, that the additional provisos are
--- XXX satisfiable.
-
--- Check if a set of predicates is consistent
-
-checkPreds :: SState -> [Pred] -> IO ([EMsg], SState)
-checkPreds s ps = runStateT (checkPredsM ps) s
-
-checkPredsM :: [Pred] -> SM [EMsg]
-checkPredsM ps = do
- ctx <- gets context
-
- -- push a new context, so we can cleanly retract the work when we're done
- liftIO $ S.ctxPush ctx
-
- -- assert the given provisos
- mapM_ assertPred ps
-
- -- check if there exists a solution
- sat <- checkSAT
-
- -- pop the context
- liftIO $ S.ctxPop ctx
-
- -- if there is no solution, report an error to the user
- if (sat /= Just True)
- then reportMinUnsatPreds [] ps
- else return []
-
-
-reportMinUnsatPreds :: [Pred] -> [Pred] -> SM [EMsg]
-reportMinUnsatPreds qs [] =
- -- XXX "satisfy" will need to take a position and plumb it to "reducePred"
- return [(noPosition, EGeneric ("unsat preds: " ++ ppReadable qs))]
-
-reportMinUnsatPreds qs (p:ps) = do
- ctx <- gets context
-
- -- push a new context, so we can cleanly retract the work when we're done
- liftIO $ S.ctxPush ctx
-
- -- assert all the provisos besides "p"
- mapM_ assertPred (qs ++ ps)
-
- -- check if there exists a solution
- sat <- checkSAT
-
- -- pop the context
- liftIO $ S.ctxPop ctx
-
- -- if there is still no solution, then drop "p" else keep it
- if (sat /= Just True)
- then reportMinUnsatPreds qs ps
- else reportMinUnsatPreds (p:qs) ps
--}
-
--- -------------------------
-
--- XXX should this take the BVS and DVS?
-
-solvePred :: SState -> [Pred] -> Pred -> IO (Maybe Pred, SState)
-solvePred s ps p = runStateT (solvePredM ps p) s
-
-solvePredM :: [Pred] -> Pred -> SM (Maybe Pred)
-solvePredM ps p = do
- ctx <- gets context
-
- when traceTest $ traceM ("solvePred: " ++ ppReadable p)
-
- -- check that the pred is one that we handle, and if so then
- -- construct p as an inequality (along with its additional assertions)
- m_yneq <- genPredInequality p
- case m_yneq of
- Nothing -> do
- -- the pred is not of the form that we can handle
- when traceTest $ traceM("solvePred: not handled")
- return Nothing
- Just (yneq, as) -> do
-
- -- first make sure that the preds have at least one solution
- is_sat <- do
- -- push a new context,
- -- so we can cleanly retract the work when we're done
- liftIO $ S.ctxPush ctx
- -- assert the given provisos
- mapM_ assertPred (p:ps)
- -- check if there exists a solution
- sat <- checkSAT
- -- pop the context
- liftIO $ S.ctxPop ctx
- return (sat == Just True)
-
- -- if there is no solution, return the pred unsatisfied
- -- (if an error needs to be reported, it will be reported later)
- if (not is_sat)
- then do when traceTest $ traceM("solvePred: not satisfiable")
- return Nothing
- else do
-
- -- push a new context,
- -- so we can cleanly retract the work when we're done
- liftIO $ S.ctxPush ctx
- -- assert the given provisos
- mapM_ assertPred ps
-
- -- XXX for now, we only resolve provisos where no substitution is learned
-
- -- assert the inequality and associated assumptions
- mapM_ (liftIO . S.assert ctx) (yneq:as)
- -- check if there exists a solution
- sat <- checkSAT
- -- if it is satisfiable, then the equality does not hold
- let res = case sat of
- Just False -> Just p
- _ -> Nothing
- -- retract the assertions
- liftIO $ S.ctxPop ctx
- when traceTest $
- case res of
- Nothing -> traceM ("solvePred: unresolved: " ++ ppReadable p)
- Just _ -> traceM ("solvePred: resolved: " ++ ppReadable p)
- return res
-
-
-genPredInequality :: Pred -> SM (Maybe (S.Expr, [S.Expr]))
-genPredInequality p@(IsIn c [t1, t2]) | classId c == idNumEq = do
- when traceTest $ traceM("pred: " ++ ppReadable p)
- (yt1, as1) <- convType2SExpr t1
- (yt2, as2) <- convType2SExpr t2
- ynp <- mkNEq yt1 yt2
- return $ Just (ynp, as1 ++ as2)
-genPredInequality p@(IsIn c [t1, t2, t3]) | classId c == idAdd = do
- when traceTest $ traceM("pred: " ++ ppReadable p)
- (yt3, as3) <- convType2SExpr t3
- (yadd, as12) <- convType2SExpr (TAp (TAp tAdd t1) t2)
- ynp <- mkNEq yadd yt3
- return $ Just (ynp, as3 ++ as12)
-genPredInequality p@(IsIn c [t1, t2, t3]) | classId c == idMul = do
- when traceTest $ traceM("pred: " ++ ppReadable p)
- (yt3, as3) <- convType2SExpr t3
- (ymul, as12) <- convType2SExpr (TAp (TAp tMul t1) t2)
- ynp <- mkNEq ymul yt3
- return $ Just (ynp, as3 ++ as12)
-genPredInequality p@(IsIn c [t1, t2, t3]) | classId c == idMax = do
- when traceTest $ traceM("pred: " ++ ppReadable p)
- (yt3, as3) <- convType2SExpr t3
- (ymax, as12) <- convType2SExpr (TAp (TAp tMax t1) t2)
- ynp <- mkNEq ymax yt3
- return $ Just (ynp, as3 ++ as12)
-genPredInequality p@(IsIn c [t1, t2, t3]) | classId c == idMin = do
- when traceTest $ traceM("pred: " ++ ppReadable p)
- (yt3, as3) <- convType2SExpr t3
- (ymin, as12) <- convType2SExpr (TAp (TAp tMin t1) t2)
- ynp <- mkNEq ymin yt3
- return $ Just (ynp, as3 ++ as12)
-genPredInequality p@(IsIn c [t1, t2, t3]) | classId c == idDiv = do
- when traceTest $ traceM("pred: " ++ ppReadable p)
- (yt3, as3) <- convType2SExpr t3
- (ydiv, as12) <- convType2SExpr (TAp (TAp tDiv t1) t2)
- ynp <- mkNEq ydiv yt3
- return $ Just (ynp, as3 ++ as12)
-genPredInequality p@(IsIn c [t1, t2, t3]) | classId c == idLog = do
- when traceTest $ traceM("pred: " ++ ppReadable p)
- (yt3, as3) <- convType2SExpr t3
- (ylog, as12) <- convType2SExpr (TAp (TAp tLog t1) t2)
- ynp <- mkNEq ylog yt3
- return $ Just (ynp, as3 ++ as12)
-genPredInequality p = do
- when traceTest $ traceM("pred unknown: " ++ ppReadable p)
- return Nothing
-
--- -------------------------
-
-checkSAT :: SM (Maybe Bool)
-checkSAT = do
- ctx <- gets context
- yf <- liftIO $ S.mkFalse ctx
- sat_res <- liftIO $ S.query ctx yf
- -- if query(False) is Valid, then there is an inconsistency,
- -- so the asserted expressions are not satisfiable
- case (sat_res) of
- S.Invalid -> return $ Just True
- S.Valid -> return $ Just False
- S.Timeout -> return Nothing
- S.Error -> internalError ("STP query error")
-
--- -------------------------
-
--- Use these functions to make sure that info is added to the most recent maps.
--- If you have a local copy of the map around, but then call monadic functions,
--- the local copy may become stale, and you'll lose info if you write back the
--- stale copy.
-
-addToTypeMap :: Type -> (S.Expr, [S.Expr]) -> SM ()
-addToTypeMap t res = do
- s <- get
- let tmap = typeSExprMap s
- tmap' = M.insert t res tmap
- put (s {typeSExprMap = tmap' })
-
--- -------------------------
-
-getUnknownName :: SM String
-getUnknownName = do
- s <- get
- let n = unknownId s
- -- XXX we need to check for name clash
- let str = "__unknown_" ++ itos n
- put (s { unknownId = n + 1})
- return str
-
-mkUnknownVar :: SM S.Expr
-mkUnknownVar = do
- ctx <- gets context
- str <- getUnknownName
- ty <- gets intType
- liftIO $ S.mkVar ctx str ty
-
-addUnknownType :: Type -> SM (S.Expr, [S.Expr])
-addUnknownType t = do
- when traceConv $ traceM("addUnknownType: " ++ ppString t)
- tmap <- gets typeSExprMap
- case (M.lookup t tmap) of
- Just res -> do when traceConv $ traceM(" reusing.")
- return res
- Nothing -> do
- when traceConv $ traceM(" making new var.")
- var <- mkUnknownVar
- let res = (var, [])
- addToTypeMap t res
- return res
-
--- -------------------------
-
-convType2SExpr :: Type -> SM (S.Expr, [S.Expr])
-convType2SExpr t = do
- when traceConv $ traceM("converting: " ++ ppReadable t)
- tmap <- gets typeSExprMap
- case (M.lookup t tmap) of
- Just res -> do when traceConv $ traceM(" reusing.")
- return res
- Nothing -> do
- when traceConv $ traceM(" converting new.")
- yt <- convType2SExpr' t
- addToTypeMap t yt
- return yt
-
-convType2SExpr' :: Type -> SM (S.Expr, [S.Expr])
-convType2SExpr' t@(TVar {}) = do
- when traceConv $ traceM("conv TyVar: " ++ ppReadable t)
- addUnknownType t
-convType2SExpr' t@(TCon (TyNum n _)) = do
- when traceConv $ traceM("conv TyNum: " ++ ppReadable n)
- ctx <- gets context
- res <- liftIO $ S.mkBVConstantFromInteger ctx intWidth n
- return (res, [])
-convType2SExpr' t@(TAp (TAp tc t1) t2) | (tc == tAdd) = do
- when traceConv $ traceM("conv TAdd: " ++ ppReadable t)
- ctx <- gets context
- (yt1, as1) <- convType2SExpr t1
- (yt2, as2) <- convType2SExpr t2
- res <- liftIO $ S.mkBVAdd ctx intWidth yt1 yt2
- -- assert that there is no overflow
- ygte1 <- liftIO $ S.mkBVGe ctx res yt1
- return (res, [ygte1] ++ as1 ++ as2)
-convType2SExpr' t@(TAp (TAp tc t1) t2) | (tc == tSub) = do
- when traceConv $ traceM("conv TSub: " ++ ppReadable t)
- ctx <- gets context
- (yt1, as1) <- convType2SExpr t1
- (yt2, as2) <- convType2SExpr t2
- res <- liftIO $ S.mkBVSub ctx intWidth yt1 yt2
- -- assert that there is no underflow
- ygte1 <- liftIO $ S.mkBVGe ctx yt1 res
- return (res, [ygte1] ++ as1 ++ as2)
-convType2SExpr' t@(TAp (TAp tc t1) t2) | (tc == tMul) = do
- when traceConv $ traceM("conv TMul: " ++ ppReadable t)
- ctx <- gets context
- (yt1, as1) <- convType2SExpr t1
- (yt2, as2) <- convType2SExpr t2
- res <- liftIO $ S.mkBVMul ctx intWidth yt1 yt2
- -- assert that there is no overflow: (t2 == 0) || (res >= t1)
- yzero <- liftIO $ S.mkBVConstantFromInteger ctx intWidth 0
- yeqz2 <- liftIO $ S.mkEq ctx yt2 yzero
- ygte1 <- liftIO $ S.mkBVGe ctx res yt1
- yor <- liftIO $ S.mkOr ctx yeqz2 ygte1
- return (res, [yor] ++ as1 ++ as2)
-convType2SExpr' t@(TAp tc t1) | (tc == tExp) = do
- when traceConv $ traceM("conv TExp: " ++ ppReadable t)
- ctx <- gets context
- (yt1, as1) <- convType2SExpr t1
- yone <- liftIO $ S.mkBVConstantFromInteger ctx intWidth 1
- res <- liftIO $ S.mkBVShiftLeftExpr ctx intWidth yone yt1
- -- assert that there is no overflow: (t1 == 0) || (res >= t1)
- yzero <- liftIO $ S.mkBVConstantFromInteger ctx intWidth 0
- yeqz1 <- liftIO $ S.mkEq ctx yt1 yzero
- ygte1 <- liftIO $ S.mkBVGe ctx res yt1
- yor <- liftIO $ S.mkOr ctx yeqz1 ygte1
- return (res, [yor] ++ as1)
-convType2SExpr' t@(TAp (TAp tc t1) t2) | (tc == tMax) = do
- when traceConv $ traceM("conv TMax: " ++ ppReadable t)
- ctx <- gets context
- (yt1, as1) <- convType2SExpr t1
- (yt2, as2) <- convType2SExpr t2
- y_t1gt <- liftIO $ S.mkBVGt ctx yt1 yt2
- res <- liftIO $ S.mkIte ctx y_t1gt yt1 yt2
- return (res, as1 ++ as2)
-convType2SExpr' t@(TAp (TAp tc t1) t2) | (tc == tMin) = do
- when traceConv $ traceM("conv TMin: " ++ ppReadable t)
- ctx <- gets context
- (yt1, as1) <- convType2SExpr t1
- (yt2, as2) <- convType2SExpr t2
- y_t1gt <- liftIO $ S.mkBVGt ctx yt1 yt2
- res <- liftIO $ S.mkIte ctx y_t1gt yt2 yt1
- return (res, as1 ++ as2)
-convType2SExpr' t@(TAp (TAp tc t1) t2) | (tc == tDiv) = do
- when traceConv $ traceM("conv TDiv: " ++ ppReadable t)
- ctx <- gets context
- (yt1, as1) <- convType2SExpr t1
- (yt2, as2) <- convType2SExpr t2
- -- A division operator exists, but TDiv returns the ceiling, not floor.
- -- So create a variable "v" ...
- var <- mkUnknownVar
- -- and assert that:
- -- (t2 * v <= t1)
- ymul <- liftIO $ S.mkBVMul ctx intWidth yt2 var
- yle <- liftIO $ S.mkBVLe ctx ymul yt1
- -- and (t1 < t2 * (v + 1))
- -- XXX consider using (t2 * v) + t2 for better sharing?
- yone <- liftIO $ S.mkBVConstantFromInteger ctx intWidth 1
- yt2plus1 <- liftIO $ S.mkBVAdd ctx intWidth yt2 yone
- ymul1 <- liftIO $ S.mkBVMul ctx intWidth yt2 yt2plus1
- ylt <- liftIO $ S.mkBVLt ctx yt1 ymul1
- -- assert that t2 is not zero
- -- XXX is this necessary?
- yzero <- liftIO $ S.mkBVConstantFromInteger ctx intWidth 0
- yneqz2 <- mkNEq yt2 yzero
- -- return the variable
- return (var, [yle, ylt, yneqz2] ++ as1 ++ as2)
-convType2SExpr' t@(TAp tc t1) | (tc == tLog) = do
- when traceConv $ traceM("conv TLog: " ++ ppReadable t)
- ctx <- gets context
- (yt1, as1) <- convType2SExpr t1
- -- Create a variable "v" ...
- var <- mkUnknownVar
- -- and assert that:
- -- ((1 << v) <= t1)
- yone <- liftIO $ S.mkBVConstantFromInteger ctx intWidth 1
- texp <- liftIO $ S.mkBVShiftLeftExpr ctx intWidth yone var
- yle <- liftIO $ S.mkBVLe ctx texp yt1
- -- and (t1 < (1 << (v + 1)))
- -- but expressed as a multiply for better sharing:
- -- (t1 < (2 * (1 << v)))
- ytwo <- liftIO $ S.mkBVConstantFromInteger ctx intWidth 2
- yexp1 <- liftIO $ S.mkBVMul ctx intWidth ytwo texp
- ylt <- liftIO $ S.mkBVLt ctx yt1 yexp1
- -- assert that t1 is not zero
- -- XXX is this necessary?
- yzero <- liftIO $ S.mkBVConstantFromInteger ctx intWidth 0
- yneqz1 <- mkNEq yt1 yzero
- -- return the variable
- return (var, [yle, ylt, yneqz1] ++ as1)
-convType2SExpr' t = do
- when traceConv $ traceM("conv unknown: " ++ ppReadable t)
- addUnknownType t
-
--- -------------------------
-
-assertPred :: Pred -> SM ()
-assertPred p@(IsIn c [t1, t2]) | classId c == idNumEq = do
- when traceTest $ traceM("asserting: " ++ ppReadable p)
- ctx <- gets context
- (yt1, as1) <- convType2SExpr t1
- (yt2, as2) <- convType2SExpr t2
- yeq <- liftIO $ S.mkEq ctx yt1 yt2
- mapM_ (liftIO . S.assert ctx) $ [yeq] ++ as1 ++ as2
-assertPred p@(IsIn c [t1, t2, t3]) | classId c == idAdd = do
- when traceTest $ traceM("asserting: " ++ ppReadable p)
- ctx <- gets context
- (yt3, as3) <- convType2SExpr t3
- (yadd, as12) <- convType2SExpr (TAp (TAp tAdd t1) t2)
- yeq <- liftIO $ S.mkEq ctx yadd yt3
- mapM_ (liftIO . S.assert ctx) $ [yeq] ++ as3 ++ as12
-assertPred p@(IsIn c [t1, t2, t3]) | classId c == idMul = do
- when traceTest $ traceM("asserting: " ++ ppReadable p)
- ctx <- gets context
- (yt3, as3) <- convType2SExpr t3
- (ymul, as12) <- convType2SExpr (TAp (TAp tMul t1) t2)
- yeq <- liftIO $ S.mkEq ctx ymul yt3
- mapM_ (liftIO . S.assert ctx) $ [yeq] ++ as3 ++ as12
-assertPred p@(IsIn c [t1, t2, t3]) | classId c == idMax = do
- when traceTest $ traceM("asserting: " ++ ppReadable p)
- ctx <- gets context
- (yt3, as3) <- convType2SExpr t3
- (ymax, as12) <- convType2SExpr (TAp (TAp tMax t1) t2)
- yeq <- liftIO $ S.mkEq ctx ymax yt3
- mapM_ (liftIO . S.assert ctx) $ [yeq] ++ as3 ++ as12
-assertPred p@(IsIn c [t1, t2, t3]) | classId c == idMin = do
- when traceTest $ traceM("asserting: " ++ ppReadable p)
- ctx <- gets context
- (yt3, as3) <- convType2SExpr t3
- (ymin, as12) <- convType2SExpr (TAp (TAp tMin t1) t2)
- yeq <- liftIO $ S.mkEq ctx ymin yt3
- mapM_ (liftIO . S.assert ctx) $ [yeq] ++ as3 ++ as12
-assertPred p@(IsIn c [t1, t2, t3]) | classId c == idDiv = do
- when traceTest $ traceM("asserting: " ++ ppReadable p)
- ctx <- gets context
- (yt3, as3) <- convType2SExpr t3
- (ydiv, as12) <- convType2SExpr (TAp (TAp tDiv t1) t2)
- yeq <- liftIO $ S.mkEq ctx ydiv yt3
- mapM_ (liftIO . S.assert ctx) $ [yeq] ++ as3 ++ as12
-assertPred p@(IsIn c [t1, t2]) | classId c == idLog = do
- when traceTest $ traceM("asserting: " ++ ppReadable p)
- ctx <- gets context
- (yt2, as2) <- convType2SExpr t2
- (ylog, as1) <- convType2SExpr (TAp tLog t1)
- yeq <- liftIO $ S.mkEq ctx ylog yt2
- mapM_ (liftIO . S.assert ctx) $ [yeq] ++ as2 ++ as1
-assertPred p = do
- when traceTest $ traceM("ignoring pred: " ++ ppReadable p)
- return ()
-
--- -------------------------
-
-classId :: Class -> Id
-classId = typeclassId . name
-
--- -------------------------
-
-mkNEq :: S.Expr -> S.Expr -> SM S.Expr
-mkNEq y1 y2 = do
- ctx <- gets context
- yeq <- liftIO $ S.mkEq ctx y1 y2
- liftIO $ S.mkNot ctx yeq
-
--- -------------------------
diff --git a/src/comp/SAT.hs b/src/comp/SAT.hs
index bb2f019e3..d7775a321 100644
--- a/src/comp/SAT.hs
+++ b/src/comp/SAT.hs
@@ -16,21 +16,16 @@ import Flags
import ASyntax
import Position(cmdPosition)
-import qualified AExpr2STP as STP
- (SState, initSState, checkBiImplication, isConstExpr,
- checkEq, checkNotEq)
import qualified AExpr2Yices as Yices
(YState, initYState, checkBiImplication, isConstExpr,
checkEq, checkNotEq)
-import STP(checkVersion)
import Yices(checkVersion)
-- -------------------------
-- A single data type for either of the solver state
data SATState = SATS_Yices Yices.YState
- | SATS_STP STP.SState
-- -------------------------
@@ -41,9 +36,6 @@ initSATState str errh flags doHardFail ds avis =
SAT_Yices -> do
yices_state <- Yices.initYState str flags doHardFail ds avis []
return (SATS_Yices yices_state)
- SAT_STP -> do
- stp_state <- STP.initSState str flags doHardFail ds avis []
- return (SATS_STP stp_state)
checkSATFlags :: ErrorHandle -> Flags -> IO Flags
@@ -54,9 +46,6 @@ checkSATFlags eh f =
handler _ = return False
in CE.catch (Yices.checkVersion >> return True) handler
- hasSTP :: IO Bool
- hasSTP = STP.checkVersion
-
checkFn :: String -> String -> IO Bool -> IO Flags
checkFn flag_str lib_str hasFn = do
res <- hasFn
@@ -68,7 +57,6 @@ checkSATFlags eh f =
WSATNotAvailable flag_str lib_str Nothing)]
in case (satBackend f) of
SAT_Yices -> checkFn "-sat-yices" "libyices.so.2" hasYices
- SAT_STP -> checkFn "-sat-stp" "libstp.so" hasSTP
-- -------------------------
@@ -76,35 +64,20 @@ checkBiImplication :: SATState -> AExpr -> AExpr -> IO ((Bool, Bool), SATState)
checkBiImplication (SATS_Yices yices_state) e1 e2 = do
(res, yices_state') <- Yices.checkBiImplication yices_state e1 e2
return (res, SATS_Yices yices_state')
-checkBiImplication (SATS_STP stp_state) e1 e2 = do
- (res, stp_state') <- STP.checkBiImplication stp_state e1 e2
- return (res, SATS_STP stp_state')
-
isConstExpr :: SATState -> AExpr -> IO (Maybe Bool, SATState)
isConstExpr (SATS_Yices yices_state) e = do
(res, yices_state') <- Yices.isConstExpr yices_state e
return (res, SATS_Yices yices_state')
-isConstExpr (SATS_STP stp_state) e = do
- (res, stp_state') <- STP.isConstExpr stp_state e
- return (res, SATS_STP stp_state')
-
checkEq :: SATState -> AExpr -> AExpr -> IO (Maybe Bool, SATState)
checkEq (SATS_Yices yices_state) e1 e2 = do
(res, yices_state') <- Yices.checkEq yices_state e1 e2
return (res, SATS_Yices yices_state')
-checkEq (SATS_STP stp_state) e1 e2 = do
- (res, stp_state') <- STP.checkEq stp_state e1 e2
- return (res, SATS_STP stp_state')
-
checkNotEq :: SATState -> AExpr -> AExpr -> IO (Maybe Bool, SATState)
checkNotEq (SATS_Yices yices_state) e1 e2 = do
(res, yices_state') <- Yices.checkNotEq yices_state e1 e2
return (res, SATS_Yices yices_state')
-checkNotEq (SATS_STP stp_state) e1 e2 = do
- (res, stp_state') <- STP.checkNotEq stp_state e1 e2
- return (res, SATS_STP stp_state')
-- -------------------------
diff --git a/src/comp/SATPred.hs b/src/comp/SATPred.hs
index 62e83dad6..d9fd6bf37 100644
--- a/src/comp/SATPred.hs
+++ b/src/comp/SATPred.hs
@@ -7,52 +7,29 @@ module SATPred(
import Flags
import Pred
-import qualified Pred2STP as STP
- (SState, initSState, solvePred)
import qualified Pred2Yices as Yices
(YState, initYState, solvePred)
-- -------------------------
-- A single data type for any of the solver state
--- For now, we always use STP for this
data SATPredState =
- SATPredS_STP STP.SState
- | SATPredS_Yices Yices.YState
+ SATPredS_Yices Yices.YState
-- -------------------------
initSATPredState :: Flags -> IO SATPredState
initSATPredState flags = do
case (satBackend flags) of
- SAT_STP -> do
- stp_state <- STP.initSState
- return (SATPredS_STP stp_state)
SAT_Yices -> do
yices_state <- Yices.initYState
return (SATPredS_Yices yices_state)
-- -------------------------
-{-
-checkPreds :: SATPredState -> [Pred] -> IO ([EMsg], SATPredState)
-checkPreds (SATPredS_STP stp_state) ps = do
- (res, stp_state') <- STP.checkPreds stp_state ps
- return (res, SATPredS_STP stp_state')
-checkPreds (SATPredS_Yices yices_state) ps = do
- (res, yices_state') <- Yices.checkPreds yices_state ps
- return (res, SATPredS_Yices yices_state')
--}
-
--- -------------------------
-
solvePred :: SATPredState -> [Pred] -> Pred -> IO (Maybe Pred, SATPredState)
-solvePred (SATPredS_STP stp_state) ps p = do
- (res, stp_state') <- STP.solvePred stp_state ps p
- return (res, SATPredS_STP stp_state')
solvePred (SATPredS_Yices yices_state) ps p = do
(res, yices_state') <- Yices.solvePred yices_state ps p
return (res, SATPredS_Yices yices_state')
-- -------------------------
-
diff --git a/src/vendor/stp/.gitignore b/src/vendor/stp/.gitignore
deleted file mode 100644
index d3ab1ac0f..000000000
--- a/src/vendor/stp/.gitignore
+++ /dev/null
@@ -1,28 +0,0 @@
-include
-lib
-include_hs
-
-*.o
-*.a
-*.or
-
-# Ignore generated libraries
-libstp.so
-libstp.so.*
-
-# Makefile depenencies
-depend.mk
-depend
-
-# Yex/yacc parser code
-src/parser/lexcvc.*
-src/parser/lexsmt.*
-src/parser/lexsmt2.*
-src/parser/parsecvc.*
-src/parser/parsesmt.*
-src/parser/parsesmt2.*
-
-#
-src/AST/ASTKind.cpp
-src/AST/ASTKind.h
-
diff --git a/src/vendor/stp/HaskellIfc/STP.hs b/src/vendor/stp/HaskellIfc/STP.hs
deleted file mode 100644
index 59fa198e1..000000000
--- a/src/vendor/stp/HaskellIfc/STP.hs
+++ /dev/null
@@ -1,738 +0,0 @@
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE TypeSynonymInstances #-}
-{-# LANGUAGE CPP #-}
-
-module STP (
-
- -- * Core STP types
- Context,
- Type,
- Expr,
- Result(..),
-
- -- Check that the dynamic library is compatible
- -- with this FFI (and not a stub)
- checkVersion,
-
- -- * Manipulating contexts
- mkContext,
- ctxPush,
- ctxPop,
- deleteExpr, deleteExprs,
-
- -- * Debug
- setPrintVarDecls,
- setPrintAsserts,
- setPrintQuery,
- setClearDecls,
- printExpr,
- setFlag,
-
- -- * Making assertions
- assert,
-
- -- * Queries
- query,
- queryWithTimeout,
- isBool,
-
- -- * STP Types
- mkBoolType,
- mkBitVectorType,
-
- -- * STP Expressions
-
- -- ** Type conversion
- mkBoolToBitVector,
-
- -- ** Variables
- mkVar,
-
- -- ** Constants
- mkTrue, mkFalse,
- mkBVConstantFromInteger,
-
- -- ** Logical operators
- mkEq,
- mkNot,
- mkAnd, mkAndMany,
- mkOr, mkOrMany,
- mkXor,
- mkImplies,
- mkIff,
- mkIte,
-
- -- ** Bit-vector arithmetic
- mkBVAdd, mkBVAddMany,
- mkBVSub, mkBVMul, mkBVDiv, mkBVMod,
- mkBVSignedDiv, mkBVSignedMod,
- mkBVMinus,
-
- -- ** Bit-vector comparisons
- mkBVLt, mkBVLe,
- mkBVGt, mkBVGe,
-
- mkBVSlt, mkBVSle,
- mkBVSgt, mkBVSge,
-
- -- ** Bitwise operations
- mkBVAnd, mkBVOr, mkBVXor,
- mkBVNot,
-
- -- ** Bit-vector shifting and signs
- mkBVSignExtend,
- mkBVShiftLeft, mkBVShiftRight,
- mkBVShiftLeftExpr, mkBVShiftRightExpr, mkBVSignedShiftRightExpr,
-
-
- -- ** Bit-vector strings
- mkBVConcat,
- mkBVExtract, mkBVBoolExtract
-
- ) where
-
-import STPFFI
-
-import Foreign
-import Foreign.C.String
-import Foreign.C.Types
-import qualified Foreign.Concurrent as F
-
---import Control.Concurrent.MVar.Strict
-import MVarStrict
-
-import ErrorUtil(internalError)
-import System.Posix.Env(getEnvDefault)
---import Util(traceM)
-
-
-cullong_size :: Int
-cullong_size = finiteBitSize (0 :: CULLong)
-
-------------------------------------------------------------------------
--- Types
-
--- | An STP /context/
---
--- A context is an environment of assertions.
---
--- /Notes:/
---
--- * The resource is automatically managed by the Haskell garbage
--- collector, and the structure is automatically deleted once it is out
--- of scope (no need to call 'vc_Destroy'.)
---
--- * Improving on the C API, we maintain a stack depth, to prevent errors
--- relating to uneven numbers of 'push' and 'pop' operations. 'pop' on a
--- zero depth stack leaves the stack at zero.
---
-data Context = Context { sContext :: ForeignPtr SContext
- , sDepth :: !(MVar Integer)
- }
- deriving Eq
-
--- | STP types
---
-newtype Type = Type { unType :: Ptr SType }
- deriving (Eq, Ord, Show, Storable)
-
--- | STP /expressions/
---
-newtype Expr = Expr { unExpr :: Ptr SExpr }
- deriving (Eq, Ord, Show, Storable)
-
--- The return type for queries
-data Result
- = Invalid
- | Valid
- | Error
- | Timeout
- deriving (Eq, Ord, Enum, Bounded, Read, Show)
-
-toResult :: CInt -> Result
-toResult n
- | n == 0 = Invalid
- | n == 1 = Valid
- | n == 2 = Error
- | n == 3 = Timeout
- | otherwise = internalError("STP.toResult: " ++ show n)
-
--- Name of environment variable contain flags
-flagEnvironment :: String
-flagEnvironment = "BSC_STP_FLAGS"
-
-------------------------------------------------------------------------
-
-checkVersion :: IO Bool
-checkVersion = do
- -- The API doesn't provide version info
- -- so all we can do is check for a stub
- ptr <- vc_createValidityChecker
- return (ptr /= nullPtr)
-
-------------------------------------------------------------------------
--- Context manipulation
-
--- | Create a new logical context.
--- When the context goes out of scope, it will be automatically deleted.
---
-mkContext :: IO Context
-mkContext = do
- ptr <- vc_createValidityChecker
- --traceM("==> vc created: " ++ show ptr)
- make_division_total ptr
- fp <- F.newForeignPtr ptr (do --traceM("==> vc destryoy: " ++ show ptr)
- --vc_Destroy ptr
- --traceM("==> destroyed")
- return ()
- )
- n <- newMVar 0
- envFlags <- getEnvDefault flagEnvironment ""
- mapM_ (setFlag ptr) envFlags
- return $! Context fp n
-
--- | Create a backtracking point in the given logical context.
---
--- The logical context can be viewed as a stack of contexts. The scope
--- level is the number of elements on this stack. The stack of contexts
--- is simulated using trail (undo) stacks.
---
-ctxPush :: Context -> IO ()
-ctxPush c = modifyMVar_ (sDepth c) $ \n ->
- if n < 0
- then error "STP.ctxPush: Corrupted Context. Stack depth < 0"
- else do
- withForeignPtr (sContext c) $ vc_push
- return (n+1)
-
--- | Backtrack.
---
--- Restores the context from the top of the stack, and pops it off the
--- stack. Any changes to the logical context (by 'vc_assertFormula' or
--- other functions) between the matching 'push' and 'pop' operators are
--- flushed, and the context is completely restored to what it was right
--- before the 'push'.
---
-ctxPop :: Context -> IO ()
-ctxPop c = modifyMVar_ (sDepth c) $ \n -> case () of
- _ | n < 0 -> error "STP.mkPop: Corrupted context. Stack depth < 0"
- | n == 0 -> return n
- | otherwise -> do
- withForeignPtr (sContext c) $ vc_pop
- return (n-1)
-
-------------------------------------------------------------------------
--- Debug
-
-setPrintVarDecls :: Context -> IO ()
-setPrintVarDecls c = withForeignPtr (sContext c) vc_printVarDecls
-
-setPrintAsserts :: Context -> IO ()
-setPrintAsserts c = withForeignPtr (sContext c) vc_printAsserts
-
-setPrintQuery :: Context -> IO ()
-setPrintQuery c = withForeignPtr (sContext c) vc_printQuery
-
-setClearDecls :: Context -> IO ()
-setClearDecls c = withForeignPtr (sContext c) vc_clearDecls
-
-printExpr :: Context -> Expr -> IO ()
-printExpr c e = do
- withForeignPtr (sContext c) $ \cptr -> vc_printExpr cptr (unExpr e)
- putChar '\n'
-
-------------------------------------------------------------------------
--- Assertions
-
--- | Assert a constraint in the logical context.
---
-assert :: Context -> Expr -> IO ()
-assert c e = withForeignPtr (sContext c) $ \cptr ->
- vc_assertFormula cptr (unExpr e)
-
-------------------------------------------------------------------------
--- Queries
-
--- | Check if an expression is satisfiable given the logical context.
---
--- * @Invalid@ means the expression is unsatisfiable in the context.
---
--- * @Valid@ means the expression is satisfiable in the context.
---
--- * @Error@ means that an error was encountered.
---
--- * @Timeout@ means it was not possible to decide in the given time.
---
-query :: Context -> Expr -> IO Result
-query c e = toResult <$>
- withForeignPtr (sContext c) (\cptr -> vc_query cptr (unExpr e))
-
-queryWithTimeout :: Context -> Expr -> Int -> IO Result
-queryWithTimeout c e msecs = toResult <$>
- withForeignPtr (sContext c)
- (\cptr -> vc_query_with_timeout cptr (unExpr e) (fromIntegral msecs))
-
--- | Determine whether an expression is True or False ?
---
--- Note that this takes no Context! What is this function?!
---
-isBool :: Expr -> IO (Maybe Bool)
-isBool e = do
- res <- vc_isBool (unExpr e)
- case res of
- 1 -> return $ Just True
- 0 -> return $ Just False
- -1 -> return $ Nothing
- _ -> internalError ("STP.isBool: " ++ show res)
-
-------------------------------------------------------------------------
--- Types
-
--- | Return the for booleans.
---
-mkBoolType :: Context -> IO Type
-mkBoolType c =
- withForeignPtr (sContext c) $ \cptr ->
- Type <$> vc_boolType cptr
-
--- | Returns a bitvector type of @n@ size.
---
--- Size must be greater than @0@.
---
-mkBitVectorType :: Context -> Int -> IO Type
-mkBitVectorType _ n | (n < 1) =
- internalError ("STP.mkBitVectorType: " ++ show n)
-mkBitVectorType c n =
- withForeignPtr (sContext c) $ \cptr ->
- Type <$> vc_bvType cptr (fromIntegral n)
-
-------------------------------------------------------------------------
--- Type conversion
-
-mkBoolToBitVector :: Context -> Expr -> IO Expr
-mkBoolToBitVector c e =
- withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_boolToBVExpr cptr (unExpr e)
-
-------------------------------------------------------------------------
--- Variables
-
-mkVar :: Context -> String -> Type -> IO Expr
-mkVar c str t =
- withCString str $ \cstr ->
- withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_varExpr cptr cstr (unType t)
-
-------------------------------------------------------------------------
--- Constants
-
--- | Return an expression representing 'True'.
---
-mkTrue :: Context -> IO Expr
-mkTrue c = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_trueExpr cptr
-
--- | Return an expression representing 'False'.
---
-mkFalse :: Context -> IO Expr
-mkFalse c = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_falseExpr cptr
-
--- | Create a bit vector constant of size bits and of the given value.
---
--- @size@ must be positive
---
-mkBVConstantFromInteger :: Context -> Integer -> Integer -> IO Expr
-mkBVConstantFromInteger _ width _ | (width < 1) =
- internalError ("STP.mkBVConstantFromInteger: " ++ show width)
-mkBVConstantFromInteger c width val | fitsInCULLong =
- withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvConstExprFromLL cptr (fromInteger width) (fromInteger val)
- where fitsInCULLong = (fromInteger width) <= cullong_size
-mkBVConstantFromInteger c width val =
- -- XXX is it more efficient to create a concat of Word64 values?
- withForeignPtr (sContext c) $ \cptr ->
- makeVPtrWith width val $ \vptr ->
- Expr <$> vc_bvConstExprFromStr cptr (castPtr vptr)
-
-makeVPtrWith :: Integer -> Integer -> (CString -> IO b) -> IO b
-makeVPtrWith width val f =
- let -- We could use "showIntAtBase", but then we should check to
- -- make sure the width is correct.
- -- This should rarely be needed, so don't worry about efficiency.
- mkBit idx = if (testBit val idx) then '1' else '0'
- str = map mkBit $ reverse [0 .. fromInteger (width-1)]
- in withCString str f
-
-------------------------------------------------------------------------
--- Logical operations
-
--- | Return an expression representing:
---
--- > a1 == a2
---
-mkEq :: Context -> Expr -> Expr -> IO Expr
-mkEq c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_eqExpr cptr (unExpr e1) (unExpr e2)
-
--- | Return an expression representing:
---
--- > not a
---
-mkNot :: Context -> Expr -> IO Expr
-mkNot c e = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_notExpr cptr (unExpr e)
-
--- | Return an expression representing the binary /AND/ of the given arguments.
---
-mkAnd :: Context -> Expr -> Expr -> IO Expr
-mkAnd c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_andExpr cptr (unExpr e1) (unExpr e2)
-
--- | Return an expression representing the /n/-ary /AND/ of the given arguments.
---
--- > and [a1, ..]
---
--- Reference:
---
-mkAndMany :: Context -> [Expr] -> IO Expr
-mkAndMany _ [] = error "STP.mkAndMany: empty list of expressions"
-mkAndMany c es =
- withArray es $ \aptr ->
- withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_andExprN cptr (castPtr aptr) (fromIntegral (length es))
-
--- | Return an expression representing the binary /OR/ of the given arguments.
---
-mkOr :: Context -> Expr -> Expr -> IO Expr
-mkOr c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_orExpr cptr (unExpr e1) (unExpr e2)
-
--- | Return an expression representing the /n/-ary /OR/ of the given arguments.
---
--- > or [a1, ..]
---
-mkOrMany :: Context -> [Expr] -> IO Expr
-mkOrMany _ [] = error "STP.mkOrMany: empty list of expressions"
-mkOrMany c es =
- withArray es $ \aptr ->
- withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_orExprN cptr (castPtr aptr) (fromIntegral (length es))
-
--- | Return an expression representing the binary /XOR/ of the given arguments.
---
-mkXor :: Context -> Expr -> Expr -> IO Expr
-mkXor c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_xorExpr cptr (unExpr e1) (unExpr e2)
-
--- | Return an expression representing:
---
--- > e1 implies e2
---
-mkImplies :: Context -> Expr -> Expr -> IO Expr
-mkImplies c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_impliesExpr cptr (unExpr e1) (unExpr e2)
-
--- | Return an expression representing:
---
--- > e1 if-and-only-if e2
---
-mkIff :: Context -> Expr -> Expr -> IO Expr
-mkIff c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_iffExpr cptr (unExpr e1) (unExpr e2)
-
--- | Return an expression representing:
---
--- > if b then e1 else e2
---
-mkIte :: Context -> Expr -> Expr -> Expr -> IO Expr
-mkIte c b e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_iteExpr cptr (unExpr b) (unExpr e1) (unExpr e2)
-
-------------------------------------------------------------------------
--- Bit-vector arithmetic
-
--- | Bitvector addition.
---
--- @a1@ and @a2@ must be bitvector expressions of same size.
---
-mkBVAdd :: Context -> Int -> Expr -> Expr -> IO Expr
-mkBVAdd c n e1 e2 =
- withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvPlusExpr cptr (fromIntegral n) (unExpr e1) (unExpr e2)
-
--- | Bitvector addition of a list of expressions
---
--- The expression list must be non-empty.
---
-mkBVAddMany :: Context -> Int -> [Expr] -> IO Expr
-mkBVAddMany c n es =
- withArray es $ \esptr ->
- withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvPlusExprN cptr (fromIntegral n)
- (castPtr esptr) (fromIntegral (length es))
-
--- | Bitvector subtraction.
---
--- @a1@ and @a2@ must be bitvector expressions of same size.
---
-mkBVSub :: Context -> Int -> Expr -> Expr -> IO Expr
-mkBVSub c n e1 e2 =
- withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvMinusExpr cptr (fromIntegral n) (unExpr e1) (unExpr e2)
-
--- | Bitvector multiplication.
---
--- @a1@ and @a2@ must be bitvector expressions of same size.
--- (The result is truncated to that size?)
---
-mkBVMul :: Context -> Int -> Expr -> Expr -> IO Expr
-mkBVMul c n e1 e2 =
- withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvMultExpr cptr (fromIntegral n) (unExpr e1) (unExpr e2)
-
--- | Bitvector division
---
--- @a1@ and @a2@ must be bitvector expressions of same size.
---
-mkBVDiv :: Context -> Int -> Expr -> Expr -> IO Expr
-mkBVDiv c n e1 e2 =
- withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvDivExpr cptr (fromIntegral n) (unExpr e1) (unExpr e2)
-
--- | Bitvector mod
---
--- @a1@ and @a2@ must be bitvector expressions of same size.
---
-mkBVMod :: Context -> Int -> Expr -> Expr -> IO Expr
-mkBVMod c n e1 e2 =
- withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvModExpr cptr (fromIntegral n) (unExpr e1) (unExpr e2)
-
--- | Bitvector division (signed)
---
--- @a1@ and @a2@ must be bitvector expressions of same size.
---
-mkBVSignedDiv :: Context -> Int -> Expr -> Expr -> IO Expr
-mkBVSignedDiv c n e1 e2 =
- withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_sbvDivExpr cptr (fromIntegral n) (unExpr e1) (unExpr e2)
-
--- | Bitvector mod (signed)
---
--- @a1@ and @a2@ must be bitvector expressions of same size.
---
-mkBVSignedMod :: Context -> Int -> Expr -> Expr -> IO Expr
-mkBVSignedMod c n e1 e2 =
- withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_sbvModExpr cptr (fromIntegral n) (unExpr e1) (unExpr e2)
-
--- | Bitvector uniary minus.
---
--- @a1@ must be bitvector expression. The result is @(- a1)@.
---
-mkBVMinus :: Context -> Expr -> IO Expr
-mkBVMinus c e = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvUMinusExpr cptr (unExpr e)
-
-------------------------------------------------------------------------
--- Bit-vector comparisons
-
--- | Unsigned bitvector comparison:
---
--- > a1 < a2
---
--- /a1/ and /a2/ must be bitvector expressions of same size.
---
-mkBVLt :: Context -> Expr -> Expr -> IO Expr
-mkBVLt c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvLtExpr cptr (unExpr e1) (unExpr e2)
-
--- | Unsigned bitvector comparison:
---
--- > a1 <= a2
---
--- /a1/ and /a2/ must be bitvector expressions of same size.
---
-mkBVLe :: Context -> Expr -> Expr -> IO Expr
-mkBVLe c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvLeExpr cptr (unExpr e1) (unExpr e2)
-
--- | Unsigned bitvector comparison:
---
--- > a1 > a2
---
--- /a1/ and /a2/ must be bitvector expressions of same size.
---
-mkBVGt :: Context -> Expr -> Expr -> IO Expr
-mkBVGt c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvGtExpr cptr (unExpr e1) (unExpr e2)
-
--- | Unsigned bitvector comparison:
---
--- > a1 >= a2
---
--- /a1/ and /a2/ must be bitvector expressions of same size.
---
-mkBVGe :: Context -> Expr -> Expr -> IO Expr
-mkBVGe c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvGeExpr cptr (unExpr e1) (unExpr e2)
-
--- | Signed bitvector comparison:
---
--- > a1 < a2
---
--- /a1/ and /a2/ must be bitvector expressions of same size.
---
-mkBVSlt :: Context -> Expr -> Expr -> IO Expr
-mkBVSlt c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_sbvLtExpr cptr (unExpr e1) (unExpr e2)
-
--- | Signed bitvector comparison:
---
--- > a1 <= a2
---
--- /a1/ and /a2/ must be bitvector expressions of same size.
---
-mkBVSle :: Context -> Expr -> Expr -> IO Expr
-mkBVSle c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_sbvLeExpr cptr (unExpr e1) (unExpr e2)
-
--- | Signed bitvector comparison:
---
--- > a1 > a2
---
--- /a1/ and /a2/ must be bitvector expressions of same size.
---
-mkBVSgt :: Context -> Expr -> Expr -> IO Expr
-mkBVSgt c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_sbvGtExpr cptr (unExpr e1) (unExpr e2)
-
--- | Signed bitvector comparison:
---
--- > a1 >= a2
---
--- /a1/ and /a2/ must be bitvector expressions of same size.
---
-mkBVSge :: Context -> Expr -> Expr -> IO Expr
-mkBVSge c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_sbvGeExpr cptr (unExpr e1) (unExpr e2)
-
-------------------------------------------------------------------------
--- Bit-wise operations
-
--- | Bitwise @and@.
---
--- /a1/ and /a2/ must be bitvector expressions of same size.
---
-mkBVAnd :: Context -> Expr -> Expr -> IO Expr
-mkBVAnd c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvAndExpr cptr (unExpr e1) (unExpr e2)
-
--- | Bitwise @or@.
---
--- /a1/ and /a2/ must be bitvector expressions of same size.
---
-mkBVOr :: Context -> Expr -> Expr -> IO Expr
-mkBVOr c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvOrExpr cptr (unExpr e1) (unExpr e2)
-
--- | Bitwise @xor@.
---
--- /a1/ and /a2/ must be bitvector expressions of same size.
---
-mkBVXor :: Context -> Expr -> Expr -> IO Expr
-mkBVXor c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvXorExpr cptr (unExpr e1) (unExpr e2)
-
--- | Bitwise negation.
---
-mkBVNot :: Context -> Expr -> IO Expr
-mkBVNot c e = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvNotExpr cptr (unExpr e)
-
-------------------------------------------------------------------------
--- Bit-vector shifting and signs
-
--- | Sign extension.
---
--- Append /n/ times the most-significant bit of to the left of /a/.
---
-mkBVSignExtend :: Context -> Expr -> Int -> IO Expr
-mkBVSignExtend c e n = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvSignExtend cptr (unExpr e) (fromIntegral n)
-
--- | Left shift by n bits, padding with zeros.
---
-mkBVShiftLeft :: Context -> Expr -> Int -> IO Expr
-mkBVShiftLeft c e n = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvLeftShiftExpr cptr (fromIntegral n) (unExpr e)
-
-
--- | Right shift by n bits, padding with zeros.
---
-mkBVShiftRight :: Context -> Expr -> Int -> IO Expr
-mkBVShiftRight c e n = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvRightShiftExpr cptr (fromIntegral n) (unExpr e)
-
--- | Dynamic shift operations
-mkBVShiftLeftExpr :: Context -> Int -> Expr -> Expr -> IO Expr
-mkBVShiftLeftExpr c n e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvLeftShiftExprExpr cptr (fromIntegral n) (unExpr e1) (unExpr e2)
-
-mkBVShiftRightExpr :: Context -> Int -> Expr -> Expr -> IO Expr
-mkBVShiftRightExpr c n e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvRightShiftExprExpr cptr (fromIntegral n) (unExpr e1) (unExpr e2)
-
-mkBVSignedShiftRightExpr :: Context -> Int -> Expr -> Expr -> IO Expr
-mkBVSignedShiftRightExpr c n e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvSignedRightShiftExprExpr cptr (fromIntegral n) (unExpr e1) (unExpr e2)
-
-------------------------------------------------------------------------
--- Bit vector strings
-
--- | Bitvector concatenation.
---
--- @a1@ and @a2@ must be two bitvector expressions.
--- @a1@ is the left part of the result and @a2@ the right part.
---
--- Assuming /a1/ and /a2/ have /n1/ and /n2/ bits, respectively, then the
--- result is a bitvector concat of size /n1 + n2/. Bit 0 of concat is bit 0 of
--- /a2/ and bit n2 of concat is bit 0 of /a1/.
---
-mkBVConcat :: Context -> Expr -> Expr -> IO Expr
-mkBVConcat c e1 e2 = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvConcatExpr cptr (unExpr e1) (unExpr e2)
-
--- | Bitvector extraction.
---
--- The first @Int@ argument is the initial index, the second is the end index.
--- /Note/: this is reversed wrt. the C API.
---
--- /a/ must a bitvector expression of size /n/ with @begin < end < n@.
--- The result is the subvector slice @a[begin .. end]@.
---
-mkBVExtract :: Context -> Int -> Int -> Expr -> IO Expr
-mkBVExtract c begin end e = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvExtract cptr (unExpr e)
- (fromIntegral end) (fromIntegral begin)
-
--- | Bitvector extraction to Boolean result
---
--- > x[bit_no:bit_no] == 1
---
-mkBVBoolExtract :: Context -> Int -> Expr -> IO Expr
-mkBVBoolExtract c idx e = withForeignPtr (sContext c) $ \cptr ->
- Expr <$> vc_bvBoolExtract_One cptr (unExpr e) (fromIntegral idx)
-
-------------------------------------------------------------------------
-
-deleteExpr :: Expr -> IO ()
-deleteExpr = vc_DeleteExpr . unExpr
-
-deleteExprs :: [Expr] -> IO ()
-deleteExprs = mapM_ deleteExpr
-
-
-setFlag :: Ptr SContext -> Char -> IO ()
-setFlag c f = vc_setFlag c (castCharToCChar f)
diff --git a/src/vendor/stp/HaskellIfc/STPFFI.hs b/src/vendor/stp/HaskellIfc/STPFFI.hs
deleted file mode 100644
index c5908acbb..000000000
--- a/src/vendor/stp/HaskellIfc/STPFFI.hs
+++ /dev/null
@@ -1,378 +0,0 @@
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE EmptyDataDecls #-}
--- LANGUAGE GeneralizedNewtypeDeriving
-
-module STPFFI (
-
- -- * C types
- SContext,
- SType,
- SExpr,
-
- -- * Context manipulation
- vc_createValidityChecker,
- vc_Destroy,
- vc_DeleteExpr,
- vc_DeleteExprFun,
-
- vc_push,
- vc_pop,
-
- -- * Debug
- vc_printVarDecls,
- vc_printAsserts,
- vc_printQuery,
- vc_clearDecls,
- vc_printExpr,
- --vc_exprString,
- --vc_typeString,
- vc_setFlag,
-
- -- * Assertions
- vc_assertFormula,
-
- -- * Solving
- vc_query,
- vc_query_with_timeout,
- vc_isBool,
-
- -- * Types
- vc_boolType,
- vc_bvType,
-
- -- * Expressions
-
- -- ** Type conversion
- vc_boolToBVExpr,
-
- -- ** Variables
- vc_varExpr,
-
- -- ** Constants
- vc_trueExpr,
- vc_falseExpr,
- vc_bvConstExprFromDecStr,
- vc_bvConstExprFromStr,
- --vc_bvConstExprFromInt,
- vc_bvConstExprFromLL,
-
- -- ** Logical operators
- vc_eqExpr,
- vc_notExpr,
- vc_andExpr,
- vc_andExprN,
- vc_orExpr,
- vc_orExprN,
- vc_xorExpr,
- vc_impliesExpr,
- vc_iffExpr,
- vc_iteExpr,
-
- -- ** Bit vector arithmetic
- vc_bvPlusExpr,
- vc_bvPlusExprN,
- vc_bvMinusExpr,
- vc_bvMultExpr,
- vc_bvDivExpr,
- vc_bvModExpr,
- vc_sbvDivExpr,
- vc_sbvModExpr,
-
- vc_bvUMinusExpr,
-
- -- ** Comparisons
- vc_bvLtExpr,
- vc_bvLeExpr,
- vc_bvGtExpr,
- vc_bvGeExpr,
-
- vc_sbvLtExpr,
- vc_sbvLeExpr,
- vc_sbvGtExpr,
- vc_sbvGeExpr,
-
- -- ** Bitwise operations
- vc_bvAndExpr,
- vc_bvOrExpr,
- vc_bvXorExpr,
- vc_bvNotExpr,
-
- -- ** Shifting and signs
- vc_bvSignExtend,
- vc_bvLeftShiftExpr,
- vc_bvRightShiftExpr,
-
- vc_bvLeftShiftExprExpr,
- vc_bvRightShiftExprExpr,
- vc_bvSignedRightShiftExprExpr,
-
- -- ** Bit vector /string/ operations
- vc_bvConcatExpr,
- vc_bvExtract,
- vc_bvBoolExtract_Zero,
- vc_bvBoolExtract_One,
-
- make_division_total,
-
- ) where
-
-import Foreign
-import Foreign.C.Types
-import Foreign.C.String
-
-------------------------------------------------------------------------
--- Types
-
--- | Abstract type representing an STP context.
---
-data SContext
-
--- | Abstract type representing an STP expression.
---
-data SExpr
-
--- | Abstract type representing an STP type.
---
-data SType
-
-------------------------------------------------------------------------
--- Function bindings
-
--- Contexts
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_createValidityChecker :: IO (Ptr SContext)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_Destroy :: Ptr SContext -> IO ()
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_DeleteExpr :: Ptr SExpr -> IO ()
-
--- Function pointer
-foreign import ccall unsafe "stp_c_interface.h &vc_DeleteExpr"
- vc_DeleteExprFun :: FunPtr (Ptr SExpr -> IO ())
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_push :: Ptr SContext -> IO ()
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_pop :: Ptr SContext -> IO ()
-
--- Debug
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_printVarDecls :: Ptr SContext -> IO ()
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_printAsserts :: Ptr SContext -> IO ()
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_printQuery :: Ptr SContext -> IO ()
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_clearDecls :: Ptr SContext -> IO ()
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_printExpr :: Ptr SContext -> Ptr SExpr -> IO ()
-
--- Assertions
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_assertFormula :: Ptr SContext -> Ptr SExpr -> IO ()
-
--- Solving
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_query :: Ptr SContext -> Ptr SExpr -> IO CInt
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_query_with_timeout :: Ptr SContext -> Ptr SExpr -> CInt -> IO CInt
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_isBool :: Ptr SExpr -> IO CInt
-
--- Types
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_boolType :: Ptr SContext -> IO (Ptr SType)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvType :: Ptr SContext -> CInt -> IO (Ptr SType)
-
--- Type conversion
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_boolToBVExpr :: Ptr SContext -> Ptr SExpr -> IO (Ptr SExpr)
-
--- Variables
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_varExpr :: Ptr SContext -> CString -> Ptr SType -> IO (Ptr SExpr)
-
--- Constants
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_trueExpr :: Ptr SContext -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_falseExpr :: Ptr SContext -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvConstExprFromDecStr :: Ptr SContext -> CString -> Ptr SType -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvConstExprFromStr :: Ptr SContext -> CString -> IO (Ptr SExpr)
-
-{-
--- This merely casts the value to CULLong, so might as well always call
--- vc_bvConstExprFromLL instead.
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvConstExprFromInt :: Ptr SContext -> CInt -> CUInt -> IO (Ptr SExpr)
--}
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvConstExprFromLL :: Ptr SContext -> CInt -> CULLong -> IO (Ptr SExpr)
-
--- Logical operations
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_eqExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_notExpr :: Ptr SContext -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_andExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_andExprN :: Ptr SContext -> Ptr (Ptr SExpr) -> CInt -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_orExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_orExprN :: Ptr SContext -> Ptr (Ptr SExpr) -> CInt -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_xorExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_impliesExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_iffExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_iteExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
--- Bit vector arithmetic
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvPlusExpr :: Ptr SContext -> CInt -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvPlusExprN :: Ptr SContext -> CInt -> Ptr (Ptr SExpr) -> CInt -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvMinusExpr :: Ptr SContext -> CInt -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvMultExpr :: Ptr SContext -> CInt -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvDivExpr :: Ptr SContext -> CInt -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvModExpr :: Ptr SContext -> CInt -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_sbvDivExpr :: Ptr SContext -> CInt -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_sbvModExpr :: Ptr SContext -> CInt -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvUMinusExpr :: Ptr SContext -> Ptr SExpr -> IO (Ptr SExpr)
-
--- Comparisons
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvLtExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvLeExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvGtExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvGeExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_sbvLtExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_sbvLeExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_sbvGtExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_sbvGeExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
--- Bitwise Operations
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvAndExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvOrExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvXorExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvNotExpr :: Ptr SContext -> Ptr SExpr -> IO (Ptr SExpr)
-
--- Shifting and signs
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvSignExtend :: Ptr SContext -> Ptr SExpr -> CInt -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvLeftShiftExpr :: Ptr SContext -> CInt -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvRightShiftExpr :: Ptr SContext -> CInt -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvLeftShiftExprExpr :: Ptr SContext -> CInt -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvRightShiftExprExpr :: Ptr SContext -> CInt -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvSignedRightShiftExprExpr :: Ptr SContext -> CInt -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-
--- Bit vector /string/ operations
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvConcatExpr :: Ptr SContext -> Ptr SExpr -> Ptr SExpr -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvExtract :: Ptr SContext -> Ptr SExpr -> CInt -> CInt -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvBoolExtract_Zero :: Ptr SContext -> Ptr SExpr -> CInt -> IO (Ptr SExpr)
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_bvBoolExtract_One :: Ptr SContext -> Ptr SExpr -> CInt -> IO (Ptr SExpr)
-
--- configure and misc features
-foreign import ccall unsafe "stp_c_interface.h"
- make_division_total :: Ptr SContext -> IO ()
-
-foreign import ccall unsafe "stp_c_interface.h"
- vc_setFlag :: Ptr SContext -> CChar -> IO ()
diff --git a/src/vendor/stp/Makefile b/src/vendor/stp/Makefile
deleted file mode 100644
index 092995d7f..000000000
--- a/src/vendor/stp/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-TOP=../../..
-include $(TOP)/platform.mk
-
-PREFIX?=$(TOP)/inst
-
-.PHONY: all install clean full_clean
-
-ifeq ($(STP_STUB),)
-SRC = src
-else
-SRC = src_stub
-endif
-
-ifeq ($(OSTYPE), Darwin)
-SNAME=libstp.dylib
-else
-SNAME=libstp.so.1
-endif
-
-all: install
-
-install:
- $(MAKE) -C $(SRC) install
- ln -fsn HaskellIfc include_hs
- install -m 755 -d $(PREFIX)/lib/SAT
- install -m 644 lib/$(SNAME) $(PREFIX)/lib/SAT
-
-clean:
- $(MAKE) -C $(SRC) clean
-
-full_clean:
- $(MAKE) -C $(SRC) full_clean
- rm -f include_hs
diff --git a/src/vendor/stp/src/AST/AST.h b/src/vendor/stp/src/AST/AST.h
deleted file mode 100644
index 45288527d..000000000
--- a/src/vendor/stp/src/AST/AST.h
+++ /dev/null
@@ -1,112 +0,0 @@
-// -*- c++ -*-
-/********************************************************************
- * AUTHORS: Vijay Ganesh
- *
- * BEGIN DATE: November, 2005
- *
- * LICENSE: Please view LICENSE file in the home dir of this Program
- ********************************************************************/
-
-#ifndef AST_H
-#define AST_H
-#include "UsefulDefs.h"
-#include "ASTNode.h"
-#include "ASTInternal.h"
-#include "ASTInterior.h"
-#include "ASTSymbol.h"
-#include "ASTBVConst.h"
-
-namespace BEEV
-{
- void process_argument(const char ch, STPMgr *bm);
- void FatalError(const char * str, const ASTNode& a, int w = 0) __attribute__ ((noreturn));
- void FatalError(const char * str) __attribute__ ((noreturn));
- void SortByExprNum(ASTVec& c);
- void SortByArith(ASTVec& c);
- bool exprless(const ASTNode n1, const ASTNode n2);
- bool arithless(const ASTNode n1, const ASTNode n2);
- bool isAtomic(Kind k);
- bool isCommutative(const Kind k);
- bool containsArrayOps(const ASTNode&n);
- bool numberOfReadsLessThan(const ASTNode&n, int v);
-
- // If (a > b) in the termorder, then return 1 elseif (a < b) in the
- // termorder, then return -1 else return 0
- int TermOrder(const ASTNode& a, const ASTNode& b);
-
-
- //FUNCTION TypeCheck: Assumes that the immediate Children of the
- //input ASTNode have been typechecked. This function is suitable
- //in scenarios like where you are building the ASTNode Tree, and
- //you typecheck as you go along. It is not suitable as a general
- //typechecker
-
- // NB: The boolean value is always true!
- bool BVTypeCheck(const ASTNode& n);
-
- long getCurrentTime();
-
- ASTVec FlattenKind(Kind k, const ASTVec &children);
-
- // Checks recursively all the way down.
- bool BVTypeCheckRecursive(const ASTNode& n);
-
- //Takes a BVCONST and returns its constant value
- unsigned int GetUnsignedConst(const ASTNode n);
-
- typedef HASHMAP<
- ASTNode,
- ASTNode,
- ASTNode::ASTNodeHasher,
- ASTNode::ASTNodeEqual> ASTNodeMap;
-
- typedef HASHMAP<
- ASTNode,
- int32_t,
- ASTNode::ASTNodeHasher,
- ASTNode::ASTNodeEqual> ASTNodeCountMap;
-
- typedef HASHSET<
- ASTNode,
- ASTNode::ASTNodeHasher,
- ASTNode::ASTNodeEqual> ASTNodeSet;
-
- typedef HASHMULTISET<
- ASTNode,
- ASTNode::ASTNodeHasher,
- ASTNode::ASTNodeEqual> ASTNodeMultiSet;
-
- typedef HASHMAP<
- ASTNode,
- ASTVec,
- ASTNode::ASTNodeHasher,
- ASTNode::ASTNodeEqual> ASTNodeToVecMap;
-
- //Needed for defining the MAP below
- struct ltint
- {
- bool operator()(int s1, int s2) const
- {
- return s1 < s2;
- }
- };
-
- class ClauseList;
-
- //Datatype for ClauseLists
- typedef MAP<
- int,
- ClauseList *,
- ltint> ClauseBuckets;
-
- typedef MAP<
- int,
- ASTVec *,
- ltint> IntToASTVecMap;
-
- // Function to dump contents of ASTNodeMap
- ostream &operator<<(ostream &os, const ASTNodeMap &nmap);
-
- void buildListOfSymbols(const ASTNode& n, ASTNodeSet& visited,ASTNodeSet& symbols);
-}; // end namespace BEEV
-#endif
diff --git a/src/vendor/stp/src/AST/ASTBVConst.cpp b/src/vendor/stp/src/AST/ASTBVConst.cpp
deleted file mode 100644
index 82ba82f1c..000000000
--- a/src/vendor/stp/src/AST/ASTBVConst.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-// -*- c++ -*-
-/********************************************************************
- * AUTHORS: Vijay Ganesh
- *
- * BEGIN DATE: November, 2005
- *
- * LICENSE: Please view LICENSE file in the home dir of this Program
- ********************************************************************/
-
-#include "AST.h"
-#include "../STPManager/STP.h"
-namespace BEEV
-{
- const ASTVec ASTBVConst::astbv_empty_children;
-
- /****************************************************************
- * ASTBVConst Member Function definitions *
- ****************************************************************/
-
- //Constructor
- ASTBVConst::ASTBVConst(CBV bv, unsigned int width) :
- ASTInternal(BVCONST)
- {
- _bvconst = CONSTANTBV::BitVector_Clone(bv);
- _value_width = width;
- cbv_managed_outside =false;
- } //End of ASTBVConst constructor
-
- // Copy constructor.
- ASTBVConst::ASTBVConst(const ASTBVConst &sym) :
- ASTInternal(sym._kind)
- {
- _bvconst = CONSTANTBV::BitVector_Clone(sym._bvconst);
- _value_width = sym._value_width;
- cbv_managed_outside =false;
- } //End of copy constructor()
-
- // Call this when deleting a node that has been stored in the the
- // unique table
- void ASTBVConst::CleanUp()
- {
- (ParserBM)->_bvconst_unique_table.erase(this);
- delete this;
- } //End of Cleanup()
-
- // Print function for bvconst -- return _bvconst value in bin
- // format (c_friendly is for printing hex. numbers that C
- // compilers will accept)
- void ASTBVConst::nodeprint(ostream& os, bool c_friendly)
- {
- unsigned char *res;
- const char *prefix;
-
- if((GlobalSTP->bm)->UserFlags.print_binary_flag) {
- res = CONSTANTBV::BitVector_to_Bin(_bvconst);
- if (c_friendly)
- {
- prefix = "0b";
- }
- else
- {
- prefix = "0bin";
- }
- }
- else if (_value_width % 4 == 0)
- {
- res = CONSTANTBV::BitVector_to_Hex(_bvconst);
- if (c_friendly)
- {
- prefix = "0x";
- }
- else
- {
- prefix = "0hex";
- }
- }
- else
- {
- res = CONSTANTBV::BitVector_to_Bin(_bvconst);
- if (c_friendly)
- {
- prefix = "0b";
- }
- else
- {
- prefix = "0bin";
- }
- }
- if (NULL == res)
- {
- os << "nodeprint: BVCONST : could not convert to string" << _bvconst;
- FatalError("");
- }
- os << prefix << res;
- CONSTANTBV::BitVector_Dispose(res);
- } //End of nodeprint()
-
- // Return the bvconst. It is a const-value
- CBV ASTBVConst::GetBVConst() const
- {
- return _bvconst;
- } //End of GetBVConst()
-
- /****************************************************************
- * Class ASTBVConstHasher and ASTBVConstEqual Functions *
- ****************************************************************/
-
- size_t ASTBVConst::ASTBVConstHasher::operator()(const ASTBVConst * bvc) const
- {
- return CONSTANTBV::BitVector_Hash(bvc->_bvconst);
- } //End of ASTBVConstHasher operator
-
-
- bool ASTBVConst::ASTBVConstEqual::operator()(const ASTBVConst * bvc1,
- const ASTBVConst * bvc2) const
- {
- if (bvc1->_value_width != bvc2->_value_width)
- {
- return false;
- }
- return (0 ==
- CONSTANTBV::BitVector_Compare(bvc1->_bvconst,
- bvc2->_bvconst));
- } //End of ASTBVConstEqual operator
-};//End of namespace
-
diff --git a/src/vendor/stp/src/AST/ASTBVConst.h b/src/vendor/stp/src/AST/ASTBVConst.h
deleted file mode 100644
index 8b4590556..000000000
--- a/src/vendor/stp/src/AST/ASTBVConst.h
+++ /dev/null
@@ -1,129 +0,0 @@
-// -*- c++ -*-
-/********************************************************************
- * AUTHORS: Vijay Ganesh
- *
- * BEGIN DATE: November, 2005
- *
- * LICENSE: Please view LICENSE file in the home dir of this Program
- ********************************************************************/
-
-#ifndef ASTBVCONST_H
-#define ASTBVCONST_H
-namespace BEEV
-{
- class STPMgr;
- void FatalError(const char * str);
-
- /******************************************************************
- * Class ASTBVConst: *
- * *
- * Class to represent internals of a bitvector constant *
- ******************************************************************/
- class ASTBVConst: public ASTInternal
- {
- friend class STPMgr;
- friend class ASTNode;
- friend class ASTNodeHasher;
- friend class ASTNodeEqual;
-
- private:
- /****************************************************************
- * Private Data *
- ****************************************************************/
-
- //CBV is actually an unsigned*. The bitvector constant is
- //represented using an external library in extlib-bvconst.
- CBV _bvconst;
-
- // If the CBV is managed outside of this class. Then a defensive copy isn't taken.
- bool cbv_managed_outside;
-
- /****************************************************************
- * Class ASTBVConstHasher: *
- * *
- * Hasher for ASTBVConst nodes *
- ****************************************************************/
- class ASTBVConstHasher
- {
- public:
- size_t operator()(const ASTBVConst * bvc) const;
- }; //End of class ASTBVConstHahser
-
-
-
- /****************************************************************
- * Class ASTBVConstEqual: *
- * *
- * Equality for ASTBVConst nodes *
- ****************************************************************/
- class ASTBVConstEqual
- {
- public:
- bool operator()(const ASTBVConst * bvc1,
- const ASTBVConst * bvc2) const;
- }; //End of class ASTBVConstEqual
-
- /****************************************************************
- * Private Functions (virtual defs and friends) *
- ****************************************************************/
-
- //Constructor
- ASTBVConst(CBV bv, unsigned int width);
-
- enum CBV_LIFETIME {CBV_MANAGED_OUTSIDE};
-
- ASTBVConst(CBV bv, unsigned int width, enum CBV_LIFETIME l )
- : ASTInternal(BVCONST)
- {
- _bvconst = (bv);
- _value_width = width;
- cbv_managed_outside =true;
- }
-
- // Copy constructor.
- ASTBVConst(const ASTBVConst &sym);
-
- //friend equality operator
- friend bool operator==(const ASTBVConst &bvc1, const ASTBVConst &bvc2)
- {
- if (bvc1._value_width != bvc2._value_width)
- return false;
- return (0 == CONSTANTBV::BitVector_Compare(bvc1._bvconst,
- bvc2._bvconst));
- } //End of operator==
-
- // Call this when deleting a node that has been stored in the the
- // unique table
- virtual void CleanUp();
-
- // Print function for bvconst -- return _bvconst value in bin
- // format (c_friendly is for printing hex. numbers that C
- // compilers will accept)
- virtual void nodeprint(ostream& os, bool c_friendly = false);
-
- const static ASTVec astbv_empty_children;
-
- public:
-
- virtual ASTVec const &
- GetChildren() const
- {
- return astbv_empty_children;
- }
-
- /****************************************************************
- * Public Member Functions *
- ****************************************************************/
-
- //Destructor. Call the external destructor
- virtual ~ASTBVConst()
- {
- if (!cbv_managed_outside)
- CONSTANTBV::BitVector_Destroy(_bvconst);
- } //End of destructor
-
- // Return the bvconst. It is a const-value
- CBV GetBVConst() const;
- }; //End of ASTBVConst
-};//end of namespace
-#endif
diff --git a/src/vendor/stp/src/AST/ASTInterior.cpp b/src/vendor/stp/src/AST/ASTInterior.cpp
deleted file mode 100644
index e1b9db733..000000000
--- a/src/vendor/stp/src/AST/ASTInterior.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-// -*- c++ -*-
-/********************************************************************
- * AUTHORS: Vijay Ganesh
- *
- * BEGIN DATE: November, 2005
- *
- * LICENSE: Please view LICENSE file in the home dir of this Program
- ********************************************************************/
-
-#include "AST.h"
-#include "../STPManager/STP.h"
-namespace BEEV
-{
- /******************************************************************
- * ASTInterior Member Functions *
- ******************************************************************/
-
- // Call this when deleting a node that has been stored in the
- // the unique table
- void ASTInterior::CleanUp()
- {
- (ParserBM)->_interior_unique_table.erase(this);
- delete this;
- } //End of Cleanup()
-
- // Returns kinds. "lispprinter" handles printing of parenthesis
- // and childnodes. (c_friendly is for printing hex. numbers that C
- // compilers will accept)
- void ASTInterior::nodeprint(ostream& os, bool c_friendly)
- {
- os << _kind_names[_kind];
- } //end of nodeprint()
-
- /******************************************************************
- * ASTInteriorHasher and ASTInteriorEqual Member Functions *
- ******************************************************************/
-
- //ASTInteriorHasher operator()
- size_t
- ASTInterior::ASTInteriorHasher::
- operator()(const ASTInterior *int_node_ptr) const
- {
- size_t hashval = ((size_t) int_node_ptr->GetKind());
- const ASTVec &ch = int_node_ptr->GetChildren();
- ASTVec::const_iterator iend = ch.end();
- for (ASTVec::const_iterator i = ch.begin(); i != iend; i++)
- {
- hashval += i->Hash();
- hashval += (hashval << 10);
- hashval ^= (hashval >> 6);
- }
-
- hashval += (hashval << 3);
- hashval ^= (hashval >> 11);
- hashval += (hashval << 15);
- return hashval;
- } //End of ASTInteriorHasher operator()
-
- //ASTInteriorEqual operator()
- bool
- ASTInterior::ASTInteriorEqual::
- operator()(const ASTInterior *int_node_ptr1,
- const ASTInterior *int_node_ptr2) const
- {
- return (*int_node_ptr1 == *int_node_ptr2);
- } ///End of ASTInteriorEqual operator()
-
-}; //end of namespace
diff --git a/src/vendor/stp/src/AST/ASTInterior.h b/src/vendor/stp/src/AST/ASTInterior.h
deleted file mode 100644
index 9c5a49a0e..000000000
--- a/src/vendor/stp/src/AST/ASTInterior.h
+++ /dev/null
@@ -1,107 +0,0 @@
-// -*- c++ -*-
-/********************************************************************
- * AUTHORS: Vijay Ganesh
- *
- * BEGIN DATE: November, 2005
- *
- * LICENSE: Please view LICENSE file in the home dir of this Program
- ********************************************************************/
-
-#ifndef ASTINTERIOR_H
-#define ASTINTERIOR_H
-
-#include "UsefulDefs.h"
-#include "ASTInternalWithChildren.h"
-namespace BEEV
-{
- class ASTNode;
- class STPMgr;
- typedef vector ASTVec;
-
- /******************************************************************
- * Class ASTInterior: *
- * *
- * Internal representation of an interior ASTNode.Generally, these*
- * nodes should have at least one child *
- ******************************************************************/
- class ASTInterior: public ASTInternalWithChildren
- {
-
- friend class STPMgr;
- friend class ASTNodeHasher;
- friend class ASTNodeEqual;
- friend BEEV::ASTNode HashingNodeFactory::CreateNode(const Kind kind, const BEEV::ASTVec & back_children);
-
- private:
- /******************************************************************
- * Private Data and Member Functions *
- ******************************************************************/
-
- /******************************************************************
- * Class ASTInteriorHasher: *
- * *
- * Hasher for ASTInterior pointer nodes *
- ******************************************************************/
- class ASTInteriorHasher
- {
- public:
- size_t operator()(const ASTInterior *int_node_ptr) const;
- }; //End of ASTInteriorHasher
-
- /******************************************************************
- * Class ASTInteriorEqual: *
- * *
- * Equality for ASTInterior nodes *
- ******************************************************************/
- class ASTInteriorEqual
- {
- public:
- bool operator()(const ASTInterior *int_node_ptr1,
- const ASTInterior *int_node_ptr2) const;
- }; //End of class ASTInteriorEqual
-
- // Used in Equality class for hash tables
- friend bool operator==(const ASTInterior &int_node1,
- const ASTInterior &int_node2)
- {
- return ((int_node1._kind == int_node2._kind)
- && (int_node1._children == int_node2._children));
- } //End of operator==
-
- // Call this when deleting a node that has been stored in the
- // the unique table
- virtual void CleanUp();
-
- // Returns kinds. "lispprinter" handles printing of parenthesis
- // and childnodes. (c_friendly is for printing hex. numbers that C
- // compilers will accept)
- virtual void nodeprint(ostream& os, bool c_friendly = false);
-
- public:
- /******************************************************************
- * Public Member Functions *
- ******************************************************************/
-
- // Basic constructors
- ASTInterior(Kind kind) : ASTInternalWithChildren(kind)
- {
- }
-
- ASTInterior(Kind kind, ASTVec &children) : ASTInternalWithChildren(kind, children)
- {
- }
-
- //Copy constructor. This copies the contents of the child nodes
- //array, along with everything else. Assigning the smart pointer,
- //ASTNode, does NOT invoke this.
- ASTInterior(const ASTInterior &int_node) : ASTInternalWithChildren(int_node)
- {
- }
-
- // Destructor (does nothing, but is declared virtual here.
- virtual ~ASTInterior()
- {
- }
- }; //End of ASTNodeInterior
-}; //end of namespace BEEV
-#endif
diff --git a/src/vendor/stp/src/AST/ASTInternal.h b/src/vendor/stp/src/AST/ASTInternal.h
deleted file mode 100644
index 9f1abd1b8..000000000
--- a/src/vendor/stp/src/AST/ASTInternal.h
+++ /dev/null
@@ -1,191 +0,0 @@
-// -*- c++ -*-
-/********************************************************************
- * AUTHORS: Vijay Ganesh
- *
- * BEGIN DATE: November, 2005
- *
- * LICENSE: Please view LICENSE file in the home dir of this Program
- ********************************************************************/
-#ifndef ASTINTERNAL_H
-#define ASTINTERNAL_H
-
-/********************************************************************
- * This file gives the class description of the ASTInternal class *
- ********************************************************************/
-namespace BEEV
-{
- /******************************************************************
- * struct enumeration: *
- * *
- * Templated class that allows you to define the number of bytes *
- * (using class T below) for the enumerated type class E. *
- ******************************************************************/
- template
- struct enumeration
- {
- typedef T type;
- typedef E enum_type;
-
- enumeration() : e_(E())
- {}
-
- enumeration(E e) : e_(static_cast(e))
- {}
-
- operator E() const
- { return static_cast(e_); }
-
- private:
- T e_;
- }; //end of Enumeration struct
-
- /******************************************************************
- * Class ASTInternal: *
- * *
- * Abstract base class for internal node representation. Requires *
- * Kind and ChildNodes so same traversal works on all nodes. *
- ******************************************************************/
- class ASTInternal
- {
- friend class ASTNode;
- friend class CNFMgr;
-
- protected:
- /****************************************************************
- * Protected Data *
- ****************************************************************/
-
- mutable uint8_t iteration;
-
- //reference counting for garbage collection
- unsigned int _ref_count;
-
- // Kind. It's a type tag and the operator.
- enumeration _kind;
-
- //Nodenum is a unique positive integer for the node. The nodenum
- //of a node should always be greater than its descendents (which
- //is easily achieved by incrementing the number each time a new
- //node is created).
- unsigned int _node_num;
-
- /*******************************************************************
- * ASTNode is of type BV <==> ((indexwidth=0)&&(valuewidth>0))*
- * ASTNode is of type ARRAY <==> ((indexwidth>0)&&(valuewidth>0))*
- * ASTNode is of type BOOLEAN <==> ((indexwidth=0)&&(valuewidth=0))*
- * *
- * Width of the index of an array. Positive for array, 0 otherwise *
- *******************************************************************/
- unsigned int _index_width;
-
-
- /*******************************************************************
- * ASTNode is of type BV <==> ((indexwidth=0)&&(valuewidth>0))*
- * ASTNode is of type ARRAY <==> ((indexwidth>0)&&(valuewidth>0))*
- * ASTNode is of type BOOLEAN <==> ((indexwidth=0)&&(valuewidth=0))*
- * *
- * Number of bits of bitvector. +ve for array/bitvector,0 otherwise*
- *******************************************************************/
- unsigned int _value_width;
-
- /****************************************************************
- * Protected Member Functions *
- ****************************************************************/
-
- // Copying assign operator. Also copies contents of children.
- ASTInternal& operator=(const ASTInternal &int_node);
-
- // Cleanup function for removing from hash table
- virtual void CleanUp() = 0;
-
- // Destructor (does nothing, but is declared virtual here.
- virtual ~ASTInternal()
- {
- }
-
- // Abstract virtual print function for internal node. c_friendly
- // is for printing hex. numbers that C compilers will accept
- virtual void nodeprint(ostream& os, bool c_friendly = false)
- {
- os << "*";
- }
- ;
-
- // Treat the result as const pleases
- virtual Kind GetKind() const
- {
- return _kind;
- }
-
- // Get the child nodes of this node
- virtual ASTVec const &GetChildren() const = 0;
-
- public:
-
- /****************************************************************
- * Public Member Functions *
- ****************************************************************/
-
- // Constructor (kind only, empty children, int nodenum)
- ASTInternal(Kind kind, int nodenum = 0) :
- _ref_count(0), _kind(kind),
- _node_num(nodenum),
- _index_width(0), _value_width(0), iteration(0)
- {
- }
-
- // Copy constructor. This copies the contents of the child nodes
- // array, along with everything else. Assigning the smart pointer,
- // ASTNode, does NOT invoke this; This should only be used for
- // temporary hash keys before uniquefication.
- // FIXME: I don't think children need to be copied.
- ASTInternal(const ASTInternal &int_node, int nodenum = 0) :
- _ref_count(0), _kind(int_node._kind),
- _node_num(int_node._node_num),
- _index_width(int_node._index_width),
- _value_width(int_node._value_width),
- iteration(0)
- {
- }
-
- // Increment Reference Count
- void IncRef()
- {
- ++_ref_count;
- } //End of IncRef()
-
- // Decrement Reference Count
- void DecRef()
- {
- if (--_ref_count == 0)
- {
- // Delete node from unique table and kill it.
- CleanUp();
- }
- }//End of DecRef()
-
- int GetNodeNum() const
- {
- return _node_num;
- } //End of GetNodeNum()
-
-
- virtual bool isSimplified() const
- {
- return false;
- }
-
- virtual void hasBeenSimplified() const
- {
- cerr << "astinternal has been";
- }
-
-
- void SetNodeNum(int nn)
- {
- _node_num = nn;
- } //End of SetNodeNum()
-
- }; //End of Class ASTInternal
-}; //end of namespace
-#endif
diff --git a/src/vendor/stp/src/AST/ASTInternalWithChildren.h b/src/vendor/stp/src/AST/ASTInternalWithChildren.h
deleted file mode 100644
index d1e93391c..000000000
--- a/src/vendor/stp/src/AST/ASTInternalWithChildren.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef ASTINTERNALWithChildren_H
-#define ASTINTERNALWithChildren_H
-
-/*
- * Leaf objects like Symbols and BVConsts don't need a vector of
- * children. On a 64-bit machine, a vector object is 24 bytes. So
- * splitting the two objects apart saves 24 bytes for those objects.
- */
-
-namespace BEEV
-{
- class ASTInternalWithChildren : public ASTInternal
- {
-
- protected:
- // The vector of children
- ASTVec _children;
-
- /// todo. This should be a bitfield in a superclass if it can fit without increasing the sizeof..
- mutable bool is_simplified;
-
- public:
-
- virtual ASTVec const &GetChildren() const
- {
- return _children;
- }
-
- bool isSimplified() const
- {
- return is_simplified;
- }
-
- void hasBeenSimplified() const
- {
- is_simplified =true;
- }
-
- // Constructor (kind and children).
- ASTInternalWithChildren(Kind kind, const ASTVec &children, int nodenum = 0) :
- ASTInternal(kind,nodenum), _children(children)
- {
- is_simplified = false;
- }
-
- // Constructor (kind only, empty children, int nodenum)
- ASTInternalWithChildren(Kind kind, int nodenum = 0) :
- ASTInternal(kind,nodenum)
- {
- is_simplified = false;
- }
- }; //End of Class ASTInternalBase
-}; //end of namespace
-#endif
diff --git a/src/vendor/stp/src/AST/ASTKind.kinds b/src/vendor/stp/src/AST/ASTKind.kinds
deleted file mode 100644
index c10d916ee..000000000
--- a/src/vendor/stp/src/AST/ASTKind.kinds
+++ /dev/null
@@ -1,73 +0,0 @@
-#Please refer LICENSE FILE in the home directory for licensing information
-# name minkids maxkids category1 category2
-Categories: Term Form
-
-# Leaf nodes.
-UNDEFINED 0 0
-SYMBOL 0 0 Term Form
-
-# These always produce terms
-BVCONST 0 0 Term
-BVNEG 1 1 Term
-BVCONCAT 2 - Term
-BVOR 1 - Term
-BVAND 1 - Term
-BVXOR 1 - Term
-BVNAND 1 - Term
-BVNOR 1 - Term
-BVXNOR 1 - Term
-BVEXTRACT 3 3 Term
-BVLEFTSHIFT 3 3 Term
-BVRIGHTSHIFT 3 3 Term
-BVSRSHIFT 3 3 Term
-BVVARSHIFT 3 3 Term
-BVPLUS 1 - Term
-BVSUB 2 2 Term
-BVUMINUS 1 1 Term
-BVMULTINVERSE 1 1 Term
-BVMULT 1 - Term
-BVDIV 2 2 Term
-BVMOD 2 2 Term
-SBVDIV 2 2 Term
-SBVREM 2 2 Term
-SBVMOD 2 2 Term
-BVSX 1 1 Term
-BVZX 1 1 Term
-#BOOLVEC 0 - Term
-
-# Formula OR term, depending on context
-ITE 3 3 Term Form
-
-# These produce formulas.
-BVGETBIT 2 2 Form
-BVLT 2 2 Form
-BVLE 2 2 Form
-BVGT 2 2 Form
-BVGE 2 2 Form
-BVSLT 2 2 Form
-BVSLE 2 2 Form
-BVSGT 2 2 Form
-BVSGE 2 2 Form
-EQ 2 2 Form
-FALSE 0 0 Form
-TRUE 0 0 Form
-NOT 1 1 Form
-AND 1 - Form
-OR 1 - Form
-NAND 1 - Form
-NOR 1 - Form
-XOR 1 - Form
-IFF 1 - Form
-IMPLIES 2 2 Form
-PARAMBOOL 2 2 Form
-
-# array operations
-READ 2 2 Term
-WRITE 3 3 Term
-
-#Types: These kinds are used only in the API. Once processed inside
-#the API, they are never used again in the system
-ARRAY 0 0
-BITVECTOR 0 0
-BOOLEAN 0 0
-
diff --git a/src/vendor/stp/src/AST/ASTNode.cpp b/src/vendor/stp/src/AST/ASTNode.cpp
deleted file mode 100644
index 0a268f504..000000000
--- a/src/vendor/stp/src/AST/ASTNode.cpp
+++ /dev/null
@@ -1,307 +0,0 @@
-// -*- c++ -*-
-/********************************************************************
- * AUTHORS: Vijay Ganesh
- *
- * BEGIN DATE: November, 2005
- *
- * LICENSE: Please view LICENSE file in the home dir of this Program
- ********************************************************************/
-
-#include "AST.h"
-#include "../STPManager/STP.h"
-
-/********************************************************************
- * This file gives the class definitions of the ASTNode class *
- ********************************************************************/
-namespace BEEV
-{
- uint8_t ASTNode::getIteration() const
- {
- return _int_node_ptr->iteration;
- }
-
- void ASTNode::setIteration(uint8_t v) const
- {
- _int_node_ptr->iteration = v;
- }
-
-
-
- // Constructor;
- //
- // creates a new pointer, increments refcount of pointed-to object.
- ASTNode::ASTNode(ASTInternal *in) :
- _int_node_ptr(in)
- {
- if (in)
- {
- in->IncRef();
- }
- } //End of Constructor
-
- // Copy constructor. Maintain _ref_count
- ASTNode::ASTNode(const ASTNode &n) :
- _int_node_ptr(n._int_node_ptr)
- {
- if (n._int_node_ptr)
- {
- n._int_node_ptr->IncRef();
- }
- } //End of Copy Constructor for ASTNode
-
- // ASTNode accessor function.
- Kind ASTNode::GetKind() const
- {
- //cout << "GetKind: " << _int_node_ptr;
- return _int_node_ptr->GetKind();
- } //End of GetKind()
-
- // Declared here because of same ordering problem as GetKind.
- const ASTVec &ASTNode::GetChildren() const
- {
- return _int_node_ptr->GetChildren();
- } //End of GetChildren()
-
- // Access node number
- int ASTNode::GetNodeNum() const
- {
- return _int_node_ptr->_node_num;
- } //End of GetNodeNum()
-
- unsigned int ASTNode::GetIndexWidth() const
- {
- return _int_node_ptr->_index_width;
- } //End of GetIndexWidth()
-
- void ASTNode::SetIndexWidth(unsigned int iw) const
- {
- _int_node_ptr->_index_width = iw;
- } //End of SetIndexWidth()
-
- unsigned int ASTNode::GetValueWidth() const
- {
- return _int_node_ptr->_value_width;
- } //End of GetValueWidth()
-
- void ASTNode::SetValueWidth(unsigned int vw) const
- {
- _int_node_ptr->_value_width = vw;
- } //End of SetValueWidth()
-
- //return the type of the ASTNode:
- //
- // 0 iff BOOLEAN; 1 iff BITVECTOR; 2 iff ARRAY; 3 iff UNKNOWN;
- types ASTNode::GetType() const
- {
- if ((GetIndexWidth() == 0) && (GetValueWidth() == 0)) //BOOLEAN
- return BOOLEAN_TYPE;
- if ((GetIndexWidth() == 0) && (GetValueWidth() > 0)) //BITVECTOR
- return BITVECTOR_TYPE;
- if ((GetIndexWidth() > 0) && (GetValueWidth() > 0)) //ARRAY
- return ARRAY_TYPE;
- return UNKNOWN_TYPE;
- } //End of GetType()
-
- // Assignment
- ASTNode& ASTNode::operator=(const ASTNode& n)
- {
- if (n._int_node_ptr)
- {
- n._int_node_ptr->IncRef();
- }
- if (_int_node_ptr)
- {
- _int_node_ptr->DecRef();
- }
- _int_node_ptr = n._int_node_ptr;
- return *this;
- } //End of operator=
-
- // Destructor
- ASTNode::~ASTNode()
- {
- if (_int_node_ptr)
- {
- _int_node_ptr->DecRef();
- }
- } //End of Destructor()
-
- STPMgr* ASTNode::GetSTPMgr() const
- {
- return ParserBM;
- } //End of GetSTPMgr()
-
- // Checks if the node has alreadybeen printed or not
- bool ASTNode::IsAlreadyPrinted() const
- {
- STPMgr * bm = GetSTPMgr();
- return (bm->AlreadyPrintedSet.find(*this) !=
- bm->AlreadyPrintedSet.end());
- } //End of IsAlreadyPrinted()
-
- // Mark the node as printed if it has been already printed
- void ASTNode::MarkAlreadyPrinted() const
- {
- STPMgr * bm = GetSTPMgr();
- bm->AlreadyPrintedSet.insert(*this);
- } //End of MarkAlreadyPrinted()
-
- // Print the node
- void ASTNode::nodeprint(ostream& os, bool c_friendly) const
- {
- _int_node_ptr->nodeprint(os, c_friendly);
- } //End of nodeprint()
-
- // Get the name from a symbol (char *). It's an error if kind !=
- // SYMBOL
- const char * ASTNode::GetName() const
- {
- if (GetKind() != SYMBOL)
- FatalError("GetName: Called GetName on a non-symbol: ", *this);
- return ((ASTSymbol *) _int_node_ptr)->GetName();
- } //End of GetName()
-
- // Get the value of bvconst from a bvconst. It's an error if kind
- // != BVCONST Treat the result as const (the compiler can't enforce
- // it).
- CBV ASTNode::GetBVConst() const
- {
- if (GetKind() != BVCONST)
- FatalError("GetBVConst: non bitvector-constant: ", *this);
- return ((ASTBVConst *) _int_node_ptr)->GetBVConst();
- } //End of GetBVConst()
-
- unsigned int ASTNode::GetUnsignedConst() const
- {
- const ASTNode& n = *this;
- assert(BVCONST == n.GetKind());
-
- if (sizeof(unsigned int) * 8 < n.GetValueWidth())
- {
- // It may only contain a small value in a bit type,
- // which fits nicely into an unsigned int. This is
- // common for functions like: bvshl(bv1[128],
- // bv1[128]) where both operands have the same type.
- signed long maxBit = CONSTANTBV::Set_Max(n.GetBVConst());
- if (maxBit >= ((signed long) sizeof(unsigned int)) * 8)
- {
- n.LispPrint(cerr); //print the node so they can find it.
- FatalError("GetUnsignedConst: cannot convert bvconst "\
- "of length greater than 32 to unsigned int");
- }
- }
- return (unsigned int) *((unsigned int *) n.GetBVConst());
- } //end of GetUnsignedConst
-
-
-
-
- void ASTNode::NFASTPrint(int l, int max, int prefix) const
- {
- //****************************************
- // stop
- //****************************************
- if (l > max)
- {
- return;
- }
-
- //****************************************
- // print
- //****************************************
- printf("[%10d]", 0);
- for (int i = 0; i < prefix; i++)
- {
- printf(" ");
- }
- cout << GetKind();
- printf("\n");
-
- //****************************************
- // recurse
- //****************************************
-
- const ASTVec &children = GetChildren();
- ASTVec::const_iterator it = children.begin();
- for (; it != children.end(); it++)
- {
- it->NFASTPrint(l + 1, max, prefix + 1);
- }
- } //End of NFASTPrint()
-
- bool
- ASTNode::isSimplfied() const
- {
- return _int_node_ptr->isSimplified();
- }
-
- void
- ASTNode::hasBeenSimplfied() const
- {
- _int_node_ptr->hasBeenSimplified();
- }
-
-
- //traverse "*this", and construct "let variables" for terms that
- //occur more than once in "*this".
- void ASTNode::LetizeNode(void) const
- {
- Kind kind = this->GetKind();
-
- if (kind == SYMBOL || kind == BVCONST || kind == FALSE || kind == TRUE)
- return;
-
- //FIXME: this is ugly.
- STPMgr * bm = GetSTPMgr();
- const ASTVec &c = this->GetChildren();
- for (ASTVec::const_iterator it = c.begin(), itend = c.end(); it != itend; it++)
- {
- ASTNode ccc = *it;
- if (bm->PLPrintNodeSet.find(ccc) == bm->PLPrintNodeSet.end())
- {
- //If branch: if *it is not in NodeSet then,
- //
- //1. add it to NodeSet
- //
- //2. Letize its childNodes
-
- bm->PLPrintNodeSet.insert(ccc);
- //debugging
- //cerr << ccc;
- ccc.LetizeNode();
- }
- else
- {
- Kind k = ccc.GetKind();
- if (k == SYMBOL || k == BVCONST || k == FALSE || k == TRUE)
- continue;
-
- //0. Else branch: Node has been seen before
- //
- //1. Check if the node has a corresponding letvar in the
- //1. NodeLetVarMap.
- //
- //2. if no, then create a new var and add it to the
- //2. NodeLetVarMap
- if (bm->NodeLetVarMap.find(ccc) == bm->NodeLetVarMap.end())
- {
- //Create a new symbol. Get some name. if it conflicts with a
- //declared name, too bad.
- int sz = bm->NodeLetVarMap.size();
- ostringstream oss;
- oss << "let_k_" << sz;
-
- ASTNode CurrentSymbol = bm->CreateSymbol(oss.str().c_str(),this->GetIndexWidth(),this->GetValueWidth());
- /* If for some reason the variable being created here is
- * already declared by the user then the printed output will
- * not be a legal input to the system. too bad. I refuse to
- * check for this.
- */
- bm->NodeLetVarMap[ccc] = CurrentSymbol;
- std::pair node_letvar_pair(CurrentSymbol, ccc);
- bm->NodeLetVarVec.push_back(node_letvar_pair);
- }
- }
- }
- } //end of LetizeNode()
-};//end of namespace
diff --git a/src/vendor/stp/src/AST/ASTNode.h b/src/vendor/stp/src/AST/ASTNode.h
deleted file mode 100644
index eb4fe7ef2..000000000
--- a/src/vendor/stp/src/AST/ASTNode.h
+++ /dev/null
@@ -1,391 +0,0 @@
-// -*- c++ -*-
-/********************************************************************
- * AUTHORS: Vijay Ganesh
- *
- * BEGIN DATE: November, 2005
- *
- * LICENSE: Please view LICENSE file in the home dir of this Program
- ********************************************************************/
-#ifndef ASTNODE_H
-#define ASTNODE_H
-#include "NodeFactory/HashingNodeFactory.h"
-
-/********************************************************************
- * This file gives the class description of the ASTNode class *
- ********************************************************************/
-namespace BEEV
-{
- /******************************************************************
- * Class ASTNode: *
- * *
- * A Kind of Smart pointer to actual ASTInternal datastructure. *
- * This class defines the node datastructure for the DAG that *
- * captures input formulas to STP. *
- ******************************************************************/
-
- class ASTNode
- {
- friend class STPMgr;
- friend class CNFMgr;
- friend class ASTInterior;
- friend class vector;
- friend BEEV::ASTNode HashingNodeFactory::CreateNode(const Kind kind, const BEEV::ASTVec & back_children);
- friend bool exprless(const ASTNode n1, const ASTNode n2);
- friend bool arithless(const ASTNode n1, const ASTNode n2);
-
- private:
- /****************************************************************
- * Private Data *
- ****************************************************************/
-
- // Ptr to the read data
- ASTInternal * _int_node_ptr;
-
- /****************************************************************
- * Private Member Functions *
- ****************************************************************/
-
- // Constructor.
- ASTNode(ASTInternal *in);
-
- //Equal iff ASTIntNode pointers are the same.
- friend bool operator==(const ASTNode& node1, const ASTNode& node2)
- {
- return
- ((size_t) node1._int_node_ptr) ==
- ((size_t) node2._int_node_ptr);
- }
-
- friend bool operator!=(const ASTNode& node1, const ASTNode& node2)
- {
- return !(node1 == node2);
- }
-
- friend bool operator<(const ASTNode& node1, const ASTNode& node2)
- {
- return
- ((size_t) node1._int_node_ptr) <
- ((size_t) node2._int_node_ptr);
- }
-
- public:
- /****************************************************************
- * Public Member Functions *
- ****************************************************************/
-
- uint8_t getIteration() const;
- void setIteration(uint8_t v) const;
-
- // Default constructor.
- ASTNode() :_int_node_ptr(NULL) {};
-
- // Copy constructor
- ASTNode(const ASTNode &n);
-
- // Destructor
- ~ASTNode();
-
- // Print the arguments in lisp format
- friend ostream &LispPrintVec(ostream &os,
- const ASTVec &v,
- int indentation);
-
- // Print the arguments in lisp format
- friend ostream &LispPrintVecSpecial(ostream &os,
- const vector &v,
- int indentation);
-
- // Check if it points to a null node
- inline bool IsNull() const
- {
- return _int_node_ptr == NULL;
- }
-
- bool isConstant() const
- {
- const Kind k = GetKind();
- return (k == BVCONST || k == TRUE || k == FALSE);
- }
-
- bool isSimplfied() const;
-
- void hasBeenSimplfied() const;
-
-
- bool isITE() const
- {
- bool result;
-
- Kind k = GetKind();
- switch (k)
- {
- case ITE:
- {
- result = true;
- break;
- }
- default:
- {
- result = false;
- break;
- }
- }
-
- return result;
- }
-
- bool isAtom() const
- {
- bool result;
-
- const Kind k = GetKind();
- switch (k)
- {
- case TRUE:
- {
- result = true;
- break;
- }
- case FALSE:
- {
- result = true;
- break;
- }
- case SYMBOL:
- {
- result = true;
- break;
- }
- case BVCONST:
- {
- result = true;
- break;
- }
- default:
- {
- result = false;
- break;
- }
- }
-
- return result;
- } //End of isAtom()
-
- bool isPred() const
- {
- bool result;
-
- const Kind k = GetKind();
- switch (k)
- {
- case BVLT:
- {
- result = true;
- break;
- }
- case BVLE:
- {
- result = true;
- break;
- }
- case BVGT:
- {
- result = true;
- break;
- }
- case BVGE:
- {
- result = true;
- break;
- }
- case BVSLT:
- {
- result = true;
- break;
- }
- case BVSLE:
- {
- result = true;
- break;
- }
- case BVSGT:
- {
- result = true;
- break;
- }
- case BVSGE:
- {
- result = true;
- break;
- }
- case EQ:
- {
- result = true;
- break;
- }
- default:
- {
- result = false;
- break;
- }
- }
- return result;
- } //End of isPred()
-
-
- // For lisp DAG printing. Has it been printed already, so we can
- // just print the node number?
- bool IsAlreadyPrinted() const;
- void MarkAlreadyPrinted() const;
-
- // delegates to the ASTInternal node.
- void nodeprint(ostream& os, bool c_friendly = false) const;
-
- // Assignment (for ref counting)
- ASTNode& operator=(const ASTNode& n);
-
- //Get the STPMgr pointer. FIXME: Currently uses a global
- //ptr. BAD!!
- STPMgr* GetSTPMgr() const;
-
- // Access node number
- int GetNodeNum() const;
-
- // Access kind.
- Kind GetKind() const;
-
- // Access Children of this Node
- const ASTVec &GetChildren() const;
-
- // Return the number of child nodes
- size_t Degree() const
- {
- return GetChildren().size();
- }
- ;
-
- // Get indexth childNode.
- const ASTNode& operator[](size_t index) const
- {
- return GetChildren()[index];
- }
- ;
-
- // Get begin() iterator for child nodes
- ASTVec::const_iterator begin() const
- {
- return GetChildren().begin();
- }
- ;
-
- // Get end() iterator for child nodes
- ASTVec::const_iterator end() const
- {
- return GetChildren().end();
- }
- ;
-
- //Get back() element for child nodes
- const ASTNode back() const
- {
- return GetChildren().back();
- }
- ;
-
- // Get the name from a symbol (char *). It's an error if kind !=
- // SYMBOL.
- const char * GetName() const;
-
- //Get the BVCONST value.
- CBV GetBVConst() const;
-
- unsigned int GetUnsignedConst() const;
-
-
- /*******************************************************************
- * ASTNode is of type BV <==> ((indexwidth=0)&&(valuewidth>0))*
- * ASTNode is of type ARRAY <==> ((indexwidth>0)&&(valuewidth>0))*
- * ASTNode is of type BOOLEAN <==> ((indexwidth=0)&&(valuewidth=0))*
- * *
- * Both indexwidth and valuewidth should never be less than 0 *
- *******************************************************************/
- unsigned int GetIndexWidth() const;
- unsigned int GetValueWidth() const;
- void SetIndexWidth(unsigned int iw) const;
- void SetValueWidth(unsigned int vw) const;
- types GetType(void) const;
-
- // Hash using pointer value of _int_node_ptr.
- size_t Hash() const
- {
- return (size_t) _int_node_ptr;
- }
-
- void NFASTPrint(int l, int max, int prefix) const;
-
- // Lisp-form printer
- ostream& LispPrint(ostream &os, int indentation = 0) const;
- ostream &LispPrint_indent(ostream &os, int indentation) const;
-
- // Presentation Language Printer
- ostream& PL_Print(ostream &os, int indentation = 0) const;
-
- // Construct let variables for shared subterms
- void LetizeNode(void) const;
-
- // Attempt to define something that will work in the gdb
- friend void lp(ASTNode &node);
- friend void lpvec(const ASTVec &vec);
-
- // Printing to stream
- friend ostream &operator<<(ostream &os, const ASTNode &node)
- {
- node.LispPrint(os, 0);
- return os;
- }
- ;
-
- // Check if NODE really has a good ptr
- bool IsDefined() const
- {
- return _int_node_ptr != NULL;
- }
-
- /*****************************************************************
- * Class ASTNodeHahser: *
- * *
- * Hasher class for STL hash_maps and hash_sets that use ASTNodes*
- * as keys. Needs to be public so people can define hash tables *
- * (and use ASTNodeMap class) *
- *****************************************************************/
- class ASTNodeHasher
- {
- public:
- size_t operator()(const ASTNode& n) const
- {
- return (size_t) n._int_node_ptr;
- //return (size_t)n.GetNodeNum();
- }
- ;
- }; //End of ASTNodeHasher
-
- /*****************************************************************
- * Class ASTNodeEqual: *
- * *
- * Equality for ASTNode hash_set and hash_map. Returns true iff *
- * internal pointers are the same. Needs to be public so people *
- * can define hash tables (and use ASTNodeSet class) *
- *****************************************************************/
- class ASTNodeEqual
- {
- public:
- bool operator()(const ASTNode& n1, const ASTNode& n2) const
- {
- return (n1._int_node_ptr == n2._int_node_ptr);
- }
- }; //End of ASTNodeEqual
-
- }; //End of Class ASTNode
-
-}; //end of namespace
-#endif
diff --git a/src/vendor/stp/src/AST/ASTSymbol.cpp b/src/vendor/stp/src/AST/ASTSymbol.cpp
deleted file mode 100644
index 59a1d7aca..000000000
--- a/src/vendor/stp/src/AST/ASTSymbol.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-// -*- c++ -*-
-/********************************************************************
- * AUTHORS: Vijay Ganesh
- *
- * BEGIN DATE: November, 2005
- *
- * LICENSE: Please view LICENSE file in the home dir of this Program
- ********************************************************************/
-
-#include "AST.h"
-#include "../STPManager/STP.h"
-namespace BEEV
-{
- const ASTVec ASTSymbol::empty_children;
-
-
- /****************************************************************
- * ASTSymbol Member Function definitions *
- ****************************************************************/
-
- // Get the name of the symbol
- const char * ASTSymbol::GetName() const
- {
- return _name;
- }//End of GetName()
-
- // Print function for symbol -- return name. (c_friendly is for
- // printing hex. numbers that C compilers will accept)
- void ASTSymbol::nodeprint(ostream& os, bool c_friendly)
- {
- os << _name;
- } //end of nodeprint()
-
- // Call this when deleting a node that has been stored in the the
- // unique table
- void ASTSymbol::CleanUp()
- {
- (ParserBM)->_symbol_unique_table.erase(this);
- free((char*) this->_name);
- delete this;
- }//End of cleanup()
-
- unsigned long long hash(unsigned char *str)
- {
- unsigned long long hash = 5381;
- long long c;
-
- while ((c = *str++))
- hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
-
- //cout << "Hash value computed is: " << hash << endl;
-
- return (unsigned long long)hash;
- }
-
-};//end of namespace
diff --git a/src/vendor/stp/src/AST/ASTSymbol.h b/src/vendor/stp/src/AST/ASTSymbol.h
deleted file mode 100644
index 32e3232be..000000000
--- a/src/vendor/stp/src/AST/ASTSymbol.h
+++ /dev/null
@@ -1,130 +0,0 @@
-// -*- c++ -*-
-/********************************************************************
- * AUTHORS: Vijay Ganesh
- *
- * BEGIN DATE: November, 2005
- *
- * LICENSE: Please view LICENSE file in the home dir of this Program
- ********************************************************************/
-
-#ifndef ASTSYMBOL_H
-#define ASTSYMBOL_H
-
-namespace BEEV
-{
- unsigned long long hash(unsigned char *str);
-
- /******************************************************************
- * Class ASTSymbol: *
- * *
- * Class to represent internals of Symbol node. *
- ******************************************************************/
- class ASTSymbol : public ASTInternal
- {
- friend class STPMgr;
- friend class ASTNode;
- friend class ASTNodeHasher;
- friend class ASTNodeEqual;
-
- const static ASTVec empty_children;
-
- private:
- /****************************************************************
- * Private Data *
- ****************************************************************/
-
- // The name of the symbol
- const char * const _name;
-
- /****************************************************************
- * Class ASTSymbolHasher: *
- * *
- * Hasher for ASTSymbol nodes *
- ****************************************************************/
- class ASTSymbolHasher
- {
- public:
- size_t operator()(const ASTSymbol *sym_ptr) const
- {
-#ifdef TR1_UNORDERED_MAP
- std::hash h;
-#else
- //hash h;
-#endif
- //return h(sym_ptr->_name);
- //cerr << "ASTSymbol hasher recieved name: "
- //<< sym_ptr->_name << endl;
- return (size_t)hash((unsigned char*)(sym_ptr->_name));
- };
- }; // End of class ASTSymbolHasher
-
- /****************************************************************
- * Class ASTSymbolEqual: *
- * *
- * Equality for ASTSymbol nodes *
- ****************************************************************/
- class ASTSymbolEqual
- {
- public:
- bool operator()(const ASTSymbol *sym_ptr1,
- const ASTSymbol *sym_ptr2) const
- {
- return (*sym_ptr1 == *sym_ptr2);
- }
- }; // End of class ASTSymbolEqual
-
- // comparator
- friend bool operator==(const ASTSymbol &sym1,
- const ASTSymbol &sym2)
- {
- return (strcmp(sym1._name, sym2._name) == 0);
- }
-
- /****************************************************************
- * Private Member Functions *
- ****************************************************************/
-
- // Get the name of the symbol
- const char * GetName() const;
-
- // Print function for symbol -- return name. (c_friendly is for
- // printing hex. numbers that C compilers will accept)
- virtual void nodeprint(ostream& os, bool c_friendly = false);
-
- // Call this when deleting a node that has been stored in the the
- // unique table
- virtual void CleanUp();
-
- public:
-
- virtual ASTVec const &GetChildren() const
- {
- return empty_children;
- }
-
-
- /****************************************************************
- * Public Member Functions *
- ****************************************************************/
-
-
- // Constructor. This does NOT copy its argument.
- ASTSymbol(const char * const name) :
- ASTInternal(SYMBOL), _name(name)
- {
- }
-
- // Destructor (does nothing, but is declared virtual here.
- virtual ~ASTSymbol()
- {
- }
-
- // Copy constructor
- ASTSymbol(const ASTSymbol &sym) :
- ASTInternal(sym._kind), _name(sym._name)
- {
- //printf("inside ASTSymbol constructor %s\n", _name);
- }
- }; //End of ASTSymbol
-}; //end of namespace
-#endif
diff --git a/src/vendor/stp/src/AST/ASTUtil.cpp b/src/vendor/stp/src/AST/ASTUtil.cpp
deleted file mode 100644
index c0b4e88dc..000000000
--- a/src/vendor/stp/src/AST/ASTUtil.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/********************************************************************
- * AUTHORS: Vijay Ganesh
- *
- * BEGIN DATE: November, 2005
- *
- * LICENSE: Please view LICENSE file in the home dir of this Program
- ********************************************************************/
-// -*- c++ -*-
-
-#include "UsefulDefs.h"
-#include "../STPManager/STPManager.h"
-#include "../main/Globals.h"
-namespace BEEV
-{
- ostream &operator<<(ostream &os, const Spacer &sp)
- {
- // Instead of wrapping lines with hundreds of spaces, prints
- // a "+" at the beginning of the line for each wrap-around.
- // so lines print like: +14+ (XOR ...
- int blanks = sp._spaces % 60;
- int wraps = sp._spaces / 60;
- if (wraps > 0)
- {
- os << "+" << wraps;
- }
- for (int i = 0; i < blanks; i++)
- os << " ";
- return os;
- }
-
- //this function accepts the name of a function (as a char *), and
- //records some stats about it. if the input is "print_func_stats",
- //the function will then print the stats that it has collected.
- void CountersAndStats(const char * functionname, STPMgr * bm)
- {
- static function_counters s;
- if (bm->UserFlags.stats_flag)
- {
-
- if (!strcmp(functionname, "print_func_stats"))
- {
- cout << endl;
- for (function_counters::iterator
- it = s.begin(), itend = s.end();
- it != itend; it++)
- cout << "Number of times the function: "
- << it->first
- << ": is called: "
- << it->second << endl;
- return;
- }
- s[functionname] += 1;
-
- }
- }
-}
-;// end of namespace
diff --git a/src/vendor/stp/src/AST/ASTmisc.cpp b/src/vendor/stp/src/AST/ASTmisc.cpp
deleted file mode 100644
index aecb98c4c..000000000
--- a/src/vendor/stp/src/AST/ASTmisc.cpp
+++ /dev/null
@@ -1,603 +0,0 @@
-// -*- c++ -*-
-/********************************************************************
- * AUTHORS: Vijay Ganesh, Trevor Hansen
- *
- * BEGIN DATE: November, 2005
- *
- * LICENSE: Please view LICENSE file in the home dir of this Program
- ********************************************************************/
-
-#include "AST.h"
-#include "../STPManager/STPManager.h"
-#include "../STPManager/NodeIterator.h"
-
-namespace BEEV
-{
-
- /****************************************************************
- * Universal Helper Functions *
- ****************************************************************/
-
- void process_argument(const char ch, STPMgr *bm)
- {
- switch(ch)
- {
- case 'a' :
- bm->UserFlags.optimize_flag = false;
- break;
- case 'c':
- bm->UserFlags.construct_counterexample_flag = true;
- break;
- case 'd':
- bm->UserFlags.construct_counterexample_flag = true;
- bm->UserFlags.check_counterexample_flag = true;
- break;
-
- case 'h':
- fprintf(stderr,usage,prog);
- cout << helpstring;
- exit(-1);
- break;
- case 'm':
- bm->UserFlags.smtlib1_parser_flag=true;
- bm->UserFlags.division_by_zero_returns_one_flag = true;
- if (bm->UserFlags.smtlib2_parser_flag)
- FatalError("Can't use both the smtlib and smtlib2 parsers");
- break;
- case 'n':
- bm->UserFlags.print_output_flag = true;
- break;
- case 'p':
- bm->UserFlags.print_counterexample_flag = true;
- break;
- case 'q':
- bm->UserFlags.print_arrayval_declaredorder_flag = true;
- break;
- case 'r':
- bm->UserFlags.ackermannisation = true;
- break;
- case 's' :
- bm->UserFlags.stats_flag = true;
- break;
- case 't':
- bm->UserFlags.quick_statistics_flag = true;
- break;
- case 'v' :
- bm->UserFlags.print_nodes_flag = true;
- break;
- case 'w':
- bm->UserFlags.wordlevel_solve_flag = false;
- break;
- case 'x':
- bm->UserFlags.xor_flatten_flag = true;
- break;
- case 'y':
- bm->UserFlags.print_binary_flag = true;
- break;
- case 'z':
- bm->UserFlags.print_sat_varorder_flag = true;
- break;
- default:
- fprintf(stderr,usage,prog);
- cout << helpstring;
- exit(-1);
- break;
- }
- }
-
- // Sort ASTNodes by expression numbers
- bool exprless(const ASTNode n1, const ASTNode n2)
- {
- return (n1.GetNodeNum() < n2.GetNodeNum());
- }
-
- // This is for sorting by arithmetic expressions (for
- // combining like terms, etc.)
- bool arithless(const ASTNode n1, const ASTNode n2)
- {
- Kind k1 = n1.GetKind();
- Kind k2 = n2.GetKind();
-
- if (n1 == n2)
- {
- // necessary for "strict weak ordering"
- return false;
- }
- else if (BVCONST == k1 && BVCONST != k2)
- {
- // put consts first
- return true;
- }
- else if (BVCONST != k1 && BVCONST == k2)
- {
- // put consts first
- return false;
- }
- else if (SYMBOL == k1 && SYMBOL != k2)
- {
- // put symbols next
- return true;
- }
- else if (SYMBOL != k1 && SYMBOL == k2)
- {
- // put symbols next
- return false;
- }
- else
- {
- // otherwise, sort by exprnum (descendents will appear
- // before ancestors).
- return (n1.GetNodeNum() < n2.GetNodeNum());
- }
- } //end of arithless
-
-
- // counts the number of reads. Shortcut when we get to the limit.
- void
- numberOfReadsLessThan(const ASTNode& n, hash_set & visited, int& soFar, const int limit)
- {
- if (n.isAtom())
- return;
-
- if (visited.find(n.GetNodeNum()) != visited.end())
- return;
-
- if (n.GetKind() == READ)
- soFar++;
-
- if (soFar > limit)
- return;
-
- visited.insert(n.GetNodeNum());
-
- for (int i = 0; i < n.Degree(); i++)
- numberOfReadsLessThan(n[i], visited, soFar,limit);
- }
-
- // True if the number of reads in "n" is less than "limit"
- bool
- numberOfReadsLessThan(const ASTNode&n, int limit)
- {
- hash_set visited;
- int reads = 0;
- numberOfReadsLessThan(n, visited, reads,limit);
- return reads < limit;
- }
-
-
- // True if any descendants are arrays.
- bool
- containsArrayOps(const ASTNode&n)
- {
-
- NodeIterator ni(n, n.GetSTPMgr()->ASTUndefined, *n.GetSTPMgr());
- ASTNode current;
- while ((current = ni.next()) != ni.end())
- if (current.GetIndexWidth()>0)
- return true;
-
- return false;
- }
-
- bool isCommutative(const Kind k) {
- switch (k) {
- case BVOR:
- case BVAND:
- case BVXOR:
- case BVNAND:
- case BVNOR:
- case BVXNOR:
- case BVPLUS:
- case BVMULT:
- case EQ:
- case AND:
- case OR:
- case NAND:
- case NOR:
- case XOR:
- case IFF:
- case BVNEG:
- case NOT:
- case BVUMINUS:
- return true;
- default:
- return false;
- }
-
- return false;
-}
-
-
- void FatalError(const char * str, const ASTNode& a, int w)
- {
- if (a.GetKind() != UNDEFINED)
- {
- cerr << "Fatal Error: " << str << endl << a << endl;
- cerr << w << endl;
- }
- else
- {
- cerr << "Fatal Error: " << str << endl;
- cerr << w << endl;
- }
- if (vc_error_hdlr)
- vc_error_hdlr(str);
- assert(0); // gdb will stop here giving a stacktrace.
- exit(-1);
- }
-
- void FatalError(const char * str)
- {
- cerr << "Fatal Error: " << str << endl;
- if (vc_error_hdlr)
- vc_error_hdlr(str);
- assert(0);
- exit(-1);
-
- }
-
- void SortByExprNum(ASTVec& v)
- {
- sort(v.begin(), v.end(), exprless);
- }
-
- void SortByArith(ASTVec& v)
- {
- sort(v.begin(), v.end(), arithless);
- }
-
- bool isAtomic(Kind kind)
- {
- if (TRUE == kind || FALSE == kind ||
- EQ == kind ||
- BVLT == kind || BVLE == kind ||
- BVGT == kind || BVGE == kind ||
- BVSLT == kind || BVSLE == kind ||
- BVSGT == kind || BVSGE == kind ||
- SYMBOL == kind || BVGETBIT == kind)
- return true;
- return false;
- }
-
-
- // If there is a lot of sharing in the graph, this will take a long
- // time. it doesn't mark subgraphs as already having been
- // typechecked.
- bool BVTypeCheckRecursive(const ASTNode& n)
- {
- const ASTVec& c = n.GetChildren();
-
- BVTypeCheck(n);
-
- for (ASTVec::const_iterator it = c.begin(), itend = c.end(); it != itend; it++)
- BVTypeCheckRecursive(*it);
-
- return true;
- }
-
- void buildListOfSymbols(const ASTNode& n, ASTNodeSet& visited,
- ASTNodeSet& symbols)
- {
- if (visited.find(n) != visited.end())
- return; // already visited.
-
- visited.insert(n);
-
- if (n.GetKind() == SYMBOL)
- {
- symbols.insert(n);
- }
-
- for (unsigned i = 0; i < n.GetChildren().size(); i++)
- buildListOfSymbols(n[i], visited, symbols);
- }
-
-
- void checkChildrenAreBV(const ASTVec& v, const ASTNode&n) {
- for (ASTVec::const_iterator it = v.begin(), itend = v.end(); it != itend; it++)
- if (BITVECTOR_TYPE != it->GetType()) {
- cerr << "The type is: " << it->GetType() << endl;
- FatalError(
- "BVTypeCheck:ChildNodes of bitvector-terms must be bitvectors\n",
- n);
- }
-}
-
- void FlattenKind(const Kind k, const ASTVec &children, ASTVec & flat_children)
- {
- ASTVec::const_iterator ch_end = children.end();
- for (ASTVec::const_iterator it = children.begin(); it != ch_end; it++)
- {
- Kind ck = it->GetKind();
- if (k == ck)
- {
- FlattenKind(k,it->GetChildren(), flat_children);
- }
- else
- {
- flat_children.push_back(*it);
- }
- }
- }
-
- // Flatten (k ... (k ci cj) ...) to (k ... ci cj ...)
- ASTVec FlattenKind(Kind k, const ASTVec &children)
- {
- ASTVec flat_children;
- FlattenKind(k,children,flat_children);
- return flat_children;
- }
-
-
- /* FUNCTION: Typechecker for terms and formulas
- *
- * TypeChecker: Assumes that the immediate Children of the input
- * ASTNode have been typechecked. This function is suitable in
- * scenarios like where you are building the ASTNode Tree, and you
- * typecheck as you go along. It is not suitable as a general
- * typechecker.
- *
- * If this returns, this ALWAYS returns true. If there is an error it
- * will call FatalError() and abort.
- */
- bool BVTypeCheck(const ASTNode& n)
- {
- Kind k = n.GetKind();
- //The children of bitvector terms are in turn bitvectors.
- const ASTVec& v = n.GetChildren();
- if (is_Term_kind(k))
- {
- switch (k)
- {
- case BVCONST:
- if (BITVECTOR_TYPE != n.GetType())
- FatalError("BVTypeCheck: The term t does not typecheck, where t = \n", n);
- break;
- case SYMBOL:
- return true;
- case ITE:
- if (n.Degree() != 3)
- FatalError("BVTypeCheck: should have exactly 3 args\n", n);
- if (BOOLEAN_TYPE != n[0].GetType() || (n[1].GetType() != n[2].GetType()))
- FatalError("BVTypeCheck: The term t does not typecheck, where t = \n", n);
- if (n[1].GetValueWidth() != n[2].GetValueWidth())
- FatalError("BVTypeCheck: length of THENbranch != length of ELSEbranch in the term t = \n", n);
- if (n[1].GetIndexWidth() != n[2].GetIndexWidth())
- FatalError("BVTypeCheck: length of THENbranch != length of ELSEbranch in the term t = \n", n);
- break;
- case READ:
- if (n.GetChildren().size() !=2)
- FatalError("2 params to read.");
- if (n[0].GetIndexWidth() != n[1].GetValueWidth())
- {
- cerr << "Length of indexwidth of array: " << n[0] << " is : " << n[0].GetIndexWidth() << endl;
- cerr << "Length of the actual index is: " << n[1] << " is : " << n[1].GetValueWidth() << endl;
- FatalError("BVTypeCheck: length of indexwidth of array != length of actual index in the term t = \n", n);
- }
- if (ARRAY_TYPE != n[0].GetType())
- FatalError("First parameter to read should be an array", n[0]);
- if (BITVECTOR_TYPE != n[1].GetType())
- FatalError("Second parameter to read should be a bitvector", n[1]);
- break;
- case WRITE:
- if (n.GetChildren().size() !=3)
- FatalError("3 params to write.");
- if (n[0].GetIndexWidth() != n[1].GetValueWidth())
- FatalError("BVTypeCheck: length of indexwidth of array != length of actual index in the term t = \n", n);
- if (n[0].GetValueWidth() != n[2].GetValueWidth())
- FatalError("BVTypeCheck: valuewidth of array != length of actual value in the term t = \n", n);
- if (ARRAY_TYPE != n[0].GetType())
- FatalError("First parameter to read should be an array", n[0]);
- if (BITVECTOR_TYPE != n[1].GetType())
- FatalError("Second parameter to read should be a bitvector", n[1]);
- if (BITVECTOR_TYPE != n[2].GetType())
- FatalError("Third parameter to read should be a bitvector", n[2]);
-
- break;
-
- case BVDIV:
- case BVMOD:
- case BVSUB:
-
- case SBVDIV:
- case SBVREM:
- case SBVMOD:
-
- case BVLEFTSHIFT:
- case BVRIGHTSHIFT:
- case BVSRSHIFT:
- case BVVARSHIFT:
- if (n.Degree() != 2)
- FatalError("BVTypeCheck: should have exactly 2 args\n", n);
- // run on.
- case BVOR:
- case BVAND:
- case BVXOR:
- case BVNOR:
- case BVNAND:
- case BVXNOR:
-
- case BVPLUS:
- case BVMULT:
- {
- if (!(v.size() >= 2))
- FatalError("BVTypeCheck:bitwise Booleans and BV arith operators must have at least two arguments\n", n);
- unsigned int width = n.GetValueWidth();
- for (ASTVec::const_iterator it = v.begin(), itend = v.end(); it != itend; it++)
- {
- if (width != it->GetValueWidth())
- {
- cerr << "BVTypeCheck:Operands of bitwise-Booleans and BV arith operators must be of equal length\n";
- cerr << n << endl;
- cerr << "width of term:" << width << endl;
- cerr << "width of offending operand:" << it->GetValueWidth() << endl;
- FatalError("BVTypeCheck:Offending operand:\n", *it);
- }
- if (BITVECTOR_TYPE != it->GetType())
- FatalError("BVTypeCheck: ChildNodes of bitvector-terms must be bitvectors\n", n);
- }
- break;
- }
- case BVSX:
- case BVZX:
- //in BVSX(n[0],len), the length of the BVSX term must be
- //greater than the length of n[0]
- if (n[0].GetValueWidth() > n.GetValueWidth()) {
- FatalError(
- "BVTypeCheck: BV[SZ]X(t,bv[sz]x_len) : length of 't' must be <= bv[sz]x_len\n",
- n);
- }
- if ((v.size() != 2))
- FatalError(
- "BVTypeCheck:BV[SZ]X must have two arguments. The second is the new width\n",
- n);
- break;
-
- case BVCONCAT:
- checkChildrenAreBV(v, n);
- if (n.Degree() != 2)
- FatalError("BVTypeCheck: should have exactly 2 args\n", n);
- if (n.GetValueWidth() != n[0].GetValueWidth()
- + n[1].GetValueWidth())
- FatalError("BVTypeCheck:BVCONCAT: lengths do not add up\n", n);
- break;
- case BVUMINUS:
- case BVNEG:
- checkChildrenAreBV(v, n);
- if (n.Degree() != 1)
- FatalError("BVTypeCheck: should have exactly 1 args\n", n);
- if (n.GetValueWidth() != n[0].GetValueWidth())
- FatalError("BVTypeCheck: should have same value width\n", n);
- break;
- case BVEXTRACT:
- checkChildrenAreBV(v, n);
- if (n.Degree() != 3)
- FatalError("BVTypeCheck: should have exactly 3 args\n", n);
- if (!(BVCONST == n[1].GetKind() && BVCONST == n[2].GetKind()))
- FatalError("BVTypeCheck: indices should be BVCONST\n", n);
- if (n.GetValueWidth() != n[1].GetUnsignedConst()
- - n[2].GetUnsignedConst() + 1)
- FatalError("BVTypeCheck: length mismatch\n", n);
- if (n[1].GetUnsignedConst() >= n[0].GetValueWidth())
- FatalError(
- "BVTypeCheck: Top index of select is greater or equal to the bitwidth.\n",
- n);
- break;
- default:
- cerr << _kind_names[k];
- FatalError("No type checking for type");
- break;
- }
- }
- else
- {
- if (!(is_Form_kind(k) && BOOLEAN_TYPE == n.GetType()))
- FatalError("BVTypeCheck: not a formula:", n);
- switch (k)
- {
- case TRUE:
- case FALSE:
- case SYMBOL:
- return true;
- case PARAMBOOL:
- if(2 != n.Degree())
- FatalError("BVTypeCheck: PARAMBOOL formula can have exactly two childNodes", n);
- break;
- case EQ:
- if (n.Degree() != 2)
- FatalError("BVTypeCheck: should have exactly 2 args\n", n);
- if (!(n[0].GetValueWidth() == n[1].GetValueWidth() && n[0].GetIndexWidth() == n[1].GetIndexWidth()))
- {
- cerr << "valuewidth of lhs of EQ: " << n[0].GetValueWidth() << endl;
- cerr << "valuewidth of rhs of EQ: " << n[1].GetValueWidth() << endl;
- cerr << "indexwidth of lhs of EQ: " << n[0].GetIndexWidth() << endl;
- cerr << "indexwidth of rhs of EQ: " << n[1].GetIndexWidth() << endl;
- FatalError("BVTypeCheck: terms in atomic formulas must be of equal length", n);
- }
- break;
- case BVLT:
- case BVLE:
- case BVGT:
- case BVGE:
- case BVSLT:
- case BVSLE:
- case BVSGT:
- case BVSGE:
- if (n.Degree() != 2)
- FatalError("BVTypeCheck: should have exactly 2 args\n", n);
- if (BITVECTOR_TYPE != n[0].GetType() && BITVECTOR_TYPE != n[1].GetType())
- FatalError("BVTypeCheck: terms in atomic formulas must be bitvectors", n);
- if (n[0].GetValueWidth() != n[1].GetValueWidth())
- FatalError("BVTypeCheck: terms in atomic formulas must be of equal length", n);
- if (n[0].GetIndexWidth() != n[1].GetIndexWidth())
- FatalError("BVTypeCheck: terms in atomic formulas must be of equal length", n);
- break;
- case NOT:
- if (1 != n.Degree())
- FatalError("BVTypeCheck: NOT formula can have exactly one childNode", n);
- break;
- case AND:
- case OR:
- case XOR:
- case NAND:
- case NOR:
- if (2 > n.Degree())
- FatalError("BVTypeCheck: AND/OR/XOR/NAND/NOR: must have atleast 2 ChildNodes", n);
- break;
- case IFF:
- case IMPLIES:
- if (2 != n.Degree())
- FatalError("BVTypeCheck:IFF/IMPLIES must have exactly 2 ChildNodes", n);
- break;
- case ITE:
- if (3 != n.Degree())
- FatalError("BVTypeCheck:ITE must have exactly 3 ChildNodes", n);
- break;
- default:
- FatalError("BVTypeCheck: Unrecognized kind: ");
- break;
- }
- }
- return true;
- } //End of TypeCheck function
-
- // callback for SIGALRM.
- void handle_time_out(int parameter){
- printf("Timed Out.\n");
-
- abort();
- // I replaced the exit(0) with an abort().
- // The exit was sometimes hanging, seemingly because of a bug somewhere else (e.g. loader, glibc).
- // In strace it output:
-
- //--- SIGVTALRM (Virtual timer expired) @ 0 (0) ---
- //fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 5), ...}) = 0
- //mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabca622000
- //write(1, "Timed Out.\n", 11Timed Out.
- //) = 11
- //futex(0x7fabc9c54e40, FUTEX_WAIT, 2, NULL
-
- // Then it would just sit there waiting for the mutex (which never came).
- //exit(0);
- }
-
-
- itimerval timeout;
- void setHardTimeout(int sec)
- {
- signal(SIGVTALRM, handle_time_out);
- timeout.it_interval.tv_usec = 0;
- timeout.it_interval.tv_sec = 0;
- timeout.it_value.tv_usec = 0;
- timeout.it_value.tv_sec = sec;
- setitimer(ITIMER_VIRTUAL, &timeout, NULL);
- }
-
- long getCurrentTime()
- {
- timeval t;
- gettimeofday(&t, NULL);
- return (1000 * t.tv_sec) + (t.tv_usec / 1000);
- }
-
-};//end of namespace
diff --git a/src/vendor/stp/src/AST/ArrayTransformer.cpp b/src/vendor/stp/src/AST/ArrayTransformer.cpp
deleted file mode 100644
index 0507c7a44..000000000
--- a/src/vendor/stp/src/AST/ArrayTransformer.cpp
+++ /dev/null
@@ -1,783 +0,0 @@
-// -*- c++ -*-
-/********************************************************************
- * AUTHORS: Vijay Ganesh
- *
- * BEGIN DATE: November, 2005
- *
- * LICENSE: Please view LICENSE file in the home dir of this Program
- ********************************************************************/
-
-/* Transform:
- *
- * Converts signed Div/signed remainder/signed modulus into their
- * unsigned counterparts. Removes array selects and stores from
- * formula. Arrays are replaced by equivalent bit-vector variables
- */
-#include "ArrayTransformer.h"
-#include
-#include "../simplifier/simplifier.h"
-#include
-#include
-#include
-#include
-
-
-namespace BEEV
-{
- // NB: This is the only function that should be called
- // externally. It sets up the cache that the others use.
- ASTNode ArrayTransformer::TransformFormula_TopLevel(const ASTNode& form)
- {
- runTimes->start(RunTimes::Transforming);
-
- assert(TransformMap == NULL);
- assert(form.GetSTPMgr() == this->bm);
- TransformMap = new ASTNodeMap(100);
- ASTNode result = TransformFormula(form);
-
-#if 0
- {
- ASTNodeSet visited;
- assertTransformPostConditions(result,visited);
- }
-#endif
-
- TransformMap->clear();
- delete TransformMap;
- TransformMap = NULL;
-
- if (bm->UserFlags.stats_flag)
- printArrayStats();
-
- // This establishes equalities between every indexes, and a fresh variable.
- if (!bm->UserFlags.ackermannisation)
- {
- ASTNodeMap replaced;
-
- ASTVec equalsNodes;
- for (ArrayTransformer::ArrType::iterator
- iset = arrayToIndexToRead.begin(),
- iset_end = arrayToIndexToRead.end();
- iset != iset_end; iset++)
- {
- const ASTNode& ArrName = iset->first;
- map& mapper = iset->second;
-
- for (map::iterator it =mapper.begin() ; it != mapper.end();it++)
- {
- const ASTNode& the_index = it->first;
-
- if (the_index.isConstant() || the_index.GetKind() == SYMBOL)
- {
- it->second.index_symbol = the_index;
- }
- else if (replaced.find(the_index) != replaced.end()) // Already associated with a variable.
- {
- it->second.index_symbol = replaced.find(the_index)->second;
- }
- else
- {
- ASTNode newV = bm->CreateFreshVariable(0,the_index.GetValueWidth(), "STP__IndexVariables");
- equalsNodes.push_back(nf->CreateNode(EQ, the_index, newV));
- replaced.insert(make_pair(the_index,newV));
- it->second.index_symbol = newV;
- }
- assert(it->second.index_symbol.GetValueWidth() == the_index.GetValueWidth());
- }
- }
-
- runTimes->stop(RunTimes::Transforming);
-
- if (equalsNodes.size() > 0)
- return nf->CreateNode(AND, result, equalsNodes);
- else
- return result;
- }
- else
- {
- runTimes->stop(RunTimes::Transforming);
- return result;
- }
- }
-
- //Translates signed BVDIV,BVMOD and BVREM into unsigned variety
- ASTNode ArrayTransformer::TranslateSignedDivModRem(const ASTNode& in, NodeFactory* nf, STPMgr *bm)
- {
- assert(in.GetChildren().size() ==2);
-
- const ASTNode& dividend = in[0];
- const ASTNode& divisor = in[1];
- const unsigned len = in.GetValueWidth();
-
- ASTNode hi1 = bm->CreateBVConst(32, len - 1);
- ASTNode one = bm->CreateOneConst(1);
- ASTNode zero = bm->CreateZeroConst(1);
- // create the condition for the dividend
- ASTNode cond_dividend =
- nf->CreateNode(EQ, one, nf->CreateTerm(BVEXTRACT, 1, dividend, hi1, hi1));
- // create the condition for the divisor
- ASTNode cond_divisor =
- nf->CreateNode(EQ, one,
- nf->CreateTerm(BVEXTRACT, 1, divisor, hi1, hi1));
-
- if (SBVREM == in.GetKind())
- {
- //BVMOD is an expensive operation. So have the fewest bvmods
- //possible. Just one.
-
- //Take absolute value.
- ASTNode pos_dividend =
- nf->CreateTerm(ITE, len,
- cond_dividend,
- nf->CreateTerm(BVUMINUS, len, dividend),
- dividend);
- ASTNode pos_divisor =
- nf->CreateTerm(ITE, len,
- cond_divisor,
- nf->CreateTerm(BVUMINUS, len, divisor),
- divisor);
-
- //create the modulus term
- ASTNode modnode =
- nf->CreateTerm(BVMOD, len,
- pos_dividend, pos_divisor);
-
- //If the dividend is <0 take the unary minus.
- ASTNode n =
- nf->CreateTerm(ITE, len,
- cond_dividend,
- nf->CreateTerm(BVUMINUS, len, modnode),
- modnode);
- return n;
- }
-
- // This is the modulus of dividing rounding to -infinity.
- else if (SBVMOD == in.GetKind())
- {
-
- /*
- (bvsmod s t) abbreviates
- (let ((?msb_s ((_ extract |m-1| |m-1|) s))
- (?msb_t ((_ extract |m-1| |m-1|) t)))
- (let ((abs_s (ite (= ?msb_s #b0) s (bvneg s)))
- (abs_t (ite (= ?msb_t #b0) t (bvneg t))))
- (let ((u (bvurem abs_s abs_t)))
- (ite (= u (_ bv0 m))
- u
- (ite (and (= ?msb_s #b0) (= ?msb_t #b0))
- u
- (ite (and (= ?msb_s #b1) (= ?msb_t #b0))
- (bvadd (bvneg u) t)
- (ite (and (= ?msb_s #b0) (= ?msb_t #b1))
- (bvadd u t)
- (bvneg u))))))))
- */
-
- //Take absolute value.
- ASTNode pos_dividend =
- nf->CreateTerm(ITE, len,
- cond_dividend,
- nf->CreateTerm(BVUMINUS, len, dividend),
- dividend);
- ASTNode pos_divisor =
- nf->CreateTerm(ITE, len,
- cond_divisor,
- nf->CreateTerm(BVUMINUS, len, divisor),
- divisor);
-
- ASTNode urem_node =
- nf->CreateTerm(BVMOD, len,
- pos_dividend, pos_divisor);
-
- // If the dividend is <0, then we negate the whole thing.
- ASTNode rev_node =
- nf->CreateTerm(ITE, len,
- cond_dividend,
- nf->CreateTerm(BVUMINUS, len, urem_node),
- urem_node);
-
- // if It's XOR <0, and it doesn't perfectly divide, then add t (not its absolute value).
- ASTNode xor_node =
- nf->CreateNode(XOR, cond_dividend, cond_divisor);
- ASTNode neZ = nf->CreateNode(NOT, nf->CreateNode(EQ, rev_node, bm->CreateZeroConst(divisor.GetValueWidth())));
- ASTNode cond = nf->CreateNode(AND,xor_node ,neZ);
- ASTNode n =
- nf->CreateTerm(ITE, len,
- cond,
- nf->CreateTerm(BVPLUS, len, rev_node, divisor),
- rev_node);
-
- return n;
- }
- else if (SBVDIV == in.GetKind())
- {
- //now handle the BVDIV case
- //if topBit(dividend) is 1 and topBit(divisor) is 0
- //
- //then output is -BVDIV(-dividend,divisor)
- //
- //elseif topBit(dividend) is 0 and topBit(divisor) is 1
- //
- //then output is -BVDIV(dividend,-divisor)
- //
- //elseif topBit(dividend) is 1 and topBit(divisor) is 1
- //
- // then output is BVDIV(-dividend,-divisor)
- //
- //else simply output BVDIV(dividend,divisor)
-
- //Take absolute value.
- ASTNode pos_dividend =
- nf->CreateTerm(ITE, len,
- cond_dividend,
- nf->CreateTerm(BVUMINUS, len, dividend),
- dividend);
- ASTNode pos_divisor =
- nf->CreateTerm(ITE, len,
- cond_divisor,
- nf->CreateTerm(BVUMINUS, len, divisor),
- divisor);
-
- ASTNode divnode =
- nf->CreateTerm(BVDIV, len, pos_dividend, pos_divisor);
-
- // A little confusing. Only negate the result if they are XOR <0.
- ASTNode xor_node =
- nf->CreateNode(XOR, cond_dividend, cond_divisor);
- ASTNode n =
- nf->CreateTerm(ITE, len,
- xor_node,
- nf->CreateTerm(BVUMINUS, len, divnode),
- divnode);
-
- return n;
- }
-
- FatalError("TranslateSignedDivModRem:"\
- "input must be signed DIV/MOD/REM", in);
- return bm->ASTUndefined;
-
- }//end of TranslateSignedDivModRem()
-
- // Check that the transformations have occurred.
- void ArrayTransformer::assertTransformPostConditions(const ASTNode & term, ASTNodeSet& visited)
- {
-
- // I haven't measure whether this is the quickest way to do it?
- pair p = visited.insert(term);
- if (!p.second)
- return;
-
- const Kind k = term.GetKind();
-
- // Check the array reads / writes have been removed
- assert( READ !=k );
- assert( WRITE !=k);
-
- // There should be no nodes left of type array.
- assert(0 == term.GetIndexWidth());
-
- const ASTVec& c = term.GetChildren();
- ASTVec::const_iterator it = c.begin();
- const ASTVec::const_iterator itend = c.end();
- for (; it != itend; it++)
- {
- assertTransformPostConditions(*it,visited);
- }
- }//End of assertTransformPostConditions()
-
- /********************************************************
- * TransformFormula()
- *
- * Get rid of DIV/MODs, ARRAY read/writes, FOR constructs
- ********************************************************/
- ASTNode ArrayTransformer::TransformFormula(const ASTNode& simpleForm)
- {
- assert(TransformMap != NULL);
-
- const Kind k = simpleForm.GetKind();
- if (!(is_Form_kind(k) && BOOLEAN_TYPE == simpleForm.GetType()))
- {
- //FIXME: "You have inputted a NON-formula"?
- FatalError("TransformFormula:"\
- "You have input a NON-formula", simpleForm);
- }
-
- ASTNodeMap::const_iterator iter;
- if ((iter = TransformMap->find(simpleForm)) != TransformMap->end())
- return iter->second;
-
- ASTNode result;
-
- switch (k)
- {
- case TRUE:
- case FALSE:
- {
- result = simpleForm;
- break;
- }
- case NOT:
- {
- ASTVec c;
- c.push_back(TransformFormula(simpleForm[0]));
- result = nf->CreateNode(NOT, c);
- break;
- }
- case BVLT:
- case BVLE:
- case BVGT:
- case BVGE:
- case BVSLT:
- case BVSLE:
- case BVSGT:
- case BVSGE:
- {
- ASTVec c;
- c.push_back(TransformTerm(simpleForm[0]));
- c.push_back(TransformTerm(simpleForm[1]));
- result = nf->CreateNode(k, c);
- break;
- }
- case EQ:
- {
- ASTNode term1 = TransformTerm(simpleForm[0]);
- ASTNode term2 = TransformTerm(simpleForm[1]);
- if (bm->UserFlags.optimize_flag)
- result = simp->CreateSimplifiedEQ(term1, term2);
- else
- result = nf->CreateNode(EQ,term1, term2);
- break;
- }
- case AND: // These could shortcut. Not sure if the extra effort is justified.
- case OR:
- case NAND:
- case NOR:
- case IFF:
- case XOR:
- case ITE:
- case IMPLIES:
- {
- ASTVec vec;
- vec.reserve(simpleForm.Degree());
-
- for (ASTVec::const_iterator
- it = simpleForm.begin(),
- itend = simpleForm.end(); it != itend; it++)
- {
- vec.push_back(TransformFormula(*it));
- }
-
- result = nf->CreateNode(k, vec);
- break;
- }
- case PARAMBOOL:
- {
- //If the parameteric boolean variable is of the form
- //VAR(const), then convert it into a Boolean variable of the
- //form "VAR(const)".
- //
- //Else if the paramteric boolean variable is of the form
- //VAR(expression), then simply return it
- if(BVCONST == simpleForm[1].GetKind())
- {
- result =
- bm->NewParameterized_BooleanVar(simpleForm[0],simpleForm[1]);
- }
- else
- {
- result = simpleForm;
- }
- break;
- }
- default:
- {
- if (k == SYMBOL && BOOLEAN_TYPE == simpleForm.GetType())
- result = simpleForm;
- else
- {
- FatalError("TransformFormula: Illegal kind: ",
- ASTUndefined, k);
- cerr << "The input is: " << simpleForm << endl;
- cerr << "The valuewidth of input is : "
- << simpleForm.GetValueWidth() << endl;
- }
- break;
- }
- } //end of Switch
-
- assert(!result.IsNull());
- if (simpleForm.Degree() > 0)
- (*TransformMap)[simpleForm] = result;
- return result;
- } //End of TransformFormula
-
-
- ASTNode ArrayTransformer::TransformTerm(const ASTNode& term)
- {
- assert(TransformMap != NULL);
-
- const Kind k = term.GetKind();
- if (!is_Term_kind(k))
- FatalError("TransformTerm: Illegal kind: You have input a nonterm:",
- term, k);
- ASTNodeMap::const_iterator iter;
- if ((iter = TransformMap->find(term)) != TransformMap->end())
- return iter->second;
-
- ASTNode result;
- switch (k)
- {
- case SYMBOL:
- case BVCONST:
- {
- result = term;
- break;
- }
- case WRITE:
- FatalError("TransformTerm: this kind is not supported", term);
- break;
- case READ:
- result = TransformArrayRead(term);
- break;
- case ITE:
- {
- ASTNode cond = term[0];
- ASTNode thn = term[1];
- ASTNode els = term[2];
- cond = TransformFormula(cond);
- if (ASTTrue == cond)
- result = TransformTerm(thn);
- else if (ASTFalse == cond)
- result = TransformTerm(els);
- else
- {
- thn = TransformTerm(thn);
- els = TransformTerm(els);
- if (bm->UserFlags.optimize_flag)
- result = simp->CreateSimplifiedTermITE(cond, thn, els);
- else
- result = nf->CreateTerm(ITE, thn.GetValueWidth(), cond, thn, els);
- }
- assert(result.GetIndexWidth() ==term.GetIndexWidth());
- break;
- }
- default:
- {
- const ASTVec& c = term.GetChildren();
- ASTVec::const_iterator it = c.begin();
- ASTVec::const_iterator itend = c.end();
- const unsigned width = term.GetValueWidth();
- const unsigned indexwidth = term.GetIndexWidth();
- ASTVec o;
- o.reserve(c.size());
- for (; it != itend; it++)
- {
- o.push_back(TransformTerm(*it));
- }
-
- if (c!=o)
- {
- result = nf->CreateArrayTerm(k,indexwidth, width, o);
- }
- else
- result = term;
- }
- break;
- }
-
- if (term.Degree() > 0)
- (*TransformMap)[term] = result;
- if (term.GetValueWidth() != result.GetValueWidth())
- FatalError("TransformTerm: "\
- "result and input terms are of different length", result);
- if (term.GetIndexWidth() != result.GetIndexWidth())
- {
- cerr << "TransformTerm: input term is : " << term << endl;
- FatalError("TransformTerm: "\
- "result & input terms have different index length", result);
- }
- return result;
- } //End of TransformTerm
-
- /* This function transforms Array Reads, Read over Writes, Read over
- * ITEs into flattened form.
- *
- * Transform1: Suppose there are two array reads in the input
- * Read(A,i) and Read(A,j) over the same array. Then Read(A,i) is
- * replaced with a symbolic constant, say v1, and Read(A,j) is
- * replaced with the following ITE:
- *
- * ITE(i=j,v1,v2)
- *
- */
- ASTNode ArrayTransformer::TransformArrayRead(const ASTNode& term)
- {
- assert(TransformMap != NULL);
-
- const unsigned int width = term.GetValueWidth();
-
- if (READ != term.GetKind())
- return term;
-
- ASTNodeMap::const_iterator iter;
- if ((iter = TransformMap->find(term)) != TransformMap->end())
- return iter->second;
-
- //'term' is of the form READ(arrName, readIndex)
- const ASTNode & arrName = term[0];
- const ASTNode & readIndex = TransformTerm(term[1]);
-
- ASTNode result;
-
- switch (arrName.GetKind())
- {
- case SYMBOL:
- {
- /* input is of the form: READ(A, readIndex)
- *
- * output is of the from: A1, if this is the first READ over A
- *
- * ITE(previous_readIndex=readIndex,A1,A2)
- *
- * .....
- */
-
- {
- ArrType::const_iterator it;
- if ((it = arrayToIndexToRead.find(arrName)) != arrayToIndexToRead.end())
- {
- map::const_iterator it2;
- if ((it2 = it->second.find(readIndex)) != it->second.end())
- {
- result = it2->second.ite;
- break;
- }
- }
- }
-
- // Make up a new abstract variable. Build symbolic name
- // corresponding to array read. The symbolic name has 2
- // components: stringname, and a count
-
- ASTNode CurrentSymbol = bm->CreateFreshVariable(
- term.GetIndexWidth(),
- term.GetValueWidth(),
- "array_" + string(arrName.GetName()));
-
- result = CurrentSymbol;
-
- if (!bm->UserFlags.ackermannisation)
- {
- // result is a variable here; it is an ite in the
- // else-branch
- }
- else
- {
- // Full Array transform if we're not doing read refinement.
-
- //list of array-read indices corresponding to arrName, seen while
- //traversing the AST tree. we need this list to construct the ITEs
- const arrTypeMap& new_read_Indices = arrayToIndexToRead[arrName];
-
- arrTypeMap::const_iterator it2 = new_read_Indices.begin();
- arrTypeMap::const_iterator it2end = new_read_Indices.end();
- for (; it2 != it2end; it2++)
- {
- ASTNode cond = simp->CreateSimplifiedEQ(readIndex, it2->first);
- if (ASTFalse == cond)
- continue;
-
- if (ASTTrue == cond)
- {
- result = it2->second.ite;
- break;
- }
-
- result =
- simp->CreateSimplifiedTermITE(cond, it2->second.ite, result);
- }
- }
-
- assert(arrName.GetType() == ARRAY_TYPE);
- arrayToIndexToRead[arrName].insert(make_pair(readIndex,ArrayRead (result, CurrentSymbol)));
- break;
- } //end of READ over a SYMBOL
- case WRITE:
- {
- /* The input to this case is: READ((WRITE A i val) j)
- *
- * The output of this case is: ITE( (= i j) val (READ A j))
- */
-
- /* 1. arrName or term[0] is infact a WRITE(A,i,val) expression
- *
- * 2. term[1] is the read-index j
- *
- * 3. arrName[0] is the new arrName i.e. A. A can be either a
- SYMBOL or a nested WRITE. no other possibility
- *
- * 4. arrName[1] is the WRITE index i.e. i
- *
- * 5. arrName[2] is the WRITE value i.e. val (val can inturn
- * be an array read)
- */
-
- ASTNode writeIndex = TransformTerm(arrName[1]);
- ASTNode writeVal = TransformTerm(arrName[2]);
-
- if (ARRAY_TYPE != arrName[0].GetType())
- FatalError("TransformArray: "\
- "An array write is being attempted on a non-array:",
- term);
-
- //if ((SYMBOL == arrName[0].GetKind()
- //|| WRITE == arrName[0].GetKind()))
- {
- ASTNode cond =
- simp->CreateSimplifiedEQ(writeIndex, readIndex);
- assert(BVTypeCheck(cond));
-
- // If the condition is true, it saves iteratively transforming through
- // all the (possibly nested) arrays.
- if (ASTTrue == cond)
- {
- result = writeVal;
- }
- else
- {
- ASTNode readTerm =
- nf->CreateTerm(READ, width, arrName[0], readIndex);
- assert(BVTypeCheck(readTerm));
-
- // The simplifying node factory may have produced
- // something that's not a READ.
- ASTNode readPushedIn = TransformTerm(readTerm);
- assert(BVTypeCheck(readPushedIn));
-
- result =
- simp->CreateSimplifiedTermITE(cond, writeVal, readPushedIn);
- }
- }
-
- // Trevor: I've removed this code because I don't see the advantage in working
- // inside out. i.e. transforming read(write(ite(p,A,B),i,j),k), into
- // read(ite(p,write(A,i,j),write(B,i,j),k). That is bringing up the ite.
- // Without this code it will become: ite(i=k, j, read(ite(p,A,B),k))
-
- #if 0
- else if (ITE == arrName[0].GetKind())
- {
- // pull out the ite from the write // pushes the write
- // through.
- ASTNode writeTrue =
- nf->CreateNode(WRITE, (arrName[0][1]), writeIndex, writeVal);
- writeTrue.SetIndexWidth(writeIndex.GetValueWidth());
- writeTrue.SetValueWidth(writeVal.GetValueWidth());
- assert(ARRAY_TYPE == writeTrue.GetType());
-
- ASTNode writeFalse =
- nf->CreateNode(WRITE, (arrName[0][2]), writeIndex, writeVal);
- writeFalse.SetIndexWidth(writeIndex.GetValueWidth());
- writeFalse.SetValueWidth(writeVal.GetValueWidth());
- assert(ARRAY_TYPE == writeFalse.GetType());
-
- result = (writeTrue == writeFalse) ?
- writeTrue : simp->CreateSimplifiedTermITE(TransformFormula(arrName[0][0]),
- writeTrue, writeFalse);
- result.SetIndexWidth(writeIndex.GetValueWidth());
- result.SetValueWidth(writeVal.GetValueWidth());
- assert(ARRAY_TYPE == result.GetType());
-
- result =
- nf->CreateTerm(READ, writeVal.GetValueWidth(),
- result, readIndex);
- BVTypeCheck(result);
- result = TransformArrayRead(result);
- }
- else
- FatalError("TransformArray: Write over bad type.");
- #endif
- break;
- } //end of READ over a WRITE
- case ITE:
- {
- /* READ((ITE cond thn els) j)
- *
- * is transformed into
- *
- * (ITE cond (READ thn j) (READ els j))
- */
-
- // pull out the ite from the read // pushes the read through.
-
- //(ITE cond thn els)
-
- ASTNode cond = arrName[0];
- cond = TransformFormula(cond);
-
- const ASTNode& thn = arrName[1];
- const ASTNode& els = arrName[2];
-
- //(READ thn j)
- ASTNode thnRead = nf->CreateTerm(READ, width, thn, readIndex);
- assert(BVTypeCheck(thnRead));
-
- //(READ els j)
- ASTNode elsRead = nf->CreateTerm(READ, width, els, readIndex);
- assert(BVTypeCheck(elsRead));
-
- /* We try to call TransformTerm only if necessary, because it
- * introduces a new symbol for each read. The amount of work we
- * need to do later is based on the square of the number of symbols.
- */
- if (ASTTrue == cond)
- {
- result = TransformTerm(thnRead);
- }
- else if (ASTFalse == cond)
- {
- result = TransformTerm(elsRead);
- }
- else
- {
- thnRead = TransformTerm(thnRead);
- elsRead = TransformTerm(elsRead);
-
- //(ITE cond (READ thn j) (READ els j))
- result = simp->CreateSimplifiedTermITE(cond, thnRead, elsRead);
- }
- break;
- }
- default:
- FatalError("TransformArray: "\
- "The READ is NOT over SYMBOL/WRITE/ITE", term);
- break;
- }
-
- assert(BVTypeCheck(result));
- assert(!result.IsNull());
- (*TransformMap)[term] = result;
- return result;
- } //end of TransformArray()
-
-
- //Since these arrayreads are being nuked and recorded in the
- //substitutionmap, we have to also record the fact that each
- //arrayread (e0 is of the form READ(Arr,const) here is represented
- //by a BVCONST (e1). This is necessary for later Leibnitz Axiom
- //generation
- void ArrayTransformer::FillUp_ArrReadIndex_Vec(const ASTNode& e0,
- const ASTNode& e1)
- {
- assert (e0.GetKind() == READ);
- assert (e0[0].GetKind() == SYMBOL);
- assert (e0[1].GetKind() == BVCONST);
- assert (e1.GetKind() == BVCONST);
- assert(arrayToIndexToRead[e0[0]].find(e0[1]) ==arrayToIndexToRead[e0[0]].end());
-
- arrayToIndexToRead[e0[0]].insert(make_pair(e0[1],ArrayRead (e1, e1)));
- }
-
-
-} //end of namespace BEEV
diff --git a/src/vendor/stp/src/AST/ArrayTransformer.h b/src/vendor/stp/src/AST/ArrayTransformer.h
deleted file mode 100644
index d2bfcfb79..000000000
--- a/src/vendor/stp/src/AST/ArrayTransformer.h
+++ /dev/null
@@ -1,150 +0,0 @@
-// -*- c++ -*-
-/********************************************************************
- * AUTHORS: Vijay Ganesh, Trevor Hansen
- *
- * BEGIN DATE: November, 2005
- *
- * LICENSE: Please view LICENSE file in the home dir of this Program
- ********************************************************************/
-
-#ifndef TRANSFORM_H
-#define TRANSFORM_H
-
-#include "AST.h"
-#include "../STPManager/STPManager.h"
-#include "../AST/NodeFactory/SimplifyingNodeFactory.h"
-#include "../boost/noncopyable.hpp"
-
-namespace BEEV
-{
- class Simplifier;
-
- class ArrayTransformer : boost::noncopyable
- {
- public:
-
- // These map from array and index to ITE and Symbol.
- struct ArrayRead
- {
- ArrayRead(ASTNode _ite, ASTNode _symbol)
- {
- assert(! _symbol.IsNull());
- assert(_ite.GetValueWidth() == _symbol.GetValueWidth());
- assert ((SYMBOL == _symbol.GetKind() || BVCONST == _symbol.GetKind()));
-
- ite = _ite;
- symbol = _symbol;
- }
-
- ASTNode ite; // if not using refinement this will be the ITE for the read. Otherwise == symbol.
- ASTNode symbol; // each read is allocated a distinct fresh variable.
- ASTNode index_symbol; // A symbol constrained to equal the index expression.
- };
-
- // MAP: This maps from arrays to their indexes.
- // This map is used by the TransformArray()
- // function ,as well as the counter example, and refinement.
- // This map is useful in converting array reads into
- // nested ITE constructs. Suppose there are two array reads in the
- // input Read(A,i) and Read(A,j). Then Read(A,i) is replaced with
- // a symbolic constant, say v1, and Read(A,j) is replaced with the
- // following ITE: ITE(i=j,v1,v2)
-
- typedef map arrTypeMap;
- typedef map ArrType ;
- ArrType arrayToIndexToRead;
-
- private:
-
- /****************************************************************
- * Private Typedefs and Data *
- ****************************************************************/
-
- // Handy defs
- ASTNode ASTTrue, ASTFalse, ASTUndefined;
-
-
- // Memo table used by the transformer while it is transforming the
- // formulas and terms
- ASTNodeMap* TransformMap;
-
- // Flag for debuggin the transformer
- const bool debug_transform;
-
- // Ptr to an external simplifier
- Simplifier * simp;
-
- // Ptr to STPManager
- STPMgr * bm;
-
- // Ptr to class that records the runtimes for various parts of the
- // code
- RunTimes * runTimes;
-
- NodeFactory *nf;
-
- /****************************************************************
- * Private Member Functions *
- ****************************************************************/
-
- ASTNode TransformTerm(const ASTNode& inputterm);
- void assertTransformPostConditions(const ASTNode & term, ASTNodeSet& visited);
-
- ASTNode TransformArrayRead(const ASTNode& term);
-
- ASTNode TransformFormula(const ASTNode& form);
-
- public:
- static ASTNode TranslateSignedDivModRem(const ASTNode& in, NodeFactory*nf, STPMgr *bm);
-
- //fill the arrayname_readindices vector if e0 is a READ(Arr,index)
- //and index is a BVCONST
- void FillUp_ArrReadIndex_Vec(const ASTNode& e0, const ASTNode& e1);
-
-
- /****************************************************************
- * Public Member Functions *
- ****************************************************************/
-
- // Constructor
- ArrayTransformer(STPMgr * bm, Simplifier* s) :
- bm(bm),
- simp(s),
- debug_transform(0),
- TransformMap(NULL)
- {
- nf = bm->defaultNodeFactory;
-
- runTimes = bm->GetRunTimes();
- ASTTrue = bm->CreateNode(TRUE);
- ASTFalse = bm->CreateNode(FALSE);
- ASTUndefined = bm->CreateNode(UNDEFINED);
- }
-
- // Takes a formula, transforms it by replacing array reads with
- // variables, and returns the transformed formula
- ASTNode TransformFormula_TopLevel(const ASTNode& form);
-
- void ClearAllTables(void)
- {
- arrayToIndexToRead.clear();
- }
-
- void printArrayStats()
- {
- cerr << "Array Sizes:";
-
- for (ArrType::const_iterator
- iset = arrayToIndexToRead.begin(),
- iset_end = arrayToIndexToRead.end();
- iset != iset_end; iset++)
- {
- cerr << iset->second.size() << " : ";
- }
- cerr << endl;
- }
-
- }; //end of class Transformer
-
-};//end of namespace
-#endif
diff --git a/src/vendor/stp/src/AST/Makefile b/src/vendor/stp/src/AST/Makefile
deleted file mode 100644
index 0190736d2..000000000
--- a/src/vendor/stp/src/AST/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-SRCTOP = ..
-include $(SRCTOP)/Makefile.common
-
-SRCS = $(wildcard *.cpp)
-SRCS += $(wildcard NodeFactory/*.cpp)
-OBJS = $(SRCS:.cpp=.o)
-OBJS += ASTKind.o
-
-
-#Make the ast library for use by other modules
-libast.a: $(OBJS)
- $(RM) $@
- $(AR) qcs $@ $^
-
-# ASTKind.h and ASTKind.cpp are automatically generated
-ASTKind.h ASTKind.cpp: ASTKind.kinds genkinds.pl
- ./genkinds.pl
-
-.PHONY: clean
-clean:
- $(RM) *.o */*.o *~ *.a .#* depend ASTKind.cpp ASTKind.h
-
-depend: $(SRCS)
- @$(call makedepend,$@,$(SRCS))
-
--include depend
-
diff --git a/src/vendor/stp/src/AST/NodeFactory/HashingNodeFactory.cpp b/src/vendor/stp/src/AST/NodeFactory/HashingNodeFactory.cpp
deleted file mode 100644
index 48fe2a01b..000000000
--- a/src/vendor/stp/src/AST/NodeFactory/HashingNodeFactory.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "HashingNodeFactory.h"
-#include "../AST.h"
-#include "../../STPManager/STP.h"
-
-using BEEV::Kind;
-using BEEV::ASTInterior;
-using BEEV::ASTVec;
-using BEEV::ASTNode;
-
-
-HashingNodeFactory::~HashingNodeFactory()
-{
-}
-
-// Get structurally hashed version of the node.
-BEEV::ASTNode HashingNodeFactory::CreateNode(const Kind kind, const BEEV::ASTVec & back_children)
-{
- // We can't create NOT(NOT (..)) nodes because of how the numbering scheme we use works.
- // So you can't trust the hashiing node factory even to return nodes of the same kind that
- // you ask for.
- if (kind == BEEV::NOT && back_children[0].GetKind() == BEEV::NOT)
- {
- return back_children[0][0];
- }
-
- ASTVec children(back_children);
- // The Bitvector solver seems to expect constants on the RHS, variables on the LHS.
- // We leave the order of equals children as we find them.
- if (BEEV::isCommutative(kind) && kind != BEEV::AND)
- {
- SortByArith(children);
- }
-
- ASTInterior *n_ptr = new ASTInterior(kind,children);
- ASTNode n(bm.LookupOrCreateInterior(n_ptr));
- return n;
-}
-
-// Create and return an ASTNode for a term
-ASTNode HashingNodeFactory::CreateTerm(Kind kind, unsigned int width,const ASTVec &children)
-{
-
- ASTNode n = CreateNode(kind, children);
- n.SetValueWidth(width);
-
- //by default we assume that the term is a Bitvector. If
- //necessary the indexwidth can be changed later
- n.SetIndexWidth(0);
- return n;
-}
-
-
diff --git a/src/vendor/stp/src/AST/NodeFactory/HashingNodeFactory.h b/src/vendor/stp/src/AST/NodeFactory/HashingNodeFactory.h
deleted file mode 100644
index 5ef94879b..000000000
--- a/src/vendor/stp/src/AST/NodeFactory/HashingNodeFactory.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// A Node factory that only does structural hashing.
-#ifndef HASHINGNODEFACTORY_H_
-#define HASHINGNODEFACTORY_H_
-
-#include "NodeFactory.h"
-#include "../ASTKind.h"
-namespace BEEV
-{
- class STPMgr;
-}
-
-class HashingNodeFactory : public NodeFactory
-{
-public:
- HashingNodeFactory(BEEV::STPMgr& bm_)
- :NodeFactory(bm_)
- {
- }
-
- virtual ~HashingNodeFactory();
- BEEV::ASTNode CreateNode(const BEEV::Kind kind, const BEEV::ASTVec & back_children);
- BEEV::ASTNode CreateTerm(BEEV::Kind kind, unsigned int width,const BEEV::ASTVec &children);
-
- virtual std::string getName() {return "hashing";}
-};
-
-#endif /* HASHINGNODEFACTORY_H_ */
diff --git a/src/vendor/stp/src/AST/NodeFactory/NodeFactory.cpp b/src/vendor/stp/src/AST/NodeFactory/NodeFactory.cpp
deleted file mode 100644
index 9930c7a6a..000000000
--- a/src/vendor/stp/src/AST/NodeFactory/NodeFactory.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-#include "../ASTKind.h"
-#include "../AST.h"
-#include "../../STPManager/STPManager.h"
-
-NodeFactory::~NodeFactory()
-{
-}
-
-BEEV::ASTNode NodeFactory::CreateTerm(BEEV::Kind kind, unsigned int width,
- const BEEV::ASTVec &children)
-{
- return CreateTerm(kind, width, children);
-}
-
-ASTNode NodeFactory::CreateTerm(Kind kind, unsigned int width,
- const ASTNode& child0, const ASTVec &children)
-{
- ASTVec child;
- child.reserve(children.size() + 1);
- child.push_back(child0);
- child.insert(child.end(), children.begin(), children.end());
- return CreateTerm(kind, width, child);
-}
-
-ASTNode NodeFactory::CreateTerm(Kind kind, unsigned int width,
- const ASTNode& child0, const ASTNode& child1, const ASTVec &children)
-{
- ASTVec child;
- child.reserve(children.size() + 2);
- child.push_back(child0);
- child.push_back(child1);
- child.insert(child.end(), children.begin(), children.end());
- return CreateTerm(kind, width, child);
-}
-
-ASTNode NodeFactory::CreateTerm(Kind kind, unsigned int width,
- const ASTNode& child0, const ASTNode& child1, const ASTNode& child2,
- const ASTVec &children)
-{
- ASTVec child;
- child.reserve(children.size() + 3);
- child.push_back(child0);
- child.push_back(child1);
- child.push_back(child2);
- child.insert(child.end(), children.begin(), children.end());
- return CreateTerm(kind, width, child);
-}
-
-ASTNode NodeFactory::CreateNode(Kind kind, const ASTNode& child0,
- const ASTVec & back_children)
-{
- ASTVec front_children;
- front_children.reserve(1 + back_children.size());
- front_children.push_back(child0);
- front_children.insert(front_children.end(), back_children.begin(),
- back_children.end());
- return CreateNode(kind, front_children);
-}
-
-ASTNode NodeFactory::CreateNode(Kind kind, const ASTNode& child0,
- const ASTNode& child1, const ASTVec & back_children)
-{
- ASTVec front_children;
- front_children.reserve(2 + back_children.size());
- front_children.push_back(child0);
- front_children.push_back(child1);
- front_children.insert(front_children.end(), back_children.begin(),
- back_children.end());
- return CreateNode(kind, front_children);
-}
-
-ASTNode NodeFactory::CreateNode(Kind kind, const ASTNode& child0,
- const ASTNode& child1, const ASTNode& child2,
- const ASTVec & back_children)
-{
- ASTVec front_children;
- front_children.reserve(3 + back_children.size());
- front_children.push_back(child0);
- front_children.push_back(child1);
- front_children.push_back(child2);
- front_children.insert(front_children.end(), back_children.begin(),
- back_children.end());
- return CreateNode(kind, front_children);
-}
-
-ASTNode NodeFactory::CreateArrayTerm(Kind kind, unsigned int index, unsigned int width,
- const ASTNode& child0, const ASTNode& child1, const ASTNode& child2,
- const ASTVec &children)
-{
- ASTVec child;
- child.reserve(children.size() + 3);
- child.push_back(child0);
- child.push_back(child1);
- child.push_back(child2);
- child.insert(child.end(), children.begin(), children.end());
- return CreateArrayTerm(kind, index, width, child);
-}
-
-BEEV::ASTNode NodeFactory::CreateArrayTerm(Kind kind, unsigned int index,
- unsigned int width, const BEEV::ASTVec &children)
-{
- ASTNode result = CreateTerm(kind, width, children);
- result.SetIndexWidth(index);
- return result;
-}
-
-BEEV::ASTNode NodeFactory::getTrue() {return bm.ASTTrue;}
-BEEV::ASTNode NodeFactory::getFalse(){return bm.ASTFalse;}
-
-
-ASTNode NodeFactory::CreateSymbol(const char * const name, unsigned indexWidth, unsigned valueWidth)
-{
- ASTNode n = bm.LookupOrCreateSymbol(name);
- n.SetIndexWidth(indexWidth);
- n.SetValueWidth(valueWidth);
- return n;
-}
-
-ASTNode NodeFactory::CreateConstant(BEEV::CBV cbv, unsigned width)
-{
- return bm.CreateBVConst(cbv,width);
-}
diff --git a/src/vendor/stp/src/AST/NodeFactory/NodeFactory.h b/src/vendor/stp/src/AST/NodeFactory/NodeFactory.h
deleted file mode 100644
index 41e2f3ac2..000000000
--- a/src/vendor/stp/src/AST/NodeFactory/NodeFactory.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// Abstract base class for all the node factories.
-#ifndef NODEFACTORY_H
-#define NODEFACTORY_H
-
-#include
-#include "../ASTKind.h"
-#include "../../boost/noncopyable.hpp"
-
-namespace BEEV
-{
-class ASTNode;
-typedef std::vector ASTVec;
-extern ASTVec _empty_ASTVec;
-class STPMgr;
-typedef unsigned int * CBV;
-}
-
-using BEEV::ASTNode;
-using BEEV::Kind;
-using BEEV::ASTVec;
-using BEEV::_empty_ASTVec;
-
-class NodeFactory : boost::noncopyable
-{
-protected:
- BEEV::STPMgr& bm;
-
-public:
- NodeFactory(BEEV::STPMgr& bm_) : bm(bm_){}
-
- virtual ~NodeFactory();
-
- virtual BEEV::ASTNode CreateTerm(Kind kind, unsigned int width,
- const BEEV::ASTVec &children) =0;
-
- virtual BEEV::ASTNode CreateArrayTerm(Kind kind, unsigned int index, unsigned int width,
- const BEEV::ASTVec &children);
-
- virtual BEEV::ASTNode CreateNode(Kind kind,
- const BEEV::ASTVec& children) =0;
-
- ASTNode CreateSymbol(const char * const name, unsigned indexWidth, unsigned valueWidth);
-
- ASTNode CreateTerm(Kind kind, unsigned int width, const ASTNode& child0,
- const ASTVec &children = _empty_ASTVec);
- ASTNode CreateTerm(Kind kind, unsigned int width, const ASTNode& child0,
- const ASTNode& child1, const ASTVec &children = _empty_ASTVec);
- ASTNode CreateTerm(Kind kind, unsigned int width, const ASTNode& child0,
- const ASTNode& child1, const ASTNode& child2,
- const ASTVec &children = _empty_ASTVec);
-
- ASTNode CreateNode(Kind kind, const ASTNode& child0,
- const ASTVec & back_children = _empty_ASTVec);
- ASTNode CreateNode(Kind kind, const ASTNode& child0, const ASTNode& child1,
- const ASTVec & back_children = _empty_ASTVec);
- ASTNode CreateNode(Kind kind, const ASTNode& child0, const ASTNode& child1,
- const ASTNode& child2, const ASTVec & back_children =
- _empty_ASTVec);
-
-
- ASTNode CreateArrayTerm(Kind kind, unsigned int index, unsigned int width, const ASTNode& child0,
- const ASTNode& child1, const ASTNode& child2,
- const ASTVec &children = _empty_ASTVec);
-
- ASTNode getTrue();
- ASTNode getFalse();
-
- ASTNode CreateConstant(BEEV::CBV cbv, unsigned width);
-
- virtual std::string getName()=0;
-};
-
-#endif
diff --git a/src/vendor/stp/src/AST/NodeFactory/SimplifyingNodeFactory.cpp b/src/vendor/stp/src/AST/NodeFactory/SimplifyingNodeFactory.cpp
deleted file mode 100644
index 647e64c16..000000000
--- a/src/vendor/stp/src/AST/NodeFactory/SimplifyingNodeFactory.cpp
+++ /dev/null
@@ -1,1466 +0,0 @@
-/* A node factory that:
- * * Sorts children to increases sharing,
- * * Performs constant evaluation,
- * * performs simplify boolean simplifications,
- * * converts less thans to greater thans.
- *
- * NOTE: CreateNode doesn't necessary return a node with the same Kind as what it was called
- * with. For example: (AND TRUE FALSE) will return FALSE. Which isn't an AND node.
- *
- * The intention is to never create nodes that will later be simplified by single level
- * re-write rules. So we will never create the node (NOT(NOT x)). This is and example of
- * a multi-level rule that never increases the global number of nodes.
- *
- * These rules (mostly) don't increase the total number of nodes by more than one.
- *
- * Sometimes the number of nodes is increased. e.g. creating BVSLT(x,y), will create NOT(BVGT(y,x)).
- * i.e. it will create an extra node.
- *
- * I think we've got all the two input cases that either map to a constant, or to an input value.
- * e.g. (a >> a), (a xor a), (a or a), (a and a), (a + 0), (a-0)..
- *
- */
-
-#include "../../AST/AST.h"
-#include
-#include "SimplifyingNodeFactory.h"
-#include "../../simplifier/simplifier.h"
-#include "../ArrayTransformer.h"
-#include
-
-using BEEV::Kind;
-
-using BEEV::SYMBOL;
-using BEEV::BVNEG;
-using BEEV::BVMOD;
-using BEEV::BVUMINUS;
-using BEEV::BVMULT;
-using BEEV::ITE;
-using BEEV::EQ;
-using BEEV::BVSRSHIFT;
-using BEEV::SBVREM;
-using BEEV::SBVMOD;
-using BEEV::SBVDIV;
-using BEEV::BVCONCAT;
-using BEEV::BVEXTRACT;
-using BEEV::BVRIGHTSHIFT;
-using BEEV::BVPLUS;
-using BEEV::BVXOR;
-using BEEV::BVDIV;
-
-static bool debug_simplifyingNodeFactory = false;
-
-ASTNode
-SimplifyingNodeFactory::CreateNode(Kind kind, const ASTVec & children)
-{
-
- assert(kind != SYMBOL);
- // These are created specially.
-
- // If all the parameters are constant, return the constant value.
- // The bitblaster calls CreateNode with a boolean vector. We don't try to simplify those.
- if (kind != BEEV::UNDEFINED && kind != BEEV::BOOLEAN && kind != BEEV::BITVECTOR && kind != BEEV::ARRAY)
- {
- bool allConstant = true;
-
- for (unsigned i = 0; i < children.size(); i++)
- if (!children[i].isConstant())
- {
- allConstant = false;
- break;
- }
-
- if (allConstant)
- {
- const ASTNode& hash = hashing.CreateNode(kind, children);
- const ASTNode& c = NonMemberBVConstEvaluator(hash);
- assert(c.isConstant());
- return c;
- }
- }
- ASTNode result;
-
- switch (kind)
- {
- // convert the Less thans to greater thans.
- case BEEV::BVLT:
- assert(children.size() ==2);
- result = NodeFactory::CreateNode(BEEV::BVGT, children[1], children[0]);
- break;
-
- case BEEV::BVLE:
- assert(children.size() ==2);
- result = NodeFactory::CreateNode(BEEV::BVGE, children[1], children[0]);
- break;
-
- case BEEV::BVSLT:
- assert(children.size() ==2);
- result = NodeFactory::CreateNode(BEEV::BVSGT, children[1], children[0]);
- break;
-
- case BEEV::BVSLE:
- assert(children.size() ==2);
- result = NodeFactory::CreateNode(BEEV::BVSGE, children[1], children[0]);
- break;
-
- case BEEV::BVSGT:
- assert(children.size() ==2);
- if (children[0] == children[1])
- result = ASTFalse;
- if (children[1].GetKind() == BEEV::BVCONST)
- {
- // 011111111 (most positive number.)
- unsigned width = children[0].GetValueWidth();
- BEEV::CBV max = CONSTANTBV::BitVector_Create(width, false);
- CONSTANTBV::BitVector_Fill(max);
- CONSTANTBV::BitVector_Bit_Off(max, width - 1);
- ASTNode biggestNumber = bm.CreateBVConst(max, width);
- if (children[1] == biggestNumber)
- result = ASTFalse;
- }
- if (children[0].GetKind() == BEEV::BVCONST)
- {
- unsigned width = children[0].GetValueWidth();
- // 1000000000 (most negative number.)
- BEEV::CBV max = CONSTANTBV::BitVector_Create(width, true);
- CONSTANTBV::BitVector_Bit_On(max, width - 1);
- ASTNode smallestNumber = bm.CreateBVConst(max, width);
- if (children[0] == smallestNumber)
- result = ASTFalse;
- }
-
- if (children[0].GetKind() == BVCONCAT && children[1].GetKind() == BVCONCAT && children[0][1] == children[1][1])
- result = NodeFactory::CreateNode(BEEV::BVSGT, children[0][0], children[1][0]);
-
- break;
-
- case BEEV::BVGT:
- assert(children.size() ==2);
- if (children[0] == children[1])
- result = ASTFalse;
- if (children[0].isConstant() && CONSTANTBV::BitVector_is_empty(children[0].GetBVConst()))
- result = ASTFalse;
- if (children[1].isConstant() && CONSTANTBV::BitVector_is_full(children[1].GetBVConst()))
- result = ASTFalse;
- if (children[0].GetKind() == BVRIGHTSHIFT && children[0][0] == children[1])
- result = ASTFalse;
- if (children[0].GetKind() == BVCONCAT && children[1].GetKind() == BVCONCAT && children[0][1] == children[1][1])
- result = NodeFactory::CreateNode(BEEV::BVGT, children[0][0], children[1][0]);
- if (children[0].GetKind() == BVCONCAT && children[1].GetKind() == BVCONCAT && children[0][0] == children[1][0])
- result = NodeFactory::CreateNode(BEEV::BVGT, children[0][1], children[1][1]);
- if (children[1].isConstant() && CONSTANTBV::BitVector_is_empty(children[1].GetBVConst()))
- result = NodeFactory::CreateNode(BEEV::NOT, NodeFactory::CreateNode(EQ, children[0], children[1]));
- if (children[0].isConstant() && CONSTANTBV::BitVector_is_full(children[0].GetBVConst()))
- result = NodeFactory::CreateNode(BEEV::NOT, NodeFactory::CreateNode(EQ, children[0], children[1]));
- if (children[0].GetKind() == BEEV::BVAND && children[0].Degree() > 1
- && ((children[0][0] == children[1]) || children[0][1] == children[1]))
- result = ASTFalse;
- break;
-
- case BEEV::BVGE:
- assert(children.size() ==2);
- {
- ASTNode a = NodeFactory::CreateNode(BEEV::BVGT, children[1], children[0]);
- result = NodeFactory::CreateNode(BEEV::NOT, a);
- }
- break;
-
- case BEEV::BVSGE:
- assert(children.size() ==2);
- {
- ASTNode a = NodeFactory::CreateNode(BEEV::BVSGT, children[1], children[0]);
- result = NodeFactory::CreateNode(BEEV::NOT, a);
- }
- break;
-
- case BEEV::NOT:
- result = CreateSimpleNot(children);
- break;
- case BEEV::AND:
- result = CreateSimpleAndOr(1, children);
- break;
- case BEEV::OR:
- result = CreateSimpleAndOr(0, children);
- break;
- case BEEV::NAND:
- result = CreateSimpleNot(CreateSimpleAndOr(1, children));
- break;
- case BEEV::NOR:
- result = CreateSimpleNot(CreateSimpleAndOr(0, children));
- break;
- case BEEV::XOR:
- result = CreateSimpleXor(children);
- break;
- case ITE:
- result = CreateSimpleFormITE(children);
- break;
- case EQ:
- result = CreateSimpleEQ(children);
- break;
- case BEEV::IFF:
- {
- assert(children.size() ==2);
- ASTVec newCh;
- newCh.reserve(2);
- newCh.push_back(CreateSimpleNot(children[0]));
- newCh.push_back(children[1]);
- result = CreateSimpleXor(newCh);
- break;
- }
- case BEEV::IMPLIES:
- {
- assert(children.size() ==2);
- if (children[0] == children[1])
- result = bm.ASTTrue;
- else
- {
- ASTVec newCh;
- newCh.reserve(2);
- newCh.push_back(CreateSimpleNot(children[0]));
- newCh.push_back(children[1]);
- result = CreateSimpleAndOr(0, newCh);
- }
- break;
- }
-
- default:
- result = hashing.CreateNode(kind, children);
- }
-
- if (result.IsNull())
- result = hashing.CreateNode(kind, children);
-
- return result;
-}
-
-ASTNode
-SimplifyingNodeFactory::CreateSimpleNot(const ASTNode& form)
-{
- const Kind k = form.GetKind();
- switch (k)
- {
- case BEEV::FALSE:
- {
- return form.GetSTPMgr()->ASTTrue;
- }
- case BEEV::TRUE:
- {
- return form.GetSTPMgr()->ASTFalse;
- }
- case BEEV::NOT:
- {
- return form[0];
- } // NOT NOT cancellation
- default:
- {
- ASTVec children;
- children.push_back(form);
- return hashing.CreateNode(BEEV::NOT, children);
- }
- }
-}
-
-ASTNode
-SimplifyingNodeFactory::CreateSimpleNot(const ASTVec& children)
-{
- const Kind k = children[0].GetKind();
- switch (k)
- {
- case BEEV::FALSE:
- {
- return children[0].GetSTPMgr()->ASTTrue;
- }
- case BEEV::TRUE:
- {
- return children[0].GetSTPMgr()->ASTFalse;
- }
- case BEEV::NOT:
- {
- return children[0][0];
- } // NOT NOT cancellation
- default:
- {
- return hashing.CreateNode(BEEV::NOT, children);
- }
- }
-}
-
-ASTNode
-SimplifyingNodeFactory::CreateSimpleAndOr(bool IsAnd, const ASTNode& form1, const ASTNode& form2)
-{
- ASTVec children;
- children.push_back(form1);
- children.push_back(form2);
- return CreateSimpleAndOr(IsAnd, children);
-}
-
-ASTNode
-SimplifyingNodeFactory::CreateSimpleAndOr(bool IsAnd, const ASTVec &children)
-{
- const Kind k = IsAnd ? BEEV::AND : BEEV::OR;
-
- if (k == BEEV::OR && children.size() == 2)
- {
- const ASTNode& c0 = children[0];
- const ASTNode& c1 = children[1];
- if (c0.GetKind() == BEEV::NOT && c0[0] == c1)
- return ASTTrue;
- if (c1.GetKind() == BEEV::NOT && c1[0] == c0)
- return ASTTrue;
- }
- if (k == BEEV::AND && children.size() == 2)
- {
- const ASTNode& c0 = children[0];
- const ASTNode& c1 = children[1];
- if (c0.GetKind() == BEEV::NOT && c0[0] == c1)
- return ASTFalse;
- if (c1.GetKind() == BEEV::NOT && c1[0] == c0)
- return ASTFalse;
- }
-
- const ASTNode& annihilator = (IsAnd ? ASTFalse : ASTTrue);
- const ASTNode& identity = (IsAnd ? ASTTrue : ASTFalse);
-
- ASTNode retval;
- ASTVec new_children;
- new_children.reserve(children.size());
-
- const ASTVec::const_iterator it_end = children.end();
- for (ASTVec::const_iterator it = children.begin(); it != it_end; it++)
- {
- ASTVec::const_iterator next_it;
-
- bool nextexists = (it + 1 < it_end);
- if (nextexists)
- next_it = it + 1;
- else
- next_it = it_end;
-
- if (nextexists)
- if (next_it->GetKind() == BEEV::NOT && (*next_it)[0] == *it)
- return annihilator;
-
- if (*it == annihilator)
- {
- return annihilator;
- }
- else if (*it == identity || (nextexists && (*next_it == *it)))
- {
- // just drop it
- }
- else
- new_children.push_back(*it);
- }
-
- // If we get here, we saw no annihilators, and children should
- // be only the non-True nodes.
-
- if (0 == new_children.size())
- {
- retval = identity;
- }
- else if (1 == new_children.size())
- {
- // there is just one child
- retval = new_children[0];
- }
- else
- {
- // 2 or more children. Create a new node.
- retval = hashing.CreateNode(IsAnd ? BEEV::AND : BEEV::OR, new_children);
- }
- return retval;
-}
-
-//Tries to simplify the input to TRUE/FALSE. if it fails, then
-//return the constructed equality
-ASTNode
-SimplifyingNodeFactory::CreateSimpleEQ(const ASTVec& children)
-{
- assert(children.size() == 2);
-
- // SYMBOL = something, if not that, then CONSTANT =
- const bool swap = (children[1].GetKind() == BEEV::SYMBOL
- || ((children[0].GetKind() != BEEV::SYMBOL) && children[1].GetKind() == BEEV::BVCONST));
- const ASTNode& in1 = swap ? children[1] : children[0];
- const ASTNode& in2 = swap ? children[0] : children[1];
- const Kind k1 = in1.GetKind();
- const Kind k2 = in2.GetKind();
- const int width = in1.GetValueWidth();
-
- if (in1 == in2)
- //terms are syntactically the same
- return in1.GetSTPMgr()->ASTTrue;
-
- //here the terms are definitely not syntactically equal but may be
- //semantically equal.
- if (BEEV::BVCONST == k1 && BEEV::BVCONST == k2)
- return in1.GetSTPMgr()->ASTFalse;
-
- if ((k1 == BVNEG && k2 == BVNEG) || (k1 == BVUMINUS && k2 == BVUMINUS))
- return NodeFactory::CreateNode(EQ, in1[0], in2[0]);
-
- if ((k1 == BVUMINUS && k2 == BEEV::BVCONST) || (k1 == BVNEG && k2 == BEEV::BVCONST))
- return NodeFactory::CreateNode(EQ, in1[0], NodeFactory::CreateTerm(k1, width, in2));
-
- if ((k2 == BVUMINUS && k1 == BEEV::BVCONST) || (k2 == BVNEG && k1 == BEEV::BVCONST))
- return NodeFactory::CreateNode(EQ, in2[0], NodeFactory::CreateTerm(k2, width, in1));
-
- if ((k1 == BVNEG && in1[0] == in2) || (k2 == BVNEG && in2[0] == in1))
- return in1.GetSTPMgr()->ASTFalse;
-
- if (k2 == BEEV::BVDIV && k1 == BEEV::BVCONST && (in1 == bm.CreateZeroConst(width)))
- return NodeFactory::CreateNode(BEEV::BVGT, in2[1], in2[0]);
-
- if (k1 == BEEV::BVDIV && k2 == BEEV::BVCONST && (in2 == bm.CreateZeroConst(width)))
- return NodeFactory::CreateNode(BEEV::BVGT, in1[1], in1[0]);
-
- // split the constant to equal each part of the concat.
- if (BVCONCAT == k2 && BEEV::BVCONST == k1)
- {
- int low_b = 0;
- int high_b = in2[1].GetValueWidth() - 1;
- int low_t = in2[1].GetValueWidth();
- int high_t = width - 1;
-
- ASTNode c0 = NodeFactory::CreateTerm(BVEXTRACT, in2[1].GetValueWidth(), in1, bm.CreateBVConst(32, high_b),
- bm.CreateBVConst(32, low_b));
- ASTNode c1 = NodeFactory::CreateTerm(BVEXTRACT, in2[0].GetValueWidth(), in1, bm.CreateBVConst(32, high_t),
- bm.CreateBVConst(32, low_t));
-
- ASTNode a = NodeFactory::CreateNode(EQ, in2[1], c0);
- ASTNode b = NodeFactory::CreateNode(EQ, in2[0], c1);
- return NodeFactory::CreateNode(BEEV::AND, a, b);
- }
-
- // This increases the number of nodes. So disable for now.
- if (false && BVCONCAT == k1 && BVCONCAT == k2 && in1[0].GetValueWidth() == in2[0].GetValueWidth())
- {
- ASTNode a = NodeFactory::CreateNode(EQ, in1[0], in2[0]);
- ASTNode b = NodeFactory::CreateNode(EQ, in1[1], in2[1]);
- return NodeFactory::CreateNode(BEEV::AND, a, b);
- }
-
- if (k1 == BEEV::BVCONST && k2 == ITE && in2[1].GetKind() == BEEV::BVCONST && in2[2].GetKind() == BEEV::BVCONST)
- {
-
- ASTNode result = NodeFactory::CreateNode(ITE, in2[0], NodeFactory::CreateNode(EQ, in1, in2[1]),
- NodeFactory::CreateNode(EQ, in1, in2[2]));
-
- return result;
- }
-
- // Don't create a PLUS with the same operand on both sides.
- // We don't do big pluses, because 1) this algorithm isn't good enough
- // 2) it might split nodes (a lot).
- if ((k1 == BVPLUS && in1.Degree() <= 2) || (k2 == BVPLUS && in2.Degree() <= 2))
- {
- const ASTVec& c1 = (k1 == BVPLUS) ? in1.GetChildren() : ASTVec(1, in1);
- const ASTVec& c2 = (k2 == BVPLUS) ? in2.GetChildren() : ASTVec(1, in2);
-
- if (c1.size() <= 2 && c2.size() <= 2)
- {
- int match1 = -1, match2 = -1;
-
- for (int i = 0; i < c1.size(); i++)
- for (int j = 0; j < c2.size(); j++)
- {
- if (c1[i] == c2[j])
- {
- match1 = i;
- match2 = j;
- }
- }
-
- if (match1 != -1)
- {
- assert(match2 !=-1);
- assert(match1 == 0 || match1 == 1);
- assert(match2 == 0 || match2 == 1);
- // If it was 1 element before, it's zero now.
- ASTNode n1 = c1.size() == 1 ? bm.CreateZeroConst(width) : c1[match1 == 0 ? 1 : 0];
- ASTNode n2 = c2.size() == 1 ? bm.CreateZeroConst(width) : c2[match2 == 0 ? 1 : 0];
- return NodeFactory::CreateNode(EQ, n1, n2);
- }
- }
- }
-
- if (k2 == BVPLUS && in2.Degree() == 2 && (in2[1] == in1 || in2[0] == in1))
- {
- return NodeFactory::CreateNode(EQ, bm.CreateZeroConst(width), in2[1] == in1 ? in2[0] : in2[1]);
- }
-
- if (k1 == BVPLUS && in1.Degree() == 2 && (in1[1] == in2 || in1[0] == in2))
- {
- return NodeFactory::CreateNode(EQ, bm.CreateZeroConst(width), in1[1] == in2 ? in1[0] : in1[1]);
- }
-
- if (k1 == BEEV::BVCONST && k2 == BEEV::BVXOR && in2.Degree() == 2 && in2[0].GetKind() == BEEV::BVCONST)
- {
- return NodeFactory::CreateNode(EQ, NodeFactory::CreateTerm(BEEV::BVXOR, width, in1, in2[0]), in2[1]);
- }
-
- if (k2 == BEEV::BVCONST && k1 == BEEV::BVXOR && in1.Degree() == 2 && in1[0].GetKind() == BEEV::BVCONST)
- {
- return NodeFactory::CreateNode(EQ, NodeFactory::CreateTerm(BEEV::BVXOR, width, in2, in1[0]), in1[1]);
- }
-
- if (k2 == BEEV::BVXOR && in2.Degree() == 2 && in1 == in2[0])
- {
- return NodeFactory::CreateNode(EQ, bm.CreateZeroConst(width), in2[1]);
- }
-
- if (k1 == BEEV::BVXOR && in1.Degree() == 2 && in2 == in1[0])
- {
- return NodeFactory::CreateNode(EQ, bm.CreateZeroConst(width), in1[1]);
- }
-
- if (k1 == BEEV::BVCONST && k2 == BEEV::BVSX && (in2[0].GetValueWidth() != width))
- {
- // Each of the bits in the extended part, and one into the un-extended part must be the same.
- bool foundZero = false, foundOne = false;
- const unsigned original_width = in2[0].GetValueWidth();
- const unsigned new_width = in2.GetValueWidth();
- for (int i = original_width - 1; i < new_width; i++)
- if (CONSTANTBV::BitVector_bit_test(in1.GetBVConst(), i))
- foundOne = true;
- else
- foundZero = true;
- if (foundZero && foundOne)
- return ASTFalse;
- ASTNode lhs = NodeFactory::CreateTerm(BVEXTRACT, original_width, in1, bm.CreateBVConst(32, original_width - 1),
- bm.CreateZeroConst(32));
- ASTNode rhs = NodeFactory::CreateTerm(BVEXTRACT, original_width, in2, bm.CreateBVConst(32, original_width - 1),
- bm.CreateZeroConst(32));
- return NodeFactory::CreateNode(EQ, lhs, rhs);
- }
-
- // Simplifiy (5 = 4/x) to FALSE.
- if (bm.UserFlags.division_by_zero_returns_one_flag && k1 == BEEV::BVCONST && k2 == BEEV::BVDIV
- && in2[0].GetKind() == BEEV::BVCONST)
- {
- ASTNode oneV = bm.CreateOneConst(width);
- if (CONSTANTBV::BitVector_Lexicompare(in1.GetBVConst(), oneV.GetBVConst()) > 0 && in1 != oneV
- && CONSTANTBV::BitVector_Lexicompare(in1.GetBVConst(), in2[0].GetBVConst()) > 0)
- {
- return ASTFalse;
- }
- }
-
- if (k1 == BVNEG && k2 == BVUMINUS && in1[0] == in2[0])
- return ASTFalse;
-
- if (k1 == BVUMINUS && k2 == BVNEG && in1[0] == in2[0])
- return ASTFalse;
-
- //last resort is to CreateNode
- return hashing.CreateNode(EQ, children);
-}
-
-// Constant children are accumulated in "accumconst".
-ASTNode
-SimplifyingNodeFactory::CreateSimpleXor(const ASTVec &children)
-{
- if (debug_simplifyingNodeFactory)
- {
- cout << "========" << endl << "CreateSimpXor ";
- lpvec(children);
- cout << endl;
- }
-
- ASTVec flat_children; // empty vector
- flat_children = children;
-
- // sort so that identical nodes occur in sequential runs, followed by
- // their negations.
- SortByExprNum(flat_children);
-
- // This is the C Boolean value of all constant args seen. It is initially
- // 0. TRUE children cause it to change value.
- bool accumconst = 0;
-
- ASTVec new_children;
- new_children.reserve(children.size());
-
- const ASTVec::const_iterator it_end = flat_children.end();
- ASTVec::iterator next_it;
- for (ASTVec::iterator it = flat_children.begin(); it != it_end; it++)
- {
- next_it = it + 1;
- bool nextexists = (next_it < it_end);
-
- if (ASTTrue == *it)
- {
- accumconst = !accumconst;
- }
- else if (ASTFalse == *it)
- {
- // Ignore it
- }
- else if (nextexists && (*next_it == *it))
- {
- // x XOR x = FALSE. Skip current, write "false" into next_it
- // so that it gets tossed, too.
- *next_it = ASTFalse;
- }
- else if (nextexists && (next_it->GetKind() == BEEV::NOT) && ((*next_it)[0] == *it))
- {
- // x XOR NOT x = TRUE. Skip current, write "true" into next_it
- // so that it gets tossed, too.
- *next_it = ASTTrue;
- }
- else if (BEEV::NOT == it->GetKind())
- {
- // If child is (NOT alpha), we can flip accumconst and use alpha.
- // This is ok because (NOT alpha) == TRUE XOR alpha
- accumconst = !accumconst;
- // CreateSimpNot just takes child of not.
- new_children.push_back(CreateSimpleNot(*it));
- }
- else
- {
- new_children.push_back(*it);
- }
- }
-
- ASTNode retval;
-
- // Children should be non-constant.
- if (new_children.size() < 2)
- {
- if (0 == new_children.size())
- {
- // XOR(TRUE, FALSE) -- accumconst will be 1.
- if (accumconst)
- {
- retval = ASTTrue;
- }
- else
- {
- retval = ASTFalse;
- }
- }
- else
- {
- // there is just one child
- // XOR(x, TRUE) -- accumconst will be 1.
- if (accumconst)
- {
- retval = CreateSimpleNot(new_children[0]);
- }
- else
- {
- retval = new_children[0];
- }
- }
- }
- else
- {
- // negate first child if accumconst == 1
- if (accumconst)
- {
- new_children[0] = CreateSimpleNot(new_children[0]);
- }
- retval = hashing.CreateNode(BEEV::XOR, new_children);
- }
-
- if (debug_simplifyingNodeFactory)
- {
- cout << "returns " << retval << endl;
- }
- return retval;
-}
-
-ASTNode
-SimplifyingNodeFactory::CreateSimpleFormITE(const ASTVec& children)
-{
- const ASTNode& child0 = children[0];
- const ASTNode& child1 = children[1];
- const ASTNode& child2 = children[2];
-
- ASTNode retval;
-
- if (debug_simplifyingNodeFactory)
- {
- cout << "========" << endl << "CreateSimpleFormITE " << child0 << child1 << child2 << endl;
- }
-
- if (ASTTrue == child0)
- {
- retval = child1;
- }
- else if (ASTFalse == child0)
- {
- retval = child2;
- }
- else if (child1 == child2)
- {
- retval = child1;
- }
- // ITE(x, TRUE, y ) == x OR y
- else if (ASTTrue == child1)
- {
- retval = CreateSimpleAndOr(0, child0, child2);
- }
- // ITE(x, FALSE, y ) == (!x AND y)
- else if (ASTFalse == child1)
- {
- retval = CreateSimpleAndOr(1, CreateSimpleNot(child0), child2);
- }
- // ITE(x, y, TRUE ) == (!x OR y)
- else if (ASTTrue == child2)
- {
- retval = CreateSimpleAndOr(0, CreateSimpleNot(child0), child1);
- }
- // ITE(x, y, FALSE ) == (x AND y)
- else if (ASTFalse == child2)
- {
- retval = CreateSimpleAndOr(1, child0, child1);
- }
- else if (child0 == child1)
- {
- retval = CreateSimpleAndOr(0, child0, child2);
- }
- else if (child0 == child2)
- {
- retval = CreateSimpleAndOr(1, child0, child1);
- }
- else
- {
- retval = hashing.CreateNode(ITE, children);
- }
-
- if (debug_simplifyingNodeFactory)
- {
- cout << "returns " << retval << endl;
- }
-
- return retval;
-}
-
-// Move reads down through writes until, either we hit a write to an identical (syntactically) index,
-// or we hit a write to an index that might be the same. This is intended to simplify things like:
-// read(write(write(A,1,2),2,3),4) cheaply.
-// The "children" that are passed should be the children of a READ.
-ASTNode
-SimplifyingNodeFactory::chaseRead(const ASTVec& children, unsigned int width)
-{
- assert(children[0].GetKind() == BEEV::WRITE);
- const ASTNode& readIndex = children[1];
- ASTNode write = children[0];
-
- const bool read_is_const = (BEEV::BVCONST == readIndex.GetKind());
- ASTVec c(2);
-
- while (write.GetKind() == BEEV::WRITE)
- {
- const ASTNode& write_index = write[1];
-
- if (readIndex == write_index)
- {
- // The are definately the same.
- //cerr << "-";
- return write[2];
- }
- else if (read_is_const && BEEV::BVCONST == write_index.GetKind())
- {
- // They are definately different. Ignore this.
- //cerr << "+";
- }
- else
- {
- // They may be the same. Exit.
- // We've finished the cheap tests, now do the expensive one.
- // I don't know if the cost of this justifies the benefit.
- //cerr << "#";
- c[0] = write_index;
- c[1] = readIndex;
- ASTNode n = CreateSimpleEQ(c);
- if (n == ASTTrue)
- {
- //cerr << "#";
- return write[2];
- }
- else if (n == ASTFalse)
- {
- //cerr << "!";
- }
- else
- {
- //cerr << "."
- //Perhaps they are the same, perhaps not.
- break;
- }
- }
- write = write[0];
- }
- return hashing.CreateTerm(BEEV::READ, width, write, readIndex);
-}
-
-// This gets called with the arguments swapped as well. So the rules don't need to know about commutivity.
-ASTNode
-SimplifyingNodeFactory::plusRules(const ASTNode& n0, const ASTNode& n1)
-{
- ASTNode result;
- const int width = n0.GetValueWidth();
-
- if (n0.isConstant() && CONSTANTBV::BitVector_is_empty(n0.GetBVConst()))
- result = n1;
- else if (width == 1 && n0 == n1)
- result = bm.CreateZeroConst(1);
- else if (n0 == n1)
- result = NodeFactory::CreateTerm(BEEV::BVMULT, width, bm.CreateBVConst(string("2"), 10, width), n0);
- else if (n0.GetKind() == BVUMINUS && n1 == n0[0])
- result = bm.CreateZeroConst(width);
- else if (n1.GetKind() == BVPLUS && n1[1].GetKind() == BVUMINUS && n0 == n1[1][0] && n1.Degree() == 2)
- result = n1[0];
- else if (n1.GetKind() == BVPLUS && n1[0].GetKind() == BVUMINUS && n0 == n1[0][0] && n1.Degree() == 2)
- result = n1[1];
- else if (n1.GetKind() == BVUMINUS && n0.GetKind() == BVPLUS && n0.Degree() == 2 && n1[0] == n0[1])
- result = n0[0];
- else if (n1.GetKind() == BVUMINUS && n0.GetKind() == BVPLUS && n0.Degree() == 2 && n1[0] == n0[0])
- result = n0[1];
- else if (n1.GetKind() == BVNEG && n1[0] == n0)
- result = bm.CreateMaxConst(width);
- else if (n0.GetKind() == BEEV::BVCONST && n1.GetKind() == BVPLUS && n1.Degree() == 2
- && n1[0].GetKind() == BEEV::BVCONST)
- {
- ASTVec ch;
- ch.push_back(n0);
- ch.push_back(n1[0]);
- ASTNode constant = NonMemberBVConstEvaluator(&bm, BVPLUS, ch, width);
- result = NodeFactory::CreateTerm(BVPLUS, width, constant, n1[1]);
- }
- else if (n1.GetKind() == BVUMINUS && (n0.isConstant() && CONSTANTBV::BitVector_is_full(n0.GetBVConst())))
- {
- result = NodeFactory::CreateTerm(BVNEG, width, n1[0]);
- }
- else if (n1.GetKind() == BVUMINUS && n0.GetKind() == BVUMINUS)
- {
- ASTNode r = NodeFactory::CreateTerm(BVPLUS, width, n0[0], n1[0]);
- result = NodeFactory::CreateTerm(BVUMINUS, width, r);
- }
-
- return result;
-}
-
-ASTNode
-SimplifyingNodeFactory::CreateTerm(Kind kind, unsigned int width, const ASTVec &children)
-{
- if (!is_Term_kind(kind))
- FatalError("CreateTerm: Illegal kind to CreateTerm:", ASTUndefined, kind);
-
- assert(kind != BEEV::BVCONST);
- // These are created specially.
- assert(kind != BEEV::SYMBOL);
- // so are these.
-
- // If all the parameters are constant, return the constant value.
- bool allConstant = true;
- for (unsigned i = 0; i < children.size(); i++)
- if (!children[i].isConstant())
- {
- allConstant = false;
- break;
- }
-
- assert(bm.hashingNodeFactory == &hashing);
-
- if (allConstant)
- {
- const ASTNode& hash = hashing.CreateTerm(kind, width, children);
- const ASTNode& c = NonMemberBVConstEvaluator(hash);
- assert(c.isConstant());
- return c;
- }
-
- ASTNode result;
-
- switch (kind)
- {
-
- case ITE:
- {
- if (children[0] == ASTTrue)
- result = children[1];
- else if (children[0] == ASTFalse)
- result = children[2];
- else if (children[1] == children[2])
- result = children[1];
- else if (children[2].GetKind() == ITE && (children[2][0] == children[0]))
- result = NodeFactory::CreateTerm(ITE, width, children[0], children[1], children[2][2]);
- else if (children[1].GetKind() == ITE && (children[1][0] == children[0]))
- result = NodeFactory::CreateTerm(ITE, width, children[0], children[1][1], children[2]);
- else if (children[0].GetKind() == BEEV::NOT)
- result = NodeFactory::CreateTerm(ITE, width, children[0][0], children[2], children[1]);
- else if (children[0].GetKind() == EQ && children[0][1] == children[1] && children[0][0].GetKind() == BEEV::BVCONST
- && children[0][1].GetKind() != BEEV::BVCONST)
- result = NodeFactory::CreateTerm(ITE, width, children[0], children[0][0], children[2]);
- else if (children[0].GetKind() == EQ && children[0][0] == children[1] && children[0][1].GetKind() == BEEV::BVCONST
- && children[0][0].GetKind() != BEEV::BVCONST)
- result = NodeFactory::CreateTerm(ITE, width, children[0], children[0][1], children[2]);
- break;
- }
-
- case BEEV::BVMULT:
- {
- if (children.size() == 2)
- {
- if (children[0].isConstant() && CONSTANTBV::BitVector_is_empty(children[0].GetBVConst()))
- result = bm.CreateZeroConst(width);
-
- else if (children[1].isConstant() && CONSTANTBV::BitVector_is_empty(children[1].GetBVConst()))
- result = bm.CreateZeroConst(width);
-
- else if (children[1].isConstant() && children[1] == bm.CreateOneConst(width))
- result = children[0];
-
- else if (children[0].isConstant() && children[0] == bm.CreateOneConst(width))
- result = children[1];
-
- else if (width == 1 && children[0] == children[1])
- result = children[0];
-
- else if (children[0].GetKind() == BVUMINUS && children[1].GetKind() == BVUMINUS)
- result = NodeFactory::CreateTerm(BEEV::BVMULT, width, children[0][0], children[1][0]);
- else if (children[0].GetKind() == BVUMINUS)
- {
- result = NodeFactory::CreateTerm(BEEV::BVMULT, width, children[0][0], children[1]);
- result = NodeFactory::CreateTerm(BVUMINUS, width, result);
- }
- else if (children[1].GetKind() == BVUMINUS)
- {
- result = NodeFactory::CreateTerm(BEEV::BVMULT, width, children[1][0], children[0]);
- result = NodeFactory::CreateTerm(BVUMINUS, width, result);
- }
- }
- else if (children.size() > 2)
- {
- //Never create multiplications with arity > 2.
-
- deque names;
-
- for (unsigned i = 0; i < children.size(); i++)
- names.push_back(children[i]);
-
- while (names.size() > 1)
- {
- ASTNode a = names.front();
- names.pop_front();
-
- ASTNode b = names.front();
- names.pop_front();
-
- ASTNode n = NodeFactory::CreateTerm(BVMULT, a.GetValueWidth(), a, b);
- names.push_back(n);
- }
- result = names.front();
- }
- }
- break;
-
- case BEEV::BVLEFTSHIFT:
- {
- if (children[0].isConstant() && CONSTANTBV::BitVector_is_empty(children[0].GetBVConst()))
- result = bm.CreateZeroConst(width);
- else if (children[1].isConstant())
- result = BEEV::Simplifier::convertKnownShiftAmount(kind, children, bm, &hashing);
- else if (width == 1 && children[0] == children[1])
- result = bm.CreateZeroConst(1);
- else if (children[0].GetKind() == BVUMINUS)
- result = NodeFactory::CreateTerm(BVUMINUS, width,
- NodeFactory::CreateTerm(BEEV::BVLEFTSHIFT, width, children[0][0], children[1]));
- }
- break;
-
- case BVRIGHTSHIFT:
- {
- if (children[0] == children[1])
- result = bm.CreateZeroConst(width);
- if (children[0].isConstant() && CONSTANTBV::BitVector_is_empty(children[0].GetBVConst()))
- result = bm.CreateZeroConst(width);
- else if (children[1].isConstant())
- result = BEEV::Simplifier::convertKnownShiftAmount(kind, children, bm, &hashing);
- else if (children[0].isConstant() && children[0] == bm.CreateOneConst(width))
- result = NodeFactory::CreateTerm(ITE, width,
- NodeFactory::CreateNode(EQ, children[1], bm.CreateZeroConst(width)), children[0],
- bm.CreateZeroConst(width));
- else if ( width >= 3 && children[0].GetKind() == BVNEG && children[1] == children[0][0] )
- result = NodeFactory::CreateTerm(BVRIGHTSHIFT,width,bm.CreateMaxConst(width),children[0][0]);//320 -> 170
- else if ( width >= 3 && children[1].GetKind() == BVNEG && children[1][0] == children[0] )
- result = NodeFactory::CreateTerm(BVRIGHTSHIFT,width,bm.CreateMaxConst(width),children[1]);//320 -> 170
- else if ( width >= 3 && children[0].GetKind() == BVUMINUS && children[1].GetKind() == BVNEG && children[1][0] == children[0][0] )
- result = NodeFactory::CreateTerm(BVDIV,width,bm.CreateOneConst(width),children[1]);//402 -> 76
- else if ( width >= 3 && children[0].GetKind() == BVNEG && children[1].GetKind() == BVUMINUS && children[1][0] == children[0][0] )
- result = NodeFactory::CreateTerm(BVUMINUS,width,NodeFactory::CreateTerm(ITE,width,NodeFactory::CreateNode(EQ,bm.CreateZeroConst(width),children[0][0]),bm.CreateOneConst(width),bm.CreateZeroConst(width)));//391 -> 70
- }
- break;
-
- case BEEV::BVSRSHIFT:
- {
- if (children[0].isConstant() && CONSTANTBV::BitVector_is_empty(children[0].GetBVConst()))
- result = bm.CreateZeroConst(width);
- else if (width > 1 && children[0].isConstant() && children[0] == bm.CreateOneConst(width))
- result = NodeFactory::CreateTerm(ITE, width,
- NodeFactory::CreateNode(EQ, children[1], bm.CreateZeroConst(width)), children[0],
- bm.CreateZeroConst(width));
- else if (children[0].isConstant() && CONSTANTBV::BitVector_is_full(children[0].GetBVConst()))
- result = bm.CreateMaxConst(width);
- else if (children[1].isConstant() && CONSTANTBV::BitVector_is_empty(children[1].GetBVConst()))
- result = children[0];
- else if (width == 1 && children[0] == children[1])
- result = children[0];
- else if ((children[0] == children[1]) || (children[0].GetKind() == BVUMINUS && children[0][0] == children[1]))
- {
- assert(width >1);
- ASTNode extract = NodeFactory::CreateTerm(BVEXTRACT, 1, children[0], bm.CreateBVConst(32, width - 1),
- bm.CreateBVConst(32, width - 1));
- result = NodeFactory::CreateTerm(BEEV::BVSX, width, extract, bm.CreateBVConst(32, width));
- }
- else if (width == 1 && children[1].isConstant() && children[1] == bm.CreateOneConst(1))
- result = children[0];
- else if (children[1].isConstant())
- result = BEEV::Simplifier::convertArithmeticKnownShiftAmount(kind, children, bm, &hashing);
- else if (children[1].GetKind() == BVUMINUS && children[0] == children[1][0])
- result = NodeFactory::CreateTerm(BEEV::BVSRSHIFT, width, children[0], children[1][0]);
- else if (children[0].isConstant() && !CONSTANTBV::BitVector_bit_test(children[0].GetBVConst(), width - 1))
- result = NodeFactory::CreateTerm(BVRIGHTSHIFT, width, children[0], children[1]);
- else if ( width >= 3 && children[0].GetKind() == BVNEG && children[1].GetKind() == BVUMINUS && children[1][0] == children[0][0] )
- result = NodeFactory::CreateTerm(BVSRSHIFT,width,children[0],children[0][0]);//414 -> 361
-
-
- }
- break;
-
- case BEEV::BVSUB:
- if (children.size() == 2)
- {
- if (children.size() == 2 && children[0] == children[1])
- result = bm.CreateZeroConst(width);
- else if (children.size() == 2 && children[1] == bm.CreateZeroConst(width))
- result = children[0];
- else
- result = NodeFactory::CreateTerm(BVPLUS, width, children[0],
- NodeFactory::CreateTerm(BVUMINUS, width, children[1]));
- }
- break;
-
- case BEEV::BVOR:
- {
- if (children.size() == 2)
- {
- if (children[0] == children[1])
- result = children[0];
-
- if (children[0].isConstant() && CONSTANTBV::BitVector_is_full(children[0].GetBVConst()))
- result = bm.CreateMaxConst(width);
-
- if (children[1].isConstant() && CONSTANTBV::BitVector_is_full(children[1].GetBVConst()))
- result = bm.CreateMaxConst(width);
-
- if (children[1].isConstant() && CONSTANTBV::BitVector_is_empty(children[1].GetBVConst()))
- result = children[0];
-
- if (children[0].isConstant() && CONSTANTBV::BitVector_is_empty(children[0].GetBVConst()))
- result = children[1];
-
- if (children[1].GetKind() == BVNEG && children[0] == children[1][0])
- result = bm.CreateMaxConst(width);
- if (children[0].GetKind() == BVNEG && children[1] == children[0][0])
- result = bm.CreateMaxConst(width);
- }
- }
- break;
-
- case BEEV::BVXOR:
- if (children.size() == 2)
- {
- if (children[0] == children[1])
- result = bm.CreateZeroConst(width);
- if (children[1].isConstant() && CONSTANTBV::BitVector_is_empty(children[1].GetBVConst()))
- result = children[0];
-
- if (children[0].isConstant() && CONSTANTBV::BitVector_is_empty(children[0].GetBVConst()))
- result = children[1];
-
- if (children[1].isConstant() && CONSTANTBV::BitVector_is_full(children[1].GetBVConst()))
- result = NodeFactory::CreateTerm(BVNEG, width, children[0]);
-
- if (children[0].isConstant() && CONSTANTBV::BitVector_is_full(children[0].GetBVConst()))
- result = NodeFactory::CreateTerm(BVNEG, width, children[1]);
-
- if (children[1].GetKind() == BVNEG && children[1][0] == children[0])
- result = bm.CreateMaxConst(width);
-
- if (children[0].GetKind() == BVNEG && children[0][0] == children[1])
- result = bm.CreateMaxConst(width);
- if ( width >= 3 && children.size() ==2 && children[0].GetKind() == BVNEG && children[1].GetKind() == BVNEG )
- result = NodeFactory::CreateTerm(BVXOR,width,children[1][0],children[0][0]);//133 -> 133
- }
- break;
-
- case BEEV::BVAND:
- {
-
- bool oneFound = false;
- bool zeroFound = false;
-
- for (int i = 0; i < children.size(); i++)
- {
- if (children[i].GetKind() == BEEV::BVCONST)
- {
- if (CONSTANTBV::BitVector_is_full(children[i].GetBVConst()))
- oneFound = true;
- else if (CONSTANTBV::BitVector_is_empty(children[i].GetBVConst()))
- zeroFound = true;
-
- }
- }
-
- if (zeroFound)
- {
- result = bm.CreateZeroConst(width);
- }
- else if (oneFound)
- {
- ASTVec new_children;
- for (int i = 0; i < children.size(); i++)
- {
- if (children[i].GetKind() != BEEV::BVCONST || !CONSTANTBV::BitVector_is_full(children[i].GetBVConst()))
- new_children.push_back(children[i]);
- }
-
- assert(new_children.size() != 0);
- // constant. Should have been handled earlier.
- if (new_children.size() == 1)
- {
- result = new_children[0];
- }
- else
- result = hashing.CreateTerm(kind, width, new_children);
- }
- }
-
- if (children.size() == 2 && children[0] == children[1])
- {
- result = children[0];
- }
-
- // If there is just one run of 1 bits, replace by an extract and a concat.
- // i.e. 00011111111000000 & x , will be replaced by an extract of x just where
- // there are one bits. This should
- if (children.size() == 2 && (children[0].isConstant() || children[1].isConstant()))
- {
- ASTNode c0 = children[0];
- ASTNode c1 = children[1];
- if (c1.isConstant())
- {
- ASTNode t = c0;
- c0 = c1;
- c1 = t;
- }
-
- int start = -1;
- int end = -1;
- BEEV::CBV c = c0.GetBVConst();
- bool bad = false;
- for (int i = 0; i < width; i++)
- {
- if (CONSTANTBV::BitVector_bit_test(c, i))
- if (start == -1)
- start = i; // first one bit.
- else if (end != -1)
- bad = true;
-
- if (!CONSTANTBV::BitVector_bit_test(c, i))
- if (start != -1 && end == -1)
- end = i - 1; // end of run.
- }
- if (start != -1 && end == -1)
- end = width - 1;
-
- if (!bad && start != -1)
- {
- assert(end != -1);
-
- result = NodeFactory::CreateTerm(BVEXTRACT, end - start + 1, c1, bm.CreateBVConst(32, end),
- bm.CreateBVConst(32, start));
-
- if (start > 0)
- {
- ASTNode z = bm.CreateZeroConst(start);
- result = NodeFactory::CreateTerm(BVCONCAT, end + 1, result, z);
- }
- if (end < width - 1)
- {
- ASTNode z = bm.CreateZeroConst(width - end - 1);
- result = NodeFactory::CreateTerm(BVCONCAT, width, z, result);
- }
- }
- }
-
- if (children.size() == 2)
- {
- if (children[1].GetKind() == BVNEG && children[1][0] == children[0])
- result = bm.CreateZeroConst(width);
- if (children[0].GetKind() == BVNEG && children[0][0] == children[1])
- result = bm.CreateZeroConst(width);
- }
- break;
-
- case BEEV::BVSX:
- {
- if (width == children[0].GetValueWidth())
- result = children[0];
- break;
- }
-
- case BVNEG:
- if (children[0].GetKind() == BVNEG)
- result = children[0][0];
- if (children[0].GetKind() == BVPLUS && children[0].Degree() == 2 && children[0][0].GetKind() == BEEV::BVCONST
- && children[0][0] == bm.CreateMaxConst(width))
- result = NodeFactory::CreateTerm(BVUMINUS, width, children[0][1]);
- if (children[0].GetKind() == BVUMINUS)
- result = NodeFactory::CreateTerm(BVPLUS, width, children[0][0], bm.CreateMaxConst(width));
- if (children[0].GetKind() == BVMOD && children[0][0].GetKind() == BVNEG && children[0][1].GetKind() == BVUMINUS
- && children[0][1][0] == children[0][0][0])
- result = children[0][0][0];
-
- break;
-
- case BVUMINUS:
- if (children[0].GetKind() == BVUMINUS)
- result = children[0][0];
- else if (width == 1)
- result = children[0];
- else if (children[0].GetKind() == BVPLUS && children[0].Degree() == 2 && children[0][0].GetKind() == BEEV::BVCONST
- && children[0][0] == bm.CreateOneConst(width))
- result = NodeFactory::CreateTerm(BVNEG, width, children[0][1]);
- else if (children[0].GetKind() == BVNEG)
- result = NodeFactory::CreateTerm(BVPLUS, width, children[0][0], bm.CreateOneConst(width));
- else if (children[0].GetKind() == BEEV::BVSX && children[0][0].GetValueWidth() == 1)
- result = NodeFactory::CreateTerm(BVCONCAT, width, bm.CreateZeroConst(width - 1), children[0][0]);
- else if (children[0].GetKind() == BVMULT && children[0].Degree() == 2 && children[0][0] == bm.CreateMaxConst(width))
- result = children[0][1];
- break;
-
- case BVEXTRACT:
- if (width == children[0].GetValueWidth())
- result = children[0];
- else if (BVEXTRACT == children[0].GetKind()) // reduce an extract over an extract.
- {
- const unsigned outerLow = children[2].GetUnsignedConst();
- const unsigned outerHigh = children[1].GetUnsignedConst();
-
- const unsigned innerLow = children[0][2].GetUnsignedConst();
- const unsigned innerHigh = children[0][1].GetUnsignedConst();
- result = NodeFactory::CreateTerm(BVEXTRACT, width, children[0][0], bm.CreateBVConst(32, outerHigh + innerLow),
- bm.CreateBVConst(32, outerLow + innerLow));
- }
- else if (BVCONCAT == children[0].GetKind())
- {
- // If the extract doesn't cross the concat, then remove the concat.
- const ASTNode& a = children[0][0];
- const ASTNode& b = children[0][1];
-
- const unsigned low = children[2].GetUnsignedConst();
- const unsigned high = children[1].GetUnsignedConst();
-
- if (high < b.GetValueWidth()) // Extract entirely from the lower value (b).
- {
- result = NodeFactory::CreateTerm(BVEXTRACT, width, b, children[1], children[2]);
- }
- if (low >= b.GetValueWidth()) // Extract entirely from the upper value (a).
- {
- ASTNode i = bm.CreateBVConst(32, high - b.GetValueWidth());
- ASTNode j = bm.CreateBVConst(32, low - b.GetValueWidth());
- result = NodeFactory::CreateTerm(BVEXTRACT, width, a, i, j);
- }
- }
- else if (BVUMINUS == children[0].GetKind() && children[1] == bm.CreateZeroConst(children[1].GetValueWidth())
- && children[2] == bm.CreateZeroConst(children[2].GetValueWidth()))
- {
- result = NodeFactory::CreateTerm(BVEXTRACT, width, children[0][0], children[1], children[2]);
- }
- break;
-
- case BVPLUS:
- if (children.size() == 2)
- {
- result = plusRules(children[0], children[1]);
- if (result.IsNull())
- result = plusRules(children[1], children[0]);
- }
- break;
-
- case SBVMOD:
- {
- const ASTNode max = bm.CreateMaxConst(width);
-
- if (children[1].isConstant() && CONSTANTBV::BitVector_is_empty(children[1].GetBVConst()))
- result = children[0];
- else if (children[0] == children[1])
- result = bm.CreateZeroConst(width);
- else if (children[1].isConstant() && children[1] == bm.CreateOneConst(width))
- result = bm.CreateZeroConst(width);
- else if (children[1].isConstant() && children[1] == bm.CreateMaxConst(width))
- result = bm.CreateZeroConst(width);
- else if (children[0].isConstant() && children[0] == bm.CreateZeroConst(width))
- result = bm.CreateZeroConst(width);
- else if (children[0].GetKind() == BVUMINUS && children[0][0] == children[1])
- result = bm.CreateZeroConst(width);
- else if (children[1].GetKind() == BVUMINUS && children[1][0] == children[0])
- result = bm.CreateZeroConst(width);
-#if 0
- else if ( width >= 4 && children[0].GetKind() == BVNEG && children[1] == children[0][0] )
- result = bm.CreateTerm(SBVMOD,width,max,children[0][0]);//9759 -> 542 | 4842 ms
- else if ( width >= 4 && children[1].GetKind() == BVNEG && children[1][0] == children[0] )
- result = bm.CreateTerm(SBVMOD,width,max,children[1]);//9759 -> 542 | 4005 ms
- else if ( width >= 4 && children[0].GetKind() == BVNEG && children[1].GetKind() == BVUMINUS && children[1][0] == children[0][0] )
- result = bm.CreateTerm(SBVMOD,width,max,children[1]);//9807 -> 674 | 2962 ms
-#endif
- }
-
- break;
-
- case BEEV::BVDIV:
- if (children[1].isConstant() && children[1] == bm.CreateOneConst(width))
- result = children[0];
- if (children[1].isConstant() && CONSTANTBV::BitVector_bit_test(children[1].GetBVConst(), width - 1))
- {
- // We are dividing by something that has a one in the MSB. It's either 1 or zero.
- result = NodeFactory::CreateTerm(ITE, width, NodeFactory::CreateNode(BEEV::BVGE, children[0], children[1]),
- bm.CreateOneConst(width), bm.CreateZeroConst(width));
- }
- else if (children[1].isConstant() && children[1] == bm.CreateZeroConst(width)
- && bm.UserFlags.division_by_zero_returns_one_flag)
- result = bm.CreateOneConst(width);
- else if (bm.UserFlags.division_by_zero_returns_one_flag && children[0] == children[1])
- result = bm.CreateOneConst(width);
- else if (bm.UserFlags.division_by_zero_returns_one_flag && children[0].isConstant() && CONSTANTBV::BitVector_is_empty(children[0].GetBVConst()))
- result = NodeFactory::CreateTerm(ITE,width, NodeFactory::CreateNode(EQ, children[1], bm.CreateZeroConst(width)) ,bm.CreateOneConst(width),bm.CreateZeroConst(width));
- else if (bm.UserFlags.division_by_zero_returns_one_flag && width >= 2 && children[0].GetKind() == BVNEG && children[1].GetKind() == BVUMINUS && children[1][0] == children[0][0])
- result = NodeFactory::CreateTerm(ITE,width,NodeFactory::CreateNode(EQ,bm.CreateZeroConst(width),children[0][0]),bm.CreateOneConst(width),bm.CreateZeroConst(width));
-
- break;
-
- case SBVDIV:
- if (children[1].isConstant() && children[1] == bm.CreateOneConst(width))
- result = children[0];
- else if (children[0] == children[1] && bm.UserFlags.division_by_zero_returns_one_flag)
- result = bm.CreateOneConst(width);
- else if (children[1].GetKind() == BVUMINUS && children[0] == children[1][0]
- && bm.UserFlags.division_by_zero_returns_one_flag)
- result = NodeFactory::CreateTerm(SBVDIV, width, children[1], children[0]);
- else if (bm.UserFlags.division_by_zero_returns_one_flag && children[0].isConstant()
- && CONSTANTBV::BitVector_is_empty(children[0].GetBVConst()))
- result = NodeFactory::CreateTerm(ITE, width, NodeFactory::CreateNode(EQ, children[1], bm.CreateZeroConst(width)),
- bm.CreateOneConst(width), bm.CreateZeroConst(width));
- if (children[1].isConstant() && CONSTANTBV::BitVector_is_full(children[1].GetBVConst()))
- result = NodeFactory::CreateTerm(BVUMINUS, width, children[0]);
- break;
-
- case SBVREM:
- {
- const ASTNode one = bm.CreateOneConst(width);
- const ASTNode zero = bm.CreateZeroConst(width);
- const ASTNode max = bm.CreateMaxConst(width);
-
- if (children[0] == children[1])
- result = bm.CreateZeroConst(width);
- else if (children[0].isConstant() && CONSTANTBV::BitVector_is_empty(children[0].GetBVConst()))
- result = bm.CreateZeroConst(width);
- else if (children[1].isConstant() && CONSTANTBV::BitVector_is_full(children[1].GetBVConst()))
- result = bm.CreateZeroConst(width);
- else if (children[1].isConstant() && CONSTANTBV::BitVector_is_empty(children[1].GetBVConst()))
- result = children[0];
- else if (children[1].isConstant() && bm.CreateOneConst(width) == children[1])
- result = bm.CreateZeroConst(width);
- else if (children[1].GetKind() == BVUMINUS)
- result = NodeFactory::CreateTerm(SBVREM, width, children[0], children[1][0]);
- else if (children[0].GetKind() == BVUMINUS && children[0][0] == children[1])
- result = bm.CreateZeroConst(width);
-#if 0
- else if ( width >= 4 && children[0].GetKind() == BVNEG && children[1] == children[0][0] )
- result = bm.CreateTerm(BVUMINUS,width,bm.CreateTerm(SBVMOD,width,one,children[0][0]));//9350 -> 624 | 3072 ms
- else if ( width >= 4 && children[1].GetKind() == BVNEG && children[1][0] == children[0] )
- result = bm.CreateTerm(BVUMINUS,width,bm.CreateTerm(SBVMOD,width,one,children[1]));//9350 -> 624 | 2402 ms
- else if ( width >= 4 && children[0].GetKind() == BVUMINUS && children[1] == max)
- result = bm.CreateTerm(BVUMINUS,width,bm.CreateTerm(SBVREM,width,children[0][0],children[1]));//123 -> 83 | 1600 ms
-#endif
- }
-
-
- break;
-
- case BVMOD:
- {
- if (children[0] == children[1])
- result = bm.CreateZeroConst(width);
-
- if (children[0].isConstant() && CONSTANTBV::BitVector_is_empty(children[0].GetBVConst()))
- result = bm.CreateZeroConst(width);
-
- if (children[1].isConstant() && CONSTANTBV::BitVector_is_empty(children[1].GetBVConst()))
- result = children[0];
-
- if (children[0].GetKind() == BVPLUS && children[0].Degree() == 2 && children[0][0] == bm.CreateMaxConst(width)
- && children[1] == children[0][1])
- result = children[0];
-
- const ASTNode one = bm.CreateOneConst(width);
-
- if (children[0].GetKind() == BVNEG && children[1].GetKind() == BVUMINUS && children[1][0] == children[0][0])
- result = children[0];
-
- if (children[1].isConstant() && children[1] == one)
- result = bm.CreateZeroConst(width);
-
- if (children[0].isConstant() && children[0] == one)
- result = NodeFactory::CreateTerm(ITE, width, NodeFactory::CreateNode(EQ, children[1], one),
- bm.CreateZeroConst(width), one);
-#if 0
- if ( width >= 3 && children[0].GetKind() == BVNEG && children[1] == children[0][0] )
- result = NodeFactory::CreateTerm(BVMOD,width,bm.CreateMaxConst(width),children[0][0]);//3285 -> 3113
-
- if ( width >= 3 && children[1].GetKind() == BVNEG && children[1][0] == children[0] )
- result = NodeFactory::CreateTerm(BVMOD,width,bm.CreateMaxConst(width),children[1]);//3285 -> 3113
-
- if ( width >= 4 && children[0].GetKind() == BVUMINUS && children[1].GetKind() == BVNEG && children[1][0] == children[0][0] )
- result = NodeFactory::CreateTerm(SBVREM,width,one,children[1]); //8883 -> 206 | 1566 ms
-#endif
- }
-
- break;
-
- case BEEV::WRITE:
- if (children[0].GetKind() == BEEV::WRITE && children[1] == children[0][1])
- {
- // If the indexes of two writes are the same, then discard the inner write.
- result = NodeFactory::CreateArrayTerm(BEEV::WRITE, children[0].GetIndexWidth(), children[0].GetValueWidth(),
- children[0][0], children[1], children[2]);
- }
- else if (children[2].GetKind() == BEEV::READ && children[0] == children[2][0] && children[1] == children[2][1])
- {
- // Its writing into the array what's already there. i.e. a[i] = a[i]
- result = children[0];
- }
- break;
-
- case BEEV::READ:
- if (children[0].GetKind() == BEEV::WRITE)
- {
- result = chaseRead(children, width);
- }
- break;
-
- default: // quieten compiler.
- break;
- }
-
- if (result.IsNull())
- result = hashing.CreateTerm(kind, width, children);
-
- return result;
-}
diff --git a/src/vendor/stp/src/AST/NodeFactory/SimplifyingNodeFactory.h b/src/vendor/stp/src/AST/NodeFactory/SimplifyingNodeFactory.h
deleted file mode 100644
index d1df19bb5..000000000
--- a/src/vendor/stp/src/AST/NodeFactory/SimplifyingNodeFactory.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* A node factory that:
- * * Sorts children to increases sharing,
- * * Performs constant evaluation,
- * * performs simplify boolean simplifications,
- * * converts less thans to greater thans.
- *
- * NOTE: CreateNode doesn't necessary return a node with the same Kind as what it was called
- * with. For example: (AND TRUE FALSE) will return FALSE. Which isn't an AND node.
- *
- * The intention is to never create nodes that will later be simplified by single level
- * re-write rules. So we will never create the node (NOT(NOT x)). This is and example of
- * a multi-level rule that never increases the global number of nodes.
- *
- * These rules never increase the total number of nodes. They are complimented by
- * multi-level re-write rules that consider the global reference count when simplifying.
- *
- */
-
-#ifndef SIMPLIFYINGNODEFACTORY_H
-#define SIMPLIFYINGNODEFACTORY_H
-
-#include "NodeFactory.h"
-#include "../../STPManager/STPManager.h"
-
-using BEEV::ASTNode;
-using BEEV::ASTVec;
-
-class SimplifyingNodeFactory: public NodeFactory
-{
-
-private:
- NodeFactory& hashing;
-
- const ASTNode& ASTTrue;
- const ASTNode& ASTFalse;
- const ASTNode& ASTUndefined;
-
- ASTNode CreateSimpleFormITE(const ASTVec &children);
- ASTNode CreateSimpleXor(const ASTVec &children);
- ASTNode CreateSimpleAndOr(bool IsAnd, const ASTVec &children);
- ASTNode CreateSimpleAndOr(bool IsAnd, const ASTNode& form1,
- const ASTNode& form2);
- ASTNode CreateSimpleNot(const ASTNode& form);
- ASTNode CreateSimpleNot(const ASTVec& children);
-
- ASTNode CreateSimpleEQ(const ASTVec& children);
-
- SimplifyingNodeFactory(const SimplifyingNodeFactory& );
- SimplifyingNodeFactory& operator=(const SimplifyingNodeFactory&);
-
- ASTNode chaseRead(const ASTVec& children, unsigned int width );
-
- ASTNode plusRules(const ASTNode& n0, const ASTNode& n1);
-public:
-
- virtual BEEV::ASTNode CreateNode(BEEV::Kind kind, const BEEV::ASTVec & children);
- virtual BEEV::ASTNode CreateTerm(BEEV::Kind kind, unsigned int width, const BEEV::ASTVec &children);
-
- virtual std::string getName() {return "simplifying";}
-
- SimplifyingNodeFactory(NodeFactory& raw_, BEEV::STPMgr& bm_)
- :hashing(raw_), NodeFactory(bm_), ASTTrue(bm_.ASTTrue), ASTFalse(bm_.ASTFalse), ASTUndefined(bm_.ASTUndefined)
- {
- }
- ;
- ~SimplifyingNodeFactory()
- {
- }
-
-};
-
-#endif
diff --git a/src/vendor/stp/src/AST/NodeFactory/TypeChecker.cpp b/src/vendor/stp/src/AST/NodeFactory/TypeChecker.cpp
deleted file mode 100644
index 2ef2afc33..000000000
--- a/src/vendor/stp/src/AST/NodeFactory/TypeChecker.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "TypeChecker.h"
-#include "../AST.h"
-
-BEEV::ASTNode TypeChecker::CreateTerm(BEEV::Kind kind, unsigned int width, const BEEV::ASTVec &children)
-{
- BEEV::ASTNode r = f.CreateTerm(kind,width,children);
- BVTypeCheck(r);
- return r;
-}
-
-//virtual BEEV::ASTNode CreateNode(BEEV::Kind kind, const BEEV::ASTVec& children);
-BEEV::ASTNode TypeChecker::CreateNode(BEEV::Kind kind, const BEEV::ASTVec& children)
-{
- BEEV::ASTNode r = f.CreateNode(kind,children);
- BVTypeCheck(r);
- return r;
-}
-
-BEEV::ASTNode TypeChecker::CreateArrayTerm(Kind kind, unsigned int index,
- unsigned int width, const BEEV::ASTVec &children)
-{
- ASTNode r = f.CreateTerm(kind, width, children);
- r.SetIndexWidth(index);
- BVTypeCheck(r);
- return r;
-}
-
diff --git a/src/vendor/stp/src/AST/NodeFactory/TypeChecker.h b/src/vendor/stp/src/AST/NodeFactory/TypeChecker.h
deleted file mode 100644
index 87a3d27b5..000000000
--- a/src/vendor/stp/src/AST/NodeFactory/TypeChecker.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- A decorator pattern, which calls some base node factory, then type checks each of the results.
- */
-
-#ifndef TYPECHECKER_H_
-#define TYPECHECKER_H_
-
-#include "NodeFactory.h"
-#include "../../STPManager/STPManager.h"
-
-namespace BEEV
-{
-class BeevMgr;
-}
-using BEEV::STPMgr;
-
-class TypeChecker : public NodeFactory
-{
-NodeFactory& f;
-
-public:
- TypeChecker(NodeFactory& f_, STPMgr& bm_) : f(f_), NodeFactory(bm)
- {}
-
- BEEV::ASTNode CreateTerm(BEEV::Kind kind, unsigned int width, const BEEV::ASTVec &children);
- BEEV::ASTNode CreateNode(BEEV::Kind kind, const BEEV::ASTVec& children);
- BEEV::ASTNode CreateArrayTerm(Kind kind, unsigned int index,unsigned int width, const BEEV::ASTVec &children);
-
- virtual string getName() {return "type checking";}
-};
-
-#endif /* TYPECHECKER_H_ */
diff --git a/src/vendor/stp/src/AST/RunTimes.cpp b/src/vendor/stp/src/AST/RunTimes.cpp
deleted file mode 100644
index a7adb9c90..000000000
--- a/src/vendor/stp/src/AST/RunTimes.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-//Hold the runtime statistics. E.g. how long was spent in simplification.
-//The times don't add up to the runtime, because we allow multiple times to
-//be counted simultaneously. For example, the current Transform()s call
-//Simplify_TopLevel, so inside simplify time will be counted towards both
-//Simplify_TopLevel & Transform.
-
-// This is intended as a low overhead profiling class. So runtimes can
-// always be tracked.
-
-#include
-#include
-#include
-#include
-#include
-#include "RunTimes.h"
-#include "../sat/utils/System.h"
-
-// BE VERY CAREFUL> Update the Category Names to match.
-std::string RunTimes::CategoryNames[] = { "Transforming", "Simplifying", "Parsing", "CNF Conversion", "Bit Blasting", "SAT Solving", "Bitvector Solving","Variable Elimination", "Sending to SAT Solver", "Counter Example Generation","SAT Simplification", "Constant Bit Propagation","Array Read Refinement", "Applying Substitutions", "Removing Unconstrained", "Pure Literals" , "ITE Contexts", "AIG core simplification", "Interval Propagation", "Always True"};
-
-namespace BEEV
-{
- void FatalError(const char * str);
-}
-
-
-long RunTimes::getCurrentTime()
-{
- timeval t;
- gettimeofday(&t, NULL);
- return (1000 * t.tv_sec) + (t.tv_usec / 1000);
-}
-
-void RunTimes::print()
-{
- if (0 != category_stack.size())
- {
- std::cerr << "size:" << category_stack.size() << std::endl;
- std::cerr << "top:" << CategoryNames[category_stack.top().first] << std::endl;
- BEEV::FatalError("category stack is not yet empty!!");
- }
-
- std::ostringstream result;
- result << "statistics\n";
- std::map::const_iterator it1 = counts.begin();
- std::map::const_iterator it2 = times.begin();
-
- int cummulative_ms = 0;
-
- while (it1 != counts.end())
- {
- int time_ms = 0;
- if ((it2 = times.find(it1->first)) != times.end())
- time_ms = it2->second;
-
- if (time_ms!=0)
- {
- result << " " << CategoryNames[it1->first] << ": " << it1->second;
- result << " [" << time_ms << "ms]";
- result << std::endl;
- cummulative_ms += time_ms;
- }
- it1++;
- }
- std::cerr << result.str();
- std::cerr << std::fixed;
- std::cerr.precision(2);
- std::cerr << "Statistics Total: " << ((double)cummulative_ms)/1000 << "s" << std::endl;
- std::cerr << "CPU Time Used : " << Minisat::cpuTime() << "s" << std::endl;
- std::cerr << "Peak Memory Used: " << Minisat::memUsedPeak() << "MB" << std::endl;
-
- clear();
-
-}
-
-void RunTimes::addTime(Category c, long milliseconds)
-{
- std::map::iterator it;
- if ((it = times.find(c)) == times.end())
- {
- times[c] = milliseconds;
- }
- else
- {
- it->second += milliseconds;
- }
-
-}
-
-void RunTimes::addCount(Category c)
-{
- std::map::iterator it;
- if ((it = counts.find(c)) == counts.end())
- {
- counts[c] = 1;
- }
- else
- {
- it->second++;
- }
-}
-
-void RunTimes::stop(Category c)
-{
- Element e = category_stack.top();
- category_stack.pop();
- if (e.first != c)
- {
- std::cerr << e.first;
- std::cerr << c;
- BEEV::FatalError("Don't match");
- }
- addTime(c, getCurrentTime() - e.second);
- addCount(c);
-}
-
-void RunTimes::start(Category c)
-{
- category_stack.push(std::make_pair(c, getCurrentTime()));
-}
diff --git a/src/vendor/stp/src/AST/RunTimes.h b/src/vendor/stp/src/AST/RunTimes.h
deleted file mode 100644
index f606da663..000000000
--- a/src/vendor/stp/src/AST/RunTimes.h
+++ /dev/null
@@ -1,106 +0,0 @@
-// -*- c++ -*-
-/********************************************************************
- * AUTHORS: Trevor Hansen
- *
- * BEGIN DATE: November, 2005
- *
- * LICENSE: Please view LICENSE file in the home dir of this Program
- ********************************************************************/
-
-#ifndef RUNTIMES_H
-#define RUNTIMES_H
-
-#include
-#include