Skip to main content

Crate set_theory

Crate set_theory 

Source
Expand description

§Set Theory Library

A comprehensive mathematical set theory library implementing standard set operations, multisets, and set laws verification following discrete mathematics principles.

§Overview

This library provides:

  • CustomSet: Mutable set with unique elements following mathematical set theory
  • FrozenSet: Immutable set for thread-safe operations
  • MultiSet: Set allowing duplicate elements with multiplicity tracking
  • Set Operations: Union, intersection, complement, difference, symmetric difference
  • Advanced Operations: Cartesian product, power set, partition validation
  • Set Laws: Verification of standard set theory laws (De Morgan, Distributive, etc.)

§Features

  • Implements standard Rust collection traits (IntoIterator, Eq, Hash)
  • Lazy evaluation for expensive operations (power set, cartesian product)
  • Type-safe generic implementations
  • Comprehensive unit tests and benchmarks
  • Optional serialization support (serde)

§Quick Start

use set_theory::models::CustomSet;
use set_theory::operations::basic_ops::SetOperations;

// Create sets
let a = CustomSet::from(vec![1, 2, 3, 4]);
let b = CustomSet::from(vec![3, 4, 5, 6]);

// Perform operations
let union = SetOperations::union(&a, &b);
let intersection = SetOperations::intersection(&a, &b);

println!("A ∪ B = {}", union);
println!("A ∩ B = {}", intersection);

§Module Structure

  • traits: Core traits for set operations
  • models: Set implementations (CustomSet, FrozenSet, MultiSet)
  • operations: Basic and advanced set operations
  • laws: Set theory law verification
  • utils: Helper utilities (equality, pretty printing)

Re-exports§

pub use laws::set_laws::SetLaws;
pub use models::custom_set::CustomSet;
pub use models::frozen_set::FrozenSet;
pub use models::multiset::MultiSet;
pub use operations::advanced_ops::AdvancedSetOperations;
pub use operations::basic_ops::SetOperations;

Modules§

laws
Laws Module
models
Models Module
operations
Operations Module
traits
Traits Module
utils
Utils Module