clingo.ast

This module provides functions to work with Abstract Syntax Trees of logic programs.

Examples

The following example shows how to parse individual statements and add them to a control object.

>>> from clingo.core import Library
>>> from clingo.control import Control
>>> from clingo import ast
>>>
>>> lib = Library()
>>> ctl = Control(lib, ["--mode=ground"])
>>> ctl.parse_string("a(1).")
>>> prg = ast.Program(lib)
>>> prg.add(ast.parse_statement(lib, "b(X+1) :- a(X)."))
>>> prg.add(ast.parse_statement(lib, "c(X+1) :- b(X)."))
>>> ctl.join(prg)
>>> ctl.ground()
>>> ctl.buffer
"""
a(1).
b(2).
c(3).
#show.
#show a/1.
#show b/1.
#show c/1.
"""
class AggregateFunction:

Enumeration of aggregate functions.

AggregateFunction(value: int)

Aggregate function #count.

Aggregate function #max.

Aggregate function #min.

Aggregate function #sum.

Aggregate function #sum+

name: str
value: int
class ArgumentTuple:

A list of arguments for a function or tuple.

Construct a ArgumentTuple object.

Arguments:
  • lib: The library object for storing symbols.
  • arguments: The arguments of the tuple.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> ArgumentTuple | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> ArgumentTuple:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The arguments of the tuple.

class BinaryOperator:

Available binary operators.

BinaryOperator(value: int)

Operator &.

Division: ClassVar[BinaryOperator] = BinaryOperator.Division

Operator /.

Operator -.

Operator %.

Multiplication: ClassVar[BinaryOperator] = BinaryOperator.Multiplication

Operator *.

Operator |.

Operator +.

Operator **.

Operator ^.

name: str
value: int
class BodyAggregate:

An aggregate in a rule body.

BodyAggregate( lib: clingo.core.Library, location: clingo.core.Location, sign: Sign, left: LeftGuard | None, function: AggregateFunction, elements: Iterable[BodyAggregateElement], right: RightGuard | None)

Construct a BodyAggregate object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the element.
  • sign: The sign of the literal.
  • left: The left guard of the aggregate.
  • function: The aggregate function.
  • elements: The aggregate elements.
  • right: The right guard of the aggregate.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> BodyAggregate | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> BodyAggregate:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
elements: Sequence[BodyAggregateElement]

The aggregate elements.

function: AggregateFunction

The aggregate function.

left: LeftGuard | None

The left guard of the aggregate.

The location of the element.

right: RightGuard | None

The right guard of the aggregate.

sign: Sign

The sign of the literal.

class BodyAggregateElement:

An element of a body aggregate.

Construct a BodyAggregateElement object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the element.
  • tuple: The term tuple of the element.
  • condition: The condition of the element.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> BodyAggregateElement | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> BodyAggregateElement:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The condition of the element.

The location of the element.

The term tuple of the element.

class BodyConditionalLiteral:

A conditional_literal.

BodyConditionalLiteral( lib: clingo.core.Library, location: clingo.core.Location, literal: LiteralBoolean | LiteralComparison | LiteralSymbolic, condition: Iterable[LiteralBoolean | LiteralComparison | LiteralSymbolic])

Construct a BodyConditionalLiteral object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the element.
  • literal: The literal of the element.
  • condition: The condition of the element.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> BodyConditionalLiteral | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> BodyConditionalLiteral:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The condition of the element.

The literal of the element.

The location of the element.

class BodySetAggregate:

A set aggregate.

BodySetAggregate( lib: clingo.core.Library, location: clingo.core.Location, sign: Sign, left: LeftGuard | None, elements: Iterable[SetAggregateElement], right: RightGuard | None)

Construct a BodySetAggregate object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the element.
  • sign: The sign of the literal.
  • left: The left guard of the aggregate.
  • elements: The aggregate elements.
  • right: The right guard of the aggregate.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> BodySetAggregate | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> BodySetAggregate:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
elements: Sequence[SetAggregateElement]

The aggregate elements.

left: LeftGuard | None

The left guard of the aggregate.

The location of the element.

right: RightGuard | None

The right guard of the aggregate.

sign: Sign

The sign of the literal.

class BodySimpleLiteral:

A literal in a rule body.

BodySimpleLiteral( lib: clingo.core.Library, literal: LiteralBoolean | LiteralComparison | LiteralSymbolic)

