# Inferring Concise Specifications of APIs

**Authors:** John L. Singleton, Gary T. Leavens, Hridesh Rajan, David R. Cok

arXiv: 1905.06847 · 2019-05-17

## TL;DR

This paper presents a novel algorithm for inferring concise formal postconditions of API methods, improving usability and verification efficiency by reducing specification size and proof complexity.

## Contribution

The work introduces a structure-aware algorithm that converts exponentially large postconditions into concise, usable specifications, demonstrated on Java libraries with significant size reductions.

## Key findings

- Inferred specifications for 75.7% of methods tested.
- 84.6% of specifications were under 20 lines long.
- Reduced SMT proof length by 76.7% and prover time by 26.7%.

## Abstract

Modern software relies on libraries and uses them via application programming interfaces (APIs). Correct API usage as well as many software engineering tasks are enabled when APIs have formal specifications. In this work, we analyze the implementation of each method in an API to infer a formal postcondition. Conventional wisdom is that, if one has preconditions, then one can use the strongest postcondition predicate transformer (SP) to infer postconditions. However, SP yields postconditions that are exponentially large, which makes them difficult to use, either by humans or by tools. Our key idea is an algorithm that converts such exponentially large specifications into a form that is more concise and thus more usable. This is done by leveraging the structure of the specifications that result from the use of SP. We applied our technique to infer postconditions for over 2,300 methods in seven popular Java libraries. Our technique was able to infer specifications for 75.7% of these methods, each of which was verified using an Extended Static Checker. We also found that 84.6% of resulting specifications were less than 1/4 page (20 lines) in length. Our technique was able to reduce the length of SMT proofs needed for verifying implementations by 76.7% and reduced prover execution time by 26.7%.

## Full text

_Full body text omitted from this summary view._ Fetch the complete paper as Markdown: https://tomesphere.com/paper/1905.06847/full.md

## Figures

14 figures with captions in the complete paper: https://tomesphere.com/paper/1905.06847/full.md

## References

53 references — full list in the complete paper: https://tomesphere.com/paper/1905.06847/full.md

---
Source: https://tomesphere.com/paper/1905.06847