SolverBuilder

interface SolverBuilder

A mutable, fluent builder for Solver/MutableSolver instances, as an alternative to calling SolverFactory.solverOf (and friends) with many named arguments at once.

Every piece of state exposed here is both a settable var property and a same-named fun that sets it and returns this, so calls can be chained, e.g.:

val solver =
Solver.prolog.newBuilder()
.staticKb(myTheory)
.standardOutput(OutputChannel.of { print(it) })
.build()

Obtain one via SolverFactory.newBuilder; every property starts out at the originating factory's default* value.

See also

Properties

Link copied to clipboard
abstract var builtins: Library?

The standard-library Library the built solver will load, or null if none (see noBuiltins).

Link copied to clipboard
abstract var dynamicKb: Theory

The dynamic knowledge base the built solver will start with.

Link copied to clipboard
abstract var flags: FlagStore

The FlagStore the built solver will start with.

Link copied to clipboard
abstract var inputs: InputStore

The it.unibo.tuprolog.solve.channel.InputStore the built solver will start with.

Link copied to clipboard
abstract var outputs: OutputStore

The it.unibo.tuprolog.solve.channel.OutputStore the built solver will start with.

Link copied to clipboard
abstract var runtime: Runtime

The Runtime of libraries the built solver will load (in addition to builtins, if any).

Link copied to clipboard

The standard error channel within outputs.

Link copied to clipboard

The standard input channel within inputs.

Link copied to clipboard

The standard output channel within outputs.

Link copied to clipboard
abstract var staticKb: Theory

The static knowledge base the built solver will start with.

Link copied to clipboard
abstract var unificator: Unificator

The Unificator the built solver will use.

Link copied to clipboard

The warnings channel within outputs.

Functions

Link copied to clipboard
abstract fun build(): Solver

Builds a Solver out of the current configuration of this builder.

Link copied to clipboard
abstract fun buildMutable(): MutableSolver

Builds a MutableSolver out of the current configuration of this builder.

Link copied to clipboard
abstract fun builtins(builtins: Library): SolverBuilder

Fluent setter for builtins.

Link copied to clipboard
abstract fun dynamicKb(theory: Theory): SolverBuilder

Fluent setter for dynamicKb.

abstract fun dynamicKb(clauses: Iterable<Clause>): SolverBuilder
abstract fun dynamicKb(clauses: Sequence<Clause>): SolverBuilder
abstract fun dynamicKb(vararg clauses: Clause): SolverBuilder

Sets dynamicKb to a Theory built out of clauses, using the current unificator.

Link copied to clipboard
abstract fun flag(flag: NotableFlag): SolverBuilder

Sets flag within flags to its default term value (NotableFlag.defaultTerm).

abstract fun flag(flag: Pair<String, Term>): SolverBuilder

Sets the flag identified by flag's first component within flags to its second component.

abstract fun <T : NotableFlag> flag(flag: T, value: T.() -> Term): SolverBuilder

Sets flag within flags to the Term computed by value, applied to flag itself.

abstract fun flag(flag: NotableFlag, value: Term): SolverBuilder

Sets flag within flags to value.

abstract fun flag(name: String, value: Term): SolverBuilder

Sets the flag named name within flags to value.

Link copied to clipboard
abstract fun flags(flags: FlagStore): SolverBuilder

Fluent setter for flags.

Link copied to clipboard
abstract fun input(alias: String, channel: InputChannel<String>): SolverBuilder

Adds channel to inputs under alias.

Link copied to clipboard
abstract fun inputs(inputs: InputStore): SolverBuilder

Fluent setter for inputs.

Link copied to clipboard
abstract fun library(item1: AbstractWrapper<*>, vararg items: AbstractWrapper<*>): SolverBuilder

Same as library, generating an anonymous alias automatically.

abstract fun library(alias: String?, item1: AbstractWrapper<*>, vararg items: AbstractWrapper<*>): SolverBuilder

Adds an anonymous (or aliased) library, assembled on the fly out of item1 and items (via it.unibo.tuprolog.solve.libraryOf), to runtime.

Link copied to clipboard
abstract fun noBuiltins(): SolverBuilder

Sets builtins to null, so the built solver won't load any standard-library predicate.

Link copied to clipboard
abstract fun output(alias: String, channel: OutputChannel<String>): SolverBuilder

Adds channel to outputs under alias.

Link copied to clipboard
abstract fun outputs(outputs: OutputStore): SolverBuilder

Fluent setter for outputs.

Link copied to clipboard
abstract fun runtime(runtime: Runtime): SolverBuilder

Fluent setter for runtime.

Link copied to clipboard

Fluent setter for standardError.

Link copied to clipboard

Fluent setter for standardInput.

Link copied to clipboard

Fluent setter for standardOutput.

Link copied to clipboard
abstract fun staticKb(theory: Theory): SolverBuilder

Fluent setter for staticKb.

abstract fun staticKb(clauses: Iterable<Clause>): SolverBuilder
abstract fun staticKb(clauses: Sequence<Clause>): SolverBuilder
abstract fun staticKb(vararg clauses: Clause): SolverBuilder

Sets staticKb to a Theory built out of clauses, using the current unificator.

Link copied to clipboard
abstract fun toFactory(): SolverFactory

Freezes the current configuration of this builder into a SolverFactory whose defaults match it.

Link copied to clipboard
abstract fun unificator(unificator: Unificator): SolverBuilder

Fluent setter for unificator.

Link copied to clipboard
abstract fun warnings(channel: OutputChannel<Warning>): SolverBuilder

Fluent setter for warnings.