{"title":"A devil's advocate against termination of direct recursion","authors":"Thom W. Frühwirth","doi":"10.1145/2790449.2790518","DOIUrl":null,"url":null,"abstract":"A devil's advocate is one who argues against a claim, not as a committed opponent but in order to determine the validity of the claim. We are interested in a devil's advocate that argues against termination of a program. He does so by producing a maleficent program that can cause the non-termination of the original program. By inspecting and running the malicious program, one may gain insight into the potential reasons for non-termination and produce counterexamples for termination. We introduce our method in the concurrent programming language Constraint Handling Rules (CHR). Like in other declarative languages, non-termination occurs through unbounded recursion. Given a self-recursive rule, we automatically generate one or more devil's rules from it. The construction of the devil's rules is straight-forward and involves no guessing. The devil's rules can be simple. For example, they are non-recursive for rules with single recursion. We show that the devil's rules are maximally vicious in the following sense: For any program that contains the self-recursive rule and for any infinite computation through that rule in that program, there is a corresponding infinite computation with the recursive rule and the devil's rules alone. In that case, the malicious rules serve as a finite witness for non-termination. On the other hand, if the devil's rules do not exhibit an infinite computation, the recursive rule is unconditionally terminating. We also identify cases where the static analysis of the devil's rule decides termination or non-termination of the recursive rule.","PeriodicalId":445788,"journal":{"name":"Proceedings of the 17th International Symposium on Principles and Practice of Declarative Programming","volume":"18 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2015-07-14","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"5","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the 17th International Symposium on Principles and Practice of Declarative Programming","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/2790449.2790518","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 5
Abstract
A devil's advocate is one who argues against a claim, not as a committed opponent but in order to determine the validity of the claim. We are interested in a devil's advocate that argues against termination of a program. He does so by producing a maleficent program that can cause the non-termination of the original program. By inspecting and running the malicious program, one may gain insight into the potential reasons for non-termination and produce counterexamples for termination. We introduce our method in the concurrent programming language Constraint Handling Rules (CHR). Like in other declarative languages, non-termination occurs through unbounded recursion. Given a self-recursive rule, we automatically generate one or more devil's rules from it. The construction of the devil's rules is straight-forward and involves no guessing. The devil's rules can be simple. For example, they are non-recursive for rules with single recursion. We show that the devil's rules are maximally vicious in the following sense: For any program that contains the self-recursive rule and for any infinite computation through that rule in that program, there is a corresponding infinite computation with the recursive rule and the devil's rules alone. In that case, the malicious rules serve as a finite witness for non-termination. On the other hand, if the devil's rules do not exhibit an infinite computation, the recursive rule is unconditionally terminating. We also identify cases where the static analysis of the devil's rule decides termination or non-termination of the recursive rule.