Solver

io.github.kelvindev15.prolog.solver.Solver
See theSolver companion trait
object Solver

Attributes

Companion
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Solver.type

Members list

Type members

Classlikes

enum Solution

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Substitution

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Types

type Substitution = Map[Variable, Term]

A mapping from Variables to Terms

A mapping from Variables to Terms

Attributes

Value members

Concrete methods

def hasSolutionForGoal(using solver: Solver)(goal: Term): Boolean

Returns true if the provided goal admits at least one solution. If not specified the default solver that will be used is the TuPrologClassicSolver.

Returns true if the provided goal admits at least one solution. If not specified the default solver that will be used is the TuPrologClassicSolver.

Value parameters

goal

the program to satisfy.

solver

the solver that should be used.

Attributes

def hasSolutionForProgram(using solver: Solver)(program: PrologProgram): Boolean

Returns true if the program admits at least one solution. If not specified the default solver that will be used is the TuPrologClassicSolver.

Returns true if the program admits at least one solution. If not specified the default solver that will be used is the TuPrologClassicSolver.

Value parameters

program

the program to solve.

solver

the solver that should be used.

Attributes

def lazyQuery(using solver: Solver)(query: Term): LazyList[Solution]

Solves the goal on program with an empty theory using a solver that is either provided as a context parameter, found as a given instance or by using the default one (TuPrologClassicSolver).

Solves the goal on program with an empty theory using a solver that is either provided as a context parameter, found as a given instance or by using the default one (TuPrologClassicSolver).

Value parameters

query

the goal to be solved.

solver

the solver that should be used.

Attributes

Returns

a lazy list of the program's Solutions.

def lazySolve(using solver: Solver)(prologProgram: PrologProgram): LazyList[Solution]

Solves a program using a solver that is either provided as a context parameter, found as a given instance or by using the default one (TuPrologClassicSolver).

Solves a program using a solver that is either provided as a context parameter, found as a given instance or by using the default one (TuPrologClassicSolver).

Value parameters

prologProgram

the program to solve.

solver

the solver that should be used.

Attributes

Returns

a lazy list of the program's Solutions.

def query(using solver: Solver)(query: Term): Iterator[Solution]

Solves the goal on program with an empty theory using a solver that is either provided as a context parameter, found as a given instance or by using the default one (TuPrologClassicSolver).

Solves the goal on program with an empty theory using a solver that is either provided as a context parameter, found as a given instance or by using the default one (TuPrologClassicSolver).

Value parameters

query

the goal to be solved.

solver

the solver that should be used.

Attributes

Returns

an iterator over the program's Solutions.

def solutionsOf(using solver: Solver)(prologProgram: PrologProgram): Seq[Solution]

Solves a program using a solver that is either provided as a context parameter, found as a given instance or by using the default one (TuPrologClassicSolver).

Solves a program using a solver that is either provided as a context parameter, found as a given instance or by using the default one (TuPrologClassicSolver).

Value parameters

prologProgram

the program to solve.

solver

the solver that should be used.

Attributes

Returns

a list of the program's Solutions.

def solve(using solver: Solver)(prologProgram: PrologProgram): Iterator[Solution]

Solves a program using a solver that is either provided as a context parameter, found as a given instance or by using the default one (TuPrologClassicSolver).

Solves a program using a solver that is either provided as a context parameter, found as a given instance or by using the default one (TuPrologClassicSolver).

Value parameters

prologProgram

the program to solve.

solver

the solver that should be used.

Attributes

Returns

an iterator over the Solutions of the program.

Returns a Solver that leverages on the tuProlog engine.

Returns a Solver that leverages on the tuProlog engine.

Attributes

Extensions

Extensions

extension (solution: Solution)
def apply(variable: Variable): Option[Term]

Returns an option filled with the substitution term for the provided variable. The option will be empty if the solution is No or Halt or the provided variable is not in the Substitution.

Returns an option filled with the substitution term for the provided variable. The option will be empty if the solution is No or Halt or the provided variable is not in the Substitution.

Attributes

def as[T <: Solution](using ClassTag[T]): T

Cast the solution to a Solution of type T.

Cast the solution to a Solution of type T.

Type parameters

T

the type of the expected solution

Attributes

Throws
ClassCastException

if T is not the runtime type of the solution.

def asHalt: Halt

Cast the solution to a Halt Solution.

Cast the solution to a Halt Solution.

Attributes

Throws
ClassCastException

if Halt is not the runtime type of the solution.

def asNo: No

Cast the solution to a No Solution.

Cast the solution to a No Solution.

Attributes

Throws
ClassCastException

if No is not the runtime type of the solution.

def asYes: Yes

Cast the solution to a Yes Solution.

Cast the solution to a Yes Solution.

Attributes

Throws
ClassCastException

if Yes is not the runtime type of the solution.

def instance: Option[Term]

Returns an option filled with the application of the substitution to the query, if the the solution is Solution.Yes, None otherwise.

Returns an option filled with the application of the substitution to the query, if the the solution is Solution.Yes, None otherwise.

Attributes

def isHalt: Boolean

Returns true if the solution is a Halt.

Returns true if the solution is a Halt.

Attributes

def isNo: Boolean

Returns true if the solution is a No.

Returns true if the solution is a No.

Attributes

def isYes: Boolean

Returns true if the solution is a Yes.

Returns true if the solution is a Yes.

Attributes