pub struct FreeTheoremDeriver {
pub type_sig: String,
pub theorem: String,
}Expand description
Derives (schematic) free theorems for polymorphic functions on lists.
Given the type ∀ α. List α → List α, the free theorem states that
for any function h : A → B and parametric f:
map h (f xs) = f (map h xs)
Fields§
§type_sig: StringThe polymorphic type signature (as a string description)
theorem: StringThe derived free theorem (as a string description)
Implementations§
Source§impl FreeTheoremDeriver
impl FreeTheoremDeriver
Sourcepub fn list_endomorphism() -> Self
pub fn list_endomorphism() -> Self
Derive the free theorem for ∀ α. List α → List α.
Sourcepub fn poly_identity() -> Self
pub fn poly_identity() -> Self
Derive the free theorem for ∀ α. α → α (parametric identity).
Sourcepub fn poly_map() -> Self
pub fn poly_map() -> Self
Derive the free theorem for ∀ α β. (α → β) → List α → List β (parametric map).
Sourcepub fn verify_identity_theorem(xs: Vec<i32>) -> bool
pub fn verify_identity_theorem(xs: Vec<i32>) -> bool
Verify the stated free theorem holds for a concrete list operation.
Uses a simplified test: map id xs = xs for the identity theorem.
Auto Trait Implementations§
impl Freeze for FreeTheoremDeriver
impl RefUnwindSafe for FreeTheoremDeriver
impl Send for FreeTheoremDeriver
impl Sync for FreeTheoremDeriver
impl Unpin for FreeTheoremDeriver
impl UnsafeUnpin for FreeTheoremDeriver
impl UnwindSafe for FreeTheoremDeriver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more