<commit_before>package com.github.prologdb.runtime.knowledge.library

import com.github.prologdb.runtime.RandomVariableScope
import com.github.prologdb.runtime.knowledge.KnowledgeBase
import com.github.prologdb.runtime.lazysequence.LazySequence
import com.github.prologdb.runtime.term.Atom
import com.github.prologdb.runtime.term.Predicate
import com.github.prologdb.runtime.term.Term
import com.github.prologdb.runtime.term.Variable
import com.github.prologdb.runtime.unification.Unification

/**
 * A type of predicate, e.g. `likes/2`.
 */
interface PredicatePrototype {
    val name: String
    val arity: Int

    /** The prolog-idiomatic representation of this prototype, e.g. for `name=foobar, arity=2` returns `'/'(foobar, 2)` */
    fun asIdiomatic(): Predicate = object : Predicate("/", arrayOf(Atom(name), com.github.prologdb.runtime.term.PrologInteger(arity.toLong()))) {
        override fun toString(): String = "${this@PredicatePrototype.name}/${this@PredicatePrototype.arity}"
    }
}

/**
 * A single entry in a knowledge base or library, e.g. a single fact or a single rule.
 * @see Predicate
 * @see com.github.prologdb.runtime.knowledge.Rule
 */
interface LibraryEntry : PredicatePrototype {
    /**
     * Unifies the given predicate (`other`) with this entry; if this is a fact (a [Predicate]), unifies with
     * the given predicate and ignores the given [KnowledgeBase]. If this is a rule, uses the [KnowledgeBase]
     * to run the query (in case the head and the given [Predicate] unify).
     */
    fun unifyWithKnowledge(other: Predicate, kb: KnowledgeBase, randomVariableScope: RandomVariableScope) : LazySequence<Unification>
}

interface LibraryEntryStore {
    /**
     * The elements of the library or knowledge base. The order enforced by the [Iterator]
     * defines the order in proof search will consider the entries.
     */<commit_msg>Renamed interface PredicatePrototype to PredicateIndicator<commit_after>package com.github.prologdb.runtime.knowledge.library

import com.github.prologdb.runtime.RandomVariableScope
import com.github.prologdb.runtime.knowledge.KnowledgeBase
import com.github.prologdb.runtime.lazysequence.LazySequence
import com.github.prologdb.runtime.term.Atom
import com.github.prologdb.runtime.term.Predicate
import com.github.prologdb.runtime.term.Term
import com.github.prologdb.runtime.term.Variable
import com.github.prologdb.runtime.unification.Unification

/**
 * A indicator of a predicate, e.g. `likes/2`.
 */
interface PredicateIndicator {
    val name: String
    val arity: Int

    /** The prolog-idiomatic representation of this indicator, e.g. for `name=foobar, arity=2` is `'/'(foobar, 2)` */
    val idiomaticIndicator: Predicate
        get() = object : Predicate("/", arrayOf(Atom(name), com.github.prologdb.runtime.term.PrologInteger(arity.toLong()))) {
            override fun toString(): String = "${this@PredicateIndicator.name}/${this@PredicateIndicator.arity}"
        }
}

/**
 * A single entry in a knowledge base or library, e.g. a single fact or a single rule.
 * @see Predicate
 * @see com.github.prologdb.runtime.knowledge.Rule
 */
interface LibraryEntry : PredicateIndicator {
    /**
     * Unifies the given predicate (`other`) with this entry; if this is a fact (a [Predicate]), unifies with
     * the given predicate and ignores the given [KnowledgeBase]. If this is a rule, uses the [KnowledgeBase]
     * to run the query (in case the head and the given [Predicate] unify).
     */
    fun unifyWithKnowledge(other: Predicate, kb: KnowledgeBase, randomVariableScope: RandomVariableScope) : LazySequence<Unification>
}

interface LibraryEntryStore {
    /**
     * The elements of the library or knowledge base. The order enforced by the [Iterator]
     * defines the order in proof search will consider the entries.
     */
{'fraction_non_alphanumeric': 0.10663878724516467, 'fraction_numerical': 0.0015682174594877157, 'mean_word_length': 4.136912751677852, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5566556', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1114, 'n_words': 328}