This post will discuss the definition of the four functors "pushforward" ff_\ast, "pullback" ff^\ast, "pushforward with compact support" f!f_{!} and "exceptional pullback" f!f^{!} of sheaves of abelian groups, associated to a continuous morphism f:XYf : X \to Y of topological spaces XX and YY. Then we will look at maps ff which are open immersions or closed immersions, and calculate in the example of C×C\mathbb{C}^\times \to \mathbb{C} and its closed complement {0}C\{0\} \to \mathbb{C} exactly what happens. This is intended to give some intuition what the general four functor calculus is about.

The four functor formalism arises as part of the six functor formalism (add Hom and Tensor to make it six) in certain (co)homological set-ups. Where I encountered it first was in a paper I tried to read, about the stable motivic homotopy category, but most likely you'll see this stuff in papers dealing with perverse sheaves or motives and their realisations.

Disclaimer: We'll stay in the topological category for this post, i.e. the objects are topological spaces and the morphisms continuous maps. Sheaves are ordinary sheaves of abelian groups (no fancy Grothendieck topology necessary here), not O\mathcal{O}-modules of some sort. However, the discussion doesn't change too much if you translate into the algebraic category, so this should be a good exercise for the bored reader.

Pushforward

Pushforward of sheaves is straightforward: given a space XX, a sheaf FF on XX and a continuous map f:XYf : X \to Y, the sheaf fFf_\ast F on YY should be a sheaf that does on open subsets YY what FF had done on the corresponding open subsets of XX, i.e. (fF)(U):=F(f1U)(f_\ast F)(U) := F(f^{-1}U). Check that this definition gives again a sheaf. Observe that the constant map c:Xptc : X \to pt yields (cF)(pt)=F(X)(c_\ast F)(pt) = F(X), so cc_\ast is almost the global section functor and we should think of any ff_\ast as some kind of generalized global section functor.

Pullback

I want to define the pullback functor f:Sh(Y)Sh(X)f^\ast : Sh(Y) \to Sh(X) as the left adjoint to ff_\ast. Of course, I have to show existence.
If ff would be an open embedding, we would have f(U)f(U) open in YY for all open subsets UU of XX, and it would be natural to define (fG)(U):=G(f(U))(f^\ast G)(U) := G(f(U)). To see that we indeed have a left adjoint by this definition is up to you, but it fails for a general ff, since f(U)f(U) needn't be open in general.
So, given a sheaf GG on YY I define a new presheaf on XX by UlimG(V)U \mapsto \lim_{\rightarrow} G(V), where the limit ranges over all open subsets VV such that VV contains f(U)f(U). By this "trick" we circumvent the given problem (and introduce new behaviour) and it turns out that this is a correct definition, in the technical sense that we really have found a left adjoint to ff_\ast.

Proof of the adjunction Hom(fG,F)=Hom(G,fF)Hom(f^\ast G, F) = Hom(G,f_\ast F):
for an open subset UU of XX, a homomorphism from (fG)(U)(f^\ast G)(U) to F(U)F(U) is just a homomorphism from limG(V)\lim_{\rightarrow} G(V) to F(U)F(U) and a homomorphism from G(V)G(V) to (fF)(V)(f_\ast F)(V) is just a homomorphism from G(V)G(V) to F(f(V))F(f(V)). So you see, if we have homomorphisms G(V)F(f(V))G(V) \to F(f(V)) for all VV, this gives in the limit homomorphisms limG(V)limF(f(V))=F(U)\lim_{\rightarrow} G(V) \to \lim_{\rightarrow} F(f(V)) = F(U).
For the other direction, observe that if we have homomorphisms limG(V)F(U)\lim_{\rightarrow} G(V) \to F(U) for all UU, we certainly have this for all U=f(V)U=f(V), where the limit is just G(V)G(V), i.e. where we have just G(V)F(f(V))G(V) \to F(f(V)).

Pushforward with compact support

We have already seen how pushforward generalizes global sections. As global sections give (as derived functor) cohomology of sheaves, there is a global section with compact support functor, which gives cohomology with compact support. For the locally constant sheaf Z\mathbb{Z} this gives back "singular" cohomology with compact support, as it appears in Poincaré duality. I will explain this in some more detail now, although I won't explain how to move from global sections to cohomology.

Poincaré duality states, for a smooth compact complex n-dimensional manifold X
!Hk(X;R)H2nk(X;R)! H^k(X;\mathbb{R}) \simeq H_{2n-k}(X;\mathbb{R})
and if X is not compact, there is still Poincaré duality:
!Hck(X;R)H2nk(X;R)! H^k_c(X;\mathbb{R}) \simeq H_{2n-k}(X;\mathbb{R})
where HckH^k_c is the cohomology with compact support,
which is related to the functor of global sections with compact support,
just as ordinary cohomology is related to the ordinary global section functor.

The functor of global sections with compact support Γc\Gamma_c is defined as
!Γc(F,U):={sF(U)supp(s) compact}F(U)=Γ(F,U).! \Gamma_c(F,U) := \{ s \in F(U) | supp(s) \text{ compact} \} \subset F(U) = \Gamma(F,U).

