Assert{a,z,}

This commit is contained in:
Tibo De Peuter 2025-05-02 21:51:34 +02:00
parent f9017da734
commit 80fb3d1e60
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
11 changed files with 373 additions and 79 deletions

View file

@ -19,7 +19,7 @@ import prolog.logic.unifyLazy
* @see [prolog.ast.terms.Variable]
* @see [Predicate]
*/
abstract class Clause(val head: Head, val body: Body) : Resolvent {
abstract class Clause(val head: Head, val body: Body) : Term, Resolvent {
val functor: Functor = head.functor
override fun solve(goal: Goal, subs: Substitutions): Answers = sequence {
@ -70,4 +70,18 @@ abstract class Clause(val head: Head, val body: Body) : Resolvent {
}
override fun toString(): String = if (body is True) head.toString() else "$head :- $body"
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is Clause) return false
if (head != other.head) return false
if (body != other.body) return false
return true
}
override fun hashCode(): Int {
return super.hashCode()
}
}