Skip to content
Symi Docs
Swift
On this page

Solving

solve#

Explicit context

func solve(
    inputExpression: UniffiExpression,
    variable: String,
) -> [UniffiExpression]
Calling forms

Expression method: UniffiExpression.solve

func solve(variable: String) -> [UniffiExpression]

Solve an equation (an equal node, or an expression implicitly equated to zero) for variable, returning a list of solutions. Solutions outside the solver's reach are simply absent — prefer solveset when you need an honest "unsolved" residue.

solveset#

Explicit context

func solveset(
    inputExpression: UniffiExpression,
    variable: String,
) -> UniffiExpression
Calling forms

Expression method: UniffiExpression.solveset

func solveset(variable: String) -> UniffiExpression

Solution set of the equation or inequality: a finite set, interval, union, image set (periodic families), or condition set (the honest "unsolved" residue). With domain given, solutions are intersected with it (same as solveset_in_domain).

The result's set shape carries an exact contract. An empty_set is a proof that no solution exists over the stated domain (for example a non-zero constant, or a polynomial whose only roots the realness filter removes for a real variable) — never the mere absence of a found solution. A decline is reported as a condition_set {variable⁡∈domain⁡:equation⁡=0}\{\operatorname{variable} \in \operatorname{domain} : \operatorname{equation} = 0\}, the honest "unsolved" residue, whose base set is real_line() for a variable assumed real and complex_plane() otherwise. A variable declared only positive, negative or extended_real counts as real here: those declarations admit a signed infinity, but a solution is a finite point and every finite value they admit is real, so x^2 + 1 proves empty_set for a positive x. A finite_set remains the complete solution set over the stated domain. Consumers must treat condition_set as unknown (hide or skip it), never as "no solutions".

Complex exponential equations use complete periodic families rather than a single principal-logarithm value. In particular, exp(z) = c with a provably non-zero constant c returns the image set log(c) + 2*pi*i*k, k in the integers; exp(z) = 0 returns empty_set. For a real-assumed variable, the corresponding equation returns the real singleton when the target is provably positive, proves empty_set when the target is provably non-positive, and otherwise declines.

For the supported elementary functions over the complex plane, solveset returns the whole inverse image, not only a principal representative: sin(w) = c, cos(w) = c, sinh(w) = c, and cosh(w) = c produce their complete integer-periodic families; tan(w) = c and tanh(w) = c do the same except at their exact omitted values, respectively c=±ic = \pm i and c=±1c = \pm 1, where they return empty_set. Thus cos(z) = 2 has the two families 2πn±arccos⁡(2)2\pi n \pm \operatorname{arccos}(2), while cos(x) = 2 over real_line() is empty. The principal logarithm is range-checked before it is inverted, so log(z) = 2*pi*i is empty. At most two integer indices are introduced for a composition: exp(exp(z)) = 1 retains the nonzero outer-logarithm condition and returns a double-index family rather than an incomplete finite list.

Over the reals, exp(f) = h with a variable-bearing h is solved as f = log(h) once f is proved real at every point being solved over: a real f cannot equal the principal logarithm of a negative or non-real h, so no sign condition on h is needed. Each root of the logarithmic equation is then checked exactly in the original one. Realness of f uses the variable's declared sign, so exp(x*log(x)) = x returns {1} for a positive x. Over the whole real line the same step declines, because x*log(x) is not real for negative x; the equation really does have the second real root x = -1 there, where exp(-i*pi) = -1.

Zero products are decomposed only when doing so preserves both completeness and definedness. Variable-free factors must be provably non-zero, every variable-bearing factor must have a complete solution set, and a candidate zero is retained only when all remaining factors are proved defined there. Consequently (x - 1)*log(x - 1) = 0 excludes the undefined point x = 1 and returns only x = 2; an undecidable cofactor causes an honest decline. A cofactor is judged at the root itself, so log(x) at x = 2 is the finite value log(2) even though log is undefined at zero. A sum whose terms all share a variable-bearing factor is first written as that factor times the remaining sum: x*log(x) - 2*log(x) returns {1, 2} and x^2*exp(x) - 4*exp(x) returns {-2, 2}.

For a real-assumed variable, or when real_line() is supplied explicitly, solveset completely solves the supported exact univariate algebraic-function class: rational and exact real-algebraic constants, sums, products, integer and rational powers, rational functions, and absolute values. Radical domains, negative-power poles, and absolute-value sign boundaries are part of the exact formula. Thus x + sqrt(x) - 2 returns {1}, abs(x - 1) - 2 returns {-1, 3}, and sqrt(x) + 1 proves empty_set. Powered candidates are never accepted without their original sign and definedness conditions. Results may use exact algebraic roots when no smaller radical form is available.

The explicit domain takes precedence over symbol assumptions. This capability is real-domain only: apart from a single principal power with a real target (see Principal inverse layers below), general principal complex rational-power equations and nonzero complex modulus level sets currently return a condition_set unless an older exact equivalence closes them. In particular, the real sign partition is never applied to complex abs, which denotes modulus rather than ordered-field absolute value.

