fix: Evaluation
This commit is contained in:
parent
d702b9b081
commit
1acd1cfb67
17 changed files with 189 additions and 120 deletions
|
@ -1,6 +1,6 @@
|
|||
package prolog.components.expressions
|
||||
|
||||
import prolog.Substitution
|
||||
import prolog.Substituted
|
||||
import prolog.components.Resolvent
|
||||
import prolog.components.terms.Functor
|
||||
import prolog.components.terms.Goal
|
||||
|
@ -49,12 +49,10 @@ class Predicate : Resolvent {
|
|||
this.clauses.addAll(clauses)
|
||||
}
|
||||
|
||||
override fun solve(goal: Goal): Sequence<Substitution> = sequence {
|
||||
override fun solve(goal: Goal, subs: Substituted): Sequence<Substituted> = sequence {
|
||||
require(goal.functor == functor) { "Goal functor does not match predicate functor" }
|
||||
for (clause in clauses) {
|
||||
// Try to unify the goal with the clause
|
||||
// If the unification is successful, yield the substitutions
|
||||
yieldAll(clause.solve(goal))
|
||||
}
|
||||
// Try to unify the goal with the clause
|
||||
// If the unification is successful, yield the substitutions
|
||||
clauses.forEach { yieldAll(it.solve(goal, subs)) }
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue