Skip to content

Preprocessors

Preprocessors for Clingo-Explaid.

__all__ = ['AssumptionPreprocessor', 'FilterPattern', 'FilterSignature'] module-attribute

AssumptionPreprocessor(filters: Iterable[FilterPattern | FilterSignature] | None = None, control: clingo.Control | None = None, fail_on_unprocessed: bool = True)

Preprocessor object that transforms program facts to choices for them tobe assumed.

Construct an AssumptionPreprocessor for the provided control, transforming facts matching the provided filters.

PARAMETER DESCRIPTION
filters

The set of filters matching facts to transform.

TYPE: Iterable[FilterPattern | FilterSignature] | None DEFAULT: None

control

The clingo Control object to use.

TYPE: Control | None DEFAULT: None

fail_on_unprocessed

Whether to fail if assumptions are accessed before a program is processed.

TYPE: bool DEFAULT: True

assumptions: set[tuple[clingo.Symbol, bool]] property

Assumptions generated by the preprocessor after calling process.

constants: dict[str, clingo.Symbol] property

Constants generated by the preprocessor after calling process.

process(program_string: str) -> str

Process the provided program string and return the transformed program string (control is also updated).

PARAMETER DESCRIPTION
program_string

The ASP program to be transformed.

TYPE: str

RETURNS DESCRIPTION
transformed_string

The transformed ASP program

process_files(files: list[str] | None = None) -> str

Process the provided files and return the transformed program string (control is also updated).

PARAMETER DESCRIPTION
files

A list of ASP program files to be transformed

TYPE: list[str] | None DEFAULT: None

RETURNS DESCRIPTION
transformed_string

The combined transformed ASP program of all the input files.

register_ast(ast: AST, builder: ProgramBuilder) -> None

Register the provided AST to the builder and the parsed rules list.

PARAMETER DESCRIPTION
ast

AST object that is registered to the builder.

TYPE: AST

builder

Builder object which the ast is registered to.

TYPE: ProgramBuilder

FilterPattern(pattern: str) dataclass

Filter to select which facts are converted to assumptions by a pattern.

__hash__() -> int

Return the hash value of the FilterPattern.

RETURNS DESCRIPTION
hash

Hashed pattern string of the FilterPattern.

FilterSignature(name: str, arity: int) dataclass

Filter to select which facts are converted to assumptions by signature.

__hash__() -> int

Return the hash value of the FilterSignature.

RETURNS DESCRIPTION
hash

Tuple containing name and arity of the FilterSignature.

preprocessor_assumption

Assumption Preprocessor for converting facts to choices that can be assumed.

AssumptionPreprocessor(filters: Iterable[FilterPattern | FilterSignature] | None = None, control: clingo.Control | None = None, fail_on_unprocessed: bool = True)

Preprocessor object that transforms program facts to choices for them tobe assumed.

Construct an AssumptionPreprocessor for the provided control, transforming facts matching the provided filters.

PARAMETER DESCRIPTION
filters

The set of filters matching facts to transform.

TYPE: Iterable[FilterPattern | FilterSignature] | None DEFAULT: None

control

The clingo Control object to use.

TYPE: Control | None DEFAULT: None

fail_on_unprocessed

Whether to fail if assumptions are accessed before a program is processed.

TYPE: bool DEFAULT: True

assumptions: set[tuple[clingo.Symbol, bool]] property

Assumptions generated by the preprocessor after calling process.

constants: dict[str, clingo.Symbol] property

Constants generated by the preprocessor after calling process.

process(program_string: str) -> str

Process the provided program string and return the transformed program string (control is also updated).

PARAMETER DESCRIPTION
program_string

The ASP program to be transformed.

TYPE: str

RETURNS DESCRIPTION
transformed_string

The transformed ASP program

process_files(files: list[str] | None = None) -> str

Process the provided files and return the transformed program string (control is also updated).

PARAMETER DESCRIPTION
files

A list of ASP program files to be transformed

TYPE: list[str] | None DEFAULT: None

RETURNS DESCRIPTION
transformed_string

The combined transformed ASP program of all the input files.

register_ast(ast: AST, builder: ProgramBuilder) -> None

Register the provided AST to the builder and the parsed rules list.

PARAMETER DESCRIPTION
ast

AST object that is registered to the builder.

TYPE: AST

builder

Builder object which the ast is registered to.

TYPE: ProgramBuilder

FilterPattern(pattern: str) dataclass

Filter to select which facts are converted to assumptions by a pattern.

__hash__() -> int

Return the hash value of the FilterPattern.

RETURNS DESCRIPTION
hash

Hashed pattern string of the FilterPattern.

FilterSignature(name: str, arity: int) dataclass

Filter to select which facts are converted to assumptions by signature.

__hash__() -> int

Return the hash value of the FilterSignature.

RETURNS DESCRIPTION
hash

Tuple containing name and arity of the FilterSignature.