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.
"""
Enumeration of aggregate functions.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The arguments of the tuple.
Available binary operators.
An aggregate in a rule body.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The condition of the element.
The term tuple of the element.
A conditional_literal.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The condition of the element.
A set aggregate.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
A literal in a rule body.
Construct a BodySimpleLiteral object.
Arguments:
- lib: The library object for storing symbols.
- literal: The literal.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The name of the theory atom.
Enumeration of comment types.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The start vertex.
The end vertex.
An aggregate in a rule head.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The condition of the element.
The term tuple of the element.
A conditional_literal.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The condition of the element.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The elements of the disjunction.
A set aggregate.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
A literal in a rule head.
Construct a HeadSimpleLiteral object.
Arguments:
- lib: The library object for storing symbols.
- literal: The literal.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The name of the theory atom.
Enumeration of include types.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The term of the guard.
A literal representing a Boolean constant.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The first term of the comparison.
The chain of comparisons. Note that the chain must have at least length one.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The term representing the atom.
An element of an optimization statement.
Construct a OptimizeElement object.
Arguments:
- lib: The library object for storing symbols.
- tuple: The tuple of the element.
- condition: The condition of the element.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The condition of the element.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
An optional priority.
The remaining terms in the tuple.
The weight of the tuple.
Enumeration of optimization types.
Enumeration of precedences values.
A non-ground program.
Create an empty non-ground program.
Arguments:
- lib: A library object to store symbols.
Add a statement to a program.
Arguments:
- statement: The statement to add.
A program part to ground.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
A placeholder for an argument to project.
Construct a Projection object.
Arguments:
- lib: The library object for storing symbols.
- location: The location of the placeholder.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Available projection modes.
Available relation symbols.
Context to rewrite statements.
Create a context to rewrite statements.
Arguments:
- lib: A library object to store symbols.
Add a parameter.
Parameters are protected from simplification.
Arguments:
- name: The name of the parameter.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The term of the guard.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The condition of the element.
The available signs.
A comment.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The term of the statement.
A defined statement.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The body of the statement.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The atom to project.
The body of the statement.
The type of the external.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The atom to heuristically modify.
The body of the statement.
The heuristic modifier.
An optional priority.
The weight of the heuristic modification.
An include statement.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
An optimization statement.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
A program parts statement.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
A program statement.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The atom to project.
The body of the statement.
A project signature statement.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The body of the statement.
A script statement.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The body of the statement.
The term to show.
An empty show statement.
Construct a StatementShowNothing object.
Arguments:
- lib: The library object for storing symbols.
- location: The location of the statement.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
A show signature statement.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
A theory definition.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The body of the statement.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The argument pool. If there is more than one argument in the pool, the term is unpooled during preprocessing.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The left argument of the operation.
The right argument of the operation.
A term representing a function.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The argument pool of the function. If there is more than one element in the pool, the term is unpooled during preprocessing.
A term representing a symbol.
Construct a TermSymbolic object.
Arguments:
- lib: The library object for storing symbols.
- location: The location of the symbol.
- symbol: The symbol.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The argument pool of the tuple. If there is more than one element in the pool, the term is unpooled during preprocessing.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The argument of the operation.
A term representing a variable.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
A theory atom definition.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The condition of the element.
The theory term tuple of the element.
Enumeration of the theory atom types.
A definition of a theory guard.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
A theory operator definition.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Enumeration of theory operators.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The theory term of the guard.
A theory term definition.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
A theory term representing a function.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The arguments of the function.
A theory term representing a symbol.
Construct a TheoryTermSymbolic object.
Arguments:
- lib: The library object for storing symbols.
- location: The location of the symbol.
- symbol: The symbol.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The arguments of the tuple.
A theory term representing an unparsed theory term.
Construct a TheoryTermUnparsed object.
Arguments:
- lib: The library object for storing symbols.
- location: The location of the theory term.
- elements: The unparsed theory elements.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
A theory term representing a variable.
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.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
Enumeration of theory tuple types.
Available unary operators.
A list of unparsed theory terms and operators.
Construct a UnparsedElement object.
Arguments:
- lib: The library object for storing symbols.
- operators: The list of theory operators.
- term: The theory term.
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.
Update the expression.
Accepts keyword arguments with attributes to update.
Arguments:
- lib: The library object for storing symbols.
Returns:
The updated object.
Visit the children of the expression.
Arguments:
- visitor: The visitor accepting the sub expressions.
The theory term.
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.
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.