It is known that:

Only in the Euclidean space geodesics satisfy the Pythagorean theorem, a space with curvature equal zero.

The Euclidean space doesn't have to be finite, since the Pythagorean theorem follows directly from the basic properties of the dot product: if $x \cdot v = 0$ , then $(x + v) \cdot (x + v) = x \cdot x + v \cdot v$ , and it even generalizes to Parseval's identity in Hilbert spaces, if, in addition it is proven that dot products induce norms, and that the series $\sum\limits_{n=1}^\infty y_n$ converges in $H$, which is equivalent to the convergence of$\sum\limits_{n=1}^\infty \|y_n\|^2$ for the equation

$$\left\|\sum_{n=1}^{\infty}y_n\right\|^2=\sum_{n=1}^{\infty}\|y_n\|^2$$

Where $\{y_n\}_{n=1}^{\infty}.$ is an infinite collection of mutually orthogonal vectors.

- Let $V$ be a real or complex vector space equipped with an inner product $\langle -, - \rangle$, and let $\| - \|$ be the corresponding norm. One version of the Pythagorean theorem states that if $v_1, \dots v_n$ are mutually orthogonal vectors in $V$ (meaning that $\langle v_i, v_j \rangle = 0$ for $i \neq j$), then $$\left\| \sum v_i \right\|^2 = \sum_i \| v_i \|^2.$$

My question is **about the objects** the Pythagorean theorem can be acted upon. Let me elaborate:
Apart from real numbers (or any other mathematically "simple" enough object for which commutativity and additivity is defined), it can be applied to some matrices under certain assumptions: Assuming the adjoint of a matrix equals the transpose of its complex conjugate, i.e.
$$A' = A^\dagger, \tag 1$$
with
$$A^\dagger = (\bar A)^T; \tag 2$$

Then the Pythagorean theorem can be expressed for matrices as $$ AA^\dagger + BB^\dagger = CC^\dagger; \tag 3$$ (I think it is also a requirement that the matrices must be non-negative semidefinite, but I am unsure about it).

So, the question can be formulated as:

i) What other objects can be input in the Pythagorean identity?, and

ii) What assumptions should be made (on those objects) for this identity to be true?

For example, as in the aforementioned case of the matrices whether it is needed that multiplication and addition is somehow defined (part of a vector space, or if commutativity is needed (or like the matrices, circumvented with a "trick"), or even deeper, if the object must be simply connected (is it really *trivially* satisfied, given that the space of the Pythagorean theorem must be Euclidean and a vector space?), or is it enough that it is a manifold? (if the Pythagorean theorem can be somehow defined sufficiently local, so that distances between points do not have to cross non-connected points, or singularities or poles, for the case of analytic spaces; probably this last remark might be elaborated on its own, perhaps?).