In
computer science
Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to practical disciplines (includin ...
, program synthesis is the task to construct a
program that provably satisfies a given high-level
formal specification. In contrast to
program verification, the program is to be constructed rather than given; however, both fields make use of formal proof techniques, and both comprise approaches of different degrees of automatization. In contrast to
automatic programming techniques, specifications in program synthesis are usually non-
algorithm
In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing ...
ic statements in an appropriate
logical calculus.
Origin
During the Summer Institute of Symbolic Logic at Cornell University in 1957,
Alonzo Church
Alonzo Church (June 14, 1903 – August 11, 1995) was an American mathematician, computer scientist, logician, philosopher, professor and editor who made major contributions to mathematical logic and the foundations of theoretical computer scie ...
defined the problem to synthesize a circuit from mathematical requirements. Even though the work only refers to circuits and not programs, the work is considered to be one of the earliest descriptions of program synthesis and some researchers refer to program synthesis as "Church's Problem". In the 1960s, a similar idea for an "automatic programmer" was explored by researchers in artificial intelligence.
Since then, various research communities considered the problem of program synthesis. Notable works include the 1969 automata-theoretic approach by
Büchi and
Landweber, and the works by
Manna
Manna ( he, מָן, mān, ; ar, اَلْمَنُّ; sometimes or archaically spelled mana) is, according to the Bible, an edible substance which God provided for the Israelites during their travels in the desert during the 40-year period follow ...
and
Waldinger Waldinger is a surname. Notable people with the surname include:
* Adolf Waldinger (1843–1904), Croatian painter
*Richard Waldinger, American computer scientist
*Robert J. Waldinger
Robert J. Waldinger (born 1951) is an American psychiatrist, ...
(c. 1980). The development of modern
high-level programming language
In computer science, a high-level programming language is a programming language with strong abstraction from the details of the computer. In contrast to low-level programming languages, it may use natural language ''elements'', be easier to ...
s can also be understood as a form of program synthesis.
21st century developments
The early 21st century has seen a surge of practical interest in the idea of program synthesis in the
formal verification
In the context of hardware and software systems, formal verification is the act of proving or disproving the correctness of intended algorithms underlying a system with respect to a certain formal specification or property, using formal met ...
community and related fields. Armando Solar-Lezama showed that it is possible to encode program synthesis problems in
Boolean logic
In mathematics and mathematical logic, Boolean algebra is a branch of algebra. It differs from elementary algebra in two ways. First, the values of the variables are the truth values ''true'' and ''false'', usually denoted 1 and 0, whereas in ...
and use algorithms for the
Boolean satisfiability problem
In logic and computer science, the Boolean satisfiability problem (sometimes called propositional satisfiability problem and abbreviated SATISFIABILITY, SAT or B-SAT) is the problem of determining if there exists an interpretation that satisfies ...
to automatically find programs. In 2013, a unified framework for program synthesis problems was proposed by researchers at
UPenn
The University of Pennsylvania (also known as Penn or UPenn) is a Private university, private research university in Philadelphia. It is the fourth-oldest institution of higher education in the United States and is ranked among the highest- ...
,
UC Berkeley
The University of California, Berkeley (UC Berkeley, Berkeley, Cal, or California) is a public university, public land-grant university, land-grant research university in Berkeley, California. Established in 1868 as the University of Californi ...
, and
MIT. Since 2014 there has been a yearly program synthesis competition comparing the different algorithms for program synthesis in a competitive event, the Syntax-Guided Synthesis Competition or SyGuS-Comp. Still, the available algorithms are only able to synthesize small programs.
The framework of Manna and Waldinger
The framework of
Manna
Manna ( he, מָן, mān, ; ar, اَلْمَنُّ; sometimes or archaically spelled mana) is, according to the Bible, an edible substance which God provided for the Israelites during their travels in the desert during the 40-year period follow ...
and
Waldinger Waldinger is a surname. Notable people with the surname include:
* Adolf Waldinger (1843–1904), Croatian painter
*Richard Waldinger, American computer scientist
*Robert J. Waldinger
Robert J. Waldinger (born 1951) is an American psychiatrist, ...
, published in 1980, starts from a user-given
first-order specification formula. For that formula, a proof is constructed, thereby also synthesizing a
functional program from
unifying substitutions.
The framework is presented in a table layout, the columns containing:
* A line number ("Nr") for reference purposes
*
Formulas that already have been established, including axioms and preconditions, ("Assertions")
* Formulas still to be proven, including postconditions, ("Goals"),
[The distinction "Assertions" / "Goals" is for convenience only; following the paradigm of ]proof by contradiction
In logic and mathematics, proof by contradiction is a form of proof that establishes the truth or the validity of a proposition, by showing that assuming the proposition to be false leads to a contradiction. Proof by contradiction is also known ...
, a Goal is equivalent to an assertion .
*
Terms denoting a valid output value ("Program")
[When and is the Goal formula and the Program term in a line, respectively, then in all cases where holds, is a valid output of the program to be synthesized. This invariant is maintained by all proof rules. An Assertion formula usually is not associated with a Program term.]
* A justification for the current line ("Origin")
Initially, background knowledge, pre-conditions, and post-conditions are entered into the table. After that, appropriate proof rules are applied manually. The framework has been designed to enhance human readability of intermediate formulas: contrary to
classical resolution
Classical may refer to:
European antiquity
*Classical antiquity, a period of history from roughly the 7th or 8th century B.C.E. to the 5th century C.E. centered on the Mediterranean Sea
*Classical architecture, architecture derived from Greek and ...
, it does not require
clausal normal form
In Boolean logic, a formula is in conjunctive normal form (CNF) or clausal normal form if it is a conjunction of one or more clauses, where a clause is a disjunction of literals; otherwise put, it is a product of sums or an AND of ORs. As a can ...
, but allows one to reason with formulas of arbitrary structure and containing any junctors ("
non-clausal resolution
In mathematical logic and automated theorem proving, resolution is a rule of inference leading to a refutation complete theorem-proving technique for sentences in propositional logic and first-order logic. For propositional logic, systematically ...
"). The proof is complete when
has been derived in the ''Goals'' column, or, equivalently,
in the ''Assertions'' column. Programs obtained by this approach are guaranteed to satisfy the specification formula started from; in this sense they are ''correct by construction''. Only a minimalist, yet
Turing-complete
In computability theory, a system of data-manipulation rules (such as a computer's instruction set, a programming language, or a cellular automaton) is said to be Turing-complete or computationally universal if it can be used to simulate any Tu ...
,
purely functional programming language
In computer science, purely functional programming usually designates a programming paradigm—a style of building the structure and elements of computer programs—that treats all computation as the evaluation of mathematical functions.
Program ...
, consisting of conditional, recursion, and arithmetic and other operators
[Only the conditional operator ( ?:) is supported from the beginning. However, arbitrary new operators and relations can be added by providing their properties as axioms. In the toy example below, only the properties of and that are actually needed in the proof have been axiomatized, in line 1 to 3.] is supported.
Case studies performed within this framework synthesized algorithms to compute e.g.
division,
remainder
In mathematics, the remainder is the amount "left over" after performing some computation. In arithmetic, the remainder is the integer "left over" after dividing one integer by another to produce an integer quotient (integer division). In algeb ...
,
square root
In mathematics, a square root of a number is a number such that ; in other words, a number whose ''square'' (the result of multiplying the number by itself, or ⋅ ) is . For example, 4 and −4 are square roots of 16, because .
...
,
term unification, answers to
relational database
A relational database is a (most commonly digital) database based on the relational model of data, as proposed by E. F. Codd in 1970. A system used to maintain relational databases is a relational database management system (RDBMS). Many relatio ...
queries and several
sorting algorithm
In computer science, a sorting algorithm is an algorithm that puts elements of a list into an order. The most frequently used orders are numerical order and lexicographical order, and either ascending or descending. Efficient sorting is importan ...
s.
Proof rules
Proof rules include:
*Non-clausal
resolution (see table).
:For example, line 55 is obtained by resolving Assertion formulas
from 51 and
from 52 which both share some common subformula
. The resolvent is formed as the disjunction of
, with
replaced by
, and
, with
replaced by
. This resolvent logically follows from the conjunction of
and
. More generally,
and
need to have only two unifiable subformulas
and
, respectively; their resolvent is then formed from
and
as before, where
is the
most general unifier of
and
. This rule generalizes
resolution of clauses.
:Program terms of parent formulas are combined as shown in line 58 to form the output of the resolvent. In the general case,
is applied to the latter also. Since the subformula
appears in the output, care must be taken to resolve only on subformulas corresponding to
computable properties.
*Logical transformations.
:For example,
can be transformed to
) in Assertions as well as in Goals, since both are equivalent.
*Splitting of conjunctive assertions and of disjunctive goals.
:An example is shown in lines 11 to 13 of the toy example below.
*
Structural induction.
:This rule allows for synthesis of
recursive functions. For a given pre- and postcondition "Given
such that
, find
such that
", and an appropriate user-given
well-ordering
In mathematics, a well-order (or well-ordering or well-order relation) on a set ''S'' is a total order on ''S'' with the property that every non-empty subset of ''S'' has a least element in this ordering. The set ''S'' together with the well- ...
of the domain of
, it is always sound to add an Assertion "
". Resolving with this assertion can introduce a recursive call to
in the Program term.
:An example is given in Manna, Waldinger (1980), p.108-111, where an algorithm to compute quotient and remainder of two given integers is synthesized, using the well-order
defined by
(p.110).
Murray has shown these rules to be
complete for