8 research outputs found

    Proactive Synthesis of Recursive Tree-to-String Functions from Examples

    Get PDF
    Synthesis from examples enables non-expert users to generate programs by specifying examples of their behavior. A domain-specific form of such synthesis has been recently deployed in a widely used spreadsheet software product. In this paper we contribute to foundations of such techniques and present a complete algorithm for synthesis of a class of recursive functions defined by structural recursion over a given algebraic data type definition. The functions we consider map an algebraic data type to a string; they are useful for, e.g., pretty printing and serialization of programs and data. We formalize our problem as learning deterministic sequential top-down tree-to-string transducers with a single state (1STS). The first problem we consider is learning a tree-to-string transducer from any set of input/output examples provided by the user. We show that, given a set of input/output examples, checking whether there exists a 1STS consistent with these examples is NP-complete in general. In contrast, the problem can be solved in polynomial time under a (practically useful) closure condition that each subtree of a tree in the input/output example set is also part of the input/output examples. Because coming up with relevant input/output examples may be difficult for the user while creating hard constraint problems for the synthesizer, we also study a more automated active learning scenario in which the algorithm chooses the inputs for which the user provides the outputs. Our algorithm asks a worst-case linear number of queries as a function of the size of the algebraic data type definition to determine a unique transducer. To construct our algorithms we present two new results on formal languages. First, we define a class of word equations, called sequential word equations, for which we prove that satisfiability can be solved in deterministic polynomial time. This is in contrast to the general word equations for which the best known complexity upper bound is in linear space. Second, we close a long-standing open problem about the asymptotic size of test sets for context-free languages. A test set of a language of words L is a subset T of L such that any two word homomorphisms equivalent on T are also equivalent on L. We prove that it is possible to build test sets of cubic size for context-free languages, matching for the first time the lower bound found 20 years ago

    Generic Theorem Proving Using HOL2P: A Category Theory Inspired Approach

    Get PDF
    Abstract Integrating formal program verification into mainstream software development has proven to be quite challenging, due to the level of abstract mathematical machinery needed. Although there have been some successes, most existing methods do not adequately support the mechanical verification of generic programs. This thesis seeks to fill this gap by presenting a formalisation and implementation of a category theory inspired approach to generic program specification. Theorems to simplify verification of generic programs are developed along with a formal framework for reasoning. The result is theorem proving support based on type quantification and type operator variables in HOL, HOL2P. This is demonstrated by the verification the Yoenda Lemma

    Interactive Programming by Example

    Get PDF
    As of today, programming has never been so accessible. Yet, it remains a challenge for end-users: students, non-technical employees, experts in their domains outside of computer science, and so on. With its forecast potential for solving problems by only observing inputs and outputs, programming-by-example was supposed to alleviate complex tasks requiring programming for end-users. The initial ideas of macro-based editors paved the way to subsequent practical solutions, such as spreadsheet transformations from examples. Finding the right program is the core of the programming-by-example systems. However, users find it difficult to trust such generated programs. In this thesis, we contribute to proving that some forms of interaction alleviate, by having users provide examples, the problem of finding correct and reliable programs. We first report on two experiments that enable us to conjecture what kind of interaction brings benefits to programming-by-example. First, we present a new kind of game engine, Pong Designer. In this game engine, by using their finger, users program rules on the fly, by modifying the game state. We analyze its potential, and its eventual downsides that have probably prevented its wide adoption. Second, we present StriSynth, an interactive command-line tool that uses programming-by-example to transform string and collections. The resulting programs can also rename or otherwise manage files. We obtained the result that confirms that many users preferred StriSynth over usual programming languages, but would appreciate to have both. We then report on two new exciting experiments with verified results, using two forms of interaction truly benefiting programming-by-example. Third, on top of a programmingby- example-based engine for extracting structured data out of text files, in this thesis we study two interaction models implemented in a tool named FlashProg: a view of the program with notification about ambiguities, and the asking of clarification questions. In this thesis, we prove that these two interaction models enable users to perform tasks with less errors and to be more confident with the results. Last, for learning recursive tree-to-string functions (e.g., pretty-printers), in this thesis we prove that questioning breaks down the learning complexity from a cubic to a linear number of questions, in practice making programming-by-example even more accessible than regular programming. The implementation, named Prosy, could be easily added to integrated development environments

    Functional Polytypic Programming

    No full text
    Many algorithms have to be implemented over and over again for different datatypes, either because datatypes change during the development of programs, or because the same algorithm is used for several datatypes. Examples of such algorithms are equality tests, pretty printers, and pattern matchers, and polytypic programming is a paradigm for expressing such algorithms. This dissertation introduces polytypic programming for functional programming languages, shows how to construct and prove properties of polytypic algorithms, presents the language extension PolyP for implementing polytypic algorithms in a type safe way, and presents a number of applications of polytypic programming. The applications include a library of basic polytypic building blocks, PolyLib, and two larger applications of polytypic programming: rewriting and data conversion. <p />PolyP extends a functional language (a subset of Haskell) with a construct for defining polytypic functions by induction on the structure of user-defined datatypes. Programs in the extended language are translated to Haskell. <p />PolyLib contains powerful structured recursion operators like catamorphisms, maps and traversals, as well as polytypic versions of a number of standard functions from functional programming: sum, length, zip, (==), (<=), etc. Both the specification of the library and a PolyP implementation are presented. <p />The first larger application is a framework for polytypic programming on terms. We show that an interface of four functions is sufficient to express polytypic functions for pattern matching, unification and term rewriting. Using this framework, a term rewriting function is specified and transformed into an efficient and correct implementation. <p />In the second application, a number of functions for polytypic data conversion are implemented and proved correct. The conversions considered include pretty printing, parsing, packing and unpacking of structured data. The conversion functions are expressed in an embedded domain specific language for data conversion (a hierarchy of Haskell's constructor classes)

    Functional Polytypic Programming --- Use and Implementation

    No full text
    Many functions have to be written over and over again for different datatypes, either because datatypes change during the development of programs, or because functions with similar functionality are needed on different datatypes. Examples of such functions are pretty printers, pattern matchers, equality functions, unifiers, rewriting functions, etc. Such functions are called polytypic functions.A polytypic function is a function that is defined by induction on the structure of user-defined datatypes. This thesis introduces polytypic functions, shows how to construct and reason about polytypic functions and describes the implementation of the polytypic programming system PolyP.PolyP extends a functional language (a subset of Haskell) with a construct for writing polytypic functions. The extended language type checks definitions of polytypic functions, and infers the types of all other expressions. Programs in the extended language are translated to Haskell

    Functional Polytypic Programming --- Use and Implementation

    No full text
    Many functions have to be written over and over again for different datatypes, either because datatypes change during the development of programs, or because functions with similar functionality are needed on different datatypes. Examples of such functions are pretty printers, pattern matchers, equality functions, unifiers, rewriting functions, etc. Such functions are called polytypic functions. A polytypic function is a function that is defined by induction on the structure of user-defined datatypes. This thesis introduces polytypic functions, shows how to construct and reason about polytypic functions and describes the implementation of the polytypic programming system PolyP. PolyP extends a functional language (a subset of Haskell) with a construct for writing polytypic functions. The extended language type checks definitions of polytypic functions, and infers the types of all other expressions. Programs in the extended language are translated to Haskell

    Functional Polytypic Programming Use and Implementation

    No full text
    Many functions have to be written over and over again for different datatypes, either because datatypes change during the development of programs, or because functions with similar functionality are needed on different datatypes. Examples of such functions are pretty printers, pattern matchers, equality functions, unifiers, rewriting functions, etc. Such functions are called polytypic functions. A polytypic function is a function that is defined by induction on the structure of user-defined datatypes. This thesis introduces polytypic functions, shows how to construct and reason about polytypic functions and describes the implementation of the polytypic programming system PolyP. PolyP extends a functional language (a subset of Haskell) with a construct for writing polytypic functions. The extended language type checks definitions of polytypic functions, and infers the types of all other expressions. Programs in the extended language are translated to Haskell. Keywords: Programming lang..

    PolyLib - a polytypic function library

    No full text
    A polytypic program is a program that behaves uniformly over a large class of datatypes. For functional polytypic programming this uniformity is achieved by parameterizing functions over type constructors to obtain polytypic functions. A polytypic function is defined either by induction on the structure of regular type constructors or in terms of other polytypic functions. PolyP is an extension of the functional programming language Haskell with a construct for defining polytypic functions. PolyP is a type guided preprocessor that generates instances of polytypic functions and inserts applications of these instances where needed.During the last few years we have used PolyP to construct a number of polytypic programs, for example for unification, parsing, rewriting, pattern matching, etc. These polytypic programs use several basic polytypic functions, such as the relatively well-known cata and map, but also less well-known functions such as propagate and thread. We have collected these basic polytypic functions in the library of PolyP: PolyLib. This paper describes the polytypic functions in PolyLib, motivates their presence in the library, and gives a rationale for their design. Thus we hope to share our experience with other researchers in the field. We will assume the reader has some familiarity with the field of polytypic programming.Of course, a library is an important part of a programming language. Languages like Java, Delphi, Perl and Haskell are popular partly because of their useful and extensive libraries. For a polytypic programming language it is even more important to have a clear and well-designed library: writing polytypic programs is difficult, and we do not expect many programmers to write polytypic programs. On the other hand, many programmers use polytypic programs such as parser generators, equality functions, etc.This is a first attempt to describe the library of PolyP; we expect that both the form and content of this description will change over time. One of the goals of this paper is to obtain feedback on the library design from other researchers working within the field. At the moment the library only contains the basic polytypic functions. In the future we will develop special purpose sublibraries for polytypic functions with more advanced functionality, for example for parsing and the other programs mentioned above
    corecore