use super::*;
#[test]
fn the_a2_almost_complete_pairs_are_the_five_edges() {
for field in fields() {
let algebra = linear_an(2, field);
let modules = [
Module::simple(&algebra, 0),
Module::simple(&algebra, 1),
Module::projective(&algebra, 0),
];
let mut found = 0;
for m in &modules {
let pair = AlmostCompletePair::new(basic(m), support(&algebra, &[]))
.expect("A_2 translates")
.expect("a tau-rigid indecomposable with no support is almost complete");
assert_eq!(pair.summand_count(), 1);
assert!(pair.verify());
found += 1;
}
for v in [0u32, 1] {
let pair =
AlmostCompletePair::new(basic(&Module::zero(&algebra)), support(&algebra, &[v]))
.expect("the zero module needs no translate")
.expect("(0, P_v) is almost complete");
assert!(pair.module().is_empty());
assert_eq!(pair.projective().len(), 1);
assert!(pair.verify());
found += 1;
}
assert_eq!(found, 5, "over F_{}", field.modulus());
}
}
#[test]
fn the_two_pair_types_reject_each_other_on_the_count() {
for field in fields() {
let algebra = linear_an(3, field);
let a = regular(&algebra);
let full = SupportTauTiltingPair::new(basic(&a), support(&algebra, &[]))
.expect("A_3 translates")
.expect("(A, 0) is a pair");
assert_eq!(full.summand_count(), 3);
let as_almost = AlmostCompletePair::classify(basic(&a), support(&algebra, &[]))
.expect("A_3 translates");
match as_almost {
AlmostCompleteClassification::Rejected(PairRejection::SummandCount {
module,
projective,
expected,
}) => assert_eq!((module, projective, expected), (3, 0, 2)),
other => panic!("expected a count rejection, got {other:?}"),
}
let two = sum(
&algebra,
&[
&Module::projective(&algebra, 0),
&Module::projective(&algebra, 1),
],
);
let almost = AlmostCompletePair::new(basic(&two), support(&algebra, &[]))
.expect("A_3 translates")
.expect("(P_0 + P_1, 0) is almost complete");
assert_eq!(almost.summand_count(), 2);
assert!(almost.verify());
let as_full = SupportTauTiltingPair::classify(basic(&two), support(&algebra, &[]))
.expect("A_3 translates");
assert_eq!(
expect_rejection(as_full).condition(),
4,
"over F_{}",
field.modulus()
);
}
}
#[test]
fn a_tampered_pair_fails_verification() {
for field in fields() {
let algebra = linear_an(3, field);
let a = regular(&algebra);
let pair = SupportTauTiltingPair::new(basic(&a), support(&algebra, &[]))
.expect("A_3 translates")
.expect("(A, 0) is a pair");
assert!(pair.verify());
assert!(pair.projective().is_empty(), "A is sincere");
let s1 = Module::simple(&algebra, 1);
let p1 = Module::projective(&algebra, 1);
let mut forged = SupportTauTiltingPair::new(basic(&a), support(&algebra, &[]))
.expect("A_3 translates")
.expect("(A, 0) is a pair");
let donor = SupportTauTiltingPair::new(
basic(&sum(
&algebra,
&[&s1, &p1, &Module::projective(&algebra, 0)],
)),
support(&algebra, &[]),
)
.expect("A_3 translates")
.expect("(S_1 + P_1 + P_0, 0) is a pair");
assert!(donor.rigid().verify(), "the donor witness is honest");
assert_eq!(
donor.rigid().summands().len(),
forged.rigid.summands().len()
);
forged.rigid = donor.rigid().clone();
assert!(!forged.verify(), "over F_{}", field.modulus());
}
}
#[test]
fn the_projective_part_of_a_pair_is_the_whole_support_complement() {
for field in fields() {
let algebra = linear_an(3, field);
let m = sum(
&algebra,
&[
&Module::simple(&algebra, 1),
&Module::projective(&algebra, 1),
],
);
assert_eq!(basic(&m).module().dim_vector(), &[0, 2, 1]);
let pair = SupportTauTiltingPair::new(basic(&m), support(&algebra, &[0]))
.expect("A_3 translates")
.expect("(S_1 + P_1, P_0) is a pair");
assert_eq!(pair.projective().vertices(), [0]);
let short = expect_rejection(
SupportTauTiltingPair::classify(basic(&m), support(&algebra, &[]))
.expect("A_3 translates"),
);
assert_eq!(short.condition(), 4, "over F_{}", field.modulus());
}
}
#[test]
fn a_shared_cache_serves_a_whole_enumeration() {
let field = f5();
let algebra = linear_an(3, field);
let catalog = IndecomposableCatalog::dynkin(&algebra).expect("A_3 is Dynkin");
let mut cache = TauCache::new();
for (i, entry) in catalog.entries().iter().enumerate() {
let pair = SupportTauTiltingPair::classify_with_cache(
basic(entry.module()),
support(&algebra, &[]),
&[i],
Some(&mut cache),
)
.expect("A_3 translates");
assert_eq!(expect_rejection(pair).condition(), 4);
}
assert_eq!(cache.len(), catalog.len());
assert_eq!(cache.misses(), catalog.len() as u64);
}
#[test]
fn a_wrong_index_count_is_rejected() {
let algebra = linear_an(3, f5());
let error = SupportTauTiltingPair::classify_with_cache(
basic(®ular(&algebra)),
support(&algebra, &[]),
&[0, 1],
None,
)
.unwrap_err();
assert!(matches!(
error,
SupportTauError::SummandIndexCount {
indices: 2,
summands: 3
}
));
}