\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
                 \usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[all]{xy}

%END usepackaging

\newcommand{\eps}{\varepsilon}
\newcommand{\qz}{{\mathbb{Q}}}
\newcommand{\qzcl}{\overline{\qz}}
\newcommand{\bn}{\begin{enumerate}}
\newcommand{\en}{\end{enumerate}}
\newcommand{\bao}[1]{\begin{array}{#1}}
\newcommand{\ea}{\end{array}}
\newcommand{\bmk}{\paragraph{Remark}}
\newcommand{\bws}{\paragraph{Proof}}
\newcommand{\bsp}{\paragraph{Example}}
\newcommand{\tens}[2]{\left(#1\right)^{\otimes #2}}
\newcommand{\tenso}[2]{#1^{\otimes #2}}
\newcommand{\twotens}[1]{\tens{#1}{2}}
\newcommand{\twotenso}[1]{\tenso{#1}{2}}
%END new commands

\newtheorem{defi}{Definition}
\newtheorem{prop}{Proposition}
\newtheorem{coro}{Corollary}
\newtheorem{lemm}{Lemma}
\newtheorem{satz}{Theorem}
\author{G. Mueller}
\title{Unified PV theory}
\begin{document}
\section{Introduction}
We briefly recall some constructions from bialgebras. We assume any ring $R$ mentioned to be unital and commutative, unless stated otherwise. In addition, we omit subscripts from tensor products and $\mathrm{Hom}$-bifunctor where no ambiguity can arise. Furthermore, $A^{\otimes 2} := A \otimes A$ and recursively $A^{\otimes n} = A \otimes A^{\otimes n - 1} \simeq A^{\otimes n - 1} \otimes A$
\subsection{Algebras and coalgebras}
Let $R$ be a ring - an $R$-module $A$ is called an $R$-algebra, or simply algebra if $R$ is clear, if there is an $R$-linear map $\mu : A \otimes A \longrightarrow A$, called multiplication. We call $(A, \mu)$ associative if
$$\xymatrix{
A^{\otimes 3} \ar[r]^{\mu \otimes id_A}\ar[d]_{id_A \otimes \mu} & A^{\otimes 2}\ar[d]^\mu\\
A^{\otimes 2} \ar[r]_{\mu} & A\\
}$$
commutes. We call $A$ unital if there is an $R$-linear map $\eta : R \longrightarrow A$, called unit (map), such that
$$\xymatrix{
R \otimes A \ar[r]^{\eta \otimes id_A}\ar[rd]_{\simeq} & A^{\otimes2} \ar[d]^\mu & A \otimes R \ar[l]_{id_A \otimes \eta} \ar[ld]^{\simeq}\\
&A&\\
}$$
commutes. $(A, \mu, \eta)$ denotes a unital associative algebra. An $R$-module $C$ is called an $R$-coalgebra if there is an $R$-linear map $\Delta : C \longrightarrow C^{\otimes2}$, called the comultiplication and denote it by $(C, \Delta)$. We call $(C, \Delta)$ coassociative if
$$\xymatrix{
C^{\otimes 3} & C^{\otimes 2}\ar[l]_{\Delta \otimes id_C}\\
C^{\otimes 2} \ar[u]^{id_C \otimes \Delta} & C\ar[l]^{\Delta}\ar[u]_{\Delta}\\
}$$
commutes. We call $(C, \Delta)$ counital if there is an $R$-linear map $\varepsilon : C \longrightarrow R$ such that
$$\xymatrix{
R \otimes C & \ar[l]_{\varepsilon \otimes id_C} C^{\otimes2} \ar[r]^{id_C \otimes \varepsilon}& C \otimes R\\
& C \ar[u]_\Delta \ar[ul]^{\simeq} \ar[ur]_{\simeq}&\\
}$$
commutes. A counital (coassociative) coalgebra is denoted by $(C, \Delta, \varepsilon)$. We call an algebra $A$ commutative and a coalgebra $C$ cocommutative if
$$\mu = \mu \circ \tau,\ \tau \circ \Delta = \Delta$$
for the flip isomorphism $\tau = \tau_{X \otimes Y} : X \otimes Y \longrightarrow Y \otimes X$.
An $R$-module $M$ is called a left $(A, \mu, \eta)$-module if there is an algebra homomorphism
$$\rho : A \longrightarrow \mathrm{End}_R(M),$$
or equivalently there is an $R$-linear $\hat{\rho} : A \otimes M \longrightarrow M, a \otimes m \longmapsto a m := \rho(a)(m)$ such that
$$\begin{array}{cc}
\xymatrix{
A^{\otimes2} \otimes M \ar[rr]^{\mu \otimes id_M} \ar[d]_{id_A \otimes \hat{\rho}} && A \otimes M \ar[d]^{\hat{\rho}}\\
A \otimes M \ar[rr]_{\hat{\rho}}& & M\\
} &\xymatrix{
R \otimes M \ar[d]_{\simeq}\ar[r]^{\eta \otimes id_M} & A \otimes M \ar[ld]^{\hat{\rho}}\\
M&\\
}
\end{array}$$
commute. Right $(A, \mu, \eta)$-modules are defined accordingly. For a counital coassociative coalgebra $(C, \Delta, \eps)$, we call a left $C$-comodule an $R$-module $M$ with $R$-linear map:
$$\rho : M \longrightarrow C \otimes M$$
such that
$$\begin{array}{cc}
\xymatrix{
C^{\otimes 2} \otimes M & C \otimes M\ar[l]_{id_C \otimes \rho}\\
C \otimes M\ar[u]^{\Delta \otimes id_M} & M \ar[u]_\rho \ar[l]^\rho\\
%M \ar[r]^\rho \ar[d]_\rho & C \otimes M\ar[d]^{\Delta \otimes id_M}\\
%C \otimes M \ar[r]_{id_C \otimes \rho} & \\
} & \xymatrix{
R \otimes M & C \otimes M\ar[l]_{\eps \otimes id_M}\\
M \ar[u]^\simeq \ar[ru]_{\rho} &\\% C \otimes M\ar[d]_{\eps \otimes id_M}\\
}
\end{array}$$
commute. An $R$-submodule $B$ of an algebra $(A, \mu, \eta)$ is called a subalgebra if $(B, \mu\mid_{B \otimes B}, \eta)$ is an algebra. A (left/right/two-sided) ideal $I$ of an algebra $A$ is a (left/right/two-sided) $A$-submodule of $A$, i.e.
$$\begin{cases}
A. I \subset I &, \mathrm{left~sided}\\
I. A \subset I &, \mathrm{right~sided}\\
 A. I + I. A \subset I &\mathrm{two-sided}\\
 \end{cases}.$$
An $R$-submodule $D$ of a coalgebra $(C, \Delta, \eps)$ is called sub coalgebra if $(D, \Delta\mid_D, \eps\mid_D)$ is a coalgebra. A coideal $I$ of a coalgebra $C$ is an $R$-submodule $I \subset \ker \eps$ such that
$$\Delta(I) \subset C \otimes I + I \otimes C,$$
i.e. a two-sided sub comodule of $\ker \eps$.
\begin{defi}
Let $C$ be a coalgebra. We call an element $c \in C$ group-like if
$$\Delta(c) = c \otimes c.$$
We call $c$ $(g,h)$-skew primitive if there are group-like elements $g, h \in C$ such that
$$\Delta(c) = g \otimes c + c \otimes h.$$
%We call $c$ primitive if $c$ is $(1_C, 1_C)$-skew primitive.
\end{defi}
\bmk We remark that $\eps(c) = 1$ if $c \in C$ is a group-like and $\eps(c) = 0$ if $c \in C$ is $(g,h)$-skew primitive. This follows from counitality.
\subsubsection{Cofree coalgebras}
We need some additional
\begin{defi}
We call an $R$-module $M$ an essential module over some module $N$ if $N \subset M$ (or equivalently essential extension of $N$) if for all $H \subset M$ we have
$$N \cap H = \{0\} \Rightarrow H = \{0\}.$$
We call $M$ an injective module if $M$ has no proper essential extensions $M'$. Furthermore, we call $M$ an injective hull if $M$ is essential and injective. We call a submodule $N \subset M$ dense if $\mathrm{Hom}_R(M/N,E(M)) = \{0\}$ for the injective hull $E(M)$ over $M$.
\end{defi}
As we already stated, the dual $A^\ast$ of an $R$-algebra $A$ is in general not a coalgebra. However, there is a way to adjust $A^\ast$ appropriately. Let
$$\bao{rcl}
A^0 &:=& \left<g \in A^\ast : \exists I \leq \ker g\ \wedge\ n \in \mathbb{N}, A/I \simeq \sum_{i \leq n} R.x_i\right>\\&&\\ &=& \left<g \in A^\ast : \mathrm{supp} g \simeq \sum_{i\leq n} R.x_n\right>.\\\ea$$
then $A^0$ is an $R$-submodule of $A^\ast$. We consider for every module homomorphism $f : A \longrightarrow B$ its dual $f^\ast : B^\ast \longrightarrow A^\ast$. This implies
$$\mu : \twotenso{A} \longrightarrow A\ \Rightarrow\ \mu^\ast : A^\ast \longrightarrow \left(\twotenso{A}\right)^\ast$$
However, $\twotens{A^\ast} \subset \left(\twotenso{A}\right)^\ast$ is a dense submodule. Now we compute for all $g \in A^0$:
$$\bao{rcl}
\Delta(g) = \mu^\ast(g) = g \circ \mu &=& [a \otimes a' \longmapsto g(a a')]\\
&\Rightarrow&\\
\ker g \circ \mu &=& \{a \otimes a' \in \twotenso{A} : g(a a') = 0\}\\
&&\\
&=& \{a \otimes a' : a a' \in \ker g\} \supset \{1_A \otimes a + b \otimes 1_A : a, b \in \ker g\}\\
&&\\
&=& \left\{a b^{-1} \otimes b + b' \otimes b'^{-1} a' : a, a' \in \ker g, b , b' \in A\right\}
\ea$$
where $a b^{-1}$ is in the left ideal $A.a/b = \{r \in A : r b \in A.a\}$ for $a, b \notin A^\times$ and for $a', b' \notin A^\times$ in the right-hand version. If $a \in \ker g$ then $f_a = [x \longmapsto x - g(x) a] \in \mathrm{End}_R(A)$ then $f_a \mid_{\ker g} = id_{\ker g}$ and $g(f_a(x)) = g(x) - g(g(x) a) = g(x)(1 - g(a)) = g(x)$ Its iterates are
$$\bao{rcl}
f_a^2 &=& [x \longmapsto f_a(x - g(x) a) = x - g(x) a - g(x - g(x) a) a = x - 2 g(x) a]\\
\ea$$
Clearly, $1 \otimes \ker g + \ker g \otimes 1$ is a submodule of $\ker \Delta(g)$ with $\twotenso{A}$
\subsubsection{Duality}
An important
\begin{prop}
Let $C^\ast := \mathrm{Hom}(C, R)$ be the dual module for a cofree counital coassociative coalgebra $(C, \Delta, \varepsilon)$ then $(C^\ast, \mu_{C^\ast}, \eta_{C^\ast})$ is a unital associative algebra with:
$$\begin{array}{rrcl}
\mu_{C^\ast} := \Delta^\ast: & \left(C^{\otimes 2}\right)^\ast \simeq C^\ast \otimes C^\ast &\longrightarrow& C^\ast,\\
&&\\
& \alpha \otimes \beta &=& \left[c_1 \otimes c_2 \longmapsto \alpha(c_1)  \beta(c_2)\right] \\
&&\\
& &\longmapsto& (\alpha \otimes \beta) \circ \Delta\\
&&&\\
&(\alpha \otimes \beta) \Delta &=& \left[c \longmapsto \sum_{(c)} (\alpha \otimes \beta)\left(c_{(1)} \otimes c_{(2)}\right)\right]\\
\end{array}$$
where $\Delta(c) = \sum_{(c)} c_{(1)} \otimes c_{(2)}$, and unit
$$\eta_{C^\ast} := \varepsilon^\ast : R \longrightarrow C^\ast,\ r \longmapsto r \cdot \eps.$$
\end{prop}
The multiplication on $C^\ast$ is sometimes denoted by $\ast$ and called convolution. The converse statement, the dual of each algebra is a coalgebra is in general not true. However:
\begin{prop}
let $A$ be an projective algebra of finite type. Its dual module $A^\ast$ is a coalgebra with structure maps
$$\Delta = \mu^\ast = \left[\alpha \longmapsto \alpha \mu_A = \left[a \otimes b \longmapsto \alpha(a b)\right] \right],\ \eps = \eta^\ast = \left[\alpha \longmapsto \alpha(1_A)\right].$$
\end{prop}
In general, $A^\ast$ is not a coalgebra. However, if $A^\ast = A^0$ this is the case.\\%let $A$ be an arbitrary unital associative algebra and
%$$A^0 := \left\{\alpha \in A^\ast : \exists I \subset \ker \alpha,\ A/I \simeq_{R-\mathrm{modules}} \sum_{i=1}^n R.e_i\right\} = A^\ast$$
%then $(A^0, \Delta = \mu^\ast\mid_{A^0}, \eps = \eta^\ast\mid_{A^0})$ is a coalgebra.\\
\indent For an algebra $(A, \mu, \eta)$ and a coalgebra $C$ as above the module
$$\mathrm{Hom}(C, A) \simeq C^\ast \otimes A$$
is an unital associative algebra with multiplication
$$\mu_{\mathrm{Hom}(C,A)} = \mu \Delta = \left[f \otimes g \longmapsto \mu(f \otimes g) \Delta = \left[c \longmapsto \mu(f \otimes g) \Delta(c)\right]\right]$$
and unit $\eta \cdot \eps$.
%Firstly, we claim that if there is an $R$-submodule $I \leq \ker g$ for some $g \in A^\ast$ with $I$ is not finitely generated if $A$ is not then $I$ is an ideal in $A$. Let $A_M := R[M]$, for some $M \subset A\backslash R$ and
%$$x = \sum_{\substack{n \geq 0\\i \in \mathbb{Z}_{\geq 0}^n}} x_{i} m^i \in R[M] \cap I,\ a = \sum_{n,i} a_i m^i \in R[M],$$ for $\ x_i, a_i \in R, m^i = m_{i_1} \ldots m_{i_n}, \forall n \geq 1$ and $m^0 = 1_A$ we have
%$$\bao{rcl}
%g(x a) &=& g \circ \mu(x \otimes a)\\
%&&\\
%&=& g \circ \mu\left(\sum_{m,m'} x_m a_{m'} m \otimes m'\right)\\
%&&\\
%&=& \sum_{m m' \in \ker g} x_m a_{m'} \underbrace{g \circ \mu(m \otimes m')}_{=0}\\&&\\&& + \sum_{m m' \in \mathrm{supp}(g)} x_m a_{m'} g \circ \mu(m \otimes m')\\
%\ea$$
\subsection{Bialgebras}
We call a module $(B, \mu, \eta, \Delta, \eps)$ a bialgebra if $(B, \mu, \eta)$ is an algebra and $(B, \Delta, \eps)$ is a coalgebra such that
$$\begin{array}{cc}
\xymatrix{
B^{\otimes2} \ar[d]_{\Delta \otimes \Delta}\ar[r]^{\mu} & B \ar[r]^\Delta & B^{\otimes2}\\
B^{\otimes4} \ar[rr]_{id_B \otimes \tau \otimes id_B}&&B^{\otimes4} \ar[u]_{\mu \otimes \mu}\\
} & \xymatrix{
 B^{\otimes2} \ar[d]_{\eps \otimes \eps}\ar[r]^\mu & B\ar[ld]^{\eps}\\
 R
}\\
&\\
\xymatrix{
R \ar[d]_{id_R}\ar[r]^\eta & B\ar[ld]^\eps\\
R&\\
}
&\xymatrix{
B^{\otimes2} & B\ar[l]_{\Delta}\\
 R\ar[u]^{\eta \otimes \eta} \ar[ur]_{\eta}
}
\end{array}$$
commute. It is equivalent to say $\Delta$ and $\eps$ are algebra homomorphisms and $\mu$ and $\eta$ are colalgebra homomorphisms.
\newpage
\section{General PV theory}
Given a bialgebra $(D, \mu, \eta, \Delta, \eps)$ and a $D$-module algebra $(A, \Psi_A)$ we define the map
$$\begin{array}{rrcl}
\rho :& A & \longrightarrow &\mathrm{Hom}(D, A)\\
& a &\longmapsto & \left[d \longmapsto \Psi_A(d \otimes a)\right] =: ev_a\\
\end{array}$$
We see that $\rho$ is an algebra homomorphism as
$$\begin{array}{rcl}
\rho(a a') &=& ev_{a a'}\\
&&\\
 &=& \left[d \longmapsto \Psi_A(d \otimes a a')\right]\\% = \sum_{(d)} \mu_A\left(\Psi_A\left(d_{(1)} \otimes a\right) \otimes \Psi_A\left(d_{(2)} \otimes a'\right)\right)\\%\left[d \longmapsto \mu_A(\rho(a) \otimes \rho(a')) \Delta(d) = \sum_{(d)} \rho(a)(d_{(1)}) \rho(a')(d_{(2)})\right]
 &&\\
 \Psi_A(d \otimes a a') &=& \sum_{(d)} \mu_A\left(\Psi_A\left(d_{(1)} \otimes a\right) \otimes \Psi_A\left(d_{(2)} \otimes a'\right)\right)\\
 &&\\
 &=& \mu_A(ev_a \otimes ev_{a'}) \Delta(d)\\
 &&\\
\rho(a) \ast \rho(a') &=& \left[d \longmapsto \mu_A(\rho(a) \otimes \rho(a'))\Delta(d)\right] = \mu_A(\rho(a) \otimes \rho(a')) \Delta\\
&&\\
 &=& \mu(ev_a \otimes ev_{a'})\Delta =: ev_a \ast ev_{a}\\
 &&\\
 &=& \rho(a a')
\end{array}$$
where $\Delta(d) = \sum_{(d)} d_{(1)} \otimes d_{(2)}$ is the coproduct in Sweedler notation and $\ast$ denotes convolution in $\mathrm{Hom}(D,A)$. We define
$$A^\rho := \{a \in A : \rho(a) = a \eps\}$$
as constant module algebra. Conversely,
$$\rho_0 := \left[a \longmapsto a \eps\right]$$
is the trivial module algebra homomorphism. In addition, we have
$$\begin{array}{rrcl}
\rho_{\mathrm{int}} :& \mathrm{Hom}(D, A) &\longrightarrow &\mathrm{Hom}(D, \mathrm{Hom}(D, A))\\
& f& \longmapsto& f_r = \left[d \longmapsto \left[d' \longmapsto f(d' d)\right]\right]\\
\end{array}$$
with
$$\mathrm{Hom}\left(D, \mathrm{Hom}(D,A)\right) \simeq \mathrm{Hom}(D \otimes D, A)$$
making $\mathrm{Hom}(D,A)$ a $D$-module algebra. We remark that
$$\begin{array}{rcl}
\mathrm{Hom}(D, A)^{\rho_{\mathrm{int}}} &=& \left\{f \in \mathrm{Hom}(D, A) : \rho_{\mathrm{int}}(f) = f \otimes \eps\right\}\\
&&\\
f \otimes \eps &=& \left[d \otimes d' \longmapsto \eps(d')f(d)\right]\\
\end{array}$$
\section{Trivial example from 2-d}
We fix $k = \qzcl$ and $L = \partial^2 - a \cdot id_{\qzcl}$, with $\partial\mid_{\qzcl} = 0$ and $a \in \qzcl^\times$. Firstly, $D = \qzcl[\partial]$ with
$$\rho_{\qzcl} : \qzcl \longrightarrow \mathrm{Hom}\left(\qzcl[\partial], \qzcl\right), x \longmapsto \left[\sum_{i=0}^n d_i \partial^i \longmapsto d_0 x\right]$$
making $\rho_{\qzcl} = \rho_0$. Furthermore, we have
$$\bao{rclcrcl}
\Delta(\partial^j) &=& \sum_{j_0=0}^j\left(\bao{c}j\\j_0\\\ea\right) \partial^{j_0} \otimes \partial^{j - 1_0} && \mu(\partial^i \otimes \partial^j) &=& \partial^{i + j}\\
\eps(\partial^j) &=& \begin{cases}
1 & j = 0\\
0 & \mathrm{else}\\
\end{cases} &&\eta(1_{\qzcl}) &=& 1_D = id\\
\ea$$
Now, let us compute the principal module algebra $R$, its module algebra homomorphism $\rho_R \in \mathrm{Hom}(R, \mathrm{Hom}(D, R))$ and $H := \left(R \otimes_k R\right)^{\rho_R \otimes \rho_R}$.
\subsection{Principal module algebra}
Abstractly, $R$ is isomorphic to $\qzcl\left[X,X^{-1}\right]$ where $X \in \mathrm{Gl}_n(\qzcl)$ is a fundamental solution. Thus, we set $R = \qzcl[X,X^{-1}]$. Let us compute
$$\bao{rcl}
\rho_R &=& \left[X^i \longmapsto ev_{X^i}\right]\\
&&\\
ev_{X^i} &=& \left[\partial^j \longmapsto \Psi_R(\partial^j \otimes X^i)\right]\\
&&\\
&=& \left[\partial^j \longmapsto \partial^j(X^i) = \begin{cases}
X^i&,\ j = 0\\
i^j A^j X^i&, \mathrm{else}\\
\end{cases}\right]\\
\ea$$
where $A = \left(\bao{cc}0 & 1\\a & 0\\\ea\right)$. This is equivalent to
$$\rho_R = \left[X^i \longmapsto \left[\sum_{j=0}^n d_j \partial^j \longmapsto \left(d_0 I_n + \sum_{j=1}^n d_j (i A)^j\right) X^i\right]\right].$$
The constant module algebra is
$$R^{\rho} = \left(\qzcl\left[X,X^{-1}\right]\right)^\rho = \left\{x \in \qzcl\left[X,X^{-1}\right] : \rho(x) = x \cdot \eps = \left[d \longmapsto x \eps(d)\right]\right\}$$
which implies
$$\bao{rcl}
\rho(x) &=& x \cdot \eps\\
\Leftrightarrow \rho(x)(d) &=& \sum_{i=0}^n d_i \partial^i(x)\\
&&\\
&\stackrel{!}{=}& x \sum d_i \underbrace{\eps(\partial^i)}_{\delta_{0,i}}\ =\ x d_0\\
\Leftrightarrow x &\in& \ker \partial\\
\ea$$
i.e. $x \in \qzcl$. Here, $\delta_{0,i}$ denotes the Kronecker Delta being zero for all but $i = 0$. This proves that $R^\rho$ equals $\qzcl$. To see that $R$ is a simple $D$-module algebra we will use the following: the differential ideal $\left<X\right> \subset \qzcl[X]$ contains a unit in its localization $S_{X} \left<X\right>$ where
$$S_{X} := \qzcl[X]\backslash\bigcup_{\substack{\mathfrak{p} \in \mathrm{Spec}\qzcl[X]\\X \notin \mathfrak{p}}} \mathfrak{p}.$$
This is clear from the fact that the negation of primality reads: $a \notin \mathfrak{p}$ and $b \notin \mathfrak{p}$ implies $a b \notin \mathfrak{p}$, for all $\mathfrak{p} \in \mathrm{Spec}R$ with $X \notin \mathfrak{p}$.
Firstly,
$$\partial(f X) = \partial(f) X + f \partial(X) = \partial(f) X + f A X \in \left<X\right>,$$
showing us that $\left<X\right>$ is a non-trivial $D$-stable prime ideal. Now we assume a prime ideal $\mathfrak{p} \neq \left<X\right>$ also being $D$-stable (we could have started with any $D$-stable ideal and then show that it is contained in a larger prime ideal with the same property). As $\qzcl[X]$ is a PID there is a generator $f$ such that $\left<f\right> = \mathfrak{p}$. Again, we compute
$$\partial(g f) = \underbrace{\partial(g) f}_{\in \left<f\right>} + g \partial(f) \in \left<f\right>$$
and for $f = \sum_i f_i X^i$:
$$g \partial(f) = g \sum_i f_i \sum_{j=0}^{i-1} X^j A X^{i-j} \stackrel{!}{=} h \sum_i f_i X^i.$$
However, since $A \neq I_2$ and $A X \neq X A$ we see that equality does not hold and we have arrived at a contradiction. Thus, $\left<X\right>$ is the only maximally $D$-stable prime ideal and $R$ has to be a simple $D$ module algebra.
\subsubsection{Two cases}
We assume to work in an appropriate subfield $k$ of $\qzcl$. We subdivide our discussion into two cases the decomposition case (that is our parameter $a \in k$ has a square root in $k$) and non-decomposition case (the polynomial $Y^2 - a \in k[Y]$ has no roots in $k$).
\paragraph{Non-composition case}

\paragraph{Composition case}
We set $k = \qz(\sqrt{a})$ and readily see that the PV ring has to contain two elements $y, y^{-1} \in R$ such that
$$a x$$
% $\qzcl[X]$ has only one maximal differential ideal $I = \left<X\right>$. Now, let $J \supset I$ be another ideal closed under $D$-action:
%$$\bao{rcl}
%D(J) &\subset& J\\ &\Leftrightarrow&\\
%J \ni j &=& \sum_{k=0}^n j_k X^k \stackrel{\partial}{\longmapsto} \sum_{k=0}^{n-1}  j_{k+1} \sum_{0 \leq l\leq %k-1} X^{l} \partial(X) X^{n - 1 - k}\\
%& =& \partial(j) \in J
%\ea$$
%\newcommand{\tens}[2]{\left(#1\right)^{\otimes #2}}
%\newcommand{\tenso}[2]{#1^{\otimes #2}}
%\newcommand{\twotens}[1]{\tens{#1}{2}}
%\newcommand{\twotenso}[1]{\tenso{#1}{2}}
\subsection{Hopf algebra}
To compute the Hopf-algebra $H = \left(\twotenso{R}\right)^{\rho_R \otimes \rho_R}$ we will discuss the map $\rho_R \otimes \rho_R$ first.
$$\bao{rrcl}
\rho_R \otimes \rho_R : &\twotenso{R}& \longrightarrow &\mathrm{Hom}\left(D, \twotenso{R}\right)\\
&r_1 \otimes r_2 &\longmapsto &\Psi_{\twotenso{R}}\left(\_ \otimes\left(r_1 \otimes r_2\right)\right) = \left[d \longmapsto \Psi_{\twotenso{R}}\left(d \otimes \left(r_1 \otimes r_2\right)\right)\right].\\
\ea$$
where
$$\bao{rcl}
\Psi_{\twotenso{R}}\left(d \otimes \left(r_1 \otimes r_2\right)\right) &=& \sum_{(d)} \Psi_R\left(d_{(1)} \otimes r_1\right) \otimes \Psi_R\left(d_{(2)} \otimes r_2\right)\\
&&\\
& =& \left(\Psi_R \otimes \Psi_R\right)(f)(\Delta \otimes id_{R^{\otimes2}})(d \otimes r_1 \otimes r_2)\\
&\mathrm{with}&\\
f &=& id_D \otimes \tau_{D\otimes R} \otimes id_R.\ea$$
The counit is $\eps = \eps_{\qzcl[\partial]} = [\partial^i \longmapsto \delta_{0,i}]$. Therefore,
$$\bao{rcl}
H &=& \left\{r_1 \otimes r_2 : \rho(r_1 \otimes r_2) = r_1 \otimes r_2 \cdot \eps\right\}\\
&&\\
&=& \left\{r_1 \otimes r_2 : \rho(r_1 \otimes r_2) (d) = \eps(d) r_1 \otimes r_2, \forall d \in \qzcl[\partial]\right\}\\
&&\\
&=& \left\{r_1 \otimes r_2 : \sum_{(d)} \Psi_R(d_{(1)} \otimes r_1) \otimes \Psi_R(d_{(2)} \otimes r_2),\forall d \in \qzcl[\partial]\right\}\\
&&\\
&=& \left\{r_1 \otimes r_2 : \partial^i \longmapsto \sum_{j=0}^i \left(\bao{c}i\\j\\\ea\right) \partial^j (r_1) \otimes \partial^{i-1}(r_2) = \delta_{0,i} \cdot r_1 \otimes r_2,\forall d\right\}\\
&&\\
&\stackrel{?}{=}& \ker \Delta(\partial)\\
&&\\
& =& \{r_1 \otimes r_2 : r_1 \otimes \partial(r_2) + \partial(r_1) \otimes r_2 = 0\}\\
&&\\
&=& \qzcl[y\otimes y^{-1}, y^{-1} \otimes y]\ \simeq \ \qzcl[y,y^{-1}]\\
\ea$$
For all $i \in \mathbb{Z}$, we have
$$\bao{rcl}
\Delta(\partial)\left(y^i \otimes y^{-i}\right) &=& y^i \otimes \partial(y^{-i}) + \partial(y^i) \otimes y^{-1}\\&&\\
 &=& - i \sqrt{a} (y^i \otimes y^{-i}) + i \sqrt{a} (y^{i} \otimes y^{-i}) = 0
 \ea$$
and
$$id(y^0 \otimes y^0) = id(1_R \otimes 1_R) = 1_R \otimes 1_R \in \ker \Delta(\partial).$$
Now, we assume $h = \sum_{i,j} h_{i,j} y^{i} \otimes y^{j} \in H$ then
$$\bao{rcl}
\rho_{\twotenso{R}}(h)(\partial) &=& \Delta(\partial)(h)\\&&\\ &=& \sum_{i,j} h_{i,j} (y^i \otimes \partial(y^j) + \partial(y^i) \otimes y^j)\\
&&\\
&=& \sum_{(i,j) \in \mathbb{Z}^2 \backslash \{0\}} h_{i,j} (j \sqrt{a} y^i \otimes y^j + i \sqrt{a} y^i \otimes y^j)\\
&&\\
&=& \sum_{(i,j) \in \mathbb{Z}^2 \backslash \{0\}} h_{i,j} (j + i) \sqrt{a} y^i \otimes y^j\ = \ 0\\
&\Leftrightarrow&\\
&&j = -i,\ \forall i \in \mathbb{Z} \vee h_{i,j} = 0,\ \forall (i,j) \neq 0 \in \mathbb{Z}^2\\
\ea$$
proving $H \subset \ker \Delta(\partial)$. As all elements $h \in \ker \Delta(\partial)$ fulfil
$$\bao{rcl}
\rho(h)(d) &=& \sum_i d_i \Psi_{\twotenso{R}}(\partial^i \otimes h)\\&&\\&=& \sum_i \delta_{0,i} \cdot d_i h\\
&&\\
&=& \sum_i d_i  \underbrace{\eps(\partial^i)}_{\delta_{0,i}} h\\&&\\ &=& \eps(d) h,\ \forall d = \sum_i d_i \partial^i\\
\ea$$
we have the inverse inclusion. As $\Delta$ is a homomorphism of $\qzcl$-algebras, we have $\Delta(\partial^i) = \Delta(\partial)^i$ and $y^{i} \otimes y^{-i} - y^{-i} \otimes y^i$ generates a proper Hopf-ideal in $H$.
\subsubsection{No composition}
The above description works for all cases $k \supset \qz$ with $\sqrt{a} \in k$. However, if $k(\sqrt{a})$ is a proper extension over $k$ then there are no non-trivial eigenvectors to $\partial - \sqrt{a} \cdot id_R$, i.e. no element $y \in R$.\\
The general solutions are $x_1$ with $\partial(x_1) = x_2$ and $\partial(x_2) = a x_1$. The PV ring is isomorphic to
$$R \simeq k[x_1,x_2]/\left<a x_1^2 - x_2^2 - 1\right> \simeq k[x_1] \otimes (k \oplus k.x_2)$$
with multiplication for all $i_1, j_1 \geq 0, i_2, j_2 = 0, 1$:
$$\begin{array}{rrcl}
\mu_R :& R \otimes R &\longrightarrow& R,\\
& x_1^{i_1} x_2^{i_2} \otimes x_1^{j_1} x_2^{j_2} &\longmapsto &x_1^{i_1 + j_1} (a x_1^2 - 1)^{\frac{i_2+j_2 - (i_2+ j_2)\mod 2}{2}} x_2^{i_2+j_2 \mod 2},\\
&&&\\
&&& = \begin{cases}
%x_1^{i_1 + j_1}, & i_2 = j_2 = 0\\
x_1^{i_1 + j_1} x_2, & i_2 + j_2 \equiv 1 \mod 2\\
x_1^{i_1 + j_1} (a x_1^2 - 1)^{[(i_2+j_2)/2]}, & i_2 + j_2 \equiv 0 \mod 2\\
\end{cases}
\end{array}$$
where $[z] := \max \{z' \in \mathbb{Z} : z' \leq z\}$, and $k$-derivation
$$\begin{array}{rrcl}
\partial_R : &R& \longrightarrow &R,\\
&x_1^i x_2^j &\longmapsto &i x_1^{i-1} x_2^{j+1} + j a x_1^{i+1} x_2^{j-1},\ \forall i \geq 0, j = 0, 1\\
&&&\\
&&& = \begin{cases}
i x_1^{i-1} x_2 & j = 0\\
i x_1^{i-1} (a x_1^2 - 1) + a x_1^{i+1} x_2& j = 1\\
\end{cases}\\
\end{array}$$
Again, we are looking for elements $r \otimes s \in \ker \Delta(\partial) \subset R^{\otimes 2}$. Clearly, the elements
$$\left\{\underbrace{a x_1 \otimes x_1 - x_2 \otimes x_2}_{=: h_1}, \underbrace{x_1 \otimes x_2 - x_2 \otimes x_1}_{=: h_2}, \underbrace{1 \otimes 1}_{1_H}\right\}$$
are ideal candidates as
$$a x_1 \otimes x_1 - x_2 \otimes x_2 - 1 \otimes 1,\ x_1 \otimes x_2 - x_2 \otimes x_1 \in \mu_R^{-1}(0) =: \ker \mu_R.$$
Some notes why only generators...\\

\subsubsection{Its structure maps}
Firstly, we are discussing the case $\sqrt{a} \in k$. Its multiplication and unit are
$$\mu_H = \mu_{R^{\otimes2}} \mid_H = [a_1 \otimes b_1 \otimes a_2 \otimes b_2 \longmapsto a_1 a_2 \otimes b_1 b_2],\ \eta = [1_{\qzcl} \longmapsto 1_R \otimes 1_{R}].$$
Its comultiplication and counit are
$$\Delta = [y^i \otimes y^{-i} \longmapsto y^i \otimes 1 \otimes 1 \otimes y^{-i}],\ \eps = [a \otimes b \longmapsto a b].$$
We remark that $H$ is generated by the non-trivial group-like:
$$y \otimes y^{-1} \longmapsto y \otimes_{\qzcl} \underbrace{y^{-1} \otimes_R y}_{= 1_R} \otimes_{\qzcl} y^{-1} = y \otimes 1 \otimes 1 \otimes y^{-1},\ y\otimes y^{-1} \stackrel{\eps_H}{\longmapsto} 1_R$$
Second case $\sqrt{a} \notin k$ is not obvious. However, we will use a trick to get the Hopf algebra structure. We recall that an algebraic element $\alpha$ over the ring of constants is constant in the algebraic extension $R(\alpha)$. Hence, we use: if $\sqrt{a} \notin \qz$ then $H(\sqrt{a})$ is constant algebraic over $H$.
\newcommand{\pvextens}{R(\sqrt{a})}
$$\pvextens \simeq \qz(\sqrt{a}) \otimes_\qz R$$
where
$$R \simeq \qz[x_1,x_2]/\left<x_2^2 - a x_1^2 + 1\right>.$$
Now, we can use the decomposition as above:
$$\begin{array}{rclrcl}
y &=& \sqrt{a} \otimes x_1 + 1_{\qz(\sqrt{a})} \otimes x_2,&y^{-1} &=& \sqrt{a} \otimes x_1 - 1_{\qz(\sqrt{a})} \otimes x_2 \in \qz(\sqrt{a}) \otimes_\qz R\\
&&&&&\\
x_1 &=& \frac{1}{2 \sqrt{a}} (y + y^{-1}) &
x_2 &=& \frac{1}{2} (y - y^{-1}) \in \pvextens\\
\end{array}$$
As this setting does not fully meet our needs we expand:
$$\begin{array}{rrcl}
&\pvextens \otimes_\qz \pvextens &\longrightarrow& \pvextens \otimes_{\qz(\sqrt{a})} \pvextens.\\
&a \cdot (r \otimes s)& \longmapsto&\sqrt{a} r \otimes  \sqrt{a} s\\
\end{array}$$
Basically, we simply replace our incomplete ring with an appropriate ring and take our equation along the way:
$$\partial^2 - a \cdot id_{\qz(\sqrt{a})} \in \qz(\sqrt{a})[\partial] \simeq \qz(\sqrt{a}) \otimes_\qz \qz[\partial.$$
Now, we may proceed. Again, $y_1 \otimes y_{-1} \longmapsto y_1 \otimes 1 \otimes_R 1 \otimes y_{-1}$ then:
$$\begin{array}{rcl}
\Delta_{\pvextens}(a x_1 \otimes x_1 - x_2 \otimes x_2) &\longmapsto& a \Delta_{\pvextens}\left(\frac{1}{2\sqrt{a}} (y + y^{-1}) \otimes \frac{1}{2\sqrt{a}} (y + y^{-1})\right)\\
&&\\
&& - \Delta_{\pvextens}\left(
\frac{1}{2} (y - y^{-1}) \otimes \frac{1}{2} (y - y^{-1})
\right)\\
&&\\
&=& \frac{1}{2} \Delta_{\pvextens}(y \otimes y^{-1} + y^{-1} \otimes y)\\
&&\\
&=& \frac{1}{2} \left(y \otimes 1 \otimes 1 \otimes y^{-1} + y^{-1} \otimes 1 \otimes 1 \otimes y\right)\\
&&\\
&=& \frac{1}{2} ((\sqrt{a} x_1 + x_2) \otimes 1 \otimes 1 \otimes (\sqrt{a} x_1 - x_2)\\&&\\&& + (\sqrt{a} x_1 - x_2) \otimes 1 \otimes 1 \otimes (\sqrt{a} x_1 + x_2))\\
&&\\
&=& a x_1 \otimes 1 \otimes 1 \otimes x_1 - x_2 \otimes 1 \otimes 1 \otimes x_2\\
\ea$$
$$\bao{rcl}
\Delta_{\pvextens}(x_1 \otimes x_2 - x_2 \otimes x_1) &=& \Delta_{\pvextens}\left(\frac{1}{2 \sqrt{a}} (y_1 + y_{-1}) \otimes \frac{1}{2} (y_1 - y_{-1})\right)\\
&&\\
&& - \Delta_{\pvextens}\left(\frac{1}{2} (y_1 - y_{-1}) \otimes \frac{1}{2\sqrt{a}} (y_1 + y_{-1})\right)\\
&&\\
&=& \frac{1}{2 \sqrt{a}} \Delta_{\pvextens}(y_{-1} \otimes y_{1} - y_{1} \otimes y_{-1})\\
&&\\
&=& \frac{1}{2 \sqrt{a}} (y_{-1} \otimes 1 \otimes 1 \otimes y_{1} - y_1 \otimes 1 \otimes 1 \otimes y_{-1})\\
&&\\
&=& \frac{1}{2 \sqrt{a}} ((\sqrt{a} x_1 - x_2) \otimes 1 \otimes 1 \otimes (\sqrt{a} x_1 + x_2)\\
&&\\
&& - (\sqrt{a} x_1 + x_2) \otimes 1 \otimes 1 \otimes (\sqrt{a} x_1 - x_2))\\
&&\\
&=& x_1 \otimes 1 \otimes 1 \otimes x_2 - x_2 \otimes 1 \otimes 1 \otimes x_1\\
\end{array}$$
In conclusion, even if we change our setting our Hopf-algebra $H$ is already contained in $R \otimes R$ (we do not need $\pvextens$).
 %more complicated. Firstly, the element $h_1$ has to be group-like as
%$h_1 \in \mu_R^{-1}(1_R)$, i.e.
%$$\begin{array}{rcl}
%\Delta(h_1) &=& h_1 \otimes_R h_1 = (a x_1 \otimes x_1 - x_2 \otimes x_2) \otimes_R (a x_1 \otimes x_1 - x_2 \otimes x_2)\\&&\\ &=& a^2 x_1 \otimes x_1 \otimes_R x_1 \otimes x_1 + x_2 \otimes x_2 \otimes_R x_2 \otimes x_2\\
%&& - a (x_1 \otimes x_1 \otimes_R x_2 \otimes x_2 + x_2 \otimes x_2 \otimes_R x_1 \otimes x_1).\\
%\end{array}$$
%On the other hand, $1 \otimes 1 = 1 \otimes (a x_1^2 - x_2^2) = a \otimes x_1^2 - 1 \otimes x_2^2 = a x_1^2 \otimes 1 - x_2^2 \otimes 1 = a^2 x_1^2 \otimes x_1^2 - a (x_1^2 \otimes x_2^2 + x_2^2 \otimes x_1^2) + x_2^2 \otimes x_2^2$ in $R \otimes R$. Therefore, we get
%$$\begin{array}{rcl}
%\Delta(h_1) &=& a^2 x_1 \otimes x_1^2 \otimes_R (a x_1^2 - x^2) \otimes x_1 + x_2 \otimes x_2^2 \otimes_R (a x_1^2 - x_2^2) \otimes x_2\\
%&&\\
%&&- a (x_1 \otimes x_1 x_2 \otimes_R (a x_1^2 - x_2^2) \otimes x_2 + x_2 \otimes x_1 x_2 \otimes_R (a x_1^2 - x_2^2) \otimes x_1)
%\end{array}$$
% \longmapsto 1 \otimes 1 \otimes_R 1 \otimes 1$
\subsection{Module algebra homomorphisms}
\end{document}


\chapter{Alternative Perspective on SIP Solutions in Example}\label{app:pde-example}
We solve our SIP for twenty different realizations of noise to pollute our hundred measurements, and show the resulting solutions for the first twenty and all hundred being used to construct the vector--valued map.
The resulting functions that are induced by these MUD points are shown in Fig.~\ref{fig:pde-highd-2d-vector-mud}, and we note that solutions are no longer are considering the possibility of the minimum value of $g$ being at the wrong knot point as we see in Fig.~\ref{fig:pde-highd-2d-scalar-mud}, even when only twenty total data points are used to construct $Q$.
By the time all hundred measurements are incorporated, the MUD solutions appear to be tracing out curves between the projection function and the interpolant function, a far more accurate set of predictions than those from the scalar--valued map (see \ref{fig:pde-highd-2d-scalar-mud}).

\begin{figure}[htbp]
\centering
  \includegraphics[width=0.6\linewidth]{figures/pde-highd/pde-highd_pair_D2-2_m20.png}
  \includegraphics[width=0.6\linewidth]{figures/pde-highd/pde-highd_pair_D2-2_m100.png}
\caption{
(Top): When vectorizing our QoI map, we find that we are able to achieve more accuracy with fewer measurements. Here, we see far less variation in MUD solutions than in the bottom of Fig.~\ref{fig:pde-highd-2d-scalar-mud}.
(Bottom): When all 100 measurements are incorporated
}
\label{fig:pde-highd-2d-vector-mud}
\end{figure}

How we incorporate the available data has a dramatic impact on our ability to reduce uncertainty in the parameter space.
We attempt to illustrate this by requesting the reader juxtapose figures of the initial samples in \ref{fig:pde-highd-initial-2d} to those in \ref{fig:pde-highd-2d-scalar-mud} and \ref{fig:pde-highd-2d-vector-mud}.
To better quantify the differences between the two types of maps, it is more rigorous to study how close we are to $g$ (in function space).
Since the approximation $\hat{g}$ that arises from evaluating the MUD point is piecewise-linear, and $g$ is continuous, we use the knot points and the trapezoidal rule to approximate the $L^2$ norm of $\abs{g - \hat{g}}$ (using {\tt scipy}), and plot the resulting histograms for the scalar- and vector-valued $\param$s whose relative ratios exceeded a threshold, and compare them against samples from the initial density, and show the result in Figure~\ref{fig:pde-highd-2d-hist}.

\begin{figure}[htbp]
\centering
  \includegraphics[width=0.675\linewidth]{figures/pde-highd/pde-highd_hist_D2_t5-0E-01}
\caption{
Histograms comparing initial samples with the highest probabilities (relative ratio $> 0.5$).
}
\label{fig:pde-highd-2d-hist}
\end{figure}

In \ref{fig:pde-highd-2d-hist}, the histograms have been normalized for comparison, and while the scalar--valued map still does reduce the uncertainty that we started with in our initial density, the vector--valued map is considerably more accurate.
The multi-modal nature of the scalar--valued histogram plot shows a lack of resolution that is not experienced at all by the vector--valued solution.
Both QoI maps solve a stochastic inverse problem, but the latter is more respectful of the geometry of the response surface, and so is able to learn significantly more, and bring us modelers far closer to the true function $g$.
The multi-modal density of probable samples corresponds to the two types of solutions we see in Figure~\ref{fig:pde-highd-2d-scalar-mud}, but we are after a single parameter estimate of truth.


% !TEX root = collhdl_ICRA_17.tex

\section{Problem Formulation}
\label{sec:task_description}

\subsection{Floating Base Robot Model}
\label{sec:float_base_model}

A rigid humanoid robot can be modeled by
%
\begin{gather}
\small
\begin{pmatrix}
\bm{M}_\mathrm{BB}(\bm{q}) & \bm{M}_\mathrm{BJ}(\bm{q}) \\
\bm{M}_\mathrm{JB}(\bm{q}) & \bm{M}_\mathrm{JJ}(\bm{q}_\mathrm{J}) \\
\end{pmatrix}
\begin{pmatrix}
\ddot{\bm{q}}_\mathrm{B} \\
\ddot{\bm{q}}_\mathrm{J}
\end{pmatrix}
+
\begin{pmatrix}
\bm{C}_\mathrm{B}(\bm{q},\dot{\bm{q}}) \\
\bm{C}_\mathrm{J}(\bm{q},\dot{\bm{q}})
\end{pmatrix}
\begin{pmatrix}
\dot{\bm{q}}_\mathrm{B} \\
\dot{\bm{q}}_\mathrm{J}
\end{pmatrix}
+
\begin{pmatrix}
\bm{g}_\mathrm{B}(\bm{q}) \\
\bm{g}_\mathrm{J}(\bm{q}) \\
\end{pmatrix} \nonumber \\
 =
\begin{pmatrix}
\bm{0} \\
\bm{\tau}_\mathrm{Jm} \\
\end{pmatrix}
-
\begin{pmatrix}
\bm{0} \\
\bm{\tau}_\mathrm{Jf} \\
\end{pmatrix}
+
\begin{pmatrix}
\bm{\tau}_\mathrm{Bext} \\
\bm{\tau}_\mathrm{Jext} \\
\end{pmatrix},
\label{eqn:indyn}
\end{gather}
%
where
%
$\bm{q}_\mathrm{B}=\begin{pmatrix}\bm{r}_\mathrm{B} ^\mathrm{T}& \bm{\varphi}_\mathrm{B}^\mathrm{T}\end{pmatrix}^\mathrm{T}$
%
and
%
$\bm{q}=\begin{pmatrix}\bm{q}_\mathrm{B}^\mathrm{T} & \bm{q}_\mathrm{J}^\mathrm{T}\end{pmatrix}^\mathrm{T}$
%
denote the generalized coordinates of the floating base and the full robot.
They consist of the Cartesian base position $\bm{r}_\mathrm{B} \in \mathbb{R}^3$, Euler angle base orientation $\bm{\varphi}_\mathrm{B} \in \mathbb{R}^3$ and joint angles $\bm{q}_\mathrm{J} \in \mathbb{R}^{n_\mathrm{J}}$.
Base and joint entries are marked with index ``B'' and ``J'', respectively.
%
Furthermore, (\ref{eqn:indyn}) can be written in the more compact form
%
\begin{equation}
\bm{M}(\bm{q})\ddot{\bm{q}}+\bm{C}(\bm{q},\dot{\bm{q}})\dot{\bm{q}}+\bm{g}(\bm{q})=\bm{\tau}_\mathrm{m}-\bm{\tau}_\mathrm{f}+\bm{\tau}_\mathrm{ext}\;,
\label{eqn:indyn_lumped}
\end{equation}
%
where $\bm{M}(\bm{q})$ denotes the mass matrix, $\bm{C}(\bm{q},\dot{\bm{q}})$ the matrix of centrifugal and Coriolis terms and $\bm{g}(\bm{q})$ the gravity vector.
The vectors $\bm{\tau}_\mathrm{m}$, $\bm{\tau}_\mathrm{f}$ and $\bm{\tau}_\mathrm{ext}$ denote the generalized motor, friction and external forces for the single contact case.
%

The external wrench $\bm{\mathcal{F}}_{\mathrm{ext}}$ acting on a point of contact $\bm{r}_{C}$ on robot link $i$ is projected via the corresponding geometric floating base Jacobian $\bm{J}(C,i)$ to the generalized external forces
\begin{align}
\bm{\tau}_{\mathrm{ext}}=&
\begin{pmatrix} \bm{\tau}_{\mathrm{B,ext}}
\\
\bm{\tau}_{\mathrm{J,ext}}
\end{pmatrix}
=
\bm{J}^\mathrm{T}(C,i)
\bm{\mathcal{F}}_{\mathrm{ext}} \\
=&
\begin{pmatrix}
\bm{I}_3 & - \bm{S}(\bm{r}_{BC}) \bm{J}_\omega & \bm{R} \bm{J}_{\mathrm{Jt}}(C,i)\\
\bm{0} & \bm{J}_\omega &  \bm{R} \bm{J}_{\mathrm{JR}}(C,i)
\end{pmatrix}
^\mathrm{T}
\begin{pmatrix} \bm{f}_{\mathrm{ext}}
\\
\bm{m}_{\mathrm{ext}} \nonumber
\end{pmatrix},
\end{align}
where
$\bm{S}(\cdot)$ denotes the skew-symmetric matrix operator,
$\bm{r}_{BC}=-\bm{r}_{B}+\bm{r}_{C}$ denotes the vector from point $B$ to point $C$,
$\bm{R}$ is the rotation matrix from robot base to world frame
and the geometric joint Jacobian $[\bm{J}_{\mathrm{Jt}}^\mathrm{T},\bm{J}_{\mathrm{JR}}^\mathrm{T}]^\mathrm{T}$ relates
%
$\dot{\bm{r}}_{C}=\bm{R}\bm{J}_{\mathrm{Jt}}(C,i)\dot{\bm{q}}_\mathrm{J}$
and
%
$\bm{\omega}_i=\bm{R}\bm{J}_{\mathrm{JR}}(C,i)\dot{\bm{q}}_\mathrm{J}$
%
\cite{OttHenLee2013,BouyarmaneKhe2012}.
Cartesian moments $\bm{m}_\mathrm{B}$ are projected to the base generalized rotation coordinates with the same angular velocity Jacobian $\bm{J}_\omega$ that relates the rotational base twist $\bm{\omega}_\mathrm{B}=\bm{J}_\omega(\bm{\varphi}_\mathrm{B})\dot{\bm{\varphi}}_\mathrm{B}$ to the derivative of the generalized coordinates for the chosen rotation representation $\dot{\bm{\varphi}}_\mathrm{B}$.
Note that in the following all vectors are expressed in world frame.
%
\subsection{Collision Detection, Isolation and Identification}
%
In this paper a humanoid robot is considered to have dynamics according to (\ref{eqn:indyn_lumped}) and to be equipped with joint torque, position and velocity sensing as well as an arbitrary number of force/torque sensors placed in the kinematic chain, see Fig.~\ref{fig:humanoid_contact_situation}.
In addition, the base orientation $\bm{\varphi}_\mathrm{B}$ and the base twist $\dot{\bm{x}}_\mathrm{B}$ can be measured.
Now, the objective is to detect, isolate and identify any collision along the robot structure for possibly multiple collisions.
In this context, collision \emph{detection} means to generate a number of binary signals indicating whether a collision is happening or not at a certain topological part of the robot.
\emph{Isolation} denotes to find the contact location $\bm{r}_{C_k}$ for the $k$-th collision.
\emph{Identification} aims for estimating the timely evolution of the generalized external forces $\bm{\tau}_{\mathrm{ext},k}(t)$ and the external contact wrenches $\bm{\mathcal{F}}_{\mathrm{ext},k}(t)$.
In summary, the objective is to find all contact locations and the corresponding contact wrenches.
%
\begin{figure}
\begin{center}
\includegraphics{figures/humanoid_contact_situation}
\end{center}
\caption{Considered problem of a humanoid robot in multiple contact situation.
External wrenches $\bm{\mathcal{F}}_{\mathrm{ext},k}$ are acting anywhere along its structure.
Forces in the feet originate from locomotion, forces at the hands may originate from manipulation.
Other external forces are caused by possibly unwanted collisions.
Also a number of force/torque sensors $S_l$ (5 in this concrete example) are distributed arbitrarily along the robot structure.}\vspace*{-0.7cm}
\label{fig:humanoid_contact_situation}
\end{figure}

Table~\ref{tab:sensors} lists the measurement quantities required to solve the problem and provides examples of suitable sensors.
Note that joint acceleration is typically not measured.
Furthermore, common acceleration sensors usually suffer from drift.
%
\begin{table}
\vspace*{0.5cm}
\caption{Measured quantities and sensors for the proposed collision detection, isolation and identification algorithm.}\label{tab:sensors}
\begin{tabular}{|c|c|c|}
\hline
robot part & measurement quantity & typical sensor\\\hline
base & $\bm{\varphi}_\mathrm{B},\dot{\bm{x}}_\mathrm{B}$ & gyroscope, Kalman estimator\\
limbs & $\bm{\tau}_\mathrm{Jm},\bm{q}_\mathrm{J},\dot{\bm{q}}_\mathrm{J}$ & joint torque sensor, encoders\\
 & $\bm{\mathcal{F}}_{S}$ & force/torque sensor\\
end-effectors & $\bm{\mathcal{F}}_{S,\mathrm{distal}}$ & force/torque sensor\\\hline
\end{tabular}\vspace*{-0.7cm}
\end{table}

\section{Collision Identification -- Part I}
\label{sec:collision_identification_i}

The first step of the proposed solution is to obtain an estimate $\hat{\bm{\tau}}_\varepsilon$ of the generalized external forces $\bm{\tau}_\mathrm{ext}$ generated by all contacts.
This can be achieved with the generalized momentum observer from \cite{DeLucaMat2003,DeLucaMat2004,Haddadin2014}, which is defined as
\begin{equation}
\hat{\bm{\tau}}_\mathrm{\varepsilon}=\bm{K}_\mathrm{O}
\left(
\bm{M}(\bm{q})\dot{\bm{q}}
-\int\limits_0^t
 [\bm{\tau}_\mathrm{m}
 -\bm{\gamma}(\bm{q},\dot{\bm{q}})
 +\hat{\bm{\tau}}_\mathrm{\varepsilon}
 ]\mathrm{d}\tilde{t}
 \right).
\label{eqn:obs_qDD}
\end{equation}
%
It generates an estimate $\hat{\bm{\tau}}_\varepsilon$ of the generalized external forces acting on the robot, where $\bm{K}_\mathrm{O}=\mathrm{diag}\{k_{\mathrm{O},i}\}>\bm{0}$ is the observer gain matrix and
\begingroup % damit spacing in align angepasst werden kann
\medmuskip=3mu
\thinmuskip=3mu
\thickmuskip=3mu
\begin{align}
\bm{\gamma}(\bm{q},\dot{\bm{q}}):=
\bm{n}(\bm{q},\dot{\bm{q}})-\dot{\bm{M}}(\bm{q})\dot{\bm{q}}
&=\bm{g}(\bm{q})
+\bm{C}(\bm{q},\dot{\bm{q}})\dot{\bm{q}}\nonumber
-\dot{\bm{M}}(\bm{q})\dot{\bm{q}}\\
&=
\bm{g}(\bm{q})-\bm{C}^\mathrm{T}(\bm{q},\dot{\bm{q}})\dot{\bm{q}}\;
\label{eqn:gamma}
\end{align}
\endgroup
%
due to the skew-symmetry of $\dot{\bm{M}}(\bm{q})-2\bm{C}(\bm{q},\dot{\bm{q}})$ \cite{DeLucaAlbHadHir2006}.
Under ideal conditions, which means that $\bm{q}, \dot{\bm{q}}, \bm{M}(\bm{q}), \bm{C}(\bm{q},\dot{\bm{q}}), \bm{g}(\bm{q})$ are known exactly, the observer dynamics are decoupled and every component $\hat{\bm{\tau}}_{\varepsilon}$ follows the first order dynamics
%
\begin{equation}
\bm{K}_\mathrm{O}^{-1}\hat{\dot{\bm{\tau}}}_{\varepsilon}+\hat{\bm{\tau}}_{\varepsilon}=\bm{\tau}_{\mathrm{ext}}\;.\label{eqn:obs_dynamic}
\end{equation}
%
Therefore, $\hat{\bm{\tau}}_{\varepsilon}$ is simply a first order filtered version of $\bm{\tau}_{\mathrm{ext}}$.

\subsection{Estimating Generalized Acceleration}

In order to be able to determine as many contact wrenches and locations as possible, the external torques already isolated and identified by force/torque sensors are to be excluded from the observed generalized external forces $\hat{\bm{\tau}}_\varepsilon$ \cite{VorndammeSchToeHad2016}.
Therefore, we need to compensate for the dynamic and static forces generated by the mass/inertia attached to each sensor.
For this compensation, the acceleration in Cartesian space $\ddot{\bm{x}}_D$ of its center of mass $D$ is required.
Assuming the sensor $S$ to be mounted on link $i$, it may simply be calculated via
%
\begin{equation}
\ddot{\bm{x}}_D=\begin{pmatrix}
\ddot{\bm{r}}_D\\\dot{\bm{\omega}}_D
\end{pmatrix}=\bm{J}(D,i)\ddot{\bm{q}}+\dot{\bm{J}}(D,i)\dot{\bm{q}}\;.
\label{eqn:accel_cart}
\end{equation}
%
As one can see, the generalized acceleration $\ddot{\bm{q}}$ is needed to calculate the Cartesian acceleration.
An estimate $\hat{\ddot{\bm{q}}}$ of $\ddot{\bm{q}}$ can be obtained from extending the disturbance observer (\ref{eqn:obs_qDD}).
Using its inner state
%
\begin{equation}
\hat{\dot{\bm{p}}}=\bm{M}(\bm{q})\hat{\ddot{\bm{q}}}+\dot{\bm{M}}(\bm{q})\dot{\bm{q}}=\bm{\tau}_\mathrm{m}
 -\bm{\gamma}(\bm{q},\dot{\bm{q}})
 +\hat{\bm{\tau}}_\mathrm{\varepsilon}\label{eqn:impulseD}
\end{equation}
%
the estimated acceleration follows as
%
\begin{equation}
\hat{\ddot{\bm{q}}}=\bm{M}(\bm{q})^{-1}(\hat{\dot{\bm{p}}}-\dot{\bm{M}}(\bm{q})\dot{\bm{q}})=
\bm{M}(\bm{q})^{-1}(\bm{\tau}_\mathrm{m}-\bm{n}(\bm{q},\dot{\bm{q}})+\hat{\bm{\tau}}_\mathrm{\varepsilon})\;.
\end{equation}
%
The dynamics of the acceleration error $\bm{e}:=\ddot{\bm{q}}-\hat{\ddot{\bm{q}}}$ can be derived using~(\ref{eqn:impulseD}):
%
\begin{align}
\bm{e}&=\bm{M}(\bm{q})^{-1}(\dot{\bm{p}}-\dot{\bm{M}}(\bm{q})\dot{\bm{q}})-\bm{M}(\bm{q})^{-1}(\hat{\dot{\bm{p}}}-\dot{\bm{M}}(\bm{q})\dot{\bm{q}})\nonumber\\
&=\bm{M}(\bm{q})^{-1}(\bm{\tau}_\mathrm{m}-\bm{n}(\bm{q},\dot{\bm{q}})+\bm{\tau}_\mathrm{\mathrm{ext}}-(\bm{\tau}_\mathrm{m}-\bm{n}(\bm{q},\dot{\bm{q}})+\hat{\bm{\tau}}_\mathrm{\varepsilon}))\nonumber\\
&=\bm{M}(\bm{q})^{-1}(\bm{\tau}_\mathrm{\mathrm{ext}}-\hat{\bm{\tau}}_\mathrm{\varepsilon})\;.\label{eqn:qDD_dyn}
\end{align}
%
Using the Laplace transform on~(\ref{eqn:obs_dynamic}) and~(\ref{eqn:qDD_dyn}) and assuming $\bm{M}(\bm{q})$ to change slowly, we achieve the following dynamics:
%
\begin{equation}
%\bm{M}(\bm{q})^{-1}\left(\begin{pmatrix}\frac{\tau_{\mathrm{ext},1}}{1+sK_{O,1}^{-1}}\\\vdots\\\frac{\tau_{\mathrm{ext},n}}{1+sK_{O,n}^{-1}}\end{pmatrix}-\bm{\tau}_\mathrm{ext}\right)
\bm{e}=\bm{M}(\bm{q})^{-1}\begin{pmatrix}\frac{sk_{\mathrm{O},1}^{-1}\tau_{\mathrm{ext},1}}{1+sk_{\mathrm{O},1}^{-1}} &\dots&\frac{sk_{\mathrm{O},n}^{-1}\tau_{\mathrm{ext},n}}{1+sk_{\mathrm{O},n}^{-1}}\end{pmatrix}^\mathrm{T}\hspace*{-2mm}.\label{eqn:acc_err_dyn}
\end{equation}
%
The error dynamics (\ref{eqn:acc_err_dyn}) consist of a vector with a linear dynamics triggered by $\bm{\tau}_\mathrm{ext}$, which is coupled nonlinearly by the inverted mass matrix to the error $\bm{e}$.
The estimate $\hat{\ddot{\bm{q}}}$ can be used to calculate $\ddot{\bm{x}}_D$ according to (\ref{eqn:accel_cart}) and therefore the external wrench $\bm{\mathcal{F}}_{\mathrm{ext}}$, as shown next.

\subsection{Dynamic Load Compensation}
\label{sec:load_comp}

\paragraph{Distal Sensor Case}
Figure~\ref{fig:fkb} depicts the free body diagram of a distal link containing a force/torque sensor $S$ measuring a wrench $\bm{\mathcal{F}}_S$.
The left part belongs to the link connected to the base holding the sensor.
The right part represents the body attached to the sensor generating gravitational and dynamic forces measured in the sensor.
The body mass is $m_D$ and its inertia tensor $\bm{I}_{D}$.
%
\begin{figure}
\begin{center}
\includegraphics{figures/freikoerperbild}
\end{center}
\caption{Free body diagram of a distal robot link containing a sensor $S$.
The sensor holds a body with mass $m_D$, center of mass $D$ and inertia $\bm{I}_\mathrm{D}$.
An external force $\bm{f}_\mathrm{ext}$ and an external moment $\bm{m}_{\mathrm{ext},C}$ act in contact point $C$.}\vspace*{-0.7cm}
\label{fig:fkb}
\end{figure}
%
Newton's second law yields
\begin{equation}
m_D\ddot{\bm{r}}_D=m_D\bm{g}+\bm{f}_\mathrm{ext}-\bm{f}_S\;.
\end{equation}
%
It follows for the \textbf{sensed} external force
%
\begin{equation}
\bar{\bm{f}}_{\mathrm{ext},S}=\bm{f}_S+m_D\ddot{\bm{r}}_D-m_D\bm{g}\;.\label{eqn:fbs}
\end{equation}
%
Obviously, equation~(\ref{eqn:fbs}) shows that the sensor does not measure the pure external forces only, but also forces due to gravity and inertia.
Thus, $\bm{\mathcal{F}}_S$ has to be corrected in order to obtain the true external wrench.

To derive the external moment, Euler's law of rigid body motion is applied to the center of gravity $D$ of the body:
%
\begin{equation}%\small
\medmuskip=0mu
\thinmuskip=0mu
\thickmuskip=0mu
\bm{I}_{D}\dot{\bm{\omega}}_D+\bm{\omega}_D\times \bm{I}_{D}\bm{\omega}_D=\bm{m}_{\mathrm{ext}}-\bm{m}_S-\bm{r}_{DS}\times\bm{f}_S+\bm{r}_{DC}\times\bm{f}_\mathrm{ext}\;.\label{eqn:mbs}
\end{equation}
%
This leads to the \textbf{sensed} external moment
%
\begingroup
\small
\begin{align}
\bar{\bm{m}}_{\mathrm{ext},S}:&=
\bm{m}_{\mathrm{ext}}+\bm{r}_{SC}\times\bm{f}_\mathrm{ext}\nonumber\\&=
\bm{m}_S+\bm{I}_{D}\dot{\bm{\omega}}_D+\bm{\omega}_D\times \bm{I}_{D}\bm{\omega}_D+\bm{r}_{DS}\times(\bm{f}_S-\bm{f}_\mathrm{ext})\;.
\end{align}
\endgroup
%
Equations~(\ref{eqn:fbs}) and~(\ref{eqn:mbs}) result in the \textbf{sensed} external wrench
%
\begingroup % damit spacing in align angepasst werden kann
\medmuskip=2mu
\thinmuskip=2mu
\thickmuskip=2mu
\small
\begin{align}
\bar{\bm{\mathcal{F}}}_{\mathrm{ext},S}&=\begin{pmatrix}
\bar{\bm{f}}_{\mathrm{ext},S}\\\bar{\bm{m}}_{\mathrm{ext},S}\nonumber
\end{pmatrix}=\bm{\mathcal{F}}_{S}+\bm{\mathcal{F}}_{c,S}\\
:&=\bm{\mathcal{F}}_S+\left(\begin{smallmatrix}
m_D\bm{I}_3 & \bm{0}\\
m_D\bm{S}(\bm{r}_{SD}) & \bm{I}_{D}
\end{smallmatrix}\right)
\left(\left(\begin{smallmatrix}\ddot{\bm{r}}_D\\\dot{\bm{\omega}}_D\end{smallmatrix}\right)-\left(\begin{smallmatrix}
\bm{g}\\\bm{0}
\end{smallmatrix}\right)\right)+\left(\begin{smallmatrix}
\bm{0}\\
\bm{\omega}_D\times\bm{I}_{D}\bm{\omega}_D
\end{smallmatrix}\right).\label{eqn:ext_wrench}
\end{align}
\endgroup
%
$\bm{I}_3$ denotes the three dimensional unit matrix, $\bm{g}$ the Cartesian gravity vector, $\bm{r}_{DS}$ the vector from the center of mass of the inertia attached to the sensor to the sensor and $\bm{0}$ the zero matrix of suitable size.
All entities are expressed in the world frame.
Using $\hat{\ddot{\bm{q}}}$ instead of $\ddot{\bm{q}}$ in~(\ref{eqn:accel_cart}) to compute $\hat{\ddot{\bm{x}}}_D$ one obtains the estimated external wrench acting in $S$ as
%
\begin{equation}\small
\medmuskip=2mu
\thinmuskip=2mu
\thickmuskip=2mu
\hat{\bm{\mathcal{F}}}_{\mathrm{ext},S}=\bm{\mathcal{F}}_S+\underbrace{\left(\begin{smallmatrix}
m_D\bm{I}_3 & \bm{0}\\
m_D\bm{S}(\bm{r}_{SD}) & \bm{I}_{D}
\end{smallmatrix}\right)
\left(\left(\begin{smallmatrix}\hat{\ddot{\bm{r}}}_D\\\hat{\dot{\bm{\omega}}}_D\end{smallmatrix}\right)-\left(\begin{smallmatrix}
\bm{g}\\\bm{0}
\end{smallmatrix}\right)\right)+\left(\begin{smallmatrix}
\bm{0}\\
\bm{\omega}_D\times\bm{I}_\mathrm{D}\bm{\omega}_D
\end{smallmatrix}\right)}_{\hat{\bm{\mathcal{F}}}_{c,S}}\;.
\end{equation}

\paragraph{Intermediate Sensor Case}
If the sensor is located within an intermediate link, the compensation wrenches for each body $b$, with center of mass $D_b$, succeeding this sensor become
%
\begin{equation}
\medmuskip=0mu
\thinmuskip=0mu
\thickmuskip=0mu
\small
\hat{\bm{\mathcal{F}}}_{\mathrm{c},b}=\left(\begin{smallmatrix}
m_{D_b}\bm{I}_3 & \bm{0}\\
m_{D_b}\bm{S}(\bm{r}_{SD_b}) & \bm{I}_{D_b}
\end{smallmatrix}\right)
\left(\left(\begin{smallmatrix}\hat{\ddot{\bm{r}}}_{D_b}\\\hat{\dot{\bm{\omega}}}_{D_b}\end{smallmatrix}\right)-\left(\begin{smallmatrix}
\bm{g}\\\bm{0}
\end{smallmatrix}\right)\right)+\left(\begin{smallmatrix}
\bm{0}\\
\bm{\omega}_{D_b}\times\bm{I}_{D_b}\bm{\omega}_{D_b}
\end{smallmatrix}\right)
\end{equation}
%
and simply have to be summed up for compensation.
Note that this operation explicitly corresponds to the Newton- Euler method for calculating multibody dynamics.
Therefore, in this case, the estimated external wrench sensed in $S$ becomes
%
\begin{equation}
\hat{\bm{\mathcal{F}}}_{\mathrm{ext},S}=\bm{\mathcal{F}}_S+\sum_{b\in N(b_\mathrm{s})}\hat{\bm{\mathcal{F}}}_{\mathrm{c},b}=:\bm{\mathcal{F}}_S+\hat{\bm{\mathcal{F}}}_{\mathrm{c},S}\;.\label{eqn:cmp}
\end{equation}
%
$N(b_\mathrm{s})$ denotes the set of all bodies succeeding link $b_\mathrm{s}$, that contains the sensor in the kinematic chain.
For multiple sensors in a kinematic chain (e.g. in each joint), the compensation wrenches can be calculated recursively to avoid multiple calculations, see Algorithm~\ref{alg:comp}.
The code uses the set $M(S)$, denoting all sensors $T\in M(S)$ directly succeeding $S$.
This means there is no further sensor between $S$ and an element of $M(S)$ in the kinematic chain connecting the two.
%
\begin{algorithm}
\caption{Dynamic load compensation for multiple force/torque sensors located along the structure}
\textbf{function} $\hat{\bm{\mathcal{F}}}_{\mathrm{c},S} =$ calculate\_F\_c($S$)\\
\Begin{
	$\hat{\bm{\mathcal{F}}}_{\mathrm{c},S}:=0$\\
	\For {all bodies $b$ directly succeeding $S$}{
			$\hat{\ddot{\bm{x}}}_{D_b}=\bm{J}_{D_b}\hat{\ddot{\bm{q}}}+\dot{\bm{J}}_{D_b}\dot{\bm{q}}$\\
			$\small\hat{\bm{\mathcal{F}}}_{\mathrm{c},S}+=\left(\begin{smallmatrix}
			m_{D_b}\bm{I}_3 & \bm{0}\\
			m_{D_b}\bm{S}(\bm{r}_{SD_b}) & \bm{I}_{D_b}
			\end{smallmatrix}\right)
			\left(\hat{\ddot{\bm{x}}}_{D_b}-\left(\begin{smallmatrix}
			\bm{g}\\\bm{0}
			\end{smallmatrix}\right)\right)$\\
			$\quad\quad\quad\quad\quad+\left(\begin{smallmatrix}
			\bm{0}\\
			\bm{\omega}_{D_b}\times\bm{I}_{D_b}\bm{\omega}_{D_b}
			\end{smallmatrix}\right)$
	}
	\For {all $T\in M(S)$}{
			$\hat{\bm{\mathcal{F}}}_{\mathrm{c},T} =$ calculate\_F\_c($T$)\\
			$\hat{\bm{\mathcal{F}}}_{\mathrm{c},S}+=\hat{\bm{\mathcal{F}}}_{\mathrm{c},T}+
			\begin{pmatrix}
			\bm{0}\\\bm{r}_{ST}\times\hat{\bm{f}}_{\mathrm{ext},T}
			\end{pmatrix}$
	}
}
\label{alg:comp}
\end{algorithm}

\subsection{Generalized Contact Force Estimation}

It is to be considered for the estimation of the contact wrenches and also for the collision detection that the observer detects generalized external forces originating from all external contacts.
In particular with a humanoid, we usually have desired contacts (e.g. at the feet during locomotion or hands during manipulation), these contact forces have to be measured with force/torque sensors close to the corresponding end-effectors (e.g. at the wrists and ankles) in order to enable exclusion from the observed generalized forces and avoid undesired collision detections (``false alarms'').

The full scheme consisting of observer and compensation is depicted in Fig.~\ref{fig:flowchart}.
For sake of simplicity force/torque sensors in all distal links of the arms and legs are assumed, denoted by the set $S_\mathrm{distal}$.
The more general case, where one or more distal links do not have a force/torque sensor will be left for future work at this point.
The general consequence of such a setup would be a limited ability to detect, isolate and identify collisions occurring between the end-effector and the most distal force/torque sensor in the kinematic chain.
%
\begin{figure}
\begin{center}
\includegraphics{figures/flowchart_compensation}
\end{center}
\caption{Exclusion of estimated desired external wrenches at the distal links $\hat{\bm{\mathcal{F}}}_{\mathrm{ext},S}$ measured by force/torque sensors from the observed generalized  forces of~(\ref{eqn:obs_qDD}).
These wrenches are therefore compensated according to~(\ref{eqn:ext_wrench}).}\vspace*{-0.8cm}
\label{fig:flowchart}
\end{figure}
%
% TODO: Keine joint forces, sondern generalized coordinates
The generalized external forces caused by the external wrenches at the distal links are subtracted from the observed generalized forces to obtain the estimated generalized forces originating from unexpected collisions $\hat{\bm{\tau}}_\mathrm{ext,col}$ as
%
\begin{equation}
\hat{\bm{\tau}}_\mathrm{ext,col}=\hat{\bm{\tau}}_\varepsilon-\sum_ {S\in S_\mathrm{distal}}\bm{J}^\mathrm{T}(S,i_S)\hat{\bm{\mathcal{F}}}_{\mathrm{ext},S}\;,\label{eqn:obs_cmp}
\end{equation}
%
where $i_S$ denotes the link containing the sensor $S$.
Now that the force/torque sensors are compensated and the desired external wrenches of the distal parts of the robot are excluded from the observed generalized external forces, collision detection can be performed.

\subsection{Collision Detection}

Collision detection is simply done via thresholding the generalized forces and estimated external wrenches
%
\begin{equation}
\begin{split}
\hat{\bm{\tau}}_\mathrm{ext,col}>\bm{\tau}_\mathrm{thresh} \text{ (element wise) or}\\
\hat{\bm{\mathcal{F}}}_{\mathrm{ext},S}>\bm{\mathcal{F}}_{S,\mathrm{thresh}} \text{ (element wise).}
\label{eqn:threshold}
\end{split}
\end{equation}
%
The information coming with evaluating (\ref{eqn:threshold}) can also be used to roughly estimate the contact location.
Contacts can always be located behind the last joint or sensor exceeding the threshold and before the next sensor not exceeding it, respectively.
To gain more precise information about the contact link, the external wrenches $\bm{\mathcal{F}}_{\mathrm{ext},k}$ are needed (see also Fig.~\ref{fig:ueberblick}).
The next section shows, how to obtain $\bm{\mathcal{F}}_{\mathrm{ext},k}$ and how to use it for collision isolation.

\section{Collision Isolation}
\label{sec:isolation}
Collision isolation cannot be generally handled for the case when external moments act along the robot.
For this case, the contact location of an additionally acting contact force cannot be located exactly.
Thus, for solving the isolation problem we assume no external moments to be acting on the robot ($\bm{m}_{\mathrm{ext},k}=\bm{0}$), which is a realistic assumption for most undesired collision situations.
If this assumption does not hold for a certain contact point, the isolation of this particular contact point will fail.
However, this does not influence the isolation and identification of other contact points.
In summary, isolation is done via the following four step approach:
%
\begin{enumerate}
\item Isolate the contact link,
\item estimate the external wrench acting on the respective contact link,
\item calculate the line of action of the force estimated and
\item determine the exact contact point by intersecting the line of action with the known robot geometry.
\end{enumerate}
%
For steps 2 and 3 two main scenarios have to be distinguished: single contact and multi contact scenarios.
The single contact scenario can be handled with joint torque sensing only, while the multi contact scenario often requires additional force/torque sensors in order to distinguish the different contacts.

\subsection{Single Contact}

\paragraph{Step 1}

The contact link can be found based on the fact that a contact cannot produce torques in joints appearing behind the contact location along the kinematic chain.
E.g., a contact at the upper arm cannot produce torques in the wrist.
Therefore, the contact link index $i$ can be isolated by
%
\begin{equation}
i=\max\{j|\tau_{\mathrm{ext,col},j} \neq 0\}
\label{eqn:contact_link}
\end{equation}
%
given the convention that joint $j$ connects link $j$ to the preceding links of the robot.
Note that due to the tree structure of a humanoid, this procedure can lead to multiple potential contact links. It has to be noted also that due to modeling and measurement errors, eq.~(\ref{eqn:contact_link}) is subject to thresholding.
Also some forces, e.g. forces parallel to the axis of the joint connected to the link they act on, do not produce torques at this joint. This may lead to erroneous estimation of the contact link. However, this problem can be tackled with a correction step introduced at the end of step~4.

\paragraph{Step 2}

When the contact link $i$ with origin $O_i$ is found, the external wrench $\bm{\mathcal{F}}_i$ acting on this respective link may be estimated via the Moore-Penrose pseudo inverse of $\bm{J}^\mathrm{T}(O_i,i)$:
%
\begin{equation}
\hat{\bm{\mathcal{F}}}_i=(\bm{J}^\mathrm{T}(O_i,i))^\#\hat{\bm{\tau}}_\mathrm{ext,col}\;.\label{eqn:F_i}
\end{equation}
%
\paragraph{Step 3}
\label{sec:isolation_step3}
For a single external wrench $\bm{\mathcal{F}}_\mathrm{ext}$ acting at the contact location $\bm{r}_C$, the wrench $\bm{\mathcal{F}}_i$ in $O_i$ may be obtained with the adjoint matrix $\bm{A}(C,O_i)$ via
%
\begin{equation}
\bm{\mathcal{F}}_i=\bm{A}^\mathrm{T}(C,O_i)\bm{\mathcal{F}}_\mathrm{ext}
=\begin{pmatrix} \bm{I}_3 & \bm{0}\\
\bm{S}(\bm{r}_{O_iC}) & \bm{I}_3\end{pmatrix}
\bm{\mathcal{F}}_\mathrm{ext}\;.\label{eqn:ext_wrench_i}
\end{equation}
%
Recalling the assumption of absence of external moments ($\bm{m}_\mathrm{ext}=\bm{0}$) this results in
%
\begin{equation}
\bm{\mathcal{F}}_i=\begin{pmatrix} \bm{f}_i\\\bm{m}_i\end{pmatrix}
=\begin{pmatrix}
\bm{f}_\mathrm{ext}\\\bm{S}(\bm{r}_{O_iC})\bm{f}_\mathrm{ext}
\end{pmatrix}=\begin{pmatrix}
\bm{f}_i\\\bm{S}^\mathrm{T}(\bm{f}_i)\bm{r}_{O_iC}
\end{pmatrix}.\label{eqn:contact_pkt}
\end{equation}
%
From~(\ref{eqn:contact_pkt}), the line of action of the force can be derived.
It is described by $\bm{r}_{A}+\lambda\bm{f}_i/\|\bm{f}_i\|$ for $\lambda\in\mathbb{R}$ with
%
\begin{equation}
\bm{r}_A=\bm{r}_{O_i}+\bm{r}_{O_iA}=\bm{r}_{O_i}+\left(\bm{S}^\mathrm{T}(\bm{f}_i)\right)^\#\bm{m}_i\;.
\label{equ:force_loa_point}
\end{equation}
%

\paragraph{Step 4}
\label{sec:isolation_step4}
Due to the properties of the pseudo inverse and the rank deficit of skew symmetric matrices, $\bm{r}_{A}$ is the point along the line of action of the force, which lies closest to the origin and therefore is not identical to $\bm{r}_C$ in general.
However, it is possible to calculate $\bm{r}_C$ by intersecting the line of action of the force with the link geometry of the contact link.
If this intersection problem has more than one solution, the one with the smallest parameter $\lambda$ can e.g. be chosen.
This choice is made when we assume a pushing force, which is most common for unexpected collisions.
However, all candidates can be generated and utilized if more sophisticated processing is done at a higher level of abstraction.

If the contact link is not estimated correctly, the contact point $\bm{r}_C$ can nonetheless be computed for the single contact case, as the base movement provides sufficient information to determine it.
This happens e.g. if the contact force is parallel to the axis of the joint connected to the link it is acting on or line of action of the force crosses this joint axis.
In this case, the line of action may happen to not intersect the estimated contact link.
Therefore, the contact point $\bm{r}_C$ may be determined correctly by intersecting the line of action also with the subsequent links.

\subsection{Multiple Contacts}

For the case of multiple contacts, above method may be used in combination with compensated force/torque sensing. Then, for each sensor, a contact in the kinematic chain following the sensor may be detected by applying steps 3 and 4 for the compensated (in the sense of~(\ref{eqn:ext_wrench})~or~(\ref{eqn:cmp})) wrenches $\hat{\bm{\mathcal{F}}}_{\mathrm{ext},S}$ of the sensors.
In case of more than one sensor and more than one contact in the kinematic chain, the wrenches originating from contacts already measured by sensors closer to the distal end of the chain have to be subtracted from the measured wrench.
As a sensor sees all contact wrenches acting on subsequent sensors with an additional moment because of the change in lever of the force, in addition to the external wrenches exclusively seen by it, this leads to
%
\begin{equation}
\hat{\bm{\mathcal{F}}}_{\mathrm{ext},k}=\hat{\bm{\mathcal{F}}}_{\mathrm{ext},S}-\sum_{T\in N(S)}\left(\hat{\bm{\mathcal{F}}}_{\mathrm{ext},T}+\begin{pmatrix}
\bm{0}\\\bm{r}_{ST}\times\hat{\bm{f}}_{\mathrm{ext},T}
\end{pmatrix}\right).\label{eqn:cmp_ext_vorher}
\end{equation}
%
Considering the situation of Fig.~\ref{fig:humanoid_contact_situation} for example, two contacts can be detected at the right arm.
One by sensor $S_3$ and one by sensor $S_1$, as long as one contact is behind $S_1$ and the other between $S_3$ and $S_1$.
As this is the case for $\bm{\mathcal{F}}_{\mathrm{ext},2}$ and $\bm{\mathcal{F}}_{\mathrm{ext},5}$ these two wrenches may be estimated correctly.

If no force/torque sensors are available the correct isolation of multiple contacts is only possible if the contact links are estimated correctly and are far enough away from the base, which means that the Jacobians of the contact links together include at least 6~DOFs per wrench to estimate. For this, the contact wrenches may be calculated by stacking the Jacobians together and calculating the according pseudoinverse
%
\begin{equation}
\medmuskip=3mu
\thinmuskip=3mu
\thickmuskip=3mu
\left(
\bm{\mathcal{F}}_{i_1}^\mathrm{T} \ldots \bm{\mathcal{F}}_{i_n}^\mathrm{T}\right)^\mathrm{T}=\left(
\bm{J}^\mathrm{T}(O_{i_1},i_1) \ldots  \bm{J}^\mathrm{T}(O_{i_n},i_n)\right)^\#\bm{\tau}_\mathrm{ext,col}\;.\label{eqn:multi_iso}
\end{equation}
%
Note that in case of a singularity in the Jacobians additional DOFs may be required to estimate the wrenches correctly.
Thereafter, steps 3 and 4 can be applied to each estimated wrench $\bm{\mathcal{F}}_{i}$. This step may be considered  a generalization of eq. (6) in \cite{OttHenLee2013}.

\section{Collision Identification -- Part II}

Now that the contact points are determined, the full contact Jacobians
%
\begin{equation}
\bm{J}(C,i)=\bm{A}(C,O_i)\bm{J}(O_i,i)
\end{equation}
%
may be computed.
Similar to~(\ref{eqn:multi_iso}) they can be used to identify the external wrenches
%
\begin{equation}
\medmuskip=1mu
\thinmuskip=1mu
\thickmuskip=1mu
\left(
\bm{\mathcal{F}}_\mathrm{ext,1}^\mathrm{T} \ldots \bm{\mathcal{F}}_{\mathrm{ext},n}^\mathrm{T}\right)^\mathrm{T}=\left(
\bm{J}^\mathrm{T}(C_1,i_1) \ldots \bm{J}^\mathrm{T}(C_n,i_n)\right)^\#\bm{\tau}_\mathrm{ext,col}\;.
\label{eqn:force_identification}
\end{equation}
%
This step is only neccessary, if the contact points are found in different links than determined by (\ref{eqn:contact_link}).
In this case, measurements of additional joints are used to improve the result of (\ref{eqn:F_i}).
Otherwise, the inverse of (\ref{eqn:ext_wrench_i}) can be used directly to calculate the contact wrenches.
For wrenches identified with a force/torque sensor, no action has to be taken in this step, as the corrected wrenches are already the best estimates.
Figure~\ref{fig:ueberblick} depicts an overview of the entire algorithm.
%
\begin{figure}
\begin{center}
\includegraphics{figures/ueberblick}
\end{center}
\caption{An overview of the collision detection isolation and identification algorithm.
The more information is used, the more information can be obtained from the collision detection step.
If the collision detection is based on $\hat{\bm{\tau}}_\mathrm{ext,col}$ only, the contact cannot be fully located.
If $\hat{\bm{\mathcal{F}}}_{\mathrm{ext},S}$ is used in addition, the contact can be located to the parts of the robot lying between the detecting and the following sensors.
If the full $\hat{\bm{\mathcal{F}}}_{\mathrm{ext},k}$ are available, collision detection can be done on a per link basis.}\vspace*{-0.7cm}
\label{fig:ueberblick}
\end{figure}
%
In the next section, the proposed algorithm is validated in different scenarios with a simulated Atlas robot.


\chapter{Lecture 24 Jun 27th 2018}%
\label{chp:lecture_24_jun_27th_2018}
% chapter lecture_24_jun_27th_2018

\section{Rings (Continued 4)}%
\label{sec:rings_continued_4}
% section rings_continued_4

\subsection{Isomorphism Theorems for Rings (Continued)}%
\label{sub:isomorphism_theorems_for_rings_continued}
% subsection isomorphism_theorems_for_rings_continued

\begin{thm}[Chinese Remainder Theorem]
\index{Chinese Remainder Theorem}
\label{thm:chinese_remainder_theorem}
  Let $A$ and $B$ be ideals of $R$.
  \begin{enumerate}
    \item $A + B = R \implies \faktor{R}{(A \cap B)} \cong \faktor{R}{A} \times \faktor{R}{B}$
    \item $A + B = R \, \land \, A \cap B = \{0\} \implies R \cong \faktor{R}{A} \times \faktor{R}{B}$
  \end{enumerate}
\end{thm}

\begin{proof}
  It suffices to prove $(1)$ since if $(1)$ is true and $A \cap B = \{0\}$, then $(2)$ immediately follows.

  Define
  \begin{equation*}
    \Theta: R \to \faktor{R}{A} \times \faktor{R}{B} \qquad r \mapsto ( r + A, r + B )
  \end{equation*}
  Then $\Theta$ is a ring homomorphism \sidenote{
  \begin{ex}
    Prove that $\Theta$ is a ring homomorphism.
  \end{ex}
  }.

  \begin{proof}[$\Theta$ is a ring homomorphism]
    $\forall r, s \in R$, we have
    \begin{align*}
      \Theta(rs) &= (rs + A, rs + B) \\
                 &\overset{(*)}{=} (r + A, r + B)(s + A, s + B) \\
                 &= \Theta(r) \Theta(s)
    \end{align*}
    where $(*)$ is by \cref{propo:construction_of_the_quotient_ring}. Also by the same proposition, we have
    \begin{equation*}
      \Theta(1) = (1 + A, 1 + B).
    \end{equation*}
    Then,
    \begin{align*}
      \Theta(r + s) &= (r + s + A, r + s + B) \\
                    &\overset{(\dagger)}{=} (r + A, r + B) + (s + A, s + B) \\
                    &= \Theta(r) + \Theta(s)
    \end{align*}
    where $(\dagger)$ is by \cref{propo:properties_of_the_additive_quotient_group}.
  \end{proof}
  Note that $\ker \Theta = A \cap B$, since
  \begin{equation*}
    \ker \Theta = \{ r \in R : \Theta(r) = (A, B) \} = \{r \in A \, \land \, r \in B \} = A \cap B.
  \end{equation*}
  To show that $\Theta$ is surjective, let $(s + A, t + B) \in \faktor{R}{A} \times \faktor{R}{B}$ with $s, \, t \in R$. Since $A + B = R$, $\exists a \in A, \, \exists b \in B$ such that $a + b = 1$. Let $r = sb + ta$. Then
  \begin{align*}
    s - r &= s - sb - ta = s(1 - b) - ta = sa - ta = (s - t) a \in A \\
    t - r &= t - sb - ta = t(1 - a) - sb = tb - sb = (t - s) b \in B
  \end{align*}
  and so by \cref{propo:properties_of_the_additive_quotient_group},
  \begin{equation*}
    s + A = r + A \text{ and } t + B = r + B.
  \end{equation*}
  Therefore
  \begin{equation*}
    \Theta(r) = (r + A, r + B) = (s + A, t + B),
  \end{equation*}
  and so $\Theta$ is surjecive. Then by the \cref{thm:first_isomorphism_theorem_for_rings},
  \begin{equation*}
    \faktor{R}{(A \cap B)} \cong \faktor{R}{A} \times \faktor{R}{B}.
  \end{equation*}\qed
\end{proof}

\newthought{Why is} \cref{thm:chinese_remainder_theorem} called the Chinese Remainder Theorem?

Let $m, n \in \mathbb{N}$ with $\gcd(m, n) = 1$. Then we know that
\begin{equation*}
  m \mathbb{Z} \cap n \mathbb{Z} = mn \mathbb{Z}.
\end{equation*}
Also, $m \mathbb{Z} + n \mathbb{Z} = \mathbb{Z}$ since $1 = ma + nb$ for some $a, b \in \mathbb{Z}$ by \hlnotea{Bezout's Lemma}. And so:

\begin{crly}
\label{crly:why_crt}
  \begin{enumerate}
    \item If $m, n \in \mathbb{N}$ with $\gcd(m, n) = 1$, then
      \begin{equation*}
        \faktor{\mathbb{Z}}{mn \mathbb{Z}} \cong \faktor{\mathbb{Z}}{m \mathbb{Z}} \times \faktor{\mathbb{Z}}{n \mathbb{Z}}
      \end{equation*}
      i.e.
      \begin{equation*}
        \mathbb{Z}_{mn} \cong \mathbb{Z}_m \times \mathbb{Z}_n
      \end{equation*}

    \item If $m, n \in \mathbb{N}$ with $m, n \geq 2$ and $\gcd(m, n) = 1$, then
      \begin{equation*}
        \phi(mn) = \phi(m)\phi(n)
      \end{equation*}
      where $\phi(m) = \abs{\mathbb{Z}_m^*}$ is \hldefn{Euler's $\phi$-function}\index{Euler's Totient Function}.
  \end{enumerate}
\end{crly}

\newthought{Let} $p$ be a prime. Recall that one consequence of \hyperref[thm:lagrange_s_theorem]{Lagrange's Theorem} is that every group $G$ of order $p$ is cyclic, i.e. $G \cong C_p$.

An analogous notion in rings is the following:

\begin{propo}[Ring With Prime Order Is Isomorphic to Integer Modulo Prime]
\label{propo:ring_with_prime_order_is_isomorphic_to_integer_modulo_prime}
  If $R$ is a non-trivial ring with $\abs{R} = p$ where $p$ is prime, then $R \cong \mathbb{Z}_p$.
\end{propo}

\begin{proof}
  Define
  \begin{equation*}
    \Theta : \mathbb{Z}_p \to R \qquad [k] \mapsto k \cdot 1_R.
  \end{equation*}
  Note that since $R$ is an additive group with $\abs{R} = p$, by \hyperref[thm:lagrange_s_theorem]{Lagrange's Theorem}, $o(1_R) = 1$ or $p$. Since $R$ is non-trivial, we have that $1_R \neq 0$ by the remark on the definition of a \hyperref[defn:trivial_ring]{trivial ring}, and so $o(1_R) \neq 1$. Thus $o(1_R) = p$. Then, by \cref{propo:implications_of_the_characteristic}, we have
  \begin{equation*}
    [k] = [m] \iff p \, | \, (k - m) \iff (k - m) 1_R = 0 \iff k \cdot 1_R = m \cdot 1_R
  \end{equation*}
  in $R$. Thus, $\Theta$ is well-defined and injective. $\Theta$ is also a ring homomorphism \sidenote{
  \begin{ex}
    Prove that $\Theta$ is a ring homomorphism.
  \end{ex}
  }.

  \begin{proof}[$\Theta$ is a ring homomorphism]
    $\forall [a], [b] \in \mathbb{Z}$, we have
    \begin{align*}
      \Theta([a][b]) &= \Theta( [ab] ) = ab \cdot 1_R \\
                     &= ( a \cdot 1_R )( b \cdot 1_R ) = \Theta([a])\Theta([b]).
    \end{align*}
    \begin{equation*}
      \Theta([1]) = 1 \cdot 1_R = 1_R
    \end{equation*}
    and
    \begin{align*}
      \Theta([a] + [b]) &= \Theta([ a + b ]) = (a + b) \cdot 1_R \\
                        &= a \cdot 1_R + b \cdot 1_R = \Theta([a]) + \Theta([b]).
    \end{align*}
    So $\Theta$ is a ring homomorphism.
  \end{proof}
  Now because $\abs{\mathbb{Z}_p} = p = \abs{R}$ and $\Theta$ is injective, $\Theta$ must be surjective. Therefore $\Theta$ is a ring isomorphism and hence $R \cong \mathbb{Z}_p$ as required. \qed
\end{proof}

% subsection isomorphism_theorems_for_rings_continued (end)

% section rings_continued_4 (end)

\section{Commutative Rings}%
\label{sec:commutative_rings}
% section commutative_rings

\subsection{Integral Domain and Fields}%
\label{sub:integral_domain_and_fields}
% subsection integral_domain_and_fields

\begin{defn}[Units]\index{Units}
\label{defn:units_and_group_of_units}
  Let $R$ be a ring. We say that $u \in R$ is a \hlnoteb{unit} if $u$ has a multiplicative inverse in $R$, and denote it by $u^{-1}$. We have
  \begin{equation*}
    uu^{-1} = 1 = u^{-1} u
  \end{equation*}
\end{defn}

\begin{note}
  If $u$ is a unit in $R$, and $r, s \in R$, we have
  \begin{align*}
    ur = us &\implies r = s \quad \text{\hlnotea{( Right Cancellation )}} \\
    ru = su &\implies r = s \quad \text{\hlnotea{( Left Cancellation )}}
  \end{align*}
  Let $R^*$ denote the set of all units in $R$. We know that the definition of a ring is that $R$ is ``almost'' a group under multiplication except that its elements do not necessarily have multiplicative inverses. Since $R^* \subseteq R$ is the set that contains all units, i.e. all elements with multiplicative inverses in $R$, we have that $(R^*, \cdot)$ is a group. This is called the \hldefn{Group of Units} of $R$.
\end{note}

\begin{eg}
  Note that $2$ is a unit in $\mathbb{Q}$, but it is not a unit in $\mathbb{Z}$. We have that
  \begin{equation*}
    \mathbb{Q}^* = \mathbb{Q} \setminus \{0\} \text{ and } \mathbb{Z}^* = \{ \pm 1 \}
  \end{equation*}
\end{eg}

\begin{eg}
  Consider the ring of \hldefn{Gaussian Integers},
  \begin{equation*}
    \mathbb{Z}[i] = \{a + bi : a, b \in \mathbb{Z}, \, i^2 = -1 \} \leq \mathbb{C}.
  \end{equation*}
  Then
  \begin{equation*}
    \mathbb{Z}[i]^* = \{ \pm 1, \pm i \} \leq \mathbb{C}.
  \end{equation*}

  \begin{proof}
    \textbf{$\mathbb{Z}[i] \leq \mathbb{C}$} : \\
    Note that $1 = 1 + 0 \cdot i \in \mathbb{Z}[i]$. $\forall x, y \in \mathbb{Z}[i]$, write
    \begin{equation*}
      x = a + bi \quad y = c + di
    \end{equation*}
    for some $a, b, c, d \in \mathbb{Z}$. Observe that
    \begin{equation}\label{eq:q5_a_1}
      xy = (a + bi)(c + di) = (ac - bd) + i (bc + ad) \in \mathbb{Z}[i]
    \end{equation}
    since $(ab - bd), (bc + ad) \in \mathbb{Z}$. Also, with a similar reason
    \begin{equation*}
      x - y = a + bi - c - di = (a - c) + i (b - d) \in \mathbb{Z}[i].
    \end{equation*}
    Therefore, by the Subring Test, $\mathbb{Z}[i]$ is a subring of $\mathbb{C}$.

    \textbf{$\mathbb{Z}[i]^* = \left\{ \pm 1, \, \pm i \right\}$} : \\
    In order for $x \in \mathbb{Z}[i]^*$, $x \neq 0$, to have an inverse, we must have that
      \begin{equation*}
        (ac - bd) + i ( bc + ad ) = 1
      \end{equation*}
      from \cref{eq:q5_a_1}, where we shall note that $a^2 + b^2 \neq 0$. Observe that
      \begin{align*}
        &( ac - bd ) + i ( bc + ad ) = 1 \\
        &\iff \begin{pmatrix}
            ac - bd \\ bc + ad
        \end{pmatrix} = \begin{pmatrix}
              1 \\ 0
        \end{pmatrix} \\
        &\iff \begin{pmatrix}
            a & -b \\ b & a
        \end{pmatrix} \begin{pmatrix}
          c \\ d
        \end{pmatrix} = \begin{pmatrix}
          1 \\ 0
        \end{pmatrix} \\
        &\iff \begin{pmatrix}
          c \\ d
        \end{pmatrix} = \frac{1}{a^2 + b^2} \begin{pmatrix}
          1 \\ 0
        \end{pmatrix} \begin{pmatrix}
          a & b \\ -b & a
        \end{pmatrix} = \frac{1}{a^2 + b^2} \begin{pmatrix}
          a \\ -b
        \end{pmatrix} \\
        &\iff c + id = \frac{a}{a^2 + b^2} + i \left( \frac{-b}{a^2 + b^2} \right)
      \end{align*}
      Since $c, d \in \mathbb{Z}$, we must have that
      \begin{equation*}
        \frac{a}{a^2 + b^2}, \, \frac{-b}{a^2 + b^2} \in \mathbb{Z}.
      \end{equation*}
      Also, since $a^2 + b^2 > a, \, b$, we have that
      \begin{equation*}
        \frac{a}{a^2 + b^2}, \, \frac{-b}{a^2 + b^2} \in \mathbb{Z} \iff a^2 + b^2 = 1.
      \end{equation*}
      Since $a, \, b \in \mathbb{Z}$, we have that the only integer solutions to $a^2 + b^2 = 1$ are
      \begin{equation*}
        (1, \, 0) , \, (0, \, 1) , \, ( -1, \, 0 ) , \, (0, \, -1),
      \end{equation*}
      which corresponds to
      \begin{equation*}
        x = \pm 1, \, \pm i.
      \end{equation*}
      Since we began with $x$ begin an arbitrary element in $\mathbb{Z}[i]^*$, we have that
      \begin{equation*}
        \mathbb{Z}[i]^* = \{ \pm 1, \, \pm i \}
      \end{equation*}
      as required.
    \qed
  \end{proof}
\end{eg}

\begin{defn}[Division Ring and Field]\index{Division Ring}\index{Field}
\label{defn:division_ring_and_field}
  A non-trivial ring $R$ is a \hlnoteb{division ring} if
  \begin{equation*}
    R^* = R \setminus \{0\}.
  \end{equation*}
  A commutative division ring is a \hlnoteb{field}.
\end{defn}

\begin{eg}
  $\mathbb{Q}, \, \mathbb{R}, \, \mathbb{C}$ are fields but $\mathbb{Z}$ is not.
\end{eg}

\begin{eg}
  $\mathbb{Z}_n$ is a field $\iff \, n$ is prime.
\end{eg}

\begin{remark}
\marginnote{This remark is not as useful or spectacular within this course, but it will be once we go into PMATH348 contents.} If $R$ is a division ring or a field, then its only ideals are $\{0\}$ or $R$, since if $A \neq \{0\}$ is an ideal of $R$, then $\exists a \in A$, $a \neq 0$, such that $1 = aa^{-1} \in A$, which implies that $A = R$ by \cref{propo:the_only_ideal_with_the_multiplicative_identity_is_the_ring_itself}.
\end{remark}

\begin{remark}
  It can be shown that every finite division ring is a field, and this is known as \href{https://en.wikipedia.org/wiki/Wedderburn_Theorem}{Wedderburn's Theorem}.
\end{remark}

\newthought{Note that} if $n = ab$ for some integer $n$ with $0 < a, b < n$, then in $\mathbb{Z}$ we have
\begin{equation*}
  [a][b] = [n] = [0]
\end{equation*}
but $[a] \neq [0] \neq [b]$ by our definition of $a, b$.

\begin{defn}[Zero Divisor]\index{Zero Divisor}
\label{defn:zero_divisor}
  Let $R$ be a non-trivial ring. If $0 \neq a \in R$, then $a$ is called a \hlnoteb{zero divisor} if $\exists 0 \neq b \in R$ such that $ab = 0$.
\end{defn}

% subsection integral_domain_and_fields (end)

% section commutative_rings (end)

% chapter lecture_24_jun_27th_2018 (end)