Prolog "cyclic"
/**
* Warranty & Liability
* To the extent permitted by applicable law and unless explicitly
* otherwise agreed upon, XLOG Technologies AG makes no warranties
* regarding the provided information. XLOG Technologies AG assumes
* no liability that any problems might be solved with the information
* provided by XLOG Technologies AG.
*
* Rights & License
* All industrial property rights regarding the information - copyright
* and patent rights in particular - are the sole property of XLOG
* Technologies AG. If the company was not the originator of some
* excerpts, XLOG Technologies AG has at least obtained the right to
* reproduce, change and translate the information.
*
* Reproduction is restricted to the whole unaltered document. Reproduction
* of the information is only allowed for non-commercial uses. Selling,
* giving away or letting of the execution of the library is prohibited.
* The library can be distributed as part of your applications and libraries
* for execution provided this comment remains unchanged.
*
* Restrictions
* Only to be distributed with programs that add significant and primary
* functionality to the library. Not to be distributed with additional
* software intended to replace any components of the library.
*
* Trademarks
* Jekejeke is a registered trademark of XLOG Technologies AG.
*/
runner_file(extend, cyclic, 'XLOG 3.6 cyclic').
/* acyclic_term(X) */
runner_pred(acyclic_term, 1, extend, cyclic, 'Corr.2 8.3.11.4').
runner_case(acyclic_term, 1, extend, cyclic, 'Corr.2 8.3.11.4, ISO 1') :-
acyclic_term(a(_,1)).
runner_case(acyclic_term, 1, extend, cyclic, 'Corr.2 8.3.11.4, ISO 2') :-
X = f(X), \+ acyclic_term(X).
runner_case(acyclic_term, 1, extend, cyclic, 'Corr.2 8.3.11.4, XLOG 1') :-
X = f(X), Y = g(X), \+ acyclic_term(Y).
runner_case(acyclic_term, 1, extend, cyclic, 'Corr.2 8.3.11.4, XLOG 2') :-
X = f(Y), Y = g(X), Z = h(X), \+ acyclic_term(Z).
runner_case(acyclic_term, 1, extend, cyclic, 'Corr.2 8.3.11.4, XLOG 3') :-
X = [a,b,Y|c], Y = [d,e,Z|f], Z = [g,h,i], acyclic_term(X).
runner_case(acyclic_term, 1, extend, cyclic, 'Corr.2 8.3.11.4, XLOG 4') :-
X = [a,b,Y|c], Y = [d,e,Z|f], Z = [g,h,X|i], \+ acyclic_term(X).
/* acyclic_factorized(L, R) */
runner_pred(acyclic_factorized,2, extend, cyclic, 'XLOG 3.6.1').
runner_case(acyclic_factorized,2, extend, cyclic, 'XLOG 3.6.1, XLOG 1') :-
Y = f(Y), acyclic_factorized([Y-Y],[[T|L]]),
L = [A=_], T == A-A, L == [A = f(A)].
runner_case(acyclic_factorized,2, extend, cyclic, 'XLOG 3.6.1, XLOG 2') :-
Y = f(Y), X = g(X,Y), Z = h(Z), acyclic_factorized([X-Z],[[T|L]]),
L = [C=_, B=_, A=_], T == B-C, L == [C = h(C), B = g(B, A), A = f(A)].
runner_case(acyclic_factorized,2, extend, cyclic, 'XLOG 3.6.1, XLOG 3') :-
X = f(f(f(X))), Y = f(f(Y)), acyclic_factorized([X-Y],[[T|L]]),
L = [A=_], T == A-A, L == [A = f(A)].
runner_case(acyclic_factorized,2, extend, cyclic, 'XLOG 3.6.1, XLOG 4') :-
X = a(f(X,Y)), Y = a(f(Y,X)), acyclic_factorized([X-Y],[[T|L]]),
L = [A=_], T == A-A, L == [A = a(f(A, A))].
runner_case(acyclic_factorized,2, extend, cyclic, 'XLOG 3.6.1, XLOG 5') :-
X = s(s(X,Y),A), Y = s(Y,X), acyclic_factorized([X-Y],[[T|L]]),
L = [C=_, B=_], T == C-B, L == [C = s(s(C, B), A), B = s(B, C)].
runner_case(acyclic_factorized,2, extend, cyclic, 'XLOG 3.6.1, XLOG 6') :-
Y = s(s(Y,B),B), X = s(s(X,Y),A), acyclic_factorized([Y,X],[[S|R],[T|L]]),
R == [S = s(S, B)], L == [T = s(s(T, S), A)].
runner_case(acyclic_factorized,2, extend, cyclic, 'XLOG 3.6.1, XLOG 7') :-
X = s(s(X,Y),A), Y = s(s(Y,B),B), acyclic_factorized([X,Y],[[T|L],[S|R]]),
L == [T = s(s(T, S), A), S = s(S, B)], R == [].