Proofs that depend on real-valued range restrictions remain real-domain proofs. For example, cos(x) = 2 proves empty_set for a real-assumed variable because its target is outside the registered real image; the complex case instead uses the complete complex inverse image above.

Circular equations and principal inverses#

Rational circular equations. An equation that is a rational function of sin, cos, tan, sec, csc and cot of rational multiples of one argument, with exact constant coefficients, is solved completely. With θ\theta the common angle, every term is rational in c=cos⁡θc = \cos\theta and s=sin⁡θs = \sin\theta; reducing s2=1−c2s^2 = 1 - c^2 writes the numerator as A(c)+s B(c)A(c) + s\,B(c), whose zeros on the circle are roots of A2−(1−c2)B2A^2 - (1 - c^2)B^2. Each root c0c_0 contributes ±arccos⁡(c0)+2πn\pm\arccos(c_0) + 2\pi n, with the sign fixed exactly by s=−A(c0)/B(c0)s = -A(c_0)/B(c_0), and every point where an original denominator vanishes is excluded. Over the reals only roots in [−1,1][-1, 1] remain. So sin(2*x) - cos(x) returns {π/6+2πn/3}∪{π/2+πn}\{\pi/6 + 2\pi n/3\} \cup \{\pi/2 + \pi n\}, sin(x)^2 - cos(x) returns ±arccos⁡((5−1)/2)+2πn\pm\arccos((\sqrt5 - 1)/2) + 2\pi n over the reals, and tan(x)*cos(x) - 1 proves empty_set over the reals, because sin⁡x=1\sin x = 1 only at the poles of tan. An undecided zero, sign or pole declines.

Periodic families. Every solveset answer presents a union of integer families whose periods are rational multiples of π\pi as its fewest residue classes: families sharing the part of their offset that is not a rational multiple of π\pi are merged exactly ({2πn}∪{π+2πn}={πn}\{2\pi n\} \cup \{\pi + 2\pi n\} = \{\pi n\}), a contained family or finite point is dropped, and each class is written with its offset in (−d/2,d/2](-d/2, d/2] for its period dd. For (x + 1)*(sin(x)^2 + 1)^2*cos(3*x)^3 over the complex plane the answer is {−1}∪{±iarcsinh⁡(1)+πn}∪{π/6+πn/3}\{-1\} \cup \{\pm i\operatorname{arcsinh}(1) + \pi n\} \cup \{\pi/6 + \pi n/3\}. Principal inverse circular functions are evaluated on the imaginary axis: arcsin(i*y) = i*arcsinh(y) for rational y, and arctan(i*y) = i*arctanh(y) for ∣y∣<1|y| < 1.

Comparing principal inverses. f(u) = g(v) with f, g among arcsin, arccos, arctan holds exactly when v=G(f(u))v = G(f(u)) for the forward function G of g and f(u)f(u) lies in the principal range of g (DLMF 4.23). Squaring gives a candidate equation every solution satisfies; each candidate is kept only when both conditions are proved. The range test uses the sign and size of u, never a numeric value of f(u), and a value on a branch-cut edge declines. asin(x) - atan(x) returns {0} and acos(x) - atan(x) returns {(5−1)/2}\{\sqrt{(\sqrt5 - 1)/2}\} over both the reals and the complex plane, and asin(x) - atan(x/2) returns {0,±i3}\{0, \pm i\sqrt3\} over the complex plane.

Principal inverse layers. An equation whose unknown sits inside nested invertible layers is peeled from the outside in, and each layer is inverted only for targets proved inside its principal range: log for −π<Im⁡t≤π-\pi < \operatorname{Im} t \le \pi, arcsin and arctan for ∣Re⁡t∣<π/2|\operatorname{Re} t| < \pi/2 (the closed real interval for arcsin), arccos for 0≤Re⁡t≤π0 \le \operatorname{Re} t \le \pi likewise, and a principal rational power yr=ty^r = t for a real t through exactly the branches exp⁡((Log⁡t+2πik)/r)\exp((\operatorname{Log} t + 2\pi i k)/r) whose imaginary part stays in (−π,π](-\pi, \pi]. A target outside a range contributes nothing: log(x) - 2*pi*i proves empty_set, and so does log(acos(asin(x^(2/3) - b) - 1)) + 2 for every b, since 1+cos⁡(e−2)>π/21 + \cos(e^{-2}) > \pi/2. A target whose membership depends on a real parameter is split into guarded strata, returned as a union of condition_sets whose conditions mention only the parameters; x^(2/3) = b + 1/2 with a real b gives (b+1/2)3/2(b + 1/2)^{3/2} for b>−1/2b > -1/2, 0 at b=−1/2b = -1/2, and nothing below. A target whose membership cannot be decided declines, which is why log(x) - c returns a condition_set for a complex parameter c and {exp(c)} for a real one.

