-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A Minisat-based SAT solver in Haskell -- -- A modern and fast SAT solver written in Haskell, based on Minisat-1.14 -- and 2.2. By using CDCL, watch literals, VSIDS, restart, -- blocking-literals, LBD and so on. The current version is only 2.0 time -- slower than Minisat-2.2. Mios is an abbreviation of -- 'Minisat-based Implementation and Optimization Study on SAT solver'. @package mios @version 1.4.0 -- | Boolean Expression module to build CNF from arbitrary expressions -- Tseitin translation: -- http://en.wikipedia.org/wiki/Tseitin_transformation module SAT.Mios.Util.BoolExp -- | class of objects that can be interpeted as a bool expression class BoolComponent a toBF :: BoolComponent a => a -> BoolForm -- | CNF expression data BoolForm Cnf :: (Int, Int) -> [[Int]] -> BoolForm -- | disjunction constructor -- --
--   >>> asList $ "3" -|- "4"
--   [[3,4,-5],[-3,5],[-4,5]]
--   
-- --
--   >>> asList (("3" -|- "4") -|- "-1")
--   [[3,4,-5],[-3,5],[-4,5],[5,-1,-6],[-5,6],[1,6]]
--   
(-|-) :: (BoolComponent a, BoolComponent b) => a -> b -> BoolForm -- | conjunction constructor -- --
--   >>> asList $ "3" -&- "-2"
--   [[-3,2,4],[3,-4],[-2,-4]]
--   
-- --
--   >>> asList $ "3" -|- ("1" -&- "2")
--   [[-1,-2,4],[1,-4],[2,-4],[3,4,-5],[-3,5],[-4,5]]
--   
(-&-) :: (BoolComponent a, BoolComponent b) => a -> b -> BoolForm -- | equal on BoolForm (-=-) :: (BoolComponent a, BoolComponent b) => a -> b -> BoolForm -- | negation on BoolForm (-!-) :: (BoolComponent a, BoolComponent b) => a -> b -> BoolForm -- | implication as a short cut -- --
--   >>> asList ("1" ->- "2")
--   [[-1,-3],[1,3],[3,2,-4],[-3,4],[-2,4]]
--   
(->-) :: (BoolComponent a, BoolComponent b) => a -> b -> BoolForm -- | negate a form -- --
--   >>> asList $ neg ("1" -|- "2")
--   [[1,2,-3],[-1,3],[-2,3],[-3,-4],[3,4]]
--   
neg :: (BoolComponent a) => a -> BoolForm -- | merge [BoolForm] by '(-|-)' disjunctionOf :: [BoolForm] -> BoolForm -- | an alias of disjunctionOf (-|||-) :: [BoolForm] -> BoolForm -- | merge [BoolForm] by '(-&-)' conjunctionOf :: [BoolForm] -> BoolForm -- | an alias of conjunctionOf (-&&&-) :: [BoolForm] -> BoolForm -- | converts a *satisfied* BoolForm to "[[Int]]" asList :: BoolForm -> [[Int]] -- | converts a BoolForm to "[[Int]]" asList_ :: BoolForm -> [[Int]] -- | make latex string from CNF, using asList asLatex :: BoolForm -> String -- | make latex string from CNF, using asList_ -- --
--   >>> asLatex $ "3" -|- "4"
--   "\\begin{displaymath}\n( x_{3} \\vee x_{4} )\n\\end{displaymath}\n"
--   
asLatex_ :: BoolForm -> String -- | returns the number of variables in the BoolForm numberOfVariables :: BoolForm -> Int -- | returns the number of clauses in the BoolForm numberOfClauses :: BoolForm -> Int -- | the start index for the generated variables by Tseitin encoding tseitinBase :: Int instance GHC.Show.Show SAT.Mios.Util.BoolExp.BoolForm instance GHC.Classes.Eq SAT.Mios.Util.BoolExp.BoolForm instance SAT.Mios.Util.BoolExp.BoolComponent GHC.Types.Int instance SAT.Mios.Util.BoolExp.BoolComponent SAT.Mios.Util.BoolExp.L instance SAT.Mios.Util.BoolExp.BoolComponent [GHC.Types.Char] instance SAT.Mios.Util.BoolExp.BoolComponent SAT.Mios.Util.BoolExp.BoolForm instance SAT.Mios.Util.BoolExp.BoolComponent GHC.Types.Bool instance GHC.Classes.Ord SAT.Mios.Util.BoolExp.BoolForm -- | Write SAT data to DIMACS file module SAT.Mios.Util.DIMACS.Writer -- | Write the DIMACS to file f, using toDIMACSString toFile :: FilePath -> [[Int]] -> IO () -- | Convert [Clause] to String, where Clause is [Int] -- --
--   >>> toDIMACSString []
--   "p cnf 0 0\n"
--   
-- --
--   >>> toDIMACSString [[-1, 2], [-3, -4]]
--   "p cnf 4 2\n-1 2 0\n-3 -4 0\n"
--   
-- --
--   >>> toDIMACSString [[1], [-2], [-3, -4], [1,2,3,4]]
--   "p cnf 4 4\n1 0\n-2 0\n-3 -4 0\n1 2 3 4 0\n"
--   
toDIMACSString :: [[Int]] -> String -- | converts [[Int]] to a String toString :: [[Int]] -> String -> String -> String -- | converts [[Int]] to a LaTeX expression toLatexString :: [[Int]] -> String -- | Read a CNF file without haskell-platform module SAT.Mios.Util.DIMACS.Reader -- | read a CNF file and return: ((numbefOfVariables, numberOfClauses), -- [Literal]) -- --
--   >>> fromFile "acnf"
--   ((3, 4), [[1, 2], [-2, 3], [-1, 2, -3], [3]]
--   
fromFile :: FilePath -> IO (Maybe ((Int, Int), [[Int]])) -- | return clauses as [[Int]] from file -- --
--   >>> clauseListFromFile "a.cnf"
--   [[1, 2], [-2, 3], [-1, 2, -3], [3]]
--   
clauseListFromFile :: FilePath -> IO [[Int]] -- | Read an output file of minisat module SAT.Mios.Util.DIMACS.MinisatReader -- | read a minisat output: ((numbefOfVariables, 0), [Literal]) -- --
--   >>> fromFile "result"
--   ((3, 0), [1, -2, 3])
--   
fromMinisatOutput :: FilePath -> IO (Maybe ((Int, Int), [Int])) -- | return clauses as [[Int]] from file -- --
--   >>> clauseListFromMinisatOutput "result"
--   [1,-2,3]
--   
clauseListFromMinisatOutput :: FilePath -> IO [Int] -- | Read/Write a CNF file only with ghc standard libraries module SAT.Mios.Util.DIMACS -- | read a CNF file and return: ((numbefOfVariables, numberOfClauses), -- [Literal]) -- --
--   >>> fromFile "acnf"
--   ((3, 4), [[1, 2], [-2, 3], [-1, 2, -3], [3]]
--   
fromFile :: FilePath -> IO (Maybe ((Int, Int), [[Int]])) -- | return clauses as [[Int]] from file -- --
--   >>> clauseListFromFile "a.cnf"
--   [[1, 2], [-2, 3], [-1, 2, -3], [3]]
--   
clauseListFromFile :: FilePath -> IO [[Int]] -- | read a minisat output: ((numbefOfVariables, 0), [Literal]) -- --
--   >>> fromFile "result"
--   ((3, 0), [1, -2, 3])
--   
fromMinisatOutput :: FilePath -> IO (Maybe ((Int, Int), [Int])) -- | return clauses as [[Int]] from file -- --
--   >>> clauseListFromMinisatOutput "result"
--   [1,-2,3]
--   
clauseListFromMinisatOutput :: FilePath -> IO [Int] -- | Write the DIMACS to file f, using toDIMACSString toFile :: FilePath -> [[Int]] -> IO () -- | Convert [Clause] to String, where Clause is [Int] -- --
--   >>> toDIMACSString []
--   "p cnf 0 0\n"
--   
-- --
--   >>> toDIMACSString [[-1, 2], [-3, -4]]
--   "p cnf 4 2\n-1 2 0\n-3 -4 0\n"
--   
-- --
--   >>> toDIMACSString [[1], [-2], [-3, -4], [1,2,3,4]]
--   "p cnf 4 4\n1 0\n-2 0\n-3 -4 0\n1 2 3 4 0\n"
--   
toDIMACSString :: [[Int]] -> String -- | String from BoolFrom asDIMACSString :: BoolForm -> String -- | String from BoolFrom asDIMACSString_ :: BoolForm -> String -- | Abstraction Layer for Mutable Vectors module SAT.Mios.Vec -- | Interface on vectors. class VecFamily v a | v -> a where reset = error "no default method: reset" asUVector = error "no default method: asUVector" swapBetween = error "no default method: swapBetween" modifyNth = error "no default method: modifyNth" newVec = error "no default method: newVec" setAll = error "no default method: setAll" asList = error "no default method: asList" growBy = error "no default method: growBy" -- | returns the n-th value. getNth :: VecFamily v a => v -> Int -> IO a -- | sets the n-th value. setNth :: VecFamily v a => v -> Int -> a -> IO () -- | erases all elements in it. reset :: VecFamily v a => v -> IO () -- | converts to an Int vector. asUVector :: (VecFamily v a, a ~ Int) => v -> UVector Int -- | returns the n-th value (index starts from zero in any case). | -- swaps two elements. swapBetween :: VecFamily v a => v -> Int -> Int -> IO () -- | calls the update function. modifyNth :: VecFamily v a => v -> (a -> a) -> Int -> IO () -- | returns a new vector. newVec :: VecFamily v a => Int -> a -> IO v -- | sets all elements. setAll :: VecFamily v a => v -> a -> IO () -- | extends the size of stack by n; note: values in new elements -- aren't initialized maybe. growBy :: VecFamily v a => v -> Int -> IO v -- | converts to a list. asList :: VecFamily v a => v -> IO [a] -- | A thin abstract layer for Mutable unboxed Vector type UVector a = IOVector a -- | Another abstraction layer on UVector. -- -- Note: the 0-th element of Vec Int is reserved for -- internal tasks. If you want to use it, use UVector Int. newtype Vec a Vec :: (UVector a) -> Vec a -- | Interface for single mutable data class SingleStorage s t | s -> t where new' = undefined modify' = undefined -- | allocates and returns an new data. new' :: SingleStorage s t => t -> IO s -- | gets the value. get' :: SingleStorage s t => s -> IO t -- | sets the value. set' :: SingleStorage s t => s -> t -> IO () -- | calls an update function on it. modify' :: SingleStorage s t => s -> (t -> t) -> IO () -- | Mutable Bool type Bool' = IOVector Bool -- | Mutable Double type Double' = IOVector Double -- | Mutable Int Note: Int' is the same with Stack type Int' = IOVector Int -- | Interface on stacks class SingleStorage s Int => StackFamily s t | s -> t where newStack = undefined pushTo = undefined popFrom = undefined lastOf = undefined shrinkBy = undefined -- | returns a new stack. newStack :: StackFamily s t => Int -> IO s -- | pushs an value to the tail of the stack. pushTo :: StackFamily s t => s -> t -> IO () -- | pops the last element. popFrom :: StackFamily s t => s -> IO () -- | peeks the last element. lastOf :: StackFamily s t => s -> IO t -- | shrinks the stack. shrinkBy :: StackFamily s t => s -> Int -> IO () -- | Alias of Vec Int. The 0-th element holds the number of -- elements. type Stack = Vec Int -- | returns a new Stack from [Int]. newStackFromList :: [Int] -> IO Stack instance SAT.Mios.Vec.VecFamily (SAT.Mios.Vec.UVector GHC.Types.Int) GHC.Types.Int instance SAT.Mios.Vec.VecFamily (SAT.Mios.Vec.UVector GHC.Types.Double) GHC.Types.Double instance SAT.Mios.Vec.VecFamily (SAT.Mios.Vec.Vec GHC.Types.Int) GHC.Types.Int instance SAT.Mios.Vec.VecFamily (SAT.Mios.Vec.Vec GHC.Types.Double) GHC.Types.Double instance SAT.Mios.Vec.SingleStorage SAT.Mios.Vec.Int' GHC.Types.Int instance SAT.Mios.Vec.SingleStorage SAT.Mios.Vec.Bool' GHC.Types.Bool instance SAT.Mios.Vec.SingleStorage SAT.Mios.Vec.Double' GHC.Types.Double instance SAT.Mios.Vec.SingleStorage SAT.Mios.Vec.Stack GHC.Types.Int instance SAT.Mios.Vec.StackFamily SAT.Mios.Vec.Stack GHC.Types.Int -- | Basic data types used throughout mios. module SAT.Mios.Types -- | represents Var. type Var = Int -- | Special constant in Var (p.7) bottomVar :: Var -- | converts a usual Int as literal to an internal Var -- presentation. -- --
--   >>> int2var 1
--   1  -- the first literal is the first variable
--   
--   >>> int2var 2
--   2  -- literal @2@ is variable 2
--   
--   >>> int2var (-2)
--   2 -- literal @-2@ is corresponding to variable 2
--   
int2var :: Int -> Int -- | The literal data has an index method which converts the -- literal to a "small" integer suitable for array indexing. The -- var method returns the underlying variable of the literal, -- and the sign method if the literal is signed (False for -- x and True for -x). type Lit = Int -- | converts Lit into Int as int2lit . lit2int == -- id. -- --
--   >>> lit2int 2
--   1
--   
--   >>> lit2int 3
--   -1
--   
--   >>> lit2int 4
--   2
--   
--   >>> lit2int 5
--   -2
--   
lit2int :: Lit -> Int -- | converts Int into Lit as lit2int . int2lit == -- id. -- --
--   >>> int2lit 1
--   2
--   
--   >>> int2lit (-1)
--   3
--   
--   >>> int2lit 2
--   4
--   
--   >>> int2lit (-2)
--   5
--   
int2lit :: Int -> Lit -- | Special constant in Lit (p.7) bottomLit :: Lit -- | returns True if the literal is positive positiveLit :: Lit -> Bool -- | converts Lit into Var. -- --
--   >>> lit2var 2
--   1
--   
--   >>> lit2var 3
--   1
--   
--   >>> lit2var 4
--   2
--   
--   >>> lit2var 5
--   2
--   
lit2var :: Lit -> Var -- | converts a Var to the corresponing literal. -- --
--   >>> var2lit 1 True
--   2
--   
--   >>> var2lit 1 False
--   3
--   
--   >>> var2lit 2 True
--   4
--   
--   >>> var2lit 2 False
--   5
--   
var2lit :: Var -> Bool -> Lit -- | negates literal -- --
--   >>> negateLit 2
--   3
--   
--   >>> negateLit 3
--   2
--   
--   >>> negateLit 4
--   5
--   
--   >>> negateLit 5
--   4
--   
negateLit :: Lit -> Lit -- | FALSE on the Lifted Bool domain lFalse :: Int -- | TRUE on the Lifted Bool domain lTrue :: Int -- | UNDEFINED on the Lifted Bool domain lBottom :: Int -- | Assisting ADT for the dynamic variable ordering of the solver. The -- constructor takes references to the assignment vector and the activity -- vector of the solver. The method select will return the -- unassigned variable with the highest activity. class VarOrder o where update _ = error "update undefined" undo _ _ = error "undo undefined" select = error "select undefined" -- | should be called when a variable has increased in activity. update :: VarOrder o => o -> Var -> IO () -- | should be called when a variable becomes unbound (may be selected -- again). undo :: VarOrder o => o -> Var -> IO () -- | returns a new, unassigned var as the next decision. select :: VarOrder o => o -> IO Var -- | Misc information on a CNF data CNFDescription CNFDescription :: !Int -> !Int -> Maybe FilePath -> CNFDescription -- | the number of variables [_numberOfVariables] :: CNFDescription -> !Int -- | the number of clauses [_numberOfClauses] :: CNFDescription -> !Int -- | given filename [_pathname] :: CNFDescription -> Maybe FilePath -- | Solver's parameters; random decision rate was dropped. data MiosConfiguration MiosConfiguration :: !Double -> MiosConfiguration -- | decay rate for variable activity , clauseDecayRate :: !Double -- ^ -- decay rate for clause activity [variableDecayRate] :: MiosConfiguration -> !Double -- | dafault configuration -- -- defaultConfiguration :: MiosConfiguration instance GHC.Show.Show SAT.Mios.Types.CNFDescription instance GHC.Classes.Ord SAT.Mios.Types.CNFDescription instance GHC.Classes.Eq SAT.Mios.Types.CNFDescription -- | command line option parser for mios module SAT.Mios.OptionParser -- | Solver's parameters; random decision rate was dropped. data MiosConfiguration MiosConfiguration :: !Double -> MiosConfiguration -- | decay rate for variable activity , clauseDecayRate :: !Double -- ^ -- decay rate for clause activity [variableDecayRate] :: MiosConfiguration -> !Double -- | dafault configuration -- -- defaultConfiguration :: MiosConfiguration -- | configuration swithces data MiosProgramOption MiosProgramOption :: Maybe String -> Maybe String -> !Double -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> MiosProgramOption [_targetFile] :: MiosProgramOption -> Maybe String [_outputFile] :: MiosProgramOption -> Maybe String [_confVariableDecayRate] :: MiosProgramOption -> !Double [_confCheckAnswer] :: MiosProgramOption -> !Bool [_confVerbose] :: MiosProgramOption -> !Bool [_confTimeProbe] :: MiosProgramOption -> !Bool [_confStatProbe] :: MiosProgramOption -> !Bool [_confNoAnswer] :: MiosProgramOption -> !Bool [_validateAssignment] :: MiosProgramOption -> !Bool [_displayHelp] :: MiosProgramOption -> !Bool [_displayVersion] :: MiosProgramOption -> !Bool -- | default option settings miosDefaultOption :: MiosProgramOption -- | definition of mios option miosOptions :: [OptDescr (MiosProgramOption -> MiosProgramOption)] -- | generates help message miosUsage :: String -> String -- | builds MiosProgramOption from string given as command option miosParseOptions :: String -> [String] -> IO MiosProgramOption -- | builds MiosProgramOption from a String miosParseOptionsFromArgs :: String -> IO MiosProgramOption -- | converts MiosProgramOption into SIHConfiguration toMiosConf :: MiosProgramOption -> MiosConfiguration -- | Clause, supporting pointer-based equality module SAT.Mios.Clause -- | Fig. 7.(p.11) normal, null (and binary) clause. This matches -- both of Clause and GClause in MiniSat. data Clause Clause :: !Bool -> !Double' -> !Bool' -> !Stack -> Clause -- | whether this is a learnt clause , rank :: !Int' -- ^ goodness like -- LBD; computed in Ranking [learnt] :: Clause -> !Bool -- | activity of this clause [activity] :: Clause -> !Double' -- | protected from reduce [protected] :: Clause -> !Bool' -- | which this clause consists of [lits] :: Clause -> !Stack NullClause :: Clause -- | copies vec and return a new Clause. Since 1.0.100 DIMACS -- reader should use a scratch buffer allocated statically. newClauseFromStack :: Bool -> Stack -> IO Clause -- | Mutable Clause Vector type ClauseVector = IOVector Clause -- | returns a new ClauseVector. newClauseVector :: Int -> IO ClauseVector instance GHC.Classes.Eq SAT.Mios.Clause.Clause instance GHC.Show.Show SAT.Mios.Clause.Clause instance SAT.Mios.Vec.VecFamily SAT.Mios.Clause.Clause SAT.Mios.Types.Lit instance SAT.Mios.Vec.SingleStorage SAT.Mios.Clause.Clause GHC.Types.Int instance SAT.Mios.Vec.StackFamily SAT.Mios.Clause.Clause SAT.Mios.Types.Lit instance SAT.Mios.Vec.VecFamily SAT.Mios.Clause.ClauseVector SAT.Mios.Clause.Clause -- | A shrinkable vector of Clause module SAT.Mios.ClauseManager -- | Resizable vector of Clause. class ClauseManager a newManager :: ClauseManager a => Int -> IO a getClauseVector :: ClauseManager a => a -> IO ClauseVector -- | Clause + Blocking Literal data ClauseExtManager -- | O(1) inserter pushClauseWithKey :: ClauseExtManager -> Clause -> Lit -> IO () -- | returns the associated Int vector, which holds blocking -- literals. getKeyVector :: ClauseExtManager -> IO (UVector Int) -- | sets the expire flag to a clause. markClause :: ClauseExtManager -> Clause -> IO () -- | Immutable Vector of ClauseExtManager type WatcherList = Vector ClauseExtManager -- | n is the number of Var, m is default size of each -- watcher list. | For n vars, we need [0 .. 2 + 2 * n - 1] slots, -- namely 2 * (n + 1)-length vector newWatcherList :: Int -> Int -> IO WatcherList -- | returns the watcher List for Literal l. getNthWatcher :: WatcherList -> Lit -> ClauseExtManager instance SAT.Mios.Vec.SingleStorage SAT.Mios.ClauseManager.ClauseExtManager GHC.Types.Int instance SAT.Mios.Vec.StackFamily SAT.Mios.ClauseManager.ClauseExtManager SAT.Mios.Clause.Clause instance SAT.Mios.ClauseManager.ClauseManager SAT.Mios.ClauseManager.ClauseExtManager instance SAT.Mios.Vec.VecFamily SAT.Mios.ClauseManager.ClauseExtManager SAT.Mios.Clause.Clause instance SAT.Mios.Vec.VecFamily SAT.Mios.ClauseManager.WatcherList SAT.Mios.Clause.Clause -- | This is a part of MIOS; main data module SAT.Mios.Solver -- | Fig. 2.(p.9) Internal State of the solver data Solver Solver :: !(Vec Int) -> !Stack -> !ClauseExtManager -> !ClauseExtManager -> !WatcherList -> !(Vec Int) -> !(Vec Int) -> !Stack -> !Stack -> !Int' -> !ClauseVector -> !(Vec Int) -> !(Vec Double) -> !VarHeap -> !MiosConfiguration -> !Int -> !Double' -> !Int' -> !Bool' -> !(Vec Int) -> !Stack -> !Stack -> !Stack -> !Stack -> !(UVector Int) -> Solver -- | If found, this vector has the model [model] :: Solver -> !(Vec Int) -- | Set of literals in the case of conflicts [conflicts] :: Solver -> !Stack -- | List of problem constraints. [clauses] :: Solver -> !ClauseExtManager -- | List of learnt clauses. [learnts] :: Solver -> !ClauseExtManager -- | list of constraint wathing p, literal-indexed [watches] :: Solver -> !WatcherList -- | The current assignments indexed on variables [assigns] :: Solver -> !(Vec Int) -- | The last assignments indexed on variables [phases] :: Solver -> !(Vec Int) -- | List of assignments in chronological order [trail] :: Solver -> !Stack -- | Separator indices for different decision levels in trail. [trailLim] :: Solver -> !Stack -- | trail is divided at qHead; assignment part and queue part [qHead] :: Solver -> !Int' -- | For each variable, the constraint that implied its value [reason] :: Solver -> !ClauseVector -- | For each variable, the decision level it was assigned [level] :: Solver -> !(Vec Int) -- | Heuristic measurement of the activity of a variable [activities] :: Solver -> !(Vec Double) -- | Keeps track of the dynamic variable order. [order] :: Solver -> !VarHeap -- | search paramerters [config] :: Solver -> !MiosConfiguration -- | number of variables [nVars] :: Solver -> !Int -- | Variable activity increment amount to bump with. [varInc] :: Solver -> !Double' -- | Separates incremental and search assumptions. [rootLevel] :: Solver -> !Int' -- | return value holder [ok] :: Solver -> !Bool' -- | used in analyze [an'seen] :: Solver -> !(Vec Int) -- | used in analyze [an'toClear] :: Solver -> !Stack -- | used in analyze [an'stack] :: Solver -> !Stack -- | last decision level used in analyze [an'lastDL] :: Solver -> !Stack -- | used in analyze and search to create a learnt clause [litsLearnt] :: Solver -> !Stack -- | statistics information holder [stats] :: Solver -> !(UVector Int) -- | A heap tree built from two Vec. This implementation is -- identical wtih that in Minisat-1.14. Note: the zero-th element of -- heap is used for holding the number of elements. Note: -- VarHeap itself is not a VarOrder, because it requires a -- pointer to solver. data VarHeap -- | returns an everything-is-initialized solver from the arguments. newSolver :: MiosConfiguration -> CNFDescription -> IO Solver -- | returns the model as a list of literal. getModel :: Solver -> IO [Int] -- | returns the number of current assigments. nAssigns :: Solver -> IO Int -- | returns the number of constraints (clauses). nClauses :: Solver -> IO Int -- | returns the number of learnt clauses. nLearnts :: Solver -> IO Int -- | returns the current decision level. decisionLevel :: Solver -> IO Int -- | returns the assignment (:: LiftedBool = [-1, 0, -1]) -- from Var. valueVar :: Solver -> Var -> IO Int -- | returns the assignment (:: LiftedBool = [-1, 0, -1]) -- from Lit. valueLit :: Solver -> Lit -> IO Int -- | Fig. 7. (p.11) returns True if the clause is locked -- (used as a reason). Learnt clauses only locked :: Solver -> Clause -> IO Bool -- | returns False if a conflict has occured. This function is -- called only before the solving phase to register the given clauses. addClause :: Solver -> Stack -> IO Bool -- | Fig. 9 (p.14) Puts a new fact on the propagation queue, as well -- as immediately updating the variable's value in the assignment vector. -- If a conflict arises, False is returned and the propagation -- queue is cleared. The parameter from contains a reference to -- the constraint from which p was propagated (defaults to -- Nothing if omitted). enqueue :: Solver -> Lit -> Clause -> IO Bool -- | Fig. 12 (p.17) returns False if immediate conflict. -- -- Pre-condition: propagation queue is empty assume :: Solver -> Lit -> IO Bool -- | #M22: Revert to the states at given level (keeping all assignment at -- level but not beyond). cancelUntil :: Solver -> Int -> IO () -- | Fig. 14 (p.19) claBumpActivity :: Solver -> Clause -> IO () -- | Fig. 14 (p.19) claRescaleActivityAfterRestart :: Solver -> IO () -- | Fig. 14 (p.19) Bumping of clause activity varBumpActivity :: Solver -> Var -> IO () -- | Fig. 14 (p.19) varDecayActivity :: Solver -> IO () -- | value for rescaling clause activity. claActivityThreshold :: Double -- | stat index data StatIndex -- | the number of backjump NumOfBackjump :: StatIndex -- | the number of restart NumOfRestart :: StatIndex -- | Don't use this dummy. EndOfStatIndex :: StatIndex -- | returns the value of StatIndex. getStat :: Solver -> StatIndex -> IO Int -- | sets to StatIndex. setStat :: Solver -> StatIndex -> Int -> IO () -- | increments a stat data corresponding to StatIndex. incrementStat :: Solver -> StatIndex -> Int -> IO () -- | returns the statistics as a list. getStats :: Solver -> IO [(StatIndex, Int)] instance GHC.Show.Show SAT.Mios.Solver.StatIndex instance GHC.Read.Read SAT.Mios.Solver.StatIndex instance GHC.Classes.Ord SAT.Mios.Solver.StatIndex instance GHC.Classes.Eq SAT.Mios.Solver.StatIndex instance GHC.Enum.Enum SAT.Mios.Solver.StatIndex instance GHC.Enum.Bounded SAT.Mios.Solver.StatIndex instance SAT.Mios.Types.VarOrder SAT.Mios.Solver.Solver -- | This is a part of MIOS; main heuristics. module SAT.Mios.Main -- | #M22 -- -- simplify : [void] -> [bool] -- -- Description: Simplify the clause database according to the -- current top-level assigment. Currently, the only thing done here is -- the removal of satisfied clauses, but more things can be put here. simplifyDB :: Solver -> IO Bool -- | Fig. 16. (p.20) Main solve method. -- -- Pre-condition: If assumptions are used, simplifyDB must -- be called right before using this method. If not, a top-level conflict -- (resulting in a non-usable internal state) cannot be distinguished -- from a conflict under assumptions. solve :: (Foldable t) => Solver -> t Lit -> IO Bool -- | validate an assignment module SAT.Mios.Validator -- | validates the assignment even if the implementation of Solver -- is wrong; we re-implement some functions here. validate :: Traversable t => Solver -> t Int -> IO Bool -- | Minisat-based Implementation and Optimization Study on SAT solver module SAT.Mios -- | version name versionId :: String -- | Misc information on a CNF data CNFDescription CNFDescription :: !Int -> !Int -> Maybe FilePath -> CNFDescription -- | the number of variables [_numberOfVariables] :: CNFDescription -> !Int -- | the number of clauses [_numberOfClauses] :: CNFDescription -> !Int -- | given filename [_pathname] :: CNFDescription -> Maybe FilePath -- | new top-level interface that returns: -- -- runSolver :: Traversable t => MiosConfiguration -> CNFDescription -> t [Int] -> IO (Either [Int] [Int]) -- | The easiest interface for Haskell programs. This returns the result -- ::[[Int]] for a given (CNFDescription, [[Int]]). The -- first argument target can be build by Just target <- -- cnfFromFile targetfile. The second part of the first argument is -- a list of vector, which 0th element is the number of its real -- elements. solveSAT :: Traversable m => CNFDescription -> m [Int] -> IO [Int] -- | solves the problem (2rd arg) under the configuration (1st arg). and -- returns an assignment as list of literals :: Int. solveSATWithConfiguration :: Traversable m => MiosConfiguration -> CNFDescription -> m [Int] -> IO [Int] -- | Fig. 16. (p.20) Main solve method. -- -- Pre-condition: If assumptions are used, simplifyDB must -- be called right before using this method. If not, a top-level conflict -- (resulting in a non-usable internal state) cannot be distinguished -- from a conflict under assumptions. solve :: (Foldable t) => Solver -> t Lit -> IO Bool -- | returns the model as a list of literal. getModel :: Solver -> IO [Int] -- | returns True if a given assignment (2nd arg) satisfies the problem -- (1st arg). if you want to check the answer which a -- slover returned, run solver validate answer, -- where validate :: Traversable t => Solver -> t Lit -- -> IO Bool. validateAssignment :: (Traversable m, Traversable n) => CNFDescription -> m [Int] -> n Int -> IO Bool -- | validates the assignment even if the implementation of Solver -- is wrong; we re-implement some functions here. validate :: Traversable t => Solver -> t Int -> IO Bool -- | executes a solver on the given CNF file. This is the simplest entry to -- standalone programs; not for Haskell programs. executeSolverOn :: FilePath -> IO () -- | executes a solver on the given 'arg :: MiosConfiguration'. This is -- another entry point for standalone programs. executeSolver :: MiosProgramOption -> IO () -- | validates a given assignment from STDIN for the CNF file (2nd arg). -- this is the entry point for standalone programs. executeValidatorOn :: FilePath -> IO () -- | validates a given assignment for the problem (2nd arg). This is -- another entry point for standalone programs; see app/mios.hs. executeValidator :: MiosProgramOption -> IO () -- | dumps an assigment to file. 2nd arg is -- -- -- --
--   >>> do y <- solve s ... ; dumpAssigmentAsCNF "result.cnf" y <$> model s
--   
dumpAssigmentAsCNF :: FilePath -> Bool -> [Int] -> IO ()