Skip to content

analysis

The analysis subpackage inspects the input programs before the CX program is built: it collects private predicates, renames clashing predicates, analyses the dependency graph, and determines input/output structure. This page documents the shared utilities defined in the package itself; individual analyses are on their own pages.

Shared analysis utilities.

PredicateReplacer

Bases: Transformer

Class to replace predicates according to a replacement dictionary.

__init__(replacements: dict[Predicate, Predicate]) -> None

Store the predicate replacement mapping.

visit_SymbolicAtom(node: AST) -> AST

Replace the predicate of a symbolic atom if it is part of the replacements.

PrivatePredicateCollector

Bases: Transformer

Class to collect the private predicates of a program.

__init__(publics: set[Predicate]) -> None

Store the public predicates and prepare the private set.

visit_SymbolicAtom(node: AST) -> AST

Add the predicate of a symbolic atom to the privates if it is not public.

collect_privates(program: list[AST], publics: set[Predicate]) -> set[Predicate]

Collect the private predicates of a program (those not in publics).

get_replacement_predicate(base: Predicate, predicates: set[Predicate]) -> Predicate

Get a replacement predicate for base that does not conflict with predicates.

get_replacements(conflicts: set[Predicate], predicates: set[Predicate]) -> dict[Predicate, Predicate]

Get fresh replacement predicates for all conflicts, avoiding predicates.

replace_predicates(program: list[AST], replacements: dict[Predicate, Predicate]) -> list[AST]

Replace all predicates that are part of the replacement dictionary.