# Automatic transformation of XML namespaces/Implementation/Precedences

Theorem Minimal strict partial order containing a given irreflexive relation is equal to transitive closure of this relation if such strict partial order exists. It exists iff the given relation is acyclic.

Proof That it exists if the given relation is acyclic, is obvious. Accordingly Wikipedia, transitive closure of a directed acyclic graph is a strict partial order. Evidently there is no strict partial order containing the given relation which is less than it. So it the minimal.

Let us denote ${\displaystyle C}$ the strict partial order for subclass relation (of precedences) (can be calculated by the above theorem).

Let us denote ${\displaystyle h}$ the directed acyclic (remove the loops if any) graph of specified "higher than" precedences.

Let us denote ${\displaystyle H}$ the strict partial order of precedences (to be calculated).

Theorem ${\displaystyle H}$ can be calculated by the following algorithm: [FIXME: When does ${\displaystyle H}$ exist?]

Let ${\displaystyle E}$ be the transitive closure of ${\displaystyle h}$.

Let ${\displaystyle F}$ = ${\displaystyle E}$.

Start loop.

Let ${\displaystyle G=E\cup (C^{-1}\circ E\circ C)}$. If ${\displaystyle G=E}$ then it is the answer. [TODO: do one rather than two multiplications at a time. FIXME: Should it be instead: ${\displaystyle G=E\cup (E\cup C^{-1}\circ E)\circ C}$?]

Let ${\displaystyle F=G\cup (E\circ G)}$. If ${\displaystyle F=G}$ then it is the answer.

End loop.

Proof ??