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#
api::sets::Session method
pub fn interval(
&self,
lower: &Expression,
upper: &Expression,
lower_inclusive: bool,
upper_inclusive: bool,
) -> Result<Expression, ApiError>Real-line interval. Closed by default; endpoints at infinity are forced open. Degenerate shapes collapse (empty interval empty set, single point finite set, real line).
real_line#
api::Session method
pub fn real_line(&self) -> ExpressionThe set .
complex_plane#
api::Session method
pub fn complex_plane(&self) -> ExpressionThe set — the ambient universe, and the domain a variable ranges over when it carries no realness assumption.
integer_set#
api::Session method
pub fn integer_set(&self) -> ExpressionThe set .
empty_set#
api::Session method
pub fn empty_set(&self) -> ExpressionThe empty set .
finite_set#
api::Session method
pub fn finite_set<IteratorType>(
&self,
elements: IteratorType,
) -> Result<Expression, ApiError>
where
IteratorType: IntoIterator<Item = Expression>,Finite set; elements are deduplicated and canonically ordered. An empty list gives the empty set.
set_union#
api::sets::Session method
pub fn set_union(
&self,
left: &Expression,
right: &Expression,
) -> Result<Expression, ApiError>Union, computed eagerly where the structural rules allow (overlapping or
touching interval pairs merge; nested unions splice, drops, absorbs);
otherwise the structural set_union node.
set_intersection#
api::sets::Session method
pub fn set_intersection(
&self,
left: &Expression,
right: &Expression,
) -> Result<Expression, ApiError>Intersection, computed eagerly where the structural rules allow (interval
pairs, finite-set membership filtering; drops, absorbs); otherwise the
structural set_intersection node.
set_complement#
api::sets::Session method
pub fn set_complement(
&self,
left: &Expression,
right: &Expression,
) -> Result<Expression, ApiError>The relative complement .
image_set#
api::sets::Session method
pub fn image_set<'a, VariableType>(
&self,
lambda_expression: &Expression,
variable: VariableType,
domain: &Expression,
) -> Result<Expression, ApiError>
where
VariableType: Into<VariableLike<'a>>,The set ; variable is a binder
over lambda_expression. Finite domains are enumerated element-wise at
construction.
condition_set#
api::sets::Session method
pub fn condition_set<'a, VariableType>(
&self,
variable: VariableType,
condition: &Expression,
domain: &Expression,
) -> Result<Expression, ApiError>
where
VariableType: Into<VariableLike<'a>>,The set . This is also solveset's honest
"unsolved" residue shape.
is_member#
api::sets::Session method
pub fn is_member(
&self,
element: &Expression,
set: &Expression,
) -> Result<TruthValue, ApiError>Calling forms
api::expression_operations::Expression method: api::expression_operations::Expression::is_member
pub fn is_member(
&self,
set: &Expression,
) -> Result<TruthValue, ApiError>Three-valued membership: True only on structural proof, False only on a
structural counterexample, None otherwise. Covers , , finite sets,
intervals, unions, intersections, complements.
is_subset#
api::sets::Session method
pub fn is_subset(
&self,
smaller: &Expression,
larger: &Expression,
) -> Result<TruthValue, ApiError>Three-valued subset query: anything, structural equality, finite-set
element checks, interval-in-interval endpoint tests; None otherwise.
enumerate_set_in_interval#
api::sets::Session method
pub fn enumerate_set_in_interval(
&self,
set: &Expression,
lower: &Expression,
upper: &Expression,
lower_inclusive: bool,
upper_inclusive: bool,
limit: Option<usize>,
) -> Result<SetEnumeration, ApiError>Exact elements of a set inside , 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 , 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.
use symi::api::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let session = Session::new();
let elements = session.finite_set([
session.integer(1),
session.integer(2),
session.integer(3),
])?;
println!("{}", elements);
println!("{}", session.parse("x^2 - 2")?.solve_as_set(&session.symbol("x"))?);
Ok(())
}Additional API#
length#
api::expression_operations::Expression method
pub fn length(&self) -> Result<usize, ApiError>The number of elements of a finite-set expression.
api::sets#
api module
pub mod sets;Set construction and query operations of the native API.
DEFAULT_ENUMERATION_LIMIT#
api::sets constant
pub const DEFAULT_ENUMERATION_LIMIT: usize = crate::sets::enumerate::DEFAULT_ENUMERATION_LIMIT;The default ceiling on how many elements one set enumeration produces.
EnumerationVerdict#
api re_export
pub use results::EnumerationVerdict;How far a set enumeration got.
EnumerationVerdict.Complete#
api::results::EnumerationVerdict variant
Complete,Every element inside the interval was produced.
EnumerationVerdict.Declined#
api::results::EnumerationVerdict variant
Declined,The set's shape is not enumerable by this procedure.
EnumerationVerdict.Truncated#
api::results::EnumerationVerdict variant
Truncated,The requested limit was reached and more elements remain.
EnumerationVerdict.name#
api::results::EnumerationVerdict method
pub fn name(&self) -> &'static strThe stable lowercase spelling shared by every binding.
SetEnumeration#
api re_export
pub use results::SetEnumeration;The elements a set enumeration produced inside an interval.
SetEnumeration.elements#
api::results::SetEnumeration method
pub fn elements(&self) -> Vec<Expression>The enumerated elements in increasing order.
SetEnumeration.outcome#
api::results::SetEnumeration method
pub fn outcome(&self) -> EnumerationVerdictWhether the enumeration is complete, truncated, or declined.