% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
\newcommand{\LyndonWordXmpTitle}{LyndonWord}
\newcommand{\LyndonWordXmpNumber}{9.53}
%
% =====================================================================
\begin{page}{LyndonWordXmpPage}{9.53 LyndonWord}
% =====================================================================
\beginscroll

%
%
%
%
%


Initialisations
\xtc{
}{
\spadpaste{a:Symbol :='a \bound{a}}
}
\xtc{
}{
\spadpaste{b:Symbol :='b \bound{b}}
}
\xtc{
}{
\spadpaste{c:Symbol :='c \bound{c}}
}
\xtc{
}{
\spadpaste{lword:= LyndonWord(Symbol) \bound{lword}}
}
\xtc{
}{
\spadpaste{magma := FreeMagma(Symbol) \bound{magma}}
}
\xtc{
}{
\spadpaste{word   := FreeMonoid(Symbol) \bound{word}}
}
\xtc{
All Lyndon words of with a, b, c to order 3
}{
\spadpaste{LyndonWordsList1([a,b,c],3)\$lword \free{lword} \free{a} \free{b} \free{c} }
}
\xtc{
All Lyndon words of with a, b, c to order 3 in flat list
}{
\spadpaste{LyndonWordsList([a,b,c],3)\$lword \free{a} \free{b} \free{c} \free{lword}}
}
\xtc{
All Lyndon words of with a, b to order 5
}{
\spadpaste{lw := LyndonWordsList([a,b],5)\$lword \free{a} \free{b} \free{lword} \bound{lw}}
}
\xtc{
}{
\spadpaste{w1 : word := lw.4 :: word \free{word} \free{lw} \bound{w1}}
}
\xtc{
}{
\spadpaste{w2 : word := lw.5 :: word \free{word} \free{lw} \bound{w2}}
}

Let's try factoring
\xtc{
}{
\spadpaste{factor(a::word)\$lword \free{a word lword}}
}
\xtc{
}{
\spadpaste{factor(w1*w2)\$lword \free{ w1 w2 lword}}
}
\xtc{
}{
\spadpaste{factor(w2*w2)\$lword \free{w2 lword}}
}
\xtc{
}{
\spadpaste{factor(w2*w1)\$lword \free{w1 w2 lword}}
}

Checks and coercions
\xtc{
}{
\spadpaste{lyndon?(w1)\$lword \free{w1 lword}}
}
\xtc{
}{
\spadpaste{lyndon?(w1*w2)\$lword \free{w1 w2 lword}}
}
\xtc{
}{
\spadpaste{lyndon?(w2*w1)\$lword \free{w1 w2 lword}}
}
\xtc{
}{
\spadpaste{lyndonIfCan(w1)\$lword \free{w1 lword}}
}
\xtc{
}{
\spadpaste{lyndonIfCan(w2*w1)\$lword \free{w1 w2 lword}}
}
\xtc{
}{
\spadpaste{lyndon(w1)\$lword \free{w1 lword}}
}
\xtc{
}{
\spadpaste{lyndon(w1*w2)\$lword \free{w1 w2 lword}}
}
\endscroll
\autobuttons
\end{page}
%
