sft_wick.expressions — Symbolic Expression Tree¶
All expression types are frozen dataclasses — immutable and hashable.
Uses exact rational arithmetic via fractions.Fraction.
Base class for all symbolic expressions. |
|
Exact rational number. |
|
A named symbol, possibly with indices. |
|
A two-point function C_{ij}(x, x') or R_{ij}(x, x'). |
|
Sum of expressions. |
|
Product of expressions. |
|
Summation over a component index: sum_{i=1}^{N} body. |
|
Integration over a spatial variable: integral d(var) body. |
|
delta_{ij} for component indices. |
|
delta(x - y) for spatial arguments. |
|
The imaginary unit \(\mathrm{i}\). |
|
Multiply each term by \((-\mathrm{i})^n\) where n is the number of response propagators R in that term. |
Custom symbolic expression tree for Wick contraction results.
All expression types are frozen dataclasses (immutable + hashable). Uses exact rational arithmetic via fractions.Fraction.
- class sft_wick.expressions.Rational(numerator, denominator=1)[source]¶
Bases:
ExprExact rational number.
- class sft_wick.expressions.Symbol(name, indices=(), spatial_args=())[source]¶
Bases:
ExprA named symbol, possibly with indices.
Examples
Symbol(‘F’, (‘i’, ‘j’, ‘k’)) -> F_{ijk} Symbol(‘K’, (‘i’, ‘j’), (‘y_0’, ‘y_1’)) -> K_{ij}(y_0, y_1)
- class sft_wick.expressions.Propagator(kind, index_left, index_right, spatial_left, spatial_right)[source]¶
Bases:
ExprA two-point function C_{ij}(x, x’) or R_{ij}(x, x’).
For scalar fields, index_left and index_right are None.
Convention for R: the physical field’s index/position is always on the left. R_{ij}(x, x’) means <phi_i(x) psi_j(x’)>_{S_0}.
- Parameters:
- class sft_wick.expressions.SumOverIndex(index_name, dimension, body)[source]¶
Bases:
ExprSummation over a component index: sum_{i=1}^{N} body.
- class sft_wick.expressions.IntegralOver(variable, body)[source]¶
Bases:
ExprIntegration over a spatial variable: integral d(var) body.
- class sft_wick.expressions.KroneckerDelta(index1, index2)[source]¶
Bases:
Exprdelta_{ij} for component indices.
- class sft_wick.expressions.DiracDelta(arg1, arg2)[source]¶
Bases:
Exprdelta(x - y) for spatial arguments.
- class sft_wick.expressions.ImaginaryUnit[source]¶
Bases:
ExprThe imaginary unit \(\mathrm{i}\).
Used to represent the phase factor \((-\mathrm{i})^n\) that arises from the MSR convention \(\langle\phi\,\psi\rangle \propto -\mathrm{i}\,R\).
- sft_wick.expressions.I = ImaginaryUnit()¶
Module-level constant for the imaginary unit.
- sft_wick.expressions.apply_response_phase(expr)[source]¶
Multiply each term by \((-\mathrm{i})^n\) where n is the number of response propagators R in that term.
This implements the MSR convention \(\langle\phi(a)\,\psi(b)\rangle = -\mathrm{i}\,R(a,b)\).
The phase is absorbed into the existing rational coefficient so that the factored form of the expression is preserved. For example, \((-\mathrm{i})^3 = \mathrm{i}\) applied to a term with prefactor \(-\tfrac{1}{6}\) yields \(-\tfrac{\mathrm{i}}{6}\).