clingo-0.2.0.0: Haskell bindings to the Clingo ASP solver

Safe HaskellNone
LanguageHaskell2010

Clingo.Control

Synopsis

Documentation

data IOSym s a Source #

A monad that serves as witness that data registered with a running solver still exists and can be used.

Instances

MonadSymbol IOSym Source # 
MonadModel IOSym Source # 
MonadSolve IOSym Source # 
Monad (IOSym s) Source # 

Methods

(>>=) :: IOSym s a -> (a -> IOSym s b) -> IOSym s b #

(>>) :: IOSym s a -> IOSym s b -> IOSym s b #

return :: a -> IOSym s a #

fail :: String -> IOSym s a #

Functor (IOSym s) Source # 

Methods

fmap :: (a -> b) -> IOSym s a -> IOSym s b #

(<$) :: a -> IOSym s b -> IOSym s a #

MonadFix (IOSym s) Source # 

Methods

mfix :: (a -> IOSym s a) -> IOSym s a #

Applicative (IOSym s) Source # 

Methods

pure :: a -> IOSym s a #

(<*>) :: IOSym s (a -> b) -> IOSym s a -> IOSym s b #

(*>) :: IOSym s a -> IOSym s b -> IOSym s b #

(<*) :: IOSym s a -> IOSym s b -> IOSym s a #

MonadIO (IOSym s) Source # 

Methods

liftIO :: IO a -> IOSym s a #

Alternative (IOSym s) Source # 

Methods

empty :: IOSym s a #

(<|>) :: IOSym s a -> IOSym s a -> IOSym s a #

some :: IOSym s a -> IOSym s [a] #

many :: IOSym s a -> IOSym s [a] #

MonadPlus (IOSym s) Source # 

Methods

mzero :: IOSym s a #

mplus :: IOSym s a -> IOSym s a -> IOSym s a #

MonadThrow (IOSym s) Source # 

Methods

throwM :: Exception e => e -> IOSym s a #

MonadCatch (IOSym s) Source # 

Methods

catch :: Exception e => IOSym s a -> (e -> IOSym s a) -> IOSym s a #

MonadMask (IOSym s) Source # 

Methods

mask :: ((forall a. IOSym s a -> IOSym s a) -> IOSym s b) -> IOSym s b #

uninterruptibleMask :: ((forall a. IOSym s a -> IOSym s a) -> IOSym s b) -> IOSym s b #

data Clingo s a 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.

Instances

MonadSymbol Clingo Source # 
MonadModel Clingo Source # 
MonadSolve Clingo Source # 
Monad (Clingo s) Source # 

Methods

(>>=) :: Clingo s a -> (a -> Clingo s b) -> Clingo s b #

(>>) :: Clingo s a -> Clingo s b -> Clingo s b #

return :: a -> Clingo s a #

fail :: String -> Clingo s a #

Functor (Clingo s) Source # 

Methods

fmap :: (a -> b) -> Clingo s a -> Clingo s b #

(<$) :: a -> Clingo s b -> Clingo s a #

MonadFix (Clingo s) Source # 

Methods

mfix :: (a -> Clingo s a) -> Clingo s a #

Applicative (Clingo s) Source # 

Methods

pure :: a -> Clingo s a #

(<*>) :: Clingo s (a -> b) -> Clingo s a -> Clingo s b #

(*>) :: Clingo s a -> Clingo s b -> Clingo s b #

(<*) :: Clingo s a -> Clingo s b -> Clingo s a #

MonadIO (Clingo s) Source # 

Methods

liftIO :: IO a -> Clingo s a #

Alternative (Clingo s) Source # 

Methods

empty :: Clingo s a #

(<|>) :: Clingo s a -> Clingo s a -> Clingo s a #

some :: Clingo s a -> Clingo s [a] #

many :: Clingo s a -> Clingo s [a] #

MonadPlus (Clingo s) Source # 

Methods

mzero :: Clingo s a #

mplus :: Clingo s a -> Clingo s a -> Clingo s a #

MonadThrow (Clingo s) Source # 

Methods

throwM :: Exception e => e -> Clingo s a #

MonadCatch (Clingo s) Source # 

Methods

catch :: Exception e => Clingo s a -> (e -> Clingo s a) -> Clingo s a #

MonadMask (Clingo s) Source # 

Methods

mask :: ((forall a. Clingo s a -> Clingo s a) -> Clingo s b) -> Clingo s b #

uninterruptibleMask :: ((forall a. Clingo s a -> Clingo s a) -> Clingo s b) -> Clingo s b #

data ClingoSetting Source #

Data type to encapsulate the settings for clingo.

Constructors

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.

data Part s Source #

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.

Constructors

Part 

Fields

loadProgram :: FilePath -> Clingo s () Source #

Load a logic program from a file.

addProgram Source #

Arguments

:: Foldable t 
=> Text

Part Name

-> t Text

Part Arguments

-> Text

Program Code

-> Clingo s () 

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.

ground Source #

Arguments

:: [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.

interrupt :: Clingo s () Source #

Interrupt the current solve call.

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 IOPropagators from Propagation. This function is unsafe!

data SymbolicLiteral s Source #

Constructors

SLPositive (Symbol s) 
SLNegative (Symbol s) 

Instances

Eq (SymbolicLiteral s) Source # 
Ord (SymbolicLiteral s) Source # 
Generic (SymbolicLiteral s) Source # 

Associated Types

type Rep (SymbolicLiteral s) :: * -> * #

Hashable (SymbolicLiteral s) Source # 
Signed (SymbolicLiteral s) Source # 
type Rep (SymbolicLiteral s) Source # 
type Rep (SymbolicLiteral s) = D1 (MetaData "SymbolicLiteral" "Clingo.Internal.Types" "clingo-0.2.0.0-DzJnCg9nABaE1yAGw8EIsO" False) ((:+:) (C1 (MetaCons "SLPositive" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Symbol s)))) (C1 (MetaCons "SLNegative" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Symbol s)))))

data Solver s 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 #

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.

backend :: Clingo s (Backend s) Source #

Obtain backend handle. See ProgramBuilding.

symbolicAtoms :: Clingo s (SymbolicAtoms s) Source #

Obtain symbolic atoms handle. See SymbolicAtoms.

theoryAtoms :: Clingo s (TheoryAtoms s) Source #

Obtain theory atoms handle. See TheoryAtoms.

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().

version :: MonadIO m => m (Int, Int, Int) Source #

Get clingo version.