Principal radical equations#

Over the complex plane, an equation built from the unknown, rationals, the imaginary unit and principal rational powers — sqrt(x + 1) = x - 1, x = 1/sqrt(1 + x^2), 2*sqrt(x) + 3*x^(1/4) = 2, nested radicals such as sqrt(1 - sqrt(x)) = x — is solved exactly. Each radicand B becomes an unknown y for its principal root B^(1/L), the radicals are eliminated by resultants, and every root of the resulting polynomial is a candidate. A candidate is kept only when the original equation, with every power principal, is proved to vanish there and every base raised to a negative power is proved nonzero, so the answer is complete and contains no root of another branch: x + sqrt(x) = 2 gives {1}, not {1, 4}, and x = 1/sqrt(1 + x^2) gives sqrt((sqrt(5) - 1)/2) and -i*sqrt((1 + sqrt(5))/2), where 1 + x^2 is negative and its principal root is imaginary. Roots the polynomial solver spells in radicals are presented that way; when one of them cannot be decided, every root is taken as a certified polynomial_root and presented as one. An equation whose eliminant vanishes identically, such as sqrt(x^2) = x (true on a half-plane), a symbolic parameter, or a candidate the exact decision cannot settle declines with a condition_set.

Over the reals, an irrational root of such an equation is presented through the irreducible factor of the eliminant that carries it: the quadratic formula for a quadratic factor, real_root(factor, x, k) otherwise.

Transcendental reductions#

A shared reduction layer handles equations in exponentials, principal logarithms, variable-base powers, and Lambert W. It is a bounded, exactly justified layer, not a general transcendental solver: unsupported shapes decline with a condition_set rather than guessing, and no numeric approximation is ever used to prove a sign, choose a branch, accept a root, or certify emptiness.

Equal exponentials. A*exp(f) + B*exp(g) = 0 with non-zero variable-free A and B is exactly exp(f - g) = -B/A. Over the complex plane this yields the full integer-parameter family; over the reals it collapses to a single logarithm for a provably positive right side, proves empty_set for a provably non-positive one, and declines when the sign is undecided. Thus exp(2 - x^2) - exp(-x) returns {-1, 2} over real_line(), and over the complex plane the union of the two complete families x=(1±9+8πin)/2x = (1 \pm \sqrt{9 + 8\pi i n}) / 2, with n in the integers. Note that the reduction keeps the 2*pi*i period rather than applying the real-only injectivity of exp over the complex plane. When f - g is affine in x with a scale that carries parameters, such as x(log⁡b−log⁡d)x(\log b - \log d) for 2*b^(x+1) - 3*d^x, the scale is never divided by unproved: where it is non-zero the family is transported, and where it vanishes the equation no longer mentions x, so every x solves it exactly when the remaining constant equation holds.

Constant-base equality. a*b^x = c*d^x is split on its coefficients before anything is divided. Over the complex plane, with non-zero bases: every x when a = c = 0, nothing when exactly one coefficient vanishes, the lattice (Log⁡(c/a)+2πin)/(Log⁡b−Log⁡d)(\operatorname{Log}(c/a) + 2\pi i n)/(\operatorname{Log} b - \operatorname{Log} d) when both are non-zero and b != d, and for b = d every x when a = c and nothing otherwise. Over the reals, with real coefficients and positive bases, the unequal-base stratum has the single root log⁡(c/a)/(log⁡b−log⁡d)\log(c/a)/(\log b - \log d) exactly when ac>0ac > 0 and nothing when ac<0ac < 0; a base equal to one needs no special case. Bases only proved non-negative add a zero-base branch, kept as an explicit condition on the original equation because 0^x is defined only for positive x.

Exponential generators. An equation whose unknown occurs only inside exponentials whose arguments are rational multiples of one another is a polynomial in one generator t = exp(u). Constant bases take part through the principal power bv=exp⁡(vLog⁡b)b^v = \exp(v \operatorname{Log} b): positive rational bases share a generator when their prime exponent vectors are proportional, found by exact factorization, so 4^x - 3*2^x + 2 is t2−3t+2t^2 - 3t + 2 in t=2xt = 2^x and returns {0, 1} over real_line(), while 6^x and 2^x never share one. Negative powers of the generator are cleared by multiplying through by a power of t, which never vanishes, so exp(x) + exp(-x) = 3 is solved completely. When the generator polynomial has degree at most two and its coefficients carry parameters, the answer is split into strata instead of declining: the leading coefficient vanishing or not, the discriminant vanishing (the two roots coalesce) or not, and over the reals the discriminant positive. Each root is lifted under its stratum and its own range condition, t≠0t \ne 0 over the complex plane and t>0t > 0 over the reals, so exp(2*x) + 3*exp(x) + 2 = z over the reals gives the single logarithm of (−3+1+4z)/2(-3 + \sqrt{1 + 4z})/2 exactly where that root is positive.

