Mathematical definition of a pipeline of functions.

477 Views Asked by At

I'm trying to represent a pipeline of functions, each of which accepts an object and returns a potentially different object, in mathematical notation.

Assume we have sets $X$ and $Y$.

Each function in the pipeline can be defined as follows, I believe:

$f : X \times Y \rightarrow X \times Y$

An ordered set of these (a single pipeline) could be defined, for example, as a tuple (where the pipeline has two items)

$f \times f$

or a triple where it has three

$f \times f \times f$

I'd like to represent the set of all possible such ordered pairs, of any length.

Calling this set $P$ I'd then want:

$P \times X \rightarrow X$

which is the result of sending $X$ through the pipeline.

Is this the correct approach?

1

There are 1 best solutions below

3
On BEST ANSWER

Your written description and the way you define your function contradict each other. $ f : X \times Y \to X $ is a function that takes two arguments and returns a single object.

However it looks like the idea that you are trying to express is called composition. This is where you take two functions $f$ and $g$ and feed the output of the first into the next. $f(g(x))$. The notation used for composistion is $\circ$ and can be defined this way $ (f \circ g)(x) = f(g(x)) $. For this to work the domain of $f$ must be a superset of the codomain of g.

You can extend the notion of composition to create a sigma like operator $\bigcirc (f_0,f_1, \dots ) = f_0 \circ f_1 \circ \dots $ this will have the type $ P \times X \to X $ if all the functions are of the type $ X \to X$.

You can define $P$ recursively first with the base $ P_0 = X^X $ (where $X^X$ is the set of all functions $ X \to X $) and the recursive step $P_n = P_0 \times P_{n-1}$. Then unify the lot with $ P = \bigcup \{ f_n | n \in \mathbb{N} \} $. Alternately you can define $P$ to be the kleene closure of $X^X$.