-- 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.2 -- | 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 realLength :: Vec Int -> 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 -- | (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 -> !FilePath -> CNFDescription -- | the number of variables [_numberOfVariables] :: CNFDescription -> !Int -- | the number of clauses [_numberOfClauses] :: CNFDescription -> !Int -- | given filename [_pathname] :: CNFDescription -> !FilePath -- | Solver's parameters; random decision rate was dropped. data MiosConfiguration MiosConfiguration :: !Double -> !Double -> !Int -> !(Int, Int) -> !Double -> !Double -> MiosConfiguration -- | decay rate for variable activity [variableDecayRate] :: MiosConfiguration -> !Double -- | decay rate for clause activity [clauseDecayRate] :: MiosConfiguration -> !Double -- | dump stats data during solving [dumpSolverStatMode] :: MiosConfiguration -> !Int -- | the coefficients for restarts [emaCoeffs] :: MiosConfiguration -> !(Int, Int) -- | restart expansion factor [restartExpansion] :: MiosConfiguration -> !Double -- | static Steps between restarts [restartStep] :: MiosConfiguration -> !Double -- | dafault configuration -- --
-- >>> 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. updateVO :: VarOrder o => o -> Var -> IO () -- | should be called when a variable becomes unbound (may be selected -- again). undoVO :: VarOrder o => o -> Var -> IO () -- | returns a new, unassigned var as the next decision. selectVO :: VarOrder o => o -> IO Var -- | Exponential Moving Average, EMA type EMA = (Double', Maybe Double', Double) -- | returns a new EMA from a flag (slow or fast) and a window size newEMA :: Bool -> Int -> IO EMA -- | returns an EMA value getEMA :: EMA -> IO Double -- | updates an EMA updateEMA :: EMA -> Double -> IO Double -- | 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 -> !(Int, Int) -> !Double -> !Double -> MiosConfiguration -- | decay rate for variable activity [variableDecayRate] :: MiosConfiguration -> !Double -- | decay rate for clause activity [clauseDecayRate] :: MiosConfiguration -> !Double -- | dump stats data during solving [dumpSolverStatMode] :: MiosConfiguration -> !Int -- | the coefficients for restarts [emaCoeffs] :: MiosConfiguration -> !(Int, Int) -- | restart expansion factor [restartExpansion] :: MiosConfiguration -> !Double -- | static Steps between restarts [restartStep] :: MiosConfiguration -> !Double -- | dafault configuration -- --
-- >>> do y <- solve s ... ; dumpAssigmentAsCNF (Just "result.cnf") y <$> model s --dumpAssigmentAsCNF :: MiosProgramOption -> Certificate -> IO String