Automatic transformation of XML namespaces/Implementation/Precedences

See also an alternative solution.

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 $$C$$ the strict partial order for subclass relation (of precedences) (can be calculated by the above theorem).

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

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

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

Let $$E$$ be the transitive closure of $$h$$.

Let $$F$$ = $$E$$.

Start loop.

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

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

End loop.

Proof ??