Inspired by [matrix rig comment](https://forum.azimuthproject.org/discussion/comment/19020/#Comment_19020).

E := employee

D := department

S := string

m := manager

a := secretary [assistant]

d := department name

f := first name

w := works in

$A^0 = \left( \begin{array}{c | c c c} s \rightarrow t & E & D & S \\\\ \hline E & \lbrace 1_E \rbrace & \emptyset & \emptyset \\\\ D & \emptyset & \lbrace 1_D \rbrace & \emptyset \\\\ S & \emptyset & \emptyset & \lbrace 1_S \rbrace \end{array} \right)$

$A^1 = \left( \begin{array}{c | c c c} s \rightarrow t & E & D & S \\\\ \hline E & \lbrace m \rbrace & \lbrace w \rbrace & \lbrace f \rbrace \\\\ D & \lbrace a \rbrace & \emptyset & \lbrace d\rbrace \\\\ S & \emptyset & \emptyset & \emptyset \end{array} \right)$

Introduce the constraints.
$WorksIn \circ Secretary =1_{Department}$
$WorksIn \circ Manager = WorksIn$

$A^2 = \left( \begin{array}{c | c c c} s \rightarrow t & E & D & S \\\\ \hline E & \lbrace m \circ m , \quad a \circ w \rbrace & \lbrace w \circ m = w \rbrace & \lbrace f \circ m, \quad d \circ w \rbrace \\\\ D & \lbrace m \circ a \rbrace & \lbrace w \circ a = 1_D \rbrace & \emptyset \\\\ S & \emptyset & \emptyset & \emptyset \end{array} \right)$

The equivalence group identifies duplicate paths.
Should the duplicate be dropped or retained?
I will presume retained and see where that takes us.

$A^3 = \left( \begin{array}{c | c c c} s \rightarrow t & E & D & S \\\\ \hline E & \lbrace m \circ m \circ m, \quad a \circ ( w \circ m ), \quad m \circ a \circ w \rbrace & \lbrace ( w \circ m ) \circ m = w, \quad ( w \circ a ) \circ w = w \rbrace & \lbrace f \circ m \circ m, \quad d \circ ( w \circ m ) \rbrace \\\\ D & \lbrace m \circ m \circ a, \quad a \circ ( w \circ a ) = a \rbrace & \lbrace ( w \circ m ) \circ a = 1_D \rbrace & \lbrace f \circ m \circ a, \quad d \circ ( w \circ a ) = d \rbrace \\\\ S & \emptyset & \emptyset & \emptyset \end{array} \right)$

From this it is obvious that all shorter paths will have already been generated and need not be carried forward.

$A^3 = \left( \begin{array}{c | c c c} s \rightarrow t & E & D & S \\\\ \hline E & \lbrace m \circ m \circ m, \quad m \circ a \circ w \rbrace & \emptyset & \lbrace f \circ m \circ m \rbrace \\\\ D & \lbrace m \circ m \circ a \rbrace & \emptyset & \lbrace f \circ m \circ a \rbrace \\\\ S & \emptyset & \emptyset & \emptyset \end{array} \right)$

One more time with pruning.

$A^4 = \left( \begin{array}{c | c c c} s \rightarrow t & E & D & S \\\\ \hline E & \lbrace m \circ m \circ m \circ m \rbrace & \emptyset & \lbrace f \circ m \circ m \circ m , \quad f \circ m \circ a \circ w \rbrace \\\\ D & \lbrace m \circ m \circ m \circ a \rbrace & \emptyset & \lbrace f \circ m \circ m \circ a \rbrace \\\\ S & \emptyset & \emptyset & \emptyset \end{array} \right)$