Combinatorial coefficients. binomial(m, k), falling_factorial(m, k) and rising_factorial(m, k) with a literal lower index 0 <= k <= 16 are solved as their polynomials in m, since (mk)=m(m−1)⋯(m−k+1)/k!\binom{m}{k} = m(m-1)\cdots(m-k+1)/k! holds for every m. The zero and sign strata of the coefficient then come from that polynomial: binomial(m, 2)*2^k = 1 has one real root exactly where m(m−1)/2>0m(m - 1)/2 > 0, and over the complex plane the full lattice wherever m is neither 0 nor 1.

Equal principal logarithms. log(f) - log(g) = 0 reduces to f = g together with the common non-zero definedness condition, so a root at which the shared argument vanishes is dropped rather than returned. An undecided definedness declines the completeness claim.

Lambert W. Affine and product exponential families, and the two logarithmic families, reduce to u*exp(u) = c, whose solutions are exactly W_k(c) over the integers k. Over the complex plane solveset returns the complete branch family, for example exp(x) - x gives image_set(k, integers, -lambert_w(k, -1)). Over the reals the branch count is decided exactly against the branch point -1/e: no branch below it, the single double root at it, both W_0 and W_-1 strictly between it and zero, and W_0 alone from zero upward. x*exp(x) = -1/(2e) therefore returns {W_0(-1/(2e)), W_-1(-1/(2e))} over real_line(), while x*exp(x) + 1 proves empty_set there.

Logarithmic generators. An equation built from rational constants and non-negative rational powers of one logarithm log(g(x)) becomes a polynomial in a generator, is solved completely, and each root is checked to be the principal root and to lie in the image of the principal logarithm before being lifted. sqrt(log(x)) - log(sqrt(x)) returns {1, exp(4)}. The normalisation log(z^a) = a*log(z) used there is admitted only for exact rational a with -1 < a <= 1, or for a provably positive z; log(z^2) and log(z^-1) are never rewritten without a positivity proof.

Variable-base powers. For b(x)^u(x) = b(x)^v(x) the equal-exponent, b = 1, and b = -1 fibres generate candidates, and every candidate must reduce the original equation to canonical zero. x^x = x therefore gives the exactly verified {-1, 1} from solve — never 0, whose 0^0 is undefined — while solveset over the complex plane still returns a condition_set, because the periodic fibre (u - v)*log(b) = 2*pi*i*n is not solved. This is the clearest case of the general rule below.

Over the reals b^u = K*b^w, with a real constant K and w possibly 0, is solved completely by magnitude and phase. Where b>0b > 0 the equation is equivalent to K>0K > 0 and (u−w)log⁡b=log⁡K(u - w)\log b = \log K; where b<0b < 0 the magnitudes must agree, (u−w)log⁡(−b)=log⁡∣K∣(u - w)\log(-b) = \log|K|, and each root of that is checked in the original equation, which decides the phase; each zero of b is checked directly. solveset over real_line() therefore returns {-1, 1} for x^x = x, {1} for x^x = 1, and {1/2, 1} for x^(2*x) = x, and declines when a branch equation has no finite exact solution.

Representatives versus complete sets. solve may return sound closed-form representatives for an equation whose complete solution set the solver cannot express; solveset must decline there. Conversely a complete infinite family is expressible as a set but not as a list, so solve reports only a representative slice of it. When you need to know whether an answer is complete, ask solveset (or solve_as_set, which routes through it): a finite set, image set, union, or empty_set is a completeness claim, and a condition_set is not.

solve_detailed#

Explicit context

func solveDetailed(
    equation: UniffiExpression,
    variable: String,
    options: UniffiEquationSolveOptions,
) -> UniffiEquationSolveReport

Returns a checked report without changing solve or solveset. Its certified_set is a subset proved against the original condition and its source-definedness requirements. complete is true only when the proof also establishes exhaustiveness. Otherwise unresolved_condition is the exact original-condition remainder after removing the certified subset; it is not an empty set and must not be read as no solutions. status is complete, partial, or declined; diagnostics explain a limit or missing proof, never mathematical impossibility.

For example, 1/(x - 1) = 0 over the reals can report an empty certified_set with complete=true: that is a proof of no roots. In contrast, an unsupported transcendental equation can report declined, an empty certified_set, and a non-empty unresolved_condition: that means not solved. The summary contains only a stable root proof-rule name, never the internal certificate graph. The requested domain overrides symbol assumptions for this call. Finite guarded_branches, when present, carry disjoint parameter guards and their certified sets.

When a complete real report has a finite, named root set, real_root_count_certificate gives its exact cardinality and unique_root_intervals gives exact singleton interval witnesses for those roots.

