clingo (version 5.3.0)
«Potassco

The clingo-5.3.0 module.
 
This module provides functions and classes to work with ground terms and to
control the instantiation process.  In clingo builts, additional functions to
control and inspect the solving process are available.
 
Functions defined in a python script block are callable during the
instantiation process using @-syntax. The default grounding/solving process can
be customized if a main function is provided.
 
Note that gringo's precomputed terms (terms without variables and interpreted
functions), called symbols in the following, are wrapped in the Symbol class.
Furthermore, strings, numbers, and tuples can be passed wherever a symbol is
expected - they are automatically converted into a Symbol object.  Functions
called during the grounding process from the logic program must either return a
symbol or a sequence of symbols.  If a sequence is returned, the corresponding
@-term is successively substituted by the values in the sequence.
 
Static Objects:
 
__version__ -- version of the clingo module (5.3.0)
Infimum     -- represents an #inf symbol
Supremum    -- represents a #sup symbol
 
Functions:
 
Function()      -- create a function symbol
Number()        -- create a number symbol
parse_program() -- parse a logic program
parse_term()    -- parse ground terms
String()        -- create a string symbol
Tuple()         -- create a tuple symbol (shortcut)
 
Classes:
 
ApplicationOptions  -- add custom options to clingo
Assignment          -- partial assignment of truth values to solver literals
Backend             -- extend the logic program
Configuration       -- modify/inspect the solver configuration
Control             -- controls the grounding/solving process
Flag                -- helper object to parse command line flags
HeuristicType       -- enumeration of heuristic modificators
MessageCode         -- enumeration of message codes
Model               -- provides access to a model during solve call
ModelType           -- captures the type of a model
ProgramBuilder      -- extend a non-ground logic program
PropagatorCheckMode -- enumeration of check modes
PropagateControl    -- controls running search in a custom propagator
PropagateInit       -- object to initialize custom propagators
SolveControl        -- controls running search in a model handler
SolveHandle         -- handle for solve calls
SolveResult         -- result of a solve call
StatisticsArray     -- updatable statistics stored in an array
StatisticsMap       -- updatable statistics stored in a map
Symbol              -- captures precomputed terms
SymbolicAtom        -- captures information about a symbolic atom
SymbolicAtomIter    -- iterate over symbolic atoms
SymbolicAtoms       -- inspection of symbolic atoms
SymbolType          -- enumeration of symbol types
TheoryAtom          -- captures theory atoms
TheoryAtomIter      -- iterate over theory atoms
TheoryElement       -- captures theory elements
TheoryTerm          -- captures theory terms
TheoryTermType      -- the type of a theory term
TruthValue          -- enumeration of truth values
 
Example:
 
#script (python)
import clingo
def id(x):
    return x
 
def seq(x, y):
    return [x, y]
 
def main(prg):
    prg.ground([("base", [])])
    prg.solve()
 
#end.
 
p(@id(10)).
q(@seq(1,2)).

 
Modules
       
clingo.ast

 
Classes
       
object
ApplicationOptions
Assignment
Backend
Configuration
Control
Flag
HeuristicType
MessageCode
Model
ModelType
ProgramBuilder
PropagateControl
PropagateInit
PropagatorCheckMode
SolveControl
SolveHandle
SolveResult
StatisticsArray
StatisticsMap
Symbol
SymbolType
SymbolicAtom
SymbolicAtomIter
SymbolicAtoms
TheoryAtom
TheoryAtomIter
TheoryElement
TheoryTerm
TheoryTermType
TruthValue

 
class ApplicationOptions(object)
    Object add custom options to a clingo based application.
 
  Methods defined here:
add(...)
add_flag(self, group, option, description, parser, multi, argument) -> None
 
Add an option that is processed with a custom parser.
 
Note that the parser also has to take care of storing the semantic value of
the option somewhere.
 
Parameter option specifies the name(s) of the option. For example, "ping,p"
adds the short option "-p" and its long form "--ping". It is also possible to
associate an option with a help level by adding "@l" to the option
specification. Options with a level greater than zero are only shown if the
argument to help is greater or equal to l.
 
An option parser is a function that takes a string as input and returns true or
false depending on whether the option was parsed successively.
 
Note that an error is raised if an option with the same name already exists.
 
Arguments:
options     -- object to register the option with
group       -- options are grouped into sections as given by this string
option      -- specifies the command line option
description -- the description of the option
parser      -- callback to parse the value of the option
 
Keyword Arguments:
multi    -- whether the option can appear multiple times on the command-line
            (Default: False)
argument -- optional string to change the value name in the generated help
            output
add_flag(...)
add_flag(self, group, option, description, target) -> None
 
Add an option that is a simple flag.
 
This function is similar to add() but simpler because it only supports flags,
which do not have values. Note that the target parameter must be of type Flag,
which is set to true if the flag is passed on the command line.
 
Arguments:
group       -- options are grouped into sections as given by this string
option      -- name on the command line
description -- description of the option
target      -- Flag object

 
class Assignment(object)
    Object to inspect the (parital) assignment of an associated solver.
 
Assigns truth values to solver literals.  Each solver literal is either true,
false, or undefined, represented by the python constants True, False, or None,
respectively.
 
  Methods defined here:
decision(...)
decision(self, level) -> int
 
Return the decision literal of the given level.
has_literal(...)
has_literal(self, lit) -> bool
 
Determine if the literal is valid in this solver.
is_false(...)
is_false(self, lit) -> bool
 
Determine if the literal is false.
is_fixed(...)
is_fixed(self, lit) -> bool
 
Determine if the literal is assigned on the top level.
is_true(...)
is_true(self, lit) -> bool
 
Determine if the literal is true.
level(...)
level(self, lit) -> int
 
The decision level of the given literal.
 
Note that the returned value is only meaningful if the literal is assigned -
i.e., value(lit) is not None.
value(...)
value(self, lit) -> bool or None
 
The truth value of the given literal or None if it has none.

Data descriptors defined here:
decision_level
The current decision level.
has_conflict
True if the assignment is conflicting.
is_total
Wheather the assignment is total.
max_size
The maximum size of the assignment (if all literals are assigned).
size
The number of assigned literals.

 
class Backend(object)
    Backend object providing a low level interface to extend a logic program.
 
