Hybrid Verification of Declarative Programs with Arithmetic Non-fail Conditions

被引:0
作者
Hanus, Michael [1 ]
机构
[1] Univ Kiel, Inst Informat, Kiel, Germany
来源
PROGRAMMING LANGUAGES AND SYSTEMS, APLAS 2024 | 2025年 / 15194卷
关键词
D O I
10.1007/978-981-97-8943-6_6
中图分类号
TP18 [人工智能理论];
学科分类号
081104 ; 0812 ; 0835 ; 1405 ;
摘要
Functions containing arithmetic operations have often restrictions not expressible by standard type systems of programming languages. The division operation requires that the divisor is non-zero and the factorial function should not be applied to negative numbers. Such partial operations might lead to program crashes if they are applied to unintended arguments. Checking the arguments before each call is tedious and decreases the run-time efficiency. To avoid these disadvantages and support the safe use of partially defined operations, we present an approach to verify the correct use of operations at compile time. To simplify its use, our approach automatically infers non-fail conditions of operations from their definitions and checks whether these conditions are satisfied for all uses of the operations. Arithmetic conditions can be verified by SMT solvers, whereas conditions in operations defined on algebraic data types can be inferred and verified by appropriate type abstractions. Therefore, we present a hybrid method which is applicable to larger programs since only a few arithmetic non-fail conditions need to be checked by an external SMT solver. This approach is implemented for functional logic Curry programs so that it is also usable for purely functional or logic programs.
引用
收藏
页码:109 / 129
页数:21
相关论文
共 37 条
[1]   Operational semantics for declarative multi-paradigm languages [J].
Albert, E ;
Hanus, M ;
Huch, F ;
Oliver, J ;
Vidal, G .
JOURNAL OF SYMBOLIC COMPUTATION, 2005, 40 (01) :795-829
[2]  
Antoy Sergio, 2020, Declarative Programming and Knowledge Management. Conference on Declarative Programming, DECLARE 2019 Unifying INAP, WLP, and WFLP. Revised Selected Papers. Lecture Notes in Artificial Intelligence Subseries of Lecture Notes in Computer Science (LNAI 12057), P286, DOI 10.1007/978-3-030-46714-2_18
[3]  
Antoy Sergio, 2012, Practical Aspects of Declarative Languages. Proceedings 14th International Symposium, PADL 2012, P33, DOI 10.1007/978-3-642-27694-1_4
[4]   A needed narrowing strategy [J].
Antoy, S ;
Echahed, R ;
Hanus, M .
JOURNAL OF THE ACM, 2000, 47 (04) :776-822
[5]  
Antoy S., 2002, Springer LNCS, V2441, P67, DOI [10.1007/3-540-45788-74, DOI 10.1007/3-540-45788-74]
[6]   Functional Logic Programming [J].
Antoy, Sergio ;
Hanus, Michael .
COMMUNICATIONS OF THE ACM, 2010, 53 (04) :74-85
[7]   Set Functions for Functional Logic Programming [J].
Antoy, Sergio ;
Hanus, Michael .
PPDP'09: PROCEEDINGS OF THE 11TH INTERNATIONAL ACM SIGPLAN SYMPOSIUM ON PRINCIPLES AND PRACTICE OF DECLARATIVE PROGRAMMING, 2009, :73-82
[8]  
Antoy Sergio., 2001, Proc. of the 3rd International ACM SIGPLAN Conference on Principles and Practice of Declarative Programming (PPDP 2001), P199, DOI [10.1145/773184.773205, DOI 10.1145/773184.773205]
[9]  
Bertot Y., 2004, TEXT THEORET COMP S
[10]   Idris, a general-purpose dependently typed programming language: Design and implementation [J].
Brady, Edwin .
JOURNAL OF FUNCTIONAL PROGRAMMING, 2013, 23 (05) :552-593