transformation¶
Module containing utilities for transformations.
aggregate_constraint(aggregate: AST, body: Sequence[AST]) -> AST
¶
Turn a body B and aggregate A into the constraint :- B, not A.
apply_transformer(transformer: Transformer, prog: list[AST]) -> list[AST]
¶
Apply a transformer to a logic program.
atom_to_predicate(atom: AST) -> Predicate
¶
Get the predicate of an atom.
choice_rule_for_elements(elements: Sequence[AST], body: Sequence[AST]) -> AST
¶
Get a choice rule for the conditions of elements.
head_atom(node: AST) -> AST | None
¶
Get the symbolic atom of a (normalized) rule head.
Returns:
| Type | Description |
|---|---|
AST | None
|
AST | None: the head atom for basic or choice rules heads, None for constraints |
Raises:
| Type | Description |
|---|---|
ValueError
|
for malformed heads (e.g., choice with more than one element) |
is_mapped_predicate(atom: AST, suffix: str) -> bool
¶
Check whether an atom contains an auxiliary predicate.
map_atom(atom: AST, suffix: str) -> AST
¶
Map an atom to its auxiliary version.
replace_predicate(atom: AST, new_pred: Predicate) -> AST
¶
Replace the predicate of a symbolic atom.
unmap_atom(atom: AST, suffix: str) -> AST
¶
Undo the mapping of a predicate to its auxiliary version.