Skip to content

python_domain_computation

CachedPythonEvaluation dataclass

Cached domain plus compressed trace bundle for one Python output request.

ComputedDomains dataclass

Cached compile2 domain-computation outputs for one grounding run.

expression_domain_symbols

expression_domain_symbols() -> Iterable[Symbol]

Yield _se_domain/2 facts for all computed expressions.

expression_set_domain_symbol_symbols

expression_set_domain_symbol_symbols(expr: Symbol) -> Iterable[Symbol]

Yield (Uid,SetValue) tuples for one set-valued expression.

expression_set_domain_symbols

expression_set_domain_symbols() -> Iterable[Symbol]

Yield _se_set_domain(Expr,Uid) facts for all computed expressions.

expression_set_domain_value_symbols

expression_set_domain_value_symbols() -> Iterable[Symbol]

Yield _se_set_domain(Uid,Sign,Value) facts across all set expressions.

python_evaluation_input_symbols

python_evaluation_input_symbols() -> Iterable[Symbol]

Yield _python_evaluation_input/4 tuples for all computed Python traces.

python_evaluation_output_symbols

python_evaluation_output_symbols() -> Iterable[Symbol]

Yield _python_evaluation_output/3 tuples for all computed Python traces.

python_evaluation_symbols

python_evaluation_symbols() -> Iterable[Symbol]

Yield _python_evaluation/2 tuples for all computed Python traces.

python_value_reference_symbol

python_value_reference_symbol(value: PythonEvaluationValue) -> Symbol

Return one export symbol for a Python trace value or set reference.

set_expression_symbols

set_expression_symbols() -> list[Symbol]

Return the sorted set-valued expressions and time the export.

DomainComputation

Compute compile2 expression domains directly from raw clingo symbols.

add_set_membership_export_request classmethod

add_set_membership_export_request(requests: set[SetMembershipExportRequest], expression_domains: Mapping[Symbol, Domain], reference_expr: Symbol, set_value: frozenset[DomainAtom]) -> None

Record one demanded _se_set_domain/3 export for a referenced concrete set.

collect_python_set_membership_export_requests classmethod

collect_python_set_membership_export_requests(requests: set[SetMembershipExportRequest], expression_domains: Mapping[Symbol, Domain], python_evaluation_inputs: Iterable[PythonEvaluationInputAtom], python_evaluation_outputs: Iterable[PythonEvaluationOutputAtom]) -> None

Add set membership exports required by one batch of Python traces.

collect_tuple_set_membership_export_requests classmethod

collect_tuple_set_membership_export_requests(requests: set[SetMembershipExportRequest], expression_domains: Mapping[Symbol, Domain], expr: Symbol) -> None

Add set membership exports required by one literal tuple expression.

compute classmethod

compute(top_level_expressions: Iterable[Symbol], solver_identifiers: tuple[Symbol, ...]) -> ComputedDomains

Compute compile2 expression domains and the derived set export metadata.

concrete_set_domain classmethod

concrete_set_domain(var: Symbol, expression_domains: Mapping[Symbol, Domain], set_sources: Mapping[Symbol, dict[str, list[Symbol]]]) -> Domain | None

Build the set-valued domain implied by one set variable and its sources.

debug_expression_total classmethod

debug_expression_total(ordered_expressions: tuple[Symbol, ...], skipped_python_extract_exprs: set[Symbol], python_extract_groups: Mapping[Symbol, tuple[Symbol, ...]]) -> int

Count the number of expression rows that will be written to the debug CSV.

debug_input_domain_formula classmethod

debug_input_domain_formula(input_sizes: tuple[int, ...]) -> tuple[str, int]

Render a stable multiplicative formula for one expression's input sizes.

debug_input_domain_sizes classmethod

debug_input_domain_sizes(expr: Symbol, expression_domains: Mapping[Symbol, Domain], variable_sources: Mapping[Symbol, list[Symbol]], set_sources: Mapping[Symbol, dict[str, list[Symbol]]]) -> tuple[int, ...]

Return the immediate input domain sizes used to derive one expression.

direct_subexpressions classmethod

direct_subexpressions(expr: Symbol) -> list[Symbol]

Return the immediate child expressions that influence one expression domain.

domain_values classmethod

domain_values(domain: Domain) -> set[DomainAtom]

Return all non-set runtime values stored in one domain.

evaluate_expression classmethod

evaluate_expression(expr: Symbol, expression_domains: Mapping[Symbol, Domain], solver_identifiers: tuple[Symbol, ...], evaluation_session: PythonEvaluationExporter, cached_compute_domain: Callable[[Symbol, tuple[Domain, ...], tuple[Symbol, ...]], Domain], cached_python_expression_evaluation: Callable[[str, tuple[Symbol, ...]], CachedPythonEvaluations], cached_python_callable_evaluation: Callable[[str, tuple[Domain, ...], tuple[Symbol, ...]], CachedPythonEvaluations], cached_python_extract_evaluation: Callable[[str, tuple[Domain, ...], tuple[Symbol, ...], tuple[str, ...]], CachedPythonEvaluations], grouped_exprs: tuple[Symbol, ...] | None = None) -> dict[Symbol, Domain]

Evaluate one raw compile2 expression symbol into one or more expression domains.

evaluate_tuple classmethod

evaluate_tuple(expr: Symbol, expression_domains: Mapping[Symbol, Domain]) -> Domain

Enumerate tuple values from already-computed child domains.