This class provides an interface that allows for adding statements in ASPIF
format.
 
  Methods defined here:
__enter__(...)
__enter__(self) -> Backend
 
Initialize the backend.
 
Must be called before using the backend.
__exit__(...)
__exit__(self, type, value, traceback) -> bool
 
Finalize the backend.
 
Follows python __exit__ conventions. Does not suppress exceptions.
add_atom(...)
add_atom(self, symbol) -> Int
 
Return a fresh program atom or the atom associated with the given symbol.
 
If the given symbol does not exist in the atom base, it is added first. Such
atoms will be used in susequents calls to ground for instantiation.
 
Keyword Arguments:
symbol -- optional symbol (Default: None)
add_external(...)
add_atom(self, atom, value) -> Int
 
Mark an atom as external optionally fixing its truth value.
 
Can also be used to unmark an external atom.
 
Arguments:
atom -- the atom to mark as external
 
Keyword Arguments:
value -- optional truth value (Default: TruthValue._False)
add_minimize(...)
add_minimize(self, priority, literals) -> None
Add a minimize constraint to the program.
 
Arguments:
priority -- integer for the priority
literals -- list of pairs of program literals and weights
add_rule(...)
add_rule(self, head, body, choice) -> None
 
Add a disjuntive or choice rule to the program.
 
Arguments:
head -- list of program atoms
 
Keyword Arguments:
body   -- list of program literals (Default: [])
choice -- whether to add a disjunctive or choice rule (Default: False)
 
Integrity constraints and normal rules can be added by using an empty or
singleton head list, respectively.
add_weight_rule(...)
add_weight_rule(self, head, lower, body, choice) -> None
Add a disjuntive or choice rule with one weight constraint with a lower bound
in the body to the program.
 
Arguments:
head  -- list of program atoms
lower -- integer for the lower bound
body  -- list of pairs of program literals and weights
 
Keyword Arguments:
choice -- whether to add a disjunctive or choice rule (Default: False)

 
class Configuration(object)
    Allows for changing the configuration of the underlying solver.
 
Options are organized hierarchically. To change and inspect an option use:
 
  config.group.subgroup.option = "value"
  value = config.group.subgroup.option
 
There are also arrays of option groups that can be accessed using integer
indices:
 
  config.group.subgroup[0].option = "value1"
  config.group.subgroup[1].option = "value2"
 
To list the subgroups of an option group, use the keys member. Array option
groups, like solver, have a non-negative length and can be iterated.
Furthermore, there are meta options having key "configuration". Assigning a
meta option sets a number of related options.  To get further information about
an option or option group <opt>, use property __desc_<opt> to retrieve a
description.
 
Example:
 
#script (python)
import clingo
 
def main(prg):
    prg.configuration.solve.models = 0
    prg.ground([("base", [])])
    prg.solve()
 
#end.
 
{a; c}.
 
Expected Answer Sets:
 
{ {}, {a}, {c}, {a,c} }
 
  Methods defined here:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__len__(...)
