Unsatisfiable Subset Functionality¶
Minimal Unsatisfiable Core Utilities.
__all__ = ['AssumptionWrapper', 'Subset', 'SubsetComputer']
module-attribute
¶
AssumptionWrapper(literal: int, symbol: Symbol, sign: bool)
dataclass
¶
Container class for assumptions.
__hash__() -> int
¶
Return self.literal for hashing.
Subset(assumptions: set[AssumptionWrapper])
dataclass
¶
Bases: ABC
Container class for different types for subsets.
assumptions_string: str
property
¶
A rendered string representation of the assumptions.
symbol_strings: set[str]
property
¶
A set of rendered string representation of the assumption symbols.
__iter__() -> Iterator[tuple[clingo.Symbol, bool] | int]
¶
Iterate of the assumption symbols.
__str__() -> str
¶
Return a string representation of the subset.
iter_literals() -> Iterator[int]
¶
Iterate over all assumption literals in the unsatisfiable subset.
iter_symbols() -> Iterator[tuple[clingo.Symbol, bool]]
¶
Iterate over all assumption symbols in the unsatisfiable subset.
SubsetComputer(control: clingo.Control, assumptions: Iterable[int | tuple[Symbol, bool]], lattice_factory: LatticeFactory | None = None)
¶
Compute fundamental subsets of unsatisfiable problems.
Construct the SubsetComputer with the given control, assumptions, and optional lattice factory.
| PARAMETER | DESCRIPTION |
|---|---|
control
|
The clingo control object.
TYPE:
|
assumptions
|
The assumptions to use for computing relevant subsets. |
lattice_factory
|
The lattice factory to use for choosing the next subset to check, by default
TYPE:
|
last_mus: MinimalUnsatisfiableSubset | None
property
¶
The last MUS that was found.
is_valid(assumptions: set[int]) -> bool
¶
mcs(assumptions: Iterable[int | tuple[Symbol, bool]] | None = None) -> MinimalCorrectionSet | None
¶
Find a singlular MCS. This method is a wrapper around SubsetComputer.multiple().
| PARAMETER | DESCRIPTION |
|---|---|
assumptions
|
A set of assumption literals that form an unsatisfiable subset (US).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
mcs
|
A |
mss(assumptions: Iterable[int | tuple[Symbol, bool]] | None = None) -> MaximalSatisfiableSubset | None
¶
Find a singlular MSS. This method is a wrapper around SubsetComputer.multiple().
| PARAMETER | DESCRIPTION |
|---|---|
assumptions
|
A set of assumption literals that form an unsatisfiable subset (US).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
mss
|
A |
multiple(assumptions: Iterable[int | tuple[Symbol, bool]] | None = None, types: set[type[MinimalUnsatisfiableSubset] | type[MaximalSatisfiableSubset] | type[MinimalCorrectionSet]] | None = None, maximum: int | None = None, timeout: float | None = None) -> Generator[Subset, None, None]
¶
Find multiple fundamental subsets filtered by the types argument.
| PARAMETER | DESCRIPTION |
|---|---|
assumptions
|
A set of assumption literals that form an unsatisfiable subset (US).
TYPE:
|
types
|
A set of
TYPE:
|
maximum
|
The maximum amout of subsets to be found. The search is stopped after this amout is reached.
TYPE:
|
timeout
|
Sets a timeout in seconds, that if exceeded stops the subset search.
TYPE:
|
| YIELDS | DESCRIPTION |
|---|---|
subset
|
A subets matching the types specified in |
mus(assumptions: Iterable[int | tuple[Symbol, bool]] | None = None, timeout: float | None = None) -> Subset
¶
Find a singlular MUS via linear elimination.
| PARAMETER | DESCRIPTION |
|---|---|
assumptions
|
A set of assumption literals that form an unsatisfiable subset (US).
TYPE:
|
timeout
|
Sets a timeout in seconds, that if exceeded stops the search and returns the already found MUS literals.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
mus
|
A |
computer
¶
Container class for subset computation.
SubsetComputer(control: clingo.Control, assumptions: Iterable[int | tuple[Symbol, bool]], lattice_factory: LatticeFactory | None = None)
¶
Compute fundamental subsets of unsatisfiable problems.
Construct the SubsetComputer with the given control, assumptions, and optional lattice factory.
| PARAMETER | DESCRIPTION |
|---|---|
control
|
The clingo control object.
TYPE:
|
assumptions
|
The assumptions to use for computing relevant subsets. |
lattice_factory
|
The lattice factory to use for choosing the next subset to check, by default
TYPE:
|
last_mus: MinimalUnsatisfiableSubset | None
property
¶
The last MUS that was found.
is_valid(assumptions: set[int]) -> bool
¶
mcs(assumptions: Iterable[int | tuple[Symbol, bool]] | None = None) -> MinimalCorrectionSet | None
¶
Find a singlular MCS. This method is a wrapper around SubsetComputer.multiple().
| PARAMETER | DESCRIPTION |
|---|---|
assumptions
|
A set of assumption literals that form an unsatisfiable subset (US).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
mcs
|
A |
mss(assumptions: Iterable[int | tuple[Symbol, bool]] | None = None) -> MaximalSatisfiableSubset | None
¶
Find a singlular MSS. This method is a wrapper around SubsetComputer.multiple().
| PARAMETER | DESCRIPTION |
|---|---|
assumptions
|
A set of assumption literals that form an unsatisfiable subset (US).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
mss
|
A |
multiple(assumptions: Iterable[int | tuple[Symbol, bool]] | None = None, types: set[type[MinimalUnsatisfiableSubset] | type[MaximalSatisfiableSubset] | type[MinimalCorrectionSet]] | None = None, maximum: int | None = None, timeout: float | None = None) -> Generator[Subset, None, None]
¶
Find multiple fundamental subsets filtered by the types argument.
| PARAMETER | DESCRIPTION |
|---|---|
assumptions
|
A set of assumption literals that form an unsatisfiable subset (US).
TYPE:
|
types
|
A set of
TYPE:
|
maximum
|
The maximum amout of subsets to be found. The search is stopped after this amout is reached.
TYPE:
|
timeout
|
Sets a timeout in seconds, that if exceeded stops the subset search.
TYPE:
|
| YIELDS | DESCRIPTION |
|---|---|
subset
|
A subets matching the types specified in |
mus(assumptions: Iterable[int | tuple[Symbol, bool]] | None = None, timeout: float | None = None) -> Subset
¶
Find a singlular MUS via linear elimination.
| PARAMETER | DESCRIPTION |
|---|---|
assumptions
|
A set of assumption literals that form an unsatisfiable subset (US).
TYPE:
|
timeout
|
Sets a timeout in seconds, that if exceeded stops the search and returns the already found MUS literals.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
mus
|
A |
lattice
¶
Wrappers for the musclingo lattice classes.
AssumptionLatticeFactory(bias: bool)
¶
Bases: LatticeFactory
Factory for creating AssumptionLattice instances.
Construct an AssumptionLatticeFactory with the given bias.
| PARAMETER | DESCRIPTION |
|---|---|
bias
|
The bias to use for the lattice.
TYPE:
|
sets
¶
Container classes for sets.
MaximalSatisfiableSubset(assumptions: set[AssumptionWrapper])
dataclass
¶
MinimalCorrectionSet(assumptions: set[AssumptionWrapper])
dataclass
¶
MinimalUnsatisfiableSubset(assumptions: set[AssumptionWrapper])
dataclass
¶
SatisfiableSubset(assumptions: set[AssumptionWrapper])
dataclass
¶
Subset(assumptions: set[AssumptionWrapper])
dataclass
¶
Bases: ABC
Container class for different types for subsets.
assumptions_string: str
property
¶
A rendered string representation of the assumptions.
symbol_strings: set[str]
property
¶
A set of rendered string representation of the assumption symbols.
__iter__() -> Iterator[tuple[clingo.Symbol, bool] | int]
¶
Iterate of the assumption symbols.
__str__() -> str
¶
Return a string representation of the subset.
iter_literals() -> Iterator[int]
¶
Iterate over all assumption literals in the unsatisfiable subset.
iter_symbols() -> Iterator[tuple[clingo.Symbol, bool]]
¶
Iterate over all assumption symbols in the unsatisfiable subset.
UnsatisfiableSubset(assumptions: set[AssumptionWrapper])
dataclass
¶
render_assumption(assumption: AssumptionWrapper) -> str
¶
Render assumption in text format.
| PARAMETER | DESCRIPTION |
|---|---|
assumption
|
The assumption to be rendered.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
The rendered assumption string.
|
|
render_assumption_set(assumptions: set[AssumptionWrapper]) -> str
¶
Render assumptions in text format.
| PARAMETER | DESCRIPTION |
|---|---|
assumptions
|
A set of assumption to be rendered.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
The rendered assumptions string.
|
|
utils
¶
Utilities for the MUS functionality of clingexplaid.
Functionality for Unsat Constraints.
__all__ = ['UnsatConstraintComputer']
module-attribute
¶
UnsatConstraintComputer(control: clingo.Control | None = None)
¶
Computes the constraints of an unsatisfiable program that are the cause for the unsatisfiability.
Construct an UnsatConstraintComputer with the given control object.
| PARAMETER | DESCRIPTION |
|---|---|
control
|
The clingo control object.
TYPE:
|
get_constraint_location(constraint_id: int) -> Location | None
¶
Return the location of the constraint with constraint_id.
get_unsat_constraints(assumption_string: str | None = None) -> dict[int, str]
¶
Return the unsatisfiable constraints of the initialized UnsatConstraintComputer.
parse_files(files: Sequence[str]) -> None
¶
Initialize the UnsatConstraintComputer with a list of program.
parse_string(program_string: str) -> None
¶
Initialize the UnsatConstraintComputer with a program string.
constants
¶
Constant definitions for the unsat_constraints package.
unsat_constraint_computer
¶
Unsat Constraint Utilities.
UnsatConstraintComputer(control: clingo.Control | None = None)
¶
Computes the constraints of an unsatisfiable program that are the cause for the unsatisfiability.
Construct an UnsatConstraintComputer with the given control object.
| PARAMETER | DESCRIPTION |
|---|---|
control
|
The clingo control object.
TYPE:
|
get_constraint_location(constraint_id: int) -> Location | None
¶
Return the location of the constraint with constraint_id.
get_unsat_constraints(assumption_string: str | None = None) -> dict[int, str]
¶
Return the unsatisfiable constraints of the initialized UnsatConstraintComputer.
parse_files(files: Sequence[str]) -> None
¶
Initialize the UnsatConstraintComputer with a list of program.
parse_string(program_string: str) -> None
¶
Initialize the UnsatConstraintComputer with a program string.