Construct a BodySimpleLiteral object.

Arguments:
  • lib: The library object for storing symbols.
  • literal: The literal.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> BodySimpleLiteral | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> BodySimpleLiteral:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
class BodyTheoryAtom:

A theory atom.

Construct a BodyTheoryAtom object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the element.
  • sign: The sign of the literal.
  • name: The name of the theory atom.
  • elements: The aggregate elements.
  • right: The right guard of the theory atom.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> BodyTheoryAtom | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> BodyTheoryAtom:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
elements: Sequence[TheoryAtomElement]

The aggregate elements.

The location of the element.

right: TheoryRightGuard | None

The right guard of the theory atom.

sign: Sign

The sign of the literal.

class CommentType:

Enumeration of comment types.

CommentType(value: int)
Block: ClassVar[CommentType] = CommentType.Block

For block comments.

Line: ClassVar[CommentType] = CommentType.Line

For line comments.

name: str
value: int
class Edge:

An edge of an edge statement.

Construct a Edge object.

Arguments:
  • lib: The library object for storing symbols.
  • u: The start vertex.
  • v: The end vertex.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> Edge | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> Edge:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
class HeadAggregate:

An aggregate in a rule head.

HeadAggregate( lib: clingo.core.Library, location: clingo.core.Location, left: LeftGuard | None, function: AggregateFunction, elements: Iterable[HeadAggregateElement], right: RightGuard | None)

Construct a HeadAggregate object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the element.
  • left: The left guard of the aggregate.
  • function: The aggregate function.
  • elements: The aggregate elements.
  • right: The right guard of the aggregate.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> HeadAggregate | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> HeadAggregate:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
elements: Sequence[HeadAggregateElement]

The aggregate elements.

function: AggregateFunction

The aggregate function.

left: LeftGuard | None

The left guard of the aggregate.

The location of the element.

right: RightGuard | None

The right guard of the aggregate.

class HeadAggregateElement:

An element of a head aggregate.

Construct a HeadAggregateElement object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the element.
  • tuple: The term tuple of the element.
  • literal: The literal of the element.
  • condition: The condition of the element.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> HeadAggregateElement | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> HeadAggregateElement:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The condition of the element.

The literal of the element.

The location of the element.

The term tuple of the element.

class HeadConditionalLiteral:

A conditional_literal.

HeadConditionalLiteral( lib: clingo.core.Library, location: clingo.core.Location, literal: LiteralBoolean | LiteralComparison | LiteralSymbolic, condition: Iterable[LiteralBoolean | LiteralComparison | LiteralSymbolic])

Construct a HeadConditionalLiteral object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the element.
  • literal: The literal of the element.
  • condition: The condition of the element.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> HeadConditionalLiteral | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> HeadConditionalLiteral:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The condition of the element.

The literal of the element.

The location of the element.

class HeadDisjunction:

A disjunction.

Construct a HeadDisjunction object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the element.
  • elements: The elements of the disjunction.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> HeadDisjunction | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> HeadDisjunction:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The elements of the disjunction.

The location of the element.

class HeadSetAggregate:

A set aggregate.

HeadSetAggregate( lib: clingo.core.Library, location: clingo.core.Location, left: LeftGuard | None, elements: Iterable[SetAggregateElement], right: RightGuard | None)

Construct a HeadSetAggregate object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the element.
  • left: The left guard of the aggregate.
  • elements: The aggregate elements.
  • right: The right guard of the aggregate.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> HeadSetAggregate | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> HeadSetAggregate:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
elements: Sequence[SetAggregateElement]

The aggregate elements.

left: LeftGuard | None

The left guard of the aggregate.

The location of the element.

right: RightGuard | None

The right guard of the aggregate.

class HeadSimpleLiteral:

A literal in a rule head.

HeadSimpleLiteral( lib: clingo.core.Library, literal: LiteralBoolean | LiteralComparison | LiteralSymbolic)

Construct a HeadSimpleLiteral object.

Arguments:
  • lib: The library object for storing symbols.
  • literal: The literal.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> HeadSimpleLiteral | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> HeadSimpleLiteral:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
class HeadTheoryAtom:

A theory atom.

Construct a HeadTheoryAtom object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the element.
  • name: The name of the theory atom.
  • elements: The aggregate elements.
  • right: The right guard of the theory atom.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> HeadTheoryAtom | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> HeadTheoryAtom:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
