Checkpoint

This commit is contained in:
Tibo De Peuter 2025-04-11 19:27:01 +02:00
parent e3c84e1761
commit e73e5cbfc8
32 changed files with 1354 additions and 92 deletions

View file

@ -1,7 +1,7 @@
package prolog.ast.terms
import prolog.ast.logic.Resolvent
import prolog.builtins.equivalent
import prolog.logic.equivalent
import prolog.logic.Substituted
import prolog.logic.unifyLazy
@ -9,13 +9,19 @@ typealias Argument = Term
typealias CompoundTerm = Structure
open class Structure(val name: Atom, val arguments: List<Argument>) : Goal(), Head, Body, Resolvent {
open class Structure(val name: Atom, var arguments: List<Argument>) : Goal(), Head, Body, Resolvent {
override val functor: Functor = "${name.name}/${arguments.size}"
override fun solve(goal: Goal, subs: Substituted): Sequence<Substituted> {
return unifyLazy(goal, this, subs)
}
// A structure does not need to be evaluated, so return an empty sequence.
override fun evaluate(subs: Substituted): Pair<Term, Substituted> = Pair(this, emptyMap())
/**
* See also [SWI Prolog Standard Order of Terms](https://www.swi-prolog.org/pldoc/man?section=standardorder)
*/
override fun compareTo(other: Term): Int {
when (other) {
is Structure -> {