$ cora sumaccumulator.lcstrs -s yices -e LCSTRS with only rule scheme Calc: Signature: add :: Int → Unit → Unit return :: Int → Unit sum1 :: Int → Unit sum2 :: Int → Unit sum3 :: Int → Unit u :: Int → Int → Int → Unit v :: Int → Int → Unit Rules: sum1(x) → u(x, 1, 0) u(x, i, z) → u(x, i + 1, z + i) | i ≤ x u(x, i, z) → return(z) | i > x sum2(x) → add(x, sum2(x - 1)) | x > 0 sum2(x) → return(0) | x ≤ 0 add(x, return(y)) → return(x + y) sum3(x) → v(x, 0) v(x, z) → v(x - 1, z + x) | x > 0 v(x, z) → return(z) | x ≤ 0 Please input one or more equations, or a file: sum2(x) = sum3(x) Goal: sum2(x) ≈ sum3(x) > simplify Goal: sum2(x) ≈ v(x, 0) > induct Goal: sum2(x) ⦾ ≈ v(x, 0) ⦾ > case x > 0 Goal: sum2(x) ⦾ ≈ v(x, 0) ⦾ | ¬(x > 0) > auto simplify R5 l with [x := x] simplify R9 r with [x := x, z := 0] delete Goal: sum2(x) ⦾ ≈ v(x, 0) ⦾ | x > 0 > auto simplify R4 l with [x := x] calc l2.1 simplify R8 r with [x := x, z := 0] calc r1 calc r2 Goal: add(x, sum2(x1)) ≈ v(x1, x2) | x > 0 ∧ x1 = x - 1 ∧ x2 = 0 + x > :hypotheses You currently have the following induction hypotheses available: H2: sum2(x) ≈ v(x, 0) Goal: add(x, sum2(x1)) ≈ v(x1, x2) | x > 0 ∧ x1 = x - 1 ∧ x2 = 0 + x > hypothesis H2 l2 Goal: add(x, v(x1, 0)) ≈ v(x1, x2) | x > 0 ∧ x1 = x - 1 ∧ x2 = 0 + x > simplify I could not find any simplification step to apply. Goal: add(x, v(x1, 0)) ≈ v(x1, x2) | x > 0 ∧ x1 = x - 1 ∧ x2 = 0 + x > generalise subterm 0 as z Goal: add(x, v(x1, z)) ⦾ ≈ v(x1, x2) ⦾ | x > z ∧ x1 = x - 1 ∧ x2 = z + x > alter rename x1 := y, x2 := a Goal: add(x, v(y, z)) ⦾ ≈ v(y, a) ⦾ | x > z ∧ y = x - 1 ∧ a = z + x > generalise drop x > z /\ y = x - 1 Goal: add(x, v(y, z)) ⦾ ≈ v(y, a) ⦾ | a = z + x > induct Goal: add(x, v(y, z)) ⦾ ≈ v(y, a) ⦾ | a = z + x > case y > 0 Goal: add(x, v(y, z)) ⦾ ≈ v(y, a) ⦾ | a = z + x ∧ ¬(y > 0) > auto simplify R9 l2 with [x := y, z := z] simplify R6 l with [x := x, y := z] calc l1 simplify R9 r with [x := y, z := a] context 1 eq-delete Goal: add(x, v(y, z)) ⦾ ≈ v(y, a) ⦾ | a = z + x ∧ y > 0 > auto simplify R8 l2 with [x := y, z := z] calc l2.1 calc l2.2 simplify R8 r with [x := y, z := a] calc r1 calc r2 hdelete H16 l with [a := z2, x := x, y := y1, z := z1] All goals have been successfully removed! To complete the proof, you still need to verify that a suitable ordering exists. You can do this using the :check command. Other useful commands include: undo -- to go back to the previous proof state :quit -- to end the proof process without termination check :ordering -- to see the current ordering requirements :rules -- to see the current rules (these must also be oriented) :check verbose -- to run the termination check and see an elaborate explanation of the outcome (particularly useful if the result is a failure) > :ordering So far the following ordering requirements have been imposed: sum2(x) ≻ add(x, v(x1, 0)) | x > 0 ∧ x1 = x - 1 ∧ x2 = 0 + x All goals have been successfully removed! To complete the proof, you still need to verify that a suitable ordering exists. You can do this using the :check command. Other useful commands include: undo -- to go back to the previous proof state :quit -- to end the proof process without termination check :ordering -- to see the current ordering requirements :rules -- to see the current rules (these must also be oriented) :check verbose -- to run the termination check and see an elaborate explanation of the outcome (particularly useful if the result is a failure) > :save sumaccumulator.proof Original equations and command history have been written to sumaccumulator.proof. All goals have been successfully removed! To complete the proof, you still need to verify that a suitable ordering exists. You can do this using the :check command. Other useful commands include: undo -- to go back to the previous proof state :quit -- to end the proof process without termination check :ordering -- to see the current ordering requirements :rules -- to see the current rules (these must also be oriented) :check verbose -- to run the termination check and see an elaborate explanation of the outcome (particularly useful if the result is a failure) > :check Sending proof request to termination checker... The current set of ordering requirements is indeed orientable. YES We start the process with the following equations: E1: (• , sum2(x) ≈ sum3(x) , •) We apply SIMPLIFICATION to E1 with rule R7 and substitution [x := x]. This yields E2: (• , sum2(x) ≈ v(x, 0) , •) We apply INDUCT to E2, which causes sum2(x) ≈ v(x, 0) to be added to the set H of induction hypotheses. This yields E3: (sum2(x) , sum2(x) ≈ v(x, 0) , v(x, 0)) We apply CASE on the constraint x > 0. This yields the following new equations: E4: (sum2(x) , sum2(x) ≈ v(x, 0) | x > 0 , v(x, 0)) E5: (sum2(x) , sum2(x) ≈ v(x, 0) | ¬(x > 0) , v(x, 0)) We apply SIMPLIFICATION to E5 with rule R5 and substitution [x := x]. This yields E6: (sum2(x) , return(0) ≈ v(x, 0) | ¬(x > 0) , v(x, 0)) We apply SIMPLIFICATION to E6 with rule R9 and substitution [x := x, z := 0]. This yields E7: (sum2(x) , return(0) ≈ return(0) | ¬(x > 0) , v(x, 0)) We apply DELETION to E7 because both sides are equal. Thus, we may remove this equation from the proof state. We apply SIMPLIFICATION to E4 with rule R4 and substitution [x := x]. This yields E8: (sum2(x) , add(x, sum2(x - 1)) ≈ v(x, 0) | x > 0 , v(x, 0)) We use ALTER to add x1 = x - 1 to the constraint, and then use CALC at position l2.1. This yields E9: (sum2(x) , add(x, sum2(x1)) ≈ v(x, 0) | x > 0 ∧ x1 = x - 1 , v(x, 0)) We apply SIMPLIFICATION to E9 with rule R8 and substitution [x := x, z := 0]. This yields E10: (sum2(x) , add(x, sum2(x1)) ≈ v(x - 1, 0 + x) | x > 0 ∧ x1 = x - 1 , v(x, 0)) We use CALC at position r1. This yields E11: (sum2(x) , add(x, sum2(x1)) ≈ v(x1, 0 + x) | x > 0 ∧ x1 = x - 1 , v(x, 0)) We use ALTER to add x2 = 0 + x to the constraint, and then use CALC at position r2. This yields E12: (sum2(x) , add(x, sum2(x1)) ≈ v(x1, x2) | x > 0 ∧ x1 = x - 1 ∧ x2 = 0 + x , v(x, 0)) We apply HYPOTHESIS to E12 with induction hypothesis H2 and substitution [x := x1]. To this end, we impose the requirement that sum2(x) ≻ add(x, v(x1, 0)) | x > 0 ∧ x1 = x - 1 ∧ x2 = 0 + x. This yields E13: (sum2(x) , add(x, v(x1, 0)) ≈ v(x1, x2) | x > 0 ∧ x1 = x - 1 ∧ x2 = 0 + x , v(x, 0)) We apply GENERALISE to replace the equation context E13 by E14: (add(x, v(x1, z)) , add(x, v(x1, z)) ≈ v(x1, x2) | x > z ∧ x1 = x - 1 ∧ x2 = z + x , v(x1, x2)). This yields E14: (add(x, v(x1, z)) , add(x, v(x1, z)) ≈ v(x1, x2) | x > z ∧ x1 = x - 1 ∧ x2 = z + x , v(x1, x2)) We apply ALTER to rename variables using the substitution [x1 := y, x2 := a]. This yields E15: (add(x, v(y, z)) , add(x, v(y, z)) ≈ v(y, a) | x > z ∧ y = x - 1 ∧ a = z + x , v(y, a)) We apply GENERALISE to replace the constraint of E15 by a = z + x. This yields E16: (add(x, v(y, z)) , add(x, v(y, z)) ≈ v(y, a) | a = z + x , v(y, a)) We apply INDUCT to E16, which causes add(x, v(y, z)) ≈ v(y, a) | a = z + x to be added to the set H of induction hypotheses. We apply CASE on the constraint y > 0. This yields the following new equations: E17: (add(x, v(y, z)) , add(x, v(y, z)) ≈ v(y, a) | a = z + x ∧ y > 0 , v(y, a)) E18: (add(x, v(y, z)) , add(x, v(y, z)) ≈ v(y, a) | a = z + x ∧ ¬(y > 0) , v(y, a)) We apply SIMPLIFICATION to E18 with rule R9 and substitution [x := y, z := z]. This yields E19: (add(x, v(y, z)) , add(x, return(z)) ≈ v(y, a) | a = z + x ∧ ¬(y > 0) , v(y, a)) We apply SIMPLIFICATION to E19 with rule R6 and substitution [x := x, y := z]. This yields E20: (add(x, v(y, z)) , return(x + z) ≈ v(y, a) | a = z + x ∧ ¬(y > 0) , v(y, a)) We use ALTER to add y1 = x + z to the constraint, and then use CALC at position l1. This yields E21: (add(x, v(y, z)) , return(y1) ≈ v(y, a) | a = z + x ∧ ¬(y > 0) ∧ y1 = x + z , v(y, a)) We apply SIMPLIFICATION to E21 with rule R9 and substitution [x := y, z := a]. This yields E22: (add(x, v(y, z)) , return(y1) ≈ return(a) | a = z + x ∧ ¬(y > 0) ∧ y1 = x + z , v(y, a)) We apply CONTEXT to E22, splitting the immediate arguments into separate equations. This yields E23: (add(x, v(y, z)) , y1 ≈ a | a = z + x ∧ ¬(y > 0) ∧ y1 = x + z , v(y, a)) We observe that a = z + x ∧ ¬(y > 0) ∧ y1 = x + z ⊨ y1 = a, and may therefore apply EQ-DELETION to remove E23 from the proof state. We apply SIMPLIFICATION to E17 with rule R8 and substitution [x := y, z := z]. This yields E24: (add(x, v(y, z)) , add(x, v(y - 1, z + y)) ≈ v(y, a) | a = z + x ∧ y > 0 , v(y, a)) We use ALTER to add y1 = y - 1 to the constraint, and then use CALC at position l2.1. This yields E25: (add(x, v(y, z)) , add(x, v(y1, z + y)) ≈ v(y, a) | a = z + x ∧ y > 0 ∧ y1 = y - 1 , v(y, a)) We use ALTER to add z1 = z + y to the constraint, and then use CALC at position l2.2. This yields E26: (add(x, v(y, z)) , add(x, v(y1, z1)) ≈ v(y, a) | a = z + x ∧ y > 0 ∧ y1 = y - 1 ∧ z1 = z + y , v(y, a)) We apply SIMPLIFICATION to E26 with rule R8 and substitution [x := y, z := a]. This yields E27: (add(x, v(y, z)) , add(x, v(y1, z1)) ≈ v(y - 1, a + y) | a = z + x ∧ y > 0 ∧ y1 = y - 1 ∧ z1 = z + y , v(y, a)) We use CALC at position r1. This yields E28: (add(x, v(y, z)) , add(x, v(y1, z1)) ≈ v(y1, a + y) | a = z + x ∧ y > 0 ∧ y1 = y - 1 ∧ z1 = z + y , v(y, a)) We use ALTER to add z2 = a + y to the constraint, and then use CALC at position r2. This yields E29: (add(x, v(y, z)) , add(x, v(y1, z1)) ≈ v(y1, z2) | a = z + x ∧ y > 0 ∧ y1 = y - 1 ∧ z1 = z + y ∧ z2 = a + y , v(y, a)) We apply HDELETE to E29 with induction hypothesis H16 and substitution [a := z2, x := x, y := y1, z := z1]. All equations have been removed, so the proof is complete: the original equations are inductive theorems. The existence of a suitable bounding pair is guaranteed by the termination of the corresponding term rewriting systems, as is demonstrated below. We consider termination of the LCSTRS with only rule scheme Calc: Signature: add :: Int → Unit → Unit return :: Int → Unit sum1 :: Int → Unit sum2 :: Int → Unit sum3 :: Int → Unit u :: Int → Int → Int → Unit v :: Int → Int → Unit Rules: sum1(x) → u(x, 1, 0) u(x, i, z) → u(x, i + 1, z + i) | i ≤ x u(x, i, z) → return(z) | i > x sum2(x) → add(x, sum2(x - 1)) | x > 0 sum2(x) → return(0) | x ≤ 0 add(x, return(y)) → return(x + y) sum3(x) → v(x, 0) v(x, z) → v(x - 1, z + x) | x > 0 v(x, z) → return(z) | x ≤ 0 sum2(x__1) → add(x__1, v(x__2, 0)) | x__1 > 0 ∧ x__2 = x__1 - 1 ∧ x__3 = 0 + x__1 The system is accessible function passing by a sort ordering that equates all sorts. We start by computing the initial DP problem D1 = (P1, R, f, c), where: P1. (1) sum1#(x) ➡ u#(x, 1, 0) (2) u#(x, i, z) ➡ u#(x, i + 1, z + i) | i ≤ x (3) sum2#(x) ➡ sum2#(x - 1) | x > 0 (4) sum2#(x) ➡ add#(x, sum2(x - 1)) | x > 0 (5) sum3#(x) ➡ v#(x, 0) (6) v#(x, z) ➡ v#(x - 1, z + x) | x > 0 (7) sum2#(x__1) ➡ v#(x__2, 0) | x__1 > 0 ∧ x__2 = x__1 - 1 ∧ x__3 = 0 + x__1 (8) sum2#(x__1) ➡ add#(x__1, v(x__2, 0)) | x__1 > 0 ∧ x__2 = x__1 - 1 ∧ x__3 = 0 + x__1 ***** We apply the Graph Processor on D1 = (P1, R, f, c). We compute a graph approximation with the following edges: 1: 2 2: 2 3: 3 4 7 8 4: 5: 6 6: 6 7: 6 8: There are 3 SCCs. Processor output: { D2 = (P2, R, f, c) ; D3 = (P3, R, f, c) ; D4 = (P4, R, f, c) }, where: P2. (1) u#(x, i, z) ➡ u#(x, i + 1, z + i) | i ≤ x P3. (1) v#(x, z) ➡ v#(x - 1, z + x) | x > 0 P4. (1) sum2#(x) ➡ sum2#(x - 1) | x > 0 ***** We apply the Integer Function Processor on D2 = (P2, R, f, c). We use the following integer mapping: J(u#) = arg_1 - arg_2 We thus have: (1) i ≤ x ⊨ x - i > x - (i + 1) (and x - i ≥ 0) All DPs are strictly oriented, and may be removed. Hence, this DP problem is finite. Processor output: { }. ***** We apply the Integer Function Processor on D3 = (P3, R, f, c). We use the following integer mapping: J(v#) = arg_1 + 1 We thus have: (1) x > 0 ⊨ x + 1 > x - 1 + 1 (and x + 1 ≥ 0) All DPs are strictly oriented, and may be removed. Hence, this DP problem is finite. Processor output: { }. ***** We apply the Integer Function Processor on D4 = (P4, R, f, c). We use the following integer mapping: J(sum2#) = arg_1 + 1 We thus have: (1) x > 0 ⊨ x + 1 > x - 1 + 1 (and x + 1 ≥ 0) All DPs are strictly oriented, and may be removed. Hence, this DP problem is finite. Processor output: { }. Steps: simplify R7 r with [x := x] induct case x > 0 simplify R5 l with [x := x] simplify R9 r with [x := x, z := 0] delete simplify R4 l with [x := x] calc l2.1 simplify R8 r with [x := x, z := 0] calc r1 calc r2 hypothesis H2 l2 with [x := x1] generalise subterm 0 as z alter rename x1 := y, x2 := a generalise drop x > z /\ y =_Int x - 1 induct case y > 0 simplify R9 l2 with [x := y, z := z] simplify R6 l with [x := x, y := z] calc l1 simplify R9 r with [x := y, z := a] context 1 eq-delete simplify R8 l2 with [x := y, z := z] calc l2.1 calc l2.2 simplify R8 r with [x := y, z := a] calc r1 calc r2 hdelete H16 l with [a := z2, x := x, y := y1, z := z1]