Fix matching single constraint on reactivation after a logical has been assigned.
This commit is contained in:
parent
fc7b9d6caf
commit
087ccf4503
|
|
@ -82,10 +82,18 @@ class RuleMatcher(val rule: Rule) {
|
|||
}
|
||||
}
|
||||
|
||||
else -> newNodes.add(fn)
|
||||
else -> {
|
||||
newNodes.add(fn)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newNodes.size == 1) {
|
||||
// only the root
|
||||
val rfn = newNodes.get(0)
|
||||
newNodes.addAll(rfn.expand(occ, genId + 1, rfn.matchingVacant(mask)))
|
||||
}
|
||||
|
||||
return MatchFringe(newNodes, seen, genId + 1)
|
||||
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -86,6 +86,34 @@ class TestRuleMatcher {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSameOccurrenceLogical() {
|
||||
with(programWithRules(
|
||||
rule("rule1",
|
||||
headReplaced(
|
||||
constraint("foo", term("bar"))
|
||||
),
|
||||
body(
|
||||
constraint("qux")
|
||||
))))
|
||||
{
|
||||
val X = metaLogical<Term>("X")
|
||||
val x = X.logical()
|
||||
val foo = occurrence("foo", x)
|
||||
with(ruleMatcher().probe()) {
|
||||
|
||||
expand(foo) }.apply {
|
||||
matches().size shouldBe 0 }.run {
|
||||
|
||||
x.set(term("bar"))
|
||||
|
||||
expand(foo) }.apply {
|
||||
matches().size shouldBe 1 }.run {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTermArgument() {
|
||||
with(programWithRules(
|
||||
|
|
|
|||
Loading…
Reference in New Issue