group_python_extract_expressions classmethod

group_python_extract_expressions(ordered_expressions: tuple[Symbol, ...]) -> tuple[dict[Symbol, tuple[Symbol, ...]], set[Symbol]]

Return representative PythonExtract groups and the redundant members to skip in the main loop.

is_function classmethod

is_function(symbol: Symbol, name: str | None = None, arity: int | None = None) -> bool

Check whether one symbol is a function term with an optional signature.

is_tuple classmethod

is_tuple(symbol: Symbol, arity: int | None = None) -> bool

Check whether one symbol is represented as an anonymous tuple term.

normalize_solver_identifiers classmethod

normalize_solver_identifiers(solver_identifiers: tuple[Symbol, ...]) -> tuple[Symbol, ...]

Flatten the _main_solverIdentifiers/1 list term into evaluator identifiers.

python_extract_group_key classmethod

python_extract_group_key(expr: Symbol) -> PythonExtractGroupKey | None

Return the grouping key for PythonExtract expressions that share one statement execution.

python_extract_output_code classmethod

python_extract_output_code(expr: Symbol) -> str | None

Return the PythonExtract output expression code for one operation symbol.

sequence_items classmethod

sequence_items(symbol: Symbol) -> list[Symbol] | None

Flatten one nested pair-list into a Python list when it ends in ().

sorted_expressions classmethod

sorted_expressions(top_level_expressions: Iterable[Symbol], variable_sources: Mapping[Symbol, list[Symbol]], set_sources: Mapping[Symbol, dict[str, list[Symbol]]]) -> Iterable[Symbol]

Yield expressions in a dependency-first order with variable sources expanded first.

source_maps classmethod

source_maps(top_level_expressions: Iterable[Symbol]) -> tuple[dict[Symbol, list[Symbol]], dict[Symbol, dict[str, list[Symbol]]]]

Split top-level variable-related declarations into scalar and set source maps.

ExportDebugProfiler dataclass

Accumulate export timings and rewrite the aggregate CSV after each update.

record

record(name: str, elapsed_seconds: float) -> None

Add one timing sample and persist the updated aggregates immediately.

ExpressionDebugLogger dataclass

Stream per-expression compute timings to CSV as domains are derived.

close

close() -> None

Close the CSV handle once the compute pass is complete.

log

log(expression_number: int, expression_total: int, expr: Symbol, elapsed_seconds: float, formula: str, formula_result: int, computed_domain_size: int) -> None

Append one timing row and flush it immediately.

PythonEvaluationCapture dataclass

Bases: PythonEvaluationSession

Capture reusable Python traces without binding them to compile2 expression ids.

compressed_results

compressed_results(arg_domains: tuple[Domain, ...]) -> CachedPythonEvaluations

Return cached domains plus compressed traces keyed only by output code.

output_requests

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

Return the requested reusable outputs for the current Python evaluation.

record_output

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

Store one expression-independent Python output trace.

PythonEvaluationCompressedTrace dataclass

One wildcard-compressed Python trace for a family of input assignments.

PythonEvaluationExporter dataclass

Export cached Python traces into compile2 python-evaluation atoms.

replay_cached_evaluation

replay_cached_evaluation(expr: Symbol, arg_exprs: tuple[Symbol, ...], compressed_evaluations: tuple[PythonEvaluationCompressedTrace, ...], *, is_extract: bool) -> None

Append one cached compressed Python trace bundle to the exported lists.

PythonEvaluationLeaf dataclass

Leaf node of one compressed Python evaluation trie.

PythonEvaluationNode dataclass

Interior node of one compressed Python evaluation trie.

PythonWarningOutput dataclass

Pre-encoded non-domain output emitted for Python evaluation warnings.

compress_python_evaluation_trie

compress_python_evaluation_trie(trie: dict[Any, Any], ordered_domains: tuple[tuple[DomainAtom, ...], ...], depth: int = 0) -> PythonEvaluationLeaf | PythonEvaluationNode

Collapse trie levels when every value in one argument domain shares the same subtree.

compressed_python_evaluations

compressed_python_evaluations(arg_domains: tuple[Domain, ...], outputs_by_assignment: Mapping[PythonEvaluationAssignment, PythonEvaluationOutputSignature]) -> tuple[PythonEvaluationCompressedTrace, ...]

Return wildcard-safe Python evaluation traces that still cover the full input product.

python_error_output

python_error_output(message: str) -> PythonWarningOutput

Return the exported error(expression(pythonError), Message) symbol.

python_evaluation_trie

python_evaluation_trie(outputs_by_assignment: Mapping[PythonEvaluationAssignment, PythonEvaluationOutputSignature]) -> dict[Any, Any]

Build a trie over concrete Python argument tuples.

python_trace_signature

python_trace_signature(domain: Domain, error_messages: Iterable[str] = ()) -> PythonEvaluationOutputSignature

Return one stable trace signature including warning outputs when present.

record_compressed_python_evaluation

record_compressed_python_evaluation(expr: Symbol, arg_exprs: tuple[Symbol, ...], compressed_evaluations: tuple[PythonEvaluationCompressedTrace, ...], python_evaluations: list[PythonEvaluationAtom], python_evaluation_inputs: list[PythonEvaluationInputAtom], python_evaluation_outputs: list[PythonEvaluationOutputAtom], *, is_extract: bool) -> None

Record one already-compressed family of Python input/output traces.