I try to rebuild a fairly complicated math-table, and I'm almost satisfied with the result. The MWE actually compiles to the table I want, but with error messages. When I include the table in my real (big) document, I get the error messages too, but in that case the document doesn't compile anymore.
I spent quite some time experimenting with and checking the $, but cannot find the error, and would be grateful for any tip.
\documentclass[]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage[listings,theorems]{tcolorbox}
\tcbset{before={\par\medskip\pagebreak[0]\noindent},after={\par\medskip}}%
\begin{document}
\newcounter{texercise}[chapter]
\begin{tcolorbox}[colback=blue!5,colframe=blue!50!black,arc=0mm,
theorem={Algebra}{texercise}{(Vereinfachter) Datentyp 'Liste'}{myMarker}]{}
\medskip
\begin{tabular}{llll}
\textbf{algebra} & $list_1$ & & \\
\textbf{sorts} & \multicolumn{3}{l}{$list$, $elem$ \{$bool$ ist im folgenden immer implizit dabei\}} \\
\textbf{ops} & $empty$ & $:$ & $\to list$ \\
& $first$ & $:list$ & $\to elem$ \\
& $append$ & $:list$ & $\to list$ \\
& $concat$ & $:list \times elem$ & $\to list$ \\
& $isempty$ & $:list \times list$ & $\to bool$ \\
\textbf{sets} & $list$ & \multicolumn{2}{l}{$= \{ <a_1,\dots,a_n> \mid n \ge 0, a_i \in elem$\}}\\
\textbf{functions} & & & \\
& $empty$ & \multicolumn{2}{l}{ $ = \Diamond$}\\
& \multicolumn{3}{l}{
\begin{equation*}
$first(a_1 \dots a_n) =$
\begin{cases}
$a_1$ & \text{falls $n>0$} \\
undefiniert & \text{sonst}
\end{cases}
\end{equation*}} \\
\textbf{end} $list_1$ & & & \\
\end{tabular}
\end{tcolorbox}
\end{document}
Here is the error message:
ERROR: Missing $ inserted.
--- TeX said ---
<inserted text>
$
l.36 \end{equation*}}
\\
--- HELP ---
TeX probably found a command that can be used only in math mode when
it wasn't in math mode....
And here is the result:

