sft_wick.wick — Wick Contraction Engine¶
Core Wick contraction engine.
Enumerates all valid pairings (contractions) of field operators and evaluates each pairing as a product of propagators.
- sft_wick.wick.generate_all_pairings(indices)[source]¶
Generate all complete pairings of the given indices.
For 2n items, yields (2n-1)!! = 1*3*5*…*(2n-1) pairings. Each pairing is a tuple of n pairs.
- sft_wick.wick.generate_valid_pairings(phi_indices, psi_indices, operators=None, ito=False)[source]¶
Generate only non-vanishing pairings (no psi-psi contractions).
Exploits the MSR structure: each psi must pair with a phi (producing R), and remaining phi’s pair among themselves (producing C).
This avoids generating the many zero-valued psi-psi pairings.
When operators and ito are provided, also skips phi-psi pairs at the same spatial point (R(x,x)=0 under Itô) and phi-psi assignments whose R edges form a causal cycle.
- sft_wick.wick.evaluate_pairing(operators, pairing, ito=True)[source]¶
Evaluate a single complete pairing.
Returns
(Product of propagators, list of individual propagators)orNoneif any contraction vanishes.Vanishing conditions:
\(\psi\)–\(\psi\) contraction
Equal-point \(R(x,x)=0\) when ito is
TrueCausal R-loop: any directed cycle among R propagator spatial arguments (e.g. \(R(a,b)\,R(b,a)=0\)) when ito is
True
- sft_wick.wick.wick_contract(operators, ito=True)[source]¶
Apply Wick’s theorem to a product of field operators.
- Parameters:
operators (Sequence[FieldOperator]) – Sequence of field operators to contract.
ito (bool) – If
True, apply the Itô prescription \(\Theta(0)=0\): response propagators at equal spatial points vanish, i.e. \(R(x,x)=0\).
- Returns:
(expression, surviving_pairings)where expression is a Sum of Products of Propagators, and surviving_pairings lists the non-zero pairings.- Return type:
- sft_wick.wick.wick_contract_grouped(operators, ito=True)[source]¶
Apply Wick’s theorem, grouping results by spatial propagator signature.
Like
wick_contract()but instead of returning a flat Sum of Products, groups surviving pairings by their spatial propagator topology. Pairings in the same group share the same Feynman diagram but differ in component-index routing.- Returns:
(groups, all_pairings)where groups maps each spatial signature to a list of(propagator_list, pairing)tuples, and all_pairings is the flat list of surviving pairings.- Parameters:
operators (Sequence[FieldOperator])
ito (bool)
- Return type:
tuple[dict[tuple[tuple[str, str, str], …], list[tuple[list[Propagator], tuple[tuple[int, int], …]]]], list[tuple[tuple[int, int], …]]]
- class sft_wick.wick.SpatialTopology(r_edges, c_edges, multiplicity)[source]¶
Bases:
objectA spatial-level Wick pairing.
Represents a complete contraction at the spatial-point level, abstracting away component indices.
- Parameters:
- sft_wick.wick.wick_contract_spatial(operators, ito=True, vertex_points=None)[source]¶
Spatial-level Wick contraction.
Enumerates spatial topologies (not individual operator-level pairings) and computes a multiplicity for each. This avoids the combinatorial explosion from component-index routing.
- Parameters:
operators (Sequence[FieldOperator]) – Sequence of field operators.
ito (bool) – Apply the Itô prescription.
vertex_points (frozenset[str] | None) – Frozenset of spatial args that belong to vertices (not observables). Needed for multiplicity computation.
- Returns:
Dict mapping each
SpatialSignatureto(reference_propagators, multiplicity, representative_pairing).- Return type:
dict[tuple[tuple[str, str, str], …], tuple[list[Propagator], int, tuple[tuple[int, int], …]]]