How do mathematical functions become executable programs with types, recursion, and effects?
Relate evaluation to least fixed points, distinguish adequacy from full abstraction, and see why mutation restricts polymorphism.
McCarthy's account of recursive symbolic expressions connects computation with an executable functional language.
Source: Recursive Functions of Symbolic Expressions (1960)Lambda calculus supplied a compact theory of functions. Turning related ideas into programming languages required decisions about data, evaluation, recursion, types, and interaction with a machine.
The history is therefore more than a sequence of languages inspired by Church. It includes a sustained attempt to explain what programs mean and which transformations preserve their behavior.
Lisp and symbolic computation
John McCarthy's 1960 paper, “Recursive Functions of Symbolic Expressions and Their Computation by Machine”, presented a foundation for Lisp.
Sources and credit for John McCarthy
Tom Varco, 21 April 2006, CC BY-SA 3.0, via Wikimedia Commons Image source · CC BY-SA 3.0 · Biographical dates
Lists and symbolic expressions made programs suitable for manipulating formulas and other structured data. Function definitions, conditionals, and recursion supported an expressive style of symbolic computation.
The relationship between programs and data was especially significant. An evaluator could itself be described within the symbolic framework, connecting an implemented language with the earlier mathematical idea of a universal computation.
Lisp should not be identified without qualification with pure lambda calculus. Its implementations and dialects included choices about variable binding, mutation, evaluation, and other operations. Those choices affect equational reasoning about programs.
The relevant historical contribution is the construction of a practical language for symbolic procedures, with a clear mathematical vocabulary for recursive definitions.
Landin and the analysis of language
Peter Landin investigated how programming-language constructs could be understood through lambda calculus and abstract machines. His 1964 work on the mechanical evaluation of expressions introduced the SECD machine; his 1966 “The Next 700 Programming Languages” articulated a language-design program centered on a small semantic core.
An abstract machine specifies states and transitions at a level between mathematical expressions and physical hardware. It can make evaluation order, environments, and control explicit.
This matters because substitution on paper and execution in an implementation need not look the same. A machine may use environments to associate variables with values instead of copying expressions textually.
An adequate semantics explains why such implementation choices realize the intended computation.
Landin's SECD machine records four parts of a computation: a stack of intermediate values, an environment for variables, the control expressions still to evaluate, and a dump recording suspended machine states. A function value is represented by a closure containing its code and the environment in which it was formed.
For example, evaluating where the environment assigns produces a closure retaining that assignment. Applying it to evaluates the body with and the captured , yielding . Replacing the closure's captured environment with whatever assignment to happens to be available at the call site would implement a different binding discipline. This is why environments are part of semantic explanation rather than merely a memory-saving trick.
Operational and denotational accounts
An operational semantics describes evaluation through rules or machine transitions. A denotational semantics assigns mathematical meanings to expressions compositionally.
For the recursive function
an operational calculation gives
The rule explains how execution unfolds on this input. A denotational account asks which mathematical object represents the entire recursive definition, including behavior on inputs where other definitions might fail to terminate.
Dana Scott and Christopher Strachey's work around the end of the 1960s and the early 1970s developed influential foundations for such meanings.
Sources and credit for Dana Scott
Logos Semantikos. Via Wikimedia Commons. Image source · CC0 · Biographical dates
Recursion as a least fixed point
Let a partial function represent a computation that may be undefined on some inputs. Write for absence of a result.
The factorial equation determines an operation on candidate partial functions:
A solution is a fixed point .
Begin with the everywhere-undefined function . Applying once gives a function defined at . Applying it again also supplies the result at , and further iterations extend the available information.
For this example, the limit of the chain supplies every factorial value. In suitable ordered domains, continuous operations have least fixed points obtained from such increasing approximations.
“Least” refers to the information order. The interpretation includes exactly the information justified by finite unfoldings of the definition, rather than arbitrarily choosing among possible mathematical solutions.
This approach also handles definitions that remain partial. Denotational semantics does not prove that every recursive program terminates; it provides a way to give divergence a systematic mathematical treatment.
The assumptions on are doing real work. In a pointed complete partial order, directed families have least upper bounds and there is a least element . Scott continuity requires to preserve those directed limits. For an appropriate continuous operation,
This is not an arbitrary solution selected from an equation. If is any fixed point, induction gives for every , so the supremum lies below . Continuity then shows that applying to the supremum gives the same supremum. The two steps justify “least” and “fixed” separately.
Adequacy and full abstraction
A mathematical interpretation still needs to be connected to execution. For a language with natural-number results, computational adequacy relates the denotation of a closed program to its operational result: the semantic value corresponds to evaluation returning the numeral , with divergence handled by the model's least element.
Contextual equivalence asks whether two expressions can be distinguished by placing them in any permitted program context and observing the results. A model is fully abstract when equality of denotations coincides with that observational equivalence. Adequacy for completed ground-type programs does not automatically establish full abstraction for all higher-type expressions.
Gordon Plotkin's “LCF Considered as a Programming Language” (1977) developed these questions for PCF, a typed language with recursion based on Scott's work. A domain model may contain parallel functions that a sequential language cannot define; such functions can distinguish denotations in ways no actual program context can. This mismatch made full abstraction a substantial research problem, later addressed through several approaches including game semantics. The historical issue was precision about observable behavior, not simply finding any set-theoretic object to attach to a program.
ML and inference of types
ML originated as a metalanguage for the LCF theorem-proving project. Its users needed a practical language for composing proof procedures while preserving the discipline of the underlying theorem system.
Roger Hindley's 1969 work on principal type schemes, Robin Milner's 1978 account of type polymorphism, and Luis Damas and Milner's 1982 paper established central results behind the familiar Hindley–Milner tradition.
A principal type scheme is sufficiently general that other permitted types of the expression arise as instances. An inference algorithm seeks that general scheme rather than requiring the programmer to annotate every occurrence.
Consider
Assign a type . Because is applied to , let . Because is applied to the result, let . The whole expression then has type
Generalizing the unconstrained type variables yields a polymorphic scheme. The same composition function can be instantiated for many concrete types.
The Damas–Milner paper proves the relevant principal-type result for its specified language. Extensions involving effects, higher-rank polymorphism, or other mechanisms require separate rules and qualifications.
The location of generalization is essential. In the pure Hindley–Milner discipline, a let-bound identity function can be instantiated once at integers and once at booleans in the same scope. A function parameter is ordinarily given one monotype within its body; it is not automatically a universally quantified argument. Generalization also excludes type variables already fixed by the surrounding context.
The inference algorithm generates equations between types, solves them by unification, and generalizes only where the rules permit. It is not proving arbitrary mathematical specifications. The principal scheme expresses the most general type constraints for that language, rather than every behavioral property of the term.
Why mutable references change polymorphism
Suppose unrestricted let-generalization were applied to a newly allocated reference holding the identity function. The following ML-like pseudocode would be unsound:
let r = ref (fun x -> x) in
r := (fun n -> n + 1);
(!r) trueThe first use would instantiate the shared cell at integer functions; the last would instantiate the same cell at boolean functions. After the assignment, the last line attempts to apply an integer successor function to true. Reusing a pure polymorphic function at different types is safe; treating one mutable storage location as if it held independent instantiations is not.
The value restriction controls generalization so that such an allocation is not given the dangerous polymorphic scheme. Andrew Wright's “Simple Imperative Polymorphism” (1995) gives an influential formulation. The example illustrates why a theorem for a pure language cannot simply be carried over after adding effects.
Polymorphism and its limits
System F, developed independently by Girard and Reynolds, expresses polymorphism through explicit quantification over types. Its expressive power exceeds ordinary Hindley–Milner let-polymorphism.
Sources and credit for Jean-Yves Girard
UTLS. Via Wikimedia Commons. Image source · CC BY-SA 4.0 · Biographical dates
Sources and credit for John C. Reynolds
original picture taken by Andrej Bauer , cropped by romanm ( talk ). Via Wikimedia Commons. Image source · CC BY-SA 2.5 · Biographical dates
The amount of type information supplied matters. In Church-style System F, terms explicitly record parameter types, type abstractions, and type applications; checking such a fully annotated term is decidable. In Curry-style System F, types are assigned to ordinary untyped lambda terms. J. B. Wells proved that both deciding whether such a term has any type and deciding whether it has a specified type are undecidable. His 1994 result, expanded in 1999, therefore concerns recovering omitted polymorphic structure, not checking a fully explicit proof term. Fujita and Schubert examine precisely how annotations affect this boundary.
This is a concrete limit on extending Hindley–Milner inference: more expressive polymorphism does not automatically retain its decidable inference procedure.
Reynolds's 1983 work on relational parametricity studied uniform behavior across type instantiations. A polymorphic term cannot arbitrarily inspect a type parameter when the language supplies no operation for doing so.
For example, in a pure total setting, a term of type
has no source for an arbitrary output of type except its input. Under the relevant parametricity assumptions, it behaves as the identity.
General recursion, exceptions, runtime type analysis, and other language features complicate that conclusion. A divergent term can inhabit a programming-language type without returning its argument. The theorem must match the actual language.
Evaluation strategy is part of meaning
Consider a function that ignores its argument and returns zero, applied to a divergent computation.
A call-by-value language evaluates the argument first and may diverge. A call-by-name or suitable lazy evaluation strategy can return zero without evaluating that argument.
Thus the mathematical-looking equation “the function always returns zero” needs an account of how application evaluates. Equational laws valid in a total calculus may need refinement in a language with partiality and effects.
Haskell's design, begun by a committee in 1987, combined non-strict evaluation with a shared functional-language framework. Type classes and later approaches to organizing effects became important parts of its identity.
The history written by Hudak, Hughes, Peyton Jones, and Wadler presents a collaborative design process, rather than attributing the language to one inventor or treating it as a direct transcription of a logical calculus.
The intervening history also includes John Backus's functional programming proposal and Turing Award lecture, Burstall and Darlington's work on program transformation, and languages such as Hope and Miranda that shaped pattern matching, algebraic data types, and non-strict language design. These projects pursued different combinations of mathematical reasoning and practical expressiveness. The Haskell committee inherited an active research community, not an empty gap between lambda calculus and a finished language.
Moggi and the distinction between values and computations
Eugenio Moggi's work in 1989 and 1991 gave effects a categorical organization. Instead of interpreting an expression of result type simply as a value in , interpret its computation in an object . A pure value can be embedded into a computation, and a computation can be sequenced with a function producing the next computation. Unit and associativity laws constrain this composition.
For exceptions, one elementary model uses : a computation either returns a value or reports an exception. Sequencing applies the next operation to a returned value and propagates an exception unchanged. For state, a typical shape is : a computation reads a state and returns both a result and an updated state. These are different effects with a common compositional pattern.
Moggi's “Notions of Computation and Monads” explains the semantic motivation. Wadler and others brought related ideas into functional programming practice, including Haskell's organization of input and output. The abstraction describes how effects compose; it does not make effects disappear or establish that every effectful program satisfies an intended specification.
A continuing exchange with logic
Functional programming influenced the construction of proof assistants, and proof-assistant requirements influenced functional languages. Semantics supplied tools for compiler transformations, reasoning about equivalence, and understanding abstraction boundaries.
Sources and credit for Simon Peyton Jones
Duncan.Hull. Via Wikimedia Commons. Image source · CC BY-SA 4.0 · Biographical dates
The exchange was productive precisely because its distinctions remained visible. A type can prevent some erroneous operations without proving termination. A denotation can describe partial behavior without declaring it desirable. A program can manipulate proof objects without itself being a proof of every property it computes about.
The next development asks how programs can search for mathematical proofs automatically.
Check your understanding: when may an ignored argument be removed?
Let be a divergent expression. Is replacing by a behavior-preserving transformation in every functional language?
Reasoning. No. A call-by-value evaluator first evaluates and therefore diverges; a call-by-name evaluator can discard the unused argument and return zero. With effects, evaluating a discarded argument might also change state or raise an exception. A compiler transformation must preserve the observations defined by the language's evaluation strategy and effects, not merely match unrestricted beta reduction on paper.
Sources and further reading
- John McCarthy, “Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I” (1960).
- Peter J. Landin, “The Mechanical Evaluation of Expressions” (1964); “The Next 700 Programming Languages” (1966).
- Dana Scott and Christopher Strachey, Toward a Mathematical Semantics for Computer Languages (1971).
- J. Roger Hindley, “The Principal Type-Scheme of an Object in Combinatory Logic” (1969); Robin Milner, “A Theory of Type Polymorphism in Programming” (1978).
- Luis Damas and Robin Milner, “Principal Type-Schemes for Functional Programs” (1982).
- John C. Reynolds, “Types, Abstraction and Parametric Polymorphism” (1983).
- J. B. Wells, “Typability and Type Checking in the Second-Order Lambda-Calculus Are Equivalent and Undecidable” (1994); expanded as “Typability and Type Checking in System F Are Equivalent and Undecidable” (1999).
- Paul Hudak, John Hughes, Simon Peyton Jones, and Philip Wadler, “A History of Haskell: Being Lazy with Class” (2007).
- Gordon D. Plotkin, “LCF Considered as a Programming Language” (1977), for adequacy, contextual equivalence, and full abstraction.
- Andrew K. Wright, “Simple Imperative Polymorphism” (1995).
- Eugenio Moggi, “Notions of Computation and Monads” (1991).