<p>First, I'm mostly experienced with Math, which I hope won't be too inconvenient.</p>

<p>I saw <a href="https://arxiv.org/abs/1610.07690" rel="nofollow noreferrer">Operational Calculus on Programming Spaces</a> by Sajovic and Vuk, which seemed very interesting to me (for a "short summary" of the paper, the Wikipedia article on <a href="https://en.wikipedia.org/wiki/Automatic_differentiation#Operational_calculus_on_programming_spaces" rel="nofollow noreferrer">Automatic Differentiation</a> may be helpful).  I had a few questions about how they defined their "memory space of the program".  The relevant section is below:</p>

<blockquote>
  <p>We will model computer programs as maps on a vector space. If we only focus on the real
  valued variables (of type <code>float</code> or <code>double</code>), the state of the virtual memory can be seen as a
  high dimensional vector. A set of all the possible states of the program’s memory, can be
  modeled by a finite dimensional real vector space $\mathcal{V} \equiv \mathbb{R}^n$. We will call $\mathcal{V}$ the <em>memory space
  of the program</em>. 
  The effect of a computer program on its memory space $\mathcal{V}$, can be described
  by a map
  $$P : \mathcal{V} \to \mathcal{V}$$
  A programming space is a space of maps $\mathcal{V} \to \mathcal{V}$ that can be implemented as a program in
  specific programming language.</p>
</blockquote>

<p>I understand how $\mathcal{V}$ should be some finite object - I don't understand why this should specifically be a vector space.
One analogy that may be useful for this is the following.  $C(\mathbb{R})$ denotes the set of all continuous functions $f:\mathbb{R}\to\mathbb{R}$. While continuous functions themselves aren't linear, we can define addition of continuous functions and scalar multiplication of continuous functions in a linear way by defining:
$$(f+g)(x) \stackrel{def}{=} f(x) + g(x)$$
$$k\cdot f(x) \stackrel{def}{=} (kf(x))$$
Something similar to this undoubtedly works for programs on $\mathcal{V}$ - for a given state $s$, define $p_1 + p_2$ evaluated on $s$ as $p_1(s) + p_2(s)$.  While this (likely) leaves us with a Banach space, I'm unsure if it's the correct interpretation.</p>

<p>This would give us that the sum of two programs $p_1,p_2$ applied to some state $s$ is just $p_1(s) + p_2(s)$.
So, looking at a single component of $p_1(s) + p_2(s)$, we have that the action of $p_1 + p_2$, as a program, is just the sum of the individual actions of $p_1$ and $p_2$ on the initial state.  This seems like an odd interpretation for me - for whatever reason it'd seem much more natural to have the way to combine programs to be function composition, but this would lead to problems like $+$ not being commutative, and scalar multiplication being harder to define.</p>

<p>In this paper, what's the correct interpretation of addition here?  The "usual" addition seems to lead to the correct mathematical construct, but I'm having a hard time understanding what the "program sum" is supposed to model in real life.</p>

<p>Edit: <a href="https://www.reddit.com/r/math/comments/5l1xet/operational_calculus_on_programming_spaces_and/" rel="nofollow noreferrer">This Reddit Post</a> seems to have some commentary on it which may help others.</p>

CC BY-SA 3.0
2017-05-02T22:00:23.680Z
I know essentially nothing about this except seeing it mentioned in one or two talks. But my impression is that you essentially ignore precision and other finer details and treat a program as a black box that takes real numbers as input and outputs real numbers. So $n$ is an upper bound on the total number of input/output variables and $\mathcal{V}$ is an $n$-dimensional real vector space.
Sasho Nikolov
CC BY-SA 3.0
2017-05-02T22:05:19.220Z
@SashoNikolov after thinking about this more, I'm closer to understanding it.  My issue is that defining $p_1 + p_2$ as $(p_1 + p_2)(x) = p_1(x) + p_2(x)$ for $x\in\mathcal{V}$ would be the "standard" way to proceed mathematically, but for some reason this seems like an odd choice of how to combine programs to me (potentially due to me seeing $p_1 \circ p_2$ to be more natural, essentially just piping output to input, but this probably doesn't give the vector space structure wanted).
Mark Schultz-Wu
CC BY-SA 3.0
2017-05-03T00:07:23.700Z
Assuming $p_1$ and $p_2$ are programs/maps, I see no contradiction here. The product of maps $p_1p_2$ is given by composition, and the sum is what you write in your comment. I.e. programs have more structure than a vector space: they form an associative algebra.
Sasho Nikolov
CC BY-SA 3.0
2017-05-03T00:19:44.810Z
@SashoNikolov In this case, is there any nice interpretation of what $p_1 + p_2$ is?  Composition has an especially nice interpretation problematically as piping things, but I'm having issues finding a suitable interpretation for $p_1 + p_2$ besides "doing two things concurrently and independently from the same initial state, and combining the results".  Is this a good way of thinking about it?
Mark Schultz-Wu
CC BY-SA 3.0
2017-05-04T12:40:49.347Z
We studied this when it came out, they construct a calculus for deep learning. It addresses the shortcomings of purely functional programming (in this frame) by introducing vector spaces and algebra, but it requires a bit different view on programs. Very general results are derived using it. You could write to the authors like we did, they replied.
LeastSquaresWonderer
<fl.formal-languages><ne.neural-evol>
Justifying the state of virtual memory as a vector space
Mark Schultz-Wu
# Justifying the state of virtual memory as a vector space

