extern crate flag_algebra; use crate::flags::*; use flag_algebra::*; fn identity1(t: Type, n: usize) where F: Flag, { let b = Basis::new(n).with_type(t); let x: QFlag = b.random(); let y = b.random(); assert_eq!(&(&x - &y) * &(x), (&(&x * &x) - &(&y * &x))); } fn commute(t: Type, n1: usize, n2: usize) where F: Flag, { let b1 = Basis::new(n1).with_type(t); let b2 = Basis::new(n2).with_type(t); let x: QFlag = b1.random(); let y: QFlag = b2.random(); assert_eq!(&x * &y, &y * &x) } fn assoc(t: Type, n1: usize, n2: usize, n3: usize) where F: Flag, { let b1 = Basis::new(n1).with_type(t); let b2 = Basis::new(n2).with_type(t); let b3 = Basis::new(n3).with_type(t); let x: QFlag = b1.random(); let y: QFlag = b2.random(); let z: QFlag = b3.random(); assert_eq!(&(&x * &y) * &z, &x * &(&y * &z)) } fn transitive(t: Type, n1: usize, n2: usize, n3: usize) where F: Flag, { let b1 = Basis::new(n1).with_type(t); let b2 = Basis::new(n2).with_type(t); let b3 = Basis::new(n3).with_type(t); let x: QFlag = b1.random(); assert_eq!(x.expand(b2).expand(b3), x.expand(b3)) } #[test] pub fn identities() { let t1 = Type::new(1, 0); identity1::(Type::empty(), 2); identity1::(t1, 2); } #[test] pub fn mul_commutativity() { commute::(Type::new(1, 0), 3, 2); commute::(Type::empty(), 2, 3); commute::(Type::new(1, 0), 3, 2); } #[test] pub fn mul_associativity() { assoc::(Type::new(1, 0), 2, 2, 2); assoc::(Type::empty(), 2, 1, 2); assoc::(Type::new(1, 0), 2, 1, 2); } #[test] pub fn untype_transitivity() { transitive::(Type::new(1, 0), 3, 4, 5); transitive::(Type::empty(), 2, 3, 5); transitive::(Type::new(1, 0), 3, 4, 5); }