%\input verb-ini
\usemodule[nath]
\setupcolors[state=start]
\setuptyping[palet=,style=\rm,icommand=\bf,ccommand=\rm]
\input verb-pseudo
\starttext
\startPSEUDO
for $i \gets 0$ to $n$ do
  if $i = 0$ then
    $S_i \gets \{s_0\}$
  else
    $S_i \gets \cup_{s \in S_{i - 1}}\delta(s, a_i)$
  % $S_i$ has not yet reached its final value.
  % It now corresponds to the set $T_i$ mentioned above.
  mark each $t$ in $S_i$ -\quotation{considered}-
  mark each $t$ in $S - S_i$ -\quotation{unconsidered}-
  $`queue \gets S_i$
  while $`queue \not= \emptyset$ do
    find and delete $t$, the first element of $`queue$
    foreach $u \in \delta(t, \epsilon)$ do
      if $u$ is -\quotation{unconsidered}- then
        mark $u$ -\quotation{considered}-
        $`queue \gets `queue \cup \{u\}$
        $S_i \gets S_i \cup \{u\}$
\stopPSEUDO

\definestartstop[PSE][before=\startlines\setups{myPSE},after=\stoplines]

\startsetups[myPSE]
  \obeyspaces
  \def\for{{\bf for}}
  \def\to{{\bf to}}
  \def\do{{\bf do}}
  \def\If{{\bf if}}
  \def\then{{\bf then}}
  \def\Else{{\bf else}}
  \def\while{{\bf while}}
\stopsetups

\startPSE
\for\ $i \gets 0$ \to\ $n$ \do
  \If $i = 0$ then
    $S_i \gets \{s_0\}$
  \Else
    $S_i \gets \cup_{s \in S_{i - 1}}\delta(s, a_i)$
\stopPSE

\stoptext
