A filter is a system which processes some input signal f(x) into an output signal g(x). The output signal is often referred to as the response of the filter.

Mathematically, a filter is usually denoted as

f(x) -> g(x)

A filter can be a physical system, such as defraction of light. It can also be a purely mathematical formula, an electronic circuit, or a computer algorithm.

Filters are often classified by various criteria. For example, a null filter is such in which the output is exactly same as the input:

f(x) = g(x)

A filter is linear if a linear change in the input produces a linear change in the output, i.e.:

af(x) -> ag(x)
f1(x) + f2(x) -> g1(x) + g2(x)

Or, more generally,

a1f1(x) + a2f2(x) -> a1g1(x) + a2g2(x)

A filter is deemed shift invariant if a shift in the input produces an identical shift in the output:

f(x - a) -> g(x - a)

In reality, most physical filters (e.g., optical lenses) are never quite linear or shift variant (or null). Software generated digital filters can be, and often are, both linear and shift variant (though rarely null, as that would be just a waste of computing resources). They can also produce such g(x) that either does not normally occur in nature, or would be very hard if impossible to create.

Theoretically, any naturally occuring physical filter can be achieved through software. All you need to know is the f(x) and the g(x), though sometimes that is easier said than done.

That means that, at least in theory, a program such as Photoshop equipped with the right plug-ins can produce any effect that a photofilter can do, plus many effects that cannot be produced by purely photographic means. Similarly, a software sound mixer can, theoretically, produce any sound effect that occurs in nature, plus many more.

In practice this is not always the case simply because software filters tend to be linear and shift variant (which makes them much easier to implement and faster to run), while real-world filter tend not to. Even when that is not the case, software filters tend to be more ideal, i.e., more pure math than real-life filters. However, they can come very close to real life, and tend to be cheaper. They also have the advantage that they can be tried and discarded if the effect is not what is expected. They are also easier to modify (e.g., a filter you screw on the camera lens either is there or is not there, but a software filter can be adjusted for many subtle differences in its effectiveness).