(Asked by: username_0 on 2017-05-02)

First, I'm mostly experienced with Math, which I hope won't be too inconvenient.

I saw [Operational Calculus on Programming Spaces](https://arxiv.org/abs/1610.07690) by Sajovic and Vuk, which seemed very interesting to me (for a "short summary" of the paper, the Wikipedia article on [Automatic Differentiation](https://en.wikipedia.org/wiki/Automatic_differentiation#Operational_calculus_on_programming_spaces) may be helpful). I had a few questions about how they defined their "memory space of the program". The relevant section is below:

> We will model computer programs as maps on a vector space. If we only focus on the real
> valued variables (of type `float` or `double`), the state of the virtual memory can be seen as a
> high dimensional vector. A set of all the possible states of the program’s memory, can be
> modeled by a finite dimensional real vector space $\mathcal{V} \equiv \mathbb{R}^n$. We will call $\mathcal{V}$ the *memory space
> of the program*.
> The effect of a computer program on its memory space $\mathcal{V}$, can be described
> by a map
> $$P : \mathcal{V} \to \mathcal{V}$$
> A programming space is a space of maps $\mathcal{V} \to \mathcal{V}$ that can be implemented as a program in
> specific programming language.

I understand how $\mathcal{V}$ should be some finite object - I don't understand why this should specifically be a vector space.
One analogy that may be useful for this is the following. $C(\mathbb{R})$ denotes the set of all continuous functions $f:\mathbb{R}\to\mathbb{R}$. While continuous functions themselves aren't linear, we can define addition of continuous functions and scalar multiplication of continuous functions in a linear way by defining:
$$(f+g)(x) \stackrel{def}{=} f(x) + g(x)$$
$$k\cdot f(x) \stackrel{def}{=} (kf(x))$$
Something similar to this undoubtedly works for programs on $\mathcal{V}$ - for a given state $s$, define $p\_1 + p\_2$ evaluated on $s$ as $p\_1(s) + p\_2(s)$. While this (likely) leaves us with a Banach space, I'm unsure if it's the correct interpretation.

This would give us that the sum of two programs $p\_1,p\_2$ applied to some state $s$ is just $p\_1(s) + p\_2(s)$.
So, looking at a single component of $p\_1(s) + p\_2(s)$, we have that the action of $p\_1 + p\_2$, as a program, is just the sum of the individual actions of $p\_1$ and $p\_2$ on the initial state. This seems like an odd interpretation for me - for whatever reason it'd seem much more natural to have the way to combine programs to be function composition, but this would lead to problems like $+$ not being commutative, and scalar multiplication being harder to define.

In this paper, what's the correct interpretation of addition here? The "usual" addition seems to lead to the correct mathematical construct, but I'm having a hard time understanding what the "program sum" is supposed to model in real life.

Edit: [This Reddit Post](https://www.reddit.com/r/math/comments/5l1xet/operational_calculus_on_programming_spaces_and/) seems to have some commentary on it which may help others.

**Tags:** fl.formal-languages, ne.neural-evol
> **Comments:**
> **username_1**: I know essentially nothing about this except seeing it mentioned in one or two talks. But my impression is that you essentially ignore precision and other finer details and treat a program as a black box that takes real numbers as input and outputs real numbers. So $n$ is an upper bound on the total number of input/output variables and $\mathcal{V}$ is an $n$-dimensional real vector space.  
> **username_0**: @SashoNikolov after thinking about this more, I'm closer to understanding it.  My issue is that defining $p_1 + p_2$ as $(p_1 + p_2)(x) = p_1(x) + p_2(x)$ for $x\in\mathcal{V}$ would be the "standard" way to proceed mathematically, but for some reason this seems like an odd choice of how to combine programs to me (potentially due to me seeing $p_1 \circ p_2$ to be more natural, essentially just piping output to input, but this probably doesn't give the vector space structure wanted).  
> **username_1**: Assuming $p_1$ and $p_2$ are programs/maps, I see no contradiction here. The product of maps $p_1p_2$ is given by composition, and the sum is what you write in your comment. I.e. programs have more structure than a vector space: they form an associative algebra.  
> **username_0**: @SashoNikolov In this case, is there any nice interpretation of what $p_1 + p_2$ is?  Composition has an especially nice interpretation problematically as piping things, but I'm having issues finding a suitable interpretation for $p_1 + p_2$ besides "doing two things concurrently and independently from the same initial state, and combining the results".  Is this a good way of thinking about it?  
> **username_2**: We studied this when it came out, they construct a calculus for deep learning. It addresses the shortcomings of purely functional programming (in this frame) by introducing vector spaces and algebra, but it requires a bit different view on programs. Very general results are derived using it. You could write to the authors like we did, they replied.  

---

## 0 answers

