In computer science, a Wirth–Weber relationship between a pair of symbols
(Vt\cupVn)
The goal is to identify when the viable prefixes have the pivot and must be reduced. A
\gtrdot
\lessdot
eq |
G=\langleVn,Vt,S,P\rangle
\begin{align} X
eq |
Y&\iff\begin{cases}A\to\alphaXY\beta\inP\ A\inVn\ \alpha,\beta\in(Vn\cup
* | |
V | |
t) |
\ X,Y\in(Vn\cupVt)\end{cases}\\ X\lessdotY&\iff\begin{cases}A\to\alphaXB\beta\inP\ B ⇒ +Y\gamma\ A,B\inVn\ \alpha,\beta,\gamma\in(Vn\cup
* | |
V | |
t) |
\ X,Y\in(Vn\cupVt)\end{cases}\\ X\gtrdotY&\iff\begin{cases}A\to\alphaBY\beta\inP\ B ⇒ +\gammaX\ Y ⇒ *a\delta\ A,B\inVn\ \alpha,\beta,\gamma,\delta\in(Vn\cup
* | |
V | |
t) |
\ X,Y\in(Vn\cupVt)\ a\inVt\end{cases}\end{align}
We will define three sets for a symbol:
\begin{align} Head+(X)&=\{Y\midX ⇒ +Y\alpha\}\\ Tail+(X)&=\{Y\midX ⇒ +\alphaY\}\\ Head*(X)&=(Head+(X)\cup\{X\})\capVt \end{align}
The pseudocode for computing relations is:
A\to\alpha\inP
X
eq |
Y
X\lessdotHead+(Y)
Tail+(X)\gtrdotHead*(Y)
\$\lessdotHead+(S)
Tail+(S)\gtrdot\$
S\toaSSb|c
S\toaSSb
a
eq |
S
a\lessdotHead+(S)
a\lessdota
a\lessdotc
S
eq |
S
S\lessdotHead+(S)
S\lessdota
S\lessdotc
Tail+(S)\gtrdotHead*(S)
b\gtrdota
b\gtrdotc
c\gtrdota
c\gtrdotc
S
eq |
b
Tail+(S)\gtrdotHead*(b)
b\gtrdotb
c\gtrdotb
S\toc
\begin{array}{c|ccccc} &S&a&b&c&\$ \\ \hlineS&
eq |
&\lessdot&
eq |
&\lessdot&\ a&
eq |
&\lessdot&&\lessdot&\ b&&\gtrdot&\gtrdot&\gtrdot&\gtrdot \ c&&\gtrdot&\gtrdot&\gtrdot&\gtrdot \ \$&&\lessdot&&\lessdot&\end{array}
S\toa|aT|[S]
T\tob|bT