Presentation is loading. Please wait.

Presentation is loading. Please wait.

A Resource-based Logic for Termination and Non-Termination Proofs Ton Chanh Le Cristian Gherghina Aquinas Hobor Wei-Ngan Chin National University of Singapore.

Similar presentations


Presentation on theme: "A Resource-based Logic for Termination and Non-Termination Proofs Ton Chanh Le Cristian Gherghina Aquinas Hobor Wei-Ngan Chin National University of Singapore."— Presentation transcript:

1 A Resource-based Logic for Termination and Non-Termination Proofs Ton Chanh Le Cristian Gherghina Aquinas Hobor Wei-Ngan Chin National University of Singapore 1ICFEM 2014

2 A Resource-based Logic for Termination and Non-Termination Proofs ICFEM 20142

3 Hoare Logic for Partial Correctness Proving Partial Correctness ICFEM 20143

4 Hoare Logic for Total Correctness Proving Termination ICFEM 20144

5 Hoare Logic for Total Correctness Proving Non-Termination ICFEM 20145

6 (Non-)Termination Specification “So-called partial correctness is inadequate: if a program is intended to terminate, that fact must be part of its specification.” – Cliff Jones Non-termination specification is also important for More comprehensive specifications to understand program better A clearer distinction between expected non-termination and failure of termination proofs ICFEM 20146

7 Research Questions requires x ≥ 0  y < 0 variance x ensures true; requires x ≥ 0  y ≥ 0 ensures false; ICFEM 20147 Is the separation between termination and non- termination specifications good? while (x ≥ 0) { x = x + y; }

8 Research Questions requires x ≥ 0  y < 0 variance x ensures true; requires x ≥ 0  y ≥ 0 ensures false; ICFEM 20148 How can the termination and non-termination specifications be unified? while (x ≥ 0) { x = x + y; }

9 A Unified Specification Logic A unified logical foundation for both termination and non-termination reasoning Integration of termination and non-termination specifications into expressive logics for functional correctness and safety verification ICFEM 20149

10 Temporal Predicates Term M : termination Loop : definite non-termination MayLoop : possible non-termination ICFEM 201410

11 Example while (x ≥ 0) { x = x + y; } requires (x ≥ 0  y < 0  Term[x])  (x ≥ 0  y ≥ 0  Loop) ensures (x ≥ 0  y ≥ 0  false); ICFEM 201411

12 Example while (x ≥ 0) { x = x + y; } case { x requires Term ensures true; x ≥ 0 -> case { y ≥ 0 -> requires Loop ensures false; y requires Term[x] ensures true; } ICFEM 201412

13 A Resource-based Logic for Termination and Non-Termination Proofs ICFEM 201413

14 Foundation for Specification Logic Solution: Consider non-termination and termination as resources. Our proposal: A new logic for consumable resources which captures the concept of resource capacity; tracking both minimum and maximum of resource usage ICFEM 201414

15 Resource Assertions ICFEM 201415

16 Temporal Entailment ICFEM 201416

17 Flow-Insensitive Temporal Entailment ICFEM 201417

18 HipTNT: A Termination Verification System ICFEM 201418 http://loris-7.ddns.comp.nus.edu.sg/~project/hiptnt

19 HipTNT+: A Termination Inference System void loop (int x, int y) { if (x < 0) return; else loop(x + y, y); } ICFEM 201419 http://loris-7.ddns.comp.nus.edu.sg/~project/hiptnt

20 HipTNT+: A Termination Inference System void loop (int x, int y) { if (x < 0) return; else loop(x + y, y - 1); } ICFEM 201420 http://loris-7.ddns.comp.nus.edu.sg/~project/hiptnt

21 HipTNT+: A Termination Inference System int Ack(int m, int n) { if (m == 0) return n + 1; else if (n == 0) return Ack(m-1, 1); else return Ack(m-1, Ack(m, n-1)); } ICFEM 201421 http://loris-7.ddns.comp.nus.edu.sg/~project/hiptnt

22 HipTNT+: A Termination Inference System int Ack(int m, int n) case { m requires Loop ensures false; m = 0 -> requires Term ensures res = n + 1; m > 0  n requires Loop ensures false; m > 0  n ≥ 0 -> requires Term[m, n] ensures res ≥ n + 1; } ICFEM 201422 http://loris-7.ddns.comp.nus.edu.sg/~project/hiptnt

23 Conclusions “Termination and Non-Termination as Resources” provides a unified framework to combine both partial correctness and (non-)termination verification The termination inference can benefit from mechanisms developed for safety verification, such as shape inference ICFEM 201423


Download ppt "A Resource-based Logic for Termination and Non-Termination Proofs Ton Chanh Le Cristian Gherghina Aquinas Hobor Wei-Ngan Chin National University of Singapore."

Similar presentations


Ads by Google