YES
proof of /hpcwork/ff862203/termcomp26/benchmarks/Q3ugZ.pl
# AProVE Commit ID: 23a904c96b029b0a549cde0d0d17dbccf967db59 jckassing 20260626 unpublished dirty


Left Termination of the query pattern

sum(g,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, 0 ms]
(4) PiDP
(5) DependencyGraphProof [EQUIVALENT, 0 ms]
(6) PiDP
(7) PiDPToQDPProof [SOUND, 0 ms]
(8) QDP
(9) QDPSizeChangeProof [EQUIVALENT, 0 ms]
(10) YES


----------------------------------------

(0)
Obligation:
Clauses:

sum([], [], []).
sum(.(X1, Y1), .(X2, Y2), .(X3, Y3)) :- ','(add(X1, X2, X3), sum(Y1, Y2, Y3)).
add(0, X, X).
add(s(X), Y, s(Z)) :- add(X, Y, Z).


Query: sum(g,g,a)
----------------------------------------

(1) PrologToDTProblemTransformerProof (SOUND)
Built DT problem from termination graph DT10.

{
    "root": 13,
    "program": {
        "directives": [],
        "clauses": [
            [
                "(sum ([]) ([]) ([]))",
                null
            ],
            [
                "(sum (. X1 Y1) (. X2 Y2) (. X3 Y3))",
                "(',' (add X1 X2 X3) (sum Y1 Y2 Y3))"
            ],
            [
                "(add (0) X X)",
                null
            ],
            [
                "(add (s X) Y (s Z))",
                "(add X Y Z)"
            ]
        ]
    },
    "graph": {
        "nodes": {
            "99": {
                "goal": [{
                    "clause": 1,
                    "scope": 1,
                    "term": "(sum ([]) ([]) T3)"
                }],
                "kb": {
                    "nonunifying": [],
                    "intvars": {},
                    "arithmetic": {
                        "type": "PlainIntegerRelationState",
                        "relations": []
                    },
                    "ground": [],
                    "free": [],
                    "exprvars": []
                }
            },
            "13": {
                "goal": [{
                    "clause": -1,
                    "scope": -1,
                    "term": "(sum T1 T2 T3)"
                }],
                "kb": {
                    "nonunifying": [],
                    "intvars": {},
                    "arithmetic": {
                        "type": "PlainIntegerRelationState",
                        "relations": []
                    },
                    "ground": [
                        "T1",
                        "T2"
                    ],
                    "free": [],
                    "exprvars": []
                }
            },
            "14": {
                "goal": [
                    {
                        "clause": 0,
                        "scope": 1,
                        "term": "(sum T1 T2 T3)"
                    },
                    {
                        "clause": 1,
                        "scope": 1,
                        "term": "(sum T1 T2 T3)"
                    }
                ],
                "kb": {
                    "nonunifying": [],
                    "intvars": {},
                    "arithmetic": {
                        "type": "PlainIntegerRelationState",
                        "relations": []
                    },
                    "ground": [
                        "T1",
                        "T2"
                    ],
                    "free": [],
                    "exprvars": []
                }
            },
            "170": {
                "goal": [],
                "kb": {
                    "nonunifying": [],
                    "intvars": {},
                    "arithmetic": {
                        "type": "PlainIntegerRelationState",
                        "relations": []
                    },
                    "ground": [],
                    "free": [],
                    "exprvars": []
                }
            },
            "171": {
                "goal": [
                    {
                        "clause": 2,
                        "scope": 2,
                        "term": "(',' (add T10 T12 T16) (sum T11 T13 T17))"
                    },
                    {
                        "clause": 3,
                        "scope": 2,
                        "term": "(',' (add T10 T12 T16) (sum T11 T13 T17))"
                    }
                ],
                "kb": {
                    "nonunifying": [],
                    "intvars": {},
                    "arithmetic": {
                        "type": "PlainIntegerRelationState",
                        "relations": []
                    },
                    "ground": [
                        "T10",
                        "T11",
                        "T12",
                        "T13"
                    ],
                    "free": [],
                    "exprvars": []
                }
            },
            "type": "Nodes",
            "172": {
                "goal": [{
                    "clause": 2,
                    "scope": 2,
                    "term": "(',' (add T10 T12 T16) (sum T11 T13 T17))"
                }],
                "kb": {
                    "nonunifying": [],
                    "intvars": {},
                    "arithmetic": {
                        "type": "PlainIntegerRelationState",
                        "relations": []
                    },
                    "ground": [
                        "T10",
                        "T11",
                        "T12",
                        "T13"
                    ],
                    "free": [],
                    "exprvars": []
                }
            },
            "173": {
                "goal": [{
                    "clause": 3,
                    "scope": 2,
                    "term": "(',' (add T10 T12 T16) (sum T11 T13 T17))"
                }],
                "kb": {
                    "nonunifying": [],
                    "intvars": {},
                    "arithmetic": {
                        "type": "PlainIntegerRelationState",
                        "relations": []
                    },
                    "ground": [
                        "T10",
                        "T11",
                        "T12",
                        "T13"
                    ],
                    "free": [],
                    "exprvars": []
                }
            },
            "184": {
                "goal": [{
                    "clause": -1,
                    "scope": -1,
                    "term": "(',' (add T30 T31 T33) (sum T11 T13 T34))"
                }],
                "kb": {
                    "nonunifying": [],
                    "intvars": {},
                    "arithmetic": {
                        "type": "PlainIntegerRelationState",
                        "relations": []
                    },
                    "ground": [
                        "T11",
                        "T13",
                        "T30",
                        "T31"
                    ],
                    "free": [],
                    "exprvars": []
                }
            },
            "174": {
                "goal": [{
                    "clause": -1,
                    "scope": -1,
                    "term": "(sum T11 T13 T23)"
                }],
                "kb": {
                    "nonunifying": [],
                    "intvars": {},
                    "arithmetic": {
                        "type": "PlainIntegerRelationState",
                        "relations": []
                    },
                    "ground": [
                        "T11",
                        "T13"
                    ],
                    "free": [],
                    "exprvars": []
                }
            },
            "185": {
                "goal": [],
                "kb": {
                    "nonunifying": [],
                    "intvars": {},
                    "arithmetic": {
                        "type": "PlainIntegerRelationState",
                        "relations": []
                    },
                    "ground": [],
                    "free": [],
                    "exprvars": []
                }
            },
            "175": {
                "goal": [],
                "kb": {
                    "nonunifying": [],
                    "intvars": {},
                    "arithmetic": {
                        "type": "PlainIntegerRelationState",
                        "relations": []
                    },
                    "ground": [],
                    "free": [],
                    "exprvars": []
                }
            },
            "100": {
                "goal": [],
                "kb": {
                    "nonunifying": [],
                    "intvars": {},
                    "arithmetic": {
                        "type": "PlainIntegerRelationState",
                        "relations": []
                    },
                    "ground": [],
                    "free": [],
                    "exprvars": []
                }
            },
            "169": {
                "goal": [{
                    "clause": -1,
                    "scope": -1,
                    "term": "(',' (add T10 T12 T16) (sum T11 T13 T17))"
                }],
                "kb": {
                    "nonunifying": [],
                    "intvars": {},
                    "arithmetic": {
                        "type": "PlainIntegerRelationState",
                        "relations": []
                    },
                    "ground": [
                        "T10",
                        "T11",
                        "T12",
                        "T13"
                    ],
                    "free": [],
                    "exprvars": []
                }
            },
            "90": {
                "goal": [{
                    "clause": 1,
                    "scope": 1,
                    "term": "(sum T1 T2 T3)"
                }],
                "kb": {
                    "nonunifying": [[
                        "(sum T1 T2 T3)",
                        "(sum ([]) ([]) ([]))"
                    ]],
                    "intvars": {},
                    "arithmetic": {
                        "type": "PlainIntegerRelationState",
                        "relations": []
                    },
                    "ground": [
                        "T1",
                        "T2"
                    ],
                    "free": [],
                    "exprvars": []
                }
            },
            "73": {
                "goal": [
                    {
                        "clause": -1,
                        "scope": -1,
                        "term": "(true)"
                    },
                    {
                        "clause": 1,
                        "scope": 1,
                        "term": "(sum ([]) ([]) T3)"
                    }
                ],
                "kb": {
                    "nonunifying": [],
                    "intvars": {},
                    "arithmetic": {
                        "type": "PlainIntegerRelationState",
                        "relations": []
                    },
                    "ground": [],
                    "free": [],
                    "exprvars": []
                }
            }
        },
        "edges": [
            {
                "from": 13,
                "to": 14,
                "label": "CASE"
            },
            {
                "from": 14,
                "to": 73,
                "label": "EVAL with clause\nsum([], [], []).\nand substitutionT1 -> [],\nT2 -> [],\nT3 -> []"
            },
            {
                "from": 14,
                "to": 90,
                "label": "EVAL-BACKTRACK"
            },
            {
                "from": 73,
                "to": 99,
                "label": "SUCCESS"
            },
            {
                "from": 90,
                "to": 169,
                "label": "EVAL with clause\nsum(.(X16, X17), .(X18, X19), .(X20, X21)) :- ','(add(X16, X18, X20), sum(X17, X19, X21)).\nand substitutionX16 -> T10,\nX17 -> T11,\nT1 -> .(T10, T11),\nX18 -> T12,\nX19 -> T13,\nT2 -> .(T12, T13),\nX20 -> T16,\nX21 -> T17,\nT3 -> .(T16, T17),\nT14 -> T16,\nT15 -> T17"
            },
            {
                "from": 90,
                "to": 170,
                "label": "EVAL-BACKTRACK"
            },
            {
                "from": 99,
                "to": 100,
                "label": "BACKTRACK\nfor clause: sum(.(X1, Y1), .(X2, Y2), .(X3, Y3)) :- ','(add(X1, X2, X3), sum(Y1, Y2, Y3))because of non-unification"
            },
            {
                "from": 169,
                "to": 171,
                "label": "CASE"
            },
            {
                "from": 171,
                "to": 172,
                "label": "PARALLEL"
            },
            {
                "from": 171,
                "to": 173,
                "label": "PARALLEL"
            },
            {
                "from": 172,
                "to": 174,
                "label": "EVAL with clause\nadd(0, X26, X26).\nand substitutionT10 -> 0,\nT12 -> T22,\nX26 -> T22,\nT16 -> T22,\nT17 -> T23"
            },
            {
                "from": 172,
                "to": 175,
                "label": "EVAL-BACKTRACK"
            },
            {
                "from": 173,
                "to": 184,
                "label": "EVAL with clause\nadd(s(X33), X34, s(X35)) :- add(X33, X34, X35).\nand substitutionX33 -> T30,\nT10 -> s(T30),\nT12 -> T31,\nX34 -> T31,\nX35 -> T33,\nT16 -> s(T33),\nT32 -> T33,\nT17 -> T34"
            },
            {
                "from": 173,
                "to": 185,
                "label": "EVAL-BACKTRACK"
            },
            {
                "from": 174,
                "to": 13,
                "label": "INSTANCE with matching:\nT1 -> T11\nT2 -> T13\nT3 -> T23"
            },
            {
                "from": 184,
                "to": 169,
                "label": "INSTANCE with matching:\nT10 -> T30\nT12 -> T31\nT16 -> T33\nT17 -> T34"
            }
        ],
        "type": "Graph"
    }
}

