expression.constant_term()¶
Compute the "constant term" of an expression, i.e., the weight associated with the empty word.
Preconditions:
Algorithm:
- Based on a simple bottom-up traversal of the tree of the expression:
$$
\newcommand{\eword}{\varepsilon}
\newcommand{\lweight}[2]{\bra{#1}{#2}}
\newcommand{\rweight}[2]{#1\bra{#2}}
\newcommand{\lmulq}[2]{\bra{#1}^?{#2}}
\newcommand{\rmulq}[2]{#1\bra{#2}^?}
\newcommand{\bra}[1]{\langle#1\rangle}
\newcommand{\K}{\mathbb{K}}
\newcommand{\zed}{\mathsf{0}}
\newcommand{\und}{\mathsf{1}}
\newcommand{\zeK}{0_{\K}}
\newcommand{\unK}{1_{\K}}
\newcommand{\Ed}{\mathsf{E}}
\newcommand{\Fd}{\mathsf{F}}
\newcommand{\Gd}{\mathsf{G}}
\newcommand{\AND}{\mathbin{\&}}
\newcommand{\infiltrate}{\mathbin{\uparrow}}
\newcommand{\shuffle}{\mathbin{\between}}
\newcommand{\coloneqq}{:=}
\begin{align}
c(\zed)                & \coloneqq \bra{\zeK}                  \\
c(\und)                & \coloneqq \bra{\unK}                  \\
c(a)                   & \coloneqq \bra{\zeK}, \forall a \in A \\
c(\Ed+\Fd)             & \coloneqq c(\Ed) + c(\Fd)             \\
c(\lweight{k}{\Ed})    & \coloneqq \lweight{k}{c(\Ed)}         \\
c(\rweight{\Ed}{k})    & \coloneqq \rweight{c(\Ed)}{k}         \\
c(\Ed \cdot \Fd)       & \coloneqq c(\Ed) \cdot c(\Fd)         \\
c(\Ed^*)               & \coloneqq c(\Ed)^*                    \\
c(\Ed \AND \Fd)        & \coloneqq c(\Ed) \cdot c(\Fd)         \\
c(\Ed \shuffle \Fd)    & \coloneqq c(\Ed) \cdot c(\Fd)         \\
c(\Ed \infiltrate \Fd) & \coloneqq c(\Ed) \cdot c(\Fd)         \\
c(\Ed^c)               & \coloneqq c(\Ed)^c
\end{align}
$$
See also: