13.20.4 Tensor Contraction Result Type Check
Tensor contraction result type check ensures the correct algebraic structure and dimensionality after contracting tensor indices.
Tensor Contraction Result Type Check is the verification test confirming that the type pair of a computed contraction result matches the value predicted in advance by the type pair update rule, catching errors in which the actual number of surviving upper or lower indices does not agree with the count expected from the number of contractions declared to have been performed.
Definition
Given an original tensor of type and a sequence of contractions claimed to have been applied, the result type check requires:
where is the actual computed result. If the actual type of differs from this predicted value, the check fails.
What a Failure Reveals
Miscounted Contractions
A mismatch between the predicted and actual type most commonly indicates that the number of contractions actually carried out differs from the number declared, such as when a step in a sequence procedure was skipped or accidentally duplicated.
Incorrect Original Type
A mismatch can also arise from an incorrect initial assumption about the original tensor's type, such as treating a type-(2,1) tensor as though it were type-(1,2), which would propagate an error through every subsequent type prediction in the sequence.
Undetected Extra Free Index
If an index intended to be contracted was mistakenly left free due to a labeling error, the result type check flags the discrepancy directly, since the actual order of will exceed the predicted order by the number of indices left uncontracted.
Procedure
Step One: Predict Expected Type
Using the recorded original type and the number of contraction steps performed, compute the expected type pair via the type pair update rule.
Step Two: Inspect Actual Result
Count the number of upper and lower free indices actually present in the computed result .
Step Three: Compare
Compare the predicted and actual type pairs component by component; any discrepancy in either the upper or lower count triggers a failure of the check.
Diagram
Relation to Other Verification Checks
The result type check builds directly on the outcomes of the dimension check and the index balance check, both of which confirm structural well-formedness of the contraction before it is carried out, while the result type check confirms the outcome afterward, comparing what was predicted against what was actually produced, and together these checks form the core of the broader tensor contraction verification procedure.