----------------------------------------

(2)
Obligation:
Triples:

pB(0, X1, X1, X2, X3, X4) :- sumA(X2, X3, X4).
pB(s(X1), X2, s(X3), X4, X5, X6) :- pB(X1, X2, X3, X4, X5, X6).
sumA(.(X1, X2), .(X3, X4), .(X5, X6)) :- pB(X1, X3, X5, X2, X4, X6).

Clauses:

sumcA([], [], []).
sumcA(.(X1, X2), .(X3, X4), .(X5, X6)) :- qcB(X1, X3, X5, X2, X4, X6).
qcB(0, X1, X1, X2, X3, X4) :- sumcA(X2, X3, X4).
qcB(s(X1), X2, s(X3), X4, X5, X6) :- qcB(X1, X2, X3, X4, X5, X6).

Afs:

sumA(x1, x2, x3)  =  sumA(x1, x2)


----------------------------------------

(3) TriplesToPiDPProof (SOUND)
We use the technique of [DT09]. With regard to the inferred argument filtering the predicates were used in the following modes:

sumA_in_3: (b,b,f)

pB_in_6: (b,b,f,b,b,f)

Transforming TRIPLES into the following Term Rewriting System:

Pi DP problem:
The TRS P consists of the following rules:

   SUMA_IN_GGA(.(X1, X2), .(X3, X4), .(X5, X6)) -> U3_GGA(X1, X2, X3, X4, X5, X6, pB_in_ggagga(X1, X3, X5, X2, X4, X6))
   SUMA_IN_GGA(.(X1, X2), .(X3, X4), .(X5, X6)) -> PB_IN_GGAGGA(X1, X3, X5, X2, X4, X6)
   PB_IN_GGAGGA(0, X1, X1, X2, X3, X4) -> U1_GGAGGA(X1, X2, X3, X4, sumA_in_gga(X2, X3, X4))
   PB_IN_GGAGGA(0, X1, X1, X2, X3, X4) -> SUMA_IN_GGA(X2, X3, X4)
   PB_IN_GGAGGA(s(X1), X2, s(X3), X4, X5, X6) -> U2_GGAGGA(X1, X2, X3, X4, X5, X6, pB_in_ggagga(X1, X2, X3, X4, X5, X6))
   PB_IN_GGAGGA(s(X1), X2, s(X3), X4, X5, X6) -> PB_IN_GGAGGA(X1, X2, X3, X4, X5, X6)

