Hostname: page-component-89b8bd64d-nlwjb Total loading time: 0 Render date: 2026-05-08T01:38:17.296Z Has data issue: false hasContentIssue false

Property-Based Testing by Elaborating Proof Outlines

Published online by Cambridge University Press:  21 November 2024

DALE MILLER
Affiliation:
INRIA Saclay & LIX, École Polytechnique, Palaiseau, France (e-mail: dale.miller@inria.fr, https://www.lix.polytechnique.fr/Labo/Dale.Miller/)
ALBERTO MOMIGLIANO
Affiliation:
DI, Università degli Studi di Milano, Milan, Italy (e-mail: momigliano@di.unimi.it, momigliano.di.unimi.it)
Rights & Permissions [Opens in a new window]

Abstract

Property-based testing (PBT) is a technique for validating code against an executable specification by automatically generating test-data. We present a proof-theoretical reconstruction of this style of testing for relational specifications and employ the Foundational Proof Certificate framework to describe test generators. We do this by encoding certain kinds of “proof outlines” as proof certificates that can describe various common generation strategies in the PBT literature, ranging from random to exhaustive, including their combination. We also address the shrinking of counterexamples as a first step toward their explanation. Once generation is accomplished, the testing phase is a standard logic programing search. After illustrating our techniques on simple, first-order (algebraic) data structures, we lift it to data structures containing bindings by using the $\lambda$-tree syntax approach to encode bindings. The $\lambda$Prolog programing language can perform both generating and checking of tests using this approach to syntax. We then further extend PBT to specifications in a fragment of linear logic.

Information

Type
Original Article
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution and reproduction, provided the original article is properly cited.
Copyright
© The Author(s), 2024. Published by Cambridge University Press
Figure 0

Fig. 1. The $\lambda$Prolog specification of five predicates.

Figure 1

Fig. 2. The basic interpreter for Horn clause specifications.

Figure 2

Fig. 3. The encoding of the Horn clause definitions of two predicates in Figure 1 as atomic formulas in RL.

Figure 3

Fig. 4. An equivalent specification of interp as one clause.

Figure 4

Fig. 5. The least fixed point expression for interp.

Figure 5

Fig. 6. A proof system augmented with proof certificates and expert predicates.

Figure 6

Fig. 7. A simple proof-checking kernel.

Figure 7

Fig. 8. Two FPCs that describe proofs that are limited in either height or in size.

Figure 8

Fig. 9. The max FPC.

Figure 9

Fig. 10. FPC for pairing.

Figure 10

Fig. 11. FPC for random generation.

Figure 11

Fig. 12. An FPC that selects randomly from a weighted disjunct.

Figure 12

Fig. 13. An FPC for collecting substitution terms from proof and a predicate to compute subterm.

Figure 13

Fig. 14. An FPC for restricting existential choices.

Figure 14

Fig. 15. A re-implementation of the interpreter in Figure 2 that treats implications and universal quantifiers in $G$-formulas.

Figure 15

Fig. 16. A re-implementation of the FPC checker in Figure 7 that treats implications and universal quantifiers in $G$-formulas.

Figure 16

Fig. 17. Additional clauses for two FPCs.

Figure 17

Fig. 18. Specifications of beta reduction and well-formed terms.

Figure 18

Fig. 19. The $\lambda$Prolog specification of the inference rules in Figure 18.

Figure 19

Fig. 20. Type-directed $\eta$-reduction.

Figure 20

Fig. 21. The $\lambda$Prolog specification of the inference rules in Figure 20.

Figure 21

Fig. 22. A sequent calculus proof system for our linear SL.

Figure 22

Fig. 23. The I/O proof system.

Figure 23

Fig. 24. An interpreter based on the proof system in Figure 23.

Figure 24

Fig. 25. Specifications of call-by-name (cbn) and call-by-value (cbv) evaluations.