elements: Sequence[TheoryAtomElement]

The aggregate elements.

The location of the element.

right: TheoryRightGuard | None

The right guard of the theory atom.

class IncludeType:

Enumeration of include types.

IncludeType(value: int)
Inbuild: ClassVar[IncludeType] = IncludeType.Inbuild

For inbuild includes.

System: ClassVar[IncludeType] = IncludeType.System

For file includes.

name: str
value: int
class LeftGuard:

A right hand side guard consisting of a term and a relation.

Construct a LeftGuard object.

Arguments:
  • lib: The library object for storing symbols.
  • term: The term of the guard.
  • relation: The relation of the guard.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> LeftGuard | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> LeftGuard:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
relation: Relation

The relation of the guard.

class LiteralBoolean:

A literal representing a Boolean constant.

LiteralBoolean( lib: clingo.core.Library, location: clingo.core.Location, sign: Sign, value: bool)

Construct a LiteralBoolean object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the symbol.
  • sign: The sign of the literal.
  • value: The fixed value of the literal.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> LiteralBoolean | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> LiteralBoolean:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The location of the symbol.

sign: Sign

The sign of the literal.

value: bool

The fixed value of the literal.

class LiteralComparison:

A literal representing a (chain of) comparison(s).

Construct a LiteralComparison object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the symbol.
  • sign: The sign of the literal.
  • left: The first term of the comparison.
  • right: The chain of comparisons.
  • Note that the chain must have at least length one.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> LiteralComparison | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> LiteralComparison:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The location of the symbol.

right: Sequence[RightGuard]

The chain of comparisons. Note that the chain must have at least length one.

sign: Sign

The sign of the literal.

class LiteralSymbolic:

A literal representing a symbolic literal.

Construct a LiteralSymbolic object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the symbol.
  • sign: The sign of the literal.
  • atom: The term representing the atom.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> LiteralSymbolic | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> LiteralSymbolic:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The location of the symbol.

sign: Sign

The sign of the literal.

class OptimizeElement:

An element of an optimization statement.

OptimizeElement( lib: clingo.core.Library, tuple: OptimizeTuple, condition: Iterable[LiteralBoolean | LiteralComparison | LiteralSymbolic])

Construct a OptimizeElement object.

Arguments:
  • lib: The library object for storing symbols.
  • tuple: The tuple of the element.
  • condition: The condition of the element.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> OptimizeElement | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> OptimizeElement:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The condition of the element.

tuple: OptimizeTuple

The tuple of the element.

class OptimizeTuple:

A tuple of an optimizization statement.

Construct a OptimizeTuple object.

Arguments:
  • lib: The library object for storing symbols.
  • weight: The weight of the tuple.
  • priority: An optional priority.
  • terms: The remaining terms in the tuple.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> OptimizeTuple | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> OptimizeTuple:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The remaining terms in the tuple.

class OptimizeType:

Enumeration of optimization types.

OptimizeType(value: int)
Maximize: ClassVar[OptimizeType] = OptimizeType.Maximize

For #maximize statements.

Minimize: ClassVar[OptimizeType] = OptimizeType.Minimize

For #minimize statements.

name: str
value: int
class Precedence:

Enumeration of precedences values.

Precedence(value: int)
Default: ClassVar[Precedence] = Precedence.Default

The default precedence.

Override: ClassVar[Precedence] = Precedence.Override

Override values with default precedence.

name: str
value: int
class Program:

A non-ground program.

Program(lib: clingo.core.Library)

Create an empty non-ground program.

Arguments:
  • lib: A library object to store symbols.
class ProgramPart:

A program part to ground.

ProgramPart( lib: clingo.core.Library, name: str, arguments: Iterable[clingo.symbol.Symbol])

Construct a ProgramPart object.

Arguments:
  • lib: The library object for storing symbols.
  • name: The name of the program part.
  • arguments: The arguments of the program part.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> ProgramPart | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> ProgramPart:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
arguments: Sequence[clingo.symbol.Symbol]

The arguments of the program part.

name: str

The name of the program part.

class Projection:

A placeholder for an argument to project.

Projection(lib: clingo.core.Library, location: clingo.core.Location)

Construct a Projection object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the placeholder.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> Projection | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> Projection:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The location of the placeholder.

class ProjectionMode:

Available projection modes.

ProjectionMode(value: int)
Anonymous: ClassVar[ProjectionMode] = ProjectionMode.Anonymous

