# This file is automatically generated by pyo3_stub_gen
# ruff: noqa: E501, F401

import builtins
import collections.abc
import decimal
import enum
import os
import pathlib
import symbolica
import symbolica.community.graph
import symbolica.community.hepkit.sector_decomposition
import symbolica.community.tensor
import symbolica.core
import types
import typing
from typing import overload
from symbolica import ComplexFloat, Float
from symbolica.community.graph import DiagramView, RenderSettings
from symbolica.community.tensor import DisplaySettings, Slot, TensorExpression, TensorName
from symbolica.core import Expression

@typing.final
class Amplitude:
    r"""
    A coherent sum of amputated, unintegrated Feynman-diagram operators.

    Diagrams must describe the same external states in the same model. Named
    couplings are expanded; model-declared real parameters and physical momenta
    are real under conjugation. Complex parameters remain complex. Quadratic
    denominators use the graph convention without widths or an i0 prescription.
    Already-sewn forward diagrams are rejected.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> generated = process.generate_diagrams()
    >>> diagram = generated.diagrams[0]
    >>> amplitude = hep.Amplitude(generated.diagrams)
    >>> operator = amplitude.expression()
    >>> adjoint = amplitude.conjugate().expression()
    >>> squared = amplitude.squared().sum_spins(average_initial=True).sum_colors()
    >>> scalar = squared.expression()
    >>> scalar = scalar.contract(collect_chains=False, collect_traces=False)
    """
    @property
    def diagrams(self) -> builtins.list[FeynmanDiagram]:
        r"""
        Source diagrams, retaining weights, routing, and graph provenance.

        Examples
        --------
        Using the setup in the ``Amplitude`` class example:

        >>> assert len(amplitude.diagrams) == len(generated.diagrams)
        """
    @property
    def legs(self) -> builtins.list[AmplitudeLeg]:
        r"""
        Physical external states in increasing external-label order.

        Examples
        --------
        Using the setup in the ``Amplitude`` class example:

        >>> external_states = [(leg.index, leg.particle.name) for leg in amplitude.legs]
        """
    @property
    def terms(self) -> builtins.list[TensorExpression]:
        r"""
        Individual weighted operators, with aligned external tensor ports.

        Examples
        --------
        Using the setup in the ``Amplitude`` class example:

        >>> operators = amplitude.terms
        >>> assert len(operators) == len(amplitude.diagrams)
        """
    @property
    def is_conjugated(self) -> builtins.bool:
        r"""
        Whether this amplitude is the physical adjoint of its source diagrams.

        Examples
        --------
        Using the setup in the ``Amplitude`` class example:

        >>> assert not amplitude.is_conjugated
        >>> assert amplitude.conjugate().is_conjugated
        """
    def __new__(cls, diagrams: typing.Sequence[FeynmanDiagram], *, dimension: typing.Optional[Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal]] = None, real: typing.Optional[typing.Sequence[Expression]] = None) -> Amplitude:
        r"""
        Sum weighted diagram operators with matching graph external indices.

        Examples
        --------
        Using the setup in the ``Amplitude`` class example:

        >>> amplitude = hep.Amplitude(generated.diagrams)

        Parameters
        ----------
        diagrams : list[FeynmanDiagram]
            Nonempty collection of complete, unsewn diagrams.
        dimension : int or Expression, optional
            Lorentz dimension, default four. Bispinor spaces retain dimension four.
        real : list[Expression] or None, optional
            Additional scalar expressions assumed real under conjugation.
        """
    @staticmethod
    def from_diagram(diagram: FeynmanDiagram, *, dimension: typing.Optional[Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal]] = None, real: typing.Optional[typing.Sequence[Expression]] = None) -> Amplitude:
        r"""
        Construct an amplitude from one complete diagram.

        Examples
        --------
        Using the setup in the ``Amplitude`` class example:

        >>> amplitude = hep.Amplitude.from_diagram(diagram)

        Parameters
        ----------
        diagram : FeynmanDiagram
            Complete, unsewn source diagram.
        dimension : int or Expression, optional
            Lorentz dimension, default four.
        real : list[Expression] or None, optional
            Additional scalar reality assumptions.
        """
    def expression(self) -> TensorExpression:
        r"""
        Return the complete operator as a Spenso tensor expression.

        Examples
        --------
        Using the setup in the ``Amplitude`` class example:

        >>> operator = amplitude.expression()
        """
    def conjugate(self) -> Amplitude:
        r"""
        Conjugate scalar coefficients, color tensors, and Dirac chains.

        Physical external-leg labels are preserved across different fermion pairings.

        Examples
        --------
        Using the setup in the ``Amplitude`` class example:

        >>> adjoint = amplitude.conjugate()
        """
    def squared(self) -> SquaredAmplitude:
        r"""
        Form the coherent square, including all interferences, with distinct ports.

        Spin/color sums and initial-state averages remain explicit operations.

        Examples
        --------
        Using the setup in the ``Amplitude`` class example:

        >>> squared = amplitude.squared().sum_spins().sum_colors()
        """
    def __repr__(self) -> builtins.str:
        r"""
        Describe the retained diagrams, external states, and conjugation state.

        Examples
        --------
        Using the setup in the ``Amplitude`` class example:

        >>> print(amplitude)
        """
    def render(self, *, config: typing.Optional[RenderSettings] = None, style: typing.Optional[DiagramStyle] = None, max_diagrams: typing.Optional[builtins.int] = 6, term_settings: typing.Optional[DisplaySettings] = None) -> DiagramView:
        r"""
        Prepare a browser-measured view of the amplitude's diagrams and weighted terms.

        Examples
        --------
        Using the setup in the ``Amplitude`` class example:

        >>> from symbolica.community.graph import RenderSettings, DrawOptions
        >>> drawing = amplitude.render(config=RenderSettings(drawing=DrawOptions(node_radius=5)), max_diagrams=2)
        >>> snapshot = drawing.measured(browser="chromium")
        >>> html = snapshot.to_html()

        Parameters
        ----------
        style : DiagramStyle or None, optional
            Particle, momentum, and physical index presentation.
        config : RenderSettings, optional
            Layout, labels, and stroke settings shared by all diagrams.
        max_diagrams : int or None, optional
            Maximum displayed contributions (default 6); None includes all, 0 none.
        term_settings : DisplaySettings, optional
            Tensor notation settings for each weighted contribution.
        """
    def _repr_mimebundle_(self, include: typing.Optional[typing.Sequence[builtins.str]] = None, exclude: typing.Optional[typing.Sequence[builtins.str]] = None) -> typing.Any:
        r"""
        Render compact diagram rows with weighted operators and expandable graphs.

        Examples
        --------
        Using the setup in the ``Amplitude`` class example:

        >>> from IPython.display import display
        >>> display(amplitude)

        Parameters
        ----------
        include : list[str] or None, optional
            MIME types requested by the frontend; None allows all available types.
        exclude : list[str] or None, optional
            MIME types omitted from the frontend response.
        """
    def _mime_(self) -> typing.Any:
        r"""
        Return Marimo MIME data with static output and an optional live widget.

        Examples
        --------
        Using the setup in the ``Amplitude`` class example:

        >>> view = amplitude.render()
        >>> view  # static output is immediate; an optional widget refines label sizes
        >>> snapshot = view.measured(browser="chromium")
        """

class AmplitudeError(FeynkitError):
    r"""
    Invalid amplitude, conjugation, or external-state sum.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> try:
    ...     hep.Amplitude([])
    ... except hep.AmplitudeError as error:
    ...     message = str(error)
    """
    ...

@typing.final
class AmplitudeLeg:
    r"""
    One physical external state of a symbolic amplitude.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> generated = process.generate_diagrams()
    >>> diagram = generated.diagrams[0]
    >>> amplitude = hep.Amplitude(generated.diagrams)
    >>> leg = amplitude.legs[0]
    >>> state = (leg.index, leg.particle.name, leg.state)
    >>> spin_sum = leg.particle.spin_sum(leg.momentum, leg.tensor_index, S("conjugate_index"))
    """
    @property
    def index(self) -> builtins.int:
        r"""
        Stable external-leg label shared by every diagram.

        Examples
        --------
        Using the setup in the ``AmplitudeLeg`` class example:

        >>> label = leg.index
        >>> assert label in [state.index for state in amplitude.legs]
        """
    @property
    def particle(self) -> Particle:
        r"""
        Model particle, including particle/antiparticle identity.

        Examples
        --------
        Using the setup in the ``AmplitudeLeg`` class example:

        >>> particle_name = leg.particle.name
        """
    @property
    def state(self) -> builtins.str:
        r"""
        Whether the state is incoming or outgoing.

        Examples
        --------
        Using the setup in the ``AmplitudeLeg`` class example:

        >>> incoming = [state for state in amplitude.legs if state.state == "incoming"]
        """
    @property
    def momentum(self) -> Expression:
        r"""
        Unindexed physical momentum P(index).

        Examples
        --------
        Using the setup in the ``AmplitudeLeg`` class example:

        >>> external_momentum = leg.momentum
        """
    @property
    def tensor_index(self) -> Expression:
        r"""
        Bare label shared by this leg's spin and color slots.

        Examples
        --------
        Using the setup in the ``AmplitudeLeg`` class example:

        >>> spin_sum = leg.particle.spin_sum(leg.momentum, leg.tensor_index, S("bra"))
        """
    @property
    def slots(self) -> builtins.list[Slot]:
        r"""
        Typed open spin/color slots attached to this physical state.

        Examples
        --------
        Using the setup in the ``AmplitudeLeg`` class example:

        >>> open_slots = leg.slots
        """
    def __repr__(self) -> builtins.str:
        r"""
        Describe the state and its physical leg identity.

        Examples
        --------
        Using the setup in the ``AmplitudeLeg`` class example:

        >>> print(amplitude.legs[0])
        """

@typing.final
class Boost:
    r"""
    A proper Lorentz boost specified by a three-velocity ``beta``.

    Use boosts to move four-momenta between the laboratory frame and a useful
    rest frame, with units chosen so that the speed of light is one.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> momentum = hep.FourMomentum(10.0, 0.0, 0.0, 0.0)
    >>> boost = hep.Boost(hep.ThreeMomentum(0.0, 0.0, 0.5))
    >>> boosted = boost.apply(momentum)
    >>> assert abs(boosted.mass_squared - momentum.mass_squared) < 1e-10

    Parameters
    ----------
    beta : ThreeMomentum
        Dimensionless boost velocity, whose magnitude must be smaller than one.
    """
    @property
    def beta(self) -> ThreeMomentum:
        r"""
        Return the dimensionless boost velocity.

        Examples
        --------
        Using the setup in the ``Boost`` class example:

        >>> assert boost.beta.pz == 0.5
        """
    def __new__(cls, beta: ThreeMomentum) -> Boost:
        r"""
        Construct a Lorentz boost from a dimensionless three-velocity.

        Examples
        --------
        Using the setup in the ``Boost`` class example:

        >>> boost = hep.Boost(hep.ThreeMomentum(0.0, 0.0, 0.5))

        Parameters
        ----------
        beta : ThreeMomentum
            Boost velocity in units where the speed of light is one.
        """
    def apply(self, momentum: FourMomentum) -> FourMomentum:
        r"""
        Apply this Lorentz boost to a four-momentum.

        Examples
        --------
        Using the setup in the ``Boost`` class example:

        >>> boosted = boost.apply(momentum)

        Parameters
        ----------
        momentum : FourMomentum
            Four-momentum to boost.
        """
    def apply_inverse(self, momentum: FourMomentum) -> FourMomentum:
        r"""
        Apply the inverse Lorentz boost to a four-momentum.

        Examples
        --------
        Using the setup in the ``Boost`` class example:

        >>> original = boost.apply_inverse(boost.apply(momentum))

        Parameters
        ----------
        momentum : FourMomentum
            Four-momentum to inverse-boost.
        """

@typing.final
class CancellationToken:
    r"""
    A thread-safe signal for cancelling a long diagram-generation job.

    Pass one token as ``cancellation_token`` and call ``cancel`` from a
    controlling thread when a large topology search should stop early.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> token = hep.CancellationToken()
    >>> token.is_cancelled
    False
    """
    @property
    def is_cancelled(self) -> builtins.bool:
        r"""
        Report whether cancellation has been requested.

        Examples
        --------
        Using the setup in the ``CancellationToken`` class example:

        >>> token = hep.CancellationToken()
        >>> token.cancel()
        >>> token.is_cancelled
        True
        """
    def __new__(cls) -> CancellationToken:
        r"""
        Create an independent token that can cancel a generation request.

        Examples
        --------
        Using the setup in the ``CancellationToken`` class example:

        >>> token = hep.CancellationToken()
        """
    def cancel(self) -> None:
        r"""
        Mark this token as cancelled for all generation requests using it.

        Examples
        --------
        Using the setup in the ``CancellationToken`` class example:

        >>> token.cancel()
        """

class CffError(FeynkitError):
    r"""
    Failure while constructing a Cross-Free Family representation.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> result = process.generate_diagrams(loops=1)
    >>> diagram = result.diagrams[0]
    >>> try:
    ...     diagram.integrate_energy(method="cff", contracted_edges=[999999])
    ... except hep.CffError as error:
    ...     message = str(error)
    """
    ...

@typing.final
class CffOrientation:
    r"""
    One acyclic energy-flow orientation in a CFF representation.

    ``families`` contains its cross-free denominator products.
    ``to_expression()`` sums their contributions, including the common
    energy prefactors and any supplied numerator. Edge directions are relative to the
    originating diagram's stored orientation.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> process = hep.Model.phi3().process(["phi"], ["phi", "phi"])
    >>> diagrams = process.generate_diagrams(
    ...     loops=1, max_vertices=3, maximum_bridges=0, progress=None
    ... )
    >>> diagram = diagrams.diagrams[0]
    >>> result = diagram.integrate_energy(method="cff")
    >>> orientation = result.orientations[0]
    >>> expression = orientation.to_expression()
    """
    @property
    def id(self) -> builtins.int:
        r"""
        Return this orientation's stable index within the CFF result.

        Examples
        --------
        Using the setup in the ``CffOrientation`` class example:

        >>> orientation_ids = [item.id for item in result.orientations]
        """
    @property
    def edge_signs(self) -> builtins.dict[builtins.int, typing.Optional[builtins.int]]:
        r"""
        Edge signs relative to the diagram's stored arrows.

        +1 agrees with the stored direction, -1 reverses it, and None denotes
        an undirected edge. These are orientation signs, not surface coefficients.

        Examples
        --------
        >>> signs = orientation.edge_signs
        >>> assert all(sign in (-1, 1, None) for sign in signs.values())
        """
    @property
    def edge_orientations(self) -> builtins.list[tuple[builtins.int, builtins.str]]:
        r"""
        Return each edge ID and its selected orientation.

        Examples
        --------
        Using the setup in the ``CffOrientation`` class example:

        >>> directions = dict(orientation.edge_orientations)
        """
    @property
    def weight(self) -> TensorExpression:
        r"""
        Exact weight of this orientation, already included in its families.

        Topology-only results weight each closure of a self-loop by one half,
        so an orientation directing ``k`` self-loops has weight ``2**-k``.
        Generalized results report one: their family coefficients carry the
        generated prefactors.

        Examples
        --------
        Using the setup in the ``CffOrientation`` class example:

        >>> weight = orientation.weight
        """
    @property
    def families(self) -> builtins.list[CrossFreeFamily]:
        r"""
        Cross-free families contributing to this orientation.

        Examples
        --------
        >>> families = orientation.families
        """
    def __repr__(self) -> builtins.str:
        r"""
        Summarize this orientation without displaying its parent representation.

        Examples
        --------
        >>> text = repr(orientation)
        """
    def to_expression(self, *, expand_surfaces: builtins.bool = True) -> TensorExpression:
        r"""
        Sum this orientation's families, including the common energy prefactor.

        Examples
        --------
        Using the setup in the class example:

        >>> expression = orientation.to_expression()

        Parameters
        ----------
        expand_surfaces : bool, optional
            Replace stored surface placeholders by affine energy definitions.
            Defaults to True. On-shell energies remain symbolic in either case.

        Returns
        -------
        TensorExpression
            This orientation's contribution to the CFF energy integral.
        """
    def render(self) -> DiagramView:
        r"""
        Prepare this orientation's explorer for display or explicit measurement.

        Examples
        --------
        >>> view = orientation.render()
        >>> snapshot = view.measured(browser="chromium")
        """
    def _repr_mimebundle_(self, include: typing.Optional[typing.Sequence[builtins.str]] = None, exclude: typing.Optional[typing.Sequence[builtins.str]] = None) -> typing.Any:
        r"""
        Inspect this orientation's family sum and fixed energy-flow graph.

        Examples
        --------
        >>> from IPython.display import display
        >>> display(orientation)

        Parameters
        ----------
        include : list[str] or None, optional
            MIME types requested by the frontend; None allows all available types.
        exclude : list[str] or None, optional
            MIME types omitted from the frontend response.
        """
    def _mime_(self) -> typing.Any:
        r"""
        Return Marimo MIME data with static output and an optional live widget.

        Examples
        --------
        >>> view = orientation.render()
        >>> view  # static output is immediate; an optional widget refines label sizes
        >>> snapshot = view.measured(browser="chromium")
        """
    def _display_(self) -> typing.Any:
        r"""
        Display this orientation in Marimo.

        Examples
        --------
        >>> view = orientation._display_()
        """

@typing.final
class CffReport:
    r"""
    Generation counts for a CFF representation.

    Compare candidate energy flows with the acyclic flows and denominator
    products retained in the result.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> process = hep.Model.phi3().process(["phi"], ["phi", "phi"])
    >>> diagrams = process.generate_diagrams(
    ...     loops=1, max_vertices=3, maximum_bridges=0, progress=None
    ... )
    >>> diagram = diagrams.diagrams[0]
    >>> result = diagram.integrate_energy(method="cff")
    >>> report = result.report
    >>> assert report.candidate_orientations >= report.acyclic_orientations
    """
    @property
    def candidate_orientations(self) -> typing.Optional[builtins.int]:
        r"""
        Candidate search count, or None for generalized numerator generation.

        Examples
        --------
        Using the setup in the ``CffReport`` class example:

        >>> assert report.candidate_orientations >= report.acyclic_orientations
        """
    @property
    def acyclic_orientations(self) -> typing.Optional[builtins.int]:
        r"""
        Acyclic search count, or None for generalized numerator generation.

        Examples
        --------
        Using the setup in the ``CffReport`` class example:

        >>> assert report.acyclic_orientations == len(result.orientations)
        """
    @property
    def unfolded_terms(self) -> builtins.int:
        r"""
        Return the total number of unfolded denominator terms.

        Examples
        --------
        Using the setup in the ``CffReport`` class example:

        >>> term_count = report.unfolded_terms
        """
    @property
    def interned_surfaces(self) -> builtins.int:
        r"""
        Return the number of unique denominator surfaces in the result.

        Examples
        --------
        Using the setup in the ``CffReport`` class example:

        >>> assert report.interned_surfaces == len(result.surfaces)
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return a concise constructor-style CFF generation summary.

        Examples
        --------
        Using the setup in the ``CffReport`` class example:

        >>> print(result.report)
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Render CFF generation statistics as a compact HTML table.

        Examples
        --------
        Using the setup in the ``CffReport`` class example:

        >>> from IPython.display import display
        >>> display(report)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write a concise CFF summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``CffReport`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(report)

        Parameters
        ----------
        pretty : object
            The IPython pretty-printer object.
        cycle : bool
            Whether this object is part of a recursive formatting cycle.
        """

@typing.final
class CffRepresentation:
    r"""
    A loop-energy integral in the cross-free family (CFF) representation.

    Create with ``diagram.integrate_energy(method="cff")``. The result groups
    acyclic energy-flow orientations into cross-free families of denominators.
    With :math:`E_e=\sqrt{\boldsymbol{q}_e^2+m_e^2}`, its scalar expression is

    $$
    I_{\mathrm{CFF}}=\left(\prod_e\frac{-1}{2E_e}\right)
    \sum_o\sum_{F\in\mathcal{F}_o}\prod_{s\in F}\frac{1}{s}.
    $$

    Repeated surfaces appear with their multiplicity. Family and orientation
    expressions include their energy prefactors, so they sum to the result.
    The measure is :math:`d\ell^0/(2\pi i)` per loop, with contours closed below,
    as in ``LtdRepresentation``. The scalar formula above applies without a
    numerator. Supply ``numerator=...`` to ``integrate_energy`` to generate
    bounded polynomial energy numerators, including quadratic and higher powers.
    Each generalized family retains its own coefficient, numerator evaluation
    map and denominator powers. Couplings, graph weights and the spatial measure
    remain separate.

    Both representations use ``gammalooprs::OSE(e)`` for :math:`E_e` and
    ``gammalooprs::Q(e, spenso::cind(0))`` for external energies; ``e`` is a
    physical diagram edge ID. ``on_shell_energies`` supplies the routed square
    roots. Impose external momentum conservation when comparing CFF and LTD.

    Displaying the object opens the orientation, family and surface explorer in
    Marimo or an HTML notebook. ``len(result)`` counts denominator products.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> process = hep.Model.phi3().process(["phi"], ["phi", "phi"])
    >>> diagrams = process.generate_diagrams(
    ...     loops=1, max_vertices=3, maximum_bridges=0, progress=None
    ... )
    >>> diagram = diagrams.diagrams[0]
    >>> result = diagram.integrate_energy(method="cff")
    >>> expression = result.to_expression()
    >>> assert result.report.acyclic_orientations == len(result.orientations)
    """
    @property
    def numerator(self) -> Expression:
        r"""
        Numerator supplied to energy integration; one for scalar generation.

        Examples
        --------
        >>> numerator = result.numerator
        """
    @property
    def energy_degree_bounds(self) -> builtins.dict[builtins.int, builtins.int]:
        r"""
        Inferred polynomial energy-degree bounds keyed by physical internal edge ID.

        Omitted edges have degree zero. Bounds are computed before applying routing.

        Examples
        --------
        >>> bounds = result.energy_degree_bounds
        """
    @property
    def report(self) -> CffReport:
        r"""
        Return generation statistics for this CFF result.

        Examples
        --------
        Using the setup in the ``CffRepresentation`` class example:

        >>> assert result.report.acyclic_orientations == len(result.orientations)
        """
    @property
    def orientations(self) -> builtins.list[CffOrientation]:
        r"""
        Return the acyclic energy-flow orientations in this result.

        Examples
        --------
        Using the setup in the ``CffRepresentation`` class example:

        >>> products = [item.to_expression() for item in result.orientations]
        """
    @property
    def surfaces(self) -> builtins.list[EnergySurface]:
        r"""
        Return all unique energy and H surfaces in this result.

        Examples
        --------
        Using the setup in the ``CffRepresentation`` class example:

        >>> energies = [surface.to_expression() for surface in result.surfaces]
        """
    @property
    def diagram(self) -> FeynmanDiagram:
        r"""
        Originating diagram or selected subgraph, retaining its routing and owner.

        Examples
        --------
        >>> routing = result.diagram.loop_momentum_basis
        """
    @property
    def on_shell_energies(self) -> builtins.dict[builtins.int, OnShellEnergy]:
        r"""
        Shared symbolic energies and routed square roots, keyed by physical edge ID.

        Examples
        --------
        >>> definitions = [(e.symbol, e.to_expression()) for e in result.on_shell_energies.values()]
        """
    def to_expression(self, *, expand_surfaces: builtins.bool = True) -> TensorExpression:
        r"""
        Return the scalar loop-energy integral as a Symbolica expression.

        Includes contour signs and on-shell energy factors for
        :math:`d\ell^0/(2\pi i)` per loop, with contours closed below. A supplied
        numerator is included; couplings, graph weights and the spatial measure are separate.
        ``expand_surfaces`` expands affine denominators while leaving
        ``gammalooprs::OSE(e)`` symbolic. Use ``on_shell_energies`` for their routed
        definitions or custom evaluation.

        Examples
        --------
        Using the setup in the class example:

        >>> expression = result.to_expression()
        >>> compact = result.to_expression(expand_surfaces=False)

        Parameters
        ----------
        expand_surfaces : bool, optional
            Replace surface placeholders by their affine energy definitions.
            Defaults to True. False keeps placeholders local to this representation.

        Returns
        -------
        TensorExpression
            Rank-zero tensor summing all orientation contributions and prefactors.
        """
    def raised_surface_groups(self, edge_representatives: typing.Optional[typing.Mapping[builtins.int, builtins.int]] = None) -> builtins.list[CffSurfaceGroup]:
        r"""
        Group equivalent energy surfaces after identifying raised propagator edges.
        ``edge_representatives`` maps repeated edges to their canonical edge.

        Examples
        --------
        Using the setup in the ``CffRepresentation`` class example:

        >>> groups = result.raised_surface_groups({3: 2})
        >>> [group.max_order for group in groups]

        Parameters
        ----------
        edge_representatives : dict[int, int], optional
            Repeated propagator edge IDs mapped to their canonical representative.
        """
    def pole_coefficients(self, group: CffSurfaceGroup) -> builtins.list[CffRepresentation]:
        r"""
        Return coefficients of each inverse surface power, indexed from order one.
        These are pole coefficients, before analytic residue derivatives.

        Examples
        --------
        Using the setup in the ``CffRepresentation`` class example:

        >>> coefficients = result.pole_coefficients(result.raised_surface_groups()[0])
        >>> [coefficient.to_expression() for coefficient in coefficients]

        Parameters
        ----------
        group : CffSurfaceGroup
            A raised-surface group belonging to this result.
        """
    def residue(self, group: CffSurfaceGroup, *, variable: Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal], root: Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal], surface: Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal], coefficient: Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal], replacements: typing.Optional[typing.Sequence[tuple[Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal], Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal]]]] = None) -> TensorExpression:
        r"""
        Evaluate all pole-order contributions to a residue in an explicit variable.
        ``surface`` must be the group's energy surface expressed in that variable;
        ``coefficient`` is the complete remaining coefficient, including any factors
        whose derivatives must act. The supplied root is assumed to be a simple zero.

        Examples
        --------
        Using the setup in ``CffRepresentation``, illustrate a simple pole locally
        parameterized by ``surface=t`` with constant remaining coefficient:

        >>> from symbolica import E, S
        >>> t = S("t")
        >>> group = result.raised_surface_groups()[0]
        >>> residue = result.residue(group, variable=t, root=E("0"), surface=t, coefficient=E("1"))

        Parameters
        ----------
        group : CffSurfaceGroup
            A raised-surface group belonging to this result.
        variable : Expression
            Independent integration variable.
        root : Expression
            Simple zero of the surface, independent of variable.
        surface : Expression
            Energy surface expressed in the integration variable.
        coefficient : Expression
            Complete remaining coefficient to differentiate.
        replacements : list[tuple[Expression, Expression]], optional
            Route all energy dependence to the integration variable before differentiating.
        """
    def __len__(self) -> builtins.int:
        r"""
        Return the number of unfolded denominator terms.

        Examples
        --------
        Using the setup in the ``CffRepresentation`` class example:

        >>> denominator_term_count = len(result)
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return a concise summary of the CFF expression and its surfaces.

        Examples
        --------
        Using the setup in the ``CffRepresentation`` class example:

        >>> print(result)
        """
    def render(self) -> DiagramView:
        r"""
        Prepare a browser-measured orientation, family and surface explorer.

        Examples
        --------
        >>> view = result.render()
        >>> view
        >>> snapshot = view.measured(browser="chromium")
        """
    def _repr_mimebundle_(self, include: typing.Optional[typing.Sequence[builtins.str]] = None, exclude: typing.Optional[typing.Sequence[builtins.str]] = None) -> typing.Any:
        r"""
        Explore orientations, factored families and surface regions on the native graph.

        Arrowhead clicks select another retained orientation; they never change the result.
        Shift-click surface factors to inspect several circlings together. The displayed
        expression includes any supplied numerator and excludes the spatial measure.

        Examples
        --------
        Using the setup in the ``CffRepresentation`` class example:

        >>> from IPython.display import display
        >>> display(result)

        Parameters
        ----------
        include : list[str] or None, optional
            MIME types requested by the frontend; None allows all available types.
        exclude : list[str] or None, optional
            MIME types omitted from the frontend response.
        """
    def _mime_(self) -> typing.Any:
        r"""
        Return Marimo MIME data with static output and an optional live widget.

        Examples
        --------
        Using the setup in the ``CffRepresentation`` class example:

        >>> view = result.render()
        >>> view  # static output is immediate; an optional widget refines label sizes
        >>> snapshot = view.measured(browser="chromium")
        """
    def _display_(self) -> typing.Any:
        r"""
        Return a Marimo widget when available, otherwise static HTML.

        Notebook MIME hooks use the same DiagramView display contract.

        Examples
        --------
        Using the setup in the ``CffRepresentation`` class example:

        >>> presentation = result._display_()
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write a summary with Symbolica's native expression formatting.

        Examples
        --------
        Using the setup in the ``CffRepresentation`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(result)

        Parameters
        ----------
        pretty : object
            The IPython pretty-printer object.
        cycle : bool
            Whether this object is part of a recursive formatting cycle.
        """

@typing.final
class CffSurfaceGroup:
    r"""
    Equivalent energy surfaces and their maximum simultaneous pole order.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> result = process.generate_diagrams(loops=1)
    >>> diagram = result.diagrams[0]
    >>> result = diagram.integrate_energy(method="cff")
    >>> group = result.raised_surface_groups()[0]
    >>> coefficients = result.pole_coefficients(group)
    """
    @property
    def max_order(self) -> builtins.int:
        r"""
        Highest inverse surface power occurring on one CFF branch.

        Examples
        --------
        Using the setup in the ``CffSurfaceGroup`` class example:

        >>> highest_pole = group.max_order
        >>> assert highest_pole >= 1
        """
    @property
    def surfaces(self) -> builtins.list[EnergySurface]:
        r"""
        Canonical energy surfaces identified by this group.

        Examples
        --------
        Using the setup in the ``CffSurfaceGroup`` class example:

        >>> equivalent_surfaces = group.surfaces
        """
    def __repr__(self) -> builtins.str:
        r"""
        Summarize the equivalent surfaces and maximum pole order.

        Examples
        --------
        >>> text = repr(group)
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Render equivalent surface definitions and their maximum pole order.

        Examples
        --------
        >>> html = group._repr_html_()
        """

@typing.final
class ClusteringResult:
    r"""
    The selected jets from one clustering operation.

    Jets are ordered by decreasing transverse momentum, and each jet's
    ``constituent_indices`` map back to positions in the supplied momentum list.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> particles = [hep.FourMomentum(50.0, 30.0, 40.0, 0.0),
    ...              hep.FourMomentum(25.0, -15.0, -20.0, 0.0)]
    >>> definition = hep.JetDefinition.anti_kt(radius=0.4, minimum_pt=20.0)
    >>> clustering = definition.cluster(particles)
    >>> jets = clustering.jets
    >>> assert len(jets) == 2
    """
    @property
    def jets(self) -> builtins.list[Jet]:
        r"""
        Return inclusive jets ordered by decreasing transverse momentum.

        Examples
        --------
        Using the setup in the ``ClusteringResult`` class example:

        >>> jets = clustering.jets
        >>> all(left.pt >= right.pt for left, right in zip(jets, jets[1:]))
        True
        """
    def __len__(self) -> builtins.int:
        r"""
        Return the number of clustered jets.

        Examples
        --------
        Using the setup in the ``ClusteringResult`` class example:

        >>> jet_multiplicity = len(clustering)
        """
    def __getitem__(self, index: builtins.int) -> Jet:
        r"""
        Return one jet by decreasing-transverse-momentum index.

        Examples
        --------
        Using the setup in the ``ClusteringResult`` class example:

        >>> leading_jet = clustering[0]

        Parameters
        ----------
        index : int
            Zero-based index; negative indices count from the end.
        """
    def __iter__(self) -> collections.abc.Iterator[Jet]:
        r"""
        Iterate over jets from highest to lowest transverse momentum.

        Examples
        --------
        Using the setup in the ``ClusteringResult`` class example:

        >>> transverse_momenta = [jet.pt for jet in clustering]
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return a concise summary of the clustered jet collection.

        Examples
        --------
        Using the setup in the ``ClusteringResult`` class example:

        >>> print(clustering)
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Render a bounded table of clustered jet kinematics.

        At most 20 jets are included so notebook display remains responsive for
        unusually large clustering results.

        Examples
        --------
        Using the setup in the ``ClusteringResult`` class example:

        >>> from IPython.display import display
        >>> display(clustering)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the concise collection summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``ClusteringResult`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(clustering)

        Parameters
        ----------
        pretty : object
            The IPython pretty-printer object.
        cycle : bool
            Whether this object is part of a recursive formatting cycle.
        """

@typing.final
class Coupling:
    r"""
    A coupling coefficient associated with interaction vertices.

    Couplings retain their symbolic expression, perturbative coupling orders,
    and evaluated complex value when the model has been numerically resolved.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.standard_model()
    >>> coupling = model.couplings[0]
    >>> orders = coupling.orders
    >>> formula = coupling.expression
    """
    @property
    def symbol(self) -> Expression:
        r"""
        Return the symbolic reference used by this model's expressions.
        This preserves the parameter or function identity without substituting
        its defining expression or numerical value.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> model = hep.Model.standard_model()
        >>> reference = model.couplings[0].symbol
        """
    @property
    def name(self) -> builtins.str:
        r"""
        Return the coupling name.

        Examples
        --------
        Using the setup in the ``Coupling`` class example:

        >>> coupling_by_name = {item.name: item.expression for item in model.couplings}
        """
    @property
    def expression(self) -> Expression:
        r"""
        Return the expression defining the coupling.

        Examples
        --------
        Using the setup in the ``Coupling`` class example:

        >>> formula = coupling.expression
        """
    @property
    def orders(self) -> builtins.dict[builtins.str, builtins.int]:
        r"""
        Return the coupling-order powers keyed by order name.

        Examples
        --------
        Using the setup in the ``Coupling`` class example:

        >>> qed_couplings = [c for c in model.couplings if c.orders.get("QED", 0) > 0]
        """
    @property
    def value(self) -> complex:
        r"""
        Return the evaluated coupling as a native Python complex number.

        Raises :class:`ModelError` when this coupling has not been evaluated.

        Examples
        --------
        Using the setup in the ``Coupling`` class example:

        >>> coupling_value = model.couplings[0].value
        >>> print("coupling:", coupling_value.real, coupling_value.imag)
        """
    def __repr__(self) -> builtins.str:
        r"""
        Summarize the defining data as well as the coupling name.

        Examples
        --------
        Using the setup in the ``Coupling`` class example:

        >>> print(next(c for c in model.couplings if c.orders.get("QED", 0) > 0))
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Display the model member's physical data and defining expressions.

        Examples
        --------
        Using the setup in the ``Coupling`` class example:

        >>> from IPython.display import display
        >>> display(coupling)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the complete text summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``Coupling`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(coupling)

        Parameters
        ----------
        pretty : object
            IPython pretty printer receiving the text.
        cycle : bool
            Whether the object occurs recursively in the current display.
        """

@typing.final
class CrossFreeFamily:
    r"""
    One cross-free family of denominator surfaces in a CFF orientation.

    ``factors`` records signed surfaces and their multiplicities. Its expression
    is the product of ``coefficient``, ``numerator`` and the inverse of every
    entry in ``factors``. Summing these expressions reproduces the parent
    orientation. Generalized numerator sampling can produce several weighted
    contributions with the same geometric family but different ``energy_map``s.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> process = hep.Model.phi3().process(["phi"], ["phi", "phi"])
    >>> diagrams = process.generate_diagrams(
    ...     loops=1, max_vertices=3, maximum_bridges=0, progress=None
    ... )
    >>> diagram = diagrams.diagrams[0]
    >>> result = diagram.integrate_energy(method="cff")
    >>> family = result.orientations[0].families[0]
    >>> expression = family.to_expression()
    """
    @property
    def id(self) -> builtins.int:
        r"""
        Family index within its orientation.

        Examples
        --------
        >>> index = family.id
        """
    @property
    def factors(self) -> builtins.list[SurfaceFactor]:
        r"""
        Signed denominator factors, grouping repeated surfaces into powers.

        Examples
        --------
        >>> denominators = [f.to_expression() for f in family.factors]
        """
    @property
    def coefficient(self) -> TensorExpression:
        r"""
        Signed coefficient and on-shell factors multiplying this family's numerator.

        Examples
        --------
        >>> coefficient = family.coefficient
        """
    @property
    def numerator(self) -> TensorExpression:
        r"""
        Evaluated numerator, including any generated numerator surface factors.

        Examples
        --------
        >>> numerator = family.numerator
        """
    @property
    def energy_map(self) -> builtins.dict[builtins.int, Expression]:
        r"""
        Edge-energy substitutions used to evaluate this contribution's numerator.

        Keys are physical edge IDs; values replace Q(edge, cind(0)). Empty for
        topology-only scalar families. These sampling maps need not be on-shell cuts.

        Examples
        --------
        >>> substitutions = family.energy_map
        """
    def __repr__(self) -> builtins.str:
        r"""
        Summarize this family's orientation, index and denominator factors.

        Examples
        --------
        >>> text = repr(family)
        """
    def to_expression(self, *, expand_surfaces: builtins.bool = True) -> TensorExpression:
        r"""
        Return this family's contribution, including the common energy prefactor.

        Examples
        --------
        Using the setup in the class example:

        >>> expression = family.to_expression()

        Parameters
        ----------
        expand_surfaces : bool, optional
            Replace stored surface placeholders by affine energy definitions.
            Defaults to True. On-shell energies remain symbolic in either case.

        Returns
        -------
        TensorExpression
            The complete family contribution, including its evaluated numerator and energy factors.
        """
    def render(self) -> DiagramView:
        r"""
        Prepare this family's explorer for display or explicit measurement.

        Examples
        --------
        >>> view = family.render()
        >>> snapshot = view.measured(browser="chromium")
        """
    def _repr_mimebundle_(self, include: typing.Optional[typing.Sequence[builtins.str]] = None, exclude: typing.Optional[typing.Sequence[builtins.str]] = None) -> typing.Any:
        r"""
        Inspect only this family's contribution and surface circlings.

        Examples
        --------
        >>> from IPython.display import display
        >>> display(family)

        Parameters
        ----------
        include : list[str] or None, optional
            MIME types requested by the frontend; None allows all available types.
        exclude : list[str] or None, optional
            MIME types omitted from the frontend response.
        """
    def _mime_(self) -> typing.Any:
        r"""
        Return Marimo MIME data with static output and an optional live widget.

        Examples
        --------
        >>> view = family.render()
        >>> view  # static output is immediate; an optional widget refines label sizes
        >>> snapshot = view.measured(browser="chromium")
        """
    def _display_(self) -> typing.Any:
        r"""
        Display this family in Marimo.

        Examples
        --------
        >>> view = family._display_()
        """

@typing.final
class CutPartition:
    r"""
    A separating topology partition, independent of physical final-state cuts.

    Both boundary selections retain half-edges on their respective sides.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> diagram = model.process(["phi", "phi"], ["phi", "phi"]).generate_diagrams(loops=1, progress=None).diagrams[0]

    >>> partitions = diagram.all_cuts([0], [1])
    >>> boundary_edges = partitions[0].boundary_left.edges
    """
    @property
    def source_side(self) -> Subgraph:
        r"""
        Region containing the requested source vertices.

        Examples
        --------
        >>> source = diagram.all_cuts([0], [1])[0].source_side
        """
    @property
    def target_side(self) -> Subgraph:
        r"""
        Region containing the requested target vertices.

        Examples
        --------
        >>> target = diagram.all_cuts([0], [1])[0].target_side
        """
    @property
    def boundary_left(self) -> Subgraph:
        r"""
        Crossing half-edges incident to the source side.

        Examples
        --------
        >>> source_ports = diagram.all_cuts([0], [1])[0].boundary_left.half_edges
        """
    @property
    def boundary_right(self) -> Subgraph:
        r"""
        Crossing half-edges incident to the target side.

        Examples
        --------
        >>> target_ports = diagram.all_cuts([0], [1])[0].boundary_right.half_edges
        """

@typing.final
class CutPropagator:
    r"""
    An oriented generalized cut distribution for a possibly raised propagator.
    ``orientation`` selects q0=+E or q0=-E; ``prescription`` is the sign of i0.
    The default normalization is -2 pi i. The positive ``on_shell_energy`` includes
    the mass. Raised cuts act on the entire coefficient, including the uncut factor.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> q0, energy = S("q0", "energy")
    >>> cut = hep.CutPropagator(q0, energy, power=2)
    >>> residue = cut.apply(q0**2, q0)
    """
    def __new__(cls, energy: Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal], on_shell_energy: Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal], *, power: builtins.int = 1, orientation: builtins.int = 1, prescription: builtins.int = 1, normalization: typing.Optional[Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal]] = None) -> CutPropagator:
        r"""
        Construct a reciprocal-propagator cut with explicit orientation and i0 sign.

        Examples
        --------
        Using the setup in the ``CutPropagator`` class example:

        >>> cut = hep.CutPropagator(q0, energy, power=3, orientation=-1)
        >>> residue = cut.apply(q0**3, q0)

        Parameters
        ----------
        energy : Expression
            Time component of the propagator momentum.
        on_shell_energy : Expression
            Positive square root of spatial momentum squared plus mass squared.
        power : int
            Positive propagator power.
        orientation : int
            Select the positive (+1) or negative (-1) energy root.
        prescription : int
            Sign of the imaginary infinitesimal, +1 or -1.
        normalization : Expression, optional
            Replacement prefactor, default -2 pi i.
        """
    def to_expression(self, *, covariant: builtins.bool = True) -> Expression:
        r"""
        Emit a covariant CutDelta or energy-space generalized Delta expression.
        Delta(n,x) acts as f^(n-1)(0)/(n-1)!; it is not the usual delta derivative.

        Examples
        --------
        Using the setup in the ``CutPropagator`` class example:

        >>> cut.to_expression(covariant=False)

        Parameters
        ----------
        covariant : bool
            Emit a mass-shell CutDelta; otherwise show the energy-space Delta.
        """
    def apply(self, coefficient: Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal], variable: Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal]) -> Expression:
        r"""
        Apply the complete derivative action and then set the energy on shell.
        Route the integrand to this independent energy variable before applying.

        Examples
        --------
        Using the setup in the ``CutPropagator`` class example:

        >>> cut.apply(q0**2, q0)

        Parameters
        ----------
        coefficient : Expression
            All remaining factors of the integrand.
        variable : Expression
            Independent energy symbol, equal to this cut's energy.
        """

@typing.final
class DiagramCut:
    r"""
    A generated physical final-state cut; each side retains its physics metadata.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> result = process.generate_cross_section(loops=1)
    >>> diagram = result.diagrams[0]
    >>> cut = diagram.cuts[0]
    >>> factors = cut.propagators()
    >>> assert len(factors) == len(cut.edges)
    """
    @property
    def left(self) -> DiagramCutSide:
        r"""
        Return the left amplitude and its generation metadata.

        Examples
        --------
        Using the setup in the ``DiagramCut`` class example:

        >>> left_numerator = cut.left.subgraph.numerator_expression()
        """
    @property
    def right(self) -> DiagramCutSide:
        r"""
        Return the right amplitude and its generation metadata.

        Examples
        --------
        Using the setup in the ``DiagramCut`` class example:

        >>> right_numerator = cut.right.subgraph.numerator_expression()
        """
    @property
    def subgraph(self) -> Subgraph:
        r"""
        Return the oriented crossing half-edges as a reusable selection.

        Examples
        --------
        Using the setup in the ``DiagramCut`` class example:

        >>> crossing_region = cut.subgraph
        """
    @property
    def edges(self) -> builtins.list[DiagramEdge]:
        r"""
        Return the crossing particle lines in their stored cut order.

        Examples
        --------
        Using the setup in the ``DiagramCut`` class example:

        >>> cut_edge_ids = [edge.id for edge in cut.edges]
        """
    @property
    def particles(self) -> builtins.list[Particle]:
        r"""
        Return physical final-state particles in the stored cut-edge order.

        The finalized left side contains the incoming initial-state endpoints.
        A source-oriented cut line carries its stored species into the final
        state; a target-oriented line carries its antiparticle. Momentum
        orientations use the same left-to-right positive-energy routing.

        Examples
        --------
        Using the setup in the ``DiagramCut`` class example:

        >>> cut_particles = cut.particles
        """
    @property
    def orientations(self) -> builtins.dict[builtins.int, builtins.int]:
        r"""
        Orient crossing lines from the left side to the right side.

        Examples
        --------
        Using the setup in the ``DiagramCut`` class example:

        >>> cut_directions = cut.orientations
        """
    @property
    def momentum_signatures(self) -> builtins.dict[builtins.int, MomentumSignature]:
        r"""
        Return stored edge momenta in the diagram's selected routing.
        Multiply by :attr:`orientations` for momenta directed from left to right.

        Examples
        --------
        Using the setup in the ``DiagramCut`` class example:

        >>> cut_momenta = cut.momentum_signatures
        """
    def propagators(self, *, edge_powers: typing.Optional[typing.Mapping[builtins.int, builtins.int]] = None, prescription: builtins.int = 1, normalization: typing.Optional[Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal]] = None) -> builtins.list[CutPropagator]:
        r"""
        Construct the oriented cut-propagator distributions, separately from
        the remaining numerator, uncut propagators, and global factors.

        Examples
        --------
        Using the setup in the ``DiagramCut`` class example:

        >>> factors = diagram.cuts[0].propagators(edge_powers={2: 2})
        >>> distributions = [factor.to_expression() for factor in factors]

        Parameters
        ----------
        edge_powers : mapping[int, int] or None, optional
            Positive propagator powers by diagram edge ID; omitted edges have power one.
        prescription : int, optional
            Sign of the imaginary prescription, either +1 or -1.
        normalization : Expression or None, optional
            Explicit replacement normalization; defaults to -2*pi*i.
        """

@typing.final
class DiagramCutSide:
    r"""
    One amplitude region of a physical cut, with generation metadata.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> result = process.generate_cross_section(loops=1)
    >>> diagram = result.diagrams[0]
    >>> cut = diagram.cuts[0]
    >>> side = cut.left
    >>> side_numerator = side.subgraph.numerator_expression()
    """
    @property
    def subgraph(self) -> Subgraph:
        r"""
        Return a physics view of this amplitude side, retaining its original diagram.

        Examples
        --------
        Using the setup in the ``DiagramCutSide`` class example:

        >>> side_numerator = side.subgraph.numerator_expression()
        """
    @property
    def coupling_orders(self) -> builtins.dict[builtins.str, builtins.int]:
        r"""
        Return coupling powers of this amplitude side.

        Examples
        --------
        Using the setup in the ``DiagramCutSide`` class example:

        >>> orders = side.coupling_orders
        """
    @property
    def loop_count(self) -> builtins.int:
        r"""
        Return the number of loops in this amplitude side.

        Examples
        --------
        Using the setup in the ``DiagramCutSide`` class example:

        >>> assert side.loop_count == 0  # tree amplitude on this side
        """

@typing.final
class DiagramEdge:
    r"""
    A particle propagator joining two vertices in a Feynman diagram.

    Edges retain their particle identity, endpoints, flow direction, and an
    symbolic numerator contribution when Feynman rules have been instantiated.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> result = process.generate_diagrams(loops=1)
    >>> diagram = result.diagrams[0]
    >>> edge = diagram.internal_edges[0]
    >>> endpoints = (edge.source, edge.target)
    >>> particle = edge.particle
    >>> factor = edge.numerator_expression()
    """
    @property
    def id(self) -> builtins.int:
        r"""
        Return this edge's integer ID within the diagram.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> numerators = {line.id: line.numerator_expression() for line in diagram.internal_edges}
        """
    @property
    def source(self) -> typing.Optional[builtins.int]:
        r"""
        Return the source interaction ID, or None at a dangling sink.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> edge = diagram.internal_edges[0]
        >>> vertices = {vertex.id: vertex for vertex in diagram.vertices}
        >>> source_vertex = vertices[edge.source]
        """
    @property
    def target(self) -> typing.Optional[builtins.int]:
        r"""
        Return the target interaction ID, or None at a dangling source.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> edge = diagram.internal_edges[0]
        >>> vertices = {vertex.id: vertex for vertex in diagram.vertices}
        >>> target_vertex = vertices[edge.target]
        """
    @property
    def particle(self) -> Particle:
        r"""
        The model particle, including symbolic mass, width parameter, spin and charge.

        >>> edge.particle.mass
        >>> edge.particle.width_parameter

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> assert edge.particle.name == edge.particle_name
        """
    @property
    def propagator(self) -> typing.Optional[Propagator]:
        r"""
        The model propagator template for an internal physical line, or None.

        Template expressions retain model placeholders. Use numerator_expression()
        and denominator_expression() for the instantiated diagram factors.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> propagator = edge.propagator
        """
    @property
    def external_index(self) -> builtins.int:
        r"""
        Return the external-leg index.

        Raises :class:`DiagramError` for an internal edge. Use
        :attr:`is_external` before accessing external-state metadata.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> external_labels = [(edge.id, edge.external_index) for edge in diagram.external_edges]
        """
    @property
    def external_state(self) -> builtins.str:
        r"""
        Return ``"incoming"`` or ``"outgoing"`` for an external edge.

        Raises :class:`DiagramError` for an internal edge.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> states = [(line.id, line.external_state) for line in diagram.external_edges]
        """
    @property
    def is_external(self) -> builtins.bool:
        r"""
        Report whether this edge represents an external particle state.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> external_edges = [edge for edge in diagram.edges if edge.is_external]
        """
    @property
    def external_connection(self) -> typing.Optional[builtins.int]:
        r"""
        Return the shared sewing identity of an external momentum carrier.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> connections = [(line.id, line.external_connection) for line in diagram.edges]
        """
    @property
    def external_name(self) -> typing.Optional[builtins.str]:
        r"""
        Return the external-state label retained during finalization.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> labels = [line.external_name for line in diagram.external_edges]
        """
    @property
    def is_dummy(self) -> builtins.bool:
        r"""
        Report whether this line is a dummy graph attachment.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> physical_lines = [line for line in diagram.edges if not line.is_dummy]
        """
    @property
    def is_dangling(self) -> builtins.bool:
        r"""
        Report whether this line has only one incident interaction vertex.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> dangling_lines = [line for line in diagram.edges if line.is_dangling]
        """
    @property
    def particle_name(self) -> builtins.str:
        r"""
        Return the particle name associated with this propagator edge.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> assert edge.particle_name == "phi"
        """
    @property
    def particle_pdg(self) -> builtins.int:
        r"""
        Return the PDG code of the particle carried by this edge.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> edge = diagram.edges[0]
        >>> edge.particle.pdg_code == edge.particle_pdg
        True
        """
    @property
    def directed(self) -> builtins.bool:
        r"""
        Report whether the edge carries an oriented particle-flow arrow.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> fermion_edges = [edge for edge in diagram.edges if edge.directed]
        """
    @property
    def numerator(self) -> builtins.str:
        r"""
        Return the symbolic numerator annotation as source text.

        Raises :class:`DiagramError` for an incomplete imported diagram that has
        no instantiated propagator numerator.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> source_text = edge.numerator
        >>> factor = edge.numerator_expression()
        """
    def denominator_expression(self, *, power: builtins.int = 1, dimension: typing.Optional[Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal]] = None, in_lmb: builtins.bool = False, lmb: typing.Optional[LoopMomentumBasis] = None) -> TensorExpression:
        r"""
        Return this edge's tagged q² - m² denominator as a scalar TensorExpression.

        Uses the shared diagram denominator builder, excluding widths, iε and custom
        UFO formulas. External, dummy and dangling lines raise DiagramError.
        Signed power and dimension follow FeynmanDiagram.denominator_expression().
        ``in_lmb=True`` uses the stored basis; an explicit ``lmb`` takes precedence.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> edge = diagram.internal_edges[0]
        >>> denominator = edge.denominator_expression(in_lmb=True)

        Parameters
        ----------
        power : int, optional
            Signed propagator power; defaults to one.
        dimension : Expression or int or None, optional
            Lorentz dimension; defaults to the shared symbolic dimension.
        in_lmb : bool, optional
            Route through the diagram's stored loop-momentum basis.
        lmb : LoopMomentumBasis or None, optional
            Explicit basis from this diagram, overriding ``in_lmb``.
        """
    def energy_expression(self) -> Expression:
        r"""
        Return this physical edge's symbolic energy component before momentum routing.

        Use this scalar expression to build polynomial numerators for CFF energy integration.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> energy = edge.energy_expression()
        >>> quadratic = energy ** 2
        """
    def momentum_expression(self, *, dimension: typing.Optional[Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal]] = None, in_lmb: builtins.bool = False, lmb: typing.Optional[LoopMomentumBasis] = None) -> TensorExpression:
        r"""
        Return the oriented edge momentum as a rank-one Minkowski TensorExpression.

        The default is Q(edge, mink(D)). With ``in_lmb=True``, return its linear
        combination of loop and external momenta. An explicit ``lmb`` from this
        diagram takes precedence. Dummy edges have no momentum and raise DiagramError.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> momentum = edge.momentum_expression(dimension=4, in_lmb=True)

        Parameters
        ----------
        dimension : Expression or int or None, optional
            Lorentz dimension; defaults to the shared symbolic dimension.
        in_lmb : bool, optional
            Route through the diagram's stored loop-momentum basis.
        lmb : LoopMomentumBasis or None, optional
            Explicit basis from this diagram, overriding ``in_lmb``.
        """
    def momentum_signature(self, *, lmb: typing.Optional[LoopMomentumBasis] = None) -> MomentumSignature:
        r"""
        Return integer loop and external momentum coefficients in the selected basis.

        Defaults to the diagram's stored basis. Dummy edges have no signature.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> edge.momentum_signature().loops
        >>> edge.momentum_signature().external

        Parameters
        ----------
        lmb : LoopMomentumBasis or None, optional
            Explicit basis from this diagram; defaults to its stored basis.
        """
    def numerator_expression(self) -> TensorExpression:
        r"""
        Return the numerator annotation as a Spenso TensorExpression.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> edge = diagram.edges[0]
        >>> propagator_factor = edge.numerator_expression()
        >>> weighted_propagator = diagram.overall_factor_expression() * propagator_factor
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return a concise description of the edge and its endpoints.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> edge = diagram.edges[0]
        >>> print(edge)  # shows particle identity, endpoints, and flow direction
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the edge summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``DiagramEdge`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(edge)

        Parameters
        ----------
        pretty : Any
            The IPython pretty-printer object.
        cycle : bool
            Whether this object is part of a recursive formatting cycle.
        """

class DiagramError(FeynkitError):
    r"""
    Invalid Feynman-diagram topology, annotation, or model reference.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> result = process.generate_diagrams(loops=1)
    >>> diagram = result.diagrams[0]
    >>> try:
    ...     diagram.with_loop_momentum_edges([])
    ... except hep.DiagramError as error:
    ...     message = str(error)
    """
    ...

@typing.final
class DiagramGroup:
    r"""
    Diagrams whose numerators are related by known scalar factors.

    Grouping lets amplitude calculations evaluate one master numerator and
    reconstruct related diagrams from each member's symbolic ratio.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> result = process.generate_diagrams(loops=1)
    >>> diagram = result.diagrams[0]
    >>> group = result.groups[0]
    >>> master_diagram = result.diagrams[group.master]
    >>> ratios = [member.ratio for member in group.members]
    """
    @property
    def master(self) -> builtins.int:
        r"""
        Return the retained-diagram index used as the numerator reference.

        Examples
        --------
        Using the setup in the ``DiagramGroup`` class example:

        >>> result.diagrams[result.groups[0].master]
        """
    @property
    def members(self) -> builtins.list[GroupMember]:
        r"""
        Return the deterministically ordered group members, including the master.

        Examples
        --------
        Using the setup in the ``DiagramGroup`` class example:

        >>> weighted_diagrams = [(result.diagrams[m.diagram], m.ratio) for m in group.members]
        """

@typing.final
class DiagramHalfEdge:
    r"""
    A particle-line endpoint using the diagram's native half-edge numbering.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> diagram = model.process(["phi", "phi"], ["phi", "phi"]).generate_diagrams(loops=1, progress=None).diagrams[0]

    >>> endpoints = [(half.id, half.vertex, half.edge.particle_name) for half in diagram.half_edges]
    """
    @property
    def id(self) -> builtins.int:
        r"""
        Native half-edge ID, also used in symbolic hedge annotations.

        Examples
        --------
        >>> ids = [half.id for half in diagram.half_edges]
        """
    @property
    def vertex(self) -> builtins.int:
        r"""
        Incident interaction vertex ID.

        Examples
        --------
        >>> incident = [half.vertex for half in diagram.half_edges]
        """
    @property
    def edge(self) -> DiagramEdge:
        r"""
        Physics edge containing this half-edge.

        Examples
        --------
        >>> particles = [half.edge.particle_name for half in diagram.half_edges]
        """
    @property
    def flow(self) -> builtins.str:
        r"""
        Underlying endpoint flow: ``source`` or ``sink``.

        Examples
        --------
        >>> incoming = [half.id for half in diagram.half_edges if half.flow == "sink"]
        """

@typing.final
class DiagramStyle:
    r"""
    Particle and momentum presentation for Feynman diagrams.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> style = hep.DiagramStyle(show_momentum=True)
    >>> style.show_momentum
    True
    """
    @property
    def show_particle(self) -> typing.Optional[builtins.bool]:
        r"""
        Show particle labels; None preserves the renderer default.

        Examples
        --------
        >>> hep.DiagramStyle(show_particle=True).show_particle
        True
        """
    @property
    def show_momentum(self) -> typing.Optional[builtins.bool]:
        r"""
        Show momentum labels; None follows the render request.

        Examples
        --------
        >>> hep.DiagramStyle(show_momentum=True).show_momentum
        True
        """
    @property
    def show_edge_index(self) -> typing.Optional[builtins.bool]:
        r"""
        Show the physical edge indices.

        Examples
        --------
        >>> hep.DiagramStyle(show_edge_index=True).show_edge_index
        True
        """
    @property
    def show_node_index(self) -> typing.Optional[builtins.bool]:
        r"""
        Show the physical vertex indices.

        Examples
        --------
        >>> hep.DiagramStyle(show_node_index=True).show_node_index
        True
        """
    @property
    def momentum_arrows(self) -> typing.Optional[builtins.bool]:
        r"""
        Draw momentum arrows beside particle lines.

        Examples
        --------
        >>> hep.DiagramStyle(momentum_arrows=True).momentum_arrows
        True
        """
    @property
    def split_initial_state(self) -> typing.Optional[builtins.bool]:
        r"""
        Separate the incoming states of a cross-section drawing.

        Examples
        --------
        >>> hep.DiagramStyle(split_initial_state=True).split_initial_state
        True
        """
    @property
    def debug(self) -> typing.Optional[builtins.bool]:
        r"""
        Show both vertex and edge indices unless individually overridden.

        Examples
        --------
        >>> hep.DiagramStyle(debug=True).debug
        True
        """
    def __new__(cls, *, show_particle: typing.Optional[builtins.bool] = None, show_momentum: typing.Optional[builtins.bool] = None, show_edge_index: typing.Optional[builtins.bool] = None, show_node_index: typing.Optional[builtins.bool] = None, momentum_arrows: typing.Optional[builtins.bool] = None, split_initial_state: typing.Optional[builtins.bool] = None, debug: typing.Optional[builtins.bool] = None) -> DiagramStyle:
        r"""
        Select physics presentation without changing graph layout or drawing settings.

        Examples
        --------
        >>> style = hep.DiagramStyle(show_particle=False, show_momentum=True)

        Parameters
        ----------
        show_particle : bool or None, optional
            Show particle labels; None preserves the renderer default.
        show_momentum : bool or None, optional
            Show momentum labels; None follows the render request.
        show_edge_index : bool or None, optional
            Show the physical edge indices.
        show_node_index : bool or None, optional
            Show the physical vertex indices.
        momentum_arrows : bool or None, optional
            Draw momentum arrows beside particle lines.
        split_initial_state : bool or None, optional
            Separate the incoming states of a cross-section drawing.
        debug : bool or None, optional
            Show both vertex and edge indices unless individually overridden.
        """
    def __repr__(self) -> builtins.str:
        r"""
        Summarize the explicitly selected physics options.

        Examples
        --------
        >>> repr(hep.DiagramStyle())
        'DiagramStyle()'
        """

@typing.final
class DiagramThresholdCandidate:
    r"""
    A topology threshold partition, independent of the requested physical final state.

    Examples
    --------
    Topology candidates depend on the generated graph and may be empty;
    physical final-state cuts are available separately through ``diagram.cuts``.

    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> result = process.generate_cross_section(loops=1)
    >>> diagram = result.diagrams[0]
    >>> cut = diagram.cuts[0]
    >>> thresholds = diagram.topology_threshold_candidates
    >>> for threshold in thresholds:
    ...     crossing_lines = threshold.edges
    ...     left_region = threshold.left
    """
    @property
    def left(self) -> Subgraph:
        r"""
        Return the left topology selection.

        Examples
        --------
        Using the setup in the ``DiagramThresholdCandidate`` class example:

        >>> left_regions = [candidate.left for candidate in thresholds]
        """
    @property
    def right(self) -> Subgraph:
        r"""
        Return the right topology selection.

        Examples
        --------
        Using the setup in the ``DiagramThresholdCandidate`` class example:

        >>> right_regions = [candidate.right for candidate in thresholds]
        """
    @property
    def subgraph(self) -> Subgraph:
        r"""
        Return the oriented crossing half-edge selection.

        Examples
        --------
        Using the setup in the ``DiagramThresholdCandidate`` class example:

        >>> crossing_regions = [candidate.subgraph for candidate in thresholds]
        """
    @property
    def edges(self) -> builtins.list[DiagramEdge]:
        r"""
        Return threshold-crossing lines in their stored order.

        Examples
        --------
        Using the setup in the ``DiagramThresholdCandidate`` class example:

        >>> crossing_edges = [candidate.edges for candidate in thresholds]
        """

@typing.final
class DiagramVertex:
    r"""
    An interaction point in a Feynman diagram.

    External states belong to edges; every public vertex references an interaction.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> result = process.generate_diagrams(loops=1)
    >>> diagram = result.diagrams[0]
    >>> vertex = diagram.vertices[0]
    >>> interaction = model.vertex_rule(vertex.interaction)
    >>> factor = vertex.numerator_expression()
    """
    @property
    def id(self) -> builtins.int:
        r"""
        Return this vertex's integer ID within the diagram.

        Examples
        --------
        Using the setup in the ``DiagramVertex`` class example:

        >>> vertices_by_id = {item.id: item for item in diagram.vertices}
        """
    @property
    def name(self) -> builtins.str:
        r"""
        Return the stable vertex label stored in the diagram.

        Examples
        --------
        Using the setup in the ``DiagramVertex`` class example:

        >>> vertex_names = [item.name for item in diagram.vertices]
        """
    @property
    def interaction(self) -> builtins.str:
        r"""
        Return the interaction name.

        Raises :class:`DiagramError` for an incomplete imported diagram.

        Examples
        --------
        Using the setup in the ``DiagramVertex`` class example:

        >>> vertex = diagram.vertices[0]
        >>> rule = model.vertex_rule(vertex.interaction)
        """
    @property
    def numerator(self) -> builtins.str:
        r"""
        Return the symbolic numerator annotation as source text.

        Raises :class:`DiagramError` when the diagram does not carry an
        instantiated Feynman-rule numerator for this vertex.

        Examples
        --------
        Using the setup in the ``DiagramVertex`` class example:

        >>> source_text = vertex.numerator
        >>> factor = vertex.numerator_expression()
        """
    def numerator_expression(self) -> TensorExpression:
        r"""
        Return the numerator annotation as a Spenso TensorExpression.

        Examples
        --------
        Using the setup in the ``DiagramVertex`` class example:

        >>> vertex = diagram.vertices[0]
        >>> vertex_factor = vertex.numerator_expression()
        >>> weighted_vertex_factor = diagram.overall_factor_expression() * vertex_factor
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return a concise, unambiguous description of the vertex.

        Examples
        --------
        Using the setup in the ``DiagramVertex`` class example:

        >>> vertex = diagram.vertices[0]
        >>> print(vertex)  # includes its external state or interaction rule
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the vertex summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``DiagramVertex`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(vertex)

        Parameters
        ----------
        pretty : Any
            The IPython pretty-printer object.
        cycle : bool
            Whether this object is part of a recursive formatting cycle.
        """

@typing.final
class EnergySurface:
    r"""
    A stored affine energy denominator in a CFF or LTD representation.

    Its definition has the form

    $$
    s=c_0+\sum_e c_e E_e+\sum_a d_a Q_a^0.
    $$

    ``energy_coefficients`` stores :math:`c_e`, ``external_shift`` stores
    :math:`d_a`, and ``constant`` stores :math:`c_0`. Both coefficient mappings
    use physical diagram edge IDs. Nonzero energy coefficients of one sign
    define an E-surface; mixed signs define an H-surface.

    ``symbol`` and ``index`` are local to the representation and surface category.
    The ``OSE`` symbols inside the definition are shared between representations.
    A ``SurfaceFactor`` records an occurrence's sign and multiplicity without
    changing this stored definition.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> process = hep.Model.phi3().process(["phi"], ["phi", "phi"])
    >>> diagrams = process.generate_diagrams(
    ...     loops=1, max_vertices=3, maximum_bridges=0, progress=None
    ... )
    >>> diagram = diagrams.diagrams[0]
    >>> rep = diagram.integrate_energy(method="cff")
    >>> surface = rep.surfaces[0]
    >>> expression = surface.to_expression()
    """
    @property
    def origin(self) -> builtins.str:
        r"""
        Whether this is a physical surface or an algebraic helper ("physical" or "helper").

        Helper factors in generalized CFF need not correspond to a graph region.

        Examples
        --------
        >>> provenance = surface.origin
        """
    @property
    def numerator_only(self) -> builtins.bool:
        r"""
        Whether this affine expression is used only as a numerator factor.

        Examples
        --------
        >>> numerator_only = surface.numerator_only
        """
    @property
    def index(self) -> builtins.int:
        r"""
        Index within its surface category and representation.

        Examples
        --------
        >>> value = surface.index
        """
    @property
    def kind(self) -> builtins.str:
        r"""
        ``"E"`` for consistent nonzero energy signs, ``"H"`` for mixed signs.

        Examples
        --------
        >>> value = surface.kind
        """
    @property
    def symbol(self) -> Expression:
        r"""
        Result-local Symbolica placeholder for this stored surface.

        Examples
        --------
        >>> value = surface.symbol
        """
    @property
    def energy_coefficients(self) -> builtins.dict[builtins.int, Expression]:
        r"""
        Exact signed OSE coefficients, keyed by physical edge ID.

        Examples
        --------
        >>> value = surface.energy_coefficients
        """
    @property
    def external_shift(self) -> builtins.dict[builtins.int, Expression]:
        r"""
        Exact coefficients of external ``gammalooprs::Q(edge, spenso::cind(0))``.

        Examples
        --------
        >>> value = surface.external_shift
        """
    @property
    def constant(self) -> Expression:
        r"""
        Energy-independent additive term.

        Examples
        --------
        >>> value = surface.constant
        """
    @property
    def vertices(self) -> builtins.list[builtins.int]:
        r"""
        CFF region vertices; LTD regions belong to individual surface occurrences.

        Examples
        --------
        >>> value = surface.vertices
        """
    def to_expression(self) -> TensorExpression:
        r"""
        Return the affine definition :math:`c_0+\sum_e c_e E_e+\sum_a d_a Q_a^0`.

        Examples
        --------
        >>> expression = surface.to_expression()

        Returns
        -------
        TensorExpression
            Signed energy combination in physical ``OSE`` and external ``Q`` symbols.
        """
    def __repr__(self) -> builtins.str:
        r"""
        Show the stored surface and its affine definition.

        Examples
        --------
        >>> print(surface)
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Render the stored surface's mathematical definition and E/H category.

        Examples
        --------
        >>> html = surface._repr_html_()
        """

@typing.final
class EvaluatedValues:
    r"""
    Numerical values returned by a custom model evaluator.

    Values are complex numbers represented as ``(real, imaginary)`` pairs and
    are applied atomically to the model after the callback completes.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> values = hep.EvaluatedValues(couplings={"GC_1": (0.3, 0.0)})

    Parameters
    ----------
    internal_parameters : dict[str, tuple[float, float]], optional
        Evaluated internal parameter values keyed by name.
    couplings : dict[str, tuple[float, float]], optional
        Evaluated coupling values keyed by name.
    """
    @property
    def internal_parameters(self) -> builtins.dict[builtins.str, tuple[builtins.float, builtins.float]]:
        r"""
        Return the evaluated internal parameters keyed by name.

        Examples
        --------
        Using the setup in the ``EvaluatedValues`` class example:

        >>> values = hep.EvaluatedValues(internal_parameters={"alpha": (0.1, 0.0)})
        >>> assert values.internal_parameters["alpha"] == (0.1, 0.0)
        """
    @property
    def couplings(self) -> builtins.dict[builtins.str, tuple[builtins.float, builtins.float]]:
        r"""
        Return the evaluated couplings keyed by name.

        Examples
        --------
        Using the setup in the ``EvaluatedValues`` class example:

        >>> values = hep.EvaluatedValues(couplings={"GC_1": (0.3, 0.0)})
        >>> assert values.couplings["GC_1"] == (0.3, 0.0)
        """
    def __new__(cls, *, internal_parameters: typing.Optional[typing.Mapping[builtins.str, tuple[builtins.float, builtins.float]]] = None, couplings: typing.Optional[typing.Mapping[builtins.str, tuple[builtins.float, builtins.float]]] = None) -> EvaluatedValues:
        r"""
        Create values returned by a custom model evaluator.

        Examples
        --------
        Using the setup in the ``EvaluatedValues`` class example:

        >>> values = hep.EvaluatedValues(couplings={"GC_1": (1.0, 0.0)})

        Parameters
        ----------
        internal_parameters : dict[str, tuple[float, float]] or None
            Evaluated internal parameters keyed by name.
        couplings : dict[str, tuple[float, float]] or None
            Evaluated couplings keyed by name.
        """

@typing.final
class EvaluationRequest:
    r"""
    The complete input supplied to a custom model evaluator.

    An evaluation request contains already-known numerical parameters and the
    internal parameters, couplings, functions, and form factors still needed.

    Examples
    --------
    This evaluator implements the built-in scalar model at its default ``lam=1``.
    A callback must return every requested internal parameter and coupling.

    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> requests = []
    >>> def evaluate(request):
    ...     requests.append(request)
    ...     return hep.EvaluatedValues(
    ...         couplings={"SCALAR_COUPLING": (0.0, -1.0)},
    ...     )
    >>> updated_model = model.recompute_with(evaluate)
    >>> request = requests[0]
    >>> formulas = {item.name: item.expression for item in request.couplings}
    """
    @property
    def known_parameters(self) -> builtins.dict[builtins.str, tuple[builtins.float, builtins.float]]:
        r"""
        Return the known parameter values keyed by name.

        Examples
        --------
        Using the setup in the ``EvaluationRequest`` class example:

        >>> def evaluate(request):
        ...     alpha_s = request.known_parameters["aS"]
        ...     return hep.EvaluatedValues()
        """
    @property
    def internal_parameters(self) -> builtins.list[ModelExpression]:
        r"""
        Return the derived parameter expressions that must be evaluated.

        Examples
        --------
        Using the setup in the ``EvaluationRequest`` class example:

        >>> formulas = {item.name: item.expression for item in request.internal_parameters}
        """
    @property
    def couplings(self) -> builtins.list[ModelExpression]:
        r"""
        Return the coupling expressions that must be evaluated.

        Examples
        --------
        Using the setup in the ``EvaluationRequest`` class example:

        >>> coupling_formulas = {item.name: item.expression for item in request.couplings}
        """
    @property
    def functions(self) -> builtins.list[ModelFunction]:
        r"""
        Return the function definitions available during evaluation.

        Examples
        --------
        Using the setup in the ``EvaluationRequest`` class example:

        >>> helper_functions = {function.name: function for function in request.functions}
        """
    @property
    def form_factors(self) -> builtins.list[FormFactor]:
        r"""
        Return the form-factor definitions available during evaluation.

        Examples
        --------
        Using the setup in the ``EvaluationRequest`` class example:

        >>> form_factors = {factor.name: factor for factor in request.form_factors}
        """

class FeynkitError(builtins.Exception):
    r"""
    Base exception for native HEP operations.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.standard_model()
    >>> try:
    ...     model.particle_by_pdg(999999)
    ... except hep.FeynkitError as error:
    ...     message = str(error)
    """
    ...

class FeynmanDiagram:
    r"""
    A generated or imported Feynman diagram, with particles, momenta and Feynman rules.

    Obtain diagrams from ``Model.process(...).generate_diagrams().diagrams``;
    use ``from_json`` or ``from_dot`` to restore a saved diagram with its model.
    There is no direct Python constructor. ``internal_edges`` are propagators,
    whereas ``external_edges`` carry the scattering or decay states.

    Use ``numerator_expression()`` for symbolic algebra, ``integral_family()``
    for loop-integral preparation, and ``render()`` for an SVG. Graph selections
    from ``subgraph`` and ``filter`` retain the original routing and identities.
    Routing changes return new diagrams. A diagram alone does not perform loop
    integration or supply a cross section.

    Examples
    --------
    Generate a one-loop scalar scattering diagram, inspect its propagators,
    and prepare its integral family. In a notebook, displaying ``diagram``
    renders the graph. The methods below reuse this setup.

    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> result = process.generate_diagrams(loops=1)
    >>> diagram = result.diagrams[0]
    >>> diagram.validate()
    >>> assert diagram.loop_count == 1
    >>> propagators = [(edge.id, edge.particle_name) for edge in diagram.internal_edges]
    >>> numerator = diagram.numerator_expression()
    >>> family = diagram.integral_family()
    >>> assert family.is_complete
    """
    @property
    def linnet_selection(self) -> symbolica.community.graph.Subgraph:
        r"""
        Return the canonical Linnet selection representing this physics region.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> region = diagram.subgraph(diagram.linnet_selection)
        >>> assert region.n_half_edges == len(diagram.half_edges)
        """
    @property
    def name(self) -> builtins.str:
        r"""
        Return the deterministic name assigned during diagram generation.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> by_name = {item.name: item for item in result.diagrams}
        """
    @property
    def id(self) -> builtins.str:
        r"""
        Return the stable content-derived hexadecimal diagram ID.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> selected = process.generate_diagrams(loops=1, select_diagrams=[diagram.id])
        >>> assert len(selected.diagrams) == 1
        """
    @property
    def symmetry_factor(self) -> builtins.int:
        r"""
        Return the positive integer denominator of the graph symmetry factor.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> graph_weight = 1 / diagram.symmetry_factor
        """
    @property
    def overall_factor(self) -> builtins.str:
        r"""
        Return the diagram-wide multiplicative factor as Symbolica source text.

        This string form is useful for serialization. For algebra or notebook
        display, prefer ``overall_factor_expression()`` so Symbolica's native
        rich formatting is preserved.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> source = diagram.overall_factor
        >>> factor = diagram.overall_factor_expression()
        >>> factor  # rich Symbolica output in a notebook
        """
    @property
    def numerator(self) -> builtins.str:
        r"""
        Return the diagram numerator annotation as source text.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> source_text = diagram.numerator
        >>> numerator = diagram.numerator_expression()
        """
    @property
    def cuts(self) -> builtins.list[DiagramCut]:
        r"""
        Return physical final-state cuts selected during generation.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> physical_cuts = [cut.edges for cut in diagram.cuts]
        >>> assert physical_cuts == []  # ordinary amplitude, not a sewn cross section
        """
    @property
    def topology_threshold_candidates(self) -> builtins.list[DiagramThresholdCandidate]:
        r"""
        Return topology threshold candidates separately from physical cuts.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> partitions = [candidate.edges for candidate in diagram.topology_threshold_candidates]
        """
    @property
    def is_selection_only(self) -> builtins.bool:
        r"""
        Whether only spectator cuts selected this cross-section diagram.

        A selection-only diagram has no physical cuts; it can be listed,
        displayed and exported, but not turned into an amplitude or integrand.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> assert not diagram.is_selection_only
        """
    @property
    def spectator_cuts(self) -> builtins.list[tuple[builtins.list[builtins.int], builtins.list[builtins.int], builtins.list[builtins.int]]]:
        r"""
        Return the spectator cuts that selected a selection-only diagram.

        Each entry is ``(crossed_edges, left_spectators, right_spectators)``:
        the crossed non-initial-state edge IDs and the external connections
        whose incoming or outgoing leg crosses the cut. Like ``cuts``, a view
        keeps only the records it fully contains: every crossed half-edge and
        both half-edges of each spectator's sewn initial-state edge.
        ``is_selection_only`` describes the whole diagram.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> assert diagram.spectator_cuts == []
        """
    @property
    def loop_momentum_basis(self) -> LoopMomentumBasis:
        r"""
        Return the loop-momentum routing selected during generation.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> basis = diagram.loop_momentum_basis
        >>> assert len(basis.loop_edges) == diagram.loop_count
        """
    @property
    def loop_count(self) -> builtins.int:
        r"""
        Return the number of independent loops in the diagram topology.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> basis = diagram.loop_momentum_bases(limit=1)[0]
        >>> len(basis.loop_edges) == diagram.loop_count
        True
        """
    @property
    def vertices(self) -> builtins.list[DiagramVertex]:
        r"""
        Return the diagram's interaction vertices with stable integer identifiers.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> interactions = [model.vertex_rule(vertex.interaction) for vertex in diagram.vertices]
        """
    @property
    def edges(self) -> builtins.list[DiagramEdge]:
        r"""
        Return every particle line, including dangling and sewn external carriers.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> particles_by_edge = {edge.id: edge.particle_name for edge in diagram.edges}
        """
    @property
    def half_edges(self) -> builtins.list[DiagramHalfEdge]:
        r"""
        Return diagram half-edges with native diagram IDs and physics edge objects.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> half_edge_ids = [half_edge.id for half_edge in diagram.half_edges]
        """
    @property
    def internal_edges(self) -> builtins.list[DiagramEdge]:
        r"""
        Return propagators excluding external momentum carriers and dummy edges.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> propagators = [(edge.id, edge.particle_name) for edge in diagram.internal_edges]
        >>> assert len(propagators) == 2
        """
    @property
    def external_edges(self) -> builtins.list[DiagramEdge]:
        r"""
        Return incoming or outgoing external-state momentum carriers.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> external_particles = [edge.particle_name for edge in diagram.external_edges]
        """
    @overload
    def integrate_energy(self, *, method: typing.Literal["cff"], max_orientations: typing.Optional[int] = None, fixed_orientations: typing.Optional[typing.Mapping[int, bool]] = None, contracted_edges: typing.Optional[typing.Sequence[int]] = None, initial_state_edges: typing.Optional[typing.Sequence[int]] = None, numerator: typing.Optional[symbolica.Expression] = None) -> CffRepresentation:
        r"""
        Integrate propagators and an optional CFF numerator over loop energies.

        The measure is :math:`d\ell^0/(2\pi i)` per loop, with contours closed below.
        Both representations include contour signs and on-shell factors, and share
        ``gammalooprs::OSE(e)`` for :math:`E_e=\sqrt{\boldsymbol{q}_e^2+m_e^2}`.
        CFF accepts a polynomial numerator; couplings, graph weights and the spatial measure are separate.

        CFF supports subgraph selections and the constraints below. LTD requires a
        complete ordinary diagram and uses its stored ordered loop-momentum basis.
        Display either result directly to explore its terms and surfaces in a notebook.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> cff = diagram.integrate_energy(method="cff")
        >>> ltd = diagram.integrate_energy(method="ltd")
        >>> expression = cff.to_expression()

        Parameters
        ----------
        method : {"cff", "ltd"}
            Required representation choice. Literal arguments retain the concrete
            return type in editors and type checkers.
        max_orientations : int or None, optional
            CFF-only limit on candidate orientations. None imposes no limit.
        fixed_orientations : mapping[int, bool] or None, optional
            CFF-only constraints by physical edge ID: False keeps the stored
            direction; True reverses it. None leaves orientations unconstrained.
        contracted_edges : sequence[int] or None, optional
            CFF-only physical edge IDs to contract before constructing surfaces.
            None contracts no edges.
        initial_state_edges : sequence[int] or None, optional
            CFF-only physical edge IDs whose on-shell energies are moved into
            external energy shifts. None performs no such replacements.
        numerator : Expression or None, optional
            CFF polynomial in ``gammalooprs::Q(e, spenso::cind(0))``, using physical
            internal edge IDs. Degree bounds are inferred before momentum routing.
            None selects scalar topology generation. Supplying a numerator uses the
            generalized backend and currently requires an unconstrained complete
            diagram. Express energy dependence explicitly; loop-basis energies and
            unevaluated energy-dependent functions are unsupported.

        Returns
        -------
        CffRepresentation or LtdRepresentation
            The selected scalar energy representation, with structured term and
            surface inspection, expression conversion and notebook display.

        Raises
        ------
        ValueError
            The method is unknown, or CFF-only options are supplied for LTD.
        """
    @overload
    def integrate_energy(self, *, method: typing.Literal["ltd"]) -> LtdRepresentation:
        r"""
        Integrate propagators and an optional CFF numerator over loop energies.

        The measure is :math:`d\ell^0/(2\pi i)` per loop, with contours closed below.
        Both representations include contour signs and on-shell factors, and share
        ``gammalooprs::OSE(e)`` for :math:`E_e=\sqrt{\boldsymbol{q}_e^2+m_e^2}`.
        CFF accepts a polynomial numerator; couplings, graph weights and the spatial measure are separate.

        CFF supports subgraph selections and the constraints below. LTD requires a
        complete ordinary diagram and uses its stored ordered loop-momentum basis.
        Display either result directly to explore its terms and surfaces in a notebook.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> cff = diagram.integrate_energy(method="cff")
        >>> ltd = diagram.integrate_energy(method="ltd")
        >>> expression = cff.to_expression()

        Parameters
        ----------
        method : {"cff", "ltd"}
            Required representation choice. Literal arguments retain the concrete
            return type in editors and type checkers.
        max_orientations : int or None, optional
            CFF-only limit on candidate orientations. None imposes no limit.
        fixed_orientations : mapping[int, bool] or None, optional
            CFF-only constraints by physical edge ID: False keeps the stored
            direction; True reverses it. None leaves orientations unconstrained.
        contracted_edges : sequence[int] or None, optional
            CFF-only physical edge IDs to contract before constructing surfaces.
            None contracts no edges.
        initial_state_edges : sequence[int] or None, optional
            CFF-only physical edge IDs whose on-shell energies are moved into
            external energy shifts. None performs no such replacements.
        numerator : Expression or None, optional
            CFF polynomial in ``gammalooprs::Q(e, spenso::cind(0))``, using physical
            internal edge IDs. Degree bounds are inferred before momentum routing.
            None selects scalar topology generation. Supplying a numerator uses the
            generalized backend and currently requires an unconstrained complete
            diagram. Express energy dependence explicitly; loop-basis energies and
            unevaluated energy-dependent functions are unsupported.

        Returns
        -------
        CffRepresentation or LtdRepresentation
            The selected scalar energy representation, with structured term and
            surface inspection, expression conversion and notebook display.

        Raises
        ------
        ValueError
            The method is unknown, or CFF-only options are supplied for LTD.
        """
    def to_graph(self) -> symbolica.community.graph.Graph:
        r"""
        Return the canonical installed Linnet graph with physics objects as payloads.

        Node, edge, and half-edge identities are mapped explicitly. Structural
        edits affect this analysis graph only; the next export starts a fresh
        graph, and selections from the modified topology cannot be used here.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> graph = diagram.to_graph()
        >>> gluons = graph.filter(edge=lambda edge: edge.data.particle_name == "g")
        """
    def subgraph(self, selection: Subgraph | None = None, *, nodes: typing.Optional[typing.Sequence[builtins.int]] = None, edges: typing.Optional[typing.Sequence[builtins.int]] = None, half_edges: typing.Optional[typing.Sequence[builtins.int]] = None) -> Subgraph:
        r"""
        Select graph elements using native diagram IDs or an existing physics region.
        Nested selections intersect this region and retain its immutable original diagram.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> region = diagram.subgraph(edges=[0, 1])
        >>> numerator = region.numerator_expression()

        Parameters
        ----------
        selection : Subgraph or None, optional
            Existing selection from the same original diagram; exclusive with element IDs.
            Generic Linnet selections additionally require the ``linnet-python`` Cargo feature.
        nodes : list[int] or None, optional
            Diagram vertex IDs to include, with all incident half-edges.
        edges : list[int] or None, optional
            Diagram edge IDs to include.
        half_edges : list[int] or None, optional
            Native diagram half-edge IDs to include.
        """
    def filter(self, *, node: typing.Callable[[DiagramVertex], bool] | None = None, edge: typing.Callable[[DiagramEdge], bool] | None = None, half_edge: typing.Callable[[DiagramHalfEdge], bool] | None = None) -> Subgraph:
        r"""
        Select by predicates on diagram vertices, edges, and half-edges.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> region = diagram.filter(edge=lambda edge: edge.particle_name == "g")

        Parameters
        ----------
        node : callable or None, optional
            Predicate on DiagramVertex objects.
        edge : callable or None, optional
            Predicate on DiagramEdge objects.
        half_edge : callable or None, optional
            Predicate on DiagramHalfEdge objects.
        """
    def boundary(self) -> Subgraph:
        r"""
        Return boundaries around the selected interaction region.

        The current region determines which interaction boundaries are returned.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> region = diagram.subgraph(nodes=[0])
        >>> boundary = region.boundary()
        """
    def connected_components(self) -> builtins.list[Subgraph]:
        r"""
        Return connected interaction regions as reusable selections.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> components = diagram.connected_components()
        """
    def is_connected(self) -> builtins.bool:
        r"""
        Test connectivity of the current diagram or selected region.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> connected = diagram.is_connected()
        """
    def bridges(self) -> Subgraph:
        r"""
        Return lines whose removal disconnects the selection.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> bridges = diagram.bridges()
        """
    def cycle_basis(self) -> tuple[builtins.list[Subgraph], Subgraph]:
        r"""
        Return structural cycles and the spanning forest used to construct them.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> cycles, forest = diagram.cycle_basis()
        """
    def all_spanning_forests(self) -> builtins.list[Subgraph]:
        r"""
        Enumerate spanning forests within the selected topology.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> forests = diagram.all_spanning_forests()
        """
    def all_bonds(self, *, min_size: typing.Optional[builtins.int] = None, max_size: typing.Optional[builtins.int] = None) -> builtins.list[Subgraph]:
        r"""
        Enumerate minimal cutsets, independently of physical final-state cuts.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> bonds = diagram.all_bonds(min_size=2, max_size=3)

        Parameters
        ----------
        min_size : int or None, optional
            Minimum number of crossing edges.
        max_size : int or None, optional
            Maximum number of crossing edges.
        """
    def all_cuts(self, source: typing.Sequence[builtins.int], target: typing.Sequence[builtins.int]) -> builtins.list[CutPartition]:
        r"""
        Enumerate separating partitions between disjoint interaction vertex groups.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> partitions = diagram.all_cuts([0], [1])

        Parameters
        ----------
        source : list[int]
            Diagram vertex IDs required on the first side.
        target : list[int]
            Diagram vertex IDs required on the opposite side.
        """
    def depth_first_traverse(self, root: builtins.int, *, include: typing.Optional[builtins.int] = None) -> TraversalTree:
        r"""
        Traverse a selected interaction region in depth-first order.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> tree = diagram.depth_first_traverse(0)

        Parameters
        ----------
        root : int
            Diagram vertex ID at which traversal starts.
        include : int or None, optional
            Native diagram half-edge ID to prioritize at the root.
        """
    def breadth_first_traverse(self, root: builtins.int, *, include: typing.Optional[builtins.int] = None) -> TraversalTree:
        r"""
        Traverse a selected interaction region in breadth-first order.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> tree = diagram.breadth_first_traverse(0)

        Parameters
        ----------
        root : int
            Diagram vertex ID at which traversal starts.
        include : int or None, optional
            Native diagram half-edge ID to prioritize at the root.
        """
    @staticmethod
    def from_json(model: Model, json: builtins.str) -> FeynmanDiagram:
        r"""
        Deserialize a Feynman diagram from its JSON representation.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> encoded = diagram.to_json()
        >>> restored = hep.FeynmanDiagram.from_json(model, encoded)
        >>> restored.validate()
        >>> restored  # render the recovered graph in a notebook

        Parameters
        ----------
        model : Model
            Model whose stable IDs and fingerprint are referenced by the diagram.
        json : str
            JSON text produced by :meth:`FeynmanDiagram.to_json` or another
            schema-compatible producer.
        """
    @staticmethod
    def from_dot(model: Model, dot: builtins.str) -> FeynmanDiagram:
        r"""
        Parse a Feynman diagram from Graphviz DOT text.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> dot = diagram.to_dot()
        >>> restored = hep.FeynmanDiagram.from_dot(model, dot)
        >>> restored.validate()
        >>> restored  # preserve topology through a Graphviz workflow

        Parameters
        ----------
        model : Model
            Model used to resolve particles and interactions or validate annotated IDs.
        dot : str
            Compact physics DOT or annotated HEP DOT. Compact cross-sections pair
            initial-state legs with is_cut and specify comma-separated final_state particles.
        """
    def apply_feynman_rules(self) -> FeynmanDiagram:
        r"""
        Instantiate the model's vertex and propagator Feynman rules.

        Returns a new diagram whose local numerator fragments are built in the
        existing half-edge frame. Momentum routing, graph weights, numerator
        prefactors and the external-state projector are retained.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> model = hep.Model.phi4()
        >>> diagram = hep.FeynmanDiagram.from_dot(model, '''digraph sunrise {
        ...     ext [style=invis];
        ...     ext -> a [particle="phi"];
        ...     a -> b [particle="phi"];
        ...     a -> b [particle="phi"];
        ...     a -> b [particle="phi"];
        ...     b -> ext [particle="phi"];
        ... }''').apply_feynman_rules()
        >>> numerator = diagram.numerator_expression(in_lmb=True)
        """
    @staticmethod
    def from_dot_set(model: Model, dot: builtins.str) -> builtins.list[FeynmanDiagram]:
        r"""
        Parse a document containing multiple Feynman diagrams in DOT format.
        Graphs are returned in document order and validated against the model.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> dot = "\n".join(item.to_dot() for item in result.diagrams)
        >>> restored = hep.FeynmanDiagram.from_dot_set(model, dot)
        >>> len(restored) == len(result.diagrams)
        True

        Parameters
        ----------
        model : Model
            Model used to resolve particles and validate diagram metadata.
        dot : str
            DOT document containing graph definitions. Annotated exports retain
            each diagram's momentum basis and physical cuts. Invalid graphs fail
            the entire import without returning a partial list.
        """
    def overall_factor_expression(self, *, evaluate: builtins.bool = False) -> Expression:
        r"""
        Return the diagram-wide multiplicative factor as a Symbolica expression.

        ``evaluate=True`` evaluates the generator's sign, multiplicity and
        symmetry annotations using the shared graph-factor evaluator. Other
        symbolic factors remain unchanged.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> factor = diagram.overall_factor_expression()
        >>> weighted_numerator = factor * diagram.numerator_expression()
        >>> weighted_numerator

        Parameters
        ----------
        evaluate : bool
            Evaluate known graph-factor annotations while preserving other symbols.
        """
    def denominator_expression(self, *, edge_powers: typing.Optional[typing.Mapping[builtins.int, builtins.int]] = None, dimension: typing.Optional[Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal]] = None, in_lmb: builtins.bool = False, lmb: typing.Optional[LoopMomentumBasis] = None) -> TensorExpression:
        r"""
        Return the product of internal propagator denominators as a scalar TensorExpression.

        Each factor retains GammaLoop's four-argument ``denom`` annotation around
        q_e² - m_e², with matching momentum labels and symbolic masses. Dimension
        defaults to GammaLoop's symbolic dimension; powers may be signed.
        The default region excludes external carriers and dummy edges. An explicit
        region follows GammaLoop and includes every complete selected edge. Widths,
        an imaginary prescription, and custom UFO denominator formulas are excluded.
        A selection without internal edges returns one.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> denominator = diagram.denominator_expression(in_lmb=True)
        >>> integrand = diagram.numerator_expression(in_lmb=True) / denominator
        >>> basis = diagram.loop_momentum_bases()[0]
        >>> denominator = diagram.denominator_expression(lmb=basis)

        Parameters
        ----------
        A complete diagram defaults to internal propagators; a Subgraph uses its region.
        edge_powers : mapping[int, int] or None, optional
            Signed propagator powers by diagram edge ID; omitted edges have power one.
        dimension : Expression or int or None, optional
            Lorentz dimension; defaults to the shared symbolic dimension.
        in_lmb : bool, optional
            Express edge momenta in the diagram's stored loop-momentum basis.
        lmb : LoopMomentumBasis or None, optional
            Basis from this diagram instance. Supplying it enables routing and
            takes precedence over ``in_lmb``, including for a selected region.
        """
    def integral_family(self, independent_dot_products: typing.Optional[typing.Sequence[Expression]] = None, *, kinematics: typing.Optional[Kinematics] = None) -> IntegralFamily:
        r"""
        Build a complete integral family with preferred or automatic ISPs.

        Physical propagators retain their edge order and model masses. Preferred
        independent dot products are appended when they increase the rank;
        automatic scalar products fill any remaining directions. Auxiliary
        entries have zero powers in the original scalar integral.
        Equivalent to ``IntegralFamily.from_diagram(self, independent_dot_products,
        kinematics=kinematics)``. Tree diagrams and dependent propagators raise
        DiagramError. Use ``propagator_family()`` to extract dependent propagators
        for partial fractioning before completing their families.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> family = diagram.integral_family()

        Parameters
        ----------
        independent_dot_products : list[Expression] or None, optional
            Preferred auxiliary inverse propagators in the routed momenta.
            None selects a suitable basis automatically.
        kinematics : Kinematics or None, optional
            External assumptions and dimension; defaults to the diagram's
            symbolic dimension with no on-shell assumptions.
        """
    def propagator_family(self, *, kinematics: typing.Optional[Kinematics] = None) -> IntegralFamily:
        r"""
        Extract the physical propagators using the diagram's stored momentum routing.

        Reuses the shared propagator builder and model masses. Denominators follow
        ascending internal edge IDs, as in ``internal_edges``, retaining bridges
        and repeated propagators. Dependent external coordinates are eliminated;
        external carriers and dummy edges are excluded. Widths, prescriptions and
        custom UFO denominator formulas are not inferred. Tree diagrams raise
        DiagramError because they contain no loop integral.
        Use ``diagram.integral_family()`` to also complete the basis
        with automatic or explicitly chosen auxiliary scalar products.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> family = diagram.propagator_family()
        >>> assert len(family.denominators) == len(diagram.internal_edges)

        Parameters
        ----------
        kinematics : Kinematics or None, optional
            Assumptions on routed momentum names and the Lorentz dimension.
            None uses the shared symbolic dimension with no on-shell assumptions.
        """
    def numerator_expression(self, *, without: Subgraph | None = None, in_lmb: builtins.bool = False, lmb: typing.Optional[LoopMomentumBasis] = None) -> TensorExpression:
        r"""
        Return the diagram numerator as a Spenso TensorExpression.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> numerator = diagram.numerator_expression(in_lmb=True)
        >>> basis = diagram.loop_momentum_bases()[0]
        >>> numerator = diagram.numerator_expression(lmb=basis)
        >>> integrand_numerator = diagram.overall_factor_expression() * numerator
        >>> integrand_numerator  # native Symbolica algebra and rich display

        Parameters
        ----------
        without : Subgraph or None, optional
            Ignored region, using GammaLoop boundary and local-factor selection semantics.
        in_lmb : bool, optional
            Express edge momenta in the diagram's stored loop-momentum basis.
        lmb : LoopMomentumBasis or None, optional
            Basis from this diagram instance. Supplying it enables routing and
            takes precedence over ``in_lmb``, including for a selected region.
        """
    def uv_expansion(self, uv_mass: Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal], *, dimension: builtins.int = 4, numerator: symbolica.Expression | symbolica.community.tensor.TensorExpression | None = None, edge_powers: typing.Optional[typing.Mapping[builtins.int, builtins.int]] = None) -> TensorExpression:
        r"""
        Expand the local integrand through its UV degree of divergence.

        The selected region's loop momenta are scaled together. Propagators are
        expanded about the auxiliary mass ``uv_mass``, retaining every power
        through logarithmic divergence in ``dimension`` spacetime dimensions.
        The result uses edge momenta and the same tagged ``denom`` convention as
        :meth:`denominator_expression`; the diagram is unchanged.

        ``numerator`` optionally replaces the local numerator (in edge momenta),
        for example after contracting a projector. Overall factors, numerator
        prefactors and projectors remain separate unless supplied in it.
        ``edge_powers`` uses the signed powers of :meth:`denominator_expression`.
        Move rational propagator factors out of a prepared numerator into these
        powers so they receive the same auxiliary-mass expansion. Powers do not
        change the selected region or its loop integration measure.
        Empty, tree and UV-convergent regions return zero. This performs one UV
        limit; it does not enumerate forests or integrate the counterterm.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> expanded = diagram.uv_expansion(0)
        >>> expansion = expanded  # symbolic Taylor-expanded integrand

        Parameters
        ----------
        uv_mass : Expression or int
            Auxiliary mass used for the propagator expansion.
        dimension : int, optional
            Positive spacetime dimension for UV power counting; defaults to four.
        numerator : Expression or TensorExpression or None, optional
            Prepared numerator in edge momenta; None uses the selected local numerator.
        edge_powers : mapping[int, int] or None, optional
            Signed propagator powers by diagram edge ID; omitted edges have power one.
            Zero omits the denominator; negative powers put it in the numerator.
            Entries outside the selected internal edges are ignored.
        """
    def uv_counterterm(self, uv_mass: Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal], *, dimension: builtins.int = 4, numerator: symbolica.Expression | symbolica.community.tensor.TensorExpression | None = None, edge_powers: typing.Optional[typing.Mapping[builtins.int, builtins.int]] = None) -> TensorExpression:
        r"""
        Return the additive local UV counterterm, the negative of ``uv_expansion``.

        Arguments and selection semantics are those of :meth:`uv_expansion`.
        Add this unintegrated expression to the selected integrand to subtract
        its simultaneous UV limit. Subdivergences require separate forest terms.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> from symbolica import S
        >>> mass = S("mUV", is_scalar=True)
        >>> counterterm = diagram.uv_counterterm(mass)

        Parameters
        ----------
        uv_mass : Expression or int
            Auxiliary mass used for the propagator expansion.
        dimension : int, optional
            Positive spacetime dimension for UV power counting; defaults to four.
        numerator : Expression or TensorExpression or None, optional
            Prepared numerator in edge momenta; None uses the selected local numerator.
        edge_powers : mapping[int, int] or None, optional
            Signed propagator powers by diagram edge ID; omitted edges have power one.
            Zero omits the denominator; negative powers put it in the numerator.
            Entries outside the selected internal edges are ignored.
        """
    def numerator_prefactor_expression(self) -> TensorExpression:
        r"""
        Return the request-wide numerator multiplier with its tensor interface.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> prefactor = diagram.numerator_prefactor_expression()
        >>> weighted_numerator = prefactor * diagram.numerator_expression()
        >>> weighted_numerator
        """
    def projector_expression(self) -> TensorExpression:
        r"""
        Return the external-state projector with its tensor interface.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> projector = diagram.projector_expression()
        >>> projected_numerator = projector * diagram.numerator_expression()
        >>> projected_numerator
        """
    def tensor_reduce(self, dimension: Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal], *, expression: symbolica.Expression | symbolica.community.tensor.TensorExpression | None = None, projector: symbolica.Expression | symbolica.community.tensor.TensorExpression | None = None) -> TensorExpression:
        r"""
        Reduce the numerator and projector using the diagram's internal edge momenta.

        Four-dimensional Lorentz slots are promoted to `D` before reduction.
        External momenta remain projector vectors, and the scalar numerator
        prefactor remains separate. Requires at least one internal edge.
        A supplied expression replaces the numerator and projector, for example
        after a UV expansion; it must use the diagram's edge momentum names.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> from symbolica import E
        >>> reduced = diagram.tensor_reduce(E("D"))

        Parameters
        ----------
        dimension : Expression or int
            Lorentz dimension used for the reduction and four-dimensional input slots.
        expression : Expression or TensorExpression, optional
            Complete prepared input to reduce instead of the numerator and projector.
            Cannot be combined with an explicit projector.
        projector : Expression or TensorExpression or None, optional
            Explicit external tensor projector, required for partial regions unless expression is supplied.
        """
    def reduce_tensor_numerator(self, reducer: TensorReducer) -> TensorExpression:
        r"""
        Reduce the finalized numerator and projector with a tensor reducer.

        The result is a native Symbolica expression using ``spenso::dot`` and
        ``spenso::g``. For a fully projected vacuum numerator, all Lorentz
        indices disappear and only scalar invariants remain. Residual free
        projector indices are preserved as metric tensors; use
        :meth:`reduce_tensor_graphs` when scalar graph contributions are
        required. The scalar numerator prefactor remains separate and is not
        included in this expression.

        Examples
        --------
        Reduce a vacuum graph after explicitly selecting its integrated momentum head:

        >>> from symbolica import S, E
        >>> from symbolica.community import hepkit as hep
        >>> model = hep.Model.phi4()
        >>> vacuum_diagram = model.process([], []).generate_diagrams(loops=2, factorized_loop_topologies_count_range=None).diagrams[0]
        >>> reducer = hep.TensorReducer(E("4"), integrated=[E("gammalooprs::Q")])
        >>> scalar_numerator = vacuum_diagram.reduce_tensor_numerator(reducer)

        Parameters
        ----------
        reducer : TensorReducer
            Tensor projector and integrated-momentum selection to apply.
        """
    def reduce_tensor_graphs(self, reducer: TensorReducer) -> builtins.list[FeynmanDiagram]:
        r"""
        Split the tensor numerator into scalar contributions on this topology.

        Each returned diagram has one compact reduction term as its numerator,
        including that term's exact projector coefficient. The graph topology,
        model, denominator data, and topology ID are preserved; deterministic
        ``.tensor[index]`` name suffixes distinguish the derived contributions.
        The external-state projector is consumed and reset to one, while the
        scalar numerator prefactor is retained. The projection must be fully
        contracted: any residual indexed Minkowski slot raises
        ``TensorReductionError``. Use
        :meth:`reduce_tensor_numerator` when residual free Lorentz indices are
        intentional.

        Examples
        --------
        Construct scalar numerator graphs for a vacuum diagram:

        >>> from symbolica import S, E
        >>> from symbolica.community import hepkit as hep
        >>> model = hep.Model.phi4()
        >>> vacuum_diagram = model.process([], []).generate_diagrams(loops=2, factorized_loop_topologies_count_range=None).diagrams[0]
        >>> reducer = hep.TensorReducer(E("4"), integrated=[E("gammalooprs::Q")])
        >>> scalar_graphs = vacuum_diagram.reduce_tensor_graphs(reducer)

        Parameters
        ----------
        reducer : TensorReducer
            Tensor projector and integrated-momentum selection to apply.
        """
    def with_loop_momentum_edges(self, edges: typing.Sequence[builtins.int]) -> FeynmanDiagram:
        r"""
        Return a diagram using the specified loop-edge coordinates, in the supplied order.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> rerouted = diagram.with_loop_momentum_edges(diagram.loop_momentum_basis.loop_edges)

        Parameters
        ----------
        edges : list[int]
            Diagram edge IDs specifying the requested routing coordinates.
        """
    def with_loop_momentum_tree_edges(self, edges: typing.Sequence[builtins.int]) -> FeynmanDiagram:
        r"""
        Return a diagram whose momentum routing uses the specified spanning forest.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> rerouted = diagram.with_loop_momentum_tree_edges(diagram.loop_momentum_basis.tree_edges)

        Parameters
        ----------
        edges : list[int]
            Diagram edge IDs specifying the requested routing coordinates.
        """
    def momentum_basis(self) -> LoopMomentumBasis:
        r"""
        Construct the canonical routing of the selected interaction region.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> basis = diagram.momentum_basis()
        >>> routed = basis.route_expression(diagram.numerator_expression())
        """
    def compatible_momentum_basis(self, parent: LoopMomentumBasis) -> LoopMomentumBasis:
        r"""
        Reuse a parent basis's loop coordinates wherever the selected topology permits it.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> basis = diagram.compatible_momentum_basis(diagram.loop_momentum_basis)

        Parameters
        ----------
        parent : LoopMomentumBasis
            Parent coordinates belonging to this same diagram instance.
        """
    def contracted_momentum_basis(self, contracted: Subgraph) -> LoopMomentumBasis:
        r"""
        Route the selected region after contracting complete internal edges.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> contracted = diagram.filter(edge=lambda edge: edge.is_dummy)
        >>> basis = diagram.contracted_momentum_basis(contracted)

        Parameters
        ----------
        contracted : Subgraph
            Complete internal edges to contract, selected from this diagram.
        """
    def superficial_degree_of_divergence(self, *, dimension: builtins.int = 4) -> builtins.int:
        r"""
        Return the local superficial UV degree of divergence.

        Counts ``dimension * loops`` plus vertex momentum powers and internal
        propagator numerator powers minus two per internal propagator. Uses the
        stored local numerators; excludes external legs, projectors, and global
        prefactors. Vertex momenta scale together, before tensor cancellations.
        Zero is logarithmic, positive is power divergent, and negative is
        superficially convergent. Subdivergences are not tested.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> degree = diagram.superficial_degree_of_divergence()
        >>> degree_in_six_dimensions = diagram.superficial_degree_of_divergence(dimension=6)

        Parameters
        ----------
        dimension : int, optional
            Spacetime dimension for each loop integration measure; defaults to four.
        """
    def validate(self) -> None:
        r"""
        Validate particle and interaction references against a physics model.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        Validation raises ``DiagramError`` for invalid particle or interaction
        references:

        >>> diagram.validate()
        """
    def to_json(self) -> builtins.str:
        r"""
        Serialize the complete diagram to JSON text.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> encoded = diagram.to_json()
        >>> restored = hep.FeynmanDiagram.from_json(model, encoded)
        >>> restored.validate()
        """
    def to_dot(self) -> builtins.str:
        r"""
        Serialize the diagram topology and annotations to Graphviz DOT text.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> dot = diagram.to_dot()
        >>> restored = hep.FeynmanDiagram.from_dot(model, dot)
        >>> restored.validate()
        """
    def to_linnest(self, *, config: typing.Optional[RenderSettings] = None, style: typing.Optional[DiagramStyle] = None, momenta: builtins.bool = False, lmb: typing.Optional[LoopMomentumBasis] = None, highlight: Subgraph | None = None) -> builtins.str:
        r"""
        Export a self-contained Typst document embedding an outlined SVG.

        Uses the same ``config``, ``momenta``, ``lmb`` and ``highlight`` settings
        as ``render``. This explicit vector export uses the optional Python
        ``typst`` compiler to outline labels; compiling the exported source
        needs no Linnest, Kurvst, MiTeX, or model assets.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> from pathlib import Path
        >>> Path("diagram.typ").write_text(diagram.to_linnest(momenta=True))

        Parameters
        ----------
        style : DiagramStyle or None, optional
            Particle, momentum, and physical index presentation.
        config : RenderSettings or None, optional
            Layout, drawing, and graph style settings, as in ``render``.
        momenta : bool, optional
            Draw momentum arrows and labels in the stored basis.
        lmb : LoopMomentumBasis or None, optional
            Routing from this diagram; also enables momentum display.
        highlight : Subgraph or None, optional
            Region to highlight in the complete diagram.
        """
    def render(self, *, config: typing.Optional[RenderSettings] = None, style: typing.Optional[DiagramStyle] = None, momenta: builtins.bool = False, lmb: typing.Optional[LoopMomentumBasis] = None, highlight: Subgraph | None = None) -> DiagramView:
        r"""
        Prepare a browser-measured view using the shared physics renderer.

        The notebook browser measures MathML labels and titles, then Rust draws
        graph geometry. ``LayoutSettings(impred_labels=True)`` refines the layout
        around those measurements. Scripts must supply measurements or explicitly
        select a browser with ``drawing.measured(browser="chromium")`` before export.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> from symbolica.community.graph import LayoutSettings, RenderSettings
        >>> settings = RenderSettings(
        ...     layouts=LayoutSettings(impred_steps=100))
        >>> drawing = diagram.render(momenta=True, config=settings, style=hep.DiagramStyle(show_particle=False))
        >>> drawing
        >>> svg = drawing.measured(browser="chromium").to_svg()
        >>> drawing = diagram.render(lmb=next(iter(diagram.loop_momentum_bases())))

        Parameters
        ----------
        style : DiagramStyle or None, optional
            Particle, momentum, and physical index presentation.
        config : RenderSettings or None, optional
            Immutable layout, styling, and physics overrides. Use ``help(RenderSettings)``
            and ``help(LayoutSettings)`` to discover the supported options.
            Cross sections open initial-state connections by default; set
            ``split_initial_state=False`` to draw the sewn graph.
        momenta : bool, optional
            Show momentum arrows and labels routed in the diagram's stored basis.
            Explicit fields in ``style`` override these display defaults.
        lmb : LoopMomentumBasis or None, optional
            Explicit routing from this diagram; also enables momentum display.
            Rendering never changes the diagram's stored loop-momentum basis.
        highlight : Subgraph or None, optional
            Highlight a region while preserving the full diagram as muted context.
            A Subgraph highlights its own region by default.
        """
    def to_html(self, *, config: typing.Optional[RenderSettings] = None, style: typing.Optional[DiagramStyle] = None, momenta: builtins.bool = False, lmb: typing.Optional[LoopMomentumBasis] = None, highlight: Subgraph | None = None, browser: typing.Optional[builtins.str] = None) -> builtins.str:
        r"""
        Export a complete static HTML figure with the same options as ``render``.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> import marimo as mo
        >>> mo.iframe(diagram.to_html(momenta=True, browser="chromium"))

        Parameters
        ----------
        style : DiagramStyle or None, optional
            Particle, momentum, and physical index presentation.
        config : RenderSettings or None, optional
            Layout, drawing, and graph style settings, as in ``render``.
        momenta : bool, optional
            Draw momentum arrows and labels in the stored basis.
        lmb : LoopMomentumBasis or None, optional
            Routing from this diagram; also enables momentum display.
        highlight : Subgraph or None, optional
            Region to highlight in the complete diagram.
        browser : {"chromium"} or None, optional
            Explicit headless browser for script exports; none is started implicitly.
            Defaults use a completed measurement, optional Typst, or estimated
            MathML label sizes. For exact notebook measurements, use
            ``render().measured().to_html()`` on the displayed view instead.
        """
    def _repr_mimebundle_(self, include: typing.Optional[typing.Sequence[builtins.str]] = None, exclude: typing.Optional[typing.Sequence[builtins.str]] = None) -> typing.Any:
        r"""
        Render the diagram as HTML in Marimo, Jupyter, and IPython.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> from IPython.display import display
        >>> display(diagram)

        Parameters
        ----------
        include : list[str] or None, optional
            MIME types requested by the frontend; None allows all available types.
        exclude : list[str] or None, optional
            MIME types omitted from the frontend response.
        """
    def _mime_(self) -> typing.Any:
        r"""
        Return Marimo MIME data for the browser-measured diagram view.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> view = diagram.render(momenta=True)
        >>> view  # notebook display measures labels before mounting the diagram
        >>> snapshot = view.measured(browser="chromium")
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write a concise summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(diagram)

        Parameters
        ----------
        pretty : Any
            The IPython pretty-printer object.
        cycle : bool
            Whether this object is part of a recursive formatting cycle.
        """
    def loop_momentum_bases(self, limit: typing.Optional[builtins.int] = None) -> builtins.list[LoopMomentumBasis]:
        r"""
        Enumerate valid loop-momentum bases for this diagram.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        Limit exploratory calculations to the first basis:

        >>> basis = diagram.loop_momentum_bases(limit=1)[0]
        >>> routing = {
        ...     edge_id: signature.format_momentum()
        ...     for edge_id, signature in basis.edge_signatures.items()
        ... }

        Parameters
        ----------
        limit : int or None
            Maximum number of bases to return. Pass ``None`` to enumerate every
            valid basis.
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return a concise description of the diagram and its loop count.

        Examples
        --------
        Using the setup in the ``FeynmanDiagram`` class example:

        >>> print(diagram)
        """
    def sector_decompose(self, *, regulator: symbolica.Expression, kinematics: typing.Optional[Kinematics] = None, dimension: typing.Optional[symbolica.Expression] = None, powers: typing.Optional[typing.Dict[int, int]] = None, numerator: None = None, scalar_values: typing.Optional[typing.Dict[symbolica.Expression, symbolica.Expression]] = None, auxiliary_momenta: typing.Optional[typing.Sequence[symbolica.Expression]] = None, measure_multiplier: typing.Optional[symbolica.Expression] = None, max_order: int = 0, coefficient_expansion: str = 'physical', observer: typing.Optional[typing.Callable[[symbolica.community.hepkit.sector_decomposition.GenerationSnapshot], typing.Optional[bool]]] = None, progress: typing.Union[typing.Literal["auto"], typing.Callable[[symbolica.community.hepkit.sector_decomposition.GenerationSnapshot], typing.Optional[bool]], None] = 'auto') -> symbolica.community.hepkit.sector_decomposition.GeneratedIntegral:
        r"""
        Generate Laurent integrands using the complete native diagram.

        Examples
        --------
        With a complete diagram and admitted numerical kinematics:

        >>> from symbolica import E, S
        >>> from symbolica.community import hepkit as hep
        >>> model = hep.Model.phi3()
        >>> diagram = model.process(["phi"], ["phi"]).generate_diagrams(loops=1, max_vertices=2, maximum_bridges=0, progress=None).diagrams[0]
        >>> from symbolica.community.hepkit.sector_decomposition import with_diagram_expressions
        >>> diagram = with_diagram_expressions(diagram, overall_factor=diagram.overall_factor_expression(evaluate=True))
        >>> eps, D = S("eps", "D")
        >>> P = hep.Kinematics.external_momentum()
        >>> point = hep.Kinematics(D, momenta=[P(0)]).with_scalar_product(P(0), P(0), E("-1"))
        >>> values = {model.particle("phi").mass: E("1"), model.parameter("g").symbol: E("1")}
        >>> generated = diagram.sector_decompose(regulator=eps, kinematics=point, scalar_values=values, progress=None)
        >>> kernels = generated.compile()

        Parameters
        ----------
        regulator : Expression
            Dimensional regulator symbol.
        kinematics : Kinematics
            Numerical external point retaining its symbolic tensor dimension.
        dimension : Expression or None
            Integration dimension; defaults to 4 - 2*regulator.
        powers : mapping[int, int] or None
            Positive propagator powers by stable diagram edge ID.
        numerator : None
            Use the diagram's numerator; explicit overrides are rejected.
        scalar_values : mapping[Expression, Expression] or None
            Explicit masses, couplings and invariant substitutions.
        auxiliary_momenta : sequence[Expression] or None
            Additional external vector heads, such as polarizations.
        measure_multiplier : Expression or None
            Explicit multiplicative measure convention, applied once.
        max_order : int
            Largest signed epsilon power retained.
        coefficient_expansion : str
            Native physical or package coefficient convention.
        observer : callable or None
            Native generation events; False cancels at an event boundary.
        progress : "auto", callable or None
            Automatic marimo display unless observer is supplied; None disables it.
            A callable receives every native event after observer and may cancel.
        """

@typing.final
class FormFactor:
    r"""
    A momentum-dependent form factor referenced by interaction rules.

    Form factors keep their model type and symbolic value so specialized
    amplitude backends can evaluate them at the relevant kinematic point.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.standard_model()
    >>> form_factors = {ff.name: ff.value for ff in model.form_factors}
    """
    @property
    def name(self) -> builtins.str:
        r"""
        Return the form-factor name.

        Examples
        --------
        Using the setup in the ``FormFactor`` class example:

        >>> names = [ff.name for ff in model.form_factors]
        """
    @property
    def type_name(self) -> typing.Optional[builtins.str]:
        r"""
        Return the model-defined form-factor type, when present.

        Examples
        --------
        Using the setup in the ``FormFactor`` class example:

        >>> types = {ff.name: ff.type_name for ff in model.form_factors}
        """
    @property
    def value(self) -> typing.Optional[Expression]:
        r"""
        Return the symbolic form-factor value, when present.

        Examples
        --------
        Using the setup in the ``FormFactor`` class example:

        >>> formulas = {ff.name: ff.value for ff in model.form_factors}
        """
    def __repr__(self) -> builtins.str:
        r"""
        Summarize the defining data as well as the form-factor name.

        Examples
        --------
        Using the setup in the ``FormFactor`` class example:

        >>> summaries = [repr(ff) for ff in model.form_factors]
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Display the model member's physical data and defining expressions.

        Examples
        --------
        Using the setup in the ``FormFactor`` class example:

        >>> from IPython.display import display
        >>> display(model.form_factors)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the complete text summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``FormFactor`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(model.form_factors)

        Parameters
        ----------
        pretty : object
            IPython pretty printer receiving the text.
        cycle : bool
            Whether the object occurs recursively in the current display.
        """

@typing.final
class FourMomentum:
    r"""
    A relativistic four-momentum in ``(energy, px, py, pz)`` order.

    The class provides collider observables, invariant products, rotations, and
    boosts while keeping the component convention explicit.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> momentum = hep.FourMomentum(5.0, 3.0, 4.0, 0.0)
    >>> p = momentum
    >>> first = hep.FourMomentum(5.0, 0.0, 5.0, 0.0)
    >>> second = hep.FourMomentum(5.0, 5.0, 0.0, 0.0)
    >>> assert momentum.mass_squared == 0.0

    Parameters
    ----------
    energy : float
        Energy component.
    px : float
        Momentum component along the x axis.
    py : float
        Momentum component along the y axis.
    pz : float
        Momentum component along the z axis.
    """
    @property
    def energy(self) -> builtins.float:
        r"""
        Return the energy component.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> assert momentum.energy == 5.0
        """
    @property
    def px(self) -> builtins.float:
        r"""
        Return the x component of spatial momentum.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> assert momentum.px == 3.0
        """
    @property
    def py(self) -> builtins.float:
        r"""
        Return the y component of spatial momentum.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> assert momentum.py == 4.0
        """
    @property
    def pz(self) -> builtins.float:
        r"""
        Return the z component of spatial momentum.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> assert momentum.pz == 0.0
        """
    @property
    def spatial(self) -> ThreeMomentum:
        r"""
        Return the spatial three-momentum.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> hep.FourMomentum(5.0, 3.0, 4.0, 0.0).spatial.pt
        5.0
        """
    @property
    def mass_squared(self) -> builtins.float:
        r"""
        Return the invariant mass squared.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> hep.FourMomentum(5.0, 3.0, 4.0, 0.0).mass_squared
        0.0
        """
    @property
    def mass(self) -> builtins.float:
        r"""
        Return the invariant mass.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> hep.FourMomentum(5.0, 0.0, 0.0, 0.0).mass
        5.0
        """
    @property
    def pt(self) -> builtins.float:
        r"""
        Return the transverse-momentum magnitude.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> hep.FourMomentum(13.0, 3.0, 4.0, 12.0).pt
        5.0
        """
    @property
    def phi(self) -> builtins.float:
        r"""
        Return the azimuthal angle in radians.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> hep.FourMomentum(1.0, 1.0, 0.0, 0.0).phi
        0.0
        """
    @property
    def pseudorapidity(self) -> builtins.float:
        r"""
        Return the pseudorapidity of the spatial momentum.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> abs(hep.FourMomentum(1.0, 1.0, 0.0, 0.0).pseudorapidity) < 1e-12
        True
        """
    @property
    def rapidity(self) -> builtins.float:
        r"""
        Return the longitudinal rapidity.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> hep.FourMomentum(1.0, 1.0, 0.0, 0.0).rapidity
        0.0
        """
    def __new__(cls, energy: builtins.float, px: builtins.float, py: builtins.float, pz: builtins.float) -> FourMomentum:
        r"""
        Construct a four-momentum from energy and Cartesian spatial components.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> momentum = hep.FourMomentum(5.0, 3.0, 4.0, 0.0)

        Parameters
        ----------
        energy : float
            Temporal component.
        px : float
            Momentum along the x axis.
        py : float
            Momentum along the y axis.
        pz : float
            Momentum along the z axis.
        """
    def wavefunction(self, kind: builtins.str, helicity: Helicity) -> Wavefunction:
        r"""
        Construct a fixed scalar, vector or spinor external state.

        ``kind`` is ``scalar``, ``epsilon``, ``epsilon_bar``, ``u``, ``u_bar``,
        ``v`` or ``v_bar``. Scalar helicity is zero; spinors use plus or minus.
        A massive vector also admits zero helicity for a longitudinal state.
        The inherited longitudinal convention is undefined at rest or zero mass
        and raises ``KinematicsError``. All states use four-dimensional external
        components and GammaLoop's MadGraph phases; no averaging is included.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> p = hep.FourMomentum(150.0, 0.0, 0.0, 150.0)
        >>> eps = p.wavefunction("epsilon", hep.Helicity.PLUS)
        >>> assert len(eps.components) == 4 and eps.bar().bar() == eps

        Parameters
        ----------
        kind : str
            Scalar, vector or spinor state kind, including the barred variants above.
        helicity : Helicity
            Fixed helicity; zero for scalars, plus/minus for spinors, and also zero
            for a massive longitudinal vector with nonzero spatial momentum.
        """
    def components(self) -> tuple[builtins.float, builtins.float, builtins.float, builtins.float]:
        r"""
        Return ``(energy, px, py, pz)``.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> hep.FourMomentum(5.0, 3.0, 4.0, 0.0).components()
        (5.0, 3.0, 4.0, 0.0)
        """
    def dot(self, other: FourMomentum) -> builtins.float:
        r"""
        Return the Minkowski dot product with another four-momentum.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> momentum.dot(momentum)
        0.0

        Parameters
        ----------
        other : FourMomentum
            Momentum to contract with this one.
        """
    def flux(self, other: typing.Optional[FourMomentum] = None) -> builtins.float:
        r"""
        Return the decay denominator ``2E`` or the invariant two-particle flux.

        Inputs must be physical, future-directed on-shell momenta. Decay rates
        refer to this momentum's frame; the rest-frame result is ``2M``.
        No unit conversion, spin/color average or symmetry factor is included.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> p = hep.FourMomentum(5.0, 0.0, 0.0, 5.0)
        >>> q = hep.FourMomentum(5.0, 0.0, 0.0, -5.0)
        >>> p.flux(q)
        200.0

        Parameters
        ----------
        other : FourMomentum | None
            Other incoming momentum; None selects a decay in this frame.
        """
    def delta_phi(self, other: FourMomentum) -> builtins.float:
        r"""
        Return the wrapped azimuthal separation from another momentum.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> first.delta_phi(second)
        1.5707963267948966

        Parameters
        ----------
        other : FourMomentum
            Momentum whose azimuth is compared.
        """
    def delta_r(self, other: FourMomentum) -> builtins.float:
        r"""
        Return the distance in rapidity-azimuth space.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> separation = first.delta_r(second)
        >>> same_jet = separation < 0.4

        Parameters
        ----------
        other : FourMomentum
            Momentum to compare with this one.
        """
    def __add__(self, other: FourMomentum) -> FourMomentum:
        r"""
        Add two four-momenta component by component.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> (first + second).energy == first.energy + second.energy
        True

        Parameters
        ----------
        other : FourMomentum
            Momentum to add.
        """
    def __sub__(self, other: FourMomentum) -> FourMomentum:
        r"""
        Subtract another four-momentum component by component.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> (first - second).energy == first.energy - second.energy
        True

        Parameters
        ----------
        other : FourMomentum
            Momentum to subtract.
        """
    def __neg__(self) -> FourMomentum:
        r"""
        Reverse the four-momentum flow convention.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> incoming_convention = hep.FourMomentum(5.0, 3.0, 4.0, 0.0)
        >>> outgoing_convention = -incoming_convention
        >>> assert outgoing_convention.energy == -5.0
        """
    def __mul__(self, scalar: builtins.float) -> FourMomentum:
        r"""
        Scale every four-momentum component.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> half_momentum = momentum * 0.5

        Parameters
        ----------
        scalar : float
            Multiplicative scale factor.
        """
    def __rmul__(self, scalar: builtins.float) -> FourMomentum:
        r"""
        Scale every four-momentum component from the left.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> half_momentum = 0.5 * momentum

        Parameters
        ----------
        scalar : float
            Multiplicative scale factor.
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return a constructor-style representation of the components.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> muon_momentum = hep.FourMomentum(5.0, 3.0, 4.0, 0.0)
        >>> print(f"muon four-momentum: {muon_momentum!r}")
        """
    def _repr_latex_(self) -> builtins.str:
        r"""
        Render the momentum as a contravariant four-vector.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> latex = momentum._repr_latex_()
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the constructor-style form to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``FourMomentum`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(momentum)

        Parameters
        ----------
        pretty : object
            The IPython pretty-printer object.
        cycle : bool
            Whether this object is part of a recursive formatting cycle.
        """

class GenerationError(FeynkitError):
    r"""
    Invalid process configuration or Feynman-diagram generation failure.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> try:
    ...     process.generate_diagrams(self_energy=hep.SelfEnergyFilterOptions(only_scaleless=True))
    ... except hep.GenerationError as error:
    ...     message = str(error)
    """
    ...

@typing.final
class GenerationProgress:
    r"""
    A progress snapshot delivered on the Python thread running generation.

    Counts restart at each stage and measure processed work, not retained diagrams.
    ``total`` is None when the amount of work is not yet known.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> snapshots = []
    >>> def report(progress):
    ...     snapshots.append((progress.stage, progress.completed, progress.total))
    >>> result = process.generate_diagrams(loops=1, progress=report)
    >>> assert result.report.completed
    """
    @property
    def stage(self) -> builtins.str:
        r"""
        Pipeline stage: topologies, topology_filters, interactions,
        interaction_filters, numerators, selection, filter_zero_color, grouping_preparation,
        grouping_samples, grouping_comparison, grouping, complete or cancelled.

        Examples
        --------
        Using the setup in the ``GenerationProgress`` class example:

        >>> stages = []
        >>> def report(progress):
        ...     stages.append(progress.stage)
        >>> result = process.generate_diagrams(progress=report)
        """
    @property
    def completed(self) -> builtins.int:
        r"""
        Work items processed within this stage.

        Examples
        --------
        Using the setup in the ``GenerationProgress`` class example:

        >>> counts = []
        >>> def report(progress):
        ...     counts.append((progress.stage, progress.completed))
        >>> result = process.generate_diagrams(progress=report)
        """
    @property
    def total(self) -> typing.Optional[builtins.int]:
        r"""
        Stage total, or None while the amount of work is unknown.

        Examples
        --------
        Using the setup in the ``GenerationProgress`` class example:

        >>> totals = []
        >>> def report(progress):
        ...     totals.append((progress.stage, progress.total))
        >>> result = process.generate_diagrams(progress=report)
        """
    @property
    def zero_numerator_count(self) -> builtins.int:
        r"""
        Zero numerators filtered so far in this generation run.

        Examples
        --------
        Using the setup in the ``GenerationProgress`` class example:

        >>> zeroes = []
        >>> result = process.generate_diagrams(
        ...     filter_zero_color=True,
        ...     progress=lambda progress: zeroes.append(progress.zero_numerator_count))
        >>> assert zeroes[-1] == result.report.zero_numerator_count
        """

@typing.final
class GenerationReport:
    r"""
    Counts and completion status from a diagram-generation run.

    The report distinguishes explored topologies and interaction assignments
    from the physical diagrams retained after numerator checks.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> result = process.generate_diagrams(loops=1)
    >>> diagram = result.diagrams[0]
    >>> report = result.report
    >>> assert report.completed
    >>> assert report.retained_count == len(result.diagrams)
    """
    @property
    def topology_count(self) -> builtins.int:
        r"""
        Return the number of distinct topologies considered during generation.

        Examples
        --------
        Using the setup in the ``GenerationReport`` class example:

        >>> assert report.topology_count >= 1
        """
    @property
    def interaction_assignment_count(self) -> builtins.int:
        r"""
        Return the number of interaction assignments examined.

        Examples
        --------
        Using the setup in the ``GenerationReport`` class example:

        >>> assignments_tested = report.interaction_assignment_count
        """
    @property
    def retained_count(self) -> builtins.int:
        r"""
        Return the number of diagrams retained after removing zero numerators.

        Examples
        --------
        Using the setup in the ``GenerationReport`` class example:

        >>> assert report.retained_count == len(result.diagrams)
        """
    @property
    def zero_numerator_count(self) -> builtins.int:
        r"""
        Return the number of diagrams removed for having an exact zero numerator.

        Examples
        --------
        Using the setup in the ``GenerationReport`` class example:

        >>> removed_zeroes = report.zero_numerator_count
        """
    @property
    def completed(self) -> builtins.bool:
        r"""
        Report whether generation finished without cancellation.

        Examples
        --------
        Using the setup in the ``GenerationReport`` class example:

        >>> assert report.completed  # False means generation was cancelled
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return a concise constructor-style generation summary.

        Examples
        --------
        Using the setup in the ``GenerationReport`` class example:

        >>> print(result.report)
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Render generation statistics as a compact HTML table.

        Examples
        --------
        Using the setup in the ``GenerationReport`` class example:

        >>> from IPython.display import display
        >>> display(report)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write a concise generation summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``GenerationReport`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(report)

        Parameters
        ----------
        pretty : object
            The IPython pretty-printer object.
        cycle : bool
            Whether this object is part of a recursive formatting cycle.
        """

@typing.final
class GenerationResult:
    r"""
    Feynman diagrams and diagnostics produced for one process.

    The result retains generated diagrams in deterministic order and may also
    contain numerator-equivalence groups for efficient downstream evaluation.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> result = process.generate_diagrams(loops=1)
    >>> diagram = result.diagrams[0]
    >>> diagrams = result.diagrams
    >>> assert result.report.retained_count == len(diagrams)
    """
    @property
    def diagrams(self) -> builtins.list[FeynmanDiagram]:
        r"""
        Return every retained diagram in generated order.

        Examples
        --------
        Using the setup in the ``GenerationResult`` class example:

        >>> numerators = [diagram.numerator_expression() for diagram in result.diagrams]
        """
    @property
    def groups(self) -> builtins.list[DiagramGroup]:
        r"""
        Return the numerator groups in deterministic master-index order.

        Examples
        --------
        Using the setup in the ``GenerationResult`` class example:

        >>> masters = [result.diagrams[group.master] for group in result.groups]
        """
    @property
    def report(self) -> GenerationReport:
        r"""
        Return generation counts and completion status.

        Examples
        --------
        Using the setup in the ``GenerationResult`` class example:

        >>> assert result.report.completed
        """
    def __len__(self) -> builtins.int:
        r"""
        Return the number of retained diagrams.

        Examples
        --------
        Using the setup in the ``GenerationResult`` class example:

        >>> number_of_diagrams = len(result)
        """
    def __getitem__(self, index: builtins.int) -> FeynmanDiagram:
        r"""
        Return one retained diagram by generated-order index.

        Examples
        --------
        Using the setup in the ``GenerationResult`` class example:

        >>> first_diagram = result[0]

        Parameters
        ----------
        index : int
            Zero-based index; negative indices count from the end.
        """
    def __iter__(self) -> collections.abc.Iterator[FeynmanDiagram]:
        r"""
        Iterate over retained diagrams in deterministic generated order.

        Examples
        --------
        Using the setup in the ``GenerationResult`` class example:

        >>> one_loop = [diagram for diagram in result if diagram.loop_count == 1]
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return a concise summary of the retained diagrams and groups.

        Examples
        --------
        Using the setup in the ``GenerationResult`` class example:

        >>> print(result)
        """
    def render(self, *, config: typing.Optional[RenderSettings] = None, style: typing.Optional[DiagramStyle] = None, max_diagrams: typing.Optional[builtins.int] = 6) -> DiagramView:
        r"""
        Render a thumbnail strip and one shared interactive diagram viewer.

        The view measures labels when displayed. By default it includes six
        diagrams; ``max_diagrams=None`` includes the complete collection.

        Examples
        --------
        Using the setup in the ``GenerationResult`` class example:

        >>> view = result.render(max_diagrams=None)
        >>> view
        >>> snapshot = view.measured(browser="chromium")

        Parameters
        ----------
        config : RenderSettings or None, optional
            Layout, label and drawing settings shared by the displayed diagrams.
        style : DiagramStyle or None, optional
            Particle, momentum and physical index presentation.
        max_diagrams : int or None, optional
            Maximum displayed diagrams (default 6); None includes all, 0 none.
        """
    def _repr_mimebundle_(self, include: typing.Optional[typing.Sequence[builtins.str]] = None, exclude: typing.Optional[typing.Sequence[builtins.str]] = None) -> typing.Any:
        r"""
        Return widget MIME data for the compact generation-result explorer.

        Examples
        --------
        Using the setup in the ``GenerationResult`` class example:

        >>> view = result.render()
        >>> view  # static output is immediate; an optional widget refines label sizes
        >>> snapshot = view.measured(browser="chromium")

        Parameters
        ----------
        include : list[str] or None, optional
            MIME types requested by the frontend; None allows all available types.
        exclude : list[str] or None, optional
            MIME types omitted from the frontend response.
        """
    def _mime_(self) -> typing.Any:
        r"""
        Return Marimo MIME data with static output and an optional live widget.

        Examples
        --------
        Using the setup in the ``GenerationResult`` class example:

        >>> view = result.render(max_diagrams=None)
        >>> view  # static output is immediate; an optional widget refines label sizes
        >>> snapshot = view.measured(browser="chromium")
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write a concise result summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``GenerationResult`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(result)

        Parameters
        ----------
        pretty : object
            The IPython pretty-printer object.
        cycle : bool
            Whether this object is part of a recursive formatting cycle.
        """

@typing.final
class GroupMember:
    r"""
    One diagram and its numerator ratio inside a grouped result.

    A group member points into ``GenerationResult.diagrams`` and expresses its
    numerator relative to the group's master diagram.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> result = process.generate_diagrams(loops=1)
    >>> diagram = result.diagrams[0]
    >>> group = result.groups[0]
    >>> member = group.members[0]
    >>> diagram = result.diagrams[member.diagram]
    """
    @property
    def source_diagram(self) -> builtins.int:
        r"""
        Return the generated-order index from before zero-numerator removal.

        Examples
        --------
        Using the setup in the ``GroupMember`` class example:

        >>> source_index = member.source_diagram
        >>> source_identity = (source_index, member.source_id, member.source_name)
        """
    @property
    def source_id(self) -> builtins.str:
        r"""
        Return the source diagram's stable content-derived ID.

        Examples
        --------
        Using the setup in the ``GroupMember`` class example:

        >>> source_ids = [entry.source_id for entry in group.members]
        """
    @property
    def source_name(self) -> builtins.str:
        r"""
        Return the finalized display name assigned to the source diagram.

        Examples
        --------
        Using the setup in the ``GroupMember`` class example:

        >>> source_names = [entry.source_name for entry in group.members]
        """
    @property
    def diagram(self) -> builtins.int:
        r"""
        Return the collapsed master index in ``GenerationResult.diagrams``.

        Examples
        --------
        Using the setup in the ``GroupMember`` class example:

        >>> result.diagrams[result.groups[0].members[0].diagram]
        """
    @property
    def ratio(self) -> builtins.str:
        r"""
        Return the member numerator divided by the group master numerator.

        Examples
        --------
        Using the setup in the ``GroupMember`` class example:

        >>> relative_weights = [entry.ratio for entry in group.members]
        """
    def ratio_expression(self) -> Expression:
        r"""
        Parse the numerator ratio as a native Symbolica expression.

        Examples
        --------
        Using the setup in the ``GroupMember`` class example:

        >>> ratio = result.groups[0].members[0].ratio_expression()
        """
    def overall_factor_expression(self) -> Expression:
        r"""
        Parse the source diagram's numerator-independent factor.

        Examples
        --------
        Using the setup in the ``GroupMember`` class example:

        >>> group = result.groups[0]
        >>> member = group.members[0]
        >>> master = result.diagrams[group.master]
        >>> reconstructed = (member.overall_factor_expression()
        ...                  * member.ratio_expression()
        ...                  * master.numerator_expression())
        >>> reconstructed
        """

@typing.final
class Helicity:
    r"""
    A spin projection along a particle's direction of motion.

    HEP represents the physical minus, longitudinal, and plus helicity
    states by the integers -1, 0, and 1.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> incoming_fermion_helicity = hep.Helicity(-1)
    >>> incoming_fermion_helicity == hep.Helicity.MINUS
    True

    Parameters
    ----------
    value : int
        Helicity value; must be -1, 0, or 1.
    """
    MINUS: Helicity
    r"""
    Return the negative-helicity singleton.

    Examples
    --------
    >>> int(Helicity.MINUS)
    -1
    """
    ZERO: Helicity
    r"""
    Return the zero-helicity singleton.

    Examples
    --------
    >>> int(Helicity.ZERO)
    0
    """
    PLUS: Helicity
    r"""
    Return the positive-helicity singleton.

    Examples
    --------
    >>> int(Helicity.PLUS)
    1
    """
    @property
    def value(self) -> builtins.int:
        r"""
        Return the helicity as -1, 0, or 1.

        Examples
        --------
        Using the setup in the ``Helicity`` class example:

        >>> hep.Helicity.PLUS.value
        1
        """
    def __new__(cls, value: builtins.int) -> Helicity:
        r"""
        Construct a physical helicity from -1, 0, or 1.

        Examples
        --------
        Using the setup in the ``Helicity`` class example:

        >>> helicity = hep.Helicity(-1)

        Parameters
        ----------
        value : int
            Integer helicity value.
        """
    @staticmethod
    def parse(value: builtins.str) -> Helicity:
        r"""
        Parse a named, signed, or integer helicity value.

        Examples
        --------
        Using the setup in the ``Helicity`` class example:

        >>> hep.Helicity.parse("+") == hep.Helicity.PLUS
        True

        Parameters
        ----------
        value : str
            Helicity spelling such as ``"-"``, ``"0"``, or ``"+"``.
        """
    def __int__(self) -> builtins.int:
        r"""
        Convert this helicity to its integer value.

        Examples
        --------
        Using the setup in the ``Helicity`` class example:

        >>> int(hep.Helicity.MINUS)
        -1
        """
    def __eq__(self, other: typing.Any) -> builtins.bool:
        r"""
        Compare with another helicity value.

        Examples
        --------
        Using the setup in the ``Helicity`` class example:

        >>> hep.Helicity(0) == hep.Helicity.ZERO
        True

        Parameters
        ----------
        other : object
            Object to compare with this helicity value.
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return an evaluable-style representation of this helicity.

        Examples
        --------
        Using the setup in the ``Helicity`` class example:

        >>> print(f"selected external helicity: {hep.Helicity.PLUS!r}")
        """

@typing.final
class IntegralFamily:
    r"""
    An ordered set of inverse propagators sharing loop momenta and external kinematics.

    Pass denominators such as ``k.k - m2``, not their reciprocals. An integral
    with powers ``[a1, a2, ...]`` has integrand ``1/(D1**a1 * D2**a2 * ...)``:
    zero powers omit a denominator and negative powers put it in the numerator.
    All power vectors and denominator labels follow the original input order.

    Declare independent external momenta and their scalar products through
    ``Kinematics``. ``is_independent`` checks the denominator basis for linear
    dependence; ``is_complete`` checks whether it spans every loop scalar product.
    For L loops and E independent external momenta this space has
    L*(L+1)/2 + L*E coordinates. ``complete()`` returns a new family with missing
    coordinates appended; give these auxiliary slots nonpositive integral powers.
    Use ``partial_fraction()`` before completion when denominators are dependent.

    Use this class to rewrite scalar numerators, compare momentum routings, test
    scalelessness, and construct Symanzik polynomials. Reduction is provided by
    ``hep.IBPFamily`` or, for one loop, ``hep.oneloop.reduce``. No integration
    prescription or loop-measure normalization is inferred by this container.

    Examples
    --------
    Build a massless bubble with external virtuality ``p.p = s``. The method
    examples below reuse this family and its symbols.

    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> D, k, p, s = S("D", "k", "p", "s")
    >>> d1, d2, x1, x2 = S("d1", "d2", "x1", "x2")
    >>> kin = hep.Kinematics(D, momenta=[k, p]).with_scalar_product(p, p, s)
    >>> denominators = [kin.scalar_product(k, k), kin.scalar_product(k-p, k-p)]
    >>> family = hep.IntegralFamily([k], [p], denominators, kinematics=kin)
    >>> assert family.rank == 2 and family.is_complete and family.is_independent
    >>> rewritten = family.rewrite_numerator(kin.scalar_product(k, p), [d1, d2])
    >>> assert (rewritten - (d1 - d2 + s)/2).expand() == E("0")
    >>> U, F = family.symanzik([x1, x2])
    >>> assert U == x1 + x2
    """
    @property
    def loop_momenta(self) -> builtins.list[Expression]:
        r"""
        Integrated momentum names in their original order.

        Examples
        --------
        Using the setup in the ``IntegralFamily`` class example:

        >>> assert family.loop_momenta == [k]
        """
    @property
    def kinematics(self) -> Kinematics:
        r"""
        Scoped kinematics, including the family momentum declarations.

        Examples
        --------
        Using the setup in the ``IntegralFamily`` class example:

        >>> assert family.kinematics.scalar_product(p, p) == s
        """
    @property
    def external_momenta(self) -> builtins.list[Expression]:
        r"""
        Independent external momentum names in their original order.

        Examples
        --------
        Using the setup in the ``IntegralFamily`` class example:

        >>> assert family.external_momenta == [p]
        """
    @property
    def scalar_products(self) -> builtins.list[Expression]:
        r"""
        Loop-loop and loop-external products spanning the numerator space.

        Examples
        --------
        Using the setup in the ``IntegralFamily`` class example:

        >>> assert len(family.scalar_products) == 2
        """
    @property
    def denominators(self) -> builtins.list[Expression]:
        r"""
        Ordered inverse propagators, including any auxiliary completion terms.

        Examples
        --------
        Using the setup in the ``IntegralFamily`` class example:

        >>> assert family.denominators == denominators
        >>> weighted = list(zip(family.denominators, [1, 2]))
        """
    @property
    def rank(self) -> builtins.int:
        r"""
        Number of independent affine forms in the loop scalar products.

        Examples
        --------
        Using the setup in the ``IntegralFamily`` class example:

        >>> assert family.rank == 2
        """
    @property
    def is_complete(self) -> builtins.bool:
        r"""
        Whether the inverse propagators span every loop scalar product.

        Examples
        --------
        Using the setup in the ``IntegralFamily`` class example:

        >>> assert family.is_complete
        >>> assert family.rank == len(family.scalar_products)
        """
    @property
    def is_independent(self) -> builtins.bool:
        r"""
        Whether no denominator can be eliminated by an affine relation.

        Examples
        --------
        Using the setup in the ``IntegralFamily`` class example:

        >>> assert family.is_independent
        >>> assert family.rank == len(family.denominators)
        """
    @staticmethod
    def from_diagram(diagram: FeynmanDiagram, independent_dot_products: typing.Optional[typing.Sequence[Expression]] = None, *, kinematics: typing.Optional[Kinematics] = None) -> IntegralFamily:
        r"""
        Build a complete family from the diagram's routed internal propagators.

        Graph propagators retain their edge order and model masses. Preferred
        independent dot products are appended in order when they increase the
        rank; automatic scalar products fill any remaining directions. Auxiliary
        denominators have nonpositive powers when representing the original
        integral. Tree diagrams and dependent graph propagators raise DiagramError.
        Use ``diagram.propagator_family()`` to extract dependent propagators for
        partial fractioning before completing the resulting families.

        Examples
        --------
        >>> from symbolica import S, E
        >>> from symbolica.community import hepkit as hep
        >>> model = hep.Model.phi4()
        >>> process = model.process(["phi", "phi"], ["phi", "phi"])
        >>> result = process.generate_diagrams(loops=1)
        >>> diagram = result.diagrams[0]
        >>> family = hep.IntegralFamily.from_diagram(diagram)
        >>> assert family.is_complete

        Parameters
        ----------
        diagram : FeynmanDiagram
            A complete diagram with its chosen loop-momentum routing.
        independent_dot_products : list[Expression] or None, optional
            Preferred auxiliary inverse propagators in the routed momenta.
            None selects a suitable basis automatically.
        kinematics : Kinematics or None, optional
            External assumptions and dimension; defaults to the diagram's
            symbolic dimension with no on-shell assumptions.
        """
    def __new__(cls, loop_momenta: typing.Sequence[Expression], external_momenta: typing.Sequence[Expression], denominators: typing.Sequence[Expression], *, kinematics: typing.Optional[Kinematics] = None) -> IntegralFamily:
        r"""
        Compute the independent loop scalar products and denominator rank.

        Examples
        --------
        >>> from symbolica import S, E
        >>> from symbolica.community import hepkit as hep
        >>> D, k, p, s = S("D", "k", "p", "s")
        >>> d1, d2, x1, x2 = S("d1", "d2", "x1", "x2")
        >>> kin = hep.Kinematics(D, momenta=[k, p]).with_scalar_product(p, p, s)
        >>> denominators = [kin.scalar_product(k, k), kin.scalar_product(k-p, k-p)]
        >>> family = hep.IntegralFamily([k], [p], denominators, kinematics=kin)
        >>> assert family.rank == 2

        Parameters
        ----------
        loop_momenta : list[Expression]
            Distinct unindexed integrated momentum names.
        external_momenta : list[Expression]
            Independent unindexed external momentum names.
        denominators : list[Expression]
            Ordered inverse propagators, not their reciprocals.
        kinematics : Kinematics | None
            External assumptions and dimension; defaults to unconstrained 4D.
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return a compact summary of the family and its scalar-product rank.

        Examples
        --------
        Using the setup in the ``IntegralFamily`` class example:

        >>> print(family)
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Display ordered inverse propagators and family metadata in a notebook.

        Expressions use Symbolica's native HTML printer.

        Examples
        --------
        Using the setup in the ``IntegralFamily`` class example:

        >>> from IPython.display import display
        >>> display(family)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the summary and ordered denominators using Symbolica's text printer.

        Examples
        --------
        Using the setup in the ``IntegralFamily`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(family)

        Parameters
        ----------
        pretty : object
            IPython's pretty printer, providing a ``text`` method.
        cycle : bool
            Whether this family is part of a recursive formatting cycle.
        """
    def complete(self, *, candidates: typing.Optional[typing.Sequence[Expression]] = None) -> IntegralFamily:
        r"""
        Complete a basis, preferring supplied inverse propagators.

        Original propagators retain their positions. Dependent families must
        first be partial-fractioned. Added propagators carry nonpositive powers
        when used to represent numerator factors in an IBP integral list.
        Candidates are tried in order after applying this family's kinematics.
        Redundant candidates are skipped; bare scalar products fill any missing
        directions. All candidates must be affine in the loop scalar products.

        Examples
        --------
        Using the bubble setup in ``IntegralFamily``:

        >>> incomplete = hep.IntegralFamily([k], [p], denominators[:1], kinematics=kin)
        >>> completed = incomplete.complete()
        >>> assert not incomplete.is_complete and completed.is_complete
        >>> assert completed.denominators[0] == denominators[0]
        >>> powers = [1, 0]  # the appended slot is absent from the original integral

        Parameters
        ----------
        candidates : list[Expression] | None
            Preferred auxiliary inverse propagators in this family's momentum
            coordinates. Defaults to using only bare scalar products.
        """
    def partial_fraction(self, powers: typing.Sequence[builtins.int], *, max_states: builtins.int = 100000) -> builtins.list[tuple[Expression, builtins.list[builtins.int]]]:
        r"""
        Partial-fraction dependent propagators while preserving family order.

        Both affine mass shifts and homogeneous dependencies are supported.
        The identity is algebraic: no momentum shifts or scaleless-term removal
        are applied. Impose exceptional kinematics before building the family;
        generic external invariants may appear in the returned coefficients.

        Examples
        --------
        Using the symbols and kinematics in ``IntegralFamily``:

        >>> m2 = S("m2")
        >>> dependent = hep.IntegralFamily([k], [], [kin.scalar_product(k, k),
        ...     kin.scalar_product(k, k) - m2], kinematics=kin)
        >>> terms = dependent.partial_fraction([1, 1])
        >>> assert all(sum(power > 0 for power in powers) == 1 for coefficient, powers in terms)

        Parameters
        ----------
        powers : list[int]
            Signed powers in family order; negative powers are numerator factors.
        max_states : int
            Maximum number of intermediate exponent vectors; defaults to 100000.

        Returns
        -------
        list[tuple[Expression, list[int]]]
            Coefficients and powers whose positive-power denominators are independent.
        """
    def mapping_to(self, target: IntegralFamily, loop_images: typing.Sequence[Expression]) -> typing.Optional[IntegralMapping]:
        r"""
        Verify explicit source-loop images in another family's coordinates.

        Real affine images must have loop determinant +1 or -1 and map every
        source propagator to a distinct equal target propagator. External names,
        dimensions and scalar-product assumptions must agree. Additional target
        propagators are allowed for subtopology embeddings.

        Examples
        --------
        Using the bubble setup in ``IntegralFamily``:

        >>> mapping = family.mapping_to(family, [k])
        >>> assert mapping.map_powers([1, 2]) == [1, 2]

        Parameters
        ----------
        target : IntegralFamily
            Family in whose coordinates the images are expressed.
        loop_images : list[Expression]
            One image per source loop momentum, in source order.

        Returns
        -------
        IntegralMapping | None
            Verified mapping, or None when the images fail the equivalence checks.
        """
    def find_mapping(self, target: IntegralFamily, *, max_candidates: builtins.int = 100000) -> typing.Optional[IntegralMapping]:
        r"""
        Find a verified affine loop-momentum shift into the target family.

        Search derives candidates from independent quadratic propagators, then
        checks every propagator, including eikonal and auxiliary entries. It
        includes loop mixtures, reversals and external shifts. It does not test
        parametric identities that have no affine loop-momentum map.

        Examples
        --------
        Using the bubble setup in ``IntegralFamily``:

        >>> target = hep.IntegralFamily([k], [p], list(reversed(denominators)), kinematics=kin)
        >>> mapping = family.find_mapping(target)
        >>> assert mapping is not None
        >>> transformed = mapping.apply(kin.scalar_product(k, p))

        Parameters
        ----------
        target : IntegralFamily
            Target family with the same external kinematics and loop count.
        max_candidates : int
            Candidate budget; exhaustion raises IntegralFamilyError.

        Returns
        -------
        IntegralMapping | None
            Verified mapping, or None if no supported candidate matches.
        """
    @staticmethod
    def find_mappings(families: typing.Sequence[IntegralFamily], *, max_candidates: builtins.int = 100000) -> builtins.list[tuple[builtins.int, IntegralMapping]]:
        r"""
        Group families and return verified maps to their representatives.

        Returns one ``(target_index, mapping)`` per input family in input order.
        Indices refer to the original list. Representatives map to themselves;
        every other mapping goes directly to a retained representative.
        The first compatible representative wins. Symbolica canonizes each
        Symanzik pair once, then native affine-shift search verifies all merges.
        A parametric equivalence without a verified loop map remains separate.

        Families need compatible external kinematics and nonsingular quadratic
        forms. Unsupported shift searches and exhausted budgets raise errors.
        Different propagator counts stay separate. Select sectors and remove
        certified scaleless integrals before grouping; complete bases afterwards.
        This does not exchange external momenta or infer integration prescriptions.

        Examples
        --------
        Using the bubble setup in ``IntegralFamily``:

        >>> families = [family, family]
        >>> mappings = hep.IntegralFamily.find_mappings(families)
        >>> assert [target for target, mapping in mappings] == [0, 0]

        Parameters
        ----------
        families : list[IntegralFamily]
            Ordered families; earlier entries are preferred as representatives.
        max_candidates : int
            Affine-shift candidate budget per pair; exhaustion raises an error.

        Returns
        -------
        list[tuple[int, IntegralMapping]]
            Target index and verified map for each input, including representatives.
        """
    def sector(self, powers: typing.Sequence[builtins.int]) -> IntegralFamily:
        r"""
        Select the positive-power propagators of an integral's sector.

        Zero and negative powers are omitted. Loop variables and external
        kinematics are retained. This selects sector support; it does not remove
        numerator factors algebraically from the original integrand.

        Examples
        --------
        Using the bubble setup in ``IntegralFamily``:

        >>> sector = family.sector([1, 0])
        >>> assert sector.denominators == denominators[:1]

        Parameters
        ----------
        powers : list[int]
            One signed propagator power per family denominator.
        """
    def scaleless_transverse_direction(self) -> typing.Optional[builtins.list[Expression]]:
        r"""
        Find an unconstrained transverse loop direction proving scalelessness.

        Returns a nonzero real list ``w`` in loop order such that each inverse
        propagator is invariant under ``k_i -> k_i + w_i*r_perp`` for any
        vector orthogonal to the external span. The corresponding unrestricted
        transverse integral vanishes in dimensional regularization, including
        polynomial numerators. Apply ``sector(powers)`` first to exclude
        numerator-only entries.

        Requires a nonsingular external Gram matrix. Symbolic dimension is
        interpreted generically; a concrete dimension must exceed the external
        basis size. None means no certificate was found. A vanishing Symanzik U
        alone is not sufficient, and complex loop directions are not accepted.

        Examples
        --------
        Using the bubble setup in ``IntegralFamily``:

        >>> empty_sector = family.sector([0, 0])
        >>> direction = empty_sector.scaleless_transverse_direction()
        >>> assert direction is not None  # no denominators constrain the loop momentum

        Returns
        -------
        list[Expression] | None
            Verified real loop direction, or no certificate.
        """
    def scaleless_scaling(self, parameters: typing.Sequence[Expression]) -> typing.Optional[builtins.list[Expression]]:
        r"""
        Find parameter weights proving a sector scaleless in dimensional regularization.

        For G=U+F, the returned weights satisfy sum(w_i*x_i*dG/dx_i)=G.
        None means this criterion did not detect scalelessness, not that the
        integral is nonzero. Every denominator is treated as present; use
        ``sector(powers)`` first to select positive-power entries. Singular
        quadratic loop forms raise IntegralFamilyError: their algebraic U/F
        polynomials do not establish this parametric scaling certificate.

        Examples
        --------
        Using the bubble setup in ``IntegralFamily``:

        >>> tadpole = family.sector([1, 0])
        >>> weights = tadpole.scaleless_scaling([x1])
        >>> assert weights is not None  # massless tadpole vanishes in dimensional regularization

        Parameters
        ----------
        parameters : list[Expression]
            One distinct new symbol or labeled call per sector denominator.

        Returns
        -------
        list[Expression] | None
            Exact scaling weights in parameter order, or no certificate.
        """
    def parametric_mapping(self, target: IntegralFamily, parameters: typing.Sequence[Expression]) -> typing.Optional[PropagatorMapping]:
        r"""
        Find a parameter permutation identifying both Symanzik polynomials.

        Symbolica canonizes polynomial incidence graphs, preserving coefficients,
        powers and the distinction between U and F. This can identify families
        without a loop shift at fixed external momenta. The result supplies no
        momentum or tensor-numerator substitution and does not check contours or
        propagator prescriptions. Both families must have equal denominator
        counts and the same external kinematics. Singular quadratic forms are
        rejected because their U/F polynomials can discard physical parameters.

        Examples
        --------
        Using the bubble setup in ``IntegralFamily``:

        >>> target = hep.IntegralFamily([k], [p], list(reversed(denominators)), kinematics=kin)
        >>> mapping = family.parametric_mapping(target, [x1, x2])
        >>> assert mapping is not None
        >>> mapped_powers = mapping.map_powers([1, 2])

        Parameters
        ----------
        target : IntegralFamily
            Family whose U and F polynomials are compared.
        parameters : list[Expression]
            One distinct new symbol or labeled call per source denominator.

        Returns
        -------
        PropagatorMapping | None
            Formal parameter permutation, or None if the polynomials differ.
        """
    def symanzik(self, parameters: typing.Sequence[Expression]) -> tuple[Expression, Expression]:
        r"""
        Compute the Symanzik polynomials U and F in propagator order.

        Uses Minkowski inverse propagators: k^2-m^2 gives U=x and F=m^2*x^2.
        For a weighted denominator k.M.k + 2 k.Q + J, this returns
        U=det(M) and F=Q.adj(M).Q-U*J, using Symbolica determinants and cofactors.
        Singular quadratic forms are accepted as algebraic polynomial data;
        they do not establish a Gaussian integration formula or scalelessness.
        This prepares polynomials without performing integration.

        Examples
        --------
        Using the setup in the ``IntegralFamily`` class example:

        >>> U, F = family.symanzik([x1, x2])
        >>> assert U == x1 + x2  # two standard one-loop propagators

        Parameters
        ----------
        parameters : list[Expression]
            One distinct new symbol or labeled call per inverse propagator.

        Returns
        -------
        tuple[Expression, Expression]
            First and second Symanzik polynomials, respectively.
        """
    def scalar_product_rules(self, labels: typing.Sequence[Expression]) -> builtins.list[tuple[Expression, Expression]]:
        r"""
        Solve loop scalar products in terms of inverse-propagator labels.

        Examples
        --------
        Using the setup in the ``IntegralFamily`` class example:

        >>> rules = family.scalar_product_rules([d1, d2])
        >>> assert len(rules) == 2

        Parameters
        ----------
        labels : list[Expression]
            One distinct symbol or labeled call per denominator, in family order.

        Returns
        -------
        list[tuple[Expression, Expression]]
            Simultaneous replacement pairs for an independent, complete family.
        """
    def rewrite_numerator(self, numerator: Expression, labels: typing.Sequence[Expression]) -> Expression:
        r"""
        Rewrite a numerator in inverse-propagator variables and expand it.

        Examples
        --------
        Using the setup in the ``IntegralFamily`` class example:

        >>> numerator = kin.scalar_product(k, p)**2
        >>> reduced = family.rewrite_numerator(numerator, [d1, d2])

        Parameters
        ----------
        numerator : Expression
            Scalar numerator after tensor reduction and momentum routing.
        labels : list[Expression]
            One distinct symbol or labeled call per denominator, in family order.
        """
    def sector_decompose(self, *, regulator: symbolica.Expression, kinematics: typing.Optional[Kinematics] = None, dimension: typing.Optional[symbolica.Expression] = None, powers: typing.Optional[typing.Sequence[int]] = None, numerator: typing.Optional[symbolica.Expression] = None, scalar_values: typing.Optional[typing.Dict[symbolica.Expression, symbolica.Expression]] = None, auxiliary_momenta: typing.Optional[typing.Sequence[symbolica.Expression]] = None, measure_multiplier: typing.Optional[symbolica.Expression] = None, max_order: int = 0, coefficient_expansion: str = 'physical', observer: typing.Optional[typing.Callable[[symbolica.community.hepkit.sector_decomposition.GenerationSnapshot], typing.Optional[bool]]] = None, progress: typing.Union[typing.Literal["auto"], typing.Callable[[symbolica.community.hepkit.sector_decomposition.GenerationSnapshot], typing.Optional[bool]], None] = 'auto') -> symbolica.community.hepkit.sector_decomposition.GeneratedIntegral:
        r"""
        Generate Laurent integrands for an explicit family member.

        Examples
        --------
        For a numerical family, with powers in native denominator order:

        >>> from symbolica import E, S
        >>> from symbolica.community import hepkit as hep
        >>> eps, D, k = S("eps", "D", "k")
        >>> point = hep.Kinematics(D, momenta=[k])
        >>> family = hep.IntegralFamily([k], [], [point.scalar_product(k, k) - 1], kinematics=point)
        >>> generated = family.sector_decompose(regulator=eps, powers=[2], numerator=E("1"), progress=None)
        >>> kernels = generated.compile()

        Parameters
        ----------
        regulator : Expression
            Dimensional regulator symbol.
        kinematics : Kinematics or None
            Explicit point; None retains the family's scoped kinematics.
        dimension : Expression or None
            Integration dimension; defaults to 4 - 2*regulator.
        powers : sequence[int]
            Required signed powers; zero omits a slot and negative moves it to the numerator.
        numerator : Expression
            Required scalar numerator including explicit physical weights once.
        scalar_values : mapping[Expression, Expression] or None
            Explicit scalar substitutions applied consistently to the family.
        auxiliary_momenta : sequence[Expression] or None
            Additional external vector heads, such as polarizations.
        measure_multiplier : Expression or None
            Explicit multiplicative measure convention, applied once.
        max_order : int
            Largest signed epsilon power retained.
        coefficient_expansion : str
            Native physical or package coefficient convention.
        observer : callable or None
            Native generation events; False cancels at an event boundary.
        progress : "auto", callable or None
            Automatic marimo display unless observer is supplied; None disables it.
            A callable receives every native event after observer and may cancel.
        """

class IntegralFamilyError(FeynkitError):
    r"""
    Invalid loop-integral family, dependent propagators, or incomplete scalar-product basis.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> D, k, p, s = S("D", "k", "p", "s")
    >>> d1, d2, x1, x2 = S("d1", "d2", "x1", "x2")
    >>> kin = hep.Kinematics(D, momenta=[k, p]).with_scalar_product(p, p, s)
    >>> denominators = [kin.scalar_product(k, k), kin.scalar_product(k-p, k-p)]
    >>> family = hep.IntegralFamily([k], [p], denominators, kinematics=kin)
    >>> try:
    ...     hep.IntegralFamily([k], [p], [denominators[0], denominators[0]], kinematics=kin).complete()
    ... except hep.IntegralFamilyError as error:
    ...     message = str(error)
    """
    ...

@typing.final
class IntegralMapping:
    r"""
    A verified real loop-momentum shift and propagator embedding.

    Obtain a mapping from ``IntegralFamily.find_mapping`` or ``mapping_to``.
    The loop determinant has absolute value one, so the loop integration measure
    is unchanged. Numerator substitutions use the same scalar-product rules
    that verified the propagator identities.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> D, k, p, s = S("D", "k", "p", "s")
    >>> d1, d2, x1, x2 = S("d1", "d2", "x1", "x2")
    >>> kin = hep.Kinematics(D, momenta=[k, p]).with_scalar_product(p, p, s)
    >>> denominators = [kin.scalar_product(k, k), kin.scalar_product(k-p, k-p)]
    >>> family = hep.IntegralFamily([k], [p], denominators, kinematics=kin)
    >>> m2 = S("m2")
    >>> denominators = [denominators[0] - m2, denominators[1]]
    >>> source = hep.IntegralFamily([k], [p], denominators, kinematics=kin)
    >>> target = hep.IntegralFamily([k], [p], list(reversed(denominators)), kinematics=kin)
    >>> mapping = source.find_mapping(target)
    >>> assert mapping is not None
    >>> target_powers = mapping.map_powers([1, 2])
    >>> assert target_powers == [2, 1]
    """
    @property
    def momentum_rules(self) -> builtins.list[tuple[Expression, Expression]]:
        r"""
        Source loop momentum names paired with their target-coordinate images.

        Examples
        --------
        Using the setup in the ``IntegralMapping`` class example:

        >>> loop_substitutions = mapping.momentum_rules
        """
    @property
    def denominator_map(self) -> builtins.list[builtins.int]:
        r"""
        Zero-based target denominator index for each source denominator.

        Examples
        --------
        Using the setup in the ``IntegralMapping`` class example:

        >>> mapped_powers = mapping.map_powers([1, 2])
        >>> slot_map = mapping.denominator_map
        """
    def map_powers(self, powers: typing.Sequence[builtins.int]) -> builtins.list[builtins.int]:
        r"""
        Reorder signed powers and insert zeros for unused target propagators.

        Examples
        --------
        Using the setup in the ``IntegralMapping`` class example:

        >>> powers = mapping.map_powers([1, 2])

        Parameters
        ----------
        powers : list[int]
            One signed power per source denominator, in source order.
        """
    def apply(self, expression: Expression) -> Expression:
        r"""
        Apply the verified scalar-product substitutions simultaneously.

        Examples
        --------
        Using the setup in ``IntegralMapping``:

        >>> transformed = mapping.apply(kin.scalar_product(k, p))

        Parameters
        ----------
        expression : Expression
            Scalar expression in compact Spenso dot notation; contract tensors first.
        """

@typing.final
class Jet:
    r"""
    A reconstructed collider jet and its input-particle constituents.

    Jets are returned by ``JetDefinition.cluster`` and expose the recombined
    four-momentum together with the indices of their original inputs.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> particles = [hep.FourMomentum(50.0, 30.0, 40.0, 0.0),
    ...              hep.FourMomentum(25.0, -15.0, -20.0, 0.0)]
    >>> definition = hep.JetDefinition.anti_kt(radius=0.4, minimum_pt=20.0)
    >>> clustering = definition.cluster(particles)
    >>> jets = clustering.jets
    >>> leading_jet = jets[0]
    >>> assert leading_jet.pt == 50.0
    >>> inputs = [particles[i] for i in leading_jet.constituent_indices]
    """
    @property
    def momentum(self) -> FourMomentum:
        r"""
        Return the recombined four-momentum of this jet.

        Examples
        --------
        Using the setup in the ``Jet`` class example:

        >>> assert leading_jet.momentum.pt == leading_jet.pt
        """
    @property
    def constituent_indices(self) -> builtins.list[builtins.int]:
        r"""
        Return sorted positions of the input momenta assigned to this jet.

        Examples
        --------
        Using the setup in the ``Jet`` class example:

        >>> inputs = [particles[i] for i in leading_jet.constituent_indices]
        """
    @property
    def pt(self) -> builtins.float:
        r"""
        Return the jet transverse momentum.

        Examples
        --------
        Using the setup in the ``Jet`` class example:

        >>> assert leading_jet.pt == 50.0
        """
    @property
    def rapidity(self) -> builtins.float:
        r"""
        Return the jet rapidity.

        Examples
        --------
        Using the setup in the ``Jet`` class example:

        >>> assert leading_jet.rapidity == 0.0
        """
    @property
    def phi(self) -> builtins.float:
        r"""
        Return the jet azimuthal angle in radians.

        Examples
        --------
        Using the setup in the ``Jet`` class example:

        >>> azimuth = leading_jet.phi
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return a concise jet summary with its kinematics and constituent count.

        Examples
        --------
        Using the setup in the ``Jet`` class example:

        >>> summary = repr(leading_jet)
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Render the jet kinematics as a compact notebook table.

        Examples
        --------
        Using the setup in the ``Jet`` class example:

        >>> from IPython.display import display
        >>> display(leading_jet)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the concise jet summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``Jet`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(leading_jet)

        Parameters
        ----------
        pretty : object
            The IPython pretty-printer object.
        cycle : bool
            Whether this object is part of a recursive formatting cycle.
        """

@typing.final
class JetDefinition:
    r"""
    A generalized-kT jet definition for sequential recombination.

    The definition selects the distance measure, jet radius, and transverse-
    momentum threshold used to reconstruct jets from final-state momenta.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> particles = [hep.FourMomentum(50.0, 30.0, 40.0, 0.0),
    ...              hep.FourMomentum(25.0, -15.0, -20.0, 0.0)]
    >>> definition = hep.JetDefinition.anti_kt(radius=0.4, minimum_pt=20.0)
    >>> clustering = definition.cluster(particles)
    >>> assert definition.radius == 0.4
    >>> assert len(clustering.jets) == 2

    Parameters
    ----------
    algorithm : JetAlgorithm
        Generalized-kT algorithm to use.
    radius : float
        Jet-radius parameter.
    minimum_pt : float, optional
        Minimum transverse momentum of returned jets.
    """
    @property
    def algorithm(self) -> JetAlgorithm:
        r"""
        Return the selected clustering algorithm.

        Examples
        --------
        Using the setup in the ``JetDefinition`` class example:

        >>> assert definition.algorithm == hep.JetAlgorithm.AntiKt
        """
    @property
    def radius(self) -> builtins.float:
        r"""
        Return the jet-radius parameter.

        Examples
        --------
        Using the setup in the ``JetDefinition`` class example:

        >>> assert definition.radius == 0.4
        """
    @property
    def minimum_pt(self) -> builtins.float:
        r"""
        Return the minimum transverse momentum for retained jets.

        Examples
        --------
        Using the setup in the ``JetDefinition`` class example:

        >>> assert definition.minimum_pt == 20.0
        """
    def __new__(cls, algorithm: JetAlgorithm, radius: builtins.float, minimum_pt: builtins.float = 0.0) -> JetDefinition:
        r"""
        Construct a generalized-kT jet definition.

        Examples
        --------
        Using the setup in the ``JetDefinition`` class example:

        >>> definition = hep.JetDefinition(hep.JetAlgorithm.AntiKt, 0.4, 20.0)

        Parameters
        ----------
        algorithm : JetAlgorithm
            Generalized-kT algorithm.
        radius : float
            Jet-radius parameter.
        minimum_pt : float, optional
            Minimum transverse momentum for returned jets.
        """
    @staticmethod
    def kt(radius: builtins.float, minimum_pt: builtins.float = 0.0) -> JetDefinition:
        r"""
        Construct a kT jet definition.

        Examples
        --------
        Using the setup in the ``JetDefinition`` class example:

        >>> definition = hep.JetDefinition.kt(0.4)

        Parameters
        ----------
        radius : float
            Jet-radius parameter.
        minimum_pt : float, optional
            Minimum transverse momentum for returned jets.
        """
    @staticmethod
    def cambridge_aachen(radius: builtins.float, minimum_pt: builtins.float = 0.0) -> JetDefinition:
        r"""
        Construct a Cambridge-Aachen jet definition.

        Examples
        --------
        Using the setup in the ``JetDefinition`` class example:

        >>> definition = hep.JetDefinition.cambridge_aachen(0.4)

        Parameters
        ----------
        radius : float
            Jet-radius parameter.
        minimum_pt : float, optional
            Minimum transverse momentum for returned jets.
        """
    @staticmethod
    def anti_kt(radius: builtins.float, minimum_pt: builtins.float = 0.0) -> JetDefinition:
        r"""
        Construct an anti-kT jet definition.

        Examples
        --------
        Using the setup in the ``JetDefinition`` class example:

        >>> definition = hep.JetDefinition.anti_kt(0.4, minimum_pt=20.0)

        Parameters
        ----------
        radius : float
            Jet-radius parameter.
        minimum_pt : float, optional
            Minimum transverse momentum for returned jets.
        """
    def cluster(self, momenta: typing.Sequence[FourMomentum]) -> ClusteringResult:
        r"""
        Cluster four-momenta with this sequential-recombination definition.

        Examples
        --------
        Using the setup in the ``JetDefinition`` class example:

        >>> result = definition.cluster(particles)
        >>> assert len(result.jets) == 2

        Parameters
        ----------
        momenta : sequence of FourMomentum
            Input four-momenta to cluster.
        """

@typing.final
class Kinematics:
    r"""
    Scoped symbolic scalar products and two-to-two Mandelstam kinematics.

    The immutable object uses Spenso's dot products and metric
    shorthand. Apply it after contracting tensors with Idenso. Momentum inputs
    are unindexed names, and mass inputs are squared masses.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> P = hep.Kinematics.external_momentum()
    >>> p1, p2, p3, p4 = [P(i) for i in range(4)]
    >>> s, t, u = hep.Kinematics.s(), hep.Kinematics.t(), hep.Kinematics.u()
    >>> kin = hep.Kinematics.mandelstam([p1, p2, p3, p4], [E("0")]*4, [s, t, u])
    >>> assert kin.scalar_product(p1, p2) == s/2
    """
    @property
    def dimension(self) -> Expression:
        r"""
        Lorentz dimension as a Symbolica integer or symbol.

        Examples
        --------
        Using the setup in the ``Kinematics`` class example:

        >>> assert hep.Kinematics(S("D")).dimension == S("D")
        """
    @staticmethod
    def s() -> Expression:
        r"""
        Mandelstam invariant ``s=(p1+p2)^2`` for ``p1 + p2 -> p3 + p4``.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> s = hep.Kinematics.s()
        """
    @staticmethod
    def t() -> Expression:
        r"""
        Mandelstam invariant ``t=(p1-p3)^2`` for ``p1 + p2 -> p3 + p4``.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> t = hep.Kinematics.t()
        """
    @staticmethod
    def u() -> Expression:
        r"""
        Mandelstam invariant ``u=(p1-p4)^2`` for ``p1 + p2 -> p3 + p4``.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> u = hep.Kinematics.u()
        """
    @staticmethod
    def external_momentum() -> Expression:
        r"""
        External momentum family indexed by physical leg.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> reference = hep.Kinematics.external_momentum()
        """
    @staticmethod
    def loop_momentum() -> Expression:
        r"""
        Loop momentum family indexed by loop basis position.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> reference = hep.Kinematics.loop_momentum()
        """
    def __new__(cls, dimension: typing.Optional[Expression] = None, *, momenta: typing.Optional[typing.Sequence[Expression]] = None) -> Kinematics:
        r"""
        Start with no scalar-product assumptions in the chosen dimension.

        Examples
        --------
        Using the setup in the ``Kinematics`` class example:

        >>> kin = hep.Kinematics()
        >>> dimensional = hep.Kinematics(S("D"))

        Parameters
        ----------
        dimension : Expression | None
            Integer or symbolic Lorentz dimension; defaults to four.
        momenta : list[Expression] | None
            Momentum names used in linear combinations with scalar coefficients.
        """
    @staticmethod
    def mandelstam(momenta: typing.Sequence[Expression], mass_squared: typing.Sequence[Expression], invariants: typing.Sequence[Expression]) -> Kinematics:
        r"""
        Set the invariants for ``p1 + p2 -> p3 + p4``.

        The convention is ``s=(p1+p2)^2``, ``t=(p1-p3)^2``, and
        ``u=(p1-p4)^2``. These obey ``s+t+u=sum(mass_squared)``; use Symbolica
        substitution when you want to eliminate one invariant.

        Examples
        --------
        Using the setup in the ``Kinematics`` class example:

        >>> kin = hep.Kinematics.mandelstam([p1, p2, p3, p4], [E("0")]*4, [s, t, u])

        Parameters
        ----------
        momenta : list[Expression]
            Four unindexed momenta, with the incoming pair first.
        mass_squared : list[Expression]
            Four squared masses in the same order.
        invariants : list[Expression]
            The three symbols or expressions ``s, t, u``.
        """
    def with_scalar_product(self, left: Expression, right: Expression, value: Expression) -> Kinematics:
        r"""
        Return a new context with one scalar product set.

        Examples
        --------
        Using the setup in the ``Kinematics`` class example:

        >>> p, m = S("p", "m")
        >>> kin = hep.Kinematics(momenta=[p]).with_scalar_product(p, p, m**2)
        >>> assert kin.scalar_product(p, p) == m**2

        Parameters
        ----------
        left : Expression
            First unindexed momentum.
        right : Expression
            Second unindexed momentum.
        value : Expression
            Assumed scalar product.
        """
    def scalar_product(self, left: Expression, right: Expression) -> Expression:
        r"""
        Expand a bilinear scalar product and apply known assumptions.

        For linear combinations, declare the momentum names in the constructor
        or by setting scalar products. Other symbols are scalar coefficients.
        Nonlinear momentum expressions raise ``KinematicsError``.

        Examples
        --------
        Using the setup in the ``Kinematics`` class example:

        >>> assert kin.scalar_product(p1, p2) == s/2
        >>> assert kin.scalar_product(p1 + p2, p1 + p2) == s

        Parameters
        ----------
        left : Expression
            First unindexed momentum or linear combination.
        right : Expression
            Second unindexed momentum or linear combination.
        """
    def flux(self, first: Expression, second: typing.Optional[Expression] = None) -> Expression:
        r"""
        Return the initial-state denominator for a cross section or decay rate.

        Two momenta give ``4*sqrt((p1.p2)**2-p1**2*p2**2)``. One momentum
        gives ``2*sqrt(p**2)`` for a decay in its rest frame. Divide the squared
        matrix element times phase space by this value. Inputs must be physical,
        future-directed on-shell momenta. Symbolica retains square-root branches;
        declare positive invariants with ``S("s", is_positive=True)`` when known.

        Examples
        --------
        Using the setup in the ``Kinematics`` class example:

        >>> p1, p2, s = S("p1", "p2", "s")
        >>> kin = hep.Kinematics(momenta=[p1, p2])
        >>> kin = kin.with_scalar_product(p1, p1, E("0")).with_scalar_product(p2, p2, E("0"))
        >>> kin = kin.with_scalar_product(p1, p2, s/2)
        >>> flux = kin.flux(p1, p2)

        Parameters
        ----------
        first : Expression
            Incoming unindexed momentum or declared linear combination.
        second : Expression | None
            Other incoming momentum; None selects a rest-frame decay.
        """
    def two_body_phase_space(self, first: Expression, second: Expression) -> Expression:
        r"""
        Return four-dimensional two-body phase space per unit solid angle.

        This is ``dPhi_2/dOmega`` in the final pair's rest frame, with
        ``(2*pi)**4*delta**4(P-p1-p2)`` and ``d**3p/((2*pi)**3*2E)`` for each
        final particle. Use physical on-shell momenta above threshold. Flux,
        spin/color averages and identical-particle factors are separate. For an
        angle-independent amplitude, integrating this measure gives ``4*pi``
        times the returned expression. Non-four-dimensional contexts are rejected.

        Examples
        --------
        Using the setup in the ``Kinematics`` class example:

        >>> p1, p2, p3, p4, s, t, u = S("p1", "p2", "p3", "p4", "s", "t", "u")
        >>> kin = hep.Kinematics.mandelstam([p1, p2, p3, p4], [E("0")]*4, [s, t, u])
        >>> density = kin.two_body_phase_space(p3, p4)

        Parameters
        ----------
        first : Expression
            First outgoing unindexed momentum or declared linear combination.
        second : Expression
            Second outgoing unindexed momentum or declared linear combination.
        """
    def three_body_phase_space(self, first: Expression, second: Expression, third: Expression) -> Expression:
        r"""
        Return four-dimensional three-body phase space per two Dalitz invariants.

        This is ``dPhi_3/(ds12*ds23) = 1/(128*pi**3*P**2)``, where
        ``P=first+second+third`` and ``sij=(pi+pj)**2``. The overall spatial
        orientation is integrated. Use an orientation-independent or
        orientation-averaged squared amplitude and physical on-shell momenta.
        The measure includes ``(2*pi)**4*delta**4`` and one
        ``d**3p/((2*pi)**3*2E)`` for each final particle.

        Masses constrain the allowed Dalitz region; its boundaries are not
        imposed here. Flux, spin/color averages and identical-particle factors
        remain separate. Non-four-dimensional contexts are rejected.

        Examples
        --------
        Using the setup in the ``Kinematics`` class example:

        >>> k1, k2, k3 = S("k1", "k2", "k3")
        >>> kin = hep.Kinematics(momenta=[k1, k2, k3])
        >>> density = kin.three_body_phase_space(k1, k2, k3)

        Parameters
        ----------
        first, second, third : Expression
            Final-state on-shell momenta. Their scalar products determine the
            total invariant mass squared through this kinematic context.
        """
    @overload
    def apply(self, expression: TensorExpression) -> TensorExpression:
        r"""
        Substitute scalar products without mutating global assumptions.

        Accepts a scalar Expression or a tensor expression. Tensor results retain
        the ordered open slots, including when the result is zero.

        Examples
        --------
        Using the setup in the ``Kinematics`` class example:

        >>> p1, p2, p3, p4, s, t, u = S("p1", "p2", "p3", "p4", "s", "t", "u")
        >>> free = hep.Kinematics(momenta=[p1, p2, p3, p4])
        >>> kin = hep.Kinematics.mandelstam([p1, p2, p3, p4], [E("0")]*4, [s, t, u])
        >>> contracted_expression = free.scalar_product(p1, p2)
        >>> assert kin.apply(contracted_expression) == s/2

        Parameters
        ----------
        expression : Expression
            Expression with compact scalar products.
        """
    @overload
    def apply(self, expression: Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal]) -> Expression:
        r"""
        Substitute scalar products without mutating global assumptions.

        Accepts a scalar Expression or a tensor expression. Tensor results retain
        the ordered open slots, including when the result is zero.

        Examples
        --------
        Using the setup in the ``Kinematics`` class example:

        >>> p1, p2, p3, p4, s, t, u = S("p1", "p2", "p3", "p4", "s", "t", "u")
        >>> free = hep.Kinematics(momenta=[p1, p2, p3, p4])
        >>> kin = hep.Kinematics.mandelstam([p1, p2, p3, p4], [E("0")]*4, [s, t, u])
        >>> contracted_expression = free.scalar_product(p1, p2)
        >>> assert kin.apply(contracted_expression) == s/2

        Parameters
        ----------
        expression : Expression
            Expression with compact scalar products.
        """

class KinematicsError(FeynkitError):
    r"""
    Invalid Lorentz transformation, momentum, or jet-clustering request.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> try:
    ...     hep.JetDefinition.anti_kt(-0.4)
    ... except hep.KinematicsError as error:
    ...     message = str(error)
    """
    ...

@typing.final
class LoadedModel:
    r"""
    A normalized model, its parameter card, and its loading diagnostics.

    This is the complete result returned by ``UfoLoader.load``; use ``model``
    for diagram generation and ``parameters`` for external numerical inputs.

    Examples
    --------
    Replace ``path/to/MyUFO`` with the directory containing your UFO model
    (``particles.py``, ``vertices.py``, and related files).

    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> loaded = hep.UfoLoader().load("path/to/MyUFO")
    >>> model = loaded.model
    >>> particle_names = [particle.name for particle in model.particles]
    >>> parameters = loaded.parameters
    """
    @property
    def model(self) -> Model:
        r"""
        Return the normalized HEP model.

        Examples
        --------
        Using the setup in the ``LoadedModel`` class example:

        >>> model = loaded.model
        >>> particles = model.particles
        """
    @property
    def parameters(self) -> ParameterCard:
        r"""
        Return the parameter card loaded alongside the model.

        Examples
        --------
        Using the setup in the ``LoadedModel`` class example:

        >>> parameters = loaded.parameters
        >>> shifted = loaded.model.with_parameter_card(parameters)
        """
    @property
    def diagnostics(self) -> UfoLoadDiagnostics:
        r"""
        Return counts and options recorded while loading the UFO model.

        Examples
        --------
        Using the setup in the ``LoadedModel`` class example:

        >>> counts = (loaded.diagnostics.particle_count, loaded.diagnostics.vertex_rule_count)
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return a concise summary of the loaded model and its source.

        Examples
        --------
        Using the setup in the ``LoadedModel`` class example:

        >>> print(loaded)
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Render a compact overview of the normalized UFO model.

        Examples
        --------
        Using the setup in the ``LoadedModel`` class example:

        >>> from IPython.display import display
        >>> display(loaded)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the concise loaded-model summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``LoadedModel`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(loaded)

        Parameters
        ----------
        pretty : object
            The IPython pretty-printer object.
        cycle : bool
            Whether this object is part of a recursive formatting cycle.
        """

@typing.final
class LoopMomentumBasis:
    r"""
    A consistent routing of independent loop and external momenta.

    Chords of the spanning tree define the loop momenta; every diagram edge is
    then assigned an integer ``MomentumSignature`` by momentum conservation.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> result = process.generate_diagrams(loops=1)
    >>> diagram = result.diagrams[0]
    >>> basis = diagram.loop_momentum_basis
    >>> assert len(basis.loop_edges) == diagram.loop_count
    >>> assignments = basis.edge_signatures
    """
    @property
    def tree_edges(self) -> builtins.list[builtins.int]:
        r"""
        Return the edge identifiers belonging to the spanning tree.

        Examples
        --------
        Using the setup in the ``LoopMomentumBasis`` class example:

        >>> rerouted = diagram.with_loop_momentum_tree_edges(basis.tree_edges)
        """
    @property
    def loop_edges(self) -> builtins.list[builtins.int]:
        r"""
        Return the edge identifiers chosen as independent loop momenta.

        Examples
        --------
        Using the setup in the ``LoopMomentumBasis`` class example:

        >>> basis = diagram.loop_momentum_bases(limit=1)[0]
        >>> len(basis.loop_edges) == diagram.loop_count
        True
        """
    @property
    def external_edges(self) -> builtins.list[builtins.int]:
        r"""
        Return the identifiers of edges attached to external states.

        Examples
        --------
        Using the setup in the ``LoopMomentumBasis`` class example:

        >>> external_ids = basis.external_edges
        >>> external_routings = [basis.edge_signatures[i] for i in external_ids]
        """
    @property
    def dependent_externals(self) -> builtins.list[builtins.int]:
        r"""
        Return external-edge identifiers fixed by momentum conservation.

        Examples
        --------
        Using the setup in the ``LoopMomentumBasis`` class example:

        >>> basis = diagram.loop_momentum_bases(limit=1)[0]
        >>> set(basis.dependent_externals) <= set(basis.external_edges)
        True
        """
    @property
    def edge_signatures(self) -> builtins.dict[builtins.int, MomentumSignature]:
        r"""
        Return momentum signatures keyed by stable diagram edge ID.

        Examples
        --------
        Using the setup in the ``LoopMomentumBasis`` class example:

        >>> basis = diagram.loop_momentum_bases(limit=1)[0]
        >>> momentum_by_edge = {
        ...     edge_id: signature.format_momentum()
        ...     for edge_id, signature in basis.edge_signatures.items()
        ... }
        >>> for edge in diagram.edges:
        ...     print(edge.particle_name, momentum_by_edge[edge.id])
        """
    def momentum_replacements(self) -> builtins.list[typing.Any]:
        r"""
        Return Symbolica Replacement objects using the same routing as numerical momenta.
        Tensor index arguments are retained on every routed vector.

        Examples
        --------
        Using the setup in the ``LoopMomentumBasis`` class example:

        >>> rules = diagram.loop_momentum_basis.momentum_replacements()
        >>> routed = diagram.numerator_expression().to_expression().replace_multiple(rules)
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return a concise description of the selected momentum basis.

        Examples
        --------
        Using the setup in the ``LoopMomentumBasis`` class example:

        >>> basis = diagram.loop_momentum_bases(limit=1)[0]
        >>> print(basis)
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Return an HTML table of edge momentum assignments for notebooks.

        Examples
        --------
        Using the setup in the ``LoopMomentumBasis`` class example:

        >>> from IPython.display import display
        >>> display(basis)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the basis summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``LoopMomentumBasis`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(basis)

        Parameters
        ----------
        pretty : Any
            The IPython pretty-printer object.
        cycle : bool
            Whether this object is part of a recursive formatting cycle.
        """
    @overload
    def route_expression(self, expression: TensorExpression, *, loop_momenta: typing.Optional[typing.Sequence[TensorName]] = None, external_momenta: typing.Optional[typing.Sequence[TensorName]] = None) -> TensorExpression:
        r"""
        Express edge momenta in this basis while retaining tensor index arguments.

        Examples
        --------
        Using the setup in the ``LoopMomentumBasis`` class example:

        >>> routed = basis.route_expression(diagram.numerator_expression().to_expression())

        Parameters
        ----------
        expression : Expression or number
            Expression with canonical edge momenta to route, or a scalar constant.
        loop_momenta : sequence[TensorName] or None, optional
            Vector names in ``loop_edges`` order. None retains indexed ``K`` calls.
        external_momenta : sequence[TensorName] or None, optional
            Vector names in ``external_edges`` order, excluding ``dependent_externals``.
            None retains indexed ``P`` calls. Naming also applies to already routed vectors.
        """
    @overload
    def route_expression(self, expression: Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal], *, loop_momenta: typing.Optional[typing.Sequence[TensorName]] = None, external_momenta: typing.Optional[typing.Sequence[TensorName]] = None) -> Expression:
        r"""
        Express edge momenta in this basis while retaining tensor index arguments.

        Examples
        --------
        Using the setup in the ``LoopMomentumBasis`` class example:

        >>> routed = basis.route_expression(diagram.numerator_expression().to_expression())

        Parameters
        ----------
        expression : Expression or number
            Expression with canonical edge momenta to route, or a scalar constant.
        loop_momenta : sequence[TensorName] or None, optional
            Vector names in ``loop_edges`` order. None retains indexed ``K`` calls.
        external_momenta : sequence[TensorName] or None, optional
            Vector names in ``external_edges`` order, excluding ``dependent_externals``.
            None retains indexed ``P`` calls. Naming also applies to already routed vectors.
        """
    @overload
    def route(self, loop_momenta: typing.Sequence[ThreeMomentum], external_momenta: typing.Sequence[ThreeMomentum]) -> dict[int, ThreeMomentum]:
        r"""
        Route four-momenta through every diagram edge.

        Examples
        --------
        Using ``basis`` from the class example; zero external momenta keep this
        routing illustration momentum-conserving:

        >>> loop_momentum = hep.FourMomentum(2.0, 1.0, 0.0, 0.0)
        >>> external_four_momenta = [hep.FourMomentum(0.0, 0.0, 0.0, 0.0)
        ...                          for edge in basis.external_edges]
        >>> routed = basis.route([loop_momentum], external_four_momenta)
        >>> internal_momentum = routed[basis.loop_edges[0]]

        Parameters
        ----------
        loop_momenta : sequence[FourMomentum]
            Independent loop momenta in ``basis.loop_edges`` order.
        external_momenta : sequence[FourMomentum]
            External momenta in ``basis.external_edges`` order.
        """
    @overload
    def route(self, loop_momenta: typing.Sequence[FourMomentum], external_momenta: typing.Sequence[FourMomentum]) -> dict[int, FourMomentum]:
        r"""
        Route four-momenta through every diagram edge.

        Examples
        --------
        Using ``basis`` from the class example; zero external momenta keep this
        routing illustration momentum-conserving:

        >>> loop_momentum = hep.FourMomentum(2.0, 1.0, 0.0, 0.0)
        >>> external_four_momenta = [hep.FourMomentum(0.0, 0.0, 0.0, 0.0)
        ...                          for edge in basis.external_edges]
        >>> routed = basis.route([loop_momentum], external_four_momenta)
        >>> internal_momentum = routed[basis.loop_edges[0]]

        Parameters
        ----------
        loop_momenta : sequence[FourMomentum]
            Independent loop momenta in ``basis.loop_edges`` order.
        external_momenta : sequence[FourMomentum]
            External momenta in ``basis.external_edges`` order.
        """

@typing.final
class LorentzStructure:
    r"""
    A reusable spin-dependent tensor structure in an interaction rule.

    The structure records the spin representation of each leg and the UFO
    expression used when constructing a diagram numerator.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.standard_model()
    >>> lorentz = model.lorentz_structures[0]
    >>> spins = lorentz.spins
    >>> formula = lorentz.structure
    """
    @property
    def name(self) -> builtins.str:
        r"""
        Return the Lorentz-structure name.

        Examples
        --------
        Using the setup in the ``LorentzStructure`` class example:

        >>> structures = {item.name: item.structure for item in model.lorentz_structures}
        """
    @property
    def spins(self) -> builtins.list[builtins.int]:
        r"""
        Return the UFO ``2S + 1`` spin codes of the structure's particle slots.

        Examples
        --------
        Using the setup in the ``LorentzStructure`` class example:

        >>> vertex = model.vertex_rules[0]
        >>> lorentz = model.lorentz_structure(vertex.lorentz_structures[0])
        >>> len(lorentz.spins) == len(vertex.particles)
        True
        """
    @property
    def structure(self) -> Expression:
        r"""
        Return the symbolic Lorentz expression.

        Examples
        --------
        Using the setup in the ``LorentzStructure`` class example:

        >>> formula = lorentz.structure
        """
    def __repr__(self) -> builtins.str:
        r"""
        Summarize the defining data as well as the structure name.

        Examples
        --------
        Using the setup in the ``LorentzStructure`` class example:

        >>> vertex = model.vertex_rules[0]
        >>> print(model.lorentz_structure(vertex.lorentz_structures[0]))
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Display the model member's physical data and defining expressions.

        Examples
        --------
        Using the setup in the ``LorentzStructure`` class example:

        >>> from IPython.display import display
        >>> display(lorentz)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the complete text summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``LorentzStructure`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(lorentz)

        Parameters
        ----------
        pretty : object
            IPython pretty printer receiving the text.
        cycle : bool
            Whether the object occurs recursively in the current display.
        """

@typing.final
class LtdReport:
    r"""
    Generation counts for an LTD representation.

    Distinguish retained pole assignments from spanning trees: several residues
    may share a tree, and a higher-order residue may contain several terms.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> process = hep.Model.phi3().process(["phi"], ["phi", "phi"])
    >>> diagrams = process.generate_diagrams(
    ...     loops=1, max_vertices=3, maximum_bridges=0, progress=None
    ... )
    >>> diagram = diagrams.diagrams[0]
    >>> ltd = diagram.integrate_energy(method="ltd")
    >>> report = ltd.report
    >>> assert report.residues == len(ltd)
    """
    @property
    def residues(self) -> builtins.int:
        r"""
        Number of retained signed pole assignments.

        Examples
        --------
        >>> count = report.residues
        """
    @property
    def trees(self) -> builtins.int:
        r"""
        Number of distinct spanning trees represented by the residues.

        Examples
        --------
        >>> count = report.trees
        """
    @property
    def unfolded_terms(self) -> builtins.int:
        r"""
        Number of additive denominator products, including higher-order residues.

        Examples
        --------
        >>> count = report.unfolded_terms
        """
    @property
    def interned_surfaces(self) -> builtins.int:
        r"""
        Number of distinct stored affine energy surfaces.

        Examples
        --------
        >>> count = report.interned_surfaces
        """
    def __repr__(self) -> builtins.str:
        r"""
        Summarize the retained residues, spanning trees, terms and surfaces.

        Examples
        --------
        >>> text = repr(report)
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Render LTD generation statistics as a compact table.

        Examples
        --------
        >>> html = report._repr_html_()
        """

@typing.final
class LtdRepresentation:
    r"""
    A scalar loop-energy integral in the loop-tree duality (LTD) representation.

    Create with ``diagram.integrate_energy(method="ltd")``. Each residue puts
    edges complementary to a spanning tree on shell at
    :math:`q_e^0=\sigma_e E_e`, where :math:`\sigma_e\in\{-1,+1\}` and
    :math:`E_e=\sqrt{\boldsymbol{q}_e^2+m_e^2}`. The ordered loop-momentum
    basis and successive contours determine the retained pole assignments and
    coefficients. A spanning tree alone does not determine the signs.

    ``to_expression()`` sums the residues, including signed coefficients and
    on-shell factors. The measure is :math:`d\ell^0/(2\pi i)` per loop, with
    contours closed below, as in ``CffRepresentation``. Numerators, couplings,
    graph weights and the spatial integration measure are excluded. Repeated
    propagators are handled by higher-order residues.

    Both representations use ``gammalooprs::OSE(e)`` for :math:`E_e` and
    ``gammalooprs::Q(e, spenso::cind(0))`` for external energies; ``e`` is a
    physical diagram edge ID. ``on_shell_energies`` supplies the routed square
    roots. Impose external momentum conservation when comparing CFF and LTD.

    Displaying the object opens the residue and surface-pair explorer in Marimo
    or an HTML notebook. ``len(ltd)`` counts retained signed residues.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> process = hep.Model.phi3().process(["phi"], ["phi", "phi"])
    >>> diagrams = process.generate_diagrams(
    ...     loops=1, max_vertices=3, maximum_bridges=0, progress=None
    ... )
    >>> diagram = diagrams.diagrams[0]
    >>> ltd = diagram.integrate_energy(method="ltd")
    >>> expression = ltd.to_expression()
    >>> assert ltd.report.residues == len(ltd.residues)
    """
    @property
    def residues(self) -> builtins.list[LtdResidue]:
        r"""
        Signed residues with tree, pole-sign and surface-pair inspection.

        Examples
        --------
        >>> residue = ltd.residues[0]
        """
    @property
    def surfaces(self) -> builtins.list[EnergySurface]:
        r"""
        All stored affine surfaces, with physical diagram edge IDs.

        Examples
        --------
        >>> definitions = [s.to_expression() for s in ltd.surfaces]
        """
    @property
    def diagram(self) -> FeynmanDiagram:
        r"""
        Originating diagram, retaining the ordered momentum routing and owner.

        Examples
        --------
        >>> routing = ltd.diagram.loop_momentum_basis
        """
    @property
    def on_shell_energies(self) -> builtins.dict[builtins.int, OnShellEnergy]:
        r"""
        Shared symbolic energies and routed square roots, keyed by physical edge ID.

        Examples
        --------
        >>> definitions = [(e.symbol, e.to_expression()) for e in ltd.on_shell_energies.values()]
        """
    @property
    def report(self) -> LtdReport:
        r"""
        Counts of retained residues, distinct trees, unfolded terms and surfaces.

        Examples
        --------
        >>> assert ltd.report.residues == len(ltd.residues)
        """
    def to_expression(self, *, expand_surfaces: builtins.bool = True) -> TensorExpression:
        r"""
        Return the scalar loop-energy integral as a Symbolica expression.

        Includes contour signs and on-shell energy factors for
        :math:`d\ell^0/(2\pi i)` per loop, with contours closed below. Numerators,
        couplings, graph weights and the spatial measure are excluded.
        ``expand_surfaces`` expands affine denominators while leaving
        ``gammalooprs::OSE(e)`` symbolic. Use ``on_shell_energies`` for their routed
        definitions or custom evaluation.

        Examples
        --------
        Using the setup in the class example:

        >>> expression = ltd.to_expression()
        >>> compact = ltd.to_expression(expand_surfaces=False)

        Parameters
        ----------
        expand_surfaces : bool, optional
            Replace surface placeholders by their affine energy definitions.
            Defaults to True. False keeps placeholders local to this representation.

        Returns
        -------
        TensorExpression
            Rank-zero tensor summing all residue contributions and prefactors.
        """
    def __len__(self) -> builtins.int:
        r"""
        Return the number of signed residues.

        Examples
        --------
        Using the setup in ``LtdRepresentation``:

        >>> residue_count = len(ltd)
        """
    def __repr__(self) -> builtins.str:
        r"""
        Summarize the native LTD result.

        Examples
        --------
        Using the setup in ``LtdRepresentation``:

        >>> print(ltd)
        """
    def render(self) -> DiagramView:
        r"""
        Prepare a browser-measured residue and surface-pair explorer.

        Examples
        --------
        >>> view = ltd.render()
        >>> view
        >>> snapshot = view.measured(browser="chromium")
        """
    def _repr_mimebundle_(self, include: typing.Optional[typing.Sequence[builtins.str]] = None, exclude: typing.Optional[typing.Sequence[builtins.str]] = None) -> typing.Any:
        r"""
        Explore native residues, surface pairs, and region-relative pole signs.

        Click cuts to navigate residues, tree edges to switch their pair, and
        hover cuts to trace the cycle fixing their signs in the ordered routing.

        Examples
        --------
        Using the setup in ``LtdRepresentation``:

        >>> from IPython.display import display
        >>> display(ltd)

        Parameters
        ----------
        include : list[str] or None, optional
            MIME types requested by the frontend; None allows all available types.
        exclude : list[str] or None, optional
            MIME types omitted from the frontend response.
        """
    def _mime_(self) -> typing.Any:
        r"""
        Return Marimo MIME data with static output and an optional live widget.

        Examples
        --------
        Using the setup in ``LtdRepresentation``:

        >>> view = ltd.render()
        >>> view  # static output is immediate; an optional widget refines label sizes
        >>> snapshot = view.measured(browser="chromium")
        """
    def _display_(self) -> typing.Any:
        r"""
        Return a Marimo widget when available, otherwise static HTML.

        Examples
        --------
        Using the setup in ``LtdRepresentation``:

        >>> presentation = ltd._display_()
        """

@typing.final
class LtdResidue:
    r"""
    One retained signed residue in an LTD representation.

    The cut edges obey :math:`q_e^0=\sigma_e E_e`, with signs relative to the
    stored momentum arrows. The diagram's ordered routing and contours determine
    these assignments; several residues may share a spanning tree. Higher-order
    poles can contribute several additive terms to one residue.

    ``energy_map`` gives every internal energy at the residue. Substituting these
    energies into an uncut propagator gives the ``surface_pairs`` factors
    :math:`q_e^0-E_e` and :math:`q_e^0+E_e`.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> process = hep.Model.phi3().process(["phi"], ["phi", "phi"])
    >>> diagrams = process.generate_diagrams(
    ...     loops=1, max_vertices=3, maximum_bridges=0, progress=None
    ... )
    >>> diagram = diagrams.diagrams[0]
    >>> ltd = diagram.integrate_energy(method="ltd")
    >>> residue = ltd.residues[0]
    >>> signs = residue.pole_signs
    """
    @property
    def id(self) -> builtins.int:
        r"""
        Stable residue index within this representation.

        Examples
        --------
        >>> index = residue.id
        """
    @property
    def cut_edges(self) -> builtins.list[builtins.int]:
        r"""
        Physical IDs of the on-shell edges complementary to the spanning tree.

        Examples
        --------
        >>> cuts = residue.cut_edges
        """
    @property
    def tree_edges(self) -> builtins.list[builtins.int]:
        r"""
        Physical IDs of uncut internal edges in the spanning tree.

        Examples
        --------
        >>> tree = residue.tree_edges
        """
    @property
    def pole_signs(self) -> builtins.dict[builtins.int, builtins.int]:
        r"""
        Cut-edge pole signs relative to the diagram's stored momentum arrows.

        Each entry fixes :math:`q_e^0=\sigma_e E_e`, with
        :math:`\sigma_e\in\{-1,+1\}`. The ordered routing and successive energy
        contours determine these signs for the entire residue. Selecting another
        surface factor does not change them.

        Examples
        --------
        >>> assignments = residue.pole_signs

        Returns
        -------
        dict[int, int]
            Physical cut-edge IDs mapped to their pole signs.
        """
    @property
    def energy_map(self) -> builtins.dict[builtins.int, Expression]:
        r"""
        Internal energies :math:`q_e^0` evaluated at this residue.

        Examples
        --------
        >>> energies = residue.energy_map

        Returns
        -------
        dict[int, Expression]
            Physical internal-edge IDs mapped to affine combinations of ``OSE`` and
            external ``Q`` symbols. Cut entries equal :math:`\sigma_e E_e`.
        """
    @property
    def surface_pairs(self) -> builtins.dict[builtins.int, SurfacePair]:
        r"""
        The two factors of each surviving uncut propagator.

        Each pair preserves :math:`q_e^0-E_e` and :math:`q_e^0+E_e` after evaluating
        :math:`q_e^0` at the residue. Each factor's sign relates it to its stored
        surface; it does not change the cut-edge pole assignment.

        Examples
        --------
        >>> pairs = residue.surface_pairs

        Returns
        -------
        dict[int, SurfacePair]
            Physical tree-edge IDs mapped to their ordered minus/plus factors.
        """
    def __repr__(self) -> builtins.str:
        r"""
        Summarize this residue's cut edges and pole signs.

        Examples
        --------
        >>> text = repr(residue)
        """
    def to_expression(self, *, expand_surfaces: builtins.bool = True) -> TensorExpression:
        r"""
        Return this residue's contribution, including its signed coefficient.

        Examples
        --------
        Using the setup in the class example:

        >>> expression = residue.to_expression()

        Parameters
        ----------
        expand_surfaces : bool, optional
            Replace stored surface placeholders by affine energy definitions.
            Defaults to True. On-shell energies remain symbolic in either case.

        Returns
        -------
        TensorExpression
            The scalar residue, including multiplicities and on-shell energy factors.
        """
    def render(self) -> DiagramView:
        r"""
        Prepare this residue's explorer for notebook display or explicit measurement.

        Examples
        --------
        >>> view = residue.render()
        >>> snapshot = view.measured(browser="chromium")
        """
    def _repr_mimebundle_(self, include: typing.Optional[typing.Sequence[builtins.str]] = None, exclude: typing.Optional[typing.Sequence[builtins.str]] = None) -> typing.Any:
        r"""
        Inspect this residue's expression, fixed cuts and surface pairs.

        Examples
        --------
        >>> from IPython.display import display
        >>> display(residue)

        Parameters
        ----------
        include : list[str] or None, optional
            MIME types requested by the frontend; None allows all available types.
        exclude : list[str] or None, optional
            MIME types omitted from the frontend response.
        """
    def _mime_(self) -> typing.Any:
        r"""
        Return Marimo MIME data with static output and an optional live widget.

        Examples
        --------
        >>> view = residue.render()
        >>> view  # static output is immediate; an optional widget refines label sizes
        >>> snapshot = view.measured(browser="chromium")
        """
    def _display_(self) -> typing.Any:
        r"""
        Display this residue in Marimo.

        Examples
        --------
        >>> view = residue._display_()
        """

@typing.final
class Model:
    r"""
    A loaded particle model ready for diagram generation.

    Models provide typed access to particles, parameters, couplings, interaction
    rules, propagators, and numerical parameter-card updates.

    Examples
    --------
    Built-in models need no external files. To import your own UFO directory,
    see ``UfoLoader``; to restore a normalized JSON model, use ``Model(path)``
    or ``Model.from_json``.

    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.standard_model()
    >>> photon = model.particle("a")
    >>> process = model.process(["e-", "e+"], ["mu-", "mu+"])
    >>> result = process.generate_diagrams()
    >>> assert result.report.completed
    >>> scalar_model = hep.Model.phi4()
    >>> assert scalar_model.particle("phi").spin == 1

    Parameters
    ----------
    path : str or os.PathLike
        Path to a normalized HEP JSON model.
    """
    @property
    def name(self) -> builtins.str:
        r"""
        Return the model name.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> model = hep.Model.standard_model()
        >>> model_name = model.name
        """
    @property
    def restriction(self) -> typing.Optional[builtins.str]:
        r"""
        Return the applied restriction name, when present.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> model = hep.Model.standard_model()
        >>> restriction = model.restriction
        """
    @property
    def particles(self) -> builtins.list[Particle]:
        r"""
        Return all particle species in deterministic model order.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> fermions = [particle for particle in model.particles if particle.spin == 2]
        """
    @property
    def parameters(self) -> builtins.list[Parameter]:
        r"""
        Return all external and internal parameters in model order.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> external = [p for p in model.parameters if p.nature == hep.ParameterNature.EXTERNAL]
        """
    @property
    def couplings(self) -> builtins.list[Coupling]:
        r"""
        Return all interaction couplings in model order.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> qed = [c for c in model.couplings if c.orders.get("QED", 0) > 0]
        """
    @property
    def vertex_rules(self) -> builtins.list[VertexRule]:
        r"""
        Return all interaction vertex rules in model order.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> electron_vertices = [v for v in model.vertex_rules if "e-" in v.particles]
        """
    @property
    def lorentz_structures(self) -> builtins.list[LorentzStructure]:
        r"""
        Return all reusable Lorentz structures in model order.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> lorentz_by_name = {item.name: item for item in model.lorentz_structures}
        """
    @property
    def propagators(self) -> builtins.list[Propagator]:
        r"""
        Return all model-defined propagators in model order.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> propagators_by_name = {item.name: item for item in model.propagators}
        """
    @property
    def functions(self) -> builtins.list[ModelFunction]:
        r"""
        Return all helper functions available to model expressions.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> functions = {function.name: function for function in model.functions}
        """
    @property
    def form_factors(self) -> builtins.list[FormFactor]:
        r"""
        Return all momentum-dependent model form factors in model order.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> form_factors = {factor.name: factor for factor in model.form_factors}
        """
    @staticmethod
    def standard_model() -> Model:
        r"""
        Load the complete embedded Standard Model with default parameters.
        No model files or UFO installation are required.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> model = hep.Model.standard_model()
        """
    @staticmethod
    def qcd() -> Model:
        r"""
        Load QCD with six quark flavors, gluons, and gluon ghosts, filtered from
        the Standard Model. Preserves its parameters and their default values.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> model = hep.Model.qcd()
        """
    @staticmethod
    def qed() -> Model:
        r"""
        Load QED with photons and all charged fermions (including quarks), filtered
        from the Standard Model. Preserves its parameters and their default values.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> model = hep.Model.qed()
        """
    @staticmethod
    def electroweak() -> Model:
        r"""
        Load the electroweak Standard Model, retaining quarks, Higgs, Goldstones,
        and electroweak ghosts, and removing gluons and gluon ghosts.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> model = hep.Model.electroweak()
        """
    @staticmethod
    def qcd_qed() -> Model:
        r"""
        Load strong and electromagnetic interactions of all quarks and charged
        leptons, including gluon ghosts, with Standard Model parameters.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> model = hep.Model.qcd_qed()
        """
    @staticmethod
    def yang_mills() -> Model:
        r"""
        Load pure SU(3) Yang-Mills theory: gluons and gluon ghosts without quarks.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> model = hep.Model.yang_mills()
        """
    @staticmethod
    def phi3() -> Model:
        r"""
        Load a real scalar phi with L_int = -g phi^3 / 3!.
        The external parameters mass and g default to one; the width is zero.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> model = hep.Model.phi3()
        """
    @staticmethod
    def phi4() -> Model:
        r"""
        Load a real scalar phi with L_int = -lam phi^4 / 4!.
        The external parameters mass and lam default to one; the width is zero.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> model = hep.Model.phi4()
        """
    @staticmethod
    def phi_3_4() -> Model:
        r"""
        Load a real scalar phi with L_int = -g phi^3 / 3! - lam phi^4 / 4!.
        Independent parameters mass, g, and lam default to one; the width is zero.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> model = hep.Model.phi_3_4()
        """
    @staticmethod
    def scalar_qed() -> Model:
        r"""
        Load scalar QED in Feynman gauge with a, phi+, and phi-.
        Parameters mass=e=1 and lam=0; the scalar potential is
        mass^2 |phi|^2 + lam |phi|^4 / 4, and all widths vanish.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> model = hep.Model.scalar_qed()
        """
    def __new__(cls, path: builtins.str | os.PathLike | pathlib.Path) -> Model:
        r"""
        Load a model from a normalized HEP JSON file.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> from pathlib import Path
        >>> from tempfile import TemporaryDirectory
        >>> with TemporaryDirectory() as directory:
        ...     path = Path(directory) / "model.json"
        ...     model.write_json(path)
        ...     restored = hep.Model(path)
        ...     assert restored.name == model.name

        Parameters
        ----------
        path : str or os.PathLike
            Path to the JSON model.
        """
    @staticmethod
    def from_json(json: builtins.str) -> Model:
        r"""
        Parse a model from its JSON representation.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> model_json = model.to_json()
        >>> restored = hep.Model.from_json(model_json)
        >>> assert restored.name == model.name

        Parameters
        ----------
        json : str
            Serialized model object.
        """
    def process(self, incoming: typing.Sequence[Particle | ParticleSelector | builtins.str | builtins.int], outgoing: typing.Sequence[Particle | ParticleSelector | builtins.str | builtins.int], *, particle_veto: typing.Optional[typing.Sequence[Particle | ParticleSelector | builtins.str | builtins.int]] = None, particle_selection: typing.Optional[typing.Sequence[Particle | ParticleSelector | builtins.str | builtins.int]] = None, vertex_allow: typing.Optional[typing.Sequence[VertexRule | builtins.str]] = None, vertex_veto: typing.Optional[typing.Sequence[VertexRule | builtins.str]] = None) -> Process:
        r"""
        Define a process with model-validated external states and sector restrictions.
        The returned process is immutable; loops and other calculation choices are
        arguments to its generate_diagrams, generate_amplitude and generate_cross_section methods.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> process = model.process(["e-", "e+"], ["a", "a"])
        >>> amplitude = process.generate_amplitude(loops=0)

        Parameters
        ----------
        incoming : sequence[Particle | ParticleSelector | str | int]
            Ordered incoming external states.
        outgoing : sequence[Particle | ParticleSelector | str | int]
            Ordered outgoing external states.
        particle_veto : sequence[Particle | ParticleSelector | str | int] or None, optional
            Excluded species, including their antiparticles.
        particle_selection : sequence[Particle | ParticleSelector | str | int] or None, optional
            Allowed species, including their antiparticles. None allows all; an
            empty list allows none. Mutually exclusive with particle_veto.
        vertex_allow : sequence[VertexRule | str] or None, optional
            Allowed interactions. None allows all; an empty list allows none.
        vertex_veto : sequence[VertexRule | str] or None, optional
            Excluded interactions.
        """
    def particle(self, name: builtins.str) -> Particle:
        r"""
        Look up a particle by name.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> electron = model.particle("e-")
        >>> assert electron.pdg_code == 11

        Parameters
        ----------
        name : str
            Particle name or antiname.
        """
    def particle_by_pdg(self, pdg: builtins.int) -> Particle:
        r"""
        Look up a particle by PDG code.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> particle = model.particle_by_pdg(11)

        Parameters
        ----------
        pdg : int
            Signed PDG particle code.
        """
    def parameter(self, name: builtins.str) -> Parameter:
        r"""
        Look up a parameter by name.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> mass = model.parameter("MM")
        >>> assert mass.nature == hep.ParameterNature.EXTERNAL

        Parameters
        ----------
        name : str
            Parameter name.
        """
    def coupling(self, name: builtins.str) -> Coupling:
        r"""
        Look up a coupling by name.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> coupling = model.coupling("GC_1")

        Parameters
        ----------
        name : str
            Coupling name.
        """
    def parse_expression(self, source: builtins.str) -> Expression:
        r"""
        Parse a diagram expression with this model's parameter and coupling names.

        Graph and tensor functions use the same short names as DOT input.
        Bare ``dim`` and ``Nc`` resolve to ``gammalooprs::dim`` and ``spenso::Nc``.
        Other unknown names use the calling module's Symbolica namespace, as in
        ``E(...)``. Explicit namespaces select the exact symbol.

        Examples
        --------
        >>> model = hep.Model.standard_model()
        >>> weight = model.parse_expression("GC_11*Q(0,cind(0))")
        >>> assert model.parse_expression("MT") == model.parameter("MT").symbol

        Parameters
        ----------
        source : str
            Symbolica expression in diagram notation.

        Returns
        -------
        Expression
            Parsed expression, suitable for operations such as ``model.expand_couplings``.

        Raises
        ------
        ValueError
            If the expression cannot be parsed.
        """
    def scalar_bindings(self, card: typing.Optional[ParameterCard] = None, *, overrides: typing.Optional[typing.Dict[symbolica.Expression, symbolica.Expression]] = None) -> typing.Dict[symbolica.Expression, symbolica.Expression]:
        r"""
        Return exact model scalar bindings with all named dependencies resolved.

        Internal parameter and coupling definitions remain analytic; cached
        dependent values are not used. Numerical model/card inputs are converted
        to exact binary64 rationals. This operation does not mutate the model or
        numerically recompute it. Unknown symbols and UFO functions outside the
        returned map are retained, not evaluated.

        Examples
        --------
        >>> from symbolica import E
        >>> model = hep.Model.standard_model()
        >>> values = model.scalar_bindings(overrides={
        ...     model.parameter("MT").symbol: E("345/2"),
        ...     model.parameter("ymt").symbol: E("345/2"),
        ...     model.parameter("WT").symbol: E("0"),
        ...     model.parameter("WH").symbol: E("0"),
        ... })
        >>> assert values[model.parameter("MT").symbol] == E("345/2")

        Parameters
        ----------
        card : ParameterCard or None, optional
            Restriction applied to a copy, including explicit internal overrides.
            Pass it explicitly even if already applied to the model, because
            the model does not retain the history of internal overrides.
        overrides : dict[Expression, Expression] or None, optional
            Exact scalar definitions, keyed by plain symbols. They take
            precedence over model/card values before dependencies are resolved.
            Model parameters can be set here without creating a parameter card.

        Returns
        -------
        dict[Expression, Expression]
            Native exact expressions keyed by model and additional override symbols.
        """
    def vertex_rule(self, name: builtins.str) -> VertexRule:
        r"""
        Look up a vertex rule by name.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> vertex = model.vertex_rule("V_1")

        Parameters
        ----------
        name : str
            Vertex-rule name.
        """
    def lorentz_structure(self, name: builtins.str) -> LorentzStructure:
        r"""
        Look up a Lorentz structure by name.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> lorentz = model.lorentz_structure("FFV1")

        Parameters
        ----------
        name : str
            Lorentz-structure name.
        """
    def propagator(self, name: builtins.str) -> Propagator:
        r"""
        Look up a propagator by name.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> name = model.propagators[0].name
        >>> propagator = model.propagator(name)

        Parameters
        ----------
        name : str
            Propagator name.
        """
    def function(self, name: builtins.str) -> ModelFunction:
        r"""
        Look up a model function by name.

        Examples
        --------
        Using ``model`` from the class example. A model may have no helper functions:

        >>> functions = [model.function(item.name) for item in model.functions]

        Parameters
        ----------
        name : str
            Function name.
        """
    def form_factor(self, name: builtins.str) -> FormFactor:
        r"""
        Look up a form factor by name.

        Examples
        --------
        Using ``model`` from the class example. A model may have no form factors:

        >>> form_factors = [model.form_factor(item.name) for item in model.form_factors]

        Parameters
        ----------
        name : str
            Form-factor name.
        """
    def default_parameter_card(self) -> ParameterCard:
        r"""
        Build a parameter card from the model's current external values.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> card = model.default_parameter_card()
        """
    def with_parameter_card(self, card: ParameterCard, evaluator: collections.abc.Callable[[EvaluationRequest], EvaluatedValues] | None = None) -> Model:
        r"""
        Return a copy with a parameter card applied atomically.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> card = model.default_parameter_card()
        >>> card.set("MM", 0.105658, 0.0)
        >>> updated = model.with_parameter_card(card)

        Parameters
        ----------
        card : ParameterCard
            External parameter values to apply.
        evaluator : Callable[[EvaluationRequest], EvaluatedValues] or None
            Optional evaluator used to recompute dependent values.
        """
    def recompute_with(self, evaluator: collections.abc.Callable[[EvaluationRequest], EvaluatedValues]) -> Model:
        r"""
        Return a copy with all dependent values recomputed by a callback.

        Examples
        --------
        This callback evaluates the built-in scalar model at its default coupling
        ``lam=1``. See ``EvaluationRequest`` for callback inputs.

        >>> from symbolica import S, E
        >>> from symbolica.community import hepkit as hep
        >>> model = hep.Model.phi4()
        >>> process = model.process(["phi", "phi"], ["phi", "phi"])
        >>> requests = []
        >>> def evaluate(request):
        ...     requests.append(request)
        ...     return hep.EvaluatedValues(
        ...         couplings={"SCALAR_COUPLING": (0.0, -1.0)},
        ...     )
        >>> updated_model = model.recompute_with(evaluate)
        >>> request = requests[0]
        >>> formulas = {item.name: item.expression for item in request.couplings}

        Parameters
        ----------
        evaluator : Callable[[EvaluationRequest], EvaluatedValues]
            Callback that evaluates every expression in a request.
        """
    def to_json(self, pretty: builtins.bool = True) -> builtins.str:
        r"""
        Serialize the model as JSON.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> model.to_json(pretty=False)

        Parameters
        ----------
        pretty : bool
            Indent the output when true.
        """
    def write_json(self, path: builtins.str | os.PathLike | pathlib.Path) -> None:
        r"""
        Write the model to a JSON file.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> model.write_json("model.json")

        Parameters
        ----------
        path : str or os.PathLike
            Destination for the JSON model.
        """
    def __repr__(self) -> builtins.str:
        r"""
        Summarize the defining data as well as the name and particle count.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> print(model)
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Render a compact inventory of the model in notebook frontends.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> from IPython.display import display
        >>> display(model)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the concise model summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(model)

        Parameters
        ----------
        pretty : object
            The IPython pretty-printer object.
        cycle : bool
            Whether this object is part of a recursive formatting cycle.
        """
    @overload
    def expand_couplings(self, expression: TensorExpression) -> TensorExpression:
        r"""
        Replace named UFO coefficients by their analytic model expressions.

        The input and the stored model are unchanged.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> analytic = model.expand_couplings(S("UFO::GC_11"))

        Parameters
        ----------
        expression : Expression
            Symbolica expression containing named couplings from this model.
        """
    @overload
    def expand_couplings(self, expression: Expression) -> Expression:
        r"""
        Replace named UFO coefficients by their analytic model expressions.

        The input and the stored model are unchanged.

        Examples
        --------
        Using the setup in the ``Model`` class example:

        >>> analytic = model.expand_couplings(S("UFO::GC_11"))

        Parameters
        ----------
        expression : Expression
            Symbolica expression containing named couplings from this model.
        """

class ModelError(FeynkitError):
    r"""
    Invalid particle-model data or model operation.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.standard_model()
    >>> try:
    ...     model.particle_by_pdg(999999)
    ... except hep.ModelError as error:
    ...     message = str(error)
    """
    ...

@typing.final
class ModelExpression:
    r"""
    A named symbolic expression awaiting numerical model evaluation.

    These records describe internal parameters or couplings passed to a custom
    ``Model.recompute_with`` callback.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> requests = []
    >>> def evaluate(request):
    ...     requests.append(request)
    ...     return hep.EvaluatedValues(
    ...         couplings={"SCALAR_COUPLING": (0.0, -1.0)},
    ...     )
    >>> updated_model = model.recompute_with(evaluate)
    >>> request = requests[0]
    >>> item = request.couplings[0]
    >>> formula = item.expression
    >>> name = item.name
    """
    @property
    def name(self) -> builtins.str:
        r"""
        Return the name assigned to the expression.

        Examples
        --------
        Using the setup in the ``ModelExpression`` class example:

        >>> formulas = {item.name: item.expression for item in request.couplings}
        """
    @property
    def expression(self) -> Expression:
        r"""
        Return the formula with its model parameter and coupling symbols.

        Examples
        --------
        Using the setup in the ``ModelExpression`` class example:

        >>> formula = item.expression
        """

@typing.final
class ModelFunction:
    r"""
    A named helper function used by model expressions.

    Functions expose their formal arguments and, when available, a symbolic
    implementation that an evaluator can use during parameter recomputation.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.standard_model()
    >>> functions = {function.name: function.arguments for function in model.functions}
    """
    @property
    def symbol(self) -> Expression:
        r"""
        Return the symbolic reference used by this model's expressions.
        This preserves the parameter or function identity without substituting
        its defining expression or numerical value.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> model = hep.Model.standard_model()
        >>> import json
        >>> definition = json.loads(model.to_json())
        >>> definition["functions"] = [{"name": "square", "arguments": ["x"], "expression": "x^2"}]
        >>> custom = hep.Model.from_json(json.dumps(definition))
        >>> reference = custom.function("square").symbol
        """
    @property
    def name(self) -> builtins.str:
        r"""
        Return the function name.

        Examples
        --------
        Using the setup in the ``ModelFunction`` class example:

        >>> names = [function.name for function in model.functions]
        """
    @property
    def arguments(self) -> builtins.list[builtins.str]:
        r"""
        Return the ordered argument names.

        Examples
        --------
        Using the setup in the ``ModelFunction`` class example:

        >>> arguments_by_name = {function.name: function.arguments for function in model.functions}
        """
    @property
    def expression(self) -> typing.Optional[Expression]:
        r"""
        Return the function body, when one is defined by the model.

        Examples
        --------
        Using the setup in the ``ModelFunction`` class example:

        >>> implementations = {function.name: function.expression for function in model.functions}
        """
    def __repr__(self) -> builtins.str:
        r"""
        Summarize the defining data as well as the function name.

        Examples
        --------
        Using the setup in the ``ModelFunction`` class example:

        >>> summaries = [repr(function) for function in model.functions]
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Display the model member's physical data and defining expressions.

        Examples
        --------
        Using the setup in the ``ModelFunction`` class example:

        >>> from IPython.display import display
        >>> display(model.functions)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the complete text summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``ModelFunction`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(model.functions)

        Parameters
        ----------
        pretty : object
            IPython pretty printer receiving the text.
        cycle : bool
            Whether the object occurs recursively in the current display.
        """

@typing.final
class MomentumSignature:
    r"""
    Integer coefficients expressing one edge momentum in a chosen basis.

    A signature separates coefficients of independent loop momenta from those
    of external momenta, for example ``-l1 + p2``.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> result = process.generate_diagrams(loops=1)
    >>> diagram = result.diagrams[0]
    >>> basis = diagram.loop_momentum_basis
    >>> edge_id = basis.loop_edges[0]
    >>> signature = basis.edge_signatures[edge_id]
    >>> routing = signature.format_momentum()
    """
    @property
    def loops(self) -> builtins.list[builtins.int]:
        r"""
        Return the integer coefficients of the independent loop momenta.

        Examples
        --------
        Using the setup in the ``MomentumSignature`` class example:

        >>> assert len(signature.loops) == diagram.loop_count
        """
    @property
    def external(self) -> builtins.list[builtins.int]:
        r"""
        Return the integer coefficients of the external momenta.

        Examples
        --------
        Using the setup in the ``MomentumSignature`` class example:

        >>> external_coefficients = signature.external
        """
    def integer_coefficients(self) -> tuple[builtins.list[builtins.int], builtins.list[builtins.int]]:
        r"""
        Return loop and external coefficients as a pair of integer lists.

        Examples
        --------
        Using the setup in the ``MomentumSignature`` class example:

        >>> signature = next(iter(basis.edge_signatures.values()))
        >>> loops, external = signature.integer_coefficients()
        >>> print("loop coefficients:", loops, "external coefficients:", external)
        """
    def format_momentum(self) -> builtins.str:
        r"""
        Format the signature as a conventional momentum sum.

        Examples
        --------
        Using the setup in the ``MomentumSignature`` class example:

        Print the momentum routing assigned to every propagator:

        >>> for edge_id, signature in basis.edge_signatures.items():
        ...     print(edge_id, signature.format_momentum())
        """
    def __str__(self) -> builtins.str:
        r"""
        Return the conventional momentum sum for ``str(signature)``.

        Examples
        --------
        Using the setup in the ``MomentumSignature`` class example:

        >>> signature = next(iter(basis.edge_signatures.values()))
        >>> print(f"propagator momentum: {signature}")
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return an unambiguous momentum-signature summary.

        Examples
        --------
        Using the setup in the ``MomentumSignature`` class example:

        >>> edge_id, signature = next(iter(basis.edge_signatures.items()))
        >>> print(f"edge {edge_id}: {signature!r}")
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the momentum signature to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``MomentumSignature`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(signature)

        Parameters
        ----------
        pretty : Any
            The IPython pretty-printer object.
        cycle : bool
            Whether this object is part of a recursive formatting cycle.
        """

@typing.final
class NumeratorGrouping:
    r"""
    Choose cross-diagram numerator grouping.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> hep.NumeratorGrouping("identical", number_of_numerical_samples=7)

    Parameters
    ----------
    mode : {"none", "identical", "up_to_sign", "up_to_scalar"}
        Disable grouping, or compare numerators exactly, up to a sign, or up
        to a scalar factor. To remove diagrams with vanishing color without
        comparing numerators, pass ``filter_zero_color=True`` to generation.
    numerical_sample_seed : int, optional
        Deterministic seed used to choose numerical substitution values.
    number_of_numerical_samples : int, optional
        Number of independent substitutions used to compare numerators.
    differentiate_particle_masses_only : bool, optional
        Treat internal species with equal mass and spin as interchangeable.
    fully_numerical_substitution : bool, optional
        Substitute scalar parameters as well as nonscalar indeterminates.
    check_canonical_numerator : bool, optional
        Try an exact canonical comparison before numerical sampling.
    symmetric_polarizations : bool, optional
        Reuse wavefunction samples across the two sides of a sewn external state.
    """
    def __new__(cls, mode: builtins.str, *, numerical_sample_seed: builtins.int = 3, number_of_numerical_samples: builtins.int = 5, differentiate_particle_masses_only: builtins.bool = True, fully_numerical_substitution: builtins.bool = False, check_canonical_numerator: builtins.bool = False, symmetric_polarizations: builtins.bool = False) -> NumeratorGrouping:
        r"""
        Choose cross-diagram numerator grouping.

        Examples
        --------
        Using the setup in the ``NumeratorGrouping`` class example:

        >>> hep.NumeratorGrouping("identical", number_of_numerical_samples=7)

        Parameters
        ----------
        mode : {"none", "identical", "up_to_sign", "up_to_scalar"}
            Disable grouping, or compare numerators exactly, up to a sign, or up
            to a scalar factor. To remove diagrams with vanishing color without
            comparing numerators, pass ``filter_zero_color=True`` to generation.
        numerical_sample_seed : int, optional
            Deterministic seed used to choose numerical substitution values.
        number_of_numerical_samples : int, optional
            Number of independent substitutions used to compare numerators.
        differentiate_particle_masses_only : bool, optional
            Treat internal species with equal mass and spin as interchangeable.
        fully_numerical_substitution : bool, optional
            Substitute scalar parameters as well as nonscalar indeterminates.
        check_canonical_numerator : bool, optional
            Try an exact canonical comparison before numerical sampling.
        symmetric_polarizations : bool, optional
            Reuse wavefunction samples across the two sides of a sewn external state.
        """

@typing.final
class OnShellEnergy:
    r"""
    A symbolic on-shell energy shared by CFF and LTD.

    ``symbol`` is ``gammalooprs::OSE(e)``, with physical diagram edge ID ``e``.
    ``to_expression()`` returns the positive-root definition

    $$
    E_e=\sqrt{\boldsymbol{q}_e^2+m_e^2}.
    $$

    The spatial momentum is routed through the diagram's loop-momentum basis.
    Its ``K(i, cind(a))`` and ``P(i, cind(a))`` coordinates use basis positions
    ``i`` and Cartesian components ``a`` equal to 1, 2 or 3. These positions are
    not physical edge IDs. Surface expansion leaves ``OSE`` symbolic; substitute
    this definition for spatial evaluation, or supply your own energy evaluator.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> process = hep.Model.phi3().process(["phi"], ["phi", "phi"])
    >>> diagrams = process.generate_diagrams(
    ...     loops=1, max_vertices=3, maximum_bridges=0, progress=None
    ... )
    >>> diagram = diagrams.diagrams[0]
    >>> rep = diagram.integrate_energy(method="cff")
    >>> energy = next(iter(rep.on_shell_energies.values()))
    >>> replacement = (energy.symbol, energy.to_expression())
    """
    @property
    def edge_id(self) -> builtins.int:
        r"""
        Physical diagram edge owning this energy.

        Examples
        --------
        >>> edge_id = energy.edge_id
        """
    @property
    def symbol(self) -> Expression:
        r"""
        Canonical ``gammalooprs::OSE(edge_id)``, shared between CFF and LTD.

        Examples
        --------
        >>> symbol = energy.symbol
        """
    def to_expression(self) -> TensorExpression:
        r"""
        Return the routed definition :math:`\sqrt{\boldsymbol{q}_e^2+m_e^2}`.

        Examples
        --------
        >>> definition = energy.to_expression()

        Returns
        -------
        TensorExpression
            Positive square root in the diagram's spatial K/P basis coordinates.
        """
    def __repr__(self) -> builtins.str:
        r"""
        Display the symbolic energy and its definition.

        Examples
        --------
        >>> print(energy)
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Render the energy symbol with its expandable routed square root.

        Examples
        --------
        >>> html = energy._repr_html_()
        """

@typing.final
class Parameter:
    r"""
    A numerical or symbolic parameter in a particle-physics model.

    External parameters carry parameter-card coordinates and values; internal
    parameters carry expressions derived from the external inputs.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.standard_model()
    >>> mass = model.parameter("MM")
    >>> assert mass.nature == hep.ParameterNature.EXTERNAL
    """
    @property
    def symbol(self) -> Expression:
        r"""
        Return the symbolic reference used by this model's expressions.
        TeX and Typst output use ``texname`` and ``typstname``, respectively. Plain output keeps
        its symbolic name; no defining expression or numerical value is substituted.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> model = hep.Model.standard_model()
        >>> reference = model.parameter("ee").symbol
        >>> mass = model.parameter("Me").symbol
        >>> assert "m_e" in (mass**2).to_latex()
        """
    @property
    def mathmlname(self) -> typing.Optional[builtins.str]:
        r"""
        The model's presentation MathML fragment for this symbol, or None when absent.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> assert "<msub>" in hep.Model.standard_model().parameter("Me").mathmlname
        """
    @property
    def typstname(self) -> typing.Optional[builtins.str]:
        r"""
        Native Typst math label without dollar delimiters, or None if not supplied.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> hep.Model.phi4().parameter("lam").typstname
        'lambda'
        """
    @property
    def name(self) -> builtins.str:
        r"""
        Return the parameter name.

        Examples
        --------
        Using the setup in the ``Parameter`` class example:

        >>> assert mass.name == "MM"
        """
    @property
    def texname(self) -> typing.Optional[builtins.str]:
        r"""
        The model's LaTeX display label, or None when no label was supplied.
        Native Typst output uses ``typstname`` independently.

        >>> hep.Model.standard_model().parameter("ee").texname
        'e'

        Examples
        --------
        Using the setup in the ``Parameter`` class example:

        >>> label = model.parameter("ee").texname
        >>> assert label == "e"
        """
    @property
    def lhablock(self) -> typing.Optional[builtins.str]:
        r"""
        Return the Les Houches block name, when defined.

        Examples
        --------
        Using the setup in the ``Parameter`` class example:

        >>> mass = model.parameter(model.particle_by_pdg(13).mass_parameter)
        >>> mass.lhablock
        'MASS'
        """
    @property
    def lhacode(self) -> typing.Optional[builtins.list[builtins.int]]:
        r"""
        Return the Les Houches entry indices, when defined.

        Examples
        --------
        Using the setup in the ``Parameter`` class example:

        >>> mass = model.parameter(model.particle_by_pdg(13).mass_parameter)
        >>> mass.lhacode
        [13]
        """
    @property
    def nature(self) -> ParameterNature:
        r"""
        Return whether the parameter is external or internal.

        Examples
        --------
        Using the setup in the ``Parameter`` class example:

        >>> mass = model.parameter(model.particle_by_pdg(13).mass_parameter)
        >>> mass.nature == hep.ParameterNature.EXTERNAL
        True
        """
    @property
    def parameter_type(self) -> ParameterType:
        r"""
        Return whether the parameter is real or complex.

        Examples
        --------
        Using the setup in the ``Parameter`` class example:

        >>> mass = model.parameter(model.particle_by_pdg(13).mass_parameter)
        >>> mass.parameter_type == hep.ParameterType.REAL
        True
        """
    @property
    def value(self) -> complex:
        r"""
        Return the evaluated value as a native Python complex number.

        Raises :class:`ModelError` when this parameter has not been evaluated.

        Examples
        --------
        Using the setup in the ``Parameter`` class example:

        >>> mass_value = model.parameter("MM").value
        >>> print("mass:", mass_value.real, "width component:", mass_value.imag)
        """
    @property
    def expression(self) -> typing.Optional[Expression]:
        r"""
        Return the defining expression for an internal parameter.

        Examples
        --------
        Using the setup in the ``Parameter`` class example:

        >>> internal = next(p for p in model.parameters if p.expression is not None)
        >>> formula = internal.expression
        """
    def __repr__(self) -> builtins.str:
        r"""
        Summarize the defining data as well as the parameter name.

        Examples
        --------
        Using the setup in the ``Parameter`` class example:

        >>> print(model.parameter(model.particle_by_pdg(13).mass_parameter))
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Display the model member's physical data and defining expressions.

        Examples
        --------
        Using the setup in the ``Parameter`` class example:

        >>> from IPython.display import display
        >>> display(mass)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the complete text summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``Parameter`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(mass)

        Parameters
        ----------
        pretty : object
            IPython pretty printer receiving the text.
        cycle : bool
            Whether the object occurs recursively in the current display.
        """

@typing.final
class ParameterCard:
    r"""
    Mutable external parameter values for a particle model.

    A parameter card can be initialized from a model, edited by parameter name,
    serialized as JSON, and atomically applied to a model copy.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.standard_model()
    >>> card = model.default_parameter_card()
    >>> card.set("MM", 0.105658, 0.0)
    >>> shifted_model = model.with_parameter_card(card)
    """
    def __new__(cls) -> ParameterCard:
        r"""
        Create an empty parameter card.

        Examples
        --------
        Using the setup in the ``ParameterCard`` class example:

        >>> card = hep.ParameterCard()
        """
    @staticmethod
    def from_json(json: builtins.str) -> ParameterCard:
        r"""
        Parse a parameter card from its JSON representation.

        Examples
        --------
        Using the setup in the ``ParameterCard`` class example:

        >>> card = hep.ParameterCard.from_json('{"mass": [1.0, 0.0]}')

        Parameters
        ----------
        json : str
            Serialized parameter-card object.
        """
    @staticmethod
    def from_path(path: builtins.str | os.PathLike | pathlib.Path) -> ParameterCard:
        r"""
        Load a parameter card from a JSON file.

        Examples
        --------
        Using the setup in the ``ParameterCard`` class example:

        >>> from pathlib import Path
        >>> from tempfile import TemporaryDirectory
        >>> with TemporaryDirectory() as directory:
        ...     path = Path(directory) / "parameters.json"
        ...     path.write_text(card.to_json())
        ...     restored = hep.ParameterCard.from_path(path)

        Parameters
        ----------
        path : str or os.PathLike
            Path to the JSON parameter card.
        """
    def get(self, name: builtins.str) -> typing.Optional[tuple[builtins.float, builtins.float]]:
        r"""
        Return a parameter's complex value, or ``None`` when it is absent.

        Examples
        --------
        Using the setup in the ``ParameterCard`` class example:

        >>> card.get("mass")

        Parameters
        ----------
        name : str
            Parameter name to look up.
        """
    def set(self, name: builtins.str, real: builtins.float, imaginary: builtins.float = 0.0) -> None:
        r"""
        Store a complex parameter value.

        Examples
        --------
        Using the setup in the ``ParameterCard`` class example:

        >>> card.set("mass", 1.0)

        Parameters
        ----------
        name : str
            Parameter name to store.
        real : float
            Real component of the value.
        imaginary : float
            Imaginary component of the value.
        """
    def remove(self, name: builtins.str) -> typing.Optional[tuple[builtins.float, builtins.float]]:
        r"""
        Remove and return a parameter value, if present.

        Examples
        --------
        Using the setup in the ``ParameterCard`` class example:

        >>> card.remove("mass")

        Parameters
        ----------
        name : str
            Parameter name to remove.
        """
    def items(self) -> builtins.list[tuple[builtins.str, tuple[builtins.float, builtins.float]]]:
        r"""
        Return all parameter-card entries.

        Examples
        --------
        Using the setup in the ``ParameterCard`` class example:

        >>> card.items()
        """
    def to_json(self, pretty: builtins.bool = True) -> builtins.str:
        r"""
        Serialize the parameter card as JSON.

        Examples
        --------
        Using the setup in the ``ParameterCard`` class example:

        >>> card.to_json(pretty=False)

        Parameters
        ----------
        pretty : bool
            Indent the output when true.
        """
    def write_json(self, path: builtins.str | os.PathLike | pathlib.Path) -> None:
        r"""
        Write the parameter card to a JSON file.

        Examples
        --------
        Using the setup in the ``ParameterCard`` class example:

        >>> card.write_json("parameters.json")

        Parameters
        ----------
        path : str or os.PathLike
            Destination for the JSON parameter card.
        """
    def __len__(self) -> builtins.int:
        r"""
        Return the number of entries in the parameter card.

        Examples
        --------
        Using the setup in the ``ParameterCard`` class example:

        >>> number_of_external_inputs = len(model.default_parameter_card())
        """

@typing.final
class Particle:
    r"""
    A particle species in a loaded interaction model.

    Particle records expose the signed PDG code, spin and color
    representations, electric charge, and the parameters used for mass and
    width.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.standard_model()
    >>> electron = model.particle_by_pdg(11)
    >>> assert electron.name == "e-"
    """
    @property
    def typstname(self) -> typing.Optional[builtins.str]:
        r"""
        Native Typst math label without dollar delimiters, or None if not supplied.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> hep.Model.phi4().particle("phi").typstname
        'phi'
        """
    @property
    def antitypstname(self) -> typing.Optional[builtins.str]:
        r"""
        Native Typst math label of the antiparticle without dollar delimiters,
        or None if not supplied.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> hep.Model.phi4().particle("phi").antitypstname
        'phi'
        """
    @property
    def name(self) -> builtins.str:
        r"""
        Return the particle name used by the model.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> assert electron.name == "e-"
        """
    @property
    def antiname(self) -> builtins.str:
        r"""
        Return the name of the corresponding antiparticle.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> assert electron.antiname == "e+"
        """
    @property
    def antiparticle(self) -> Particle:
        r"""
        Return the corresponding antiparticle from the same model.

        Self-conjugate particles map to themselves.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> electron = model.particle_by_pdg(11)
        >>> electron.antiparticle.name
        'e+'
        >>> model.particle_by_pdg(22).antiparticle.name  # the photon is self-conjugate
        'a'
        """
    @property
    def pdg_code(self) -> builtins.int:
        r"""
        Return the signed Particle Data Group code.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> model.particle("e-").pdg_code
        11
        """
    @property
    def spin(self) -> builtins.int:
        r"""
        Return the UFO spin code ``2S + 1`` (negative for ghost fields).

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> model.particle_by_pdg(11).spin  # spin-1/2 electron
        2
        """
    @property
    def color(self) -> builtins.int:
        r"""
        Return the signed UFO SU(3) color representation code.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> model.particle_by_pdg(11).color  # color-singlet electron
        1
        """
    @property
    def mass_parameter(self) -> builtins.str:
        r"""
        Return the name of the particle's mass parameter.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> particle = model.particle_by_pdg(13)
        >>> mass = model.parameter(particle.mass_parameter)
        """
    @property
    def width_parameter(self) -> builtins.str:
        r"""
        Return the name of the particle's width parameter.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> particle = model.particle_by_pdg(23)
        >>> width = model.parameter(particle.width_parameter)
        """
    @property
    def mass(self) -> Expression:
        r"""
        Exact symbolic mass, with the UFO ZERO parameter represented as zero.
        Other parameters remain symbolic, even when their current value is zero.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> model.particle("c").mass
        """
    @property
    def electric_charge(self) -> Expression:
        r"""
        Signed symbolic electric charge Q e, including the model's coupling.
        An electron has charge ``-e`` and a positron ``+e``. Neutral particles
        return exact zero. Use ``charge`` for the dimensionless charge Q.
        The unit charge is inferred from minimal photon (PDG 22) interactions
        with fermions or scalars, including their Lorentz normalization; no
        parameter name is assumed. Use ``-electron.electric_charge`` for positive e.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> qed_model = hep.Model.qed()
        >>> electron = qed_model.particle("e-")
        >>> mass, charge = electron.mass, electron.electric_charge
        >>> assert electron.antiparticle.electric_charge == -charge
        >>> assert qed_model.particle("a").electric_charge == 0

        Raises
        ------
        ModelError
            If a charged particle's model has no supported minimal photon vertex,
            or its photon vertices imply inconsistent unit charges.
        """
    @property
    def charge(self) -> Expression:
        r"""
        Electric charge in units of e, as an exact Symbolica expression.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> model.particle("c").charge
        """
    @property
    def y_charge(self) -> typing.Optional[Expression]:
        r"""
        Hypercharge in Q = T3 + Y/2; left-handed for fermions.
        None means absent, undefined, or unspecified, rather than zero.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> model.particle("c").y_charge
        """
    @property
    def y_charge_right(self) -> typing.Optional[Expression]:
        r"""
        Right-handed fermion hypercharge in Q = T3 + Y/2, if specified.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> model.particle("c").y_charge_right
        """
    @property
    def weak_isospin(self) -> typing.Optional[Expression]:
        r"""
        Third weak-isospin component Q - Y/2; left-handed for fermions.
        Antiparticle chiralities are exchanged by charge conjugation.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> model.particle("c").weak_isospin
        """
    @property
    def weak_isospin_right(self) -> typing.Optional[Expression]:
        r"""
        Right-handed fermion third weak-isospin component, if specified.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> model.particle("c").weak_isospin_right
        """
    @property
    def is_antiparticle(self) -> builtins.bool:
        r"""
        Report whether this object represents an antiparticle.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> model.particle_by_pdg(11).is_antiparticle
        False
        """
    @property
    def is_self_antiparticle(self) -> builtins.bool:
        r"""
        Report whether the particle is its own antiparticle.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> model.particle_by_pdg(22).is_self_antiparticle
        True
        """
    @property
    def is_fermion(self) -> builtins.bool:
        r"""
        Report whether the particle has fermionic spin.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> model.particle_by_pdg(11).is_fermion
        True
        """
    @property
    def is_massless(self) -> builtins.bool:
        r"""
        Report whether the particle's mass parameter is zero.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> model.particle_by_pdg(22).is_massless
        True
        """
    def color_sum(self, left: Expression, right: Expression, *, average: builtins.bool = False) -> Expression:
        r"""
        Construct the identity on this particle's color space.

        The bare ``left`` index carries the particle representation; ``right``
        carries its dual. Antiquarks and antisextets reverse the dual orientation.
        Supports UFO singlet, fundamental, sextet and adjoint representations.
        ``average=True`` divides by the number of color states (1, 3, 6 or 8).
        This sums color only; spin sums and color-algebra simplification remain
        separate operations. To close an existing tensor, use indices whose
        slots are dual to the open color slots of that tensor.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> from symbolica import S
        >>> i, j = S("i", "j")
        >>> color_projector = model.particle_by_pdg(5).color_sum(i, j, average=True)
        >>> model.particle_by_pdg(11).color_sum(i, j) == 1
        True

        Parameters
        ----------
        left : Expression
            Bare index in the particle's color representation.
        right : Expression
            Bare index in its dual representation.
        average : bool, optional
            Divide by the number of color states. Defaults to ``False``.

        Returns
        -------
        Expression
            Spenso color identity, or one for a color singlet.

        Raises
        ------
        ValueError
            If the particle's UFO color representation is unsupported.
        """
    def spin_sum(self, momentum: Expression, left: Expression, right: Expression, *, average: builtins.bool = False, reference: typing.Optional[Expression] = None, covariant: builtins.bool = False, spin_vector: typing.Optional[Expression] = None, dimension: typing.Optional[Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal]] = None) -> Expression:
        r"""
        Construct this particle's external-state spin or polarization sum.

        Return an ordinary Symbolica expression using Spenso gamma matrices
        and metrics. Indices are bare symbols; momentum and reference are
        unindexed symbols or labeled calls such as ``Q(1)``. The calculation
        defaults to four-dimensional external states. ``dimension`` changes the
        Lorentz dimension while Dirac spinor slots retain dimension four.
        Massive vectors use the Proca
        projector. For massless vectors, supply a reference for a physical
        axial sum, or omit it for the covariant sum of a gauge-invariant
        amplitude. Subsequent kinematic substitutions must enforce on-shell
        conditions and a nonzero momentum-reference scalar product.

        For a massive Dirac particle, ``spin_vector`` selects one physical spin
        state instead of summing states. Supply a dimensionless unindexed vector
        satisfying ``p.s = 0`` and ``s.s = -1``: the rest-frame spin direction,
        boosted with the particle. The same projector sign applies to fermions
        and antifermions; do not reverse this vector for an antiparticle.
        This option requires ``average=False`` and four Lorentz dimensions.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> from symbolica import S
        >>> p, i, j = S("p", "i", "j")
        >>> projector = model.particle("e-").spin_sum(p, i, j, average=True)
        >>> polarized = model.particle("ta-").spin_sum(p, i, j, spin_vector=S("s"))
        >>> dimensional = model.particle("g").spin_sum(p, i, j, dimension=S("D"))
        >>> six_dimensional = model.particle("g").spin_sum(p, i, j, dimension=6)

        Parameters
        ----------
        momentum : Expression
            Unindexed external momentum.
        left : Expression
            Open index on the amplitude.
        right : Expression
            Open index on the conjugate amplitude.
        average : bool
            Divide by two for Dirac fermions, D-2 for massless vectors, or D-1
            for massive vectors. Scalars have one state.
        dimension : Expression | int | None
            Integer or symbolic Lorentz dimension; defaults to four. Dirac
            spinor slots and their trace dimension stay four. To use a fixed
            two-state vector average at symbolic D, leave average=False and
            divide the result by two.
        reference : Expression | None
            Axial reference momentum for a massless vector; need not be null.
        covariant : bool
            Use the Feynman-gauge vector numerator even for a massive vector.
        spin_vector : Expression | None
            Physical spin vector of a massive Dirac state, with ``p.s = 0`` and
            ``s.s = -1``. Requires ``average=False``; ``None`` sums both states.

        Raises
        ------
        ValueError
            If ``spin_vector`` is used with averaging, a massless particle, or
            a particle other than a Dirac fermion, non-four-dimensional Lorentz
            slots, or is not an unindexed name. Also raised for an invalid
            dimension or a concrete dimension with no physical vector states.
        """
    def sum_spins(self, expression: Expression, momentum: Expression, *, edge: builtins.int, average: builtins.bool = False, reference: typing.Optional[Expression] = None, covariant: builtins.bool = False, spin_vector: typing.Optional[Expression] = None, dimension: typing.Optional[Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal]] = None) -> Expression:
        r"""
        Sum paired generated external wavefunctions for one edge.

        Replace this particle's wavefunction and its adjoint using the same
        completeness relation as ``spin_sum``. The expression may be a sewn
        diagram's ``projector_expression()`` or a squared amplitude. Only pairs
        with the supplied edge label are replaced; unpaired wavefunctions stay
        unchanged. Scalar particles have no external wavefunction factors.
        Vector wavefunction slots must use the requested Lorentz dimension.
        External states default to four dimensions; reference and gauge conventions
        are those of ``spin_sum``. For a massive Dirac particle, ``spin_vector``
        selects the same physical spin state as in ``spin_sum``, including for
        antiparticles. This does not sum color, conjugate amplitudes, or apply
        graph symmetry factors.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> from symbolica import S, E
        >>> from symbolica.community import hepkit as hep
        >>> model = hep.Model.standard_model()
        >>> diagram = model.process(["e-", "e+"], ["mu-", "mu+"]).generate_diagrams().diagrams[0]
        >>> electron = model.particle("e-")
        >>> projector = diagram.projector_expression()
        >>> spin_summed = electron.sum_spins(projector, S("gammalooprs::P")(1), edge=1)

        Parameters
        ----------
        expression : Expression
            Projector or squared expression containing paired wavefunctions.
        momentum : Expression
            Unindexed external momentum in the physical particle direction.
        edge : int
            Generated edge label of the pair to replace.
        average : bool
            Divide by two for Dirac fermions, D-2 for massless vectors, or D-1
            for massive vectors. Scalars have one state.
        dimension : Expression | int | None
            Integer or symbolic Lorentz dimension; defaults to four. Dirac
            spinor slots and their trace dimension stay four. To use a fixed
            two-state vector average at symbolic D, leave average=False and
            divide the result by two.
        reference : Expression | None
            Axial reference for a massless vector; need not be null.
        covariant : bool
            Use the Feynman-gauge vector numerator even for a massive vector.
        spin_vector : Expression | None
            Physical spin vector of a massive Dirac state, with ``p.s = 0`` and
            ``s.s = -1``. Requires ``average=False``; ``None`` sums both states.

        Raises
        ------
        ValueError
            If ``spin_vector`` is used with averaging, a massless particle, or
            a particle other than a Dirac fermion, non-four-dimensional Lorentz
            slots, or is not an unindexed name. Also raised for an invalid
            dimension or a concrete dimension with no physical vector states.
        """
    def __repr__(self) -> builtins.str:
        r"""
        Summarize the defining data as well as the name and PDG code.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> print(model.particle_by_pdg(11))
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Display the model member's physical data and defining expressions.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> from IPython.display import display
        >>> display(electron)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the complete text summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``Particle`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(electron)

        Parameters
        ----------
        pretty : object
            IPython pretty printer receiving the text.
        cycle : bool
            Whether the object occurs recursively in the current display.
        """

@typing.final
class ParticleSelector:
    r"""
    A model-independent way to identify an external particle.

    Selectors may use a UFO particle name or a signed PDG code, making process
    definitions convenient while deferring validation to a concrete model.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> electron = hep.ParticleSelector.by_pdg(11)
    >>> positron = hep.ParticleSelector.by_name("e+")
    """
    @property
    def name(self) -> builtins.str:
        r"""
        Return the selected particle name.

        Raises :class:`TypeError` for a PDG selector. Use :attr:`is_name` to
        distinguish the selector variants before accessing their payloads.

        Examples
        --------
        Using the setup in the ``ParticleSelector`` class example:

        >>> assert hep.ParticleSelector.by_name("e-").name == "e-"
        """
    @property
    def pdg(self) -> builtins.int:
        r"""
        Return the selected PDG code.

        Raises :class:`TypeError` for a name selector. Use :attr:`is_pdg` to
        distinguish the selector variants before accessing their payloads.

        Examples
        --------
        Using the setup in the ``ParticleSelector`` class example:

        >>> assert hep.ParticleSelector.by_pdg(11).pdg == 11
        """
    @property
    def is_name(self) -> builtins.bool:
        r"""
        Report whether this selector identifies a particle by name.

        Examples
        --------
        Using the setup in the ``ParticleSelector`` class example:

        >>> assert hep.ParticleSelector.by_name("e-").is_name
        """
    @property
    def is_pdg(self) -> builtins.bool:
        r"""
        Report whether this selector identifies a particle by PDG code.

        Examples
        --------
        Using the setup in the ``ParticleSelector`` class example:

        >>> assert hep.ParticleSelector.by_pdg(11).is_pdg
        """
    @staticmethod
    def by_name(name: builtins.str) -> ParticleSelector:
        r"""
        Select a particle by its model name.

        Examples
        --------
        Using the setup in the ``ParticleSelector`` class example:

        >>> hep.ParticleSelector.by_name("e-").name
        'e-'

        Parameters
        ----------
        name : str
            Particle name as it appears in the model.
        """
    @staticmethod
    def by_pdg(pdg: builtins.int) -> ParticleSelector:
        r"""
        Select a particle by its signed PDG code.

        Examples
        --------
        Using the setup in the ``ParticleSelector`` class example:

        >>> hep.ParticleSelector.by_pdg(11).pdg
        11

        Parameters
        ----------
        pdg : int
            Signed PDG code of the particle.
        """
    def __str__(self) -> builtins.str:
        r"""
        Format the selector as its particle name or signed PDG code.

        Examples
        --------
        Using the setup in the ``ParticleSelector`` class example:

        >>> str(hep.ParticleSelector.by_pdg(11))
        '11'
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return a constructor-style representation of the selector.

        Examples
        --------
        Using the setup in the ``ParticleSelector`` class example:

        >>> print(hep.ParticleSelector.by_pdg(11))  # electron selector in a process
        """
    def __eq__(self, other: typing.Any) -> builtins.bool:
        r"""
        Compare with another selector, a particle name, or a PDG code.

        Examples
        --------
        Using the setup in the ``ParticleSelector`` class example:

        >>> hep.ParticleSelector.by_pdg(11) == 11
        True

        Parameters
        ----------
        other : object
            Selector, particle-name string, or integer PDG code to compare with.
        """

@typing.final
class Process:
    r"""
    A scattering or decay process to pass to the diagram generator.

    A process records its incoming and outgoing particles and model-sector restrictions. External states accept loaded
    :class:`Particle` objects as well as names, signed PDG codes, and explicit
    :class:`ParticleSelector` objects.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.standard_model()
    >>> process = model.process(["e-", "e+"], ["mu-", "mu+"])
    >>> result = process.generate_diagrams(loops=0)
    >>> assert result.report.completed
    """
    @property
    def model(self) -> Model:
        r"""
        The particle model supplying this process's Feynman rules.

        Examples
        --------
        Using the setup in the ``Process`` class example:

        >>> electron = process.model.particle("e-")
        """
    @property
    def particle_veto(self) -> builtins.list[ParticleSelector]:
        r"""
        The excluded particle selectors, shared by every generation operation.

        Examples
        --------
        Using the setup in the ``Process`` class example:

        >>> excluded_particles = process.particle_veto
        """
    @property
    def particle_selection(self) -> typing.Optional[builtins.list[ParticleSelector]]:
        r"""
        Allowed species, including their antiparticles. None allows all;
        an empty list allows none. Shared by every generation operation.

        Examples
        --------
        Using the setup in the ``Process`` class example:

        >>> qed = model.process(["e-", "e+"], ["a", "a"], particle_selection=["e-", "a"])
        >>> allowed_particles = qed.particle_selection
        """
    @property
    def vertex_allow(self) -> typing.Optional[builtins.list[VertexRule]]:
        r"""
        Allowed model vertex rules; None permits every interaction.

        Examples
        --------
        Using the setup in the ``Process`` class example:

        >>> allowed_interactions = process.vertex_allow
        """
    @property
    def vertex_veto(self) -> builtins.list[VertexRule]:
        r"""
        Excluded model vertex rules.

        Examples
        --------
        Using the setup in the ``Process`` class example:

        >>> excluded_interactions = process.vertex_veto
        """
    @property
    def incoming(self) -> builtins.list[ParticleSelector]:
        r"""
        Return the ordered incoming-particle selectors.

        Examples
        --------
        Using the setup in the ``Process`` class example:

        >>> assert [selector.name for selector in process.incoming] == ["e-", "e+"]
        """
    @property
    def outgoing_alternatives(self) -> builtins.list[builtins.list[ParticleSelector]]:
        r"""
        Return every allowed ordered final-state alternative.

        Examples
        --------
        Using the setup in the ``Process`` class example:

        >>> alternatives = process.outgoing_alternatives
        """
    def __repr__(self) -> builtins.str:
        r"""
        Format the external states, model, and active particle/vertex restrictions.

        Examples
        --------
        Using the setup in the ``Process`` class example:

        >>> repr(process)
        'Process("sm": [e-, e+] -> [mu-, mu+])'
        """
    def render(self, *, config: typing.Optional[RenderSettings] = None, style: typing.Optional[DiagramStyle] = None) -> DiagramView:
        r"""
        Create a displayable blob with the process's physical incoming and outgoing particles.
        Alternative final states are displayed as separate schematics.

        Examples
        --------
        Using the setup in the ``Process`` class example:

        >>> drawing = process.render()
        >>> drawing
        >>> svg = drawing.measured(browser="chromium").to_svg()

        Parameters
        ----------
        style : DiagramStyle or None, optional
            Particle, momentum, and physical index presentation.
        config : RenderSettings or None, optional
            Particle-label, layout and drawing overrides shared with Feynman diagrams.
        """
    def _repr_mimebundle_(self, include: typing.Optional[typing.Sequence[builtins.str]] = None, exclude: typing.Optional[typing.Sequence[builtins.str]] = None) -> typing.Any:
        r"""
        Measure and display the process schematic in notebook frontends.

        Examples
        --------
        Using the setup in the ``Process`` class example:

        >>> from IPython.display import display
        >>> display(process)

        Parameters
        ----------
        include : list[str] or None, optional
            MIME types requested by the frontend; None allows all available types.
        exclude : list[str] or None, optional
            MIME types omitted from the frontend response.
        """
    def _mime_(self) -> typing.Any:
        r"""
        Return Marimo MIME data with static output and an optional live widget.

        Examples
        --------
        Using the setup in the ``Process`` class example:

        >>> view = process.render()
        >>> view  # static output is immediate; an optional widget refines label sizes
        >>> snapshot = view.measured(browser="chromium")
        """
    def with_final_state_alternatives(self, alternatives: typing.Sequence[typing.Sequence[Particle | ParticleSelector | builtins.str | builtins.int]]) -> Process:
        r"""
        Return a process accepting any of the supplied final states.
        Generating amplitudes requires exactly one alternative; cross sections may include an empty
        alternative for a vacuum final state.

        Examples
        --------
        Using the setup in the ``Process`` class example:

        >>> process = model.process([11, -11], [22, 22])
        >>> inclusive = process.with_final_state_alternatives([[22, 22], [13, -13]])

        Parameters
        ----------
        alternatives : sequence[sequence[Particle | ParticleSelector | str | int]]
            Allowed outgoing particle lists.
        """
    def with_filters(self, *, particle_veto: typing.Sequence[Particle | ParticleSelector | str | int] | types.EllipsisType | None = ..., particle_selection: typing.Sequence[Particle | ParticleSelector | str | int] | types.EllipsisType | None = ..., vertex_allow: typing.Sequence[VertexRule | str] | types.EllipsisType | None = ..., vertex_veto: typing.Sequence[VertexRule | str] | types.EllipsisType | None = ...) -> Process:
        r"""
        Return a process with updated particle and vertex restrictions.
        Omitted fields are preserved; None clears a field. An empty vertex_allow
        list permits no interactions, whereas None permits every interaction.

        Examples
        --------
        Using the setup in the ``Process`` class example:

        >>> qed = process.with_filters(vertex_allow=["V_98"])
        >>> unrestricted = qed.with_filters(vertex_allow=None)

        Parameters
        ----------
        particle_veto : sequence[Particle | ParticleSelector | str | int] or None, optional
            Replace the excluded species, including their antiparticles.
        particle_selection : sequence[Particle | ParticleSelector | str | int] or None, optional
            Replace the allowed species, including their antiparticles. An empty
            list allows none. Clear particle_veto with None when switching modes.
        vertex_allow : sequence[VertexRule | str] or None, optional
            Replace the allowed interaction rules.
        vertex_veto : sequence[VertexRule | str] or None, optional
            Replace the excluded interaction rules.
        """
    def generate_diagrams(self, *, loops: builtins.int | tuple[builtins.int, builtins.int] = 0, symmetrize_initial: builtins.bool = False, symmetrize_final: typing.Optional[builtins.bool] = None, symmetrize_left_right: builtins.bool = False, symmetrize_external_fermions: builtins.bool = False, threads: typing.Optional[builtins.int] = None, max_vertices: typing.Optional[builtins.int] = None, allow_self_loops: builtins.bool = True, allow_zero_flow_edges: builtins.bool = False, graph_prefix: typing.Optional[builtins.str] = None, maximum_bridges: int | None | types.EllipsisType = ..., self_energy: SelfEnergyFilterOptions | types.EllipsisType | None = ..., tadpoles: TadpoleFilterOptions | types.EllipsisType | None = ..., zero_snails: SnailFilterOptions | types.EllipsisType | None = ..., coupling_orders: typing.Optional[typing.Mapping[builtins.str, builtins.int | tuple[builtins.int, typing.Optional[builtins.int]]]] = None, fermion_loop_count_range: typing.Optional[tuple[builtins.int, builtins.int]] = None, factorized_loop_topologies_count_range: tuple[int, int] | types.EllipsisType | None = ..., blob_range: tuple[int, int] | types.EllipsisType | None = ..., spectator_range: tuple[int, int] | types.EllipsisType | None = ..., perturbative_orders: typing.Optional[typing.Mapping[builtins.str, builtins.int]] = None, sewn_tadpoles: typing.Optional[builtins.bool] = None, cut_amplitude_coupling_orders: typing.Optional[typing.Mapping[builtins.str, builtins.int | tuple[builtins.int, typing.Optional[builtins.int]]]] = None, cut_amplitude_loop_count_range: typing.Optional[tuple[builtins.int, builtins.int]] = None, select_diagrams: typing.Optional[typing.Sequence[FeynmanDiagram | builtins.str]] = None, veto_diagrams: typing.Optional[typing.Sequence[FeynmanDiagram | builtins.str]] = None, loop_momentum_bases: typing.Optional[typing.Sequence[tuple[FeynmanDiagram | builtins.str, typing.Sequence[builtins.int]]]] = None, numerator_prefactor: typing.Optional[Expression] = None, projector: typing.Optional[Expression] = None, numerator_grouping: typing.Optional[NumeratorGrouping] = None, filter_zero_color: builtins.bool = False, cancellation_token: typing.Optional[CancellationToken] = None, progress: typing.Literal['auto'] | collections.abc.Callable[[GenerationProgress], None] | None = 'auto', filter: collections.abc.Callable[[symbolica.core.Graph, int], bool] | None = None) -> GenerationResult:
        r"""
        Generate and optionally group all diagrams matching a process.

        Model Feynman rules are instantiated into each returned diagram: inspect
        ``vertex.numerator_expression()`` and ``edge.numerator_expression()`` for
        individual factors, or ``diagram.numerator_expression()`` for their
        combined numerator.

        Examples
        --------
        Using the setup in the ``Process`` class example:

        >>> result = process.generate_diagrams(max_vertices=6)
        >>> combined_numerator = result.diagrams[0].numerator_expression()

        Parameters
        ----------
        loops : int or tuple[int, int], optional
            Exact order or inclusive range for this call, default zero. Cross sections count
            loops in the sewn forward graph; two-particle tree cuts need loops=1.
        symmetrize_initial : bool, optional
            Identify graphs related by initial-state permutations; default False.
        symmetrize_final : bool or None, optional
            Identify final-state permutations; None uses True for cross sections and False for amplitudes.
        symmetrize_left_right : bool, optional
            Identify cross-section graphs related by exchanging amplitude sides.
        symmetrize_external_fermions : bool, optional
            Include amplitude fermions in enabled external-state symmetry classes.
        threads : int or None, optional
            Number of worker threads; None uses the generator default.
        max_vertices : int or None, optional
            Maximum interaction vertices; None applies no override.
        allow_self_loops : bool, optional
            Permit propagators that start and end on the same vertex; defaults to True.
        allow_zero_flow_edges : bool, optional
            Permit internal edges with identically zero momentum flow.
        graph_prefix : str or None, optional
            Prefix assigned to generated diagram names; None uses "D" (diagram).
        maximum_bridges : int, None, or Ellipsis, optional
            Omission or Ellipsis requires one-particle irreducibility only for diagrams
            with loops; tree exchanges are allowed, including in mixed loop ranges.
            An integer limits internal bridges at every loop order; None disables it.
        self_energy : SelfEnergyFilterOptions or None, optional
            Reject self-energy subgraphs. Omission enables the default filter for
            non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.
        tadpoles : TadpoleFilterOptions or None, optional
            Reject tadpole subgraphs. Omission enables the default filter for
            non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.
        zero_snails : SnailFilterOptions or None, optional
            Reject zero-snail subgraphs. Omission enables the default filter for
            non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.
        coupling_orders : dict[str, int | tuple[int, int or None]] or None, optional
            Exact coupling powers or inclusive ranges; an upper None is unbounded.
        fermion_loop_count_range : tuple[int, int] or None, optional
            Inclusive range of closed fermion loops.
        factorized_loop_topologies_count_range : tuple[int, int] or None, optional
            Inclusive range of factorized loop-topology components. Defaults to
            ``(1, 1)`` for vacuum processes; ``None`` disables the restriction.
        blob_range : tuple[int, int] or None, optional
            Inclusive cross-section blob-count range. Defaults to ``(1, 1)`` for
            cross sections; ``None`` omits the filter, which also selects ``(1, 1)``.
        spectator_range : tuple[int, int] or None, optional
            Inclusive range of spectators, initial-state legs crossed by a cut, on each
            cut side. Defaults to ``(0, 0)`` for cross sections; ``None`` omits the
            filter, which also selects ``(0, 0)``. A graph selected only through a
            spectator cut is a selection-only diagram (``is_selection_only``): it is
            listed and exported, but not turned into an amplitude or integrand.
        perturbative_orders : dict[str, int] or None, optional
            Exact perturbative powers required for cross-section graphs.
        sewn_tadpoles : bool or None, optional
            Reject tadpoles revealed by sewing cross-section sides; None applies no filter.
        cut_amplitude_coupling_orders : dict[str, int | tuple[int, int or None]] or None, optional
            Coupling-order bounds applied independently within every cut amplitude.
        cut_amplitude_loop_count_range : tuple[int, int] or None, optional
            Inclusive combined loop count across both sides of every cut.
        select_diagrams : sequence[FeynmanDiagram | str] or None, optional
            Retain only these diagram objects, content-derived IDs, or finalized names.
        veto_diagrams : sequence[FeynmanDiagram | str] or None, optional
            Remove these diagram objects, content-derived IDs, or finalized names.
        loop_momentum_bases : sequence[tuple[FeynmanDiagram | str, sequence[int]]] or None, optional
            Diagram selectors paired with ordered stable edge IDs for independent loop momenta.
        numerator_prefactor : Expression or None, optional
            Scalar multiplier retained on every finalized diagram numerator.
        projector : Expression or None, optional
            Override all automatic external-state contractions; S("1") disables them.
            The default cross-section projector also sums paired initial colors
            without averaging; unsewn amplitude colors remain open.
        numerator_grouping : NumeratorGrouping or None, optional
            Defaults to None: no numerator comparison or grouping. Diagrams still
            contain numerators. Pass NumeratorGrouping to compare and group them.
        filter_zero_color : bool, optional
            Discard diagrams whose color algebra proves the numerator is zero,
            before numerator grouping. Defaults to False, independently of grouping.
        progress : {"auto"}, Callable[[GenerationProgress], None] or None, optional
            Defaults to "auto": show progress when marimo.running_in_notebook()
            is true, with stage, counts, and elapsed time. None disables progress.
            Known totals use a progress bar; unknown totals use a spinner.
            The display closes on completion, cancellation, or error.
            Observe stage changes and coalesced counts on the calling Python thread.
            Callback exceptions propagate and stop generation.
        filter : Callable[[symbolica.core.Graph, int], bool] or None, optional
            Prune partial topologies during enumeration. The first N vertices are
            complete. False rejects only this search branch. Edge data is the base
            particle PDG code; node data is 0 internally, -(index+1) for incoming
            legs and +(index+1) for outgoing legs. Mutating the snapshot does not
            change enumeration. Keep callbacks cheap: each snapshot is constructed
            using Symbolica's core Python Graph API.
        cancellation_token : CancellationToken or None, optional
            Shared token for cancelling a running generation task. Token cancellation
            returns an incomplete result; Python signal-handler exceptions, including
            KeyboardInterrupt, stop generation and propagate to the caller.
        """
    def generate_amplitude(self, *, dimension: typing.Optional[Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal]] = None, real: typing.Optional[typing.Sequence[Expression]] = None, loops: builtins.int | tuple[builtins.int, builtins.int] = 0, symmetrize_initial: builtins.bool = False, symmetrize_final: typing.Optional[builtins.bool] = None, symmetrize_left_right: builtins.bool = False, symmetrize_external_fermions: builtins.bool = False, threads: typing.Optional[builtins.int] = None, max_vertices: typing.Optional[builtins.int] = None, allow_self_loops: builtins.bool = True, allow_zero_flow_edges: builtins.bool = False, graph_prefix: typing.Optional[builtins.str] = None, maximum_bridges: int | None | types.EllipsisType = ..., self_energy: SelfEnergyFilterOptions | types.EllipsisType | None = ..., tadpoles: TadpoleFilterOptions | types.EllipsisType | None = ..., zero_snails: SnailFilterOptions | types.EllipsisType | None = ..., coupling_orders: typing.Optional[typing.Mapping[builtins.str, builtins.int | tuple[builtins.int, typing.Optional[builtins.int]]]] = None, fermion_loop_count_range: typing.Optional[tuple[builtins.int, builtins.int]] = None, factorized_loop_topologies_count_range: tuple[int, int] | types.EllipsisType | None = ..., blob_range: tuple[int, int] | types.EllipsisType | None = ..., spectator_range: tuple[int, int] | types.EllipsisType | None = ..., perturbative_orders: typing.Optional[typing.Mapping[builtins.str, builtins.int]] = None, sewn_tadpoles: typing.Optional[builtins.bool] = None, cut_amplitude_coupling_orders: typing.Optional[typing.Mapping[builtins.str, builtins.int | tuple[builtins.int, typing.Optional[builtins.int]]]] = None, cut_amplitude_loop_count_range: typing.Optional[tuple[builtins.int, builtins.int]] = None, select_diagrams: typing.Optional[typing.Sequence[FeynmanDiagram | builtins.str]] = None, veto_diagrams: typing.Optional[typing.Sequence[FeynmanDiagram | builtins.str]] = None, loop_momentum_bases: typing.Optional[typing.Sequence[tuple[FeynmanDiagram | builtins.str, typing.Sequence[builtins.int]]]] = None, numerator_prefactor: typing.Optional[Expression] = None, projector: typing.Optional[Expression] = None, numerator_grouping: typing.Optional[NumeratorGrouping] = None, filter_zero_color: builtins.bool = False, cancellation_token: typing.Optional[CancellationToken] = None, progress: typing.Literal['auto'] | collections.abc.Callable[[GenerationProgress], None] | None = 'auto', filter: collections.abc.Callable[[symbolica.core.Graph, int], bool] | None = None) -> Amplitude:
        r"""
        Generate a coherent symbolic amplitude for this process.
        Cancelled or empty generation cannot produce an amplitude.

        Model Feynman rules are instantiated into each returned diagram: inspect
        ``vertex.numerator_expression()`` and ``edge.numerator_expression()`` for
        individual factors, or ``diagram.numerator_expression()`` for their
        combined numerator.

        Examples
        --------
        Using the setup in the ``Process`` class example:

        >>> result = process.generate_amplitude(max_vertices=6)
        >>> operator = result.expression()

        Parameters
        ----------
        dimension : int or Expression, optional
            Lorentz dimension of the amplitude; default four.
        real : list[Expression] or None, optional
            Additional scalars assumed real under conjugation.
        loops : int or tuple[int, int], optional
            Exact order or inclusive range for this call, default zero. Cross sections count
            loops in the sewn forward graph; two-particle tree cuts need loops=1.
        symmetrize_initial : bool, optional
            Identify graphs related by initial-state permutations; default False.
        symmetrize_final : bool or None, optional
            Identify final-state permutations; None uses True for cross sections and False for amplitudes.
        symmetrize_left_right : bool, optional
            Identify cross-section graphs related by exchanging amplitude sides.
        symmetrize_external_fermions : bool, optional
            Include amplitude fermions in enabled external-state symmetry classes.
        threads : int or None, optional
            Number of worker threads; None uses the generator default.
        max_vertices : int or None, optional
            Maximum interaction vertices; None applies no override.
        allow_self_loops : bool, optional
            Permit propagators that start and end on the same vertex; defaults to True.
        allow_zero_flow_edges : bool, optional
            Permit internal edges with identically zero momentum flow.
        graph_prefix : str or None, optional
            Prefix assigned to generated diagram names; None uses "D" (diagram).
        maximum_bridges : int, None, or Ellipsis, optional
            Omission or Ellipsis requires one-particle irreducibility only for diagrams
            with loops; tree exchanges are allowed, including in mixed loop ranges.
            An integer limits internal bridges at every loop order; None disables it.
        self_energy : SelfEnergyFilterOptions or None, optional
            Reject self-energy subgraphs. Omission enables the default filter for
            non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.
        tadpoles : TadpoleFilterOptions or None, optional
            Reject tadpole subgraphs. Omission enables the default filter for
            non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.
        zero_snails : SnailFilterOptions or None, optional
            Reject zero-snail subgraphs. Omission enables the default filter for
            non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.
        coupling_orders : dict[str, int | tuple[int, int or None]] or None, optional
            Exact coupling powers or inclusive ranges; an upper None is unbounded.
        fermion_loop_count_range : tuple[int, int] or None, optional
            Inclusive range of closed fermion loops.
        factorized_loop_topologies_count_range : tuple[int, int] or None, optional
            Inclusive range of factorized loop-topology components. Defaults to
            ``(1, 1)`` for vacuum processes; ``None`` disables the restriction.
        blob_range : tuple[int, int] or None, optional
            Inclusive cross-section blob-count range. Defaults to ``(1, 1)`` for
            cross sections; ``None`` omits the filter, which also selects ``(1, 1)``.
        spectator_range : tuple[int, int] or None, optional
            Inclusive range of spectators, initial-state legs crossed by a cut, on each
            cut side. Defaults to ``(0, 0)`` for cross sections; ``None`` omits the
            filter, which also selects ``(0, 0)``. A graph selected only through a
            spectator cut is a selection-only diagram (``is_selection_only``): it is
            listed and exported, but not turned into an amplitude or integrand.
        perturbative_orders : dict[str, int] or None, optional
            Exact perturbative powers required for cross-section graphs.
        sewn_tadpoles : bool or None, optional
            Reject tadpoles revealed by sewing cross-section sides; None applies no filter.
        cut_amplitude_coupling_orders : dict[str, int | tuple[int, int or None]] or None, optional
            Coupling-order bounds applied independently within every cut amplitude.
        cut_amplitude_loop_count_range : tuple[int, int] or None, optional
            Inclusive combined loop count across both sides of every cut.
        select_diagrams : sequence[FeynmanDiagram | str] or None, optional
            Retain only these diagram objects, content-derived IDs, or finalized names.
        veto_diagrams : sequence[FeynmanDiagram | str] or None, optional
            Remove these diagram objects, content-derived IDs, or finalized names.
        loop_momentum_bases : sequence[tuple[FeynmanDiagram | str, sequence[int]]] or None, optional
            Diagram selectors paired with ordered stable edge IDs for independent loop momenta.
        numerator_prefactor : Expression or None, optional
            Scalar multiplier retained on every finalized diagram numerator.
        projector : Expression or None, optional
            Override all automatic external-state contractions; S("1") disables them.
            The default cross-section projector also sums paired initial colors
            without averaging; unsewn amplitude colors remain open.
        numerator_grouping : NumeratorGrouping or None, optional
            Defaults to None: no numerator comparison or grouping. Diagrams still
            contain numerators. Pass NumeratorGrouping to compare and group them.
        filter_zero_color : bool, optional
            Discard diagrams whose color algebra proves the numerator is zero,
            before numerator grouping. Defaults to False, independently of grouping.
        progress : {"auto"}, Callable[[GenerationProgress], None] or None, optional
            Defaults to "auto": show progress when marimo.running_in_notebook()
            is true, with stage, counts, and elapsed time. None disables progress.
            Known totals use a progress bar; unknown totals use a spinner.
            The display closes on completion, cancellation, or error.
            Observe stage changes and coalesced counts on the calling Python thread.
            Callback exceptions propagate and stop generation.
        filter : Callable[[symbolica.core.Graph, int], bool] or None, optional
            Prune partial topologies during enumeration. The first N vertices are
            complete. False rejects only this search branch. Edge data is the base
            particle PDG code; node data is 0 internally, -(index+1) for incoming
            legs and +(index+1) for outgoing legs. Mutating the snapshot does not
            change enumeration. Keep callbacks cheap: each snapshot is constructed
            using Symbolica's core Python Graph API.
        cancellation_token : CancellationToken or None, optional
            Shared token for cancelling a running generation task. Token cancellation
            returns an incomplete result; Python signal-handler exceptions, including
            KeyboardInterrupt, stop generation and propagate to the caller.
        """
    def generate_cross_section(self, *, loops: builtins.int | tuple[builtins.int, builtins.int] = 0, symmetrize_initial: builtins.bool = False, symmetrize_final: typing.Optional[builtins.bool] = None, symmetrize_left_right: builtins.bool = False, symmetrize_external_fermions: builtins.bool = False, threads: typing.Optional[builtins.int] = None, max_vertices: typing.Optional[builtins.int] = None, allow_self_loops: builtins.bool = True, allow_zero_flow_edges: builtins.bool = False, graph_prefix: typing.Optional[builtins.str] = None, maximum_bridges: int | None | types.EllipsisType = ..., self_energy: SelfEnergyFilterOptions | types.EllipsisType | None = ..., tadpoles: TadpoleFilterOptions | types.EllipsisType | None = ..., zero_snails: SnailFilterOptions | types.EllipsisType | None = ..., coupling_orders: typing.Optional[typing.Mapping[builtins.str, builtins.int | tuple[builtins.int, typing.Optional[builtins.int]]]] = None, fermion_loop_count_range: typing.Optional[tuple[builtins.int, builtins.int]] = None, factorized_loop_topologies_count_range: tuple[int, int] | types.EllipsisType | None = ..., blob_range: tuple[int, int] | types.EllipsisType | None = ..., spectator_range: tuple[int, int] | types.EllipsisType | None = ..., perturbative_orders: typing.Optional[typing.Mapping[builtins.str, builtins.int]] = None, sewn_tadpoles: typing.Optional[builtins.bool] = None, cut_amplitude_coupling_orders: typing.Optional[typing.Mapping[builtins.str, builtins.int | tuple[builtins.int, typing.Optional[builtins.int]]]] = None, cut_amplitude_loop_count_range: typing.Optional[tuple[builtins.int, builtins.int]] = None, select_diagrams: typing.Optional[typing.Sequence[FeynmanDiagram | builtins.str]] = None, veto_diagrams: typing.Optional[typing.Sequence[FeynmanDiagram | builtins.str]] = None, loop_momentum_bases: typing.Optional[typing.Sequence[tuple[FeynmanDiagram | builtins.str, typing.Sequence[builtins.int]]]] = None, numerator_prefactor: typing.Optional[Expression] = None, projector: typing.Optional[Expression] = None, numerator_grouping: typing.Optional[NumeratorGrouping] = None, filter_zero_color: builtins.bool = False, cancellation_token: typing.Optional[CancellationToken] = None, progress: typing.Literal['auto'] | collections.abc.Callable[[GenerationProgress], None] | None = 'auto', filter: collections.abc.Callable[[symbolica.core.Graph, int], bool] | None = None) -> GenerationResult:
        r"""
        Generate sewn forward diagrams and their physical final-state cuts.
        The result contains diagrams and cut metadata, before phase-space integration.

        Model Feynman rules are instantiated into each returned diagram: inspect
        ``vertex.numerator_expression()`` and ``edge.numerator_expression()`` for
        individual factors, or ``diagram.numerator_expression()`` for their
        combined numerator.

        Examples
        --------
        A two-particle tree cut has one loop after the amplitude sides are sewn:

        >>> from symbolica import S, E
        >>> from symbolica.community import hepkit as hep
        >>> model = hep.Model.phi4()
        >>> process = model.process(["phi", "phi"], ["phi", "phi"])
        >>> result = process.generate_cross_section(loops=1)
        >>> assert result.diagrams[0].cuts
        >>> combined_numerator = result.diagrams[0].numerator_expression()

        Parameters
        ----------
        loops : int or tuple[int, int], optional
            Exact order or inclusive range for this call, default zero. Cross sections count
            loops in the sewn forward graph; two-particle tree cuts need loops=1.
        symmetrize_initial : bool, optional
            Identify graphs related by initial-state permutations; default False.
        symmetrize_final : bool or None, optional
            Identify final-state permutations; None uses True for cross sections and False for amplitudes.
        symmetrize_left_right : bool, optional
            Identify cross-section graphs related by exchanging amplitude sides.
        symmetrize_external_fermions : bool, optional
            Include amplitude fermions in enabled external-state symmetry classes.
        threads : int or None, optional
            Number of worker threads; None uses the generator default.
        max_vertices : int or None, optional
            Maximum interaction vertices; None applies no override.
        allow_self_loops : bool, optional
            Permit propagators that start and end on the same vertex; defaults to True.
        allow_zero_flow_edges : bool, optional
            Permit internal edges with identically zero momentum flow.
        graph_prefix : str or None, optional
            Prefix assigned to generated diagram names; None uses "D" (diagram).
        maximum_bridges : int, None, or Ellipsis, optional
            Omission or Ellipsis requires one-particle irreducibility only for diagrams
            with loops; tree exchanges are allowed, including in mixed loop ranges.
            An integer limits internal bridges at every loop order; None disables it.
        self_energy : SelfEnergyFilterOptions or None, optional
            Reject self-energy subgraphs. Omission enables the default filter for
            non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.
        tadpoles : TadpoleFilterOptions or None, optional
            Reject tadpole subgraphs. Omission enables the default filter for
            non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.
        zero_snails : SnailFilterOptions or None, optional
            Reject zero-snail subgraphs. Omission enables the default filter for
            non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.
        coupling_orders : dict[str, int | tuple[int, int or None]] or None, optional
            Exact coupling powers or inclusive ranges; an upper None is unbounded.
        fermion_loop_count_range : tuple[int, int] or None, optional
            Inclusive range of closed fermion loops.
        factorized_loop_topologies_count_range : tuple[int, int] or None, optional
            Inclusive range of factorized loop-topology components. Defaults to
            ``(1, 1)`` for vacuum processes; ``None`` disables the restriction.
        blob_range : tuple[int, int] or None, optional
            Inclusive cross-section blob-count range. Defaults to ``(1, 1)`` for
            cross sections; ``None`` omits the filter, which also selects ``(1, 1)``.
        spectator_range : tuple[int, int] or None, optional
            Inclusive range of spectators, initial-state legs crossed by a cut, on each
            cut side. Defaults to ``(0, 0)`` for cross sections; ``None`` omits the
            filter, which also selects ``(0, 0)``. A graph selected only through a
            spectator cut is a selection-only diagram (``is_selection_only``): it is
            listed and exported, but not turned into an amplitude or integrand.
        perturbative_orders : dict[str, int] or None, optional
            Exact perturbative powers required for cross-section graphs.
        sewn_tadpoles : bool or None, optional
            Reject tadpoles revealed by sewing cross-section sides; None applies no filter.
        cut_amplitude_coupling_orders : dict[str, int | tuple[int, int or None]] or None, optional
            Coupling-order bounds applied independently within every cut amplitude.
        cut_amplitude_loop_count_range : tuple[int, int] or None, optional
            Inclusive combined loop count across both sides of every cut.
        select_diagrams : sequence[FeynmanDiagram | str] or None, optional
            Retain only these diagram objects, content-derived IDs, or finalized names.
        veto_diagrams : sequence[FeynmanDiagram | str] or None, optional
            Remove these diagram objects, content-derived IDs, or finalized names.
        loop_momentum_bases : sequence[tuple[FeynmanDiagram | str, sequence[int]]] or None, optional
            Diagram selectors paired with ordered stable edge IDs for independent loop momenta.
        numerator_prefactor : Expression or None, optional
            Scalar multiplier retained on every finalized diagram numerator.
        projector : Expression or None, optional
            Override all automatic external-state contractions; S("1") disables them.
            The default cross-section projector also sums paired initial colors
            without averaging; unsewn amplitude colors remain open.
        numerator_grouping : NumeratorGrouping or None, optional
            Defaults to None: no numerator comparison or grouping. Diagrams still
            contain numerators. Pass NumeratorGrouping to compare and group them.
        filter_zero_color : bool, optional
            Discard diagrams whose color algebra proves the numerator is zero,
            before numerator grouping. Defaults to False, independently of grouping.
        progress : {"auto"}, Callable[[GenerationProgress], None] or None, optional
            Defaults to "auto": show progress when marimo.running_in_notebook()
            is true, with stage, counts, and elapsed time. None disables progress.
            Known totals use a progress bar; unknown totals use a spinner.
            The display closes on completion, cancellation, or error.
            Observe stage changes and coalesced counts on the calling Python thread.
            Callback exceptions propagate and stop generation.
        filter : Callable[[symbolica.core.Graph, int], bool] or None, optional
            Prune partial topologies during enumeration. The first N vertices are
            complete. False rejects only this search branch. Edge data is the base
            particle PDG code; node data is 0 internally, -(index+1) for incoming
            legs and +(index+1) for outgoing legs. Mutating the snapshot does not
            change enumeration. Keep callbacks cheap: each snapshot is constructed
            using Symbolica's core Python Graph API.
        cancellation_token : CancellationToken or None, optional
            Shared token for cancelling a running generation task. Token cancellation
            returns an incomplete result; Python signal-handler exceptions, including
            KeyboardInterrupt, stop generation and propagate to the caller.
        """

@typing.final
class Propagator:
    r"""
    A particle propagator with symbolic numerator and denominator.

    Propagator formulas are kept in their model representation so that diagram
    construction can combine them with interaction Lorentz structures.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.standard_model()
    >>> propagator = model.propagators[0]
    >>> formula = propagator.numerator / propagator.denominator
    """
    @property
    def name(self) -> builtins.str:
        r"""
        Return the propagator name.

        Examples
        --------
        Using the setup in the ``Propagator`` class example:

        >>> propagators_by_name = {item.name: item for item in model.propagators}
        """
    @property
    def particle(self) -> builtins.str:
        r"""
        Return the name of the particle using this propagator.

        Examples
        --------
        Using the setup in the ``Propagator`` class example:

        >>> propagator = model.propagators[0]
        >>> particle = model.particle(propagator.particle)
        """
    @property
    def numerator(self) -> Expression:
        r"""
        Return the symbolic propagator numerator.

        Examples
        --------
        Using the setup in the ``Propagator`` class example:

        >>> formula = propagator.numerator / propagator.denominator
        """
    @property
    def denominator(self) -> Expression:
        r"""
        Return the symbolic propagator denominator.

        Examples
        --------
        Using the setup in the ``Propagator`` class example:

        >>> inverse_propagator = propagator.denominator
        """
    def __repr__(self) -> builtins.str:
        r"""
        Summarize the defining data as well as the propagator name.

        Examples
        --------
        Using the setup in the ``Propagator`` class example:

        >>> print(model.propagators[0])
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Display the model member's physical data and defining expressions.

        Examples
        --------
        Using the setup in the ``Propagator`` class example:

        >>> from IPython.display import display
        >>> display(propagator)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the complete text summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``Propagator`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(propagator)

        Parameters
        ----------
        pretty : object
            IPython pretty printer receiving the text.
        cycle : bool
            Whether the object occurs recursively in the current display.
        """

@typing.final
class PropagatorMapping:
    r"""
    A formal propagator permutation determined from Symanzik polynomials.

    Unlike a momentum mapping, this supplies no tensor-numerator substitution
    or check of integration prescriptions. Signed propagator powers can be
    reordered; scalar numerators must first be expressed in family coordinates.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> D, k, p, s = S("D", "k", "p", "s")
    >>> d1, d2, x1, x2 = S("d1", "d2", "x1", "x2")
    >>> kin = hep.Kinematics(D, momenta=[k, p]).with_scalar_product(p, p, s)
    >>> denominators = [kin.scalar_product(k, k), kin.scalar_product(k-p, k-p)]
    >>> family = hep.IntegralFamily([k], [p], denominators, kinematics=kin)
    >>> m2 = S("m2")
    >>> denominators = [denominators[0] - m2, denominators[1]]
    >>> source = hep.IntegralFamily([k], [p], denominators, kinematics=kin)
    >>> target = hep.IntegralFamily([k], [p], list(reversed(denominators)), kinematics=kin)
    >>> mapping = source.parametric_mapping(target, [x1, x2])
    >>> assert mapping is not None
    >>> target_powers = mapping.map_powers([1, 2])
    >>> assert target_powers == [2, 1]
    """
    @property
    def denominator_map(self) -> builtins.list[builtins.int]:
        r"""
        Zero-based target denominator index for each source denominator.

        Examples
        --------
        Using the setup in the ``PropagatorMapping`` class example:

        >>> slot_map = mapping.denominator_map
        >>> mapped_powers = mapping.map_powers([1, 2])
        """
    def map_powers(self, powers: typing.Sequence[builtins.int]) -> builtins.list[builtins.int]:
        r"""
        Reorder signed propagator powers into target-family order.

        Examples
        --------
        Using the setup in the ``PropagatorMapping`` class example:

        >>> reordered = mapping.map_powers([1, -2])

        Parameters
        ----------
        powers : list[int]
            One signed power per source denominator.
        """

@typing.final
class Rotation:
    r"""
    A spatial rotation acting on three- and four-momenta.

    Rotations may be built from Euler angles, an identity transformation, or a
    quarter turn around a Cartesian axis.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> rotation = hep.Rotation.quarter_turn(hep.Axis.Z)
    >>> rotated = rotation.apply_three(hep.ThreeMomentum(1.0, 0.0, 0.0))
    """
    @staticmethod
    def identity() -> Rotation:
        r"""
        Construct the identity rotation.

        Examples
        --------
        Using the setup in the ``Rotation`` class example:

        >>> rotation = hep.Rotation.identity()
        """
    @staticmethod
    def euler(alpha: builtins.float, beta: builtins.float, gamma: builtins.float) -> Rotation:
        r"""
        Construct a rotation from three Euler angles in radians.

        Examples
        --------
        Using the setup in the ``Rotation`` class example:

        >>> rotation = hep.Rotation.euler(0.1, 0.2, 0.3)

        Parameters
        ----------
        alpha : float
            First Euler angle.
        beta : float
            Second Euler angle.
        gamma : float
            Third Euler angle.
        """
    @staticmethod
    def quarter_turn(axis: Axis) -> Rotation:
        r"""
        Construct a positive quarter turn around a Cartesian axis.

        Examples
        --------
        Using the setup in the ``Rotation`` class example:

        >>> rotation = hep.Rotation.quarter_turn(hep.Axis.Z)

        Parameters
        ----------
        axis : Axis
            Axis about which to rotate by pi/2.
        """
    def apply_three(self, momentum: ThreeMomentum) -> ThreeMomentum:
        r"""
        Apply this rotation to a three-momentum.

        Examples
        --------
        Using the setup in the ``Rotation`` class example:

        >>> momentum = hep.ThreeMomentum(1.0, 0.0, 0.0)
        >>> rotated = rotation.apply_three(momentum)

        Parameters
        ----------
        momentum : ThreeMomentum
            Spatial momentum to rotate.
        """
    def apply_four(self, momentum: FourMomentum) -> FourMomentum:
        r"""
        Apply this spatial rotation to a four-momentum.

        Examples
        --------
        Using the setup in the ``Rotation`` class example:

        >>> momentum = hep.FourMomentum(2.0, 1.0, 0.0, 0.0)
        >>> rotated = rotation.apply_four(momentum)

        Parameters
        ----------
        momentum : FourMomentum
            Four-momentum whose spatial components are rotated.
        """
    def apply_inverse_three(self, momentum: ThreeMomentum) -> ThreeMomentum:
        r"""
        Apply the inverse rotation to a three-momentum.

        Examples
        --------
        Using the setup in the ``Rotation`` class example:

        >>> momentum = hep.ThreeMomentum(1.0, 0.0, 0.0)
        >>> original = rotation.apply_inverse_three(rotation.apply_three(momentum))

        Parameters
        ----------
        momentum : ThreeMomentum
            Spatial momentum to inverse-rotate.
        """
    def apply_inverse_four(self, momentum: FourMomentum) -> FourMomentum:
        r"""
        Apply the inverse spatial rotation to a four-momentum.

        Examples
        --------
        Using the setup in the ``Rotation`` class example:

        >>> momentum = hep.FourMomentum(2.0, 1.0, 0.0, 0.0)
        >>> original = rotation.apply_inverse_four(rotation.apply_four(momentum))

        Parameters
        ----------
        momentum : FourMomentum
            Four-momentum whose spatial components are inverse-rotated.
        """

@typing.final
class SelfEnergyFilterOptions:
    r"""
    Configure rejection of self-energy subgraphs by mass category.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> hep.SelfEnergyFilterOptions(veto_massive=True, veto_massless=True)

    Parameters
    ----------
    veto_massive : bool, optional
        Reject self energies carried by massive particles.
    veto_massless : bool, optional
        Reject self energies carried by massless particles.
    only_scaleless : bool, optional
        Currently unsupported; ``True`` makes generation return an error.
    """
    def __new__(cls, *, veto_massive: builtins.bool = True, veto_massless: builtins.bool = True, only_scaleless: builtins.bool = False) -> SelfEnergyFilterOptions:
        r"""
        Configure rejection of self-energy subgraphs by mass category.

        Examples
        --------
        Using the setup in the ``SelfEnergyFilterOptions`` class example:

        >>> hep.SelfEnergyFilterOptions(veto_massive=True, veto_massless=True)

        Parameters
        ----------
        veto_massive : bool, optional
            Reject self energies carried by massive particles.
        veto_massless : bool, optional
            Reject self energies carried by massless particles.
        only_scaleless : bool, optional
            Currently unsupported; ``True`` makes generation return an error.
        """

@typing.final
class SnailFilterOptions:
    r"""
    Configure rejection of zero-momentum snail subgraphs.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> hep.SnailFilterOptions(veto_attached_to_massless=True)

    Parameters
    ----------
    veto_attached_to_massive : bool, optional
        Reject zero-momentum snails attached through a massive particle.
    veto_attached_to_massless : bool, optional
        Reject zero-momentum snails attached through a massless particle.
    only_scaleless : bool, optional
        Currently unsupported; ``True`` makes generation return an error.
    """
    def __new__(cls, *, veto_attached_to_massive: builtins.bool = False, veto_attached_to_massless: builtins.bool = True, only_scaleless: builtins.bool = False) -> SnailFilterOptions:
        r"""
        Configure rejection of zero-momentum snail subgraphs.

        Examples
        --------
        Using the setup in the ``SnailFilterOptions`` class example:

        >>> hep.SnailFilterOptions(veto_attached_to_massless=True)

        Parameters
        ----------
        veto_attached_to_massive : bool, optional
            Reject zero-momentum snails attached through a massive particle.
        veto_attached_to_massless : bool, optional
            Reject zero-momentum snails attached through a massless particle.
        only_scaleless : bool, optional
            Currently unsupported; ``True`` makes generation return an error.
        """

@typing.final
class SquaredAmplitude:
    r"""
    A coherent amplitude square with independent ket and bra tensor indices.

    State sums return new objects; an already-summed leg raises AmplitudeError.
    No phase-space integration, symmetry factor, flux, or state average is implicit.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> generated = process.generate_diagrams()
    >>> diagram = generated.diagrams[0]
    >>> amplitude = hep.Amplitude(generated.diagrams)
    >>> squared = amplitude.squared()
    >>> unpolarized = squared.sum_spins(average_initial=True).sum_colors(average_initial=True)
    >>> tensor = unpolarized.expression()
    """
    @property
    def amplitude(self) -> Amplitude:
        r"""
        The original coherent amplitude and its source diagrams.

        Examples
        --------
        Using the setup in the ``SquaredAmplitude`` class example:

        >>> source_diagrams = squared.amplitude.diagrams
        """
    @property
    def spin_summed(self) -> builtins.list[builtins.int]:
        r"""
        External labels whose spin states have been summed.

        Examples
        --------
        Using the setup in the ``SquaredAmplitude`` class example:

        >>> summed = squared.sum_spins()
        >>> assert set(summed.spin_summed) == {leg.index for leg in amplitude.legs}
        """
    @property
    def color_summed(self) -> builtins.list[builtins.int]:
        r"""
        External labels whose color states have been summed.

        Examples
        --------
        Using the setup in the ``SquaredAmplitude`` class example:

        >>> summed = squared.sum_colors()
        >>> assert set(summed.color_summed) == {leg.index for leg in amplitude.legs}
        """
    @staticmethod
    def from_diagram(diagram: FeynmanDiagram, *, dimension: typing.Optional[Expression | int | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | ComplexFloat | Float | builtins.int | builtins.float | builtins.str | decimal.Decimal | builtins.complex | tuple[Float | builtins.int | builtins.float | builtins.str | decimal.Decimal, Float | builtins.int | builtins.float | builtins.str | decimal.Decimal]] = None, real: typing.Optional[typing.Sequence[Expression]] = None) -> SquaredAmplitude:
        r"""
        Construct the coherent square of a single unsewn diagram.

        Examples
        --------
        Using the setup in the ``SquaredAmplitude`` class example:

        >>> squared = hep.SquaredAmplitude.from_diagram(diagram)

        Parameters
        ----------
        diagram : FeynmanDiagram
            Complete, unsewn source diagram.
        dimension : int or Expression, optional
            Lorentz dimension, default four.
        real : list[Expression] or None, optional
            Additional scalar reality assumptions.
        """
    def expression(self) -> TensorExpression:
        r"""
        Return the current tensor expression for further Spenso simplification.

        Examples
        --------
        Using the setup in the ``SquaredAmplitude`` class example:

        >>> tensor = squared.expression()
        >>> tensor = tensor.contract(collect_chains=False, collect_traces=False)
        """
    def sum_spins(self, legs: typing.Optional[typing.Sequence[builtins.int]] = None, *, average_initial: builtins.bool = False, references: typing.Optional[typing.Mapping[builtins.int, Expression]] = None, spin_vectors: typing.Optional[typing.Mapping[builtins.int, Expression]] = None) -> SquaredAmplitude:
        r"""
        Sum selected physical spin states, optionally averaging incoming states.

        Omitted legs selects all unsummed legs. Omitting a massless vector reference
        uses the covariant sum and requires a gauge-invariant amplitude. At most
        one colored massless vector leg, such as a gluon, may omit its reference
        across all sums of this square; otherwise AmplitudeError is raised because
        unphysical contributions require external ghosts. Multiple QED photons
        may use covariant sums under their Ward identities. This color-based guard
        does not establish gauge invariance for a custom model or incomplete amplitude.

        Examples
        --------
        Using the setup in the ``SquaredAmplitude`` class example:

        >>> unpolarized = squared.sum_spins(average_initial=True)
        >>> assert set(unpolarized.spin_summed) == {leg.index for leg in amplitude.legs}

        Parameters
        ----------
        legs : list[int] or None, optional
            External labels to sum; default all remaining labels.
        average_initial : bool, optional
            Divide each selected incoming completeness tensor by its state count.
        references : dict[int, Expression] or None, optional
            Unindexed axial reference momentum per selected vector leg.
        spin_vectors : dict[int, Expression] or None, optional
            Physical spin vector per selected massive Dirac leg.
        """
    def sum_colors(self, legs: typing.Optional[typing.Sequence[builtins.int]] = None, *, average_initial: builtins.bool = False) -> SquaredAmplitude:
        r"""
        Sum selected color states, optionally averaging incoming states.

        Examples
        --------
        Using the setup in the ``SquaredAmplitude`` class example:

        >>> color_averaged = squared.sum_colors(average_initial=True)

        Parameters
        ----------
        legs : list[int] or None, optional
            External labels to sum; default all remaining labels.
        average_initial : bool, optional
            Divide by the selected incoming color-space dimensions.
        """
    def __repr__(self) -> builtins.str:
        r"""
        Describe which external states have already been summed.

        Examples
        --------
        Using the setup in the ``SquaredAmplitude`` class example:

        >>> print(squared)
        """
    def paged(self, page_size: typing.Optional[builtins.int] = None, *, settings: typing.Optional[DisplaySettings] = None, notation_source: typing.Optional[builtins.str] = None) -> typing.Any:
        r"""
        Explore the current tensor expression with the interactive notebook pager.

        Examples
        --------
        Using the setup in the ``SquaredAmplitude`` class example:

        >>> viewer = squared.paged()
        >>> first_page = viewer.page()

        Parameters
        ----------
        page_size : int, optional
            None uses automatic previews: compact products may be shown completely,
            with 25 entries per page otherwise. An explicit size sets the maximum
            entries per page, between 1 and 500. Rendering budgets may show fewer.
        settings : DisplaySettings, optional
            Tensor notation, index labels, and presentation preferences.
        notation_source : str, optional
            Unsupported by the direct MathML pager, as for TensorExpression.paged().
        """
    def _display_(self) -> typing.Any:
        r"""
        Present the current tensor expression with its interactive notebook display.

        Examples
        --------
        Using the setup in the ``SquaredAmplitude`` class example:

        >>> presentation = squared._display_()
        """
    def _repr_mimebundle_(self, include: typing.Optional[typing.Sequence[builtins.str]] = None, exclude: typing.Optional[typing.Sequence[builtins.str]] = None) -> typing.Any:
        r"""
        Return the tensor expression's static and optional live representations.

        Examples
        --------
        Using the setup in the ``SquaredAmplitude`` class example:

        >>> bundle = squared._repr_mimebundle_(include=["text/html"])
        >>> html = bundle["text/html"]

        Parameters
        ----------
        include, exclude : list[str], optional
            MIME types to include or exclude from the returned representations.
        """
    def _repr_html_(self) -> typing.Any:
        r"""
        Render the current tensor expression with Spenso's printer.

        Examples
        --------
        Using the setup in the ``SquaredAmplitude`` class example:

        >>> from IPython.display import display
        >>> display(squared)
        """

@typing.final
class Subgraph(FeynmanDiagram):
    r"""
    A physics region retaining its immutable original Feynman diagram.

    Construct with ``diagram.subgraph(...)`` or ``diagram.filter(...)``. Inherited
    physics operations use this selection, with original edge IDs and momentum
    coordinates. Display keeps the full original graph as muted context.
    ``excise()`` creates independent topology and routing when those are needed.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> process = model.process(["phi", "phi"], ["phi", "phi"])
    >>> result = process.generate_diagrams(loops=1)
    >>> diagram = result.diagrams[0]
    >>> region = diagram.filter(edge=lambda edge: not edge.is_external)
    >>> left = diagram.subgraph(nodes=[0])
    >>> right = diagram.subgraph(nodes=[1])
    >>> common = left & right
    >>> independent = region.excise()
    >>> independent.validate()
    """
    @property
    def original(self) -> FeynmanDiagram:
        r"""
        Return a full view of the immutable original diagram, sharing the same underlying diagram.

        Examples
        --------
        Using the setup in the ``Subgraph`` class example:

        >>> assert region.original.id == diagram.id
        """
    @property
    def n_half_edges(self) -> builtins.int:
        r"""
        Return the number of selected half-edges, excluding isolated vertices.

        Examples
        --------
        Using the setup in the ``Subgraph`` class example:

        >>> assert region.n_half_edges == len(region.half_edge_indices())
        """
    def excise(self) -> FeynmanDiagram:
        r"""
        Materialize an independent diagram with dangling legs at the region boundary.

        Complete interaction crowns are retained. Only selected internal pairs stay
        paired; remaining incident halves become boundary legs. Proper regions get
        independent momentum coordinates and unit global weights and projector.
        Excising the complete original preserves its factors, cuts and routing.

        Examples
        --------
        Using the setup in the ``Subgraph`` class example:

        >>> region = diagram.subgraph(nodes=[0])
        >>> independent = region.excise()
        >>> independent.validate()
        """
    def half_edge_indices(self) -> builtins.list[builtins.int]:
        r"""
        Return native diagram half-edge IDs of this region.

        Examples
        --------
        Using the setup in the ``Subgraph`` class example:

        >>> selected_half_edges = region.half_edge_indices()
        >>> selected = region.original.subgraph(half_edges=selected_half_edges)
        """
    def isolated_node_indices(self) -> builtins.list[builtins.int]:
        r"""
        Return explicitly selected vertices with no incident half-edges.

        Examples
        --------
        Using the setup in the ``Subgraph`` class example:

        >>> isolated_vertices = region.isolated_node_indices()
        """
    def __len__(self) -> builtins.int:
        r"""
        Count selected half-edges and explicitly selected isolated vertices.

        Examples
        --------
        Using the setup in the ``Subgraph`` class example:

        >>> size = len(region)
        """
    def __bool__(self) -> builtins.bool:
        r"""
        Test whether any half-edge or isolated vertex is selected.

        Examples
        --------
        Using the setup in the ``Subgraph`` class example:

        >>> nonempty = bool(region)
        """
    def __and__(self, other: FeynmanDiagram) -> Subgraph:
        r"""
        Intersect two regions belonging to the same original diagram.

        Examples
        --------
        Using the setup in the ``Subgraph`` class example:

        >>> common = left & right

        Parameters
        ----------
        other : FeynmanDiagram
            Region or full diagram sharing this region's immutable original.
        """
    def __or__(self, other: FeynmanDiagram) -> Subgraph:
        r"""
        Unite two regions belonging to the same original diagram.

        Examples
        --------
        Using the setup in the ``Subgraph`` class example:

        >>> combined = left | right

        Parameters
        ----------
        other : FeynmanDiagram
            Region or full diagram sharing this region's immutable original.
        """
    def __xor__(self, other: FeynmanDiagram) -> Subgraph:
        r"""
        Select elements present in exactly one of two regions.

        Examples
        --------
        Using the setup in the ``Subgraph`` class example:

        >>> exclusive = left ^ right

        Parameters
        ----------
        other : FeynmanDiagram
            Region or full diagram sharing this region's immutable original.
        """
    def __sub__(self, other: FeynmanDiagram) -> Subgraph:
        r"""
        Remove the other region's elements from this selection.

        Examples
        --------
        Using the setup in the ``Subgraph`` class example:

        >>> remaining = left - right

        Parameters
        ----------
        other : FeynmanDiagram
            Region or full diagram sharing this region's immutable original.
        """
    def __invert__(self) -> Subgraph:
        r"""
        Complement the region relative to its immutable original diagram.

        Examples
        --------
        Using the setup in the ``Subgraph`` class example:

        >>> outside = ~region
        """

@typing.final
class SurfaceFactor:
    r"""
    A signed denominator factor referring to a stored energy surface.

    For stored surface :math:`s`, occurrence sign :math:`\epsilon\in\{-1,+1\}`
    and positive multiplicity :math:`p`, ``to_expression()`` returns
    :math:`(\epsilon s)^p`. This is the denominator, before inversion.
    ``sign`` relates the occurrence to the stored surface; it is not an LTD
    cut-edge pole sign.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> process = hep.Model.phi3().process(["phi"], ["phi", "phi"])
    >>> diagrams = process.generate_diagrams(
    ...     loops=1, max_vertices=3, maximum_bridges=0, progress=None
    ... )
    >>> diagram = diagrams.diagrams[0]
    >>> rep = diagram.integrate_energy(method="cff")
    >>> factor = rep.orientations[0].families[0].factors[0]
    >>> denominator = factor.to_expression()
    """
    @property
    def surface(self) -> EnergySurface:
        r"""
        Stored surface referenced by this factor.

        Examples
        --------
        >>> value = factor.surface
        """
    @property
    def sign(self) -> builtins.int:
        r"""
        Overall sign relative to the stored surface, +1 or -1.

        Examples
        --------
        >>> value = factor.sign
        """
    @property
    def power(self) -> builtins.int:
        r"""
        Positive multiplicity in this denominator product.

        Examples
        --------
        >>> value = factor.power
        """
    def __repr__(self) -> builtins.str:
        r"""
        Show the signed denominator and its multiplicity.

        Examples
        --------
        >>> text = repr(factor)
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Render this denominator before inversion, preserving its sign and power.

        Examples
        --------
        >>> html = factor._repr_html_()
        """
    def to_expression(self, *, expand_surfaces: builtins.bool = True) -> TensorExpression:
        r"""
        Return the signed denominator factor, including its power.

        Examples
        --------
        Using the setup in the class example:

        >>> expression = factor.to_expression()

        Parameters
        ----------
        expand_surfaces : bool, optional
            Replace stored surface placeholders by affine energy definitions.
            Defaults to True. On-shell energies remain symbolic in either case.

        Returns
        -------
        TensorExpression
            The denominator :math:`(\epsilon s)^p`, before inversion.
        """

@typing.final
class SurfacePair:
    r"""
    The two linear factors of an uncut propagator at an LTD residue.

    ``minus`` represents :math:`q_e^0-E_e` and ``plus`` represents
    :math:`q_e^0+E_e`, with :math:`q_e^0` taken from ``residue.energy_map``.
    Their product is :math:`(q_e^0)^2-E_e^2`. Each ``SurfaceFactor`` retains
    its sign relative to the stored affine surface. Switching factors changes
    only the coefficient of :math:`E_e`, not the cut-edge pole assignments.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> process = hep.Model.phi3().process(["phi"], ["phi", "phi"])
    >>> diagrams = process.generate_diagrams(
    ...     loops=1, max_vertices=3, maximum_bridges=0, progress=None
    ... )
    >>> diagram = diagrams.diagrams[0]
    >>> ltd = diagram.integrate_energy(method="ltd")
    >>> residue = ltd.residues[0]
    >>> pair = next(iter(residue.surface_pairs.values()))
    >>> denominator = pair.minus.to_expression() * pair.plus.to_expression()
    """
    @property
    def minus(self) -> SurfaceFactor:
        r"""
        The :math:`q_e^0-E_e` denominator factor evaluated at this residue.

        Examples
        --------
        >>> factor = pair.minus

        Returns
        -------
        SurfaceFactor
            The stored affine surface together with its occurrence sign.
        """
    @property
    def plus(self) -> SurfaceFactor:
        r"""
        The :math:`q_e^0+E_e` denominator factor evaluated at this residue.

        Examples
        --------
        >>> factor = pair.plus

        Returns
        -------
        SurfaceFactor
            The stored affine surface together with its occurrence sign.
        """
    def __repr__(self) -> builtins.str:
        r"""
        Identify both denominator factors for this tree edge.

        Examples
        --------
        >>> text = repr(pair)
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Render the minus/plus factors evaluated at the owning residue.

        Examples
        --------
        >>> html = pair._repr_html_()
        """

@typing.final
class Symbols:
    r"""
    Canonical expression heads owned by diagrams and imported models.

    Tensor and representation vocabulary belongs to `symbolica.community.tensor`.
    Symbols are constructed on demand so importing the module leaves time to set a license key.
    Use these references for diagram patterns and momentum construction without
    depending on internal namespaces. External and loop momenta belong to
    ``Kinematics``. Model parameters and couplings belong to
    their model; obtain those through ``model.parameter(name).symbol`` or
    ``model.coupling(name).symbol`` instead.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> Q = hep.Symbols.edge_momentum()
    >>> edge_momentum = Q(0)
    >>> mass = hep.Model.standard_model().particle("e-").mass
    """
    @staticmethod
    def edge_momentum() -> Expression:
        r"""
        Momentum family indexed by graph edge.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> reference = hep.Symbols.edge_momentum()
        """
    @staticmethod
    def denominator() -> Expression:
        r"""
        Tagged propagator denominator head; its fourth argument is the inverse denominator.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> reference = hep.Symbols.denominator()
        """
    @staticmethod
    def dimension() -> Expression:
        r"""
        Lorentz dimension used by generated diagram expressions.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> reference = hep.Symbols.dimension()
        """
    @staticmethod
    def half_edge() -> Expression:
        r"""
        Half-edge index family used to match external tensor slots.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> reference = hep.Symbols.half_edge()
        """
    @staticmethod
    def polarization() -> Expression:
        r"""
        Vector polarization wavefunction head.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> reference = hep.Symbols.polarization()
        """
    @staticmethod
    def polarization_conjugate() -> Expression:
        r"""
        Conjugated vector polarization wavefunction head.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> reference = hep.Symbols.polarization_conjugate()
        """
    @staticmethod
    def ufo_metric() -> Expression:
        r"""
        Metric head in model propagator definitions.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> reference = hep.Symbols.ufo_metric()
        """
    @staticmethod
    def ufo_index() -> Expression:
        r"""
        Index placeholder head in model propagator definitions.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> reference = hep.Symbols.ufo_index()
        """
    @staticmethod
    def ufo_momentum() -> Expression:
        r"""
        Momentum head in model propagator definitions.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> reference = hep.Symbols.ufo_momentum()
        """
    @staticmethod
    def model_conjugate() -> Expression:
        r"""
        Complex-conjugation helper used in imported model formulas.

        Examples
        --------
        >>> from symbolica.community import hepkit as hep
        >>> model = hep.Model.standard_model()
        >>> conjugate = hep.Symbols.model_conjugate()(model.parameter("CKM1x1").symbol)
        """

@typing.final
class TadpoleFilterOptions:
    r"""
    Configure rejection of tadpoles by the mass of their attachment.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> hep.TadpoleFilterOptions(veto_attached_to_massless=True)

    Parameters
    ----------
    veto_attached_to_massive : bool, optional
        Reject tadpoles attached through a massive particle.
    veto_attached_to_massless : bool, optional
        Reject tadpoles attached through a massless particle.
    only_scaleless : bool, optional
        Currently unsupported; ``True`` makes generation return an error.
    """
    def __new__(cls, *, veto_attached_to_massive: builtins.bool = True, veto_attached_to_massless: builtins.bool = True, only_scaleless: builtins.bool = False) -> TadpoleFilterOptions:
        r"""
        Configure rejection of tadpoles by the mass of their attachment.

        Examples
        --------
        Using the setup in the ``TadpoleFilterOptions`` class example:

        >>> hep.TadpoleFilterOptions(veto_attached_to_massless=True)

        Parameters
        ----------
        veto_attached_to_massive : bool, optional
            Reject tadpoles attached through a massive particle.
        veto_attached_to_massless : bool, optional
            Reject tadpoles attached through a massless particle.
        only_scaleless : bool, optional
            Currently unsupported; ``True`` makes generation return an error.
        """

@typing.final
class TensorReducer:
    r"""
    Project Lorentz-tensor integrands onto Spenso invariants.

    The reducer implements the symmetry-orbit form of the orthogonal
    Weingarten projector. Repeated loop and projector momenta are kept in
    compact contraction classes, making the common rank-20 vacuum projections
    practical without constructing the full ``19!!`` pairing matrix.
    Fully contracted projectors yield scalar ``spenso::dot`` invariants. If
    projector indices remain free, the returned expression retains them as
    explicit ``spenso::g`` tensors. Keep mixed high-rank reductions symbolic
    in ``D`` until afterward: at fixed positive integer dimension below half
    the rank, dimension-specific identities make the universal metric basis
    singular. The all-equal isotropic fast path remains well defined.
    For denominators depending on external momenta, add an independent basis
    with the ``external`` constructor keyword. Only the transverse components are then
    rotationally averaged; odd total ranks need not vanish.

    Examples
    --------
    Average a rank-two vacuum numerator over the loop direction. The result
    is proportional to the metric tensor times ``k.k / D``.

    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> from symbolica.community.tensor import TensorName, Representation, PortPattern, TensorPattern
    >>> D, mu, nu = S("D", "mu", "nu")
    >>> k, p = (TensorName.vector("hep_reducer_docs::" + name).to_expression() for name in ("k", "p"))
    >>> lorentz = Representation.mink(D)
    >>> reducer = hep.TensorReducer(D, integrated=[k(PortPattern.exact(lorentz))])
    >>> numerator = k(PortPattern.exact(lorentz, mu)) * k(PortPattern.exact(lorentz, nu))
    >>> projected = reducer.reduce(numerator)

    Parameters
    ----------
    dimension : Expression
        Lorentz-space dimension, commonly ``D`` or ``4 - 2*eps``.
    """
    @property
    def dimension(self) -> Expression:
        r"""
        Return the configured Lorentz-space dimension.

        Examples
        --------
        Using the setup in the ``TensorReducer`` class example:

        >>> assert reducer.dimension == D
        """
    def __new__(cls, dimension: Expression, *, integrated: typing.Sequence[symbolica.community.tensor.TensorName | symbolica.Expression | symbolica.community.tensor.TensorExpression] = (), external: typing.Sequence[symbolica.Expression | symbolica.community.tensor.TensorExpression] = ()) -> TensorReducer:
        r"""
        Configure the integrated momenta and independent external basis.

        Bare symbols and ``TensorName`` entries in ``integrated`` select every
        vector with that head. Compact vector expressions select one exact
        momentum, including its scalar arguments. External entries are compact
        vectors and take precedence over integrated-head selections.

        Examples
        --------
        Using the setup in the ``TensorReducer`` class example:

        >>> reducer = hep.TensorReducer(D, integrated=[k])
        >>> reducer = hep.TensorReducer(D, integrated=[k(PortPattern.exact(lorentz))], external=[p(PortPattern.exact(lorentz))])

        Parameters
        ----------
        dimension : Expression
            Lorentz-space dimension used by every ``spenso::mink`` slot.
        integrated : sequence of TensorName or Expression or TensorExpression, optional
            Whole vector heads or exact compact vectors to integrate.
        external : sequence of Expression or TensorExpression, optional
            Independent compact vectors in the denominator's external basis.
        """
    @staticmethod
    def feynkit(dimension: Expression) -> TensorReducer:
        r"""
        Construct a reducer that selects every ``gammalooprs::Q`` tensor.

        This is the convenient constructor for vacuum numerators produced by
        HEP native Feynman-rule generator. It selects the entire
        ``gammalooprs::Q`` head and is therefore intended for pure vacuum
        numerators, where every such momentum is integrated. If a graph still
        contains external ``gammalooprs::Q`` tensors, construct a reducer
        with exact compact vectors in ``integrated`` for its internal
        momenta instead.

        Examples
        --------
        The equivalent explicit selector shows which momentum head is integrated:

        >>> from symbolica import S, E
        >>> from symbolica.community import hepkit as hep
        >>> model = hep.Model.phi4()
        >>> vacuum_diagram = model.process([], []).generate_diagrams(loops=2, factorized_loop_topologies_count_range=None).diagrams[0]
        >>> reducer = hep.TensorReducer(E("4"), integrated=[E("gammalooprs::Q")])
        >>> reduced = reducer.reduce(vacuum_diagram.numerator_expression().to_expression())

        Parameters
        ----------
        dimension : Expression
            Lorentz-space dimension used by every ``spenso::mink`` slot. It
            must match the dimension carried by the input expression.
        """
    def with_pairing_limit(self, limit: builtins.int) -> TensorReducer:
        r"""
        Set the labeled-pairing budget for unsymmetrized or free-index output.

        Symmetric contraction-orbit paths do not consume this budget.

        Examples
        --------
        Using the setup in the ``TensorReducer`` class example:

        >>> reducer = reducer.with_pairing_limit(200_000)

        Parameters
        ----------
        limit : int
            Maximum number of labeled perfect matchings to enumerate.
        """
    def with_pairing_product_limit(self, limit: builtins.int) -> TensorReducer:
        r"""
        Set the relative-pairing budget for residual free-index output.

        Examples
        --------
        Using the setup in the ``TensorReducer`` class example:

        >>> reducer = reducer.with_pairing_product_limit(150_000_000)

        Parameters
        ----------
        limit : int
            Maximum Cartesian product of internal and projector matchings.
        """
    def with_output_term_limit(self, limit: builtins.int) -> TensorReducer:
        r"""
        Set the maximum number of distinct invariant output terms.

        Examples
        --------
        Using the setup in the ``TensorReducer`` class example:

        >>> reducer = reducer.with_output_term_limit(20_000)

        Parameters
        ----------
        limit : int
            Maximum compact contraction classes to materialize.
        """
    def reduce(self, expression: symbolica.Expression | symbolica.community.tensor.TensorExpression) -> TensorExpression:
        r"""
        Reduce a numerator to a TensorExpression with its ordered interface.

        Rank-one tensors must carry a final ``spenso::mink(D,index)`` argument.
        Fully contracted projectors are returned as scalar ``spenso::dot``
        invariants. Residual free projector pairs remain explicit
        ``spenso::g`` tensors; this method intentionally does not reject
        tensor-valued output. Compact dots between an integrated vector and a
        spectator are reduced directly, including nonnegative integer powers.
        Dots between integrated vectors or with declared external basis vectors
        remain scalar invariants. Negative or noninteger powers of spectator
        contractions are rejected. Odd-rank vacuum tensors vanish while retaining
        their output interface.

        Examples
        --------
        Using the setup in the ``TensorReducer`` class example:

        A rank-two vacuum projection becomes a product of dot products divided
        by the dimension:

        >>> from symbolica import S
        >>> from symbolica.community import hepkit as hep
        >>> D, mu, nu = S("hep_docs::D", "hep_docs::mu", "hep_docs::nu")
        >>> from symbolica.community.tensor import TensorName, Representation, PortPattern, TensorPattern
        >>> k, p = (TensorName.vector("hep_reducer_docs::" + name).to_expression() for name in ("k", "p"))
        >>> lorentz, dot = Representation.mink(D), TensorPattern.dot
        >>> k_compact = k(PortPattern.exact(lorentz))
        >>> p_compact = p(PortPattern.exact(lorentz))
        >>> numerator = (
        ...     k(PortPattern.exact(lorentz, mu)) * k(PortPattern.exact(lorentz, nu))
        ...     * p(PortPattern.exact(lorentz, mu)) * p(PortPattern.exact(lorentz, nu))
        ... )
        >>> reducer = hep.TensorReducer(D, integrated=[k_compact])
        >>> reduced = reducer.reduce(numerator)
        >>> expected = dot(k_compact, k_compact) * dot(p_compact, p_compact) / D
        >>> assert reduced.rank == 0 and reduced.axes == ()
        >>> assert reduced.to_expression() == expected

        Parameters
        ----------
        expression : Expression or TensorExpression
            Tensor numerator or projected tensor numerator to reduce.
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return a concise description of the reducer configuration.

        Examples
        --------
        Using the setup in the ``TensorReducer`` class example:

        >>> print(reducer)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the reducer summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``TensorReducer`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(reducer)

        Parameters
        ----------
        pretty : Any
            The IPython pretty-printer object.
        cycle : bool
            Whether this object is part of a recursive formatting cycle.
        """

class TensorReductionError(FeynkitError):
    r"""
    Failure while parsing or reducing a Lorentz tensor.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> from symbolica.community.tensor import Representation, TensorName
    >>> D, mu = S("D", "mu")
    >>> k = TensorName.vector("tensor_reduction_error_example::k")
    >>> reducer = hep.TensorReducer(D)
    >>> try:
    ...     reducer.reduce(k(Representation.mink(D)(mu)))
    ... except hep.TensorReductionError as error:
    ...     assert "no integrated vectors selected" in str(error)
    ... else:
    ...     raise AssertionError("expected a missing-selector error")
    """
    ...

@typing.final
class ThreeMomentum:
    r"""
    A Cartesian spatial momentum ``(px, py, pz)``.

    Three-momenta are used for boost velocities, spatial rotations, and the
    three-vector part of a relativistic four-momentum.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> momentum = hep.ThreeMomentum(3.0, 4.0, 0.0)
    >>> p = momentum
    >>> first = hep.ThreeMomentum(0.0, 1.0, 0.0)
    >>> second = hep.ThreeMomentum(1.0, 0.0, 0.0)
    >>> assert momentum.pt == 5.0

    Parameters
    ----------
    px : float
        Momentum component along the x axis.
    py : float
        Momentum component along the y axis.
    pz : float
        Momentum component along the z axis.
    """
    @property
    def px(self) -> builtins.float:
        r"""
        Return the x component.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> assert momentum.px == 3.0
        """
    @property
    def py(self) -> builtins.float:
        r"""
        Return the y component.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> assert momentum.py == 4.0
        """
    @property
    def pz(self) -> builtins.float:
        r"""
        Return the z component.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> assert momentum.pz == 0.0
        """
    @property
    def norm_squared(self) -> builtins.float:
        r"""
        Return the squared Euclidean norm.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> hep.ThreeMomentum(3.0, 4.0, 0.0).norm_squared
        25.0
        """
    @property
    def norm(self) -> builtins.float:
        r"""
        Return the Euclidean norm.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> hep.ThreeMomentum(3.0, 4.0, 0.0).norm
        5.0
        """
    @property
    def pt(self) -> builtins.float:
        r"""
        Return the transverse-momentum magnitude.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> hep.ThreeMomentum(3.0, 4.0, 12.0).pt
        5.0
        """
    @property
    def phi(self) -> builtins.float:
        r"""
        Return the azimuthal angle in radians.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> hep.ThreeMomentum(1.0, 0.0, 0.0).phi
        0.0
        """
    @property
    def pseudorapidity(self) -> builtins.float:
        r"""
        Return the pseudorapidity derived from the momentum direction.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> abs(hep.ThreeMomentum(1.0, 0.0, 0.0).pseudorapidity) < 1e-12
        True
        """
    def __new__(cls, px: builtins.float, py: builtins.float, pz: builtins.float) -> ThreeMomentum:
        r"""
        Construct a Cartesian three-momentum.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> momentum = hep.ThreeMomentum(3.0, 4.0, 0.0)

        Parameters
        ----------
        px : float
            Momentum along the x axis.
        py : float
            Momentum along the y axis.
        pz : float
            Momentum along the z axis.
        """
    def dot(self, other: ThreeMomentum) -> builtins.float:
        r"""
        Return the Euclidean dot product with another three-momentum.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> hep.ThreeMomentum(1.0, 0.0, 0.0).dot(hep.ThreeMomentum(2.0, 0.0, 0.0))
        2.0

        Parameters
        ----------
        other : ThreeMomentum
            Momentum to contract with this one.
        """
    def cross(self, other: ThreeMomentum) -> ThreeMomentum:
        r"""
        Return the vector cross product with another three-momentum.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> hep.ThreeMomentum(1.0, 0.0, 0.0).cross(hep.ThreeMomentum(0.0, 1.0, 0.0))
        ThreeMomentum(0, 0, 1)

        Parameters
        ----------
        other : ThreeMomentum
            Right-hand operand of the cross product.
        """
    def delta_phi(self, other: ThreeMomentum) -> builtins.float:
        r"""
        Return the wrapped azimuthal separation from another momentum.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> first.delta_phi(second)
        1.5707963267948966

        Parameters
        ----------
        other : ThreeMomentum
            Momentum whose azimuth is compared.
        """
    def delta_r(self, other: ThreeMomentum) -> builtins.float:
        r"""
        Return the angular distance in pseudorapidity-azimuth space.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> separation = first.delta_r(second)
        >>> passes_isolation = separation > 0.4

        Parameters
        ----------
        other : ThreeMomentum
            Momentum to compare with this one.
        """
    def __add__(self, other: ThreeMomentum) -> ThreeMomentum:
        r"""
        Add two spatial momenta component by component.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> total = first + second

        Parameters
        ----------
        other : ThreeMomentum
            Momentum to add.
        """
    def __sub__(self, other: ThreeMomentum) -> ThreeMomentum:
        r"""
        Subtract another spatial momentum component by component.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> incoming = hep.ThreeMomentum(3.0, 4.0, 0.0)
        >>> outgoing = hep.ThreeMomentum(1.0, 0.0, 0.0)
        >>> transfer = incoming - outgoing
        >>> assert transfer.px == 2.0

        Parameters
        ----------
        other : ThreeMomentum
            Momentum to subtract.
        """
    def __neg__(self) -> ThreeMomentum:
        r"""
        Reverse every spatial momentum component.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> incoming_convention = hep.ThreeMomentum(3.0, 4.0, 0.0)
        >>> outgoing_convention = -incoming_convention
        >>> assert outgoing_convention.px == -3.0
        """
    def __mul__(self, scalar: builtins.float) -> ThreeMomentum:
        r"""
        Scale every spatial momentum component.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> half_momentum = momentum * 0.5

        Parameters
        ----------
        scalar : float
            Multiplicative scale factor.
        """
    def __rmul__(self, scalar: builtins.float) -> ThreeMomentum:
        r"""
        Scale every spatial momentum component from the left.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> half_momentum = 0.5 * momentum

        Parameters
        ----------
        scalar : float
            Multiplicative scale factor.
        """
    def on_shell(self, mass: typing.Optional[builtins.float] = None) -> FourMomentum:
        r"""
        Lift this spatial momentum to an on-shell four-momentum.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> hep.ThreeMomentum(3.0, 4.0, 0.0).on_shell().energy
        5.0

        Parameters
        ----------
        mass : float, optional
            On-shell mass; omitted values describe a massless momentum.
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return a constructor-style representation of the components.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> track_momentum = hep.ThreeMomentum(1.0, 2.0, 3.0)
        >>> print(f"track momentum: {track_momentum!r}")
        """
    def _repr_latex_(self) -> builtins.str:
        r"""
        Render the momentum as a mathematical three-vector.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> latex = momentum._repr_latex_()
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the constructor-style form to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``ThreeMomentum`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(momentum)

        Parameters
        ----------
        pretty : object
            The IPython pretty-printer object.
        cycle : bool
            Whether this object is part of a recursive formatting cycle.
        """

@typing.final
class TraversalTree:
    r"""
    A native DFS or BFS result retaining the immutable physics diagram.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.phi4()
    >>> diagram = model.process(["phi", "phi"], ["phi", "phi"]).generate_diagrams(loops=1, progress=None).diagrams[0]

    >>> tree = diagram.depth_first_traverse(0)
    >>> discovery_order = [vertex.id for vertex in tree.nodes]
    """
    @property
    def subgraph(self) -> Subgraph:
        r"""
        Traversal edges as a reusable physics region, retaining isolated roots.

        Examples
        --------
        >>> edges = diagram.depth_first_traverse(0).subgraph.edges
        """
    @property
    def nodes(self) -> builtins.list[DiagramVertex]:
        r"""
        Physics vertices in traversal discovery order.

        Examples
        --------
        >>> order = [vertex.id for vertex in diagram.depth_first_traverse(0).nodes]
        """
    def covers(self, subgraph: Subgraph) -> Subgraph:
        r"""
        Restrict a physics region to vertices visited by this traversal.

        Examples
        --------
        >>> region = diagram.subgraph(edges=[0])
        >>> covered = diagram.depth_first_traverse(0).covers(region)

        Parameters
        ----------
        subgraph : Subgraph
            Region from the same original diagram.
        """
    def parent(self, node: builtins.int) -> typing.Optional[DiagramVertex]:
        r"""
        Immediate parent vertex, or None for the traversal root.

        Examples
        --------
        >>> tree = diagram.depth_first_traverse(0)
        >>> parent = tree.parent(tree.nodes[-1].id)

        Parameters
        ----------
        node : int
            Diagram vertex ID in this traversal.
        """
    def children(self, node: builtins.int) -> builtins.list[DiagramVertex]:
        r"""
        Immediate children in discovery order.

        Examples
        --------
        >>> children = diagram.depth_first_traverse(0).children(0)

        Parameters
        ----------
        node : int
            Diagram vertex ID in this traversal.
        """
    def ancestors(self, node: builtins.int) -> builtins.list[DiagramVertex]:
        r"""
        Strict ancestors from the immediate parent to the root.

        Examples
        --------
        >>> tree = diagram.depth_first_traverse(0)
        >>> ancestors = tree.ancestors(tree.nodes[-1].id)

        Parameters
        ----------
        node : int
            Diagram vertex ID in this traversal.
        """
    def fundamental_cycle(self, half_edge: builtins.int) -> typing.Optional[Subgraph]:
        r"""
        Fundamental cycle closed by a half-edge, or None for a tree edge.

        Examples
        --------
        >>> tree = diagram.depth_first_traverse(0)
        >>> cycles = [tree.fundamental_cycle(half.id) for half in diagram.half_edges if not half.edge.is_dangling]

        Parameters
        ----------
        half_edge : int
            Native diagram half-edge ID whose endpoints are in this traversal.
        """

@typing.final
class UfoLoadDiagnostics:
    r"""
    Provenance, options, and entity counts from loading a UFO model.

    Diagnostics make it easy to verify which restriction was applied and how
    many particles, interactions, and auxiliary structures were normalized.

    Examples
    --------
    Replace ``path/to/MyUFO`` with the directory containing your UFO model
    (``particles.py``, ``vertices.py``, and related files).

    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> loaded = hep.UfoLoader().load("path/to/MyUFO")
    >>> diagnostics = loaded.diagnostics
    >>> print(diagnostics.source, diagnostics.particle_count, diagnostics.vertex_rule_count)
    """
    @property
    def source(self) -> pathlib.Path:
        r"""
        Return the UFO source directory.

        Examples
        --------
        Using the setup in the ``UfoLoadDiagnostics`` class example:

        >>> source = diagnostics.source
        """
    @property
    def restriction_name(self) -> typing.Optional[builtins.str]:
        r"""
        Return the applied restriction-card name, if any.

        Examples
        --------
        Using the setup in the ``UfoLoadDiagnostics`` class example:

        >>> restriction_name = diagnostics.restriction_name
        """
    @property
    def simplify_model(self) -> builtins.bool:
        r"""
        Return whether model expressions were simplified while loading.

        Examples
        --------
        Using the setup in the ``UfoLoadDiagnostics`` class example:

        >>> simplify_model = diagnostics.simplify_model
        """
    @property
    def wrap_indices_in_lorentz_structures(self) -> builtins.bool:
        r"""
        Return whether normalized Lorentz indices were wrapped.

        Examples
        --------
        Using the setup in the ``UfoLoadDiagnostics`` class example:

        >>> wrap_indices_in_lorentz_structures = diagnostics.wrap_indices_in_lorentz_structures
        """
    @property
    def order_count(self) -> builtins.int:
        r"""
        Return the number of coupling orders loaded from the UFO model.

        Examples
        --------
        Using the setup in the ``UfoLoadDiagnostics`` class example:

        >>> order_count = diagnostics.order_count
        """
    @property
    def model_parameter_count(self) -> builtins.int:
        r"""
        Return the number of model parameters loaded.

        Examples
        --------
        Using the setup in the ``UfoLoadDiagnostics`` class example:

        >>> model_parameter_count = diagnostics.model_parameter_count
        """
    @property
    def particle_count(self) -> builtins.int:
        r"""
        Return the number of particles loaded.

        Examples
        --------
        Using the setup in the ``UfoLoadDiagnostics`` class example:

        >>> particle_count = diagnostics.particle_count
        """
    @property
    def propagator_count(self) -> builtins.int:
        r"""
        Return the number of propagators loaded.

        Examples
        --------
        Using the setup in the ``UfoLoadDiagnostics`` class example:

        >>> propagator_count = diagnostics.propagator_count
        """
    @property
    def lorentz_structure_count(self) -> builtins.int:
        r"""
        Return the number of Lorentz structures loaded.

        Examples
        --------
        Using the setup in the ``UfoLoadDiagnostics`` class example:

        >>> lorentz_structure_count = diagnostics.lorentz_structure_count
        """
    @property
    def coupling_count(self) -> builtins.int:
        r"""
        Return the number of couplings loaded.

        Examples
        --------
        Using the setup in the ``UfoLoadDiagnostics`` class example:

        >>> coupling_count = diagnostics.coupling_count
        """
    @property
    def vertex_rule_count(self) -> builtins.int:
        r"""
        Return the number of vertex rules loaded.

        Examples
        --------
        Using the setup in the ``UfoLoadDiagnostics`` class example:

        >>> vertex_rule_count = diagnostics.vertex_rule_count
        """
    @property
    def function_count(self) -> builtins.int:
        r"""
        Return the number of model functions loaded.

        Examples
        --------
        Using the setup in the ``UfoLoadDiagnostics`` class example:

        >>> function_count = diagnostics.function_count
        """
    @property
    def form_factor_count(self) -> builtins.int:
        r"""
        Return the number of form factors loaded.

        Examples
        --------
        Using the setup in the ``UfoLoadDiagnostics`` class example:

        >>> form_factor_count = diagnostics.form_factor_count
        """
    @property
    def parameter_value_count(self) -> builtins.int:
        r"""
        Return the number of parameter values loaded into the parameter card.

        Examples
        --------
        Using the setup in the ``UfoLoadDiagnostics`` class example:

        >>> parameter_value_count = diagnostics.parameter_value_count
        """
    def __repr__(self) -> builtins.str:
        r"""
        Return a concise summary of the UFO import diagnostics.

        Examples
        --------
        Using the setup in the ``UfoLoadDiagnostics`` class example:

        >>> print(loaded.diagnostics)
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Render the UFO source and imported object counts as a notebook table.

        Examples
        --------
        Using the setup in the ``UfoLoadDiagnostics`` class example:

        >>> from IPython.display import display
        >>> display(diagnostics)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the concise diagnostic summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``UfoLoadDiagnostics`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(diagnostics)

        Parameters
        ----------
        pretty : object
            The IPython pretty-printer object.
        cycle : bool
            Whether this object is part of a recursive formatting cycle.
        """

class UfoLoadError(FeynkitError):
    r"""
    Failure while importing or normalizing a UFO model.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> try:
    ...     hep.UfoLoader().load("/path/to/missing-model")
    ... except hep.UfoLoadError as error:
    ...     message = str(error)
    """
    ...

@typing.final
class UfoLoader:
    r"""
    Load and normalize a Universal FeynRules Output model.

    The loader delegates UFO parsing to ``ufo_model_loader`` and returns typed
    HEP model entities suitable for process and diagram generation.

    Examples
    --------
    Replace ``path/to/MyUFO`` with the directory containing your UFO model
    (``particles.py``, ``vertices.py``, and related files).

    >>> from symbolica.community import hepkit as hep
    >>> loader = hep.UfoLoader()
    >>> loaded = loader.load("path/to/MyUFO")

    Parameters
    ----------
    restriction_name : str, optional
        Restriction-card name to apply while loading.
    simplify_model : bool, optional
        Simplify normalized symbolic model expressions.
    wrap_indices_in_lorentz_structures : bool, optional
        Wrap normalized indices in Lorentz structures.
    """
    @property
    def restriction_name(self) -> typing.Optional[builtins.str]:
        r"""
        Return the configured restriction-card name.

        Examples
        --------
        Using the setup in the ``UfoLoader`` class example:

        >>> loader = hep.UfoLoader(restriction_name="massless")
        >>> assert loader.restriction_name == "massless"
        """
    @property
    def simplify_model(self) -> builtins.bool:
        r"""
        Return whether model simplification is enabled.

        Examples
        --------
        Using the setup in the ``UfoLoader`` class example:

        >>> loader = hep.UfoLoader(simplify_model=False)
        >>> assert not loader.simplify_model
        """
    @property
    def wrap_indices_in_lorentz_structures(self) -> builtins.bool:
        r"""
        Return whether normalized Lorentz indices are wrapped.

        Examples
        --------
        Using the setup in the ``UfoLoader`` class example:

        >>> loader = hep.UfoLoader(wrap_indices_in_lorentz_structures=True)
        >>> assert loader.wrap_indices_in_lorentz_structures
        """
    def __new__(cls, *, restriction_name: typing.Optional[builtins.str] = None, simplify_model: builtins.bool = True, wrap_indices_in_lorentz_structures: builtins.bool = True) -> UfoLoader:
        r"""
        Construct a UFO loader with normalization options.

        Examples
        --------
        Using the setup in the ``UfoLoader`` class example:

        >>> loader = hep.UfoLoader(restriction_name="massless")

        Parameters
        ----------
        restriction_name : str, optional
            Restriction-card name passed to the UFO loader.
        simplify_model : bool, optional
            Simplify expressions in the normalized model.
        wrap_indices_in_lorentz_structures : bool, optional
            Wrap indices in normalized Lorentz structures.
        """
    def load(self, path: builtins.str | os.PathLike | pathlib.Path) -> LoadedModel:
        r"""
        Load through the caller's attached interpreter without changing Python globals.

        Examples
        --------
        Using the setup in the ``UfoLoader`` class example:

        >>> loaded = hep.UfoLoader().load("path/to/ufo_model")
        >>> model = loaded.model

        Parameters
        ----------
        path : str or os.PathLike
            Directory containing the UFO Python modules.
        """

@typing.final
class VertexRule:
    r"""
    An interaction vertex rule from a particle model.

    A vertex rule links its participating particles to color tensors, Lorentz
    structures, and the corresponding matrix of coupling names.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.standard_model()
    >>> vertex = model.vertex_rules[0]
    >>> particles = [model.particle(name) for name in vertex.particles]
    """
    @property
    def name(self) -> builtins.str:
        r"""
        Return the vertex-rule name.

        Examples
        --------
        Using the setup in the ``VertexRule`` class example:

        >>> rules_by_name = {rule.name: rule for rule in model.vertex_rules}
        """
    @property
    def particles(self) -> builtins.list[builtins.str]:
        r"""
        Return the ordered particle names attached to the vertex.

        Examples
        --------
        Using the setup in the ``VertexRule`` class example:

        >>> vertex = model.vertex_rules[0]
        >>> particles = [model.particle(name) for name in vertex.particles]
        """
    @property
    def color_structures(self) -> builtins.list[Expression]:
        r"""
        Return the color structures used by the vertex.

        Examples
        --------
        Using the setup in the ``VertexRule`` class example:

        >>> color_basis = vertex.color_structures
        """
    @property
    def lorentz_structures(self) -> builtins.list[builtins.str]:
        r"""
        Return the Lorentz-structure names used by the vertex.

        Examples
        --------
        Using the setup in the ``VertexRule`` class example:

        >>> vertex = model.vertex_rules[0]
        >>> tensors = [model.lorentz_structure(name) for name in vertex.lorentz_structures]
        """
    @property
    def couplings(self) -> builtins.list[builtins.list[typing.Optional[builtins.str]]]:
        r"""
        Return the coupling-name matrix indexed by color and Lorentz structure.

        Examples
        --------
        Using the setup in the ``VertexRule`` class example:

        >>> vertex = model.vertex_rules[0]
        >>> names = [name for row in vertex.couplings for name in row if name is not None]
        >>> couplings = [model.coupling(name) for name in names]
        """
    def coupling_orders(self) -> builtins.dict[builtins.str, builtins.int]:
        r"""
        Combine the coupling-order powers referenced by this vertex.

        Examples
        --------
        Using the setup in the ``VertexRule`` class example:

        >>> vertex.coupling_orders()
        {'QED': 2}
        """
    def __repr__(self) -> builtins.str:
        r"""
        Summarize the defining data as well as the vertex-rule name.

        Examples
        --------
        Using the setup in the ``VertexRule`` class example:

        >>> print(next(v for v in model.vertex_rules if "e-" in v.particles))
        """
    def _repr_html_(self) -> builtins.str:
        r"""
        Display the model member's physical data and defining expressions.

        Examples
        --------
        Using the setup in the ``VertexRule`` class example:

        >>> from IPython.display import display
        >>> display(vertex)
        """
    def _repr_pretty_(self, pretty: typing.Any, cycle: builtins.bool) -> None:
        r"""
        Write the complete text summary to an IPython pretty printer.

        Examples
        --------
        Using the setup in the ``VertexRule`` class example:

        >>> from IPython.lib.pretty import pretty
        >>> text = pretty(vertex)

        Parameters
        ----------
        pretty : object
            IPython pretty printer receiving the text.
        cycle : bool
            Whether the object occurs recursively in the current display.
        """

@typing.final
class Wavefunction:
    r"""
    A fixed numerical external state in GammaLoop's MadGraph phase convention.

    Obtain states from ``FourMomentum.wavefunction(kind, helicity)``. Vector
    components use ``(E,x,y,z)`` and signature ``+---``; spinors use the chiral
    gamma-matrix basis. These external states have four components independently
    of the dimension used for internal symbolic Lorentz/Dirac algebra. A scalar
    has one component. No helicity sum, spin average or coupling is included.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> momentum = hep.FourMomentum(150.0, 0.0, 0.0, 150.0)
    >>> state = momentum.wavefunction("epsilon", hep.Helicity.PLUS)
    >>> assert state.kind == "epsilon" and len(state) == 4
    """
    @property
    def kind(self) -> builtins.str:
        r"""
        One of ``scalar``, ``epsilon``, ``epsilon_bar``, ``u``, ``u_bar``, ``v``, ``v_bar``.

        Examples
        --------
        Using the setup in the ``Wavefunction`` class example:

        >>> assert state.kind == "epsilon"
        """
    @property
    def components(self) -> builtins.list[complex]:
        r"""
        Return a copy of the numerical components as native Python complex values.

        Examples
        --------
        Using the setup in the ``Wavefunction`` class example:

        >>> values = state.components
        >>> assert len(values) == 4 and values[0] == 0j
        >>> assert abs(values[1] + 2**-0.5) < 1e-14
        """
    def bar(self) -> Wavefunction:
        r"""
        Conjugate a scalar/vector or take the chiral Dirac adjoint of a spinor.

        Calling this twice restores both the original components and state kind.

        Examples
        --------
        Using the setup in the ``Wavefunction`` class example:

        >>> assert state.bar().kind == "epsilon_bar"
        >>> assert state.bar().bar() == state
        """
    def __len__(self) -> builtins.int:
        r"""
        Return one for scalar states and four for vector or spinor states.

        Examples
        --------
        Using the setup in the ``Wavefunction`` class example:

        >>> assert len(state) == 4
        """
    def __repr__(self) -> builtins.str:
        r"""
        Describe the numerical state kind and its components.

        Examples
        --------
        Using the setup in the ``Wavefunction`` class example:

        >>> assert "Wavefunction" in repr(state)
        """
    def __eq__(self, other: Wavefunction) -> builtins.bool:
        r"""
        Compare both the external-state kind and its numerical components.

        Examples
        --------
        Using the setup in the ``Wavefunction`` class example:

        >>> assert state == state.bar().bar()

        Parameters
        ----------
        other : Wavefunction
            State to compare with this one.
        """

@typing.final
class Axis(enum.Enum):
    r"""
    A Cartesian axis used to specify spatial rotations.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> beam_axis = hep.Axis.Z
    >>> rotation = hep.Rotation.quarter_turn(beam_axis)
    """
    X = ...
    Y = ...
    Z = ...

@typing.final
class JetAlgorithm(enum.Enum):
    r"""
    A sequential-recombination algorithm for collider jet clustering.

    The available choices are kT, Cambridge--Aachen, and anti-kT.

    Examples
    --------
    >>> from symbolica.community import hepkit as hep
    >>> algorithm = hep.JetAlgorithm.AntiKt
    >>> definition = hep.JetDefinition(algorithm, radius=0.4)
    """
    Kt = ...
    CambridgeAachen = ...
    AntiKt = ...

@typing.final
class ParameterNature(enum.Enum):
    r"""
    Whether a model parameter is supplied externally or derived internally.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.standard_model()
    >>> nature = hep.ParameterNature.EXTERNAL
    >>> external = [p for p in model.parameters if p.nature == nature]
    """
    EXTERNAL = ...
    INTERNAL = ...

@typing.final
class ParameterType(enum.Enum):
    r"""
    Whether a model parameter is real-valued or complex-valued.

    Examples
    --------
    >>> from symbolica import S, E
    >>> from symbolica.community import hepkit as hep
    >>> model = hep.Model.standard_model()
    >>> real_parameters = [p for p in model.parameters
    ...                    if p.parameter_type == hep.ParameterType.REAL]
    """
    REAL = ...
    COMPLEX = ...
