Cleanup 2
This commit is contained in:
parent
a9bb6e0338
commit
3c938749d0
22 changed files with 299 additions and 110 deletions
|
@ -7,7 +7,6 @@ package prolog.builtins
|
|||
|
||||
import prolog.Answers
|
||||
import prolog.Substitutions
|
||||
import prolog.ast.terms.Atom
|
||||
import prolog.ast.terms.Operator
|
||||
import prolog.ast.terms.Term
|
||||
import prolog.logic.applySubstitution
|
||||
|
@ -17,7 +16,7 @@ import prolog.logic.unifyLazy
|
|||
/**
|
||||
* Unify Term1 with Term2. True if the unification succeeds.
|
||||
*/
|
||||
class Unify(private val term1: Term, private val term2: Term): Operator(Atom("="), term1, term2) {
|
||||
class Unify(private val term1: Term, private val term2: Term): Operator("=", term1, term2) {
|
||||
override fun satisfy(subs: Substitutions): Answers = sequence {
|
||||
val t1 = applySubstitution(term1, subs)
|
||||
val t2 = applySubstitution(term2, subs)
|
||||
|
@ -31,16 +30,11 @@ class Unify(private val term1: Term, private val term2: Term): Operator(Atom("="
|
|||
)
|
||||
}
|
||||
|
||||
class NotUnify(private val term1: Term, private val term2: Term) : Operator(Atom("\\="), term1, term2) {
|
||||
private val not = Not(Unify(term1, term2))
|
||||
override fun satisfy(subs: Substitutions): Answers = not.satisfy(subs)
|
||||
override fun applySubstitution(subs: Substitutions): NotUnify = NotUnify(
|
||||
applySubstitution(term1, subs),
|
||||
applySubstitution(term2, subs)
|
||||
)
|
||||
class NotUnify(private val term1: Term, private val term2: Term) : Not(Unify(term1, term2)) {
|
||||
override fun toString(): String = "($term1 \\= $term2)"
|
||||
}
|
||||
|
||||
class Equivalent(private val term1: Term, private val term2: Term) : Operator(Atom("=="), term1, term2) {
|
||||
class Equivalent(private val term1: Term, private val term2: Term) : Operator("==", term1, term2) {
|
||||
override fun satisfy(subs: Substitutions): Answers = sequence {
|
||||
val t1 = applySubstitution(term1, subs)
|
||||
val t2 = applySubstitution(term2, subs)
|
||||
|
@ -56,11 +50,6 @@ class Equivalent(private val term1: Term, private val term2: Term) : Operator(At
|
|||
)
|
||||
}
|
||||
|
||||
class NotEquivalent(private val term1: Term, private val term2: Term) : Operator(Atom("\\=="), term1, term2) {
|
||||
private val not = Not(Equivalent(term1, term2))
|
||||
override fun satisfy(subs: Substitutions): Answers = not.satisfy(subs)
|
||||
override fun applySubstitution(subs: Substitutions): NotEquivalent = NotEquivalent(
|
||||
applySubstitution(term1, subs),
|
||||
applySubstitution(term2, subs)
|
||||
)
|
||||
class NotEquivalent(private val term1: Term, private val term2: Term) : Not(Equivalent(term1, term2)) {
|
||||
override fun toString(): String = "($term1 \\== $term2)"
|
||||
}
|
||||
|
|
Reference in a new issue