Only project anonymous variables.

Disabled: ClassVar[ProjectionMode] = ProjectionMode.Disabled

Do not project.

Project pure variables.

name: str
value: int
class Relation:

Available relation symbols.

Relation(value: int)
Equal: ClassVar[Relation] = Relation.Equal

The equal to relation.

Greater: ClassVar[Relation] = Relation.Greater

The greater than relation.

GreaterEqual: ClassVar[Relation] = Relation.GreaterEqual

The equal to relation.

Less: ClassVar[Relation] = Relation.Less

The less than relation.

LessEqual: ClassVar[Relation] = Relation.LessEqual

The equal to relation.

NotEqual: ClassVar[Relation] = Relation.NotEqual

The equal to relation.

name: str
value: int
class RewriteContext:

Context to rewrite statements.

RewriteContext(lib: clingo.core.Library)

Create a context to rewrite statements.

Arguments:
  • lib: A library object to store symbols.
def add_param(self, name: str) -> None:

Add a parameter.

Parameters are protected from simplification.

Arguments:
  • name: The name of the parameter.
def add_theory(self, theory: StatementTheory) -> None:

Add a theory definition statement.

The theory definition is used to rewrite theory atoms in statements.

Arguments:
  • theory: The theory statement to add.
def clear_params(self) -> None:

Remove previously added params

project_anonymous: bool

Whether to project anonymous variables in negative literals.

project_mode: ProjectionMode

The active projection mode.

class RightGuard:

A right hand side guard consisting of a relation and term.

Construct a RightGuard object.

Arguments:
  • lib: The library object for storing symbols.
  • relation: The relation of the guard.
  • term: The term of the guard.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> RightGuard | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> RightGuard:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
relation: Relation

The relation of the guard.

class SetAggregateElement:

An element of a set aggregate.

Construct a SetAggregateElement object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the element.
  • literal: The literal of the element.
  • condition: The condition of the element.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> SetAggregateElement | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> SetAggregateElement:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The condition of the element.

The literal of the element.

The location of the element.

class Sign:

The available signs.

Sign(value: int)
Double: ClassVar[Sign] = Sign.Double

Two signs.

NoSign: ClassVar[Sign] = Sign.NoSign

No sign.

Single: ClassVar[Sign] = Sign.Single

One sign.

name: str
value: int
class StatementComment:

A comment.

StatementComment( lib: clingo.core.Library, location: clingo.core.Location, value: str, comment_type: CommentType)

Construct a StatementComment object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the comment.
  • value: The value of the comment.
  • comment_type: The type of the comment.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementComment | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> StatementComment:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
comment_type: CommentType

The type of the comment.

The location of the comment.

value: str

The value of the comment.

class StatementConst:

A const statement.

Construct a StatementConst object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
  • name: The name of the statement.
  • value: The term of the statement.
  • precedence: The precedence of the statement.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementConst | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> StatementConst:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The location of the statement.

name: str

The name of the statement.

precedence: Precedence

The precedence of the statement.

class StatementDefined:

A defined statement.

StatementDefined( lib: clingo.core.Library, location: clingo.core.Location, name: str, arity: int, sign: bool = False)

Construct a StatementDefined object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
  • name: The name of the atom to project.
  • arity: The arity of the atom to project.
  • sign: The classical sign of the atom.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementDefined | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> StatementDefined:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
arity: int

The arity of the atom to project.

The location of the statement.

name: str

The name of the atom to project.

sign: bool

The classical sign of the atom.

class StatementEdge:

An edge statement.

Construct a StatementEdge object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
  • pool: The edge pool of the statement.
  • body: The body of the statement.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementEdge | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> StatementEdge:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The body of the statement.

The location of the statement.

pool: Sequence[Edge]

The edge pool of the statement.

class StatementExternal:

An external statement.

Construct a StatementExternal object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
  • atom: The atom to project.
  • body: The body of the statement.
  • external_type: The type of the external.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementExternal | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> StatementExternal:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The body of the statement.

The type of the external.

The location of the statement.

class StatementHeuristic:

A heuristic statement.

Construct a StatementHeuristic object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
  • atom: The atom to heuristically modify.
  • body: The body of the statement.
  • weight: The weight of the heuristic modification.
  • modifier: The heuristic modifier.
  • priority: An optional priority.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementHeuristic | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> StatementHeuristic:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The body of the statement.

