ArticleslgStudy

computer science

Lambda calculus

Lambda calculus is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Lambda calculus rather than just read about it. In short: In mathematical logic, the lambda calculus (also written as λ-calculus) is a formal system for expressing computation based on function abstraction and application using variable binding and substitution. Untyped lambda calculus, the topic of this article, is a universal machine, i.e. a model of computation that can be used to simulate any Turing machine (and vice versa).

Lambda calculus — main illustration
Lambda calculus — illustration

Key takeaways

  • Lambda calculus belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Lambda calculus to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Lambda calculus from memory before moving on to harder problems.

Reference excerpt

In mathematical logic, the lambda calculus (also written as λ-calculus) is a formal system for expressing computation based on function abstraction and application using variable binding and substitution. Untyped lambda calculus, the topic of this article, is a universal machine, i.e. a model of computation that can be used to simulate any Turing machine (and vice versa). It was introduced by the mathematician Alonzo Church in the 1930s as part of his research into the foundations of mathematics. In 1936, Church found a formulation which was logically consistent, and documented it in 1940.

Definition

The lambda calculus consists of a language of lambda terms, which are defined by a formal syntax, and a set of transformation rules for manipulating those terms. In BNF, the syntax is e ::= x ∣ λ x . e ∣ e e , {\displaystyle e::=x\mid \lambda x{\text{.}}e\mid e\,e,} where variables x , y , z {\displaystyle x,y,z} range over an infinite set of names. Terms M , N , t , s , e , f {\displaystyle M,N,t,s,e,f} range over all lambda terms. This corresponds to the following inductive definition:

A variable x {\displaystyle x} is a valid lambda term. An abstraction is a lambda term ( λ x . t ) {\displaystyle (\lambda x{\text{.}}t)} where t {\displaystyle t} is a lambda term, referred to as the abstraction's body, and x {\displaystyle x} is the abstraction's parameter variable, An application is a lambda term ( t s ) {\displaystyle (t\,s)} where t {\displaystyle t} and s {\displaystyle s} are lambda terms. A lambda term is syntactically valid if it can be obtained by repeated application of these three rules. For convenience, parentheses can often be omitted when writing a lambda term—see Lambda calculus definition § Notation for details. Within lambda terms, any occurrence of a variable that is not a parameter of some enclosing λ {\displaystyle \lambda } is said to be free. Any free occurrence of x {\displaystyle x} in a term M {\displaystyle M} is bound in λ x . M {\displaystyle \lambda x{\text{.}}M} . Any free occurrence of any other variable within M {\displaystyle M} remains free in λ x . M {\displaystyle \lambda x{\text{.}}M} . For example, in the term x y {\displaystyle x\,y} , both x {\displaystyle x} and y {\displaystyle y} occur free. In ( λ x . x y ) {\displaystyle (\lambda x{\text{.}}x\,y)} , y {\displaystyle y} is free, but x {\displaystyle x} in the body (i.e. after the dot) is not free, and is said to be bound (to the parameter). While y {\displaystyle y} is free in ( λ x . x y ) {\displaystyle (\lambda x{\text{.}}x\,y)} , it is bound in ( λ y . λ x . x y ) {\displaystyle (\lambda y{\text{.}}\lambda x{\text{.}}x\,y)} . There are two occurrences of x {\displaystyle x} in ( λ y . ( λ x . x y ) x ) {\displaystyle (\lambda y{\text{.}}(\lambda x{\text{.}}x\,y)\,x)} – one is bound, and the other is free.

FV ⁡ ( M ) {\displaystyle \operatorname {FV} (M)} is the set of free variables of M {\displaystyle M} , i.e. such variables that occur free in M {\displaystyle M} at least once. It can be defined inductively as follows:

FV ⁡ ( x ) = { x } {\displaystyle \operatorname {FV} (x)=\{x\}}

FV ⁡ ( M 1 M 2 ) = FV ⁡ ( M 1 ) ∪ FV ⁡ ( M 2 ) {\displaystyle \operatorname {FV} (M_{1}M_{2})=\operatorname {FV} (M_{1})\cup \operatorname {FV} (M_{2})}

FV ⁡ ( λ x . M ) = FV ⁡ ( M ) ∖ { x } {\displaystyle \operatorname {FV} (\lambda x{\text{.}}M)=\operatorname {FV} (M)\backslash \{x\}}

… excerpt ends here. Continue reading the full article.

Illustrations

Lambda calculus: The lambda abstraction decomposed. The 
  
    
      
        λ
      
    
    {\displaystyle \lambda }
  
 indicates the start of a function. 
  
    
      
        x
      
    
    {\displaystyle x}
  
 is the input parameter. 
  
    
      
        M
      
    
    {\displaystyle M}
  
 is the body, separated by a dot separator "
  
    
      
        .
      
    
    {\displaystyle .}
  
" from the input parameter.
The lambda abstraction decomposed. The λ {\displaystyle \lambda } indicates the start of a function. x {\displaystyle x} is the input parameter. M {\displaystyle M} is the body, separated by a dot separator " . {\displaystyle .} " from the input parameter.

Worked examples

Example 1 — a first encounter with Lambda calculus

Start with the simplest possible case. Write down what Lambda calculus claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Lambda calculus before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Lambda calculus ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Lambda calculus

In research
Lambda calculus appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Lambda calculus in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Lambda calculus is common in secondary-school and first-year university syllabi. It links to neighbouring topics 1936 in computing, Computability theory, Formal methods, so understanding it makes those chapters shorter.
In everyday life
Look for Lambda calculus outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Lambda calculus in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Lambda calculus means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Lambda calculus out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Lambda calculus in simple terms?

In mathematical logic, the lambda calculus (also written as λ-calculus) is a formal system for expressing computation based on function abstraction and application using variable binding and substitution. Untyped lambda calculus, the topic of this article, is a universal machine, i.e. a model of co…

Why does Lambda calculus matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Lambda calculus?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Lambda calculus.

Tags

  • 1936 in computing
  • Computability theory
  • Formal methods
  • Lambda calculus
  • Models of computation
  • Programming language comparisons
  • Theoretical computer science

Keep exploring