1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
pub trait Set<E> {
    fn is_empty(&self) -> bool;

    fn contains(&self, element: &E) -> bool;
}

pub trait Intersect<S, O> {
    fn intersect(&self, other: S) -> O;

    fn has_non_empty_intersection_with(&self, other: S) -> bool;
}

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum CountableType {
    Finite(usize),
    CountablyInfinite,
}

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum Cardinality {
    Countable(CountableType),
    Uncountable,
}

pub trait Countable {
    fn count(&self) -> CountableType;

    fn is_finite(&self) -> bool {
        self.count() != CountableType::CountablyInfinite
    }
}

pub trait Finite {
    fn size(&self) -> usize;
}

/// Given two sets of the same type that are `Refineable`, their common
/// refinement can be obtained
pub trait Refineable<O> {
    fn get_common_refinement(&self, other: &Self) -> O;
}