The function ${\displaystyle x^{2))$ with domain ${\displaystyle \mathbb {R} }$ does not have an inverse function. If we restrict ${\displaystyle x^{2))$ to the non-negative real numbers, then it does have an inverse function, known as the square root of ${\displaystyle x.}$

In mathematics, the restriction of a function ${\displaystyle f}$ is a new function, denoted ${\displaystyle f\vert _{A))$ or ${\displaystyle f{\upharpoonright _{A)),}$ obtained by choosing a smaller domain ${\displaystyle A}$ for the original function ${\displaystyle f.}$ The function ${\displaystyle f}$ is then said to extend ${\displaystyle f\vert _{A}.}$

## Formal definition

Let ${\displaystyle f:E\to F}$ be a function from a set ${\displaystyle E}$ to a set ${\displaystyle F.}$ If a set ${\displaystyle A}$ is a subset of ${\displaystyle E,}$ then the restriction of ${\displaystyle f}$ to ${\displaystyle A}$ is the function[1]

${\displaystyle {f|}_{A}:A\to F}$
given by ${\displaystyle {f|}_{A}(x)=f(x)}$ for ${\displaystyle x\in A.}$ Informally, the restriction of ${\displaystyle f}$ to ${\displaystyle A}$ is the same function as ${\displaystyle f,}$ but is only defined on ${\displaystyle A}$.

If the function ${\displaystyle f}$ is thought of as a relation ${\displaystyle (x,f(x))}$ on the Cartesian product ${\displaystyle E\times F,}$ then the restriction of ${\displaystyle f}$ to ${\displaystyle A}$ can be represented by its graph ${\displaystyle G({f|}_{A})=\{(x,f(x))\in G(f):x\in A\}=G(f)\cap (A\times F),}$ where the pairs ${\displaystyle (x,f(x))}$ represent ordered pairs in the graph ${\displaystyle G.}$

### Extensions

A function ${\displaystyle F}$ is said to be an extension of another function ${\displaystyle f}$ if whenever ${\displaystyle x}$ is in the domain of ${\displaystyle f}$ then ${\displaystyle x}$ is also in the domain of ${\displaystyle F}$ and ${\displaystyle f(x)=F(x).}$ That is, if ${\displaystyle \operatorname {domain} f\subseteq \operatorname {domain} F}$ and ${\displaystyle F{\big \vert }_{\operatorname {domain} f}=f.}$

A linear extension (respectively, continuous extension, etc.) of a function ${\displaystyle f}$ is an extension of ${\displaystyle f}$ that is also a linear map (respectively, a continuous map, etc.).

## Examples

1. The restriction of the non-injective function${\displaystyle f:\mathbb {R} \to \mathbb {R} ,\ x\mapsto x^{2))$ to the domain ${\displaystyle \mathbb {R} _{+}=[0,\infty )}$ is the injection${\displaystyle f:\mathbb {R} _{+}\to \mathbb {R} ,\ x\mapsto x^{2}.}$
2. The factorial function is the restriction of the gamma function to the positive integers, with the argument shifted by one: ${\displaystyle {\Gamma |}_{\mathbb {Z} ^{+))\!(n)=(n-1)!}$

## Properties of restrictions

• Restricting a function ${\displaystyle f:X\rightarrow Y}$ to its entire domain ${\displaystyle X}$ gives back the original function, that is, ${\displaystyle f|_{X}=f.}$
• Restricting a function twice is the same as restricting it once, that is, if ${\displaystyle A\subseteq B\subseteq \operatorname {dom} f,}$ then ${\displaystyle \left(f|_{B}\right)|_{A}=f|_{A}.}$
• The restriction of the identity function on a set ${\displaystyle X}$ to a subset ${\displaystyle A}$ of ${\displaystyle X}$ is just the inclusion map from ${\displaystyle A}$ into ${\displaystyle X.}$[2]
• The restriction of a continuous function is continuous.[3][4]

## Applications

### Inverse functions

 Main article: Inverse function

For a function to have an inverse, it must be one-to-one. If a function ${\displaystyle f}$ is not one-to-one, it may be possible to define a partial inverse of ${\displaystyle f}$ by restricting the domain. For example, the function

${\displaystyle f(x)=x^{2))$
defined on the whole of ${\displaystyle \mathbb {R} }$ is not one-to-one since ${\displaystyle x^{2}=(-x)^{2))$ for any ${\displaystyle x\in \mathbb {R} .}$ However, the function becomes one-to-one if we restrict to the domain ${\displaystyle \mathbb {R} _{\geq 0}=[0,\infty ),}$ in which case
${\displaystyle f^{-1}(y)={\sqrt {y)).}$

(If we instead restrict to the domain ${\displaystyle (-\infty ,0],}$ then the inverse is the negative of the square root of ${\displaystyle y.}$) Alternatively, there is no need to restrict the domain if we allow the inverse to be a multivalued function.

### Selection operators

 Main article: Selection (relational algebra)

