Generated by
sema docfrom the compiler’s authoritative native-signature registry.
native builtins
Section titled “native builtins”Ambient constructors and tensor/embedding builtins — no import required.
rational
Section titled “rational”QQ(value, denominator?) -> rational
Section titled “QQ(value, denominator?) -> rational”Exact rational constructor: canonical coprime form, positive denominator.
- domain: one finite number (exact binary-rational conversion for floats), or int numerator and nonzero int denominator
- shape: constructor
- returns:
rational - example:
QQ(1, 3)
Rational(value, denominator?) -> rational
Section titled “Rational(value, denominator?) -> rational”Exact rational constructor: canonical coprime form, positive denominator.
- domain: one finite number (exact binary-rational conversion for floats), or int numerator and nonzero int denominator
- shape: constructor
- returns:
rational - example:
Rational(2, 4)
rational(value, denominator?) -> rational
Section titled “rational(value, denominator?) -> rational”Exact rational constructor: canonical coprime form, positive denominator.
- domain: one finite number (exact binary-rational conversion for floats), or int numerator and nonzero int denominator
- shape: constructor
- returns:
rational - example:
rational(0.5)
to_QQ(value, denominator?) -> rational
Section titled “to_QQ(value, denominator?) -> rational”Exact rational constructor: canonical coprime form, positive denominator.
- domain: one finite number (exact binary-rational conversion for floats), or int numerator and nonzero int denominator
- shape: constructor
- returns:
rational - example:
to_QQ(0.5)
sets_logic
Section titled “sets_logic”FiniteSet(items...) -> FiniteSet
Section titled “FiniteSet(items...) -> FiniteSet”Construct a canonical finite set from explicit elements.
- domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
- shape: finite set / three-valued logic
- returns:
FiniteSet - example:
FiniteSet(1, 2, 2)
set(iterable?) -> FiniteSet
Section titled “set(iterable?) -> FiniteSet”Explicitly convert a list, tuple, or FiniteSet to FiniteSet.
- domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
- shape: finite set / three-valued logic
- returns:
FiniteSet - example:
set([1, 2, 2])
subset(left, right) -> bool
Section titled “subset(left, right) -> bool”Test extensional subset.
- domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
- shape: finite set / three-valued logic
- returns:
bool - example:
subset({1}, {1, 2})
proper_subset(left, right) -> bool
Section titled “proper_subset(left, right) -> bool”Test strict extensional subset.
- domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
- shape: finite set / three-valued logic
- returns:
bool - example:
proper_subset({1}, {1, 2})
superset(left, right) -> bool
Section titled “superset(left, right) -> bool”Test extensional superset.
- domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
- shape: finite set / three-valued logic
- returns:
bool - example:
superset({1, 2}, {1})
union(left, right) -> FiniteSet
Section titled “union(left, right) -> FiniteSet”Bounded finite-set union.
- domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
- shape: finite set / three-valued logic
- returns:
FiniteSet - example:
union({1}, {2})
intersection(left, right) -> FiniteSet
Section titled “intersection(left, right) -> FiniteSet”Bounded finite-set intersection.
- domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
- shape: finite set / three-valued logic
- returns:
FiniteSet - example:
intersection({1, 2}, {2, 3})
set_difference(left, right) -> FiniteSet
Section titled “set_difference(left, right) -> FiniteSet”Bounded finite-set difference.
- domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
- shape: finite set / three-valued logic
- returns:
FiniteSet - example:
set_difference({1, 2}, {2})
symmetric_difference(left, right) -> FiniteSet
Section titled “symmetric_difference(left, right) -> FiniteSet”Bounded symmetric difference.
- domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
- shape: finite set / three-valued logic
- returns:
FiniteSet - example:
symmetric_difference({1, 2}, {2, 3})
cartesian_product(left, right) -> FiniteSet
Section titled “cartesian_product(left, right) -> FiniteSet”Bounded Cartesian product as a set of tuples.
- domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
- shape: finite set / three-valued logic
- returns:
FiniteSet - example:
cartesian_product({1}, {2})
power_set(set) -> FiniteSet
Section titled “power_set(set) -> FiniteSet”Power set for at most twelve input elements.
- domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
- shape: finite set / three-valued logic
- returns:
FiniteSet - example:
power_set({1, 2})
indexed_union(family) -> FiniteSet
Section titled “indexed_union(family) -> FiniteSet”Union a bounded family of explicit finite sets.
- domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
- shape: finite set / three-valued logic
- returns:
FiniteSet - example:
indexed_union([{1}, {2}])
indexed_intersection(family) -> FiniteSet
Section titled “indexed_intersection(family) -> FiniteSet”Intersect a nonempty bounded family of explicit finite sets.
- domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
- shape: finite set / three-valued logic
- returns:
FiniteSet - example:
indexed_intersection([{1, 2}, {2}])
indicator(set, value) -> int
Section titled “indicator(set, value) -> int”Exact 0/1 finite-set indicator.
- domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
- shape: finite set / three-valued logic
- returns:
int - example:
indicator({1, 2}, 2)
logical_not(value) -> Truth
Section titled “logical_not(value) -> Truth”Strong-Kleene negation.
- domain: bool or explicit Truth; Unknown retains its reason and has no implicit bool conversion
- shape: finite set / three-valued logic
- returns:
Truth - example:
logical_not(Truth.unknown)
logical_and(left, right) -> Truth
Section titled “logical_and(left, right) -> Truth”Strong-Kleene conjunction.
- domain: bool or explicit Truth; Unknown retains its reason and has no implicit bool conversion
- shape: finite set / three-valued logic
- returns:
Truth - example:
logical_and(Truth.unknown, false)
logical_or(left, right) -> Truth
Section titled “logical_or(left, right) -> Truth”Strong-Kleene disjunction.
- domain: bool or explicit Truth; Unknown retains its reason and has no implicit bool conversion
- shape: finite set / three-valued logic
- returns:
Truth - example:
logical_or(Truth.unknown, true)
logical_xor(left, right) -> Truth
Section titled “logical_xor(left, right) -> Truth”Three-valued exclusive-or.
- domain: bool or explicit Truth; Unknown retains its reason and has no implicit bool conversion
- shape: finite set / three-valued logic
- returns:
Truth - example:
logical_xor(true, false)
implies(left, right) -> Truth
Section titled “implies(left, right) -> Truth”Strong-Kleene implication.
- domain: bool or explicit Truth; Unknown retains its reason and has no implicit bool conversion
- shape: finite set / three-valued logic
- returns:
Truth - example:
implies(Truth.unknown, false)
iff(left, right) -> Truth
Section titled “iff(left, right) -> Truth”Strong-Kleene biconditional.
- domain: bool or explicit Truth; Unknown retains its reason and has no implicit bool conversion
- shape: finite set / three-valued logic
- returns:
Truth - example:
iff(true, true)
forall(domain, predicate) -> Truth
Section titled “forall(domain, predicate) -> Truth”Universal quantification over an explicit FiniteSet.
- domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
- shape: finite set / three-valued logic
- returns:
Truth - example:
forall({1, 2}, lambda x: x > 0)
exists(domain, predicate) -> Truth
Section titled “exists(domain, predicate) -> Truth”Existential quantification over an explicit FiniteSet.
- domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
- shape: finite set / three-valued logic
- returns:
Truth - example:
exists({1, 2}, lambda x: x == 2)
exists_unique(domain, predicate) -> Truth
Section titled “exists_unique(domain, predicate) -> Truth”Unique-existence quantification over an explicit FiniteSet.
- domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
- shape: finite set / three-valued logic
- returns:
Truth - example:
exists_unique({1, 2}, lambda x: x == 2)
domain
Section titled “domain”complex(real?, imag?) -> complex
Section titled “complex(real?, imag?) -> complex”Finite approximate complex scalar with checked arithmetic and C99 branch conventions.
- domain: zero to two finite f64-representable real components, or one complex value
- shape: constructor
- returns:
complex - example:
complex(1.5, -2.0)
Algebraic(coefficients, lower, upper) -> algebraic
Section titled “Algebraic(coefficients, lower, upper) -> algebraic”Certified exact real algebraic number represented by a square-free polynomial and isolating interval.
- domain: primitive bounded integer polynomial and exact rational isolating interval containing exactly one real root
- shape: constructor
- returns:
algebraic - example:
Algebraic([-2, 0, 1], 1, 2)
algebraic(coefficients, lower, upper) -> algebraic
Section titled “algebraic(coefficients, lower, upper) -> algebraic”Lowercase exact algebraic-real constructor.
- domain: primitive bounded integer polynomial and exact rational isolating interval containing exactly one real root
- shape: constructor
- returns:
algebraic - example:
algebraic([-2, 0, 1], 1, 2)
interval(lower, upper?) -> interval
Section titled “interval(lower, upper?) -> interval”Certified closed f64 interval with outward-rounded arithmetic and transcendentals.
- domain: one finite real point or two ordered finite f64-representable endpoints
- shape: constructor
- returns:
interval - example:
interval(-0.1, 0.1)
real_ball(midpoint, radius?) -> real_ball
Section titled “real_ball(midpoint, radius?) -> real_ball”Certified outward-rounded real ball for validated approximate computation.
- domain: finite f64 midpoint and optional nonnegative finite radius
- shape: constructor
- returns:
real_ball - example:
real_ball(1.0, 0.01)
Quantity(value, unit) -> quantity
Section titled “Quantity(value, unit) -> quantity”Physical quantity stored in SI base dimensions.
- domain: finite f64 value and a supported SI-derived unit expression
- shape: constructor
- returns:
quantity - example:
Quantity(1.0, "km")
quantity(value, unit) -> quantity
Section titled “quantity(value, unit) -> quantity”Lowercase physical-quantity constructor.
- domain: finite f64 value and a supported SI-derived unit expression
- shape: constructor
- returns:
quantity - example:
quantity(1.0, "km")
to_quantity(value, unit) -> quantity
Section titled “to_quantity(value, unit) -> quantity”Construct a physical quantity in a named unit.
- domain: finite f64 value and a supported SI-derived unit expression
- shape: constructor
- returns:
quantity - example:
to_quantity(1.0, "km")
convert_unit(quantity, unit) -> float
Section titled “convert_unit(quantity, unit) -> float”Return the quantity’s numeric value expressed in the target unit.
- domain: physical quantity and a dimension-compatible supported unit expression
- shape: scalar
- returns:
float - example:
convert_unit(quantity(1.0, "km"), "m")
to_unit(quantity, unit) -> float
Section titled “to_unit(quantity, unit) -> float”Alias for convert_unit.
- domain: physical quantity and a dimension-compatible supported unit expression
- shape: scalar
- returns:
float - example:
to_unit(quantity(1.0, "km"), "m")
dimension(value) -> list[int]
Section titled “dimension(value) -> list[int]”Return SI exponents in length, mass, time, current, temperature, amount, luminous-intensity order.
- domain: physical quantity or supported SI unit spelling
- shape: bounded discrete / graph
- returns:
list[int] - example:
dimension(quantity(2.0, "N"))
dimension_check(left, right) -> bool
Section titled “dimension_check(left, right) -> bool”Decide exact equality of two seven-axis SI dimension vectors.
- domain: two physical quantities or supported SI unit spellings
- shape: bounded discrete / graph
- returns:
bool - example:
dimension_check("J", quantity(1.0, "N") * quantity(1.0, "m"))
simplify_unit(value) -> str
Section titled “simplify_unit(value) -> str”Return a deterministic coherent SI spelling accepted by the quantity constructor.
- domain: physical quantity or supported SI unit spelling
- shape: bounded discrete / graph
- returns:
str - example:
simplify_unit(quantity(1.0, "N") * quantity(1.0, "m"))
equivalent_unit(left, right) -> bool
Section titled “equivalent_unit(left, right) -> bool”Alias for exact SI dimension equality; scale and magnitude do not affect equivalence.
- domain: two physical quantities or supported SI unit spellings
- shape: bounded discrete / graph
- returns:
bool - example:
equivalent_unit("J", "N*m")
base_units() -> any
Section titled “base_units() -> any”Return the seven supported SI base-unit dimension vectors.
- domain: no arguments
- shape: bounded discrete / graph
- returns:
any - example:
base_units()
derived_units() -> any
Section titled “derived_units() -> any”Return the curated coherent SI derived-unit dimension vectors.
- domain: no arguments
- shape: bounded discrete / graph
- returns:
any - example:
derived_units()
unit_prefix(prefix) -> float
Section titled “unit_prefix(prefix) -> float”Return the finite f64 decimal scale for an SI prefix.
- domain: one explicit SI decimal prefix from quecto through quetta
- shape: scalar
- returns:
float - example:
unit_prefix("k")
quantity_uncertainty(center, uncertainty) -> any
Section titled “quantity_uncertainty(center, uncertainty) -> any”Return closed lower and upper quantity bounds without inventing a distribution.
- domain: two dimension-compatible finite quantities; uncertainty magnitude is interpreted as absolute
- shape: bounded discrete / graph
- returns:
any - example:
quantity_uncertainty(quantity(10.0, "m"), quantity(0.1, "m"))
physical_constant(name) -> quantity
Section titled “physical_constant(name) -> quantity”Return a pinned finite-f64 SI nominal value and dimensions; this is not exact, proved, or uncertainty-bearing evidence.
- domain: one curated SI constant name: c, h, G, e, k_B, or N_A (or its descriptive alias)
- shape: constructor
- returns:
quantity - example:
physical_constant("speed_of_light")
quaternion(w?, x?, y?, z?) -> quaternion
Section titled “quaternion(w?, x?, y?, z?) -> quaternion”Finite approximate Hamilton quaternion with checked algebra and rotation operations.
- domain: zero to four finite f64-representable Hamilton components, or one quaternion
- shape: constructor
- returns:
quaternion - example:
quaternion(1.0, 0.0, 0.0, 0.0)
modint(value, modulus) -> modint
Section titled “modint(value, modulus) -> modint”Canonical exact residue class with checked same-modulus arithmetic, inverses, and powers.
- domain: exact integer value and modulus in 2..=2^63
- shape: constructor
- returns:
modint - example:
modint(10, 7)
Modular(value, modulus) -> modint
Section titled “Modular(value, modulus) -> modint”Canonical exact residue class with checked same-modulus arithmetic, inverses, and powers.
- domain: exact integer value and modulus in 2..=2^63
- shape: constructor
- returns:
modint - example:
Modular(10, 7)
decimal(value) -> decimal
Section titled “decimal(value) -> decimal”Exact decimal input with an explicit bounded significant-digit arithmetic context.
- domain: decimal string or exact integer; precision 1..=4933; half_even or half_up
- shape: constructor
- returns:
decimal - keywords:
precision,rounding - example:
decimal("1.25", precision=28, rounding="half_even")
machine_int(value) -> int
Section titled “machine_int(value) -> int”Explicit checked conversion to the bounded machine-integer lane.
- domain: exact integral value representable by signed i64; fractional and out-of-range inputs fail typed
- shape: constructor
- returns:
int - example:
machine_int(42)
to_machine_int(value) -> int
Section titled “to_machine_int(value) -> int”Explicit checked conversion to the bounded machine-integer lane.
- domain: exact integral value representable by signed i64; fractional and out-of-range inputs fail typed
- shape: constructor
- returns:
int - example:
to_machine_int(QQ(42, 1))
ZZ(value) -> int
Section titled “ZZ(value) -> int”Construct Sema’s canonical arbitrary-precision integer lane.
- domain: exact integral number or integer text under the 16,384-bit value ceiling; no truncation
- shape: constructor
- returns:
int - example:
ZZ("12345678901234567890")
BigInt(value) -> int
Section titled “BigInt(value) -> int”Alias for the checked ZZ constructor.
- domain: exact integral number or integer text under the 16,384-bit value ceiling; no truncation
- shape: constructor
- returns:
int - example:
BigInt("12345678901234567890")
to_ZZ(value) -> int
Section titled “to_ZZ(value) -> int”Explicit lossless conversion to the canonical exact-integer lane.
- domain: exact integral number or integer text under the 16,384-bit value ceiling; no truncation
- shape: constructor
- returns:
int - example:
to_ZZ(QQ(9, 1))
Real(value) -> float
Section titled “Real(value) -> float”Explicit finite-f64 real constructor.
- domain: value explicitly convertible to a finite IEEE-754 f64
- shape: constructor
- returns:
float - example:
Real(QQ(1, 2))
to_real(value) -> float
Section titled “to_real(value) -> float”Explicit finite-f64 conversion; overflow and non-finite results fail typed.
- domain: value explicitly convertible to a finite IEEE-754 f64
- shape: constructor
- returns:
float - example:
to_real(QQ(1, 2))
Complex(real?, imag?) -> complex
Section titled “Complex(real?, imag?) -> complex”Uppercase alias for the checked complex constructor.
- domain: zero to two finite f64-representable real components, or one complex value
- shape: constructor
- returns:
complex - example:
Complex(1.0, -2.0)
to_complex(real, imag?) -> complex
Section titled “to_complex(real, imag?) -> complex”Explicit conversion to the checked complex domain.
- domain: one finite numeric/complex value or two finite f64-representable components
- shape: constructor
- returns:
complex - example:
to_complex(1.0, -2.0)
Interval(lower, upper?) -> interval
Section titled “Interval(lower, upper?) -> interval”Uppercase alias for the outward-rounded interval constructor.
- domain: one finite real point or two ordered finite f64-representable endpoints
- shape: constructor
- returns:
interval - example:
Interval(-0.1, 0.1)
to_interval(lower, upper?) -> interval
Section titled “to_interval(lower, upper?) -> interval”Explicit conversion to a checked closed interval.
- domain: one finite real point or two ordered finite f64-representable endpoints
- shape: constructor
- returns:
interval - example:
to_interval(1.0)
Quaternion(w?, x?, y?, z?) -> quaternion
Section titled “Quaternion(w?, x?, y?, z?) -> quaternion”Uppercase alias for the checked Hamilton quaternion constructor.
- domain: zero to four finite f64-representable Hamilton components, or one quaternion
- shape: constructor
- returns:
quaternion - example:
Quaternion(1.0, 0.0, 0.0, 0.0)
to_quaternion(w, x?, y?, z?) -> quaternion
Section titled “to_quaternion(w, x?, y?, z?) -> quaternion”Explicit conversion to the checked quaternion domain.
- domain: one quaternion or one to four finite f64-representable Hamilton components
- shape: constructor
- returns:
quaternion - example:
to_quaternion(1.0)
to_modular(value, modulus) -> modint
Section titled “to_modular(value, modulus) -> modint”Explicit conversion to the canonical modular-integer domain.
- domain: exact integer value and modulus in 2..=2^63
- shape: constructor
- returns:
modint - example:
to_modular(10, 7)
Decimal(value) -> decimal
Section titled “Decimal(value) -> decimal”Uppercase alias for the exact decimal constructor.
- domain: decimal string or exact integer; precision 1..=4933; half_even or half_up
- shape: constructor
- returns:
decimal - keywords:
precision,rounding - example:
Decimal("1.25", precision=28)
to_decimal(value) -> decimal
Section titled “to_decimal(value) -> decimal”Explicit conversion to the bounded exact-decimal domain.
- domain: decimal string, exact integer, or decimal value with an explicit bounded arithmetic context
- shape: constructor
- returns:
decimal - keywords:
precision,rounding - example:
to_decimal("1.25", precision=28)
DenseTensor(data) -> Tensor
Section titled “DenseTensor(data) -> Tensor”Explicit dense-tensor constructor.
- domain: uniform bounded rectangular nested numeric/bool data or an existing dense Tensor
- shape: constructor
- returns:
Tensor - keywords:
dtype - example:
DenseTensor([[1.0, 2.0]])
to_dense_tensor(data) -> Tensor
Section titled “to_dense_tensor(data) -> Tensor”Explicit checked conversion to a dense Tensor.
- domain: uniform bounded rectangular nested numeric/bool data or an existing dense Tensor
- shape: constructor
- returns:
Tensor - keywords:
dtype - example:
to_dense_tensor([1.0, 2.0])
SparseTensor(value_or_rows, cols?, row_indices?, col_indices?, values?) -> SparseMatrix
Section titled “SparseTensor(value_or_rows, cols?, row_indices?, col_indices?, values?) -> SparseMatrix”Explicit sparse-tensor constructor retaining canonical CSR storage.
- domain: one existing SparseMatrix, or five validated finite COO constructor arguments
- shape: constructor
- returns:
SparseMatrix - example:
SparseTensor(2, 2, [0, 1], [0, 1], [1.0, 2.0])
to_sparse_tensor(value_or_rows, cols?, row_indices?, col_indices?, values?) -> SparseMatrix
Section titled “to_sparse_tensor(value_or_rows, cols?, row_indices?, col_indices?, values?) -> SparseMatrix”Explicit sparse conversion; no implicit dense-to-sparse threshold is guessed.
- domain: one existing SparseMatrix, or five validated finite COO constructor arguments
- shape: constructor
- returns:
SparseMatrix - example:
to_sparse_tensor(sparse(1, 1, [0], [0], [1.0]))
domain_of(value) -> str
Section titled “domain_of(value) -> str”Return the canonical observable scientific domain name.
- domain: one runtime value
- shape: scalar
- returns:
str - example:
domain_of(QQ(1, 3))
is_integer(value) -> bool
Section titled “is_integer(value) -> bool”Decide exact mathematical integrality without truncation.
- domain: one runtime value; values outside the predicate’s scientific domain return false
- shape: scalar
- returns:
bool - example:
is_integer(QQ(4, 2))
is_rational(value) -> bool
Section titled “is_rational(value) -> bool”Decide whether a bounded scalar has an exact rational value.
- domain: one runtime value; values outside the predicate’s scientific domain return false
- shape: scalar
- returns:
bool - example:
is_rational(0.5)
is_decimal(value) -> bool
Section titled “is_decimal(value) -> bool”Test membership in the exact-decimal runtime domain.
- domain: one runtime value; values outside the predicate’s scientific domain return false
- shape: scalar
- returns:
bool - example:
is_decimal(decimal("1.25"))
is_algebraic(value) -> bool
Section titled “is_algebraic(value) -> bool”Test membership in the certified algebraic-real runtime domain.
- domain: one runtime value; values outside the predicate’s scientific domain return false
- shape: scalar
- returns:
bool - example:
is_algebraic(Algebraic([-2, 0, 1], 1, 2))
is_real(value) -> bool
Section titled “is_real(value) -> bool”Decide whether a scalar value lies on the real axis.
- domain: one runtime value; values outside the predicate’s scientific domain return false
- shape: scalar
- returns:
bool - example:
is_real(complex(1.0, 0.0))
is_complex(value) -> bool
Section titled “is_complex(value) -> bool”Test membership in the explicit complex runtime domain.
- domain: one runtime value; values outside the predicate’s scientific domain return false
- shape: scalar
- returns:
bool - example:
is_complex(complex(1.0, 2.0))
is_finite(value) -> bool
Section titled “is_finite(value) -> bool”Decide whether every represented numeric component is finite.
- domain: one runtime value; values outside the predicate’s scientific domain return false
- shape: scalar
- returns:
bool - example:
is_finite(tensor([1.0, 2.0]))
is_nan(value) -> bool
Section titled “is_nan(value) -> bool”Detect NaN in a scalar or dense/sparse tensor payload.
- domain: one runtime value; values outside the predicate’s scientific domain return false
- shape: scalar
- returns:
bool - example:
is_nan(math.nan)
is_infinite(value) -> bool
Section titled “is_infinite(value) -> bool”Detect infinity in a scalar or dense/sparse tensor payload.
- domain: one runtime value; values outside the predicate’s scientific domain return false
- shape: scalar
- returns:
bool - example:
is_infinite(math.inf)
is_exact(value) -> bool
Section titled “is_exact(value) -> bool”Test membership in an exact or explicit enclosure domain.
- domain: one runtime value; values outside the predicate’s scientific domain return false
- shape: scalar
- returns:
bool - example:
is_exact(QQ(1, 3))
is_symbolic(value) -> bool
Section titled “is_symbolic(value) -> bool”Test whether a runtime value is a symbolic equation object.
- domain: one runtime value; values outside the predicate’s scientific domain return false
- shape: scalar
- returns:
bool - example:
is_symbolic(None)
is_tensor(value) -> bool
Section titled “is_tensor(value) -> bool”Test dense or sparse tensor membership.
- domain: one runtime value; values outside the predicate’s scientific domain return false
- shape: scalar
- returns:
bool - example:
is_tensor(tensor([1.0]))
is_quantity(value) -> bool
Section titled “is_quantity(value) -> bool”Test physical-quantity domain membership.
- domain: one runtime value; values outside the predicate’s scientific domain return false
- shape: scalar
- returns:
bool - example:
is_quantity(quantity(1.0, "m"))
rotate(rotation, vector) -> list[float]
Section titled “rotate(rotation, vector) -> list[float]”Rotate a three-vector by the orientation represented by a nonzero quaternion.
- domain: nonzero quaternion and a finite length-3 real vector
- shape: constructor
- returns:
list[float] - example:
rotate(quaternion(1.0), [1.0, 2.0, 3.0])
slerp(start, end, t) -> quaternion
Section titled “slerp(start, end, t) -> quaternion”Shortest-path normalized spherical interpolation between orientations.
- domain: two nonzero quaternions and finite t in [0, 1]
- shape: constructor
- returns:
quaternion - example:
slerp(quaternion(1.0), quaternion(0.0, 0.0, 0.0, 1.0), 0.5)
tensor
Section titled “tensor”tensor(data) -> Tensor
Section titled “tensor(data) -> Tensor”Build a typed Tensor from rectangular nested data.
- domain: uniform nested numeric or bool data with optional matching f64/bool dtype; bounded rank/elements
- shape: constructor
- returns:
Tensor - keywords:
dtype - example:
tensor([true, false], dtype="bool")
matmul(a, b) -> Tensor
Section titled “matmul(a, b) -> Tensor”Matrix product (or matrix·vector), shape-checked.
- domain: 2-D shapes (m,k)·(k,n), or matrix·vector; typed ShapeError otherwise
- shape: contraction
- returns:
Tensor - example:
matmul(eye(2), ones([2, 2]))
dot(a, b) -> float
Section titled “dot(a, b) -> float”Dot product of two vectors.
- domain: two equal-length 1-D vectors (bounded reduction work)
- shape: reduction
- returns:
float - example:
dot(tensor([1.0, 2.0]), tensor([3.0, 4.0]))
zeros(shape) -> Tensor
Section titled “zeros(shape) -> Tensor”Tensor of zeros with the given shape.
- domain: nonnegative exact int or list/tuple of them (bounded elements)
- shape: constructor
- returns:
Tensor - example:
zeros([2, 3])
ones(shape) -> Tensor
Section titled “ones(shape) -> Tensor”Tensor of ones with the given shape.
- domain: nonnegative exact int or list/tuple of them (bounded elements)
- shape: constructor
- returns:
Tensor - example:
ones(3)
eye(n) -> Tensor
Section titled “eye(n) -> Tensor”n×n identity matrix.
- domain: one nonnegative exact int dimension (bounded elements)
- shape: constructor
- returns:
Tensor - example:
eye(2)
arange(stop) -> Tensor
Section titled “arange(stop) -> Tensor”1-D tensor of 0.0..stop-1.
- domain: exact integer stop (negative yields an empty tensor; bounded elements)
- shape: constructor
- returns:
Tensor - example:
arange(4)
full(shape, value) -> Tensor
Section titled “full(shape, value) -> Tensor”Build a typed dense tensor filled with one value.
- domain: bounded shape and finite numeric, bool, or complex fill value
- shape: constructor
- returns:
Tensor - example:
full([2, 2], 3.0)
reshape(tensor, shape) -> Tensor
Section titled “reshape(tensor, shape) -> Tensor”Reshape contiguous storage without changing element order.
- domain: Tensor and bounded shape with exactly the same element count
- shape: constructor
- returns:
Tensor - example:
reshape(arange(6), [2, 3])
flatten(value) -> any
Section titled “flatten(value) -> any”Flatten a Tensor to rank one or flatten one level of a list.
- domain: Tensor or ordinary list; tensors preserve dtype
- shape: constructor
- returns:
any - example:
flatten(reshape(arange(6), [2, 3]))
squeeze(tensor, axis?) -> Tensor
Section titled “squeeze(tensor, axis?) -> Tensor”Remove singleton dimensions.
- domain: Tensor and optional singleton axis
- shape: constructor
- returns:
Tensor - keywords:
axis - example:
squeeze(zeros([1, 2, 1]))
unsqueeze(tensor, axis) -> Tensor
Section titled “unsqueeze(tensor, axis) -> Tensor”Insert a singleton dimension.
- domain: Tensor and insertion axis
- shape: constructor
- returns:
Tensor - example:
unsqueeze(arange(3), 0)
transpose_axes(tensor, axes?) -> Tensor
Section titled “transpose_axes(tensor, axes?) -> Tensor”Permute tensor axes into new contiguous storage.
- domain: Tensor and optional complete signed-axis permutation
- shape: constructor
- returns:
Tensor - example:
transpose_axes(reshape(arange(6), [2, 3]), [1, 0])
broadcast_to(tensor, shape) -> Tensor
Section titled “broadcast_to(tensor, shape) -> Tensor”Materialize NumPy-compatible broadcasting.
- domain: Tensor and compatible higher-rank bounded shape
- shape: elementwise
- returns:
Tensor - example:
broadcast_to(tensor([1.0, 2.0]), [2, 2])
broadcast_arrays(tensors...) -> any
Section titled “broadcast_arrays(tensors...) -> any”Broadcast all tensors to their common bounded shape.
- domain: one tensor list or variadic broadcast-compatible tensors
- shape: elementwise
- returns:
any - example:
broadcast_arrays(tensor([[1.0], [2.0]]), tensor([3.0, 4.0]))
concatenate(tensors, axis?) -> Tensor
Section titled “concatenate(tensors, axis?) -> Tensor”Concatenate tensors along one axis.
- domain: nonempty same-rank, same-dtype tensor list with matching non-concatenated dimensions
- shape: constructor
- returns:
Tensor - keywords:
axis - example:
concatenate([arange(2), arange(3)])
concat(tensors, axis?) -> Tensor
Section titled “concat(tensors, axis?) -> Tensor”Alias for concatenate.
- domain: same contract as concatenate
- shape: constructor
- returns:
Tensor - keywords:
axis - example:
concat([arange(2), arange(3)])
stack(tensors, axis?) -> Tensor
Section titled “stack(tensors, axis?) -> Tensor”Stack tensors along a new axis.
- domain: nonempty identical-shape, same-dtype tensor list
- shape: constructor
- returns:
Tensor - keywords:
axis - example:
stack([arange(3), arange(3)])
batch(tensors, axis?) -> Tensor
Section titled “batch(tensors, axis?) -> Tensor”Build a dense batch by stacking equal-shape tensors.
- domain: same contract as stack
- shape: constructor
- returns:
Tensor - keywords:
axis - example:
batch([arange(3), arange(3)])
split(tensor, sections, axis?) -> any
Section titled “split(tensor, sections, axis?) -> any”Split a tensor into equal contiguous sections.
- domain: Tensor, bounded positive section count exactly dividing the selected axis
- shape: constructor
- returns:
any - keywords:
axis - example:
split(arange(6), 3)
slice(tensor, start, stop, step?, axis?) -> Tensor
Section titled “slice(tensor, start, stop, step?, axis?) -> Tensor”Copy a signed-step slice along one axis.
- domain: Tensor and bounded Python-style signed slice coordinates
- shape: constructor
- returns:
Tensor - keywords:
step,axis - example:
slice(arange(6), 1, 5, 2)
index(tensor, indices) -> any
Section titled “index(tensor, indices) -> any”Read a scalar or trailing subtensor by signed prefix indices.
- domain: Tensor and exact integer or prefix index tuple/list
- shape: introspection
- returns:
any - example:
index(reshape(arange(6), [2, 3]), [1, 2])
gather(tensor, indices, axis?) -> Tensor
Section titled “gather(tensor, indices, axis?) -> Tensor”Gather positions along one axis.
- domain: Tensor and bounded signed integer index list
- shape: constructor
- returns:
Tensor - keywords:
axis - example:
gather(arange(4), [3, 1])
scatter(tensor, indices, updates, axis?) -> Tensor
Section titled “scatter(tensor, indices, updates, axis?) -> Tensor”Return an immutable tensor with indexed updates applied.
- domain: Tensor, bounded signed indices, and same-dtype updates of the gathered shape
- shape: constructor
- returns:
Tensor - keywords:
axis - example:
scatter(arange(4), [1, 3], tensor([9.0, 8.0]))
einsum(specification, left, right?) -> Tensor
Section titled “einsum(specification, left, right?) -> Tensor”Bounded Einstein summation with exact shape validation.
- domain: explicit-output ASCII-label Einstein notation over one or two same-dtype f64 or complex tensors
- shape: contraction
- returns:
Tensor - example:
einsum("ij,jk->ik", eye(2), ones([2, 2]))
tensordot(left, right, axes?) -> Tensor
Section titled “tensordot(left, right, axes?) -> Tensor”Contract the final left and initial right axes.
- domain: matching f64 or complex tensors and bounded trailing/leading contraction-axis count
- shape: contraction
- returns:
Tensor - keywords:
axes - example:
tensordot(eye(2), ones([2, 2]), 1)
contiguous(tensor) -> Tensor
Section titled “contiguous(tensor) -> Tensor”Return the tensor unchanged; all native tensors are contiguous.
- domain: native Tensor (already row-major contiguous by invariant)
- shape: introspection
- returns:
Tensor - example:
contiguous(arange(3))
device(tensor) -> str
Section titled “device(tensor) -> str”Report the honest native backend device (cpu).
- domain: native Tensor
- shape: introspection
- returns:
str - example:
device(arange(3))
to_device(tensor, device) -> Tensor
Section titled “to_device(tensor, device) -> Tensor”Select the native CPU device without fake accelerator transfers.
- domain: native Tensor and
cpuorauto; unsupported devices fail loudly - shape: introspection
- returns:
Tensor - example:
to_device(arange(3), "cpu")
to_dtype(tensor, dtype) -> Tensor
Section titled “to_dtype(tensor, dtype) -> Tensor”Convert tensor elements to a supported dtype.
- domain: native Tensor and f64, bool, or complex dtype with checked conversion
- shape: elementwise
- returns:
Tensor - example:
to_dtype(arange(3), "complex")
shape(value) -> list[int]
Section titled “shape(value) -> list[int]”Dimensions of a tensor as a list of ints.
- domain: a Tensor/Embedding/list (scalars report [])
- shape: introspection
- returns:
list[int] - example:
shape(zeros([2, 3]))
dtype(tensor) -> str
Section titled “dtype(tensor) -> str”Return the tensor dtype (f64, bool, or complex).
- domain: Tensor with an explicit runtime dtype
- shape: introspection
- returns:
str - example:
dtype(tensor([true, false]))
where(condition, when_true, when_false) -> Tensor
Section titled “where(condition, when_true, when_false) -> Tensor”Select broadcast branch elements using a boolean tensor condition.
- domain: broadcastable bool condition and same-dtype f64, bool, or complex branches
- shape: elementwise (binary broadcast)
- returns:
Tensor - example:
where(tensor([true, false]), tensor([1.0, 2.0]), 0.0)
sparse_linalg
Section titled “sparse_linalg”sparse(rows, cols, row_indices, col_indices, values) -> SparseMatrix
Section titled “sparse(rows, cols, row_indices, col_indices, values) -> SparseMatrix”Construct a first-class canonical sparse CSR matrix.
- domain: validated finite COO triplets canonicalized to immutable CSR under shape and nnz ceilings
- shape: constructor
- returns:
SparseMatrix - example:
sparse(2, 2, [0, 1], [0, 1], [1.0, 2.0])
sparse_matmul(matrix, operand) -> SparseMatrix | Vec | Matrix
Section titled “sparse_matmul(matrix, operand) -> SparseMatrix | Vec | Matrix”Sparse-preserving product; dense operands produce dense tensors.
- domain: CSR times CSR or a dense real vector/matrix under exact work and fill ceilings
- shape: contraction
- returns:
SparseMatrix | Vec | Matrix - example:
sparse_matmul(sparse(1, 1, [0], [0], [2.0]), sparse(1, 1, [0], [0], [3.0]))
sparse_solve(matrix, rhs) -> Vec
Section titled “sparse_solve(matrix, rhs) -> Vec”Solve through bounded pivoted sparse LU without densification.
- domain: square finite CSR system and length-matching dense real right-hand side
- shape: contraction
- returns:
Vec - example:
sparse_solve(sparse(1, 1, [0], [0], [2.0]), [4.0])
sparse_transpose(matrix) -> SparseMatrix
Section titled “sparse_transpose(matrix) -> SparseMatrix”Transpose while preserving canonical CSR storage.
- domain: canonical CSR matrix under shape and nnz ceilings
- shape: decomposition
- returns:
SparseMatrix - example:
sparse_transpose(sparse(1, 2, [0], [1], [2.0]))
sparse_lu(matrix) -> tuple[SparseMatrix, SparseMatrix, list[int]]
Section titled “sparse_lu(matrix) -> tuple[SparseMatrix, SparseMatrix, list[int]]”Return sparse L/U factors and row permutation.
- domain: square finite CSR matrix under pivot-search, work, and factor-fill ceilings
- shape: decomposition
- returns:
tuple[SparseMatrix, SparseMatrix, list[int]] - example:
sparse_lu(sparse(1, 1, [0], [0], [2.0]))
sparse_lstsq(matrix, rhs) -> Vec
Section titled “sparse_lstsq(matrix, rhs) -> Vec”Sparse normal-equation least squares with typed rank deficiency.
- domain: finite CSR design matrix and length-matching dense real right-hand side
- shape: contraction
- returns:
Vec - example:
sparse_lstsq(sparse(2, 1, [0, 1], [0, 0], [1.0, 1.0]), [1.0, 3.0])
sparse_eigs(matrix, iterations?, tolerance?) -> tuple[float, Vec, float, int, bool]
Section titled “sparse_eigs(matrix, iterations?, tolerance?) -> tuple[float, Vec, float, int, bool]”Dominant sparse eigenpair with residual and convergence evidence.
- domain: square finite CSR matrix, optional bounded positive iterations and finite positive tolerance
- shape: decomposition
- returns:
tuple[float, Vec, float, int, bool] - example:
sparse_eigs(sparse(2, 2, [0, 1], [0, 1], [4.0, 1.0]), 100, 0.0000000001)
reduction
Section titled “reduction”any(values) -> bool | Tensor
Section titled “any(values) -> bool | Tensor”Whether any element is true; bool tensors support axis reduction.
- domain: ordinary iterable, or bool Tensor with optional signed axis/keepdims
- shape: reduction
- returns:
bool | Tensor - keywords:
axis,keepdims - example:
any(tensor([true, false]))
all(values) -> bool | Tensor
Section titled “all(values) -> bool | Tensor”Whether every element is true; bool tensors support axis reduction.
- domain: ordinary iterable, or bool Tensor with optional signed axis/keepdims
- shape: reduction
- returns:
bool | Tensor - keywords:
axis,keepdims - example:
all(tensor([true, false]))
mean(values) -> int | rational | float | Tensor
Section titled “mean(values) -> int | rational | float | Tensor”Mean; exact rational for exact inputs, float once any float enters, or deterministic complex tensor reduction.
- domain: non-empty iterable, or finite f64/complex tensor with optional integer axis/keepdims
- shape: reduction
- returns:
int | rational | float | Tensor - keywords:
axis,keepdims - example:
mean([1.0, 2.0, 4.0])
sum(values, start?) -> int | rational | float | Tensor
Section titled “sum(values, start?) -> int | rational | float | Tensor”Sum; exact for exact inputs, float once any float enters, or deterministic complex tensor reduction.
- domain: iterable plus optional start, or finite f64/complex tensor with optional integer axis/keepdims
- shape: reduction
- returns:
int | rational | float | Tensor - keywords:
start,axis,keepdims - example:
sum([1, 2, 3], start=4)
min(values...) -> float | Tensor
Section titled “min(values...) -> float | Tensor”Minimum value, with signed-axis tensor reduction support.
- domain: orderable values, or non-empty finite f64 Tensor
- shape: reduction
- returns:
float | Tensor - keywords:
axis,keepdims - example:
min([3, 1, 2])
max(values...) -> float | Tensor
Section titled “max(values...) -> float | Tensor”Maximum value, with signed-axis tensor reduction support.
- domain: orderable values, or non-empty finite f64 Tensor
- shape: reduction
- returns:
float | Tensor - keywords:
axis,keepdims - example:
max([3, 1, 2])
prod(tensor) -> float | Tensor
Section titled “prod(tensor) -> float | Tensor”Deterministic product over all elements or one signed axis.
- domain: finite f64/complex Tensor; empty products use the dtype’s one identity
- shape: reduction
- returns:
float | Tensor - keywords:
axis,keepdims - example:
prod(tensor([2.0, 3.0, 4.0]))
argmin(tensor) -> int | Tensor
Section titled “argmin(tensor) -> int | Tensor”Index of the first minimum over all elements or one signed axis.
- domain: non-empty finite f64 Tensor; first index wins ties
- shape: reduction
- returns:
int | Tensor - keywords:
axis,keepdims - example:
argmin(tensor([3.0, 1.0, 2.0]))
argmax(tensor) -> int | Tensor
Section titled “argmax(tensor) -> int | Tensor”Index of the first maximum over all elements or one signed axis.
- domain: non-empty finite f64 Tensor; first index wins ties
- shape: reduction
- returns:
int | Tensor - keywords:
axis,keepdims - example:
argmax(tensor([3.0, 1.0, 2.0]))
embedding
Section titled “embedding”embed(text) -> Tensor
Section titled “embed(text) -> Tensor”Embed text as a rank-1 tensor via the configured embedding seam.
- domain: any string (deterministic hash embedder unless a model is configured)
- shape: constructor
- returns:
Tensor - effects:
model.embed - example:
embed("sema native registry")
arithmetic
Section titled “arithmetic”divmod(a, b) -> tuple[int | rational | float, int | rational | float]
Section titled “divmod(a, b) -> tuple[int | rational | float, int | rational | float]”Python-compatible floored quotient/remainder pair (a//b, a%b); exact for exact operands.
- domain: numbers with a nonzero divisor
- shape: scalar
- returns:
tuple[int | rational | float, int | rational | float] - example:
divmod(9, 4)