Skip to content

API

Documentation of the metasp API.

Main module

metasp

The metasp project.

MetaspExtension

Bases: ReifyExtension

Metasp Extension for the reification process. It uses ASPEN to transform the input program and then reifies it with the help of the FormulaRegistery to keep track of the formulas and their types.

add_extension_encoding(ctl: Control) -> None

Adds the extension encoding to the control object. Args: ctl (Control): The clingo control object to which the encoding will be added.

additional_symbols() -> Sequence[Symbol]

Provides additional symbols to be added to the reified program. In this case, it provides the symbols for the formulas in the formula registery.

update_context(context: object) -> None

Updates the context object with the necessary functions for the extension.

Parameters:

Name Type Description Default
context object

The clingo context object to be updated.

required

MetaspProcessor

reify_and_extend(prg: str, constants: dict[str, str]) -> str

Reify the input data with the given constants. The input program is expected to be first transformed.

Parameters:

Name Type Description Default
prg str

The input data to be reified.

required
constants dict[str, str]

The constants to be used in the reification.

required

Returns: str: The reified input data.

is_reserved_predicate(symbol: Symbol) -> bool

Checks if a symbol is a reserved predicate.

Parameters:

Name Type Description Default
symbol Symbol

The symbol to check.

required

Returns:

Name Type Description
bool bool

True if the symbol is a reserved predicate, False otherwise.

replace_internal_prefix(prg: str) -> str

Replaces the __ prefix by & in the program. Used to show the output to the user.

Parameters:

Name Type Description Default
prg str

The program string to process.

required

Printing functions

metasp.printing

Module with all printing functions that will be available for the print_model Custom printing functions can be provided by adding the script in the configuration

pretty_printer(model: Model, system) -> None

Print the model with color highlighting the internal symbols (those starting with &) in yellow.

Parameters:

Name Type Description Default
model Model

The clingo model to be printed.

required
system MetaSystem

The metasp system.

required

temporal_printer(model: Model, system) -> None

Prints the model as in telingo, separating the states.

Parameters:

Name Type Description Default
model Model

The clingo model to be printed.

required
system MetaSystem

The metasp system.

required