x.__len__() <==> len(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value

Data descriptors defined here:
keys
The list of names of sub-option groups or options.
 
The list is None if the current object is not an option group.

 
class Control(object)
    Control(arguments) -> Control
 
Control object for the grounding/solving process.
 
Keyword Arguments:
arguments     -- arguments to the grounder and solver (default: []).
logger        -- function to intercept messages normally printed to standard
                 error (default: None)
message_limit -- maximum number of messages passed to the logger (default: 20)
 
Note that only gringo options (without --text) and clasp's search options are
supported. Furthermore, a Control object is blocked while a search call is
active; you must not call any member function during search.
 
  Methods defined here:
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature
add(...)
add(self, name, params, program) -> None
 
Extend the logic program with the given non-ground logic program in string form.
 
Arguments:
name    -- name of program block to add
params  -- parameters of program block
program -- non-ground program as string
 
Example:
 
#script (python)
import clingo
 
def main(prg):
    prg.add("p", ["t"], "q(t).")
    prg.ground([("p", [2])])
    prg.solve()
 
#end.
 
Expected Answer Set:
q(2)
assign_external(...)
assign_external(self, external, truth) -> None
 
Assign a truth value to an external atom (represented as a function symbol or
program literal).
 
It is possible to assign a Boolean or None.  A Boolean fixes the external to the
respective truth value; and None leaves its truth value open.
 
The truth value of an external atom can be changed before each solve call. An
atom is treated as external if it has been declared using an #external
directive, and has not been forgotten by calling release_external() or defined
in a logic program with some rule. If the given atom is not external, then the
function has no effect.
 
For convenience, the truth assigned to atoms over negative program literals is
inverted.
 
Arguments:
external -- symbol or program literal representing the external atom
truth    -- bool or None indicating the truth value
 
To determine whether an atom a is external, inspect the symbolic_atoms using
SolveControl.symbolic_atoms[a].is_external. See release_external() for an
example.
backend(...)
backend() -> Backend
 
Returns a Backend object providing a low level interface to extend a logic program.
builder(...)
builder(self) -> ProgramBuilder
 
Return a builder to construct non-ground logic programs.
 
Example:
 
#script (python)
 
import clingo
 
def main(prg):
    s = "a."
    with prg.builder() as b:
        clingo.parse_program(s, lambda stm: b.add(stm))
    prg.ground([("base", [])])
    prg.solve()
 
#end.
cleanup(...)
cleanup(self) -> None
 
Cleanup the domain used for grounding by incorporating information from the
solver.
 
This function cleans up the domain used for grounding.  This is done by first
simplifying the current program representation (falsifying released external
atoms).  Afterwards, the top-level implications are used to either remove atoms
from the domain or mark them as facts.
 
Note that any atoms falsified are completely removed from the logic program.
Hence, a definition for such an atom in a successive step introduces a fresh atom.
get_const(...)
get_const(self, name) -> Symbol
 
Return the symbol for a constant definition of form: #const name = symbol.
ground(...)
ground(self, parts, context) -> None
 
Ground the given list of program parts specified by tuples of names and arguments.
 
Keyword Arguments:
parts   -- list of tuples of program names and program arguments to ground
context -- context object whose methods are called during grounding using
           the @-syntax (if omitted methods from the main module are used)
 
Note that parts of a logic program without an explicit #program specification
are by default put into a program called base without arguments.
 
Example:
 
#script (python)
import clingo
 
def main(prg):
    parts = []
    parts.append(("p", [1]))
    parts.append(("p", [2]))
    prg.ground(parts)
    prg.solve()
 
#end.
 
#program p(t).
q(t).
 
Expected Answer Set:
q(1) q(2)
interrupt(...)
interrupt(self) -> None
 
Interrupt the active solve call.
 
This function is thread-safe and can be called from a signal handler. If no
search is active the subsequent call to solve() is interrupted. The SolveResult
of the above solving methods can be used to query if the search was
interrupted.
load(...)
load(self, path) -> None
 
Extend the logic program with a (non-ground) logic program in a file.
 
Arguments:
path -- path to program
register_observer(...)
register_observer(self, observer, replace) -> None
 
Registers the given observer to inspect the produced grounding.
 
Arguments:
observer -- the observer to register
 
Keyword Arguments:
replace  -- if set to true, the output is just passed to the observer and no
            longer to the underlying solver
            (Default: False)
 
An observer should be a class of the form below. Not all functions have to be
implemented and can be omitted if not needed.
 
class GroundProgramObserver:
    init_program(self, incremental) -> None
        Called once in the beginning.
 
        If the incremental flag is true, there can be multiple calls to
        Control.solve().
 
        Arguments:
        incremental -- whether the program is incremental
 
    begin_step(self) -> None
        Marks the beginning of a block of directives passed to the solver.
 
    rule(self, choice, head, body) -> None
        Observe rules passed to the solver.
 
        Arguments:
        choice -- determines if the head is a choice or a disjunction
        head   -- list of program atoms
        body   -- list of program literals
 
    weight_rule(self, choice, head, lower_bound, body) -> None
        Observe weight rules passed to the solver.
 
        Arguments:
        choice      -- determines if the head is a choice or a disjunction
        head        -- list of program atoms
        lower_bound -- the lower bound of the weight rule
        body        -- list of weighted literals (pairs of literal and weight)
 
    minimize(self, priority, literals) -> None
        Observe minimize constraints (or weak constraints) passed to the
        solver.
 
        Arguments:
        priority -- the priority of the constraint
        literals -- list of weighted literals whose sum to minimize
                    (pairs of literal and weight)
 
    project(self, atoms) -> None
        Observe projection directives passed to the solver.
 
        Arguments:
        atoms -- the program atoms to project on
 
    output_atom(self, symbol, atom) -> None
        Observe shown atoms passed to the solver.  Facts do not have an
        associated program atom.  The value of the atom is set to zero.
 
        Arguments:
        symbol -- the symbolic representation of the atom
        atom   -- the program atom (0 for facts)
 
    output_term(self, symbol, condition) -> None
        Observe shown terms passed to the solver.
 
        Arguments:
        symbol    -- the symbolic representation of the term
        condition -- list of program literals
 
    output_csp(self, symbol, value, condition) -> None
        Observe shown csp variables passed to the solver.
 
        Arguments:
        symbol    -- the symbolic representation of the variable
        value     -- the integer value of the variable
        condition -- list of program literals
 
    external(self, atom, value) -> None
        Observe external statements passed to the solver.
 
        Arguments:
        atom  -- the external atom in form of a literal
        value -- the TruthValue of the external statement
 
    assume(self, literals) -> None
        Observe assumption directives passed to the solver.
 
        Arguments:
        literals -- the program literals to assume (positive literals are true
                    and negative literals false for the next solve call)
 
    heuristic(self, atom, type, bias, priority, condition) -> None
        Observe heuristic directives passed to the solver.
 
        Arguments:
        atom      -- the target atom
        type      -- the HeuristicType
        bias      -- the heuristic bias
        priority  -- the heuristic priority
        condition -- list of program literals
 
    acyc_edge(self, node_u, node_v, condition) -> None
        Observe edge directives passed to the solver.
 
        Arguments:
        node_u    -- the start vertex of the edge (in form of an integer)
        node_v    -- the end vertex of the edge (in form of an integer)
        condition -- list of program literals
 
    theory_term_number(self, term_id, number) -> None
        Observe numeric theory terms.
 
        Arguments:
        term_id -- the id of the term
        number  -- the (integer) value of the term
 
    theory_term_string(self, term_id, name) -> None
        Observe string theory terms.
 
        Arguments:
        term_id -- the id of the term
        name    -- the string value of the term
 
    theory_term_compound(self, term_id, name_id_or_type, arguments) -> None
        Observe compound theory terms.
 
        The name_id_or_type gives the type of the compound term:
        - if it is -1, then it is a tuple
        - if it is -2, then it is a set
        - if it is -3, then it is a list
        - otherwise, it is a function and name_id_or_type refers to the id of
          the name (in form of a string term)
 
        Arguments:
        term_id         -- the id of the term
        name_id_or_type -- the name or type of the term
        arguments       -- the arguments of the term
 
    theory_element(self, element_id, terms, condition) -> None
        Observe theory elements.
 
        Arguments:
        element_id -- the id of the element
        terms      -- term tuple of the element
        condition  -- list of program literals
 
    theory_atom(self, atom_id_or_zero, term_id, elements) -> None
        Observe theory atoms without guard.
 
        Arguments:
        atom_id_or_zero -- the id of the atom or zero for directives
        term_id         -- the term associated with the atom
        elements        -- the list of elements of the atom
 
    theory_atom_with_guard(self, atom_id_or_zero, term_id, elements,
                           operator_id, right_hand_side_id) -> None
        Observe theory atoms with guard.
 
        Arguments:
        atom_id_or_zero    -- the id of the atom or zero for directives
        term_id            -- the term associated with the atom
        elements           -- the elements of the atom
        operator_id        -- the id of the operator (a string term)
        right_hand_side_id -- the id of the term on the right hand side of the atom
 
    end_step(self) -> None
        Marks the end of a block of directives passed to the solver.
 
        This function is called right before solving starts.
register_propagator(...)
register_propagator(self, propagator) -> None
 
Registers the given propagator with all solvers.
 
Arguments:
propagator -- the propagator to register
 
A propagator should be a class of the form below. Not all functions have to be
implemented and can be omitted if not needed.
 
class Propagator(object)
    init(self, init) -> None
        This function is called once before each solving step.  It is used to
        map relevant program literals to solver literals, add watches for
        solver literals, and initialize the data structures used during
        propagation.
 
        Arguments:
        init -- PropagateInit object
 
        Note that this is the last point to access theory atoms.  Once the
        search has started, they are no longer accessible.
 
    propagate(self, control, changes) -> None
        Can be used to propagate solver literals given a partial assignment.
 
        Arguments:
        control -- PropagateControl object
        changes -- list of watched solver literals assigned to true
 
        Usage:
        Called during propagation with a non-empty list of watched solver
        literals that have been assigned to true since the last call to either
        propagate, undo, (or the start of the search) - the change set.  Only
        watched solver literals are contained in the change set.  Each literal
        in the change set is true w.r.t. the current Assignment.
        PropagateControl.add_clause can be used to add clauses.  If a clause is
        unit resulting, it can be propagated using
        PropagateControl.propagate().  If either of the two methods returns
        False, the propagate function must return immediately.
 
          c = ...
          if not control.add_clause(c) or not control.propagate(c):
              return
 
        Note that this function can be called from different solving threads.
        Each thread has its own assignment and id, which can be obtained using
        PropagateControl.id().
 
    undo(self, thread_id, assign, changes) -> None
        Called whenever a solver with the given id undos assignments to watched
        solver literals.
 
        Arguments:
        thread_id -- the solver thread id
        changes   -- list of watched solver literals whose assignment is undone
 
        This function is meant to update assignment dependent state in a
        propagator.
 
    check(self, control) -> None
        This function is similar to propagate but is called without a change
        set on propagation fixpoints.  When exactly this function is called,
        can be configured using the @ref PropagateInit.check_mode property.
 
        Note that this function is called even if no watches have been added.
 
        Arguments:
        control -- PropagateControl object
 
        This function is called even if no watches have been added.
release_external(...)
release_external(self, symbol) -> None
 
Release an external atom represented by the given symbol or program literal.
 
This function causes the corresponding atom to become permanently false if
there is no definition for the atom in the program. Otherwise, the function has
no effect.
 
If the program literal is negative, the corresponding atom is released.
 
Example:
 
#script (python)
from clingo import function
 
def main(prg):
    prg.ground([("base", [])])
    prg.assign_external(Function("b"), True)
    prg.solve()
    prg.release_external(Function("b"))
    prg.solve()
 
#end.
 
a.
#external b.
 
Expected Answer Sets:
a b
a
solve(...)
solve(self, assumptions, on_model, on_finish, yield_, async) -> SolveHandle|SolveResult
 
Starts a search.
 
Keyword Arguments:
on_model      -- Optional callback for intercepting models.
                 A Model object is passed to the callback.
                 (Default: None)
on_statistics -- Optional callback to update statistics.
                 The step and accumulated statistics are passed as arguments.
                 (Default: None)
on_finish     -- Optional callback called once search has finished.
                 A SolveResult and a Boolean indicating whether the solve call
                 has been canceled is passed to the callback.
                 (Default: None)
assumptions   -- List of (atom, boolean) tuples or program literals that serve
                 as assumptions for the solve call, e.g. - solving under
                 assumptions [(Function("a"), True)] only admits answer sets
                 that contain atom a.
                 (Default: [])
yield_        -- The resulting SolveHandle is iterable yielding Model objects.
                 (Default: False)
async         -- The solve call and SolveHandle.resume() are non-blocking.
                 (Default: False)
 
If neither yield_ nor async is set, the function returns a SolveResult right
away.
 
Note that in gringo or in clingo with lparse or text output enabled this
function just grounds and returns a SolveResult where SolveResult.satisfiable
is True.
 
You might want to start clingo using the --outf=3 option to disable all output
from clingo.
 
Note that asynchronous solving is only available in clingo with thread support
enabled. Furthermore, the on_model and on_finish callbacks are called from
another thread.  To ensure that the methods can be called, make sure to not use
any functions that block the GIL indefinitely.
 
This function as well as blocking functions on the SolveHandle release the GIL
but are not thread-safe.
 
Example:
 
#script (python)
import clingo
 
def main(prg):
    prg.add("p", [], "{a;b;c}.")
    prg.ground([("p", [])])
    ret = prg.solve()
    print(ret)
 
#end.
 
Yielding Example:
 
#script (python)
import clingo
 
def main(prg):
    prg.add("p", [], "{a;b;c}.")
    prg.ground([("p", [])])
    with prg.solve(yield_=True) as handle:
        for m in handle: print m
        print(handle.get())
 
#end.
 
Asynchronous Example:
 
#script (python)
import clingo
 
def on_model(model):
    print model
 
def on_finish(res, canceled):
    print res, canceled
 
def main(prg):
    prg.add("p", [], "{a;b;c}.")
    prg.ground([("base", [])])
    with prg.solve(on_model=on_model, on_finish=on_finish, async=True) as handle:
        while not handle.wait(0):
            # do something asynchronously
        print(handle.get())
 
#end.

Data descriptors defined here:
configuration
Configuration object to change the configuration.
is_conflicting
Whether the internal program representation is conflicting.
 
If this (read-only) property is true, solve calls return immediately with an
unsatisfiable solve result.  Note that conflicts first have to be detected,
e.g. - initial unit propagation results in an empty clause, or later if an
empty clause is resolved during solving.  Hence, the property might be false
even if the problem is unsatisfiable.
statistics
A dictionary containing solve statistics of the last solve call.
 
Contains the statistics of the last solve() call. The statistics correspond to
the --stats output of clingo.  The detail of the statistics depends on what
level is requested on the command line. Furthermore, you might want to start
clingo using the --outf=3 option to disable all output from clingo.
 
Note that this (read-only) property is only available in clingo.
 
Example:
import json
json.dumps(prg.statistics, sort_keys=True, indent=4, separators=(',', ': '))
symbolic_atoms
SymbolicAtoms object to inspect the symbolic atoms.
theory_atoms
A TheoryAtomIter object, which can be used to iterate over the theory atoms.
use_enumeration_assumption
Boolean determining how learnt information from enumeration modes is treated.
 
If the enumeration assumption is enabled, then all information learnt from
clasp'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/nogoods
added with Model.add_clause()/Model.add_nogood().
 
Note that initially the enumeration assumption is enabled.

Data and other attributes defined here:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
class Flag(object)
    Helper object to parse flags.
 
Keyword Arguments:
value -- initial value of the flag
 
  Methods defined here:
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature

Data descriptors defined here:
value
The value of the flag.

Data and other attributes defined here:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
class HeuristicType(object)
    Enumeration of the different heuristic types.
 
HeuristicType objects cannot be constructed from python. Instead the following
preconstructed objects are available:
 
HeuristicType.True    -- truth value true
HeuristicType.False   -- truth value false
HeuristicType.Free    -- no truth value
HeuristicType.Release -- indicates that an atom is to be released
 
  Methods defined here:
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__le__(...)
x.__le__(y) <==> x<=y
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__str__(...)
x.__str__() <==> str(x)

Data and other attributes defined here:
Factor = Factor
False = False
Init = Init
Level = Level
Sign = Sign
True = True

 
class MessageCode(object)
    Enumeration of the different types of messages.
 
MessageCode objects cannot be constructed from python. Instead the following
preconstructed objects are available:
 
MessageCode.OperationUndefined -- undefined arithmetic operation or weight of aggregate
MessageCode.RuntimeError       -- to report multiple errors; a corresponding runtime error is raised later
MessageCode.AtomUndefined      -- undefined atom in program
MessageCode.FileIncluded       -- same file included multiple times
MessageCode.VariableUnbounded  -- CSP variable with unbounded domain
MessageCode.GlobalVariable     -- global variable in tuple of aggregate element
MessageCode.Other              -- other kinds of messages
 
  Methods defined here:
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__le__(...)
x.__le__(y) <==> x<=y
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__str__(...)
x.__str__() <==> str(x)

Data and other attributes defined here:
AtomUndefined = AtomUndefined
FileIncluded = FileIncluded
GlobalVariable = GlobalVariable
OperationUndefined = OperationUndefined
Other = Other
RuntimeError = RuntimeError
VariableUnbounded = VariableUnbounded

 
class Model(object)
    Provides access to a model during a solve call.
 
The string representation of a model object is similar to the output of models
by clingo using the default output.
 
Note that model objects cannot be constructed from python. Instead they are
passed as argument to a model callback (see Control.solve()). Furthermore, the
lifetime of a model object is limited to the scope of the callback. They must
not be stored for later use in other places like - e.g., the main function.
 
  Methods defined here:
__repr__(...)
x.__repr__() <==> repr(x)
__str__(...)
x.__str__() <==> str(x)
contains(...)
contains(self, atom) -> bool
 
Check if an atom is contained in the model.
 
The atom must be represented using a function symbol.
extend(...)
extend(self, symbols) -> None
 
Extend a model with the given symbols.
 
This only has an effect if there is an underlying clingo application, which
will print the added symbols.
is_true(...)
is_true(self, a) -> bool
 
Check if the given program literal is true.
symbols(...)
symbols(self, atoms, terms, shown, csp, complement)
        -> list of terms
 
Return the list of atoms, terms, or CSP assignments in the model.
 
Keyword Arguments:
atoms      -- select all atoms in the model (independent of #show statements)
              (Default: False)
terms      -- select all terms displayed with #show statements in the model
              (Default: False)
shown      -- select all atoms and terms as outputted by clingo
              (Default: False)
csp        -- select all csp assignments (independent of #show statements)
              (Default: False)
complement -- return the complement of the answer set w.r.t. to the Herbrand
              base accumulated so far (does not affect csp assignments)
              (Default: False)
 
Note that atoms are represented using functions (Symbol objects), and that CSP
assignments are represented using functions with name "$" where the first
argument is the name of the CSP variable and the second its value.

Data descriptors defined here:
context
SolveControl object that allows for controlling the running search.
cost
Return the list of integer cost values of the model.
 
The return values correspond to clasp's cost output.
number
The running number of the model.
optimality_proven
Whether the optimality of the model has been proven.
thread_id
The id of the thread which found the model.
type
The type of the model.

 
class ModelType(object)
    Enumeration of the different types of models.
 
ModelType objects cannot be constructed from python. Instead the following
preconstructed objects are available:
 
SymbolType.StableModel          -- a stable model
SymbolType.BraveConsequences    -- set of brave consequences
SymbolType.CautiousConsequences -- set of cautious consequences
 
  Methods defined here:
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__le__(...)
x.__le__(y) <==> x<=y
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__str__(...)
x.__str__() <==> str(x)

Data and other attributes defined here:
BraveConsequences = BraveConsequences
CautiousConsequences = CautiousConsequences
StableModel = StableModel

 
class ProgramBuilder(object)
    Object to build non-ground programs.
 
  Methods defined here:
__enter__(...)
__enter__(self) -> ProgramBuilder
 
Begin building a program.
 
Must be called before adding statements.
__exit__(...)
__exit__(self, type, value, traceback) -> bool
 
Finish building a program.
 
Follows python __exit__ conventions. Does not suppress exceptions.
add(...)
add(self, statement) -> None
 
Adds a statement in form of an ast.AST node to the program.

 
class PropagateControl(object)
    This object can be used to add clauses and propagate literals.
 
  Methods defined here:
add_clause(...)
add_clause(self, clause, tag, lock) -> bool
 
Add the given clause to the solver.
 
This method returns False if the current propagation must be stopped.
 
Arguments:
clause -- sequence of solver literals
 
Keyword Arguments:
tag  -- clause applies only in the current solving step
        (Default: False)
lock -- exclude clause from the solver's regular clause deletion policy
        (Default: False)
add_literal(...)
add_literal(self) -> int
 
Adds a new positive volatile literal to the underlying solver thread.
 
The literal is only valid within the current solving step and solver thread.
All volatile literals and clauses involving a volatile literal are deleted
after the current search.
add_nogood(...)
add_nogood(self, clause, tag, lock) -> bool
Equivalent to self.add_clause([-lit for lit in clause], tag, lock).
add_watch(...)
add_watch(self, literal) -> None
Add a watch for the solver literal in the given phase.
 
Unlike PropagateInit.add_watch() this does not add a watch to all solver
threads but just the current one.
 
Arguments:
literal -- the target literal
has_watch(...)
has_watch(self, literal) -> bool
Check whether a literal is watched in the current solver thread.
 
Arguments:
literal -- the target literal
propagate(...)
propagate(self) -> bool
 
Propagate implied literals.
remove_watch(...)
remove_watch(self, literal) -> None
Removes the watch (if any) for the given solver literal.
 
Similar to PropagateInit.add_watch() this just removes the watch in the current
solver thread.
 
Arguments:
literal -- the target literal

Data descriptors defined here:
assignment
The partial assignment of the current solver thread.
thread_id
The numeric id of the current solver thread.

 
class PropagateInit(object)
    Object that is used to initialize a propagator before each solving step.
 
Each symbolic or theory atom is uniquely associated with a positive program
atom in form of a positive integer.  Program literals additionally have a sign
to represent default negation.  Furthermore, there are non-zero integer solver
literals.  There is a surjective mapping from program atoms to solver literals.
 
All methods called during propagation use solver literals whereas
SymbolicAtom.literal() and TheoryAtom.literal() return program literals.  The
function PropagateInit.solver_literal() can be used to map program literals or
condition ids to solver literals.
 
  Methods defined here:
add_watch(...)
add_watch(self, lit, thread_id) -> None
 
Add a watch for the solver literal in the given phase.
 
If the thread_id is None then all active threads will watch the literal.
 
Arguments:
literal -- the literal to watch
 
Keyword Arguments:
thread_id -- id of the thread to watch the literal
             (Default: None)
solver_literal(...)
solver_literal(self, lit) -> int
 
Map the given program literal or condition id to its solver literal.

Data descriptors defined here:
assignment
The top level assignment.
check_mode
PropagatorCheckMode controlling when to call Propagator.check().
number_of_threads
The number of solver threads used in the corresponding solve call.
symbolic_atoms
The symbolic atoms captured by a SymbolicAtoms object.
theory_atoms
A TheoryAtomIter object to iterate over all theory atoms.

 
class PropagatorCheckMode(object)
    Enumeration of supported check modes for propagators.
 
PropagatorCheckMode objects cannot be constructed from python. Instead the
following preconstructed objects are available:
 
PropagatorCheckMode.None     -- do not call Propagator.check() at all
PropagatorCheckMode.Total    -- call Propagator.check() on total assignment
PropagatorCheckMode.Fixpoint -- call Propagator.check() on propagation fixpoints
 
  Methods defined here:
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__le__(...)
x.__le__(y) <==> x<=y
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__str__(...)
x.__str__() <==> str(x)

Data and other attributes defined here:
Fixpoint = Fixpoint
Off = Off
Total = Total

 
class SolveControl(object)
    Object that allows for controlling a running search.
 
Note that SolveControl objects cannot be constructed from python.  Instead
they are available as properties of Model objects.
 
  Methods defined here:
add_clause(...)
add_clause(self, literals) -> None
 
Add a clause that applies to the current solving step during the search.
 
Arguments:
literals -- list of literals either represented as pairs of symbolic atoms and
            Booleans or as program literals
 
Note that this function can only be called in the model callback (or while
iterating when using a SolveHandle).
add_nogood(...)
add_nogood(self, literals) -> None
 
Equivalent to add_clause with the literals inverted.
 
Arguments:
literals -- list of pairs of Booleans and atoms representing the nogood

Data descriptors defined here:
symbolic_atoms
The symbolic atoms captured by a SymbolicAtoms object.

 
class SolveHandle(object)
    Handle for solve calls.
 
SolveHandle objects cannot be created from python. Instead they are returned by
Control.solve.  A SolveHandle object can be used to control solving, like,
retrieving models or cancelling a search.
 
Blocking functions in this object release the GIL. They are not thread-safe though.
 
See Control.solve() for an example.
 
  Methods defined here:
__enter__(...)
__enter__(self) -> SolveHandle
 
Returns self.
__exit__(...)
__exit__(self, type, value, traceback) -> bool
 
Follows python __exit__ conventions. Does not suppress exceptions.
 
Stops the current search. It is necessary to call this method after each
search.
__iter__(...)
x.__iter__() <==> iter(x)
cancel(...)
cancel(self) -> None
 
Cancel the running search.
 
See Control.interrupt() for a thread-safe alternative.
get(...)
get(self) -> SolveResult
 
Get the result of a solve call.
 
If the search is not completed yet, the function blocks until the result is
ready.
next(...)
x.next() -> the next value, or raise StopIteration
resume(...)
resume(self) -> None
 
Discards the last model and starts the search for the next one.
 
If the search has been started asynchronously, this function also starts the
search in the background.  A model that was not yet retrieved by calling __next__
is not discared.
wait(...)
wait(self, timeout) -> None or bool
 
Wait for solve call to finish with an optional timeout.
 
If a timeout is given, the function waits at most timeout seconds and returns a
Boolean indicating whether the search has finished. Otherwise, the function
blocks until the search is finished and returns nothing.
 
Arguments:
timeout -- optional timeout in seconds
           (permits floating point values)

 
class SolveResult(object)
    Captures the result of a solve call.
 
SolveResult objects cannot be constructed from python. Instead they
are returned by the solve methods of the Control object.
 
  Methods defined here:
__repr__(...)
x.__repr__() <==> repr(x)
__str__(...)
x.__str__() <==> str(x)

Data descriptors defined here:
exhausted
True if the search space was exhausted.
interrupted
True if the search was interrupted.
satisfiable
True if the problem is satisfiable, False if the problem is
unsatisfiable, or None if the satisfiablity is not known.
unknown
True if the satisfiablity is not known.
 
This is equivalent to satisfiable is None.
unsatisfiable
True if the problem is unsatisfiable, False if the problem is
satisfiable, or None if the satisfiablity is not known.
 
This is equivalent to None if satisfiable is None else not satisfiable.

 
class StatisticsArray(object)
    StatisticsArray object to capture statistics stored in an array.
 
This class implements the sequence protocol but does not support deletion.
Furthermore, only existing numeric values in a statistics array can be changed
using the assignment operator.
 
The update function provides a convenient means to initialize and modify a
statistics array.
 
  Methods defined here:
__delitem__(...)
x.__delitem__(y) <==> del x[y]
__getitem__(...)
x.__getitem__(y) <==> x[y]
__len__(...)
x.__len__() <==> len(x)
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
append(...)
append(self, statistics) -> None
 
Append a statistics to an array.
 
The statistics parameter has to be a nested structure composed of numbers,
sequences, and mappings.
extend(...)
extend(self, values) -> None
 
Extend the statistics array with the given values.
 
Calls append() for each element of values.
update(...)
update(self, statistics) -> None
 
Update a statistics array.
 
The statistics argument must be a sequence. Further, it has to be a nested
structure composed of numbers, sequences, mappings, and callables. A callable
can be used to update an existing value, it receives the previous numeric value
(or None if absent) as argument and must return an updated numeric value.

 
class StatisticsMap(object)
    StatisticsMap object to capture statistics stored in a map.
 
  Methods defined here:
__contains__(...)
x.__contains__(y) <==> y in x
__delitem__(...)
x.__delitem__(y) <==> del x[y]
__getitem__(...)
x.__getitem__(y) <==> x[y]
__iter__(...)
x.__iter__() <==> iter(x)
__len__(...)
x.__len__() <==> len(x)
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
items(...)
items(self) -> [(str, Statstics)]
 
Return the items in the statistics map.
keys(...)
keys(self) -> [str]
 
Return the keys in the statistics map.
update(...)
update(self, statistics) -> None
 
Update a statistics array.
 
The statistics argument must be a map. Otherwise, it is equivalent to
StatisticsArray.update().
values(...)
values(self) -> [Statistics]
 
Return the values in the statistics map.

 
class Symbol(object)
    Represents a gringo symbol.
 
This includes numbers, strings, functions (including constants with
len(arguments) == 0 and tuples with len(name) == 0), #inf and #sup.  Symbol
objects are ordered like in gringo and their string representation corresponds
to their gringo representation.
 
Note that this class does not have a constructor. Instead there are the
functions Number(), String(), and Function() to construct symbol objects or the
preconstructed symbols Infimum and Supremum.
 
  Methods defined here:
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__le__(...)
x.__le__(y) <==> x<=y
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__str__(...)
x.__str__() <==> str(x)

Data descriptors defined here:
arguments
The arguments of a function.
name
The name of a function.
negative
The sign of a function.
number
The value of a number.
positive
The sign of a function.
string
The value of a string.
type
The type of the symbol.

 
class SymbolType(object)
    Enumeration of the different types of symbols.
 
SymbolType objects cannot be constructed from python. Instead the following
preconstructed objects are available:
 
SymbolType.Number   -- a numeric symbol - e.g., 1
SymbolType.String   -- a string symbol - e.g., "a"
SymbolType.Function -- a numeric symbol - e.g., c, (1, "a"), or f(1,"a")
SymbolType.Infimum  -- the #inf symbol
SymbolType.Supremum -- the #sup symbol
 
  Methods defined here:
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__le__(...)
x.__le__(y) <==> x<=y
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__str__(...)
x.__str__() <==> str(x)

Data and other attributes defined here:
Function = Function
Infimum = Infimum
Number = Number
String = String
Supremum = Supremum

 
class SymbolicAtom(object)
    Captures a symbolic atom and provides properties to inspect its state.
 
  Data descriptors defined here:
is_external
Wheather the atom is an external atom.
is_fact
Wheather the atom is a is_fact.
literal
The program literal associated with the atom.
symbol
The representation of the atom in form of a symbol (Symbol object).

 
class SymbolicAtomIter(object)
    Class to iterate over symbolic atoms.
 
  Methods defined here:
__iter__(...)
x.__iter__() <==> iter(x)
next(...)
x.next() -> the next value, or raise StopIteration

 
class SymbolicAtoms(object)
    This class provides read-only access to the symbolic atoms of the grounder
(the Herbrand base).
 
Example:
 
p(1).
{ p(3) }.
#external p(1..3).
 
q(X) :- p(X).
 
#script (python)
 
import clingo
 
def main(prg):
    prg.ground([("base", [])])
    print "universe:", len(prg.symbolic_atoms)
    for x in prg.symbolic_atoms:
        print x.symbol, x.is_fact, x.is_external
    print "p(2) is in domain:", prg.symbolic_atoms[clingo.Function("p", [3])] is not None
    print "p(4) is in domain:", prg.symbolic_atoms[clingo.Function("p", [6])] is not None
    print "domain of p/1:"
    for x in prg.symbolic_atoms.by_signature("p", 1):
        print x.symbol, x.is_fact, x.is_external
    print "signatures:", prg.symbolic_atoms.signatures
 
#end.
 
Expected Output:
 
universe: 6
p(1) True False
p(3) False False
p(2) False True
q(1) True False
q(3) False False
q(2) False False
p(2) is in domain: True
p(4) is in domain: False
domain of p/1:
p(1) True False
p(3) False False
p(2) False True
signatures: [('p', 1), ('q', 1)]
 
  Methods defined here:
__contains__(...)
x.__contains__(y) <==> y in x
__getitem__(...)
x.__getitem__(y) <==> x[y]
__iter__(...)
x.__iter__() <==> iter(x)
__len__(...)
x.__len__() <==> len(x)
by_signature(...)
by_signature(self, name, arity, positive) -> SymbolicAtomIter
 
Return an iterator over the symbolic atoms with the given signature.
 
Arguments:
name     -- the name of the signature
arity    -- the arity of the signature
positive -- the sign of the signature

Data descriptors defined here:
signatures
The list of predicate signatures (triples of names, arities, and Booleans)
occurring in the program. A true Boolean stands for a positive signature.

 
class TheoryAtom(object)
    TheoryAtom objects represent theory atoms.
 
  Methods defined here:
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__le__(...)
x.__le__(y) <==> x<=y
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__str__(...)
x.__str__() <==> str(x)

Data descriptors defined here:
elements
elements -> [TheoryElement]
 
The theory elements of the theory atom.
guard
guard -> (str, TheoryTerm)
 
The guard of the theory atom or None if the atom has no guard.
literal
literal -> int
 
The program literal associated with the theory atom.
term
term -> TheoryTerm
 
The term of the theory atom.

 
class TheoryAtomIter(object)
    Object to iterate over all theory atoms.
 
  Methods defined here:
__getitem__(...)
x.__getitem__(y) <==> x[y]
__iter__(...)
x.__iter__() <==> iter(x)
__len__(...)
x.__len__() <==> len(x)
get(...)
get(self) -> TheoryAtom
next(...)
x.next() -> the next value, or raise StopIteration

 
class TheoryElement(object)
    TheoryElement objects represent theory elements which consist of a tuple of
terms and a set of literals.
 
  Methods defined here:
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__le__(...)
x.__le__(y) <==> x<=y
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__str__(...)
x.__str__() <==> str(x)

Data descriptors defined here:
condition
condition -> [TheoryTerm]
 
The condition of the element.
condition_id
condition_id -> int
 
Each condition has an id. This id can be passed to PropagateInit.solver_literal
to obtain a solver literal equivalent to the condition.
terms
terms -> [TheoryTerm]
 
The tuple of the element.

 
class TheoryTerm(object)
    TheoryTerm objects represent theory terms.
 
This are read-only objects, which can be obtained from theory atoms and
elements.
 
  Methods defined here:
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__le__(...)
x.__le__(y) <==> x<=y
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__str__(...)
x.__str__() <==> str(x)

Data descriptors defined here:
arguments
arguments -> [Symbol]
 
The arguments of the TheoryTerm (for functions, tuples, list, and sets).
name
name -> str
 
The name of the TheoryTerm\n(for symbols and functions).
number
number -> integer
 
The numeric representation of the TheoryTerm (for numbers).
type
type -> TheoryTermType
 
The type of the theory term.

 
class TheoryTermType(object)
    Enumeration of the different types of theory terms.
 
TheoryTermType objects cannot be constructed from python. Instead the
following preconstructed objects are available:
 
TheoryTermType.Function -- a function theory term
TheoryTermType.Number   -- a numeric theory term
TheoryTermType.Symbol   -- a symbolic theory term
TheoryTermType.List     -- a list theory term
TheoryTermType.Tuple    -- a tuple theory term
TheoryTermType.Set      -- a set theory term
 
  Methods defined here:
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__le__(...)
x.__le__(y) <==> x<=y
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__str__(...)
x.__str__() <==> str(x)

Data and other attributes defined here:
Function = Function
List = List
Number = Number
Set = Set
Symbol = Symbol
Tuple = Tuple

 
class TruthValue(object)
    Enumeration of the different truth values.
 
TruthValue objects cannot be constructed from python. Instead the following
preconstructed objects are available:
 
TruthValue._True   -- truth value true
TruthValue._False  -- truth value false
TruthValue.Free    -- no truth value
TruthValue.Release -- indicates that an atom is to be released
 
  Methods defined here:
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__le__(...)
x.__le__(y) <==> x<=y
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__str__(...)
x.__str__() <==> str(x)

Data and other attributes defined here:
Free = Free
Release = Release

 
Functions
       
Function(...)
Function(name, arguments, positive) -> Symbol
 
Construct a function symbol.
 
Arguments:
name -- the name of the function (empty for tuples)
 
Keyword Arguments:
arguments -- the arguments in form of a list of symbols
positive  -- the sign of the function (tuples must not have signs)
             (Default: True)
 
This includes constants and tuples. Constants have an empty argument list and
tuples have an empty name. Functions can represent classically negated atoms.
Argument positive has to be set to False to represent such atoms.
Number(...)
Number(number) -> Symbol
 
Construct a numeric symbol given a number.
String(...)
String(string) -> Symbol
 
Construct a string symbol given a string.
Tuple(...)
Tuple(arguments) -> Symbol
 
Shortcut for Function("", arguments).
clingo_main(...)
clingo_main(application, files) -> int
 
Runs the given applications using clingo's default output and signal handling.
 
The application can overwrite clingo's default behaviour by registering
additional options and overriding its default main function.
 
Arguments:
application -- the Application object
 
Keyword Arguments:
files -- files passed on the command line
 
The application object must implement a main function and additionally can
override the other functions.
 
class Application(object):
    main(self, control, files) -> None
        Function to replace clingo's default main function.
 
    register_options(self, options) -> None
        Function to register custom options.
 
        Arguments:
        options -- ApplicationOptions object that can be used to register
                   different kind of options
 
    validate_options(self) -> bool
        Function to validate custom options.
 
        This function should return a boolean to indicate that option
        validation failed.
 
        Note: this function should not raise execptions
 
    logger(self, code, message) -> None
        Function to intercept messages normally printed to standard error.
        (Default: messages are printed to stdandard error)
 
        Arguments:
        code    -- MessageCode object
        message -- message string
 
        Note: this function should not raise execptions
 
    program_name -> String:
        Optional program name to be used in the help output.
        (Default: clingo)
 
    message_limit -> Int:
        Maximum number of messages passed to the logger.
        (Default: 20)
 
Example reproducing the default clingo behaviour:
 
    import sys
    import clingo
 
    class Application:
        def __init__(self, name):
            self.program_name = name
 
        def main(self, ctl, files):
            if len(files) > 0:
                for f in files:
                    ctl.load(f)
            else:
                ctl.load("-")
            ctl.ground([("base", [])])
            ctl.solve()
 
    clingo.clingo_main(Application(sys.argv[0]), sys.argv[1:])
parse_program(...)
parse_program(program, callback) -> None
 
Parse the given program and return an abstract syntax tree for each statement
via a callback.
 
Arguments:
program  -- string representation of program
callback -- callback taking an ast as argument
parse_term(...)
parse_term(string, logger, message_limit) -> Symbol
 
Parse the given string using gringo's term parser for ground terms. The
function also evaluates arithmetic functions.
 
Arguments:
string -- the string to be parsed
 
Keyword Arguments:
logger        -- function to intercept messages normally printed to standard
                 error (default: None)
message_limit -- maximum number of messages passed to the logger (default: 20)
 
Example:
 
clingo.parse_term('p(1+2)') == clingo.Function("p", [3])

 
Data
        Infimum = #inf
Supremum = #sup
__version__ = '5.3.0'