commonMain.it.unibo.tuprolog.theory.TheoryUtils.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of theory-metadata Show documentation
Show all versions of theory-metadata Show documentation
In-memory storage and indexing facilities for ordered and unordered knowledge bases composed by logic clauses
package it.unibo.tuprolog.theory
import it.unibo.tuprolog.core.Clause
internal object TheoryUtils {
/** Utility method to check clause well-formed property */
fun checkClauseCorrect(clause: Clause) =
clause.also {
require(clause.isWellFormed) {
"ClauseDatabase can contain only well formed clauses: " +
"this isn't $clause"
}
}
/** Utility method to check more than one clause well-formed property */
fun checkClausesCorrect(clauses: Iterable) =
clauses.also {
require(clauses.all { it.isWellFormed }) {
"ClauseDatabase can contain only well formed clauses: these aren't " +
"${clauses.filterNot { it.isWellFormed }.toList()}"
}
}
fun checkClausesCorrect(clauses: Sequence) =
clauses.also {
require(clauses.all { it.isWellFormed }) {
"ClauseDatabase can contain only well formed clauses: these aren't " +
"${clauses.filterNot { it.isWellFormed }.toList()}"
}
}
}