All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.it.unibo.tuprolog.solve.streams.SolverStrategies.kt Maven / Gradle / Ivy

Go to download

Experimental, functional-programming-based implementation of Prolog's SLDNF resolution principle

There is a newer version: 1.0.4
Show newest version
package it.unibo.tuprolog.solve.streams

import it.unibo.tuprolog.core.Clause
import it.unibo.tuprolog.core.Term
import it.unibo.tuprolog.solve.ExecutionContext

/**
 * Interface representing internal strategies used by the [Solver]
 *
 * @author Enrico
 */
interface SolverStrategies {
    /** Selects the predication to be solved first, from provided sequence */
    fun 

predicationChoiceStrategy( predicationSequence: Sequence

, context: ExecutionContext, ): P /** Selects the clause to be expanded in place of unifying predication, from provided sequence */ fun clauseChoiceStrategy( unifiableClauses: Sequence, context: ExecutionContext, ): C /** Determines "when and what" is considered successfully demonstrated, during solution process */ fun successCheckStrategy( term: Term, context: ExecutionContext, ): Boolean companion object { /** Returns a strategy object containing the key solution strategies used by a Standard Prolog solver */ val prologStandard = object : SolverStrategies { /** The default implementation, following the Prolog Standard, selects the first predication found */ override fun

predicationChoiceStrategy( predicationSequence: Sequence

, context: ExecutionContext, ): P = predicationSequence.first() /** The default implementation, following the Prolog Standard, selects the first clause found */ override fun clauseChoiceStrategy( unifiableClauses: Sequence, context: ExecutionContext, ): C = unifiableClauses.first() override fun successCheckStrategy( term: Term, context: ExecutionContext, ): Boolean = term.isTrue } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy