This repository has been archived on 2025-09-23. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
2025LogProg-project-GhentPr.../src/prolog/builtins/unification.kt
2025-04-11 19:27:01 +02:00

24 lines
715 B
Kotlin

/**
* Comparison and Unification of Terms
*
* [SWI Prolog Documentation](https://www.swi-prolog.org/pldoc/man?section=compare)
*/
package prolog.builtins
import prolog.ast.terms.Atom
import prolog.ast.terms.Operator
import prolog.ast.terms.Term
import prolog.logic.Substituted
import prolog.logic.applySubstitution
import prolog.logic.equivalent
class Equivalent(private val term1: Term, private val term2: Term) : Operator(Atom("=="), term1, term2) {
override fun prove(subs: Substituted): Sequence<Substituted> = sequence {
val t1 = applySubstitution(term1, subs)
val t2 = applySubstitution(term2, subs)
if (equivalent(t1, t2)) {
yield(emptyMap())
}
}
}