R is empty.
The argument filtering Pi contains the following mapping:
sumA_in_gga(x1, x2, x3)  =  sumA_in_gga(x1, x2)

.(x1, x2)  =  .(x1, x2)

pB_in_ggagga(x1, x2, x3, x4, x5, x6)  =  pB_in_ggagga(x1, x2, x4, x5)

0  =  0

s(x1)  =  s(x1)

SUMA_IN_GGA(x1, x2, x3)  =  SUMA_IN_GGA(x1, x2)

U3_GGA(x1, x2, x3, x4, x5, x6, x7)  =  U3_GGA(x1, x2, x3, x4, x7)

PB_IN_GGAGGA(x1, x2, x3, x4, x5, x6)  =  PB_IN_GGAGGA(x1, x2, x4, x5)

U1_GGAGGA(x1, x2, x3, x4, x5)  =  U1_GGAGGA(x1, x2, x3, x5)

U2_GGAGGA(x1, x2, x3, x4, x5, x6, x7)  =  U2_GGAGGA(x1, x2, x4, x5, x7)


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:

   SUMA_IN_GGA(.(X1, X2), .(X3, X4), .(X5, X6)) -> U3_GGA(X1, X2, X3, X4, X5, X6, pB_in_ggagga(X1, X3, X5, X2, X4, X6))
   SUMA_IN_GGA(.(X1, X2), .(X3, X4), .(X5, X6)) -> PB_IN_GGAGGA(X1, X3, X5, X2, X4, X6)
   PB_IN_GGAGGA(0, X1, X1, X2, X3, X4) -> U1_GGAGGA(X1, X2, X3, X4, sumA_in_gga(X2, X3, X4))
   PB_IN_GGAGGA(0, X1, X1, X2, X3, X4) -> SUMA_IN_GGA(X2, X3, X4)
   PB_IN_GGAGGA(s(X1), X2, s(X3), X4, X5, X6) -> U2_GGAGGA(X1, X2, X3, X4, X5, X6, pB_in_ggagga(X1, X2, X3, X4, X5, X6))
   PB_IN_GGAGGA(s(X1), X2, s(X3), X4, X5, X6) -> PB_IN_GGAGGA(X1, X2, X3, X4, X5, X6)

