neuralqx.experimental.operators.symbolic.dsl.selectors module

Symbolic selector helpers for the declarative symbolic operator DSL.

Selectors are lightweight immutable facades used at build time to construct IR symbol references pointing to site quantum numbers, site indices, and free named parameters.

class SiteSelector(label, namespace='site')

Bases: object

Symbolic selector for one Hilbert-space site iterator.

SiteSelector is created by site() and used inside DSL predicates, amplitude rules, and update programs. Attribute access on a selector returns symbolic AmplitudeExpr nodes that are resolved by the compiler at lowering time.

Parameters:

label (str) – Iterator label bound by for_each_site(label).

site(label)

Returns a symbolic site selector.

Parameters:

label (str) – Iterator label bound by for_each_site(label) or for_each_pair(label_a, label_b).

Return type:

SiteSelector

Returns:

Site selector handle.

Example

from neuralqx.experimental.operators.symbolic.dsl import site

s = site("i")
print(s.value)          # AmplitudeExpr, x[i]
print(s.index)          # AmplitudeExpr, i
print(s.value < 3)      # PredicateExpr, x[i] < 3
print(s.value + 1)      # AmplitudeExpr, x[i] + 1
emitted(label)

Returns a symbolic selector bound to the emitted or connected state x'.

Return type:

SiteSelector

Example

from neuralqx.experimental.operators.symbolic.dsl import emitted

e = emitted("i")
print(e.value)   # AmplitudeExpr, x'[i]
print(e.index)   # AmplitudeExpr, i
symbol(name)

Returns a free symbolic amplitude expression by name.

Free symbols are not bound to any site iterator, they are resolved at operator-evaluation time from external parameter dictionaries.

Parameters:

name (str) – Symbol name.

Return type:

AmplitudeExpr

Returns:

Symbolic amplitude expression.