fix: Groene vinkjes
This commit is contained in:
parent
4810b91628
commit
dff53b4e68
2 changed files with 7 additions and 5 deletions
|
@ -44,14 +44,16 @@ abstract class Clause(var head: Head, var body: Body) : Term, Resolvent {
|
|||
bodyAnswer.fold(
|
||||
onSuccess = { bodySubs ->
|
||||
// If the body can be proven, yield the (combined) substitutions
|
||||
var result = goalToHeadSubs.mapValues { applySubstitution(it.value, bodySubs) }
|
||||
yield(Result.success(result))
|
||||
val goalToHeadResult = goalToHeadSubs.mapValues { applySubstitution(it.value, bodySubs) }
|
||||
val headResult = headToGoalSubs.filterKeys { key -> goalToHeadSubs.any { occurs(key as Variable, it.value) } }
|
||||
yield(Result.success(goalToHeadResult + headResult))
|
||||
},
|
||||
onFailure = { error ->
|
||||
if (error is AppliedCut) {
|
||||
// Find single solution and return immediately
|
||||
if (error.subs != null) {
|
||||
yield(Result.failure(AppliedCut(headAndGoalSubs + error.subs)))
|
||||
var result = goalToHeadSubs.mapValues { applySubstitution(it.value, error.subs) }
|
||||
yield(Result.failure(AppliedCut(result)))
|
||||
} else {
|
||||
yield(Result.failure(AppliedCut()))
|
||||
}
|
||||
|
|
Reference in a new issue