The location of the statement.

The weight of the heuristic modification.

class StatementInclude:

An include statement.

StatementInclude( lib: clingo.core.Library, location: clingo.core.Location, value: str, include_type: IncludeType)

Construct a StatementInclude object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
  • value: The path of the statement.
  • include_type: The type of the include.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementInclude | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> StatementInclude:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
include_type: IncludeType

The type of the include.

The location of the statement.

value: str

The path of the statement.

class StatementOptimize:

An optimization statement.

StatementOptimize( lib: clingo.core.Library, location: clingo.core.Location, elements: Iterable[OptimizeElement], optimize_type: OptimizeType)

Construct a StatementOptimize object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
  • elements: The elements of the statement.
  • optimize_type: The type of the statement.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementOptimize | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> StatementOptimize:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
elements: Sequence[OptimizeElement]

The elements of the statement.

The location of the statement.

optimize_type: OptimizeType

The type of the statement.

class StatementParts:

A program parts statement.

StatementParts( lib: clingo.core.Library, location: clingo.core.Location, elements: Iterable[ProgramPart], precedence: Precedence)

Construct a StatementParts object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
  • elements: The program parts to ground.
  • precedence: The precedence of the statement.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementParts | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> StatementParts:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
elements: Sequence[ProgramPart]

The program parts to ground.

The location of the statement.

precedence: Precedence

The precedence of the statement.

class StatementProgram:

A program statement.

StatementProgram( lib: clingo.core.Library, location: clingo.core.Location, name: str, arguments: Iterable[str])

Construct a StatementProgram object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
  • name: The name of the program.
  • arguments: The arguments of the program.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementProgram | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> StatementProgram:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
arguments: Sequence[str]

The arguments of the program.

The location of the statement.

name: str

The name of the program.

class StatementProject:

A project statement.

Construct a StatementProject object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
  • atom: The atom to project.
  • body: The body of the statement.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementProject | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> StatementProject:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The body of the statement.

The location of the statement.

class StatementProjectSignature:

A project signature statement.

StatementProjectSignature( lib: clingo.core.Library, location: clingo.core.Location, name: str, arity: int, sign: bool = False)

Construct a StatementProjectSignature object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
  • name: The name of the atom to project.
  • arity: The arity of the atom to project.
  • sign: The classical sign of the atom.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementProjectSignature | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> StatementProjectSignature:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
arity: int

The arity of the atom to project.

The location of the statement.

name: str

The name of the atom to project.

sign: bool

The classical sign of the atom.

class StatementRule:

A rule.

Construct a StatementRule object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
  • head: The head literal.
  • body: The body of the statement.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementRule | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> StatementRule:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The body of the statement.

The location of the statement.

class StatementScript:

A script statement.

StatementScript( lib: clingo.core.Library, location: clingo.core.Location, value: str, script_type: str)

Construct a StatementScript object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
  • value: The content of the script.
  • script_type: The type of the script.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementScript | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> StatementScript:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The location of the statement.

script_type: str

The type of the script.

value: str

The content of the script.

class StatementShow:

A show statement.

Construct a StatementShow object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
  • term: The term to show.
  • body: The body of the statement.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementShow | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> StatementShow:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The body of the statement.

The location of the statement.

class StatementShowNothing:

An empty show statement.

StatementShowNothing(lib: clingo.core.Library, location: clingo.core.Location)

Construct a StatementShowNothing object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementShowNothing | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> StatementShowNothing:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The location of the statement.

class StatementShowSignature:

A show signature statement.

StatementShowSignature( lib: clingo.core.Library, location: clingo.core.Location, name: str, arity: int, sign: bool = False)

Construct a StatementShowSignature object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
  • name: The name of the atom to show.
  • arity: The arity of the atom to show.
  • sign: The classical sign of the atom.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementShowSignature | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> StatementShowSignature:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
arity: int

The arity of the atom to show.

The location of the statement.

name: str

The name of the atom to show.

sign: bool

The classical sign of the atom.

class StatementTheory:

A theory definition.

StatementTheory( lib: clingo.core.Library, location: clingo.core.Location, name: str, terms: Iterable[TheoryTermDefinition], atoms: Iterable[TheoryAtomDefinition])

Construct a StatementTheory object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
  • name: The name of the theory.
  • terms: A list of term definitions.
  • atoms: A list of atom definitions.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementTheory | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> StatementTheory:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
atoms: Sequence[TheoryAtomDefinition]

A list of atom definitions.

The location of the statement.

name: str

The name of the theory.

terms: Sequence[TheoryTermDefinition]

A list of term definitions.

class StatementWeakConstraint:

A weak constraint.

Construct a StatementWeakConstraint object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the statement.
  • body: The body of the statement.
  • tuple: The tuple of the statement.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> StatementWeakConstraint | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> StatementWeakConstraint:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The body of the statement.

The location of the statement.

tuple: OptimizeTuple

The tuple of the statement.

class TermAbsolute:

A term representing the absolute operation.

Construct a TermAbsolute object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the operation.
  • pool: The argument pool.
  • If there is more than one argument in the pool, the term is
  • unpooled during preprocessing.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TermAbsolute | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> TermAbsolute:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The location of the operation.

The argument pool. If there is more than one argument in the pool, the term is unpooled during preprocessing.

class TermBinaryOperation:

A term representing a binary operation.

Construct a TermBinaryOperation object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the operation.
  • left: The left argument of the operation.
  • operator_type: The type of the operation.
  • right: The right argument of the operation.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TermBinaryOperation | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> TermBinaryOperation:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The location of the operation.

operator_type: BinaryOperator

The type of the operation.

The right argument of the operation.

class TermFunction:

A term representing a function.

TermFunction( lib: clingo.core.Library, location: clingo.core.Location, name: str, pool: Iterable[ArgumentTuple], external: bool = False)

Construct a TermFunction object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the function.
  • name: The name of the function.
  • pool: The argument pool of the function.
  • If there is more than one element in the pool, the term is
  • unpooled during preprocessing.
  • external: Whether the function is external.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TermFunction | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> TermFunction:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
external: bool

Whether the function is external.

The location of the function.

name: str

The name of the function.

pool: Sequence[ArgumentTuple]

The argument pool of the function. If there is more than one element in the pool, the term is unpooled during preprocessing.

class TermSymbolic:

A term representing a symbol.

TermSymbolic( lib: clingo.core.Library, location: clingo.core.Location, symbol: clingo.symbol.Symbol)

Construct a TermSymbolic object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the symbol.
  • symbol: The symbol.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TermSymbolic | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> TermSymbolic:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The location of the symbol.

The symbol.

class TermTuple:

A term representing a tuple.

Construct a TermTuple object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the tuple.
  • pool: The argument pool of the tuple.
  • If there is more than one element in the pool, the term is
  • unpooled during preprocessing.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TermTuple | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> TermTuple:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The location of the tuple.

The argument pool of the tuple. If there is more than one element in the pool, the term is unpooled during preprocessing.

class TermUnaryOperation:

A term representing a unary operation.

Construct a TermUnaryOperation object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the operation.
  • operator_type: The type of the operation.
  • right: The argument of the operation.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TermUnaryOperation | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> TermUnaryOperation:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The location of the operation.

operator_type: UnaryOperator

The type of the operation.

class TermVariable:

A term representing a variable.

TermVariable( lib: clingo.core.Library, location: clingo.core.Location, name: str, anonymous: bool = False)

Construct a TermVariable object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the variable.
  • name: The name of the variable.
  • anonymous: Whether the variable is anonymous.
  • Anonymous variables receive a unique name during preprocessing.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TermVariable | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> TermVariable:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
anonymous: bool

Whether the variable is anonymous. Anonymous variables receive a unique name during preprocessing.

The location of the variable.

name: str

The name of the variable.

class TheoryAtomDefinition:

A theory atom definition.

TheoryAtomDefinition( lib: clingo.core.Library, location: clingo.core.Location, name: str, arity: int, term: str, guard: TheoryGuardDefinition | None, atom_type: TheoryAtomType)

Construct a TheoryAtomDefinition object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the definition.
  • name: The name of the atom.
  • arity: The arity of the atom.
  • term: The name of a term definition.
  • guard: An optional guard definition.
  • atom_type: The type of the atom definition.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TheoryAtomDefinition | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> TheoryAtomDefinition:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
arity: int

The arity of the atom.

atom_type: TheoryAtomType

The type of the atom definition.

guard: TheoryGuardDefinition | None

An optional guard definition.

The location of the definition.

name: str

The name of the atom.

term: str

The name of a term definition.

