Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data IOSym s a
- data Clingo s a
- data ClingoWarning
- warningString :: MonadIO m => ClingoWarning -> m Text
- data ClingoSetting = ClingoSetting {
- clingoArgs :: [String]
- clingoLogger :: Maybe (ClingoWarning -> Text -> IO ())
- msgLimit :: Natural
- defaultClingo :: ClingoSetting
- withDefaultClingo :: (forall s. Clingo s r) -> IO r
- withClingo :: ClingoSetting -> (forall s. Clingo s r) -> IO r
- data Part s = Part {
- partName :: Text
- partParams :: [Symbol s]
- loadProgram :: FilePath -> Clingo s ()
- addProgram :: Foldable t => Text -> t Text -> Text -> Clingo s ()
- ground :: [Part s] -> Maybe (Location -> Text -> [Symbol s] -> ([Symbol s] -> IO ()) -> IO ()) -> Clingo s ()
- interrupt :: Clingo s ()
- cleanup :: Clingo s ()
- registerPropagator :: Bool -> Propagator s -> Clingo s ()
- registerUnsafePropagator :: Bool -> IOPropagator s -> Clingo s ()
- data Continue
- data SymbolicLiteral s
- = SLPositive (Symbol s)
- | SLNegative (Symbol s)
- data SolveResult
- exhausted :: SolveResult -> Bool
- data Solver s
- solve :: SolveMode -> [SymbolicLiteral s] -> Maybe (Maybe (Model s) -> IOSym s Continue) -> Clingo s (Solver s)
- withSolver :: [SymbolicLiteral s] -> (forall s1. Solver s1 -> IOSym s1 r) -> Clingo s r
- data SolveMode
- pattern SolveModeAsync :: SolveMode
- pattern SolveModeYield :: SolveMode
- statistics :: Clingo s (Statistics s)
- programBuilder :: Clingo s (ProgramBuilder s)
- configuration :: Clingo s (Configuration s)
- backend :: Clingo s (Backend s)
- symbolicAtoms :: Clingo s (SymbolicAtoms s)
- theoryAtoms :: Clingo s (TheoryAtoms s)
- data TruthValue
- pattern TruthTrue :: TruthValue
- pattern TruthFalse :: TruthValue
- pattern TruthFree :: TruthValue
- negateTruth :: TruthValue -> TruthValue
- assignExternal :: Symbol s -> TruthValue -> Clingo s ()
- releaseExternal :: Symbol s -> Clingo s ()
- getConst :: Text -> Clingo s (Symbol s)
- hasConst :: Text -> Clingo s Bool
- useEnumAssumption :: Bool -> Clingo s ()
- version :: MonadIO m => m (Int, Int, Int)
Documentation
A monad that serves as witness that data registered with a running solver still exists and can be used.
MonadSymbol IOSym Source # | |
MonadModel IOSym Source # | |
MonadSolve IOSym Source # | |
Monad (IOSym s) Source # | |
Functor (IOSym s) Source # | |
MonadFix (IOSym s) Source # | |
Applicative (IOSym s) Source # | |
MonadIO (IOSym s) Source # | |
Alternative (IOSym s) Source # | |
MonadPlus (IOSym s) Source # | |
MonadThrow (IOSym s) Source # | |
MonadCatch (IOSym s) Source # | |
MonadMask (IOSym s) Source # | |
The Clingo
monad provides a base monad for computations utilizing the
clingo answer set solver. It uses an additional type parameter to ensure that
values that are managed by the solver can not leave scope.
MonadSymbol Clingo Source # | |
MonadModel Clingo Source # | |
MonadSolve Clingo Source # | |
Monad (Clingo s) Source # | |
Functor (Clingo s) Source # | |
MonadFix (Clingo s) Source # | |
Applicative (Clingo s) Source # | |
MonadIO (Clingo s) Source # | |
Alternative (Clingo s) Source # | |
MonadPlus (Clingo s) Source # | |
MonadThrow (Clingo s) Source # | |
MonadCatch (Clingo s) Source # | |
MonadMask (Clingo s) Source # | |
warningString :: MonadIO m => ClingoWarning -> m Text Source #
data ClingoSetting Source #
Data type to encapsulate the settings for clingo.
ClingoSetting | |
|
defaultClingo :: ClingoSetting Source #
Default settings for clingo. This is like calling clingo with no arguments, and no logger.
withDefaultClingo :: (forall s. Clingo s r) -> IO r Source #
Equal to withClingo defaultClingo
withClingo :: ClingoSetting -> (forall s. Clingo s r) -> IO r Source #
The entry point into a computation utilizing clingo. Inside, a handle to the clingo solver is available, which can not leave scope. By the same mechanism, derived handles cannot be passed out either.
A Part
is one building block of a logic program in clingo. Parts can be
grounded separately and can have arguments, which need to be initialized with
the solver.
Part | |
|
loadProgram :: FilePath -> Clingo s () Source #
Load a logic program from a file.
Add an ungrounded logic program to the solver as a Text
. This function
can be used in order to utilize clingo's parser. See parseProgram
for when
you want to modify the AST before adding it.
:: [Part s] | Parts to be grounded |
-> Maybe (Location -> Text -> [Symbol s] -> ([Symbol s] -> IO ()) -> IO ()) | Callback for injecting symbols |
-> Clingo s () |
Ground logic program parts. A callback can be provided to inject symbols when needed.
cleanup :: Clingo s () Source #
Clean up the domains of clingo's grounding component using the solving component's top level assignment.
This function removes atoms from domains that are false and marks atoms as facts that are true. With multi-shot solving, this can result in smaller groundings because less rules have to be instantiated and more simplifications can be applied.
registerPropagator :: Bool -> Propagator s -> Clingo s () Source #
Register a custom propagator with the solver.
If the sequential flag is set to true, the propagator is called sequentially when solving with multiple threads.
See the Propagation
module for more information.
registerUnsafePropagator :: Bool -> IOPropagator s -> Clingo s () Source #
Like registerPropagator
but allows using IOPropagator
s from
Propagation
. This function is unsafe!
A datatype that can be used to indicate whether solving shall continue or not.
data SymbolicLiteral s Source #
SLPositive (Symbol s) | |
SLNegative (Symbol s) |
Eq (SymbolicLiteral s) Source # | |
Ord (SymbolicLiteral s) Source # | |
Generic (SymbolicLiteral s) Source # | |
Hashable (SymbolicLiteral s) Source # | |
Signed (SymbolicLiteral s) Source # | |
type Rep (SymbolicLiteral s) Source # | |
data SolveResult Source #
exhausted :: SolveResult -> Bool Source #
solve :: SolveMode -> [SymbolicLiteral s] -> Maybe (Maybe (Model s) -> IOSym s Continue) -> Clingo s (Solver s) Source #
Solve the currently grounded logic program enumerating its models. Takes an
optional event callback. Since Clingo 5.2, the callback is no longer the only
way to interact with models. The callback can still be used to obtain the
same functionality as before. It will be called with Nothing
when there is
no more model.
Furthermore, asynchronous solving and iterative solving is also controlled from this function. See Clingo.Solving for more details.
The Solver
must be closed explicitly after use. See withSolver
for a
bracketed version.
withSolver :: [SymbolicLiteral s] -> (forall s1. Solver s1 -> IOSym s1 r) -> Clingo s r Source #
pattern SolveModeAsync :: SolveMode Source #
pattern SolveModeYield :: SolveMode Source #
statistics :: Clingo s (Statistics s) Source #
Obtain statistics handle. See Statistics
.
programBuilder :: Clingo s (ProgramBuilder s) Source #
Obtain program builder handle. See ProgramBuilding
.
configuration :: Clingo s (Configuration s) Source #
Obtain configuration handle. See Configuration
.
symbolicAtoms :: Clingo s (SymbolicAtoms s) Source #
Obtain symbolic atoms handle. See SymbolicAtoms
.
theoryAtoms :: Clingo s (TheoryAtoms s) Source #
Obtain theory atoms handle. See TheoryAtoms
.
pattern TruthTrue :: TruthValue Source #
pattern TruthFalse :: TruthValue Source #
pattern TruthFree :: TruthValue Source #
negateTruth :: TruthValue -> TruthValue Source #
assignExternal :: Symbol s -> TruthValue -> Clingo s () Source #
Assign a truth value to an external atom.
If the atom does not exist or is not external, this is a noop.
releaseExternal :: Symbol s -> Clingo s () Source #
Release an external atom.
After this call, an external atom is no longer external and subject to program simplifications. If the atom does not exist or is not external, this is a noop.
getConst :: Text -> Clingo s (Symbol s) Source #
Get the symbol for a constant definition #const name = symbol
.
hasConst :: Text -> Clingo s Bool Source #
Check if there is a constant definition for the given constant.
useEnumAssumption :: Bool -> Clingo s () Source #
Configure how learnt constraints are handled during enumeration.
If the enumeration assumption is enabled, then all information learnt from the solver's various enumeration modes is removed after a solve call. This includes enumeration of cautious or brave consequences, enumeration of answer sets with or without projection, or finding optimal models, as well as clauses added with clingo_solve_control_add_clause().