Definition of inner product as in the case of work According to the mathematical definition of "vectors", vectors are simply the elements of a set $V$ which forms a vector space structure $(V,F,+,*)$. The definition of inner product states that it is a function from $\langle ,\rangle :V\times V \rightarrow F$ with the properties of inner products being satisfied as such. My questions is: How do we then define the dot product like work $dW=F.dx$ where $F$ and $dx$ are both vectors as per the mathematical definition? Because both the vector $F$ and $dx$ belong to two different vector spaces, so how do we define "inner product" between them?
 A: If you consider $F$ and $dx$ as in different Vector spaces, you are entering in the region of Differential Geometry. Here the things are more complicated, since vectors are defined as the element of the tangent space defined in each point of the manifold, and in order to compare vectors in different points you have to define a rule (which is the parallel transport), which in turn is defined by a covariant derivative.
In your example though, $\vec{F}=(F_x,F_y,F_z)$ and $d\vec{x}=(dx,dy,dz)$ so that they can be thought of belonging to $\mathbb{R}^3$, and the '$\cdot$' (dot) product is just the usual one.
EDIT::
!Attention! Mathematical atrocity incoming
You consider the Work as a function:
$$W:\mathbb{R}^3\to\mathbb{R}$$
then when you write the differential $dW$ you mean:
$$dW=\frac{\partial W(x,y,z)}{\partial x}dx+\frac{\partial W(x,y,z)}{\partial y}dy+\frac{\partial W(x,y,z)}{\partial z}dz$$
Then you can think of the vector field $\vec{F}:\mathbb{R}^3\to\mathbb{R}^3$ as:
$$\vec{F}=\left(\frac{\partial W(x,y,z)}{\partial x},\frac{\partial W(x,y,z)}{\partial y},\frac{\partial W(x,y,z)}{\partial z} \right)$$
and then you can think of $dW$ as this $\vec{F}\cdot d\vec{x}$. But clearly this dot product is not that well defined if you consider the real meaning of the symbol $d\vec{x}$ ($dW$ is a differential form).
Mathematical Rigour
If we want to be more precise, the work done by an external field $\vec{F}:\mathbb{R}^3\to\mathbb{R}^3$ along a path $\gamma\subset\mathbb{R}^3$ which is parametrized by $\phi:[a,b]\to\gamma$, is the following second class line integral:
$$W=\int_a^b \langle\vec{F}(\phi(t)),\frac{\phi'(t)}{||\phi'(t)||}\rangle ||\phi'(t)||dt$$
And that's why, naively, one can think to differentiate both terms and get the infinitesimal work as you wrote, but it is just an handy writing to mean that the total work is the formula above.
A: I assume you're referring to the fact that they belong to different vector spaces because they have different units. The difficulty you're running into is just an indication of an inconvenience in the set of definitions and foundations for mathematics that currently happens to be popular. To understand this, it may be helpful to look at the history.


*

*Something like what we today define as a vector space was first defined by Peano in 1888.

*Vectors, including the words "vector" and "scalar," were defined by Gibbs around 1888, as a way of simplifying the quaternion system for his students at Yale.

*Physicists' modern definition of a vector, which involves its transformation properties, was standardized ca. 1930-1950.

