Skip to content
Symi Docs
Swift
On this page

Object model

Each class is named for the Symi operation vocabulary and spelled the way its host language spells a class: Python uses CapWords (Expression, Point2d), JavaScript uses PascalCase (Expression, Point2d), and Kotlin and Swift use their UniFFI prefixed forms. The names below are given in the shared Symi spelling; see Names in each language for the rule that maps them onto one host.

context#

The root object. It owns the symbol table (names + assumptions) and the hash-consed expression interner. Every constructor and every mathematical operation is a Context method; results are Expression, Matrix, or geometry objects that hold a reference back to their context. Never mix objects from different contexts.

expression#

An immutable reference into the context's hash-consed expression tree. The same class represents numbers, symbols, arithmetic trees, function calls, unevaluated calculus nodes (integrals, derivatives, summations, transforms, exact polynomial-root atoms, ODE/recurrence placeholders, piecewise) and set values (intervals, finite sets, unions, intersections, complements, image sets, condition sets). expression_type reports the top-level node kind; the is_* shape queries and structural accessors (interval_lower, integral_integrand, union_components, …) take the node apart.

Operations that cannot produce a closed form return an unevaluated node of the matching kind rather than guessing; calling execute later retries evaluation (useful after substituting values).

matrix#

A dense symbolic matrix with Expression entries. Constructed directly against the default context with the class itself, via context.matrix for an explicit context, via matrix_identity, matrix_zero, matrix_diagonal, or returned by jacobian / hessian. Row/column indices are zero-based.

Geometry classes#

Point2d, Segment2d, Polygon2d, Triangle2d, Circle2d — exact symbolic plane geometry built from Expression coordinates. Constructing these classes directly uses the default context; their matching Context methods provide explicit-context construction.

undefined_function#

A callable proxy for a user-named function symbol, used to build the unknown function in ODE/recurrence equations: y = context.undefined_function("y"), then y(x) (Python) or y.call([x]) (JS) produces the function-call expression y(x).

Result-shape classes (WASM only)#

Where the Python binding returns tuples, the WASM binding returns small classes with named getters:

class getters returned by
RootMultiplicity root, multiplicity rootsWithMultiplicities
Eigenpair eigenvalue, vectors eigenvectors
PrimeFactor prime, multiplicity factorInteger
IsolatingInterval lower, upper isolateRealRoots
QuadraticContinuedFractionExpansion initialTerms, periodicTerms continuedFractionQuadraticIrrational
VertexAngle vertex, angle interiorAngles

Three-valued logic#

Assumption and set queries (is_real, is_positive, is_integer, is_rational, is_negative, is_nonzero, is_finite, is_member, is_subset, is_prime) are three-valued: a definite yes/no on structural proof, otherwise "unknown" (None in Python, undefined in JS). Unknown means undecided, never false.

Example#

Symi documentation · Swift