/export/starexec/sandbox/solver/bin/starexec_run_standard /export/starexec/sandbox/benchmark/theBenchmark.pl /export/starexec/sandbox/output/output_files -------------------------------------------------------------------------------- YES proof of /export/starexec/sandbox/benchmark/theBenchmark.pl # AProVE Commit ID: 48fb2092695e11cc9f56e44b17a92a5f88ffb256 marcel 20180622 unpublished dirty Left Termination of the query pattern lsort(g,a) w.r.t. the given Prolog program could successfully be proven: (0) Prolog (1) PrologToDTProblemTransformerProof [SOUND, 0 ms] (2) TRIPLES (3) TriplesToPiDPProof [SOUND, 17 ms] (4) PiDP (5) DependencyGraphProof [EQUIVALENT, 0 ms] (6) PiDP (7) PiDPToQDPProof [SOUND, 7 ms] (8) QDP (9) QDPSizeChangeProof [EQUIVALENT, 0 ms] (10) YES ---------------------------------------- (0) Obligation: Clauses: lsort(InList, OutList) :- lsort(InList, OutList, asc). lsort(InList, OutList, Dir) :- ','(add_key(InList, KList, Dir), ','(keysort(KList, SKList), rem_key(SKList, OutList))). add_key([], [], X1). add_key(.(X, Xs), .(-(L, p(X)), Ys), asc) :- ','(!, ','(length(X, L), add_key(Xs, Ys, asc))). add_key(.(X, Xs), .(-(L, p(X)), Ys), desc) :- ','(length(X, L1), ','(is(L, -(L1)), add_key(Xs, Ys, desc))). rem_key([], []). rem_key(.(-(X2, p(X)), Xs), .(X, Ys)) :- rem_key(Xs, Ys). length(X3, X4). Query: lsort(g,a) ---------------------------------------- (1) PrologToDTProblemTransformerProof (SOUND) Built DT problem from termination graph DT10. { "root": 3, "program": { "directives": [], "clauses": [ [ "(lsort InList OutList)", "(lsort InList OutList (asc))" ], [ "(lsort InList OutList Dir)", "(',' (add_key InList KList Dir) (',' (keysort KList SKList) (rem_key SKList OutList)))" ], [ "(add_key ([]) ([]) X1)", null ], [ "(add_key (. X Xs) (. (- L (p X)) Ys) (asc))", "(',' (!) (',' (length X L) (add_key Xs Ys (asc))))" ], [ "(add_key (. X Xs) (. (- L (p X)) Ys) (desc))", "(',' (length X L1) (',' (is L (- L1)) (add_key Xs Ys (desc))))" ], [ "(rem_key ([]) ([]))", null ], [ "(rem_key (. (- X2 (p X)) Xs) (. X Ys))", "(rem_key Xs Ys)" ], [ "(length X3 X4)", null ] ] }, "graph": { "nodes": { "11": { "goal": [{ "clause": -1, "scope": -1, "term": "(',' (add_key T13 X22 (asc)) (',' (keysort X22 X23) (rem_key X23 T15)))" }], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": ["T13"], "free": [ "X22", "X23" ], "exprvars": [] } }, "22": { "goal": [ { "clause": 3, "scope": 3, "term": "(add_key ([]) X22 (asc))" }, { "clause": 4, "scope": 3, "term": "(add_key ([]) X22 (asc))" } ], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": [], "free": ["X22"], "exprvars": [] } }, "66": { "goal": [], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": [], "free": [], "exprvars": [] } }, "12": { "goal": [{ "clause": -1, "scope": -1, "term": "(add_key T13 X22 (asc))" }], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": ["T13"], "free": ["X22"], "exprvars": [] } }, "34": { "goal": [{ "clause": -1, "scope": -1, "term": "(',' (!_3) (',' (length T25 X67) (add_key T26 X68 (asc))))" }], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": [ "T25", "T26" ], "free": [ "X67", "X68" ], "exprvars": [] } }, "13": { "goal": [{ "clause": -1, "scope": -1, "term": "(',' (keysort T16 X23) (rem_key X23 T15))" }], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": [], "free": ["X23"], "exprvars": [] } }, "24": { "goal": [{ "clause": 4, "scope": 3, "term": "(add_key ([]) X22 (asc))" }], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": [], "free": ["X22"], "exprvars": [] } }, "36": { "goal": [], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": [], "free": [], "exprvars": [] } }, "15": { "goal": [ { "clause": 2, "scope": 3, "term": "(add_key T13 X22 (asc))" }, { "clause": 3, "scope": 3, "term": "(add_key T13 X22 (asc))" }, { "clause": 4, "scope": 3, "term": "(add_key T13 X22 (asc))" } ], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": ["T13"], "free": ["X22"], "exprvars": [] } }, "38": { "goal": [{ "clause": -1, "scope": -1, "term": "(',' (length T25 X67) (add_key T26 X68 (asc)))" }], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": [ "T25", "T26" ], "free": [ "X67", "X68" ], "exprvars": [] } }, "17": { "goal": [ { "clause": -1, "scope": -1, "term": "(true)" }, { "clause": 3, "scope": 3, "term": "(add_key ([]) X22 (asc))" }, { "clause": 4, "scope": 3, "term": "(add_key ([]) X22 (asc))" } ], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": [], "free": ["X22"], "exprvars": [] } }, "28": { "goal": [], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": [], "free": [], "exprvars": [] } }, "type": "Nodes", "3": { "goal": [{ "clause": -1, "scope": -1, "term": "(lsort T1 T2)" }], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": ["T1"], "free": [], "exprvars": [] } }, "6": { "goal": [{ "clause": 0, "scope": 1, "term": "(lsort T1 T2)" }], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": ["T1"], "free": [], "exprvars": [] } }, "7": { "goal": [{ "clause": -1, "scope": -1, "term": "(lsort T5 T7 (asc))" }], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": ["T5"], "free": [], "exprvars": [] } }, "30": { "goal": [{ "clause": 3, "scope": 3, "term": "(add_key T13 X22 (asc))" }], "kb": { "nonunifying": [[ "(add_key T13 X22 (asc))", "(add_key ([]) ([]) X30)" ]], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": ["T13"], "free": [ "X22", "X30" ], "exprvars": [] } }, "63": { "goal": [{ "clause": 7, "scope": 4, "term": "(',' (length T25 X67) (add_key T26 X68 (asc)))" }], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": [ "T25", "T26" ], "free": [ "X67", "X68" ], "exprvars": [] } }, "20": { "goal": [ { "clause": 3, "scope": 3, "term": "(add_key T13 X22 (asc))" }, { "clause": 4, "scope": 3, "term": "(add_key T13 X22 (asc))" } ], "kb": { "nonunifying": [[ "(add_key T13 X22 (asc))", "(add_key ([]) ([]) X30)" ]], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": ["T13"], "free": [ "X22", "X30" ], "exprvars": [] } }, "64": { "goal": [{ "clause": -1, "scope": -1, "term": "(add_key T26 X68 (asc))" }], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": ["T26"], "free": ["X68"], "exprvars": [] } }, "10": { "goal": [{ "clause": 1, "scope": 2, "term": "(lsort T5 T7 (asc))" }], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": ["T5"], "free": [], "exprvars": [] } }, "32": { "goal": [{ "clause": 4, "scope": 3, "term": "(add_key T13 X22 (asc))" }], "kb": { "nonunifying": [[ "(add_key T13 X22 (asc))", "(add_key ([]) ([]) X30)" ]], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": ["T13"], "free": [ "X22", "X30" ], "exprvars": [] } }, "65": { "goal": [], "kb": { "nonunifying": [], "intvars": {}, "arithmetic": { "type": "PlainIntegerRelationState", "relations": [] }, "ground": [], "free": [], "exprvars": [] } } }, "edges": [ { "from": 3, "to": 6, "label": "CASE" }, { "from": 6, "to": 7, "label": "ONLY EVAL with clause\nlsort(X7, X8) :- lsort(X7, X8, asc).\nand substitutionT1 -> T5,\nX7 -> T5,\nT2 -> T7,\nX8 -> T7,\nT6 -> T7" }, { "from": 7, "to": 10, "label": "CASE" }, { "from": 10, "to": 11, "label": "ONLY EVAL with clause\nlsort(X19, X20, X21) :- ','(add_key(X19, X22, X21), ','(keysort(X22, X23), rem_key(X23, X20))).\nand substitutionT5 -> T13,\nX19 -> T13,\nT7 -> T15,\nX20 -> T15,\nX21 -> asc,\nT14 -> T15" }, { "from": 11, "to": 12, "label": "SPLIT 1" }, { "from": 11, "to": 13, "label": "SPLIT 2\nnew knowledge:\nT13 is ground\nreplacements:X22 -> T16" }, { "from": 12, "to": 15, "label": "CASE" }, { "from": 13, "to": 66, "label": "UNDEFINED ERROR" }, { "from": 15, "to": 17, "label": "EVAL with clause\nadd_key([], [], X30).\nand substitutionT13 -> [],\nX22 -> [],\nX30 -> asc" }, { "from": 15, "to": 20, "label": "EVAL-BACKTRACK" }, { "from": 17, "to": 22, "label": "SUCCESS" }, { "from": 20, "to": 30, "label": "PARALLEL" }, { "from": 20, "to": 32, "label": "PARALLEL" }, { "from": 22, "to": 24, "label": "BACKTRACK\nfor clause: add_key(.(X, Xs), .(-(L, p(X)), Ys), asc) :- ','(!, ','(length(X, L), add_key(Xs, Ys, asc)))because of non-unification" }, { "from": 24, "to": 28, "label": "BACKTRACK\nfor clause: add_key(.(X, Xs), .(-(L, p(X)), Ys), desc) :- ','(length(X, L1), ','(is(L, -(L1)), add_key(Xs, Ys, desc)))because of non-unification" }, { "from": 30, "to": 34, "label": "EVAL with clause\nadd_key(.(X63, X64), .(-(X65, p(X63)), X66), asc) :- ','(!_3, ','(length(X63, X65), add_key(X64, X66, asc))).\nand substitutionX63 -> T25,\nX64 -> T26,\nT13 -> .(T25, T26),\nX65 -> X67,\nX66 -> X68,\nX22 -> .(-(X67, p(T25)), X68)" }, { "from": 30, "to": 36, "label": "EVAL-BACKTRACK" }, { "from": 32, "to": 65, "label": "BACKTRACK\nfor clause: add_key(.(X, Xs), .(-(L, p(X)), Ys), desc) :- ','(length(X, L1), ','(is(L, -(L1)), add_key(Xs, Ys, desc)))because of non-unification" }, { "from": 34, "to": 38, "label": "CUT" }, { "from": 38, "to": 63, "label": "CASE" }, { "from": 63, "to": 64, "label": "ONLY EVAL with clause\nlength(X79, X80).\nand substitutionT25 -> T29,\nX79 -> T29,\nX67 -> X81,\nX80 -> X81" }, { "from": 64, "to": 12, "label": "INSTANCE with matching:\nT13 -> T26\nX22 -> X68" } ], "type": "Graph" } } ---------------------------------------- (2) Obligation: Triples: add_keyA(.(X1, X2), .(-(X3, p(X1)), X4)) :- add_keyA(X2, X4). lsortB(X1, X2) :- add_keyA(X1, X3). Clauses: add_keycA([], []). add_keycA(.(X1, X2), .(-(X3, p(X1)), X4)) :- add_keycA(X2, X4). Afs: lsortB(x1, x2) = lsortB(x1) ---------------------------------------- (3) TriplesToPiDPProof (SOUND) We use the technique of [DT09]. With regard to the inferred argument filtering the predicates were used in the following modes: lsortB_in_2: (b,f) add_keyA_in_2: (b,f) Transforming TRIPLES into the following Term Rewriting System: Pi DP problem: The TRS P consists of the following rules: LSORTB_IN_GA(X1, X2) -> U2_GA(X1, X2, add_keyA_in_ga(X1, X3)) LSORTB_IN_GA(X1, X2) -> ADD_KEYA_IN_GA(X1, X3) ADD_KEYA_IN_GA(.(X1, X2), .(-(X3, p(X1)), X4)) -> U1_GA(X1, X2, X3, X4, add_keyA_in_ga(X2, X4)) ADD_KEYA_IN_GA(.(X1, X2), .(-(X3, p(X1)), X4)) -> ADD_KEYA_IN_GA(X2, X4) R is empty. The argument filtering Pi contains the following mapping: add_keyA_in_ga(x1, x2) = add_keyA_in_ga(x1) .(x1, x2) = .(x1, x2) -(x1, x2) = -(x2) p(x1) = p(x1) LSORTB_IN_GA(x1, x2) = LSORTB_IN_GA(x1) U2_GA(x1, x2, x3) = U2_GA(x1, x3) ADD_KEYA_IN_GA(x1, x2) = ADD_KEYA_IN_GA(x1) U1_GA(x1, x2, x3, x4, x5) = U1_GA(x1, x2, x5) We have to consider all (P,R,Pi)-chains Infinitary Constructor Rewriting Termination of PiDP implies Termination of TRIPLES ---------------------------------------- (4) Obligation: Pi DP problem: The TRS P consists of the following rules: LSORTB_IN_GA(X1, X2) -> U2_GA(X1, X2, add_keyA_in_ga(X1, X3)) LSORTB_IN_GA(X1, X2) -> ADD_KEYA_IN_GA(X1, X3) ADD_KEYA_IN_GA(.(X1, X2), .(-(X3, p(X1)), X4)) -> U1_GA(X1, X2, X3, X4, add_keyA_in_ga(X2, X4)) ADD_KEYA_IN_GA(.(X1, X2), .(-(X3, p(X1)), X4)) -> ADD_KEYA_IN_GA(X2, X4) R is empty. The argument filtering Pi contains the following mapping: add_keyA_in_ga(x1, x2) = add_keyA_in_ga(x1) .(x1, x2) = .(x1, x2) -(x1, x2) = -(x2) p(x1) = p(x1) LSORTB_IN_GA(x1, x2) = LSORTB_IN_GA(x1) U2_GA(x1, x2, x3) = U2_GA(x1, x3) ADD_KEYA_IN_GA(x1, x2) = ADD_KEYA_IN_GA(x1) U1_GA(x1, x2, x3, x4, x5) = U1_GA(x1, x2, x5) We have to consider all (P,R,Pi)-chains ---------------------------------------- (5) DependencyGraphProof (EQUIVALENT) The approximation of the Dependency Graph [LOPSTR] contains 1 SCC with 3 less nodes. ---------------------------------------- (6) Obligation: Pi DP problem: The TRS P consists of the following rules: ADD_KEYA_IN_GA(.(X1, X2), .(-(X3, p(X1)), X4)) -> ADD_KEYA_IN_GA(X2, X4) R is empty. The argument filtering Pi contains the following mapping: .(x1, x2) = .(x1, x2) -(x1, x2) = -(x2) p(x1) = p(x1) ADD_KEYA_IN_GA(x1, x2) = ADD_KEYA_IN_GA(x1) We have to consider all (P,R,Pi)-chains ---------------------------------------- (7) PiDPToQDPProof (SOUND) Transforming (infinitary) constructor rewriting Pi-DP problem [LOPSTR] into ordinary QDP problem [LPAR04] by application of Pi. ---------------------------------------- (8) Obligation: Q DP problem: The TRS P consists of the following rules: ADD_KEYA_IN_GA(.(X1, X2)) -> ADD_KEYA_IN_GA(X2) R is empty. Q is empty. We have to consider all (P,Q,R)-chains. ---------------------------------------- (9) QDPSizeChangeProof (EQUIVALENT) By using the subterm criterion [SUBTERM_CRITERION] together with the size-change analysis [AAECC05] we have proven that there are no infinite chains for this DP problem. From the DPs we obtained the following set of size-change graphs: *ADD_KEYA_IN_GA(.(X1, X2)) -> ADD_KEYA_IN_GA(X2) The graph contains the following edges 1 > 1 ---------------------------------------- (10) YES