#![doc(include = "../../doc/references.md")]
pub use crate::helpers::*;
pub use crate::numeric::*;
pub use super::relation::*;
pub trait TotalOrder: PartialEq {}
pub trait TotalOrderLaws: TotalOrder {
fn connexity(f: &Rel<Self>, x: &Self, y: &Self) -> bool {
f(x, y) || f(y, x)
}
fn antisymmetry(f: &Rel<Self>, x: &Self, y: &Self) -> bool {
imply(f(x, y) && f(y, x), x == y)
}
fn transitivity(f: &Rel<Self>, x: &Self, y: &Self, z: &Self) -> bool {
imply(f(x, y) && f(y, z), f(x, z))
}
}
impl<S: TotalOrder> TotalOrderLaws for S {}
pub trait NumTotalOrderLaws: NumEq + TotalOrder {
fn num_connexity(f: &NumRel<Self>, x: &Self, y: &Self, eps: &Self::Eps) -> bool {
f(x, y, eps) || f(y, x, eps)
}
fn antisymmetry(f: &NumRel<Self>, x: &Self, y: &Self, eps: &Self::Eps) -> bool {
imply(f(x, y, eps) && f(y, x, eps), x.num_eq(y, eps))
}
fn num_transitivity(f: &NumRel<Self>, x: &Self, y: &Self, z: &Self, eps: &Self::Eps) -> bool {
imply(f(x, y, eps) && f(y, z, eps), f(x, z, eps))
}
}
impl<S: NumEq + TotalOrder> NumTotalOrderLaws for S {}
impl TotalOrder for f32 {}
impl TotalOrder for f64 {}
#[cfg(test)]
mod tests;