Skip to content

Commit 026d68f

Browse files
committed
add docs about anyonic contractions
1 parent e19b72a commit 026d68f

1 file changed

Lines changed: 58 additions & 1 deletion

File tree

‎docs/src/man/contractions.md‎

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,64 @@ exp(t) ≈ exp_via_mul(t, 10)
252252

253253
## Anyonic tensor contractions
254254

255-
TODO
255+
When `BraidingStyle(I) == Anyonic()`, the situation is more restrictive still.
256+
The relevant group describing the exchange of two lines is no longer the permutation group but the full braid group, so even a double crossing is non-trivial and there is no preferred way to reorder lines in a diagram.
257+
As a consequence, the implicit reordering that `@tensor` performs is no longer well-defined, and attempting an anyonic contraction with `@tensor` raises a `SectorMismatch` error.
258+
259+
```@example anyoncontraction
260+
using TensorKit # hide
261+
V = Vect[FibonacciAnyon](:I => 1, :τ => 1)
262+
A = randn(ComplexF64, V ← V ⊗ V)
263+
B = randn(ComplexF64, V ⊗ V ← V)
264+
try
265+
@tensor C[i; j] := A[i; k l] * B[k l; j]
266+
catch err
267+
err
268+
end
269+
```
270+
271+
The way out is to write the contraction as a literal *planar* diagram, in which every required crossing is made explicit through a braiding tensor.
272+
This is what the `@planar` macro provides.
273+
274+
### The `@planar` macro
275+
276+
The surface syntax of `@planar` is identical to that of `@tensor`, but with a number of additional restrictions.
277+
278+
A diagram is *planar* in this context when it can be drawn on a sheet of paper without any of its lines crossing, and additionally with all open legs ending on the exterior of the diagram.
279+
The second condition rules out arrangements in which an open leg is enclosed by contracted ones, even if the resulting diagram itself contains no crossings.
280+
281+
For the macro to recognise this layout unambiguously, the codomain–domain separator `;` must be present in every index list.
282+
It fixes which legs sit on the top (codomain) and which on the bottom (domain) of each tensor box, and changing the partition can change whether a given index pattern is planar.
283+
284+
Planarity is moreover enforced for each binary contraction, not only for the overall expression.
285+
The pairwise contraction order can therefore matter: an expression whose final layout is planar may still be rejected when an intermediate contraction produces a non-planar subdiagram.
286+
Manually controlling the order, for instance via parentheses, NCON-style numbering, or the `order=...` keyword, is still supported, but must be done with care.
287+
288+
Finally, the name `τ` is reserved for the braiding tensor: every literal crossing must be written out as a `τ[a b; c d]` factor, with its adjoint `τ'[a b; c d]` representing the inverse (under-)crossing.
289+
The `BraidingTensor` itself does not need to be constructed by the user; the macro figures out the appropriate spaces from the surrounding contraction.
290+
Any layout the macro cannot identify as planar is rejected at parse time with `ArgumentError("not a planar diagram expression: ...")`.
291+
292+
To make this concrete, consider the contraction `A * B` for two anyonic tensors, written in a manifestly planar fashion:
293+
294+
```@example anyoncontraction
295+
@planar C1[i; j] := A[i; k l] * B[k l; j]
296+
```
297+
298+
Inserting an explicit braiding tensor on the contracted legs gives a genuinely different result, reflecting the non-trivial R-symbols of the anyon braiding:
299+
300+
```@example anyoncontraction
301+
@planar C2[i; j] := A[i; k l] * τ[k l; m n] * B[m n; j]
302+
C1 ≈ C2
303+
```
304+
305+
Both expressions correspond to valid, but distinct, tensor network diagrams, and the choice between them must be made explicit by the user.
306+
307+
### The `@plansor` macro
308+
309+
For code that should work uniformly across braiding styles, TensorKit provides the `@plansor` macro.
310+
It inspects the `BraidingStyle` of the first non-braiding tensor in the expression and dispatches to `@tensor` for `Bosonic` sectors, and to `@planar` otherwise.
311+
Any explicit `τ` factors that appear in the expression are silently removed in the bosonic case, where braidings are trivial, and faithfully evaluated otherwise.
312+
This makes `@plansor` the natural choice for generic library code that wishes to remain correct regardless of the underlying symmetry.
256313

257314

258315
[^Mortier]: Mortier, Q., Devos, L., Burgelman, L., et al. (2025). Fermionic Tensor Network Methods. SciPost Physics 18, no. 1. [10.21468/SciPostPhys.18.1.012](https://doi.org/10.21468/SciPostPhys.18.1.012).

0 commit comments

Comments
 (0)