In relational algebra, a selection (sometimes called a restriction to avoid confusion with SQL's use of SELECT) is a unary operation written as ${\displaystyle \sigma _{a\theta b}(R)}$ or ${\displaystyle \sigma _{a\theta v}(R)}$ where:

• ${\displaystyle a}$ and ${\displaystyle b}$ are attribute names,
• ${\displaystyle \theta }$ is a binary operation in the set ${\displaystyle \{<,\leq ,=,\neq ,\geq ,>\},}$
• ${\displaystyle v}$ is a value constant,
• ${\displaystyle R}$ is a relation.

The selection ${\displaystyle \sigma _{a\theta b}(R)}$ selects all those tuples in ${\displaystyle R}$ for which ${\displaystyle \theta }$ holds between the ${\displaystyle a}$ and the ${\displaystyle b}$ attribute.

The selection ${\displaystyle \sigma _{a\theta v}(R)}$ selects all those tuples in ${\displaystyle R}$ for which ${\displaystyle \theta }$ holds between the ${\displaystyle a}$ attribute and the value ${\displaystyle v.}$

Thus, the selection operator restricts to a subset of the entire database.

### The pasting lemma

 Main article: Pasting lemma

The pasting lemma is a result in topology that relates the continuity of a function with the continuity of its restrictions to subsets.

Let ${\displaystyle X,Y}$ be two closed subsets (or two open subsets) of a topological space ${\displaystyle A}$ such that ${\displaystyle A=X\cup Y,}$ and let ${\displaystyle B}$ also be a topological space. If ${\displaystyle f:A\to B}$ is continuous when restricted to both ${\displaystyle X}$ and ${\displaystyle Y,}$ then ${\displaystyle f}$ is continuous.

This result allows one to take two continuous functions defined on closed (or open) subsets of a topological space and create a new one.

### Sheaves

 Main article: Sheaf theory

Sheaves provide a way of generalizing restrictions to objects besides functions.

In sheaf theory, one assigns an object ${\displaystyle F(U)}$ in a category to each open set ${\displaystyle U}$ of a topological space, and requires that the objects satisfy certain conditions. The most important condition is that there are restriction morphisms between every pair of objects associated to nested open sets; that is, if ${\displaystyle V\subseteq U,}$ then there is a morphism ${\displaystyle \operatorname {res} _{V,U}:F(U)\to F(V)}$ satisfying the following properties, which are designed to mimic the restriction of a function:

• For every open set ${\displaystyle U}$ of ${\displaystyle X,}$ the restriction morphism ${\displaystyle \operatorname {res} _{U,U}:F(U)\to F(U)}$ is the identity morphism on ${\displaystyle F(U).}$
• If we have three open sets ${\displaystyle W\subseteq V\subseteq U,}$ then the composite ${\displaystyle \operatorname {res} _{W,V}\circ \operatorname {res} _{V,U}=\operatorname {res} _{W,U}.}$
• (Locality) If ${\displaystyle \left(U_{i}\right)}$ is an open covering of an open set ${\displaystyle U,}$ and if ${\displaystyle s,t\in F(U)}$ are such that ${\displaystyle s{\big \vert }_{U_{i))=t{\big \vert }_{U_{i))}$s|Ui = t|Ui for each set ${\displaystyle U_{i))$ of the covering, then ${\displaystyle s=t}$; and
• (Gluing) If ${\displaystyle \left(U_{i}\right)}$ is an open covering of an open set ${\displaystyle U,}$ and if for each ${\displaystyle i}$ a section ${\displaystyle x_{i}\in F\left(U_{i}\right)}$ is given such that for each pair ${\displaystyle U_{i},U_{j))$ of the covering sets the restrictions of ${\displaystyle s_{i))$ and ${\displaystyle s_{j))$ agree on the overlaps: ${\displaystyle s_{i}{\big \vert }_{U_{i}\cap U_{j))=s_{j}{\big \vert }_{U_{i}\cap U_{j)),}$ then there is a section ${\displaystyle s\in F(U)}$ such that ${\displaystyle s{\big \vert }_{U_{i))=s_{i))$ for each ${\displaystyle i.}$

The collection of all such objects is called a sheaf. If only the first two properties are satisfied, it is a pre-sheaf.

## Left- and right-restriction

More generally, the restriction (or domain restriction or left-restriction) ${\displaystyle A\triangleleft R}$ of a binary relation ${\displaystyle R}$ between ${\displaystyle E}$ and ${\displaystyle F}$ may be defined as a relation having domain ${\displaystyle A,}$ codomain ${\displaystyle F}$ and graph ${\displaystyle G(A\triangleleft R)=\{(x,y)\in F(R):x\in A\}.}$ Similarly, one can define a right-restriction or range restriction ${\displaystyle R\triangleright B.}$ Indeed, one could define a restriction to ${\displaystyle n}$-ary relations, as well as to subsets understood as relations, such as ones of the Cartesian product ${\displaystyle E\times F}$ for binary relations. These cases do not fit into the scheme of sheaves.[clarification needed]

## Anti-restriction

The domain anti-restriction (or domain subtraction) of a function or binary relation ${\displaystyle R}$ (with domain ${\displaystyle E}$ and codomain ${\displaystyle F}$) by a set ${\displaystyle A}$ may be defined as ${\displaystyle (E\setminus A)\triangleleft R}$; it removes all elements of ${\displaystyle A}$ from the domain ${\displaystyle E.}$ It is sometimes denoted ${\displaystyle A}$ ⩤ ${\displaystyle R.}$[5] Similarly, the range anti-restriction (or range subtraction) of a function or binary relation ${\displaystyle R}$ by a set ${\displaystyle B}$ is defined as ${\displaystyle R\triangleright (F\setminus B)}$; it removes all elements of ${\displaystyle B}$ from the codomain ${\displaystyle F.}$ It is sometimes denoted ${\displaystyle R}$ ⩥ ${\displaystyle B.}$