By analogy, we define the pushforward with compact support f!f_{!} as a subfunctor of ff_\ast (which just means that f!Ff_{!} F will be a subsheaf of fFf_\ast F for every FF, which in turn just means that (f!F)U(f_{!}F) U is a subset of (fF)U(f_\ast F) U for every open set UU).
!(f!F)(U):={sF(f1U)fsupp(s):supp(s)U proper}.! (f_{!}F)(U) := \{ s \in F(f^{-1}U) | f|supp(s) : supp(s) \to U \text{ proper}\}.
This really gives a sheaf and for ff the constant map to a point,
the values are exactly Γc(F,X)\Gamma_c(F,X).

An example:
Let ff be an open embedding f:UXf : U \to X, then f!Ff_{!} F is just the "extension by zero", i.e. the stalks at all points of UU are just the same as those of FF, and all other/new stalks (over XUX \setminus U) are plain 00.

Another example:
Let ff be a proper map f:YXf : Y \to X, then f!=ff_{!} = f_\ast, as you can see from the definition.

A comprehensive example:
If ff can be factored into f=pjf = p \circ j with jj an open embedding and pp proper, we have f!=pj!f_{!} = p_\ast \circ j_{!}, which gives a very explicit description of f!f_{!}.

Exceptional inverse image

We define a functor f!f^{!} called exceptional inverse image, as the right adjoint to f!f_{!}, if it exists. We should say straightforward, that it doesn't exists, in general, on the level of sheaves and this is one of the things that makes working with complexes of sheaves necessary (in fact, the derived category).

However, for innocent maps ff, we can actually define a functor that is right adjoint to f!f_{!} and thus deserves to be called f!f^{!}.

For f an open embedding f:UXf : U \to X, we have just f!=ff^{!} = f^\ast, i.e. the functor ff^\ast is the left adjoint to ff_\ast and also the right adjoint to f!f_{!}.
The proof is similar to the proof of the adjointness of ff^\ast with ff_\ast, so I leave it out.

Now I want to make clear why a right adjoint to f!f_{!} doesn't exist (on the level of sheaves) in general, for categorical reasons.

Every left adjoint functor preserves colimits, since an adjunction like
!Hom(f!F,G)Hom(F,f!G)! Hom(f_{!} F, G) \simeq Hom(F, f^{!} G)
means that one can compute Hom(f!(),G)Hom(f_{!}(-), G) as the Hom-functor Hom(,f!G)Hom(-, f^{!}G), where colimits in the first argument are obviously preserved (now apply Yoneda lemma). There we use that the Hom-functor turns colimits in its first argument into limits, which doesn't work with limits, so left adjoints needn't preserve limits. Exercise: apply the same reasoning to see that right adjoints preserve limits.

Now being right-exact is a special case of preserving colimits, since it means to preserve cokernels (which are special colimits). Clearly, f!f_{!} is not right-exact, since it has cohomology: let XX be a compact space and ff the constant map to a point. Then for f!=f=cΓf_{!} = f_\ast = c_\ast \simeq \Gamma to be right-exact, the cohomology on XX must vanish.

The salvation consists of enlarging the category of sheaves to the category of chain complexes of sheaves, only to make it smaller again by introducing the appropriate definition of morphisms, which in the end gives what is called the derived category of abelian sheaves. There, a general f!f^{!} exists.

Concrete examples for four functors

Let us look at the embedding j:C×Cj : \mathbb{C}^\times \to \mathbb{C} and its closed complement i:{0}Ci : \{0\} \to \mathbb{C}.

First we will look at a skyscraper sheaf on {0}\{0\} with stalk some abelian group AA over 00. We denote the skyscraper sheaf by FF. By definition, we have i!F=iFi_{!} F = i_\ast F a skyscraper sheaf with stalk AA over 00. Now j!iF=jiF=0j^{!} i_\ast F = j^\ast i_\ast F = 0, since jj^\ast throws away all information from the stalk over 00.

Okay, let's look at a local system on C\mathbb{C}, i.e. a locally constant sheaf FF.
This is the same data (an equivalent category) as the monodromy representation of the fundamental group, in this case π1(C×,1)Z\pi_1(\mathbb{C}^\times,1) \simeq \mathbb{Z}.
We have as j!Fj_{!} F a sheaf with stalks just FxF_x where x0x \neq 0, and (j!F)0=0(j_{!} F)_0 = 0, since every section with compact support is away from an arbitrarily small ball around the origin.
The sheaf jFj_\ast F has the same stalks FxF_x where x0x \neq 0 but it has a new one at the origin, given by the usual stalk-limit-formula you would write down - and in general, this is non-zero.

Cleary ij!Fi^\ast j_{!} F vanishes, since ii^\ast picks the stalk at the origin and throws away everything else. Of course, ijFi^\ast j_\ast F contains exactly the "new" stalk which might be interesting.
Thinking about it, the sheaves i!j!Fi^{!} j_{!} F and i!jFi^{!} j_\ast F are both zero, by the same argument we had for (j!F)0(j_{!} F)_0. Here you can also use the adjunction for reasoning!

Last words

The nice thing about this setting is that it generalizes to give the following:

Take VV a closed subspace in XX and UU its open complement, then you have an open embedding jj and a closed embedding ii which behave very much like our jj and ii from the last examples. It presents the category of sheaves on XX as an extension of the sheaves on VV by the sheaves on UU. The same happens for the derived category. The magic word for this situation is "Recollement".