ArticleslgStudy

mathematics

Partial application

Partial application is a mathematics 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 Partial application rather than just read about it. In short: In computer science, partial application (or partial function application) refers to the process of fixing a number of arguments of a function, producing another function of smaller arity. Given a function f:(X×Y×Z)→N, we might fix (or 'bind') the first argument, producing a function of type partial(f):(Y×Z)→N.

Key takeaways

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

Reference excerpt

In computer science, partial application (or partial function application) refers to the process of fixing a number of arguments of a function, producing another function of smaller arity. Given a function f:(X×Y×Z)→N, we might fix (or 'bind') the first argument, producing a function of type partial(f):(Y×Z)→N. Evaluation of this function might be represented as fpartial(2,3). Note that the result of partial function application in this case is a function that takes two arguments. Partial application is sometimes incorrectly called currying, which is a related, but distinct concept.

Motivation Intuitively, partial function application says "if you fix the first arguments of the function, you get a function of the remaining arguments". For example, if function div(x,y) = x/y, then div with the parameter x fixed at 1 is another function: div1(y) = div(1,y) = 1/y. This is the same as the function inv that returns the multiplicative inverse of its argument, defined by inv(y) = 1/y. The practical motivation for partial application is that very often the functions obtained by supplying some but not all of the arguments to a function are useful; for example, many languages have a function or operator similar to plus_one. Partial application makes it easy to define these functions, for example by creating a function that represents the addition operator with 1 bound as its first argument.

Implementations In languages such as ML, Haskell and F#, functions are defined in curried form by default. Supplying fewer than the total number of arguments is referred to as partial application. In languages with first-class functions, one can define curry, uncurry and papply to perform currying and partial application explicitly. This might incur a greater run-time overhead due to the creation of additional closures, while Haskell can use more efficient techniques. Scala implements optional partial application with placeholder, e.g. def add(x: Int, y: Int) = {x+y}; add(1, _: Int) returns an incrementing function. Scala also supports multiple parameter lists as currying, e.g. def add(x: Int)(y: Int) = {x+y}; add(1) _. Clojure implements partial application using the partial function defined in its core library. The C++ standard library provides bind(function, args..) to return a function object that is the result of partial application of the given arguments to the given function. Since C++20 the function bind_front(function, args...) is also provided which binds the first sizeof...(args) arguments of the function to the args. In contrast, bind allows binding any of the arguments of the function passed to it, not just the first ones. Alternatively, lambda expressions can be used:

In Java, MethodHandle.bindTo partially applies a function to its first argument. Alternatively, since Java 8, lambdas can be used:

In Raku, the assuming method creates a new function with fewer parameters. The Python standard library module functools includes the partial function, allowing positional and named argument bindings, returning a new function. In XQuery, an argument placeholder (?) is used for each non-fixed argument in a partial function application.

Definitions In the simply typed lambda calculus with function and product types (λ→,×) partial application, currying and uncurrying can be defined as

papply (((a × b) → c) × a) → (b → c) = λ(f, x). λy. f (x, y) curry ((a × b) → c) → (a → (b → c)) = λf. λx. λy. f (x, y) uncurry (a → (b → c)) → ((a × b) → c) = λf. λ(x, y). f x y Note that curry papply = curry.

Mathematical formulation and examples Partial application can be a useful way to define several useful notions in mathematics. Given sets X,Y and Z, and a function f:X×Y→Z, one can define the function

f(⋅,−):X→(Y→Z), where (Y→Z) is the set of functions Y→Z. The image of x∈X under this map is f(x,⋅):Y→Z. This is the function which sends y∈Y to f(x,y). There are often structures on X,Y,Z which mean that the image of f(⋅,−) restricts to some subset of functions Y→Z, as illustrated in the following examples.

Group actions A group action can be understood as a function ∗:G×X→X. The partial evaluation ρ:G→Sym(X)⊂(X→X) restricts to the group of bijections from X to itself. The group action axioms further ensure ρ is a group homomorphism.

Inner-products and canonical map to the dual An inner-product on a vector space V over a field K is a map ϕ:V×V→K. The partial evaluation provides a canonical map to the dual vector space, ϕ(⋅,−):V→V∗⊂(V→K). If this is the inner-product of a Hilbert space, the Riesz representation theorem ensures this is an isomorphism.

Cross-products and the adjoint map for Lie algebras The partial application of the cross product × on ℝ3 is ×(⋅,−):ℝ3↦End(ℝ3). The image of the vector 𝐮 is a linear map T𝐮 such that T𝐮(𝐯)=𝐮×𝐯. The components of T𝐮 can be found to be (T𝐮)ij=ϵijkuk. This is closely related to the adjoint map for Lie algebras. Lie algebras are equipped with a bracket [⋅,⋅]:𝔤×𝔤→𝔤. The partial application gives a map ad:𝔤→End(𝔤). The axioms for the bracket ensure this map is a homomorphism of Lie algebras.

See also η-conversion POP-2 Restriction (mathematics), the more general phenomenon of restricting a function to a subset of its domain

References

Further reading Marlow, Simon; Peyton Jones, Simon (2004), "Making a Fast Curry: Push/Enter vs. Eval/Apply for Higher-order Languages", ICFP '04 Proceedings of the ninth ACM SIGPLAN international conference on Functional programming Benjamin C. Pierce et al. "Partial Application", Archived 2016-05-21 at the Wayback Machine "Digression: Currying". Archived 2016-05-21 at the Wayback Machine Software Foundations.

External links Partial function application on Rosetta code. Partial application at Haskell Wiki Constant applicative form at Haskell Wiki The dangers of being too partial

Worked examples

Example 1 — a first encounter with Partial application

Start with the simplest possible case. Write down what Partial application claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, 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 Partial application 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 Partial application 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 Partial application

In research
Partial application appears in mathematics 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 Partial application 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
Partial application is common in secondary-school and first-year university syllabi. It links to neighbouring topics Functional programming, Implementation of functional programming languages, so understanding it makes those chapters shorter.
In everyday life
Look for Partial application 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.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Partial application” →

How to study Partial application in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Partial application 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 Partial application out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Partial application in simple terms?

In computer science, partial application (or partial function application) refers to the process of fixing a number of arguments of a function, producing another function of smaller arity. Given a function f:(X×Y×Z)→N, we might fix (or 'bind') the first argument, producing a function of type partia…

Why does Partial application matter?

Because it connects several mathematics 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 Partial application?

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 Partial application.

Tags

  • Functional programming
  • Implementation of functional programming languages

Keep exploring