Semantic code browsing*

Programmers currently enjoy access to a very high number of code repositories and libraries of ever increasing size. The ensuing potential for reuse is however hampered by the fact that searching within all this code becomes an increasingly difficult task. Most code search engines are based on syntactic techniques such as signature matching or keyword extraction. However, these techniques are inaccurate (because they basically rely on documentation) and at the same time do not offer very expressive code query languages. We propose a novel approach that focuses on querying for semantic characteristics of code obtained automatically from the code itself. Program units are pre-processed using static analysis techniques, based on abstract interpretation, obtaining safe semantic approximations. A novel, assertion-based code query language is used to express desired semantic characteristics of the code as partial specifications. Relevant code is found by comparing such partial specifications with the inferred semantics for program elements. Our approach is fully automatic and does not rely on user annotations or documentation. It is more powerful and flexible than signature matching because it is parametric on the abstract domain and properties, and does not require type definitions. Also, it reasons with relations between properties, such as implication and abstraction, rather than just equality. It is also more resilient to syntactic code differences. We describe the approach and report on a prototype implementation within the Ciao system.

[1]  Manuel V. Hermenegildo,et al.  Combined Determination of Sharing and Freeness of Program Variables through Abstract Interpretation , 1991, ICLP.

[2]  Jeannette M. Wing,et al.  Specifications as Search Keys for Software Libraries , 1991, ICLP.

[3]  Manuel V. Hermenegildo,et al.  Abstract Multiple Specialization and Its Application to Program Parallelization , 1999, J. Log. Program..

[4]  Peter J. Stuckey,et al.  A Generic Framework for Context-Sensitive Analysis of Modular Programs , 2004, Program Development in Computational Logic.

[5]  Patrick Cousot,et al.  Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints , 1977, POPL.

[6]  Collin McMillan,et al.  Recommending source code for use in rapid software prototypes , 2012, 2012 34th International Conference on Software Engineering (ICSE).

[7]  Manuel V. Hermenegildo,et al.  Integrated program debugging, verification, and optimization using abstract interpretation (and the Ciao system preprocessor) , 2005, Sci. Comput. Program..

[8]  Neil Mitchell Hoogle Overview , 2008 .

[9]  Manuel V. Hermenegildo,et al.  Compile-Time Derivation of Variable Dependency Using Abstract Interpretation , 1992, J. Log. Program..

[10]  Manuel V. Hermenegildo,et al.  An Assertion Language for Constraint Logic Programs , 2000, Analysis and Visualization Tools for Constraint Programming.

[11]  Manuel V. Hermenegildo,et al.  Combined Static and Dynamic Assertion-Based Debugging of Constraint Logic Programs , 1999, LOPSTR.

[12]  John P. Gallagher,et al.  Fast and Precise Regular Approximations of Logic Programs , 1994, ICLP.

[13]  Manuel V. Hermenegildo,et al.  A New Module System for Prolog , 2000, Computational Logic.

[14]  Manuel V. Hermenegildo,et al.  Assertion-based Debugging of Higher-Order (C)LP Programs , 2014, PPDP '14.

[15]  Manuel V. Hermenegildo,et al.  An overview of Ciao and its design philosophy , 2011, Theory and Practice of Logic Programming.

[16]  Steven P. Reiss,et al.  Semantics-based code search , 2009, 2009 IEEE 31st International Conference on Software Engineering.

[17]  Francisco Bueno,et al.  More Precise Yet Efficient Type Inference for Logic Programs , 2002, SAS.

[18]  Maurice Bruynooghe,et al.  A Practical Framework for the Abstract Interpretation of Logic Programs , 1991, J. Log. Program..

[19]  E KaiserGail,et al.  An Information Retrieval Approach for Automatically Constructing Software Libraries , 1991 .

[20]  Gail E. Kaiser,et al.  An Information Retrieval Approach For Automatically Constructing Software Libraries , 1991, IEEE Trans. Software Eng..