Leroy: Library Learning for Imperative Programming Languages

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Bellur, Abhiram, Alghamdi, Razan, Workneh, Kidus, Izraelevitz, Joseph
Format: Preprint
Publié: 2024
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866916428751306752
author Bellur, Abhiram
Alghamdi, Razan
Workneh, Kidus
Izraelevitz, Joseph
author_facet Bellur, Abhiram
Alghamdi, Razan
Workneh, Kidus
Izraelevitz, Joseph
contents Library learning is the process of building a library of common functionalities from a given set of programs. Typically, this process is applied in the context of aiding program synthesis: concise functions can help the synthesizer produce modularized code that is smaller in size. Previous work has focused on functional Lisp-like languages, as their regularity makes them more amenable to extracting repetitive structures. Our work introduces Leroy, which extends existing library learning techniques to imperative higher-level programming languages, with the goal of facilitating reusability and ease of maintenance. Leroy wraps the existing Stitch framework for library learning and converts imperative programs into a Lisp-like format using the AST. Our solution uses Stitch to do a top-down, corpus-guided extraction of repetitive expressions. Further, we prune abstractions that cannot be implemented in the programming language and convert the best abstractions back to the original language. We implement our technique in a tool for a subset of the Python programming language and evaluate it on a large corpus of programs. Leroy achieves a compression ratio of 1.04x of the original code base, with a slight expansion when the library is included. Additionally, we show that our technique prunes invalid abstractions.
format Preprint
id arxiv_https___arxiv_org_abs_2410_06438
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Leroy: Library Learning for Imperative Programming Languages
Bellur, Abhiram
Alghamdi, Razan
Workneh, Kidus
Izraelevitz, Joseph
Programming Languages
Library learning is the process of building a library of common functionalities from a given set of programs. Typically, this process is applied in the context of aiding program synthesis: concise functions can help the synthesizer produce modularized code that is smaller in size. Previous work has focused on functional Lisp-like languages, as their regularity makes them more amenable to extracting repetitive structures. Our work introduces Leroy, which extends existing library learning techniques to imperative higher-level programming languages, with the goal of facilitating reusability and ease of maintenance. Leroy wraps the existing Stitch framework for library learning and converts imperative programs into a Lisp-like format using the AST. Our solution uses Stitch to do a top-down, corpus-guided extraction of repetitive expressions. Further, we prune abstractions that cannot be implemented in the programming language and convert the best abstractions back to the original language. We implement our technique in a tool for a subset of the Python programming language and evaluate it on a large corpus of programs. Leroy achieves a compression ratio of 1.04x of the original code base, with a slight expansion when the library is included. Additionally, we show that our technique prunes invalid abstractions.
title Leroy: Library Learning for Imperative Programming Languages
topic Programming Languages
url https://arxiv.org/abs/2410.06438