R is empty.
The argument filtering Pi contains the following mapping:
sumA_in_gga(x1, x2, x3)  =  sumA_in_gga(x1, x2)

.(x1, x2)  =  .(x1, x2)

pB_in_ggagga(x1, x2, x3, x4, x5, x6)  =  pB_in_ggagga(x1, x2, x4, x5)

0  =  0

s(x1)  =  s(x1)

SUMA_IN_GGA(x1, x2, x3)  =  SUMA_IN_GGA(x1, x2)

U3_GGA(x1, x2, x3, x4, x5, x6, x7)  =  U3_GGA(x1, x2, x3, x4, x7)

PB_IN_GGAGGA(x1, x2, x3, x4, x5, x6)  =  PB_IN_GGAGGA(x1, x2, x4, x5)

U1_GGAGGA(x1, x2, x3, x4, x5)  =  U1_GGAGGA(x1, x2, x3, x5)

U2_GGAGGA(x1, x2, x3, x4, x5, x6, x7)  =  U2_GGAGGA(x1, x2, x4, x5, x7)


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:

   SUMA_IN_GGA(.(X1, X2), .(X3, X4), .(X5, X6)) -> PB_IN_GGAGGA(X1, X3, X5, X2, X4, X6)
   PB_IN_GGAGGA(0, X1, X1, X2, X3, X4) -> SUMA_IN_GGA(X2, X3, X4)
   PB_IN_GGAGGA(s(X1), X2, s(X3), X4, X5, X6) -> PB_IN_GGAGGA(X1, X2, X3, X4, X5, X6)

