/* Demonstrates that most formation rules are lifted to Path Semantics. */ use prop::*; use path_semantics::*; use std::rc::Rc; use Either::*; // a : T, b : T // --------------- // (a, b) : (T, U) pub fn product_formation( ty_a: Imply, ty_b: Imply, ) -> Imply, And> { Rc::new(move |(a, b)| { (ty_a(a), ty_b(b)) }) } // a : T, b : T // --------------- // a | b : T | U pub fn sum_formation( ty_a: Imply, ty_b: Imply, ) -> Imply, Or> { Rc::new(move |or_a_b| { match or_a_b { Left(a) => Left(ty_a(a)), Right(b) => Right(ty_b(b)), } }) } // a : T, f : T -> U // ----------------- // f(a) : U pub fn app_formation( ty_a: Imply, ty_f: Imply>, ) -> Imply, U> { Rc::new(move |(f, a)| { ty_f(f)(ty_a(a)) }) } // a : U // ---------------------- // (\(_: T) = a) : T -> U pub fn abs_formation( ty_a: Imply, abs: Imply>, Imply>>, ) -> Imply>> { Rc::new(move |a| abs((a, ty_a.clone()))) } // a : T, b : U // ----------------- // (a ~~ b) : (T ~~ U) pub fn eqv_formation( ty_a: Imply, ty_b: Imply, ) -> Imply, Q> where A: POrd, B: POrd { Rc::new(move |f| { let p = assume_naive(); p((f, (ty_a.clone(), ty_b.clone()))) }) } fn main() {}