Skip to content

python_domain

Domain dataclass

Compact domain model for compile2 without using expression wrappers.

Set-valued domains are modeled by their candidate atoms plus either an explicit subset collection or None to mean that every subset of the candidate atoms is valid.

set_uids cached property

set_uids: frozenset[int]

Return cached global ids for all possible concrete set values.

sets cached property

sets: frozenset[frozenset[DomainAtom]]

Return all concrete set values represented by this domain.

all_subsets classmethod

all_subsets(*values: DomainAtom) -> Domain

Return a domain where every subset of the candidate atoms is valid.

apply classmethod

apply(operation: Any, *domains: Domain) -> Domain

Dispatch one operator name to the matching domain transfer function.

arithmetic_values

arithmetic_values() -> Iterable[int | float]

Yield numeric values with booleans coerced to their integer form.

bad classmethod

bad() -> Domain

Return a domain containing only the bad marker.

booleans classmethod

booleans(*values: bool) -> Domain

Return a domain seeded with boolean values.

coarse_boolean_output_domain classmethod

coarse_boolean_output_domain(operation: Any) -> Domain

Return the old shortcut domain for expensive boolean-valued operators.

compute_domain classmethod

compute_domain(operation: Symbol, *domains: Domain, solver_identifiers: tuple[Symbol, ...] = (), evaluation_session: PythonEvaluationSession) -> Domain

Compute one operation domain from its symbolic operator and child domains.

empty classmethod

empty() -> Domain

Return an empty domain.

evaluate_python_callable classmethod

evaluate_python_callable(code: str, domains: tuple[Domain, ...], solver_identifiers: tuple[Symbol, ...], evaluation_session: PythonEvaluationSession) -> Domain

Evaluate one Python callable and optionally expose per-input outputs.

evaluate_python_expression classmethod

evaluate_python_expression(code: str, solver_identifiers: tuple[Symbol, ...], evaluation_session: PythonEvaluationSession) -> Domain

Evaluate one bare Python expression and optionally expose the concrete output.

evaluate_python_extract classmethod

evaluate_python_extract(stmt: str, expr_code: str, domains: tuple[Domain, ...], solver_identifiers: tuple[Symbol, ...], evaluation_session: PythonEvaluationSession) -> Domain

Evaluate one PythonExtract operator and optionally expose per-input outputs.

evaluate_python_extract_output classmethod

evaluate_python_extract_output(expr_code: str, execution: PythonExtractExecution) -> tuple[Domain, tuple[str, ...]]

Evaluate one PythonExtract output expression against a cached statement execution.

execute_python_extract_statement cached classmethod

execute_python_extract_statement(stmt: str, arg_values: tuple[DomainAtom, ...], solver_identifiers: tuple[Symbol, ...]) -> PythonExtractExecution

Execute one PythonExtract statement for one concrete input assignment.

expression_domain_symbols

expression_domain_symbols(expr: Symbol, *, include_set_values: bool) -> Iterable[Symbol]

Yield _se_domain/2 tuples for one expression.

expression_set_domain_symbol_symbols

expression_set_domain_symbol_symbols(global_set_uids: Mapping[frozenset[DomainAtom], int] | None = None) -> Iterable[Symbol]

Yield (Uid, SetValue) tuples for this domain's concrete sets.

expression_set_domain_symbols

expression_set_domain_symbols(expr: Symbol, global_set_uids: Mapping[frozenset[DomainAtom], int] | None = None) -> Iterable[Symbol]

Yield _se_set_domain/2 tuples for this domain's concrete sets.

floats_only classmethod

floats_only(*values: float) -> Domain

Return a domain seeded with float values.

from_runtime classmethod

from_runtime(value: Any) -> Domain

Lift one direct Python runtime result into a domain.

from_symbol classmethod

from_symbol(symbol: Symbol) -> Domain

Lift one compile2 value symbol into a runtime domain.

from_value classmethod

from_value(value: DomainAtom) -> Domain

Lift one concrete runtime value into a domain.

has_boolean_output classmethod

has_boolean_output(operation: Any) -> bool

Report whether an operator always returns a boolean-like domain.

has_possible_sets

has_possible_sets() -> bool

Report whether this domain includes any concrete or symbolic set value.

has_values

has_values() -> bool

Report whether this domain contains any non-bad possibility.

integers classmethod

integers(*values: int) -> Domain

Return a domain seeded with integer values.

merge classmethod

merge(*domains: Domain) -> Domain

Return one domain containing the union of all inputs.

none classmethod

none() -> Domain

Return a domain containing only none.

numeric_values

numeric_values() -> Iterable[int | float]

Yield numeric values while preserving int/float deduplication.

op_abs classmethod

op_abs(domain: Domain) -> Domain

Compute the absolute-value domain.

op_acos classmethod

op_acos(domain: Domain) -> Domain

Compute the arccosine domain.

op_add classmethod

op_add(left: Domain, right: Domain) -> Domain

Compute the addition domain.

op_asin classmethod

op_asin(domain: Domain) -> Domain

Compute the arcsine domain.

op_atan classmethod

op_atan(domain: Domain) -> Domain

Compute the arctangent domain.

op_ceil classmethod

op_ceil(domain: Domain) -> Domain

Apply ceil to all numeric values in the domain.

op_concat classmethod

op_concat(left: Domain, right: Domain) -> Domain

Compute all string concatenations from two string domains.

op_conj classmethod

op_conj(left: Domain, right: Domain) -> Domain

Compute the logical-conjunction domain.

op_cos classmethod

op_cos(domain: Domain) -> Domain

Compute the cosine domain.

op_default classmethod

op_default(primary: Domain, fallback: Domain) -> Domain

Return the primary domain, falling back when it is only none-like.

op_diff classmethod

op_diff(left: Domain, right: Domain) -> Domain

Compute the pairwise set difference of all candidate sets.

op_disj classmethod

op_disj(left: Domain, right: Domain) -> Domain

Compute the logical-disjunction domain.

op_eq classmethod

op_eq(left: Domain, right: Domain) -> Domain

Compute the equality domain using overlap shortcuts.

op_float_div classmethod

op_float_div(left: Domain, right: Domain) -> Domain

Compute the floating-division domain.

op_floor classmethod

op_floor(domain: Domain) -> Domain

Apply floor to all numeric values in the domain.

op_geq classmethod

op_geq(left: Domain, right: Domain) -> Domain

Compute the greater-or-equal comparison domain.

op_gt classmethod

op_gt(left: Domain, right: Domain) -> Domain

Compute the strict-greater-than comparison domain.

op_hasValue classmethod

op_hasValue(domain: Domain) -> Domain

Return whether the domain can hold a concrete non-none value.

op_if classmethod

op_if(condition: Domain, if_true: Domain, if_false: Domain) -> Domain

Compute the guarded-value domain for the two-argument if operator.

op_int_div classmethod

op_int_div(left: Domain, right: Domain) -> Domain

Compute the integer-division domain.

op_inter classmethod

op_inter(left: Domain, right: Domain) -> Domain

Compute the pairwise intersection of all candidate sets.

op_ite classmethod

op_ite(condition: Domain, if_true: Domain, if_false: Domain) -> Domain

Compute the if-then-else domain from the possible condition values.

op_length classmethod

op_length(domain: Domain) -> Domain

Compute lengths for strings, tuples, and concrete sets.

op_leq classmethod

op_leq(left: Domain, right: Domain) -> Domain

Compute the less-or-equal comparison domain.

op_leqv classmethod

op_leqv(left: Domain, right: Domain) -> Domain

Compute the logical-equivalence domain.

op_limp classmethod

op_limp(left: Domain, right: Domain) -> Domain

Compute the logical-implication domain.

op_lnot classmethod

op_lnot(domain: Domain) -> Domain

Compute the logical-negation domain.

op_lt classmethod

op_lt(left: Domain, right: Domain) -> Domain

Compute the strict-less-than comparison domain.

op_lxor classmethod

op_lxor(left: Domain, right: Domain) -> Domain

Compute the logical-exclusive-or domain.

op_max classmethod

op_max(*domains: Domain) -> Domain

Compute all max results across the argument cross-product.

op_min classmethod

op_min(*domains: Domain) -> Domain

Compute all min results across the argument cross-product.

op_minus classmethod

op_minus(domain: Domain) -> Domain

Negate all numeric values in the domain.

op_mult classmethod

op_mult(left: Domain, right: Domain) -> Domain

Compute the multiplication domain.

op_neq classmethod

op_neq(left: Domain, right: Domain) -> Domain

Compute the inequality domain from the equality domain.

op_pow classmethod

op_pow(left: Domain, right: Domain) -> Domain

Compute the exponentiation domain.

op_set_isin classmethod

op_set_isin(member: Domain, set_domain: Domain) -> Domain

Compute whether scalar members can occur in candidate sets.

op_set_make classmethod

op_set_make(*domains: Domain) -> Domain

Build all concrete sets produced by choosing one scalar from each input domain.

op_set_notin classmethod

op_set_notin(member: Domain, set_domain: Domain) -> Domain

Compute whether scalar members can be absent from candidate sets.

op_sin classmethod

op_sin(domain: Domain) -> Domain

Compute the sine domain.

op_snot classmethod

op_snot(domain: Domain) -> Domain

Compute strong negation, where none collapses to false.

op_sqrt classmethod

op_sqrt(domain: Domain) -> Domain

Compute the square-root domain.

op_sub classmethod

op_sub(left: Domain, right: Domain) -> Domain

Compute the subtraction domain.

op_subset classmethod

op_subset(left: Domain, right: Domain) -> Domain

Compute the subset relation over all candidate set pairs.

