Skip to content
Symi Docs
Python
On this page

Sets

Sets are ordinary Expression values; constructors route through auto-simplification (degenerate intervals collapse, unions splice and deduplicate, etc.). Take results apart with the structural accessors on the expressions page.

interval#

Default context

interval(
    lower: ExpressionLike,
    upper: ExpressionLike,
    lower_open: bool = False,
    upper_open: bool = False,
) -> Expression
Calling forms

Explicit context: Context.interval

interval(
    lower: ExpressionLike,
    upper: ExpressionLike,
    lower_open: bool = False,
    upper_open: bool = False,
) -> Expression

Real-line interval. Closed by default; endpoints at infinity are forced open. Degenerate shapes collapse (empty interval →\to empty set, single point →\to finite set, (−∞,∞)→(-\infty, \infty)\to real line).

real_line#

Default context

real_line: Expression
Calling forms

Explicit context: Context.real_line

real_line: Expression

The set R\mathbb{R}.

complex_plane#

Default context

complex_plane: Expression
Calling forms

Explicit context: Context.complex_plane

complex_plane: Expression

The set C\mathbb{C} — the ambient universe, and the domain a variable ranges over when it carries no realness assumption.

integer_set#

Default context

integer_set: Expression
Calling forms

Explicit context: Context.integer_set

integer_set: Expression

The set Z\mathbb{Z}.

empty_set#

Default context

empty_set: Expression
Calling forms

Explicit context: Context.empty_set

empty_set: Expression

The empty set ∅\varnothing.

finite_set#

Default context

finite_set(elements: Any) -> Expression
Calling forms

Explicit context: Context.finite_set

finite_set(elements: Any) -> Expression

Finite set; elements are deduplicated and canonically ordered. An empty list gives the empty set.

set_union#

Default context

set_union(set_a: ExpressionLike, set_b: ExpressionLike) -> Expression
Calling forms

Explicit context: Context.set_union

set_union(set_a: ExpressionLike, set_b: ExpressionLike) -> Expression

Union, computed eagerly where the structural rules allow (overlapping or touching interval pairs merge; nested unions splice, ∅\varnothing drops, R\mathbb{R} absorbs); otherwise the structural set_union node.

set_intersection#

Default context

set_intersection(
    set_a: ExpressionLike,
    set_b: ExpressionLike,
) -> Expression
Calling forms

Explicit context: Context.set_intersection

set_intersection(
    set_a: ExpressionLike,
    set_b: ExpressionLike,
) -> Expression

Intersection, computed eagerly where the structural rules allow (interval pairs, finite-set membership filtering; R\mathbb{R} drops, ∅\varnothing absorbs); otherwise the structural set_intersection node.

set_complement#

Default context

set_complement(
    set_a: ExpressionLike,
    set_b: ExpressionLike,
) -> Expression
Calling forms

Explicit context: Context.set_complement

set_complement(
    set_a: ExpressionLike,
    set_b: ExpressionLike,
) -> Expression

The relative complement a∖ba \setminus b.

image_set#

Default context

image_set(
    lambda_expression: ExpressionLike,
    variable: VariableLike,
    domain: ExpressionLike,
) -> Expression
Calling forms

Explicit context: Context.image_set

image_set(
    lambda_expression: ExpressionLike,
    variable: VariableLike,
    domain: ExpressionLike,
) -> Expression

The set {lambda_expression⁡:variable⁡∈domain⁡}\{\operatorname{lambda\_expression} : \operatorname{variable} \in \operatorname{domain}\}; variable is a binder over lambda_expression. Finite domains are enumerated element-wise at construction.

condition_set#

Default context

condition_set(
    variable: VariableLike,
    condition: ExpressionLike,
    domain: ExpressionLike,
) -> Expression
Calling forms

Explicit context: Context.condition_set

condition_set(
    variable: VariableLike,
    condition: ExpressionLike,
    domain: ExpressionLike,
) -> Expression

The set {variable⁡∈domain⁡:condition⁡}\{\operatorname{variable} \in \operatorname{domain} : \operatorname{condition}\}. This is also solveset's honest "unsolved" residue shape.

is_member#

Default context

is_member(
    element: ExpressionLike,
    set: ExpressionLike,
) -> Optional[bool]
Calling forms

Explicit context: Context.is_member

is_member(
    element: ExpressionLike,
    set: ExpressionLike,
) -> Optional[bool]

Three-valued membership: True only on structural proof, False only on a structural counterexample, None otherwise. Covers ∅\varnothing, R\mathbb{R}, finite sets, intervals, unions, intersections, complements.

is_subset#

Default context

is_subset(
    set_a: ExpressionLike,
    set_b: ExpressionLike,
) -> Optional[bool]
Calling forms

Explicit context: Context.is_subset

is_subset(
    set_a: ExpressionLike,
    set_b: ExpressionLike,
) -> Optional[bool]

Three-valued subset query: ∅⊆\varnothing \subseteq anything, structural equality, finite-set element checks, interval-in-interval endpoint tests; None otherwise.

enumerate_set_in_interval#

Default context

enumerate_set_in_interval(
    set: ExpressionLike,
    lower: ExpressionLike,
    upper: ExpressionLike,
    lower_inclusive: bool = True,
    upper_inclusive: bool = True,
    limit: Optional[int] = None,
) -> Any
Calling forms

Explicit context: Context.enumerate_set_in_interval

enumerate_set_in_interval(
    set: ExpressionLike,
    lower: ExpressionLike,
    upper: ExpressionLike,
    lower_inclusive: bool = True,
    upper_inclusive: bool = True,
    limit: Optional[int] = None,
) -> Any

Exact elements of a set inside [lower⁡,upper⁡][\operatorname{lower}, \operatorname{upper}], in increasing order, as {"outcome": str, "elements": list[Expression]}. outcome is "complete" when those are exactly the elements in the interval, "truncated" when limit cut the list short (the family is still solved), and "declined" when the set's shape is not enumerable — never a licence to approximate. Handles finite sets, affine image sets over Z\mathbb{Z}, unions, complements, and the unevaluated set_intersection(interval, image_set) shape solveset_in_domain returns for a lattice too wide to materialize. limit defaults to 64. WASM returns a SetEnumeration object with outcome and elements getters.

Example#

Set construction and membership over exact elements.

Python
import symi

x = symi.symbol("x")
left = symi.finite_set([1, 2, 3])
right = symi.finite_set([2, 3, 4])

print(symi.set_union(left, right))
print(symi.set_intersection(left, right))
print(symi.is_member(2, left))
print(symi.solveset(symi.sin(x), "x"))

Additional API#

iter#

Expression method

__iter__() -> Any

Iterate the elements of a finite_set expression.

len#

Expression method

__len__() -> int

Number of elements of a finite_set expression.

Symi documentation · Python