class TheoryAtomElement:

An element of a theory atom elements.

Construct a TheoryAtomElement object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the element.
  • tuple: The theory term tuple of the element.
  • condition: The condition of the element.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TheoryAtomElement | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> TheoryAtomElement:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The condition of the element.

The location of the element.

The theory term tuple of the element.

class TheoryAtomType:

Enumeration of the theory atom types.

TheoryAtomType(value: int)

For theory atoms that can appear in both head and body.

For theory atoms that can appear in the body.

Directive: ClassVar[TheoryAtomType] = TheoryAtomType.Directive

For theory atoms that must not have a body.

For theory atoms that can appear in the head.

name: str
value: int
class TheoryGuardDefinition:

A definition of a theory guard.

TheoryGuardDefinition(lib: clingo.core.Library, operators: Iterable[str], term: str)

Construct a TheoryGuardDefinition object.

Arguments:
  • lib: The library object for storing symbols.
  • operators: A list of operator definition names.
  • term: The name of a term definition.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TheoryGuardDefinition | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> TheoryGuardDefinition:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
operators: Sequence[str]

A list of operator definition names.

term: str

The name of a term definition.

class TheoryOperatorDefinition:

A theory operator definition.

TheoryOperatorDefinition( lib: clingo.core.Library, location: clingo.core.Location, name: str, priority: int, operator_type: TheoryOperatorType)

Construct a TheoryOperatorDefinition object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the definition.
  • name: The name of the definition.
  • priority: The priority of the operator.
  • operator_type: The type of the operator.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TheoryOperatorDefinition | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> TheoryOperatorDefinition:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The location of the definition.

name: str

The name of the definition.

operator_type: TheoryOperatorType

The type of the operator.

priority: int

The priority of the operator.

class TheoryOperatorType:

Enumeration of theory operators.

TheoryOperatorType(value: int)

A left associative binary operator.

A right associative binary operator.

An unary theory operator.

name: str
value: int
class TheoryRightGuard:

A right hand side guard consisting of a theory operator and theory term.

Construct a TheoryRightGuard object.

Arguments:
  • lib: The library object for storing symbols.
  • theory_operator: The operator of the guard.
  • term: The theory term of the guard.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TheoryRightGuard | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> TheoryRightGuard:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
theory_operator: str

The operator of the guard.

class TheoryTermDefinition:

A theory term definition.

TheoryTermDefinition( lib: clingo.core.Library, location: clingo.core.Location, name: str, operators: Iterable[TheoryOperatorDefinition])

Construct a TheoryTermDefinition object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the definition.
  • name: The name of the definition.
  • operators: The operator definitions to construct terms.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TheoryTermDefinition | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> TheoryTermDefinition:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The location of the definition.

name: str

The name of the definition.

operators: Sequence[TheoryOperatorDefinition]

The operator definitions to construct terms.

class TheoryTermFunction:

A theory term representing a function.

TheoryTermFunction( lib: clingo.core.Library, location: clingo.core.Location, name: str, arguments: Iterable[TheoryTermVariable | TheoryTermSymbolic | TheoryTermTuple | TheoryTermFunction | TheoryTermUnparsed])

Construct a TheoryTermFunction object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the function.
  • name: The name of the function.
  • arguments: The arguments of the function.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TheoryTermFunction | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> TheoryTermFunction:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The arguments of the function.

The location of the function.

name: str

The name of the function.

class TheoryTermSymbolic:

A theory term representing a symbol.

TheoryTermSymbolic( lib: clingo.core.Library, location: clingo.core.Location, symbol: clingo.symbol.Symbol)

Construct a TheoryTermSymbolic object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the symbol.
  • symbol: The symbol.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TheoryTermSymbolic | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> TheoryTermSymbolic:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The location of the symbol.

The symbol.

class TheoryTermTuple:

A theory term representing a tuple.

Construct a TheoryTermTuple object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the tuple.
  • tuple_type: The type of the tuple.
  • arguments: The arguments of the tuple.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TheoryTermTuple | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> TheoryTermTuple:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.

The arguments of the tuple.

The location of the tuple.

tuple_type: TheoryTupleType

The type of the tuple.

class TheoryTermUnparsed:

A theory term representing an unparsed theory term.

TheoryTermUnparsed( lib: clingo.core.Library, location: clingo.core.Location, elements: Iterable[UnparsedElement])

