pub trait MeetSemilattice: Sized + PartialOrd {
fn meet(&self, other: &Self) -> Self;
}
pub trait JoinSemilattice: Sized + PartialOrd {
fn join(&self, other: &Self) -> Self;
}
pub trait Lattice: MeetSemilattice + JoinSemilattice {
fn meet_join(&self, other: &Self) -> (Self, Self) {
(self.meet(other), self.join(other))
}
fn partial_min<'a>(&'a self, other: &'a Self) -> Option<&'a Self> {
if self <= other {
Some(self)
} else if other <= self {
Some(other)
} else {
None
}
}
fn partial_max<'a>(&'a self, other: &'a Self) -> Option<&'a Self> {
if self >= other {
Some(self)
} else if other >= self {
Some(other)
} else {
None
}
}
}
pub trait BoundedLattice: Lattice {
fn top() -> Self;
fn bottom() -> Self;
}
pub trait DistributiveLattice: Lattice {}
pub trait ComplementedLattice: BoundedLattice {
fn complement(&self) -> Self;
}
pub trait BooleanAlgebra: DistributiveLattice + ComplementedLattice {}