Class Unifier

java.lang.Object
ca.mcscert.jpipe.operators.Unifier

public final class Unifier extends Object
Phase 4 post-processor for composition operators.

After CompositionOperator.apply(String, List, Map) returns its command list, this class inspects the element-creation commands, groups equivalent ones according to a named EquivalenceRelation looked up in a UnificationEquivalenceRegistry, and rewrites the command list so that each equivalence class is represented by a single synthesized element whose id is "unified_N" (N = 0-based counter per merged group). All original member ids are aliased to the new id via RegisterAlias commands, and AddSupport commands referencing removed ids are rewritten accordingly. Each new id is also flagged via MarkUnified, since it names a group by a counter and so appears in no source file; exporters that address a human audience name the element by its originals instead.

A group may legitimately mix element kinds — one source argued a claim while another still asserts it — so the merged element is built from the group's dominant member rather than from whichever member happens to come first: a sub-conclusion subsumes an evidence, and among members of the same kind the first one wins (it also provides the merged element's label and source location). A group whose kinds are incomparable cannot be merged and raises an IncompatibleUnificationException. This makes composition operators commutative: the result no longer depends on the order the source models were listed in.

Note that for an equivalence relation that does not compare labels, the merged element's label is still the dominant member's, hence still order-dependent among members of the same kind. The only registered relation, sameLabel, cannot exhibit that.

Controlled by two optional config parameters:

  • unifyBy — name of the equivalence relation to use (default: "sameLabel")
  • unifyExclude — comma-separated list of result-model element ids that must NOT participate in unification (default: empty)

If no merged groups are found the original command list is returned unchanged.