-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A Minisat-based CDCL SAT solver in Haskell -- -- A modern and very fast SAT solver written in Haskell, using CDCL, -- watch literals, VSIDS, blocking-literals, phase saving, LBD, -- Glucose-like restart and so on. Mios is an abbreviation of -- 'Minisat-based Implementation and Optimization Study on SAT solver'. @package mios @version 1.6.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 -- | 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 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]] -- | 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/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 -- | (This is a part of MIOS.) Abstraction Layer for Mutable Vectors module SAT.Mios.Vec -- | The interface on vectors. class VecFamily v a | v -> a -- | 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 () -- | 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] -- | Another abstraction layer on Vector which reserves zero -- element for internal use. Note: If you want to use the 0-th -- element, use UVector Int. -- | Interface for single (one-length vector) mutable data class SingleStorage s t | s -> t -- | 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' = ByteArrayDouble -- | Mutable Int Note: Int' is identical to Stack type Int' = ByteArrayInt -- | Interface on stacks class SingleStorage s Int => StackFamily s t | s -> t -- | 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 () -- | Stack of Int, an alias of Vec Int type Stack = Vec Int -- | returns a new Stack from [Int]. newStackFromList :: [Int] -> IO Stack -- | returns the number of allocated slots realLengthOfStack :: Stack -> Int -- | sort the content of a stack, in small-to-large order. sortStack :: Stack -> IO () instance SAT.Mios.Vec.StackFamily SAT.Mios.Vec.ByteArrayInt GHC.Types.Int instance SAT.Mios.Vec.SingleStorage SAT.Mios.Vec.Bool' GHC.Types.Bool instance SAT.Mios.Vec.SingleStorage SAT.Mios.Vec.ByteArrayInt GHC.Types.Int instance SAT.Mios.Vec.SingleStorage SAT.Mios.Vec.ByteArrayDouble GHC.Types.Double instance SAT.Mios.Vec.VecFamily SAT.Mios.Vec.ByteArrayDouble GHC.Types.Double instance SAT.Mios.Vec.VecFamily SAT.Mios.Vec.ByteArrayInt GHC.Types.Int instance SAT.Mios.Vec.VecFamily (SAT.Mios.Vec.UVector GHC.Types.Int) GHC.Types.Int instance SAT.Mios.Vec.VecFamily (SAT.Mios.Vec.Vec [GHC.Types.Int]) GHC.Types.Int -- | (This is a part of MIOS.) Basic data types used throughout mios. module SAT.Mios.Types -- | the type that Mios returns This captures the following three cases: * -- solved with a satisfiable assigment, * proved that it's an -- unsatisfiable problem, and * aborted due to Mios specification or an -- internal error type SolverResult = Either SolverException Certificate -- | terminate and find an SAT/UNSAT answer data Certificate SAT :: [Int] -> Certificate UNSAT :: [Int] -> Certificate -- | abnormal termination flags data SolverException StateUNSAT :: SolverException StateSAT :: SolverException OutOfMemory :: SolverException TimeOut :: SolverException InternalInconsistent :: SolverException UndescribedError :: SolverException -- | 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 -> !Double -> !Int -> MiosConfiguration -- | decay rate for variable activity [variableDecayRate] :: MiosConfiguration -> !Double -- | decay rate for clause activity [clauseDecayRate] :: MiosConfiguration -> !Double -- | dump stats data during solving [dumpStat] :: MiosConfiguration -> !Int -- | dafault configuration -- -- defaultConfiguration :: MiosConfiguration -- | 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 -- | Lifted Boolean domain (p.7) that extends Bool with "⊥" means -- undefined design note: _|_ should be null = 0; True literals -- are coded to even numbers. So it should be 2. type LiftedBool = Int -- | returns the value of a literal as a LiftedBool lit2lbool :: Lit -> LiftedBool -- | A fixed-precision integer type with at least the range [-2^29 .. -- 2^29-1]. The exact range for a given implementation can be -- determined by using minBound and maxBound from the -- Bounded class. data 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 -- | 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 -- | stat index data StatIndex -- | the number of backjump NumOfBackjump :: StatIndex -- | the number of restart NumOfRestart :: StatIndex -- | the number of blacking start NumOfBlockRestart :: StatIndex -- | the number of classic restart NumOfGeometricRestart :: StatIndex -- | the number of propagation NumOfPropagation :: StatIndex -- | the number of reduction NumOfReduction :: StatIndex -- | the number of alive given clauses NumOfClause :: StatIndex -- | the number of alive learnt clauses NumOfLearnt :: StatIndex -- | the number of alive variables NumOfVariable :: StatIndex -- | the number of assigned variables NumOfAssigned :: StatIndex -- | Don't use this dummy. EndOfStatIndex :: StatIndex -- | formats of state dump data DumpMode NoDump :: DumpMode DumpCSVHeader :: DumpMode DumpCSV :: DumpMode DumpJSON :: DumpMode instance GHC.Show.Show SAT.Mios.Types.MiosDump instance GHC.Read.Read SAT.Mios.Types.MiosDump instance GHC.Classes.Ord SAT.Mios.Types.MiosDump instance GHC.Classes.Eq SAT.Mios.Types.MiosDump instance GHC.Show.Show SAT.Mios.Types.MiosStats instance GHC.Read.Read SAT.Mios.Types.MiosStats instance GHC.Classes.Ord SAT.Mios.Types.MiosStats instance GHC.Classes.Eq SAT.Mios.Types.MiosStats instance GHC.Show.Show SAT.Mios.Types.DumpTag instance GHC.Read.Read SAT.Mios.Types.DumpTag instance GHC.Classes.Ord SAT.Mios.Types.DumpTag instance GHC.Classes.Eq SAT.Mios.Types.DumpTag instance GHC.Enum.Enum SAT.Mios.Types.DumpTag instance GHC.Enum.Bounded SAT.Mios.Types.DumpTag instance GHC.Show.Show SAT.Mios.Types.DumpMode instance GHC.Read.Read SAT.Mios.Types.DumpMode instance GHC.Classes.Ord SAT.Mios.Types.DumpMode instance GHC.Classes.Eq SAT.Mios.Types.DumpMode instance GHC.Enum.Enum SAT.Mios.Types.DumpMode instance GHC.Enum.Bounded SAT.Mios.Types.DumpMode instance GHC.Show.Show SAT.Mios.Types.StatIndex instance GHC.Read.Read SAT.Mios.Types.StatIndex instance GHC.Classes.Ord SAT.Mios.Types.StatIndex instance GHC.Classes.Eq SAT.Mios.Types.StatIndex instance GHC.Enum.Enum SAT.Mios.Types.StatIndex instance GHC.Enum.Bounded SAT.Mios.Types.StatIndex instance GHC.Show.Show SAT.Mios.Types.MiosConfiguration instance GHC.Read.Read SAT.Mios.Types.MiosConfiguration instance GHC.Classes.Ord SAT.Mios.Types.MiosConfiguration instance GHC.Classes.Eq SAT.Mios.Types.MiosConfiguration instance GHC.Show.Show SAT.Mios.Types.CNFDescription instance GHC.Read.Read SAT.Mios.Types.CNFDescription instance GHC.Classes.Ord SAT.Mios.Types.CNFDescription instance GHC.Classes.Eq SAT.Mios.Types.CNFDescription instance GHC.Show.Show SAT.Mios.Types.SolverException instance GHC.Classes.Ord SAT.Mios.Types.SolverException instance GHC.Classes.Eq SAT.Mios.Types.SolverException instance GHC.Enum.Enum SAT.Mios.Types.SolverException instance GHC.Enum.Bounded SAT.Mios.Types.SolverException instance GHC.Show.Show SAT.Mios.Types.Certificate instance GHC.Read.Read SAT.Mios.Types.Certificate instance GHC.Classes.Ord SAT.Mios.Types.Certificate instance GHC.Classes.Eq SAT.Mios.Types.Certificate -- | (This is a part of MIOS.) Command line option parser module SAT.Mios.OptionParser -- | Solver's parameters; random decision rate was dropped. data MiosConfiguration MiosConfiguration :: !Double -> !Double -> !Int -> MiosConfiguration -- | decay rate for variable activity [variableDecayRate] :: MiosConfiguration -> !Double -- | decay rate for clause activity [clauseDecayRate] :: MiosConfiguration -> !Double -- | dump stats data during solving [dumpStat] :: MiosConfiguration -> !Int -- | dafault configuration -- -- defaultConfiguration :: MiosConfiguration -- | configuration swithces data MiosProgramOption MiosProgramOption :: Maybe String -> [String] -> Maybe String -> !Double -> Double -> !Int -> !Bool -> !Bool -> Integer -> !Int -> !Bool -> !Int -> !Bool -> !Bool -> !Bool -> MiosProgramOption [_targetFile] :: MiosProgramOption -> Maybe String [_targets] :: MiosProgramOption -> [String] [_outputFile] :: MiosProgramOption -> Maybe String [_confVariableDecayRate] :: MiosProgramOption -> !Double [_confClauseDecayRate] :: MiosProgramOption -> Double [_confMaxSize] :: MiosProgramOption -> !Int [_confCheckAnswer] :: MiosProgramOption -> !Bool [_confVerbose] :: MiosProgramOption -> !Bool [_confBenchmark] :: MiosProgramOption -> Integer [_confBenchSeq] :: MiosProgramOption -> !Int [_confNoAnswer] :: MiosProgramOption -> !Bool [_confDumpStat] :: MiosProgramOption -> !Int [_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 -- | (This is a part of MIOS.) 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 :: !Int' -> !Double' -> !Stack -> Clause -- | goodness like LBD; computed in Ranking [rank] :: Clause -> !Int' -- | activity of this clause , protected :: !Bool' -- ^ protected from -- reduce [activity] :: Clause -> !Double' -- | 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 SAT.Mios.Vec.VecFamily SAT.Mios.Clause.ClauseVector SAT.Mios.Clause.Clause 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 -- | (This is a part of MIOS.) 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 ClauseSimpleManager -- | 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 (Vec [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 FIXME: sometimes n > 1M newWatcherList :: Int -> Int -> IO WatcherList -- | returns the watcher List for Literal l. getNthWatcher :: WatcherList -> Lit -> ClauseExtManager instance SAT.Mios.Vec.VecFamily SAT.Mios.ClauseManager.WatcherList SAT.Mios.Clause.Clause 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.SingleStorage SAT.Mios.ClauseManager.ClauseSimpleManager GHC.Types.Int instance SAT.Mios.Vec.StackFamily SAT.Mios.ClauseManager.ClauseSimpleManager SAT.Mios.Clause.Clause instance SAT.Mios.ClauseManager.ClauseManager SAT.Mios.ClauseManager.ClauseSimpleManager -- | (This is a part of MIOS.) Recycling clauses module SAT.Mios.ClausePool -- | an immutable Vector of ClauseSimpleManager type ClausePool = Vector ClauseSimpleManager -- | returns a new ClausePool newClausePool :: Int -> IO ClausePool -- | If a nice candidate as a learnt is stored, return it. Otherwise -- allocate a new clause in heap then return it. makeClauseFromStack :: ClausePool -> Stack -> IO Clause -- | Note: only not-too-large and learnt clauses are recycled. putBackToPool :: ClausePool -> Clause -> IO () -- | (This is a part of MIOS.) Solver, the main data structure module SAT.Mios.Solver -- | Fig. 2.(p.9) Internal State of the solver data Solver Solver :: !ClauseExtManager -> !ClauseExtManager -> !WatcherList -> !(Vec Int) -> !(Vec Int) -> !Stack -> !Stack -> !Int' -> !ClauseVector -> !(Vec Int) -> !Stack -> !(Vec Double) -> !VarHeap -> !MiosConfiguration -> !Int -> !Double' -> !Double' -> !Int' -> Double' -> Int' -> Double' -> !Int' -> !(Vec Int) -> !Stack -> !Stack -> !Stack -> ClausePool -> !Stack -> !(Vec [Int]) -> !(Vec Int) -> !Int' -> !Double' -> !Double' -> !Double' -> !Double' -> !Int' -> Int' -> Solver -- | 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) -- | Set of literals in the case of conflicts [conflicts] :: Solver -> !Stack -- | 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 -- | Clause activity increment amount to bump with. [claInc] :: Solver -> !Double' -- | Variable activity increment amount to bump with. [varInc] :: Solver -> !Double' -- | Separates incremental and search assumptions. [rootLevel] :: Solver -> !Int' -- | used in search [learntSAdj] :: Solver -> Double' -- | used in search [learntSCnt] :: Solver -> Int' -- | used in search [maxLearnts] :: Solver -> Double' -- | internal flag [ok] :: Solver -> !Int' -- | 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 -- | clause recycler [clsPool] :: Solver -> ClausePool -- | used in analyze and search to create a learnt clause [litsLearnt] :: Solver -> !Stack -- | statistics information holder [stats] :: Solver -> !(Vec [Int]) -- | used in lbd computation [lbd'seen] :: Solver -> !(Vec Int) -- | used in lbd computation [lbd'key] :: Solver -> !Int' -- | fast ema value of LBD [emaDFast] :: Solver -> !Double' -- | slow ema value of LBD [emaDSlow] :: Solver -> !Double' -- | fast ema value of assignment [emaAFast] :: Solver -> !Double' -- | slow ema value of assignment [emaASlow] :: Solver -> !Double' -- | next restart in number of conflict [nextRestart] :: Solver -> !Int' -- | mode of restart [restartMode] :: Solver -> Int' -- | returns an everything-is-initialized solver from the arguments. newSolver :: MiosConfiguration -> CNFDescription -> IO Solver -- | 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 -- | assigns a value to the n-th variable setAssign :: Solver -> Int -> LiftedBool -> IO () -- | 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 () -- | stat index data StatIndex -- | the number of backjump NumOfBackjump :: StatIndex -- | the number of restart NumOfRestart :: StatIndex -- | the number of blacking start NumOfBlockRestart :: StatIndex -- | the number of classic restart NumOfGeometricRestart :: StatIndex -- | the number of propagation NumOfPropagation :: StatIndex -- | the number of reduction NumOfReduction :: StatIndex -- | the number of alive given clauses NumOfClause :: StatIndex -- | the number of alive learnt clauses NumOfLearnt :: StatIndex -- | the number of alive variables NumOfVariable :: StatIndex -- | the number of assigned variables NumOfAssigned :: 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)] -- | print statatistic data to stdio. This should be called after each -- restart. dumpSolver :: DumpMode -> Solver -> IO () instance SAT.Mios.Types.VarOrder SAT.Mios.Solver.Solver -- | (This is a part of MIOS.) 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 -- | (This is a part of MIOS.) Advanced heuristics library for Main module SAT.Mios.Criteria -- | Fig. 14 (p.19) claBumpActivity :: Solver -> Clause -> IO () -- | Fig. 14 (p.19) claDecayActivity :: Solver -> IO () -- | Fig. 14 (p.19) Bumping of clause activity varBumpActivity :: Solver -> Var -> IO () -- | Fig. 14 (p.19) varDecayActivity :: Solver -> IO () -- | 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 -- | returns a POSIVITE value lbdOf :: Solver -> Stack -> IO Int -- | #62 checkRestartCondition :: Solver -> Int -> IO Bool -- | (This is a part of MIOS.) Main part of solving satisfiability problem. module SAT.Mios.Main -- | Fig. 2.(p.9) Internal State of the solver data Solver -- | returns an everything-is-initialized solver from the arguments. newSolver :: MiosConfiguration -> CNFDescription -> IO Solver -- | assigns a value to the n-th variable setAssign :: Solver -> Int -> LiftedBool -> IO () -- | 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 -- | print statatistic data to stdio. This should be called after each -- restart. dumpSolver :: DumpMode -> Solver -> IO () -- | #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 SolverResult -- | (This file is a part of MIOS.) 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 SolverResult -- | the type that Mios returns This captures the following three cases: * -- solved with a satisfiable assigment, * proved that it's an -- unsatisfiable problem, and * aborted due to Mios specification or an -- internal error type SolverResult = Either SolverException Certificate -- | terminate and find an SAT/UNSAT answer data Certificate SAT :: [Int] -> Certificate UNSAT :: [Int] -> Certificate -- | 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 () -- | parses the header of a CNF file parseCNF :: Maybe FilePath -> IO (CNFDescription, ByteString) -- | parses ByteString then injects the clauses in it into a solver injectClausesFromCNF :: Solver -> CNFDescription -> ByteString -> IO () -- | dumps an assigment to file. 2nd arg is -- -- -- --
--   >>> do y <- solve s ... ; dumpAssigmentAsCNF (Just "result.cnf") y <$> model s
--   
dumpAssigmentAsCNF :: Maybe FilePath -> Certificate -> IO ()