Construct a TheoryTermUnparsed object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the theory term.
  • elements: The unparsed theory elements.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TheoryTermUnparsed | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> TheoryTermUnparsed:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
elements: Sequence[UnparsedElement]

The unparsed theory elements.

The location of the theory term.

class TheoryTermVariable:

A theory term representing a variable.

TheoryTermVariable( lib: clingo.core.Library, location: clingo.core.Location, name: str, anonymous: bool = False)

Construct a TheoryTermVariable object.

Arguments:
  • lib: The library object for storing symbols.
  • location: The location of the variable.
  • name: The name of the variable.
  • anonymous: Whether the variable is anonymous.
  • Anonymous variables receive a unique name during preprocessing.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> TheoryTermVariable | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update( self, lib: clingo.core.Library, **kwargs) -> TheoryTermVariable:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
anonymous: bool

Whether the variable is anonymous. Anonymous variables receive a unique name during preprocessing.

The location of the variable.

name: str

The name of the variable.

class TheoryTupleType:

Enumeration of theory tuple types.

TheoryTupleType(value: int)

Theory lists "[t1,...,tn]".

Theory sets "{t1,...,tn}".

Theory tuples "(t1,...,tn)".

name: str
value: int
class UnaryOperator:

Available unary operators.

UnaryOperator(value: int)
Minus: ClassVar[UnaryOperator] = UnaryOperator.Minus

Operator -.

Negation: ClassVar[UnaryOperator] = UnaryOperator.Negation

Operator ~.

name: str
value: int
class UnparsedElement:

A list of unparsed theory terms and operators.

UnparsedElement( lib: clingo.core.Library, operators: Iterable[str], term: TheoryTermVariable | TheoryTermSymbolic | TheoryTermTuple | TheoryTermFunction | TheoryTermUnparsed)

Construct a UnparsedElement object.

Arguments:
  • lib: The library object for storing symbols.
  • operators: The list of theory operators.
  • term: The theory term.
def transform( self, lib: clingo.core.Library, transformer: Any, *args, **kwargs) -> UnparsedElement | None:

Transform the expression.

Additional arguments are passed to the transformer.

Arguments:
  • lib: The library object for storing symbols.
  • transformer: The transformer accepting the sub expressions.
Returns:

The transformed object or None.

def update(self, lib: clingo.core.Library, **kwargs) -> UnparsedElement:

Update the expression.

Accepts keyword arguments with attributes to update.

Arguments:
  • lib: The library object for storing symbols.
Returns:

The updated object.

def visit(self, visitor: Any, *args, **kwargs) -> None:

Visit the children of the expression.

Arguments:
  • visitor: The visitor accepting the sub expressions.
operators: Sequence[str]

The list of theory operators.

Parse a body literal.

Arguments:
  • lib: The library object for storing symbols.
  • string: The string to parse.
Returns:

The parsed BodyLiteral object.

Parse the program in the given files.

The parser follows clingo's handling of files on the command line. Filename "-" is treated as "STDIN" and if an empty list is given, then the parser will read from "STDIN".

Arguments:
  • lib: A library object to store symbols.
  • files: The files to parse.
  • callback: Function to report statements.
  • control: Optional Control object to handle ASPIF.

Parse a head literal.

Arguments:
  • lib: The library object for storing symbols.
  • string: The string to parse.
Returns:

The parsed HeadLiteral object.

def parse_literal( lib: clingo.core.Library, string: str) -> LiteralBoolean | LiteralComparison | LiteralSymbolic:

Parse a literal.

Arguments:
  • lib: The library object for storing symbols.
  • string: The string to parse.
Returns:

The parsed Literal object.

Parse a statement.

Arguments:
  • lib: The library object for storing symbols.
  • string: The string to parse.
Returns:

The parsed Statement object.

Parse the program in the given string.

Arguments:
  • lib: A library object to store symbols.
  • program: The program to parse.
  • callback: Function to report statements.
  • control: Optional Control object to handle ASPIF.

Parse a term.

Arguments:
  • lib: The library object for storing symbols.
  • string: The string to parse.
Returns:

The parsed Term object.

Parse a theory term.

Arguments:
  • lib: The library object for storing symbols.
  • string: The string to parse.
Returns:

The parsed TheoryTerm object.

Simplify the given statement.

Arguments:
  • ctx: The rewrite context.
  • statement: The statement to rewrite.
Returns:

A list of rewritten statements.