Constrained generation of well-typed program - Inria - Institut national de recherche en sciences et technologies du numérique Accéder directement au contenu
Rapport (Rapport De Recherche) Année : 2024

Constrained generation of well-typed program

Génération aléatoire de programmes bien typés par contraintes.

Résumé

“Fuzzing” is a popular testing approach where we throw random inputs at a program and check that it respects some expected properties on all inputs. Fuzzing a metaprogram such as a compiler requires producing random input programs. To exercise interesting behaviors of the compiler, we want our input programs to be well-formed in a strong sense, in particular to be well-typed. Generating random well-typed program is difficult when the type-system is powerful, there is a whole scientific literature on the topic, see for example \citet*{palka2011}. Most existing generators integrate a large part of the implementation of a type-checker, “inverted” to assist in top-down random term generation by efficiently discarding choices that result in ill-typed programs. Scaling this approach to a full language would result in implementing two sophisticated type-checkers, once in the compiler and once in the program generator. This is one type-checker too many! In this research report we present preliminary, in-progress work on reusing the constraint-based type inference approach to write a single type-checker that can be used for both purposes: to check types of user-provided programs, and to efficiently guide a random program generator. This only requires a fairly simple modification to constraint generators: parametrizing them over a search monad. Our software prototype is available at: https://gitlab.com/gasche/constraints-for-random-generation
Fichier principal
Vignette du fichier
constrained-generation.pdf (122.06 Ko) Télécharger le fichier
Origine Fichiers produits par l'(les) auteur(s)
Licence

Dates et versions

hal-04607309 , version 1 (12-06-2024)

Licence

Identifiants

  • HAL Id : hal-04607309 , version 1

Citer

Gabriel Scherer. Constrained generation of well-typed program. Inria - Paris 7. 2024. ⟨hal-04607309⟩
22 Consultations
8 Téléchargements

Partager

Gmail Mastodon Facebook X LinkedIn More