add backward looking cyclicity check for variables in cycle detecting stackless iterator (#2111, #2117)

This commit is contained in:
Mark
2023-10-15 13:07:41 -06:00
parent 3a6aee72a3
commit e2000859b6
2 changed files with 33 additions and 8 deletions

View File

@@ -24,6 +24,10 @@ term5(A) :-
D=[_E|C],
A=[C|D].
term6(A) :-
A=[B|B],
B=[C|C].
test("acyclic_term_1", (
L = [_Y,[M,B],B|M], acyclic_term(L)
)).
@@ -165,6 +169,10 @@ test("acyclic_term#2111_5", (
term5(A), \+ acyclic_term(A)
)).
test("acyclic_term#2111_6", (
term6(A), acyclic_term(A)
)).
test("acyclic_term#2113", (
A=[]*B,B=[]*B, \+ acyclic_term(A)
)).
@@ -177,6 +185,10 @@ test("acyclic_term#2116", (
A=B*B,B=[]*[], acyclic_term(A)
)).
test("acyclic_term#2117", (
A=[]*A,B=[]*A, \+ acyclic_term(B)
)).
main :-
findall(test(Name, Goal), test(Name, Goal), Tests),
run_tests(Tests, Failed),
@@ -188,7 +200,7 @@ main_quiet :-
run_tests_quiet(Tests, Failed),
( Failed = [] ->
format("All tests passed", [])
; format("Some tests failed", [])
; format("Some tests failed: ~w~n", [Failed])
),
halt.