Cauchy-Schwarz inequality for bilinear forms valued in an abstract vector space This question is perhaps a little vague; part of what I want to know is what question I should ask.
First, recall the following form of the Cauchy-Schwarz inequality: let $V$ be a real vector space, and suppose $(\cdot, \cdot) : V \times V \to \mathbb{R}$ is a symmetric bilinear form which is positive semidefinite, that is, $(x,x) \ge 0$ for all $x$.  Then for any $x,y \in V$ we have $|(x,y)|^2 \le (x,x) (y,y)$.
I'd like to know what happens if we replace $\mathbb{R}$ by some other space $W$.  Suppose at first that $W$ is a real vector space, equipped with a partial order $\le$ that makes it an an ordered vector space, as well as a multiplication operation $\cdot$ that makes it an algebra.  Then it makes sense to speak of a positive semidefinite symmetric bilinear form $(\cdot, \cdot) : V \times V \to W$, and ask whether it satisfies the Cauchy-Schwarz inequality $(v,w)\cdot(v,w) \le (v,v) \cdot (v,w)$.

Under what conditions on $W$ does this "generalized Cauchy-Schwarz inequality" hold?

At a minimum I expect we will need some more structure on $W$; in particular I assume we would like the multiplication and the partial ordering in $W$ to interact in some reasonable way, so that for instance $w\cdot w \ge 0$ for all $w \in W$.  Are there other properties that $W$ should have?
There are lots of proofs of the classical Cauchy-Schwarz inequality; presumably one should try to find one of them which generalizes.  But I couldn't immediately see how to do this.

Here are some motivating examples.
As a fairly simple one, let $X$ be any set, and $W = \mathbb{R}^X$ the vector space of all real-valued functions on $X$.  We can equip $W$ with the pointwise multiplication and ordering.  Then let $V$ be any linear subspace of $W$, and let the bilinear form $V \times V \to W$ also be pointwise multiplication.  Then of course Cauchy-Schwarz holds since we can just prove it pointwise.
For a slightly less trivial example, let $(X,\mu)$ be a measure space, and $W = L^0(X,\mu)$ be the vector space of all measurable functions on $X$, mod $\mu$-almost-everywhere equality (so an element of $W$ is in fact an equivalence class of functions).  Again let $\cdot$ be pointwise multiplication (which is well defined), and the ordering $f \le g$ when $f(x) \le g(x)$ almost everywhere.  Take again a linear subspace $V \subset W$, and pointwise multiplication as the bilinear form.  Now Cauchy-Schwarz holds because we can prove it pointwise on a set of full measure.
A related but more complicated example from probability (and my original motivation) is the quadratic variation form from probability.  For instance, we could take $V$ to be the vector space of continuous $L^2$ martingales on some filtered probability space over some time interval $[0,T]$, and $W$ the vector space of continuous adapted processes of bounded variation, mod indistinguishability, with pointwise multiplication and the partial order $X \le Y$ iff $X_t \le Y_t$ for all $t$ almost surely.  Then the quadratic variation $\langle M,N \rangle$ is a symmetric positive semidefinite bilinear form from $V \times V$ to $W$.  
In this case I can prove the Cauchy-Schwarz inequality pointwise: fix $M,N \in V$.  For almost every $\omega$, for all $t \in [0,T]$ and all $q \in \mathbb{Q}$ I can say
$$q^2 \langle M,M \rangle_t(\omega) \pm 2 \langle M,N \rangle_t(\omega) + \frac{1}{q^2} \langle N,N \rangle_t(\omega) = \langle q M \pm \frac{1}{q} N \rangle_t(\omega) \ge 0$$
and then letting $q$ be a rational very close to $\sqrt{\langle N,N \rangle_t(\omega) / \langle M,M \rangle_t(\omega)}$ shows that $$|\langle M,N \rangle_t(\omega)| \le \sqrt{\langle M,M \rangle_t(\omega) \langle N,N \rangle_t(\omega)}$$
which is what we want.
In each of these examples, we are working on function spaces (or quotients thereof), and the proof essentially operates pointwise.  I'm hoping for some kind of more abstract global argument.
 A: I think the space $W$ should be defined a partial order $\leq$ and zero element $0$ firstly and satisfy:


*

*If $a\leq b$ then $ca\leq cb$, $\forall a,b\in W$ and $0\leq c\in W$.

*If $a\leq b$ then $a-b\leq 0$.


Secondly, a multiply operator $\cdot$ should be defined in $W$ and satisfy $0\leq a\cdot a\stackrel{\triangle}{=}a^2$ for $\forall a\in W$. Also, the inverse operator of $\cdot$ should be defined in $W$ (Alternatively, the inverse element is defined in $W$). That is, if $ab=c$ then $c\stackrel{\triangle}{=}a/b$ for $\forall a,b,c\in W$ and $b\neq 0$ where $/$is the inverse operator of $\cdot$. What is more, these operators should be closed in $W$. Say, if $\forall a,b\in W$ then $a\cdot b\in W$ and $a/b\in W$ if $b\neq 0$. Finally, the operators $\cdot$ and /should satisfy commutative law.
Thirdly, there should have a multiply operator between the elements from $W$ and $V$ because we will define inner product by using this operator. 
What is more, to hold the Cauchy-Schwarz inequality, the properties of inner product is important. I believe the Cauchy-Schwarz inequality is valid in a space which define a inner product whose definition is classical. In another word, if a space $V$ have been defined a inner product $(*,*)$ (say, a bilinear form that $V\times V\rightarrow W$) satisfy the following conditions:


*

*Commutative: $(x,y)=(y,x)$, $\forall x,y\in V$ (If V is a complex space, the right hand side should be dual. But for the sake of simplicity, we ignore it here.)

*Linearity: $(\alpha x+\beta y, z)=\alpha(x,z)+\beta(y,z)$, $\forall x,y,z\in V$ and $\alpha,\beta\in W$.

*Positive define: $(x,x)\geq0$, $\forall x\in V$. The equal sign is valid iff $x=0$ is valid where $0$ donate the zero element in $W$.


Then, by this definition, the Cauchy-Schwarz inequality is valid. The proof are as follow:
For $\forall\lambda\in W$ and $\forall x,y \in V$, we have:
\begin{equation}
0\leq (x+\lambda y,x+\lambda y)=(x,x)+2\lambda(x,y)+\lambda^2(y,y)
\end{equation}
If $y=0$, that is a trivial case and Cauchy-Schwarz inequality is valid obviously. If $y\neq 0$, let $\lambda=-(x,y)/(y,y)$ then we have:
\begin{equation}
0\leq(x,x)-2(x,y)^2/(y,y)+(x,y)^2/(y,y)^2(y,y)\\
(x,y)^2\leq (x,x)(y,y)
\end{equation}
This is the Cauchy-Schwarz inequality.
In fact, Cauchy-Schwarz inequality imply that the inner product of two elements is less than the their product of length because there is an angle between them. And $W$ is a space to measure the inner product of $V$. So I think the conditions I assume at start is reasonable.