*Set theory was cast into something like its present form by by ZFC in 1908-1922.
Keep in mind that all of these developments really occurred over the period of many years, not on specific dates, so what we really have is an overlapping set of time periods, with people working independently of one another and not necessarily producing consistent systems.
The basic notions that we really need in order to do linear algebra are algebraic, i.e., essentially syntactical facts, e.g., the property $(a\textbf{u})\cdot\textbf{v}=a(\textbf{u}\cdot\textbf{v})$. When you look at an axiom like this one and then apply it, it makes no difference whether or not the objects $a$, $\textbf{u}$, and $\textbf{v}$ belong to certain sets. The notion of a set came later than the notion of a vector space. The fact that people today usually use ZFC as a foundation and define things like vector spaces in terms of operations on some set does not mean that it has to be done that way, was historically done that way, or is always convenient to do that way.
So for example, suppose an object starts at rest and is accelerated by a constant force $\textbf{F}$, so that $\textbf{F}=(2m/t^2)\textbf{x}$. The identities that define the properties of the inner product have the same syntactical form, and therefore lead to the same results, regardless of the fact that it wouldn't make sense to talk about $\textbf{F}+\textbf{x}$. You can find the work done by this force, and while you're doing that, you can freely use the identity $(a\textbf{u})\cdot\textbf{v}=a(\textbf{u}\cdot\textbf{v})$. 
If you like, you can describe forces and displacements as different vector spaces with some machinery to connect them so that you can do dot products, or if you like, you can think of them as both belonging to some sort of space that has some forbidden operations, such as not being able to some additions. It doesn't matter which of these you do, and in practice nobody does anything like this formally.
Keep in mind also that the physicist's definition of a vector is more restrictive than a mathematician's, e.g., if you form an ordered pair consisting of $(S,q)$, where $S$ is the current value of the S&P 500 stock market index, and $q$ is an electric charge, then to a mathematician, this is a vector that lives in some vector space, but to a physicist this is not a vector at all, because it doesn't transform as a vector.
A: I'm not sure if your claim that $F$ and $dx$ lie in different vector spaces stems from the fact that one is infinitesimal and the other isn't, or that they have different physical units and so can't be added together. If it's the former, then we can consider a line integral as a limit of sums of dot products of non-infinitesimal vectors.
If it's the latter, then we can get at the same issue without needing to consider the complication of vector spaces by asking why we can multiply together two scalar quantities with different units, even though they can't be added together and so don't (obviously) lie in the same field (in the abstract algebra sense of the word). Mathematically formalizing elementary dimensional analysis is actually surprisingly nontrivial: Terry Tao has a nice treatment here.
The "quick and dirty" answer is that when you think of the formal mathematical/abstract-algebraic structure of the space of possible values for a physical quantity, you forget about units and treat everything as dimensionless. (E.g. you think of all three-vectors as living in $\mathbb{R}^3$, regardless of their physical units.) Then afterward, you declare operations that don't make dimensional sense to be "physically invalid" even though they're perfectly legitimate from a formal mathematical perspective. "Hard-coding" the dimensional restrictions on the set of allowed operations directly into the formal mathematical structure is usually way more effort than it's worth.
(One last comment, which goes significantly beyond the scope your question, so feel free to ignore it. The "dimensionful" approach gets really annoying in the operator formalism of quantum mechanics, because in that case scalar multiplication by a dimensionful "scalar" actually formally takes a vector to another vector in a different (though isomorphic) Hilbert space. This means that linear "operators" corresponding to dimensionful observables actually aren't operators at all, but linear maps between different Hilbert spaces. The innocuous equation $\hat{H} |\psi\rangle = E |\psi\rangle$ is just a straightforward eigenvalue equation in the "dimensionless" formalism, but it's a much more subtle category-theoretic generalization of the eigenvalue equation in the "dimensionful" formalism, in which you can't add $|\psi\rangle + E |\psi\rangle$. Trust me, sometimes mathematical rigor just isn't worth it.)
A: If you are referring to them having different physical dimensions ($[F] = MLT^{-2}$ and $[dx] = L$) and units, then we can think of the two spaces being what could be called "tagged vector spaces". Such can be seen as tuples of a vector space and a tag (e.g. a unit), like $\langle \mathbb{R}^3, \mathrm{N} \rangle$ and $\langle \mathbb{R}^3, \mathrm{m}\rangle.$ I will denote elements in these spaces also as tagged values, e.g. $\langle f, \mathrm{N} \rangle,$ where $f \in \mathbb{R}^3.$
Addition is only allowed inside a tagged vector space and is defined by $\langle u_1, \text{tag} \rangle + \langle u_2, \text{tag} \rangle = \langle u_1+u_2, \text{tag} \rangle.$
Multiplication (of some kind) of two vectors $\langle u, \mathrm{u} \rangle$ and $\langle v, \mathrm{v} \rangle$ is allowed if multiplication of $u$ and $v$ is allowed, and is defined as $\langle u, \mathrm{u} \rangle * \langle v, \mathrm{v} \rangle = \langle u*v, \mathrm{u}\mathrm{v} \rangle.$ Here $\mathrm{u}\mathrm{v}$ is a product of units, so the set of units should be monoid.
A: Excellent question. Indeed I would argue that force is not a spacial vector, but a dual vector. Specifically, a cotangent vector. The cotangent space at a point $p$ is defined as the space of linear functionals on the tangent space at that point, i.e. $F(p) \in T_p^\ast M$ can be used as a linear map
$$\begin{align}
    F(p):&\quad T_pM \to \mathbb{R}
 \\ F(p):&\quad\mathrm{d}x \mapsto F(p)\ \mathrm{d}x
 \\ \text{or}&  \quad v \mapsto F(p)\ v \quad\text{with infinitesimal $v$}
 \\ \text{fulfilling} & \quad F(p)\ (\mu\cdot v + \nu\cdot w) = \mu\cdot F(p)\ v + \nu\cdot F(p)\ w
\end{align}$$
In that light, this isn't so much scalar multiplication at all what we're dealing with, as just function application.
Where do these linear functionals come from? Well, taking the POV that conservation of energy is the more fundamental principle, we might say the potential of a conservative field is the prototypical setup for force to arise (whereas nonconservative forces are emergent, either from friction etc. which just moves energy into microstates, or artificial mechanical setups). In that light, force would be defined as the gradient of the potential:
$$
  F(p) := \nabla\phi(p)
$$
A gradient is usually described as a vector, but it's arguably mathematically more sensible to describe it as a dual vector, namely as the unique linear functional such that
$$
  \lim_{\epsilon\to0}\frac{\phi(p+\epsilon\cdot v)-\phi(p)}{\epsilon} = F(p)\ v
$$
where $v$ is actually a finite length vector, i.e. a direct path between $p$ and some other point $q$, which through the limiting process with $\epsilon$ is merely scaled down to “infinitesimal length”. (That there exists such a unique functional is precisely the mathematical definition of differentiability.)
All of this works smoothly, but where it gets interesting is when we consider that force does in practice also seem to have traits of a spatial vector. Namely, it points in a certain direction. So, we have some correspondence between the dual-vector and vector natures of $F$. This correspondence is the Hodge star operator. It is essentially an application of the Riesz representation theorem, which is IMO one of the most important and underrated results needed for lots of physics.
A: Thinking about this in the finite case, without dealing with infinitesimals, you have $F\cdot \Delta x$. Both vectors in this inner product do live in the same space, namely $\mathbb{R}^3$ in usual 3-d space, at least up to an isomorphism.