op_tan classmethod

op_tan(domain: Domain) -> Domain

Compute the tangent domain.

op_union classmethod

op_union(left: Domain, right: Domain) -> Domain

Compute the pairwise union of all candidate sets.

op_wnot classmethod

op_wnot(domain: Domain) -> Domain

Compute weak negation, where none collapses to true.

operation_name classmethod

operation_name(operation: Any) -> str

Normalize a symbolic operator representation to its name.

operation_spec classmethod

operation_spec(operation: Any) -> OperationSpec

Return the uniform dispatch spec for one non-Python operator.

options

options() -> tuple[DomainAtom, ...]

Return one stable enumeration of domain alternatives, including bad when present.

register_set_uid classmethod

register_set_uid(value: frozenset[DomainAtom]) -> int

Assign a stable global uid to one concrete set value.

runtime_to_value classmethod

runtime_to_value(value: Any) -> DomainAtom

Normalize one direct Python runtime value into the internal domain representation.

scalar_values

scalar_values() -> Iterable[bool | int | float | str | None | Symbol]

Yield only scalar values, excluding tuples and concrete sets.

set_count

set_count() -> int

Count concrete set values without materializing symbolic all-subset domains.

set_domain_value_symbols

set_domain_value_symbols(global_set_uids: Mapping[frozenset[DomainAtom], int] | None = None, candidate_values: Iterable[DomainAtom] = ()) -> Iterable[Symbol]

Yield _se_set_domain/3 tuples for concrete set memberships.

set_sort_key classmethod

set_sort_key(value: frozenset[DomainAtom])

Build a deterministic structural ordering key for one concrete set value.

set_uid_sort_key classmethod

set_uid_sort_key(value: object)

Build a deterministic structural ordering key for set-uid assignment.

set_value_domain_symbols classmethod

set_value_domain_symbols(set_value: frozenset[DomainAtom], *, global_set_uids: Mapping[frozenset[DomainAtom], int] | None = None, candidate_values: Iterable[DomainAtom] = ()) -> Iterable[Symbol]

Yield _se_set_domain/3 tuples for one concrete set value.

set_values classmethod

set_values(*values: frozenset[DomainAtom]) -> Domain

Return a domain seeded with concrete set values.

strings_only classmethod

strings_only(*values: str) -> Domain

Return a domain seeded with string values.

symbols_only classmethod

symbols_only(*values: Symbol) -> Domain

Return a domain seeded with symbol values.

to_symbols

to_symbols(*, include_bad: bool = False, include_set_values: bool = True) -> Iterable[Symbol]

Yield compile2 symbols while preserving native-value ordering and filtering.

truth_values

truth_values() -> Iterable[bool | None]

Yield the truthy lattice used by logical operations.

tuple_values classmethod

tuple_values(*values: tuple[DomainAtom, ...]) -> Domain

Return a domain seeded with tuple values.

value_count

value_count(*, include_bad: bool = False) -> int

Count represented values for threshold heuristics without materializing sets.

value_set

value_set(*, include_bad: bool = False) -> set[DomainAtom]

Materialize the represented values when set operations are required.

value_to_runtime classmethod

value_to_runtime(value: DomainAtom) -> Any

Convert one internal domain value into direct Python runtime data.

value_to_symbol classmethod

value_to_symbol(value: DomainAtom) -> Symbol

Convert one runtime domain value into the compile2 value encoding.

values

values(*, include_bad: bool = False) -> Iterable[DomainAtom]

Yield all concrete values represented by this domain.

OperationSpec dataclass

Describe how one operator should be dispatched over child domains.

PythonEvaluationOutputRequest dataclass

Describe one requested Python output for a concrete input assignment.

PythonEvaluationSession

Bidirectional interface used while enumerating Python evaluation traces.

output_requests

output_requests() -> tuple[PythonEvaluationOutputRequest, ...]

Return the outputs the current Python evaluation should produce.

record_output

record_output(output_id: object, arg_values: tuple[DomainAtom, ...], assignment_domain: 'Domain', error_messages: tuple[str, ...]) -> None

Receive one concrete Python output for the current assignment.

cached_function cached

cached_function(name: str, arguments: tuple[Symbol, ...] = (), positive: bool = True) -> Symbol

Return one interned clingo function symbol for the given signature.

cached_number cached

cached_number(value: int) -> Symbol

Return one interned clingo number symbol for the provided value.

cached_tuple cached

cached_tuple(arguments: tuple[Symbol, ...]) -> Symbol

Return one interned clingo tuple symbol for the provided arguments.

get_compiled_eval cached

get_compiled_eval(code: str)

Compile one Python expression string once.

get_compiled_exec cached

get_compiled_exec(code: str)

Compile one Python statement string once.

get_environment cached

get_environment(identifiers: tuple[Symbol, ...]) -> dict[str, Any]

Build the Python globals for one normalized solver-identifier tuple.