Skip to main content

Module symbolic

Module symbolic 

Source
Expand description

Python bindings for scirs2-symbolic.

Exposes the EML substrate (EmlTree, Canonical, LoweredOp), evaluation (eval_real), gradient (grad), and the symbolic-regression API (discover) under the Python sub-namespace scirs2.symbolic.

§Example (Python)

import scirs2 as s2
import numpy as np

# Build an EML tree: sin(x²)
x = s2.symbolic.EmlTree.var(0)
formula = s2.symbolic.Canonical.sin(s2.symbolic.Canonical.mul(x, x))
lowered = s2.symbolic.lower(formula)

# Evaluate at x = 0.5
result = s2.symbolic.eval_real(lowered, [0.5])
print(result)  # ~0.247

# Symbolic gradient with respect to variable 0
grad_op = s2.symbolic.grad(lowered, 0)

# Symbolic regression
features = np.array([[1.0], [2.0], [3.0]])
targets = np.array([1.0, 4.0, 9.0])
results = s2.symbolic.discover(features, targets)

Note: Canonical::sin produces a 543-node-deep canonical EML tree; evaluation is iterative (no stack blowup).

Structs§

PyCanonical
Namespace for canonical EML constructors.
PyDiscoveredFormula
Python view of a discovered formula returned by discover.
PyEmlTree
Python wrapper for scirs2_symbolic::eml::EmlTree.
PyLoweredOp
Python wrapper for scirs2_symbolic::eml::LoweredOp — the flat operator IR produced by lower.

Functions§

register_module
Register the symbolic sub-namespace on the parent scirs2 module.