protocol

asp_protocol

Protocol for process-backed ASP solving, source generation, and result inspection.

Availability:
logtalk_load(asp(loader))
Author: Paulo Moura
Version: 1:0:0
Date: 2026-11-11
Compilation flags:
static
Dependencies:
(none)
Remarks:
(none)
Inherited public predicates:
(none)

Public predicates

solve/2

Solves a source with default options using the external Clingo CLI and returns a collected result after cleanup. Valid sources are object(Object), terms(Statements), codes(Codes), and file(Path).

Compilation flags:
static
Template:
solve(Source,Result)
Mode and number of proofs:
solve(+compound,-compound) - one_or_error
Exceptions:
Source is not a ground term:
instantiation_error
Source is ground but not a supported source, or is object(Object) where Object does not implement asp_problem_protocol:
domain_error(asp_source,Source)
Statements is ground but not a list:
type_error(list,Statements)
A statement enumerated by the provider object is not a valid statement:
domain_error(asp_statement,Statement)
An origin enumerated by the provider object is invalid, or its origins and statements differ in length:
domain_error(asp_origins,Origins)
Codes is ground but not a list of character codes:
type_error(codes,Codes)
An element Code of the list Codes is ground but not an integer:
type_error(integer,Code)
An element Code of the list Codes is an integer but not a valid character code:
domain_error(character_code,Code)
Path is ground but not an atom:
type_error(atom,Path)
Path does not exist:
existence_error(source_sink,Path)
Path cannot be opened for reading:
permission_error(open,source_sink,Path)
A launcher argument contains a null character:
domain_error(asp_shell_argument,Argument)
The solver executable or a shell dependency does not exist:
existence_error(command,Command)
An owned directory cannot be found during cleanup:
existence_error(directory,Directory)
An owned file or directory cannot be removed:
permission_error(delete,source_sink,Path)
A character sequence is not valid UTF-8:
representation_error(utf_8)
A launcher operation fails:
asp_transport(Stage,Status,Details)
Solver output is invalid or inconsistent with its exit status:
asp_solver_error(Formal,Status,Diagnostics,SourceMap)

solve/3

Solves a source using solver selection, executable, enumeration, optimization, resource, and statistics options. Repeated options use the first occurrence. Valid sources are object(Object), terms(Statements), codes(Codes), and file(Path).

Compilation flags:
static
Template:
solve(Source,Result,Options)
Mode and number of proofs:
solve(+compound,-compound,+list(compound)) - one_or_error
Exceptions:
Source is not a ground term:
instantiation_error
Source is ground but not a supported source, or is object(Object) where Object does not implement asp_problem_protocol:
domain_error(asp_source,Source)
Statements is ground but not a list:
type_error(list,Statements)
A statement enumerated by the provider object is not a valid statement:
domain_error(asp_statement,Statement)
An origin enumerated by the provider object is invalid, or its origins and statements differ in length:
domain_error(asp_origins,Origins)
Codes is ground but not a list of character codes:
type_error(codes,Codes)
An element Code of the list Codes is ground but not an integer:
type_error(integer,Code)
An element Code of the list Codes is an integer but not a valid character code:
domain_error(character_code,Code)
Path is ground but not an atom:
type_error(atom,Path)
Path does not exist:
existence_error(source_sink,Path)
Path cannot be opened for reading:
permission_error(open,source_sink,Path)
Options is a variable:
instantiation_error
Options is neither a variable nor a list:
type_error(list,Options)
An element Option of the list Options is a variable:
instantiation_error
An element Option of the list Options is neither a variable nor a compound term:
type_error(compound,Option)
An element Option of the list Options is a compound term but not a valid option:
domain_error(option,Option)
An effective option is unsupported by the selected solver:
domain_error(asp_solver_option,Solver-Option)
A launcher argument contains a null character:
domain_error(asp_shell_argument,Argument)
The solver executable or a shell dependency does not exist:
existence_error(command,Command)
An owned directory cannot be found during cleanup:
existence_error(directory,Directory)
An owned file or directory cannot be removed:
permission_error(delete,source_sink,Path)
A character sequence is not valid UTF-8:
representation_error(utf_8)
A launcher operation fails:
asp_transport(Stage,Status,Details)
Solver output is invalid or inconsistent with its exit status:
asp_solver_error(Formal,Status,Diagnostics,SourceMap)

program/1

Generates and prints ASP source to the current output, equivalent to program/2 followed by print_program/1, without invoking Clingo.

Compilation flags:
static
Template:
program(Source)
Mode and number of proofs:
program(+compound) - one_or_error
Exceptions:
Source is not a ground term:
instantiation_error
Source is ground but not a supported source, or is object(Object) where Object does not implement asp_problem_protocol:
domain_error(asp_source,Source)
Statements is ground but not a list:
type_error(list,Statements)
A statement enumerated by the provider object is not a valid statement:
domain_error(asp_statement,Statement)
An origin enumerated by the provider object is invalid, or its origins and statements differ in length:
domain_error(asp_origins,Origins)
Codes is ground but not a list of character codes:
type_error(codes,Codes)
An element Code of the list Codes is ground but not an integer:
type_error(integer,Code)
An element Code of the list Codes is an integer but not a valid character code:
domain_error(character_code,Code)
Path is ground but not an atom:
type_error(atom,Path)
Path does not exist:
existence_error(source_sink,Path)
Path cannot be opened for reading:
permission_error(open,source_sink,Path)
The current output stream does not allow writing:
permission_error(output,stream,Stream)

program/2

Returns ASP source codes from object(Object), terms(Statements), codes(Codes), or file(Path) without invoking Clingo.

Compilation flags:
static
Template:
program(Source,Codes)
Mode and number of proofs:
program(+compound,-list(integer)) - one_or_error
Exceptions:
Source is not a ground term:
instantiation_error
Source is ground but not a supported source, or is object(Object) where Object does not implement asp_problem_protocol:
domain_error(asp_source,Source)
Statements is ground but not a list:
type_error(list,Statements)
A statement enumerated by the provider object is not a valid statement:
domain_error(asp_statement,Statement)
An origin enumerated by the provider object is invalid, or its origins and statements differ in length:
domain_error(asp_origins,Origins)
Codes is ground but not a list of character codes:
type_error(codes,Codes)
An element Code of the list Codes is ground but not an integer:
type_error(integer,Code)
An element Code of the list Codes is an integer but not a valid character code:
domain_error(character_code,Code)
Path is ground but not an atom:
type_error(atom,Path)
Path does not exist:
existence_error(source_sink,Path)
Path cannot be opened for reading:
permission_error(open,source_sink,Path)

model/2

Enumerates, by backtracking, collected model(Symbols, Costs, RawValues) records without starting a process.

Compilation flags:
static
Template:
model(Result,Model)
Mode and number of proofs:
model(+compound,-compound) - zero_or_more
Exceptions:
Result is not a ground term:
instantiation_error
Result is not a valid collected Clingo result:
domain_error(asp_result,Result)

result_property/2

Enumerates, by backtracking, status(Status) and the stored result properties.

Compilation flags:
static
Template:
result_property(Result,Property)
Mode and number of proofs:
result_property(+compound,?compound) - zero_or_more
Exceptions:
Result is not a ground term:
instantiation_error
Result is not a valid collected Clingo result:
domain_error(asp_result,Result)


Protected predicates

(none)

Private predicates

(none)

Operators

(none)