Generating Good Generators for Inductive Relations

被引:24
作者
Lampropoulos, Leonidas [1 ]
Paraskevopoulou, Zoe [2 ]
Pierce, Benjamin C. [1 ]
机构
[1] Univ Penn, Philadelphia, PA 19104 USA
[2] Princeton Univ, Princeton, NJ 08544 USA
来源
PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL | 2018年 / 2卷 / POPL期
基金
美国国家科学基金会;
关键词
Random Testing; Property-based Testing; Coq; QuickCheck; QuickChick; Narrowing;
D O I
10.1145/3158133
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Property-based random testing (PBRT) is widely used in the functional programming and verification communities. For testing simple properties, PBRT tools such as QuickCheck can automatically generate random inputs of a given type. But for more complex properties, effective testing often demands generators for random inputs that belong to a given type and satisfy some logical condition. QuickCheck provides a library of combinators for building such generators by hand, but this can be tedious for simple conditions and error prone for more complex ones. Fortunately, the process can often be automated. The most prominent method, narrowing, works by traversing the structure of the condition, lazily instantiating parts of the data structure as constraints involving them are met. We show how to use ideas from narrowing to compile a large subclass of Coq's inductive relations into efficient generators, avoiding the interpretive overhead of previous implementations. More importantly, the same compilation technique allows us to produce proof terms certifying that each derived generator is good-i.e., sound and complete with respect to the inductive relation it was derived from. We implement our algorithm as an extension of QuickChick, an existing tool for property-based testing in Coq. We evaluate our method by automatically deriving good generators for the majority of the specifications in Software Foundations, a formalized textbook on programming language foundations.
引用
收藏
页数:30
相关论文
共 38 条
[1]   A needed narrowing strategy [J].
Antoy, S ;
Echahed, R ;
Hanus, M .
JOURNAL OF THE ACM, 2000, 47 (04) :776-822
[2]  
Arts T, 2008, ERLANG '08: PROCEEDINGS OF THE 2008 SIGPLAN ERLANG WORKSHOP, P1
[3]  
Bulwahn L, 2012, LECT NOTES COMPUT SC, V7180, P153, DOI 10.1007/978-3-642-28717-6_14
[4]  
Bulwahn Lukas, LECT NOTES COMPUTER, V7679, P92
[5]  
Carlier M., 2013, CCIS, V170, P140, DOI [10.1007/978-3-642-29578-29, DOI 10.1007/978-3-642-29578-29]
[6]  
Casinghino Chris, 2011, SOFTWARE FDN
[7]   Integrating Testing and Interactive Theorem Proving [J].
Chamarthi, Harsh Raju ;
Dillinger, Peter C. ;
Kaufmann, Matt ;
Manolios, Panagiotis .
ELECTRONIC PROCEEDINGS IN THEORETICAL COMPUTER SCIENCE, 2011, (70) :4-19
[8]  
Christiansen J, 2008, LECT NOTES COMPUT SC, V4989, P322
[9]   QuickCheck: A lightweight tool for random testing of Haskell programs [J].
Claessen, K ;
Hughes, J .
ACM SIGPLAN NOTICES, 2000, 35 (09) :268-279
[10]  
Claessen K, 2014, LECT NOTES COMPUT SC, V8475, P18, DOI 10.1007/978-3-319-07151-0_2