SolutionSet
SolutionSet
SolutionSet()Exact solutions returned by Expression.solve.
Iterate or index this set to get Solution branches. Each branch describes an alternative: a point, or a family of points with free variables. len(result) counts branches, so a set of length one can still contain infinitely many points. Branch order is not guaranteed.
For a generic result, the assignments apply where coverage_guard is true. Solve again after substituting parameter values outside that guard. Use dict(result[i]) or result[i].as_dict() to extract assignments. Use branch.free_variables() and branch.conditions() to inspect a family’s free coordinates and validity restrictions.
Printing a set shows each branch’s assignments and restrictions; notebooks display them as aligned equations. A branch with an empty mapping describes a family in which all requested variables are free.
Examples
from symbolica import Expression, S, Reals
x = S("x")
result = Expression.solve(x.eq(2), [x], domain=Reals)
print(result)
[0] {x = 2}
dict(result[0]) == {x: 2}
True
bool(Expression.solve(x**2 + 1, [x], domain=Reals))
FalseAttributes
| Name | Description |
|---|---|
coverage |
Whether the represented solutions are complete or generic. |
coverage_guard |
The condition under which the coverage claim applies. |
domain |
The solve domain, also used as the default domain of external parameters. |
parameters |
Symbols treated as fixed parameters during the solve. |
variables |
The unknowns requested in the solve, in the original input order. |
coverage
SolutionSet.coverage: Literal['complete', 'generic']Whether the represented solutions are complete or generic.
coverage_guard
SolutionSet.coverage_guard: ConditionThe condition under which the coverage claim applies.
domain
SolutionSet.domain: SolveDomainThe solve domain, also used as the default domain of external parameters.
parameters
SolutionSet.parameters: list[Expression]Symbols treated as fixed parameters during the solve.
variables
SolutionSet.variables: list[Expression]The unknowns requested in the solve, in the original input order.
Methods
| Name | Description |
|---|---|
__bool__ |
|
__getitem__ |
|
__iter__ |
|
__len__ |
|
__repr__ |
|
__str__ |
|
_repr_html_ |
|
_repr_pretty_ |
Display assignments using IPython’s pretty printer. |
dimension |
Return the largest branch dimension for fixed external parameter values |
is_empty |
Return whether there are no solutions |
__bool__
SolutionSet.__bool__() -> bool__getitem__
SolutionSet.__getitem__(index: int) -> Solution__iter__
SolutionSet.__iter__() -> Iterator[Solution]__len__
SolutionSet.__len__() -> int__repr__
SolutionSet.__repr__() -> str__str__
SolutionSet.__str__() -> str_repr_html_
SolutionSet._repr_html_() -> str_repr_pretty_
SolutionSet._repr_pretty_(pretty: Any, cycle: bool) -> NoneDisplay assignments using IPython’s pretty printer.
Parameters
pretty(Any) IPython’s pretty printer.cycle(bool) Whether this object is already being displayed.
dimension
SolutionSet.dimension() -> int | NoneReturn the largest branch dimension for fixed external parameter values.
A finite nonempty collection of points has dimension zero; a free line has dimension one. Returns -1 for a complete empty set, or None if unknown.
is_empty
SolutionSet.is_empty() -> boolReturn whether there are no solutions.
Raises IncompleteCoverage if completeness is not established or emptiness depends on unresolved branch conditions. bool(result) is the opposite of this check; use len(result) to count represented branches.