A real report can also know its root count while the solution set remains a condition_set. A residual such as 2*x + cos(x) has derivative 2 - sin(x) >= 1, so it is strictly increasing on the real line and has at most one real root; exact range bounds show it is negative at -1 and positive at 0, so by the intermediate value theorem it has exactly one root, in the open interval (-1, 0). No exact closed form names that root, so the solution set stays a condition_set while real_root_count_certificate is 1 and unique_root_intervals holds (-1, 0). The interval is a proved statement about where the root lies, not a numeric estimate of it, and neither field is ever filled from sampling.

The analysis behind these fields is bounded: derivatives up to order 3, 256 proof nodes, 32 integer interval segments, and 8 exact derivative evaluations per request. A request that exceeds a bound leaves both fields absent and adds the resource_limit diagnostic.

For admitted parameter-dependent univariate polynomials and real rational relations, the report preserves each degree-drop, discriminant, root-order, and source-pole case as a guarded branch. maximum_branches is a hard limit: if another exact split would exceed it, the original condition remains unresolved rather than presenting explored cases as exhaustive. solveset represents a complete guarded answer as a condition-set union.

maximum_branches, maximum_nodes, and maximum_algebraic_degree must be positive. A bounded proof replay that runs out of nodes reports resource_limit, retains its residue, and never upgrades the result to complete. Captured assumptions are immutable for the request, so a report is never reused after assumptions change.

solve_system_detailed#

Explicit context

func solveSystemDetailed(
    equations: [UniffiExpression],
    variables: [String],
    options: UniffiEquationSolveOptions,
) -> UniffiSystemSolveReport

The system counterpart returns a checked certified_solution, the original unresolved_equations when completeness is unproved, guarded branches, diagnostics, requested domain, and a compact proof summary. An empty certified solution is a proof of inconsistency only when complete=true; otherwise the unresolved equations remain the authoritative residue.

solveset_in_domain#

Explicit context

func solvesetInDomain(
    inputExpression: UniffiExpression,
    variable: String,
    domain: UniffiExpression,
) -> UniffiExpression

solveset restricted to an explicit domain set (e.g. real_line(), integer_set(), an interval).

Over integer_set(), or integer_set() intersected with intervals whose endpoints are exact rationals or infinities, an equation that is a rational function of the variable with exact rational coefficients is solved completely. Its candidates are the signed divisors of the numerator's constant term within the Cauchy root bound, and each is accepted only if the original equation is defined there and evaluates to exactly zero, so a cancelled factor never turns a pole into a solution: x^2 - 2 = 0 and 1/(x - 1) = 0 return empty_set, x^3 - x = 0 returns {-1, 0, 1}, and an equation whose numerator vanishes identically returns the domain minus its integer poles. When the divisors of a large constant term cannot be proved exhaustive within the factorization budget, the result is a condition_set over the integer domain, unless the domain is a range of at most 4096 integers, which are then decided one by one. Equations outside this class keep the general route.

roots_with_multiplicities#

Explicit context

func rootsWithMultiplicities(
    inputExpression: UniffiExpression,
    variable: String,
) -> [UniffiRootMultiplicity]
Calling forms

Expression method: UniffiExpression.rootsWithMultiplicities

func rootsWithMultiplicities(variable: String) -> [UniffiRootMultiplicity]

Roots of a polynomial with their multiplicities. Notes: Python returns a dict keyed by root; WASM returns an array of RootMultiplicity objects.

polynomial_root#

Explicit context

func polynomialRoot(
    inputExpression: UniffiExpression,
    variable: String,
    index: UInt64,
) -> UniffiExpression?

Construct the zero-based index-th exact root of a univariate rational polynomial. Roots use canonical mathematical order: increasing real roots first, then non-real roots ordered by exact real part and exact imaginary part; indexing counts multiplicity. Coefficient scale and the variable name do not affect the resulting atom. Invalid, constant, non-rational, out-of-range, or uncertifiable inputs return None.

The result is exact even when no radical or cyclotomic form is available. For example, substituting any root of x^5 - x - 1 back into that polynomial reduces exactly to zero in its quotient ring. Approximate evaluation is an explicit, separate operation.

The root carries the retained facts of the polynomial it was taken from, so it can appear in a compiled numeric function, which prepares it once as its correctly rounded binary64 value.

minimal_polynomial_of#

Explicit context

func minimalPolynomialOf(
    inputExpression: UniffiExpression,
    variable: String,
) -> UniffiExpression?

Return an exact polynomial in the requested variable for a first-class polynomial-root atom. Its dense primitive integer coefficients are independent of the source variable, coefficient scale, and current isolation precision.

root_multiplicity (WASM result class)#

Has root and multiplicity getters; see object model.

solve_polynomial_system#

Explicit context

func solvePolynomialSystem(
    equations: [UniffiExpression],
    variables: [String],
) -> UniffiPolynomialSystemSolution

Solve a multivariate polynomial system { equation_i = 0 } for the named unknowns. Every other free symbol is a parameter carried symbolically in the coefficient ring. The solver is sound and honestly incomplete: every returned tuple has been back-substituted into every equation and reduced to a provable zero, and the verdict never overstates completeness.

The result reports one of six verdicts — finite (a list of solution tuples), empty (certified no solutions), affine (a complete parameterized family, a particular solution plus an independent direction basis), conditional (an exhaustive partition of parameter space into guarded branches, each carrying its own complete result), positive_dimensional (certified infinitely many, with no family produced), or declined (could not close the system) — plus a complete flag that is true only when the engine certified it found every solution.

An affine result is complete in the strong sense: the solution set of an affine system is a coset of the coefficient matrix's kernel, so the direction count is the exact dimension of the solution set, n−rank⁡An - \operatorname{rank} A, and the directions are certified independent.

For a linear system whose coefficients are rational in parameters, the rank can change on relations among the parameters, and the answer is a conditional partition of parameter space into strata of constant rank. Elimination divides only by entries proved nonzero; where every candidate is undecided, the space is split on one irreducible factor of the entry that blocked it — the factor is nonzero, or it vanishes. A vanishing relation that determines a parameter linearly is substituted into the system, so a - b - c = 0 specializes a to b + c; a relation linear in a parameter with an undecided coefficient is split on that coefficient first. The domain conditions of the source equations travel with each substitution, so on a = b + c a denominator a reads b + c and the branch guard states b + c != 0. A split whose vanishing stratum has exactly the answer of a sibling branch is absorbed into that branch, so guards name only the relations where the answer really changes. The branch count is bounded, and a system that needs more splits declines rather than publishing a partial partition; a relation of degree two or more in every parameter can only be entered as a hypothesis, and declines when that hypothesis cannot be decided. Notes: Python returns a dict with keys verdict (str), complete (bool), solutions (a list of { unknown_name: ExpressionLike } dicts), affine_families (a list of { variables, particular_solution, direction_vectors } dicts), parametric_components (a list of certified chart dicts), and conditional_branches (a list of { condition, solution } dicts whose solution is a nested result dict); WASM returns a PolynomialSystemSolution object.

polynomial_system_solution (WASM result class)#

The WASM return of solve_polynomial_system. Python returns a plain dict in its place.

verdict#

UniffiPolynomialSystemSolution method

func verdict() -> UniffiSystemVerdict

Getter on PolynomialSystemSolution: the verdict string, one of "finite", "empty", "affine", "conditional", "positive_dimensional", or "parametric_components", or "declined".

complete#

UniffiPolynomialSystemSolution method

func complete() -> Bool

Getter on PolynomialSystemSolution: whether the solver certified it found every solution.

solutions#

Getter on PolynomialSystemSolution: the array of SystemAssignment tuples (empty for the non-finite verdicts).

UniffiPolynomialSystemSolution method

func solutions() -> [UniffiSystemAssignment]

Getter on polynomial_system_solution: the array of system_assignment tuples (empty for the non-finite verdicts).

affine_families#

UniffiPolynomialSystemSolution method

func affineFamilies() -> [UniffiAffineSystemFamily]

Getter on PolynomialSystemSolution: the complete affine families, empty unless the verdict is "affine".

parametric_components#

UniffiPolynomialSystemSolution method

func parametricComponents() -> [UniffiSystemParametricComponent]

Getter on PolynomialSystemSolution: the certified explicit charts, empty unless the verdict is "parametric_components".

component_parameters#

UniffiSystemParametricComponent method

func parameters() -> [String]

Getter on SystemParametricComponent: the fresh independent parameter names.

component_assignments#

UniffiSystemParametricComponent method

func assignments() -> UniffiSystemAssignment

Getter on SystemParametricComponent: the exact solved-variable assignments.

component_parameter_guard#

UniffiSystemParametricComponent method

func parameterGuard() -> UniffiExpression

Getter on SystemParametricComponent: the parameter-space guard of this chart.

component_source_conditions#

UniffiSystemParametricComponent method

func sourceConditions() -> [UniffiExpression]

Getter on SystemParametricComponent: source definedness conditions retained by this chart.

component_certificate_summary#

UniffiSystemParametricComponent method

func certificateSummary() -> String

Getter on SystemParametricComponent: a concise exact construction certificate.

conditional_branches#

UniffiPolynomialSystemSolution method

func conditionalBranches() -> [UniffiConditionalSystemBranch]

Getter on PolynomialSystemSolution: the exhaustive guarded branches, empty unless the verdict is "conditional". The branch conditions are mutually exclusive and together cover the whole parameter space the request left open.

system_assignment (WASM result class)#

One solution tuple of a polynomial system, pairing each unknown with its value.

affine_system_family (WASM result class)#

A complete affine family of solutions: every sum of the particular solution and an arbitrary linear combination of the direction vectors, and nothing else.

system_parametric_component (WASM result class)#

One certified rational chart of a positive-dimensional component. Its parameters, assignments, parameter guard, inherited source conditions, and certificate summary describe both the chart and the exact conditions under which it covers solutions.

affine_system_direction (WASM result class)#

One independent direction of an affine family, as a coordinate vector over the same unknowns.

conditional_system_branch (WASM result class)#

One guarded branch of a conditional result: a parameter condition together with the complete solution that holds wherever it is true.

variables#

UniffiSystemAssignment method

func variables() -> [String]
Calling forms and variants

Variant for this object — UniffiAffineSystemDirection method: UniffiAffineSystemDirection.variables

func variables() -> [String]

Variant for this object — UniffiAffineSystemFamily method: UniffiAffineSystemFamily.variables

func variables() -> [String]

Getter on SystemAssignment, AffineSystemFamily, or AffineSystemDirection: the unknown names, in the order the unknowns were requested, whatever order the solver eliminated them in.

values#

UniffiSystemAssignment method

func values() -> [UniffiExpression]
Calling forms and variants

Variant for this object — UniffiAffineSystemDirection method: UniffiAffineSystemDirection.values

func values() -> [UniffiExpression]

Getter on SystemAssignment: the assigned value expressions, aligned with variables. On AffineSystemDirection the same getter gives the direction components in that order.

particular_solution#

UniffiAffineSystemFamily method

func particularSolution() -> [UniffiExpression]

Getter on AffineSystemFamily: one exact solution of the system, aligned with variables.

direction_vectors#

UniffiAffineSystemFamily method

func directionVectors() -> [UniffiAffineSystemDirection]

Getter on AffineSystemFamily: an independent basis of the homogeneous solution space, as AffineSystemDirection records. Its size is the dimension of the family, so a family with no directions is a single point.

branch_condition#

UniffiConditionalSystemBranch method

func condition() -> UniffiExpression

Getter on ConditionalSystemBranch: the exact condition selecting this branch, as a relation between parameters.

branch_solution#

UniffiConditionalSystemBranch method

func solution() -> UniffiPolynomialSystemSolution

Getter on ConditionalSystemBranch: the complete result established under the branch condition. It is a PolynomialSystemSolution of its own, so a branch may itself be finite, empty or an affine family.

real_root_count#

Explicit context

func realRootCount(
    inputExpression: UniffiExpression,
    variable: String,
    lower: Int64,
    upper: Int64,
) -> UInt64?

Number of distinct real roots of a univariate polynomial in the interval (lower, upper] via Sturm sequences. None when the expression is not a univariate polynomial over the rationals.

count_distinct_real_roots#

Explicit context

func countDistinctRealRoots(
    inputExpression: UniffiExpression,
    variable: String,
) -> UInt64?

Number of distinct real roots over all of R\mathbb{R}. Same None conditions as real_root_count.

real_root_sign#

Explicit context

func realRootSign(
    inputExpression: UniffiExpression,
    variable: String,
    index: UInt64,
) -> Int64?

The exact sign (-1, 0, or 1) of the index-th smallest real root of a univariate polynomial over the rationals, decided exactly through the real algebraic number layer rather than by numeric evaluation. None when the expression is not a univariate polynomial over the rationals or index is out of range.

compare_real_roots#

Explicit context

func compareRealRoots(
    firstExpression: UniffiExpression,
    firstVariable: String,
    firstIndex: UInt64,
    secondExpression: UniffiExpression,
    secondVariable: String,
    secondIndex: UInt64,
) -> Int64?

Compare two real algebraic numbers exactly, each given as the index-th smallest real root of a univariate polynomial over the rationals. Returns -1, 0, or 1 according to whether the first is less than, equal to, or greater than the second — a total order decided exactly (for example compare_real_roots of 2\sqrt{2} and 33\sqrt[3]{3} returns -1). None when either operand is not a univariate polynomial over the rationals or an index is out of range.

Real quantifier elimination and semialgebraic solving#

eliminate_quantifiers#

Explicit context

func eliminateQuantifiers(
    matrix: UniffiExpression,
    quantifiers: [UniffiQuantifier],
    variables: [String],
) -> UniffiExpression

context.eliminate_quantifiers(matrix, quantifiers: list[str], variables: list[VariableLike])

Effective real quantifier elimination: returns a quantifier-free expression equivalent over R\mathbb{R} to the prenex formula whose quantifier-free matrix is a Boolean combination of polynomial relations and whose quantifiers prefix (each "forall" or "exists", outermost first) binds the trailing variables. Built on the cylindrical algebraic decomposition: the matrix's truth is evaluated on the sign-invariant cells and projected through the quantifier prefix, then a solution formula in the free variables is constructed and verified exact at every cell sample point. For example, ∀x. x2+ax+1>0\forall x.\ x^2 + a x + 1 > 0 eliminates to a2−4<0a^2 - 4 < 0 (that is, −2<a<2-2 < a < 2); a fully-quantified sentence returns a Boolean constant. Errors outside Q[variables]\mathbb{Q}[\text{variables}], on a decomposition decline, or when the solution formula cannot be certified.

solve_semialgebraic#

Explicit context

func solveSemialgebraic(
    matrix: UniffiExpression,
    variables: [String],
) -> UniffiExpression

context.solve_semialgebraic(matrix, variables: list[VariableLike])

Nonlinear polynomial constraint / inequality solving over Rn\mathbb{R}^n — the no-quantifier case of quantifier elimination. Given a Boolean combination of polynomial relations over Q[variables]\mathbb{Q}[\text{variables}], returns the quantifier-free description of the real solution set { x : matrix(x) } (the disjunction of the satisfying CAD cells' sign conditions). This generalises the univariate solve over inequalities to the multivariate semialgebraic case (for example, {(x,y):x2−1<0∧y2−1<0}\{(x, y) : x^2 - 1 < 0 \land y^2 - 1 < 0\} is the open square). Errors outside Q[variables]\mathbb{Q}[\text{variables}] or on a decomposition decline.

Example#

solve_as_set#

Not exposed by the Swift bindings. Available as api::Expression::solve_as_set in Rust.

The solution set of an equation as a set-valued expression, rather than the list of solutions solve returns. A set answer can express solution families a list cannot — an image set over the integers, or a union of several families — so it is the right entry when the solution set may be infinite. See Sets for what can be done with the result.

Additional API#

EquationGuardedBranch#

EquationGuardedBranch.certified_set#

UniffiEquationGuardedBranch method

func certifiedSet() -> UniffiExpression

The exact solution set certified by this report or guarded branch.

EquationGuardedBranch.guard#

UniffiEquationGuardedBranch method

func guard() -> UniffiExpression

The exact parameter condition selecting this guarded branch.

EquationSolveReport#

EquationSolveReport.certified_set#

UniffiEquationSolveReport method

func certifiedSet() -> UniffiExpression

The exact solution set certified by this report or guarded branch.

EquationSolveReport.complete#

UniffiEquationSolveReport method

func complete() -> Bool

Whether exact replay proved that the certified result is exhaustive.

EquationSolveReport.diagnostics#

UniffiEquationSolveReport method

func diagnostics() -> [UniffiSolveReportDiagnostic]

Non-impossibility reasons that prevented a stronger report.

EquationSolveReport.guarded_branches#

UniffiEquationSolveReport method

func guardedBranches() -> [UniffiEquationGuardedBranch]

The exact guarded strata carried by this report.

EquationSolveReport.proof_summary#

UniffiEquationSolveReport method

func proofSummary() -> UniffiSolveProofSummary

The root checked proof rule, without exposing the internal proof graph.

EquationSolveReport.real_root_count_certificate#

UniffiEquationSolveReport method

func realRootCountCertificate() -> UInt64?

Exact real-root count when this complete report established a finite real root set.

EquationSolveReport.requested_domain#

UniffiEquationSolveReport method

func requestedDomain() -> UniffiSolveRequestedDomain

The ambient domain in which the report was checked.

EquationSolveReport.status#

UniffiEquationSolveReport method

func status() -> UniffiSolveReportStatus

The checked report status: complete, partial, or declined.

EquationSolveReport.unique_root_intervals#

UniffiEquationSolveReport method

func uniqueRootIntervals() -> [UniffiExpression]

Exact singleton intervals for named roots whose real-root count was certified.

EquationSolveReport.unresolved_condition#

UniffiEquationSolveReport method

func unresolvedCondition() -> UniffiExpression?

The retained source-condition residue, absent only after an exhaustive proof.

SystemSolveReport#

SystemSolveReport.certified_solution#

UniffiSystemSolveReport method

func certifiedSolution() -> UniffiPolynomialSystemSolution

The assignments or families checked against the original system.

SystemSolveReport.complete#

UniffiSystemSolveReport method

func complete() -> Bool

Whether exact replay proved that the certified result is exhaustive.

SystemSolveReport.diagnostics#

UniffiSystemSolveReport method

func diagnostics() -> [UniffiSolveReportDiagnostic]

Non-impossibility reasons that prevented a stronger report.

SystemSolveReport.guarded_branches#

UniffiSystemSolveReport method

func guardedBranches() -> [UniffiConditionalSystemBranch]

The exact guarded strata carried by this report.

SystemSolveReport.proof_summary#

UniffiSystemSolveReport method

func proofSummary() -> UniffiSolveProofSummary

The root checked proof rule, without exposing the internal proof graph.

SystemSolveReport.requested_domain#

UniffiSystemSolveReport method

func requestedDomain() -> UniffiSolveRequestedDomain

The ambient domain in which the report was checked.

SystemSolveReport.status#

UniffiSystemSolveReport method

func status() -> UniffiSolveReportStatus

The checked report status: complete, partial, or declined.

SystemSolveReport.unresolved_equations#

UniffiSystemSolveReport method

func unresolvedEquations() -> [UniffiExpression]

The retained original equations when a system report is not complete.

Symi documentation · Swift