clingo.base
Functions and classes to work with atom and term bases.
Examples
>>> from clingo.core import Library
>>> from clingo.symbol import Function, Number
>>> from clingo.control import Control
>>> lib = Library()
>>> ctl = Control(lib)
>>> ctl.parse_string("""\
... p(1).
... { p(3) }.
... #external p(1..3).
...
... q(X) :- p(X).
... """)
>>> ctl.ground()
>>> bse = ctl.base
>>> len(bse)
2
>>> p = bse[("p", 1)]
>>> Function(lib, "p", [Number(lib, 2)]) in p
True
>>> Function(lib, "p", [Number(lib, 4)]) in p
False
>>> [sig for sig in bse]
[('p', 1, False), ('q', 1, False)]
>>> [(str(x.symbol), bse.is_fact(x.literal), bse.is_external(x.literal))
... for x in p.values()]
[('p(1)', True, False), ('p(3)', False, False), ('p(2)', False, True)]
A class providing information about symbolic atoms.
An class providing information about symbolic atoms.
Implements Mapping[Symbol, Atom]
.
A class providing information about symbolic and theory atoms and shown terms.
Implements Mapping[tuple[str, int, bool], AtomBase]
providing additional
overloads to directly lookup symbols and short signatures (assuming a positive
sign):
__getitem__: Callable[[Symbol], Atom]
__contains__: Callable[[Symbol], bool]
__getitem__: Callable[[tuple[str, int]], AtomBase]
__contains__: Callable[[tuple[str, int]], bool]
Check whether a literal has been introduced in the current step.
Note that all literals introduced before the last solve call are considered from a previous step.
Arguments:
- literal: The literal to check.
Returns:
Whether the literal is subject to projection.
Check whether the given program literal corresponds to an external.
Arguments:
- literal: The literal to check.
Returns:
Whether the literal is external.
Check whether the literal is a fact.
Arguments:
- literal: The literal to check.
Returns:
Whether the literal is a fact.
Check whether the literal is part of a #project
directive.
Arguments:
- literal: The literal to check.
Returns:
Whether the literal is subject to projection.
Check whether the literal is shown via a #show
directive.
Arguments:
- literal: The literal to check.
Returns:
Whether the literal is shown.
A class providing information about terms.
A class providing information about shown terms.
The base is established by the show directives occurring in a program.
Implements Mapping[Symbol, Term]
.
A view to inspect a theory atom.
A class prooviding information about theory atoms.
Implements Sequence[TheoryAtom]
.
A view to inspect a theory element.
A view to inspect a theory term.
Enumeration of theory term types.