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

commonMain.it.unibo.tuprolog.theory.TheoryUtils.kt Maven / Gradle / Ivy

Go to download

In-memory storage and indexing facilities for ordered and unordered knowledge bases composed by logic clauses

There is a newer version: 0.17.4
Show newest version
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()}"
            }
        }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy