#![doc(include = "../../doc/references.md")]
pub use crate::helpers::*;
pub use crate::numeric::*;
pub use super::relation::*;
pub trait StrictOrder: Sized {}
pub trait StrictOrderLaws: StrictOrder {
fn asymmetry(f: &Rel<Self>, x: &Self, y: &Self) -> bool {
imply(f(x, y), !f(y, x))
}
fn irreflexivity(f: &Rel<Self>, x: &Self) -> bool {
!f(x, x)
}
fn transitivity(f: &Rel<Self>, x: &Self, y: &Self, z: &Self) -> bool {
imply(f(x, y) && f(y, z), f(x, z))
}
}
impl<S: StrictOrder> StrictOrderLaws for S {}
pub trait NumStrictOrderLaws: NumEq + StrictOrder {
fn num_asymmetry(f: &NumRel<Self>, x: &Self, y: &Self, eps: &Self::Eps) -> bool {
imply(f(x, y, eps), !f(y, x, eps))
}
fn num_irreflexivity(f: &NumRel<Self>, x: &Self, eps: &Self::Eps) -> bool {
!f(x, x, 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 + StrictOrder> NumStrictOrderLaws for S {}
impl StrictOrder for f32 {}
impl StrictOrder for f64 {}
#[cfg(test)]
mod tests;