R is empty.
The argument filtering Pi contains the following mapping:
.(x1, x2)  =  .(x1, x2)

0  =  0

s(x1)  =  s(x1)

SUMA_IN_GGA(x1, x2, x3)  =  SUMA_IN_GGA(x1, x2)

PB_IN_GGAGGA(x1, x2, x3, x4, x5, x6)  =  PB_IN_GGAGGA(x1, x2, x4, x5)


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:

   SUMA_IN_GGA(.(X1, X2), .(X3, X4)) -> PB_IN_GGAGGA(X1, X3, X2, X4)
   PB_IN_GGAGGA(0, X1, X2, X3) -> SUMA_IN_GGA(X2, X3)
   PB_IN_GGAGGA(s(X1), X2, X4, X5) -> PB_IN_GGAGGA(X1, X2, X4, X5)

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:
*PB_IN_GGAGGA(0, X1, X2, X3) -> SUMA_IN_GGA(X2, X3)
The graph contains the following edges 3 >= 1, 4 >= 2


*PB_IN_GGAGGA(s(X1), X2, X4, X5) -> PB_IN_GGAGGA(X1, X2, X4, X5)
The graph contains the following edges 1 > 1, 2 >= 2, 3 >= 3, 4 >= 4


*SUMA_IN_GGA(.(X1, X2), .(X3, X4)) -> PB_IN_GGAGGA(X1, X3, X2, X4)
The graph contains the following edges 1 > 1, 2 > 2, 1 > 3, 2 > 4


----------------------------------------

(10)
YES
