auslander 0.9.0

Computational representation theory of finite-dimensional bound quiver algebras
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
use super::*;
use crate::algebra::{
    an_with_relations, commutative_square, dual_numbers, linear_an, truncated_poly,
};
use crate::decompose::add_morphisms;
use crate::field::PrimeField;
use crate::hom::{hom_dim, zero_morphism};
use crate::homspace::scale_morphism;
use crate::module::direct_sum;

fn f5() -> PrimeField {
    PrimeField::new(5).unwrap()
}

fn f2() -> PrimeField {
    PrimeField::new(2).unwrap()
}

fn unit(dim: usize, k: usize, field: &PrimeField) -> Vec<Fp> {
    let mut v = vec![field.zero(); dim];
    v[k] = field.one();
    v
}

fn basis_class(space: &ExtSpace, k: usize) -> ExtClass {
    let field = space.source().field();
    space
        .class_from_coordinates(&unit(space.dim(), k, &field))
        .unwrap()
}

#[test]
fn ext_space_dim_matches_ext_dim_and_hom_dim_on_fixtures() {
    let field = f5();
    for algebra in [
        truncated_poly(3, field).unwrap(),
        commutative_square(field),
        linear_an(3, field),
        an_with_relations(3, &[(0, 2)], field).unwrap(),
        dual_numbers(field),
    ] {
        let nv = algebra.quiver().num_vertices();
        let mut modules: Vec<Module> = (0..nv).map(|v| Module::simple(&algebra, v)).collect();
        modules.push(Module::projective(&algebra, 0));
        modules.push(Module::injective(&algebra, nv - 1));
        let s0 = Module::simple(&algebra, 0);
        let i_last = Module::injective(&algebra, nv - 1);
        modules.push(direct_sum(&[&s0, &i_last]).0);
        for m in &modules {
            for n in &modules {
                for k in 0..=3 {
                    let space = ExtSpace::new(m, n, k).unwrap();
                    assert_eq!(
                        space.dim(),
                        ext_dim(m, n, k).unwrap(),
                        "dim m = {:?}, dim n = {:?}, k = {k}",
                        m.dim_vector(),
                        n.dim_vector()
                    );
                    if k == 0 {
                        assert_eq!(space.dim(), hom_dim(m, n).unwrap());
                    }
                }
            }
        }
    }
}

#[test]
fn truncated_poly_3_ext_spaces_are_one_dimensional_over_f5_and_f2() {
    for field in [f5(), f2()] {
        let algebra = truncated_poly(3, field).unwrap();
        let s = Module::simple(&algebra, 0);
        for k in 0..=4 {
            let space = ExtSpace::new(&s, &s, k).unwrap();
            assert_eq!(space.dim(), 1, "Ext^{k}(S, S) over F_{}", field.modulus());
            assert_eq!(space.dim(), ext_dim(&s, &s, k).unwrap());
        }
    }
}

#[test]
fn identity_classes_are_yoneda_units() {
    let field = f5();
    let x3 = truncated_poly(3, field).unwrap();
    let s = Module::simple(&x3, 0);
    let a3 = an_with_relations(3, &[(0, 2)], field).unwrap();
    let s0 = Module::simple(&a3, 0);
    let s1 = Module::simple(&a3, 1);
    let s2 = Module::simple(&a3, 2);
    let cases: Vec<(Module, Module, usize)> = vec![
        (s.clone(), s.clone(), 0),
        (s.clone(), s.clone(), 1),
        (s.clone(), s.clone(), 2),
        (s0.clone(), s1.clone(), 1),
        (s0.clone(), s2.clone(), 2),
        (s1.clone(), s2.clone(), 1),
    ];
    for (m, n, k) in cases {
        let space = ExtSpace::new(&m, &n, k).unwrap();
        assert!(space.dim() > 0, "fixture case has a nonzero space");
        let alpha = basis_class(&space, 0);
        let id_m = ExtSpace::new(&m, &m, 0).unwrap().identity_class().unwrap();
        let id_n = ExtSpace::new(&n, &n, 0).unwrap().identity_class().unwrap();
        let left = id_m.then(&alpha).unwrap();
        let right = alpha.then(&id_n).unwrap();
        assert!(left.equals(&alpha).unwrap(), "left unit at degree {k}");
        assert!(right.equals(&alpha).unwrap(), "right unit at degree {k}");
    }
}

// Over k[x]/(x^3) the differentials of the minimal resolution of S
// alternate right multiplication by x and by x^2. The degree-1 lift of
// the Ext^1 generator sends the generator of P_2 into the radical, so
// composing with a cocycle P_1 -> S kills it: the Yoneda square of the
// degree-1 class is zero in every characteristic. The Ext algebra is
// k[z] tensor the exterior algebra on y, so every product involving the
// degree-2 generator z is nonzero.
#[test]
fn truncated_poly_3_yoneda_products_match_the_ext_algebra() {
    for field in [f5(), f2()] {
        let algebra = truncated_poly(3, field).unwrap();
        let s = Module::simple(&algebra, 0);
        let ext1 = ExtSpace::new(&s, &s, 1).unwrap();
        let ext2 = ExtSpace::new(&s, &s, 2).unwrap();
        let xi = basis_class(&ext1, 0);
        let chi = basis_class(&ext2, 0);
        assert!(
            xi.then(&xi).unwrap().is_zero(),
            "y^2 = 0 over F_{}",
            field.modulus()
        );
        assert!(!xi.then(&chi).unwrap().is_zero(), "y z is nonzero");
        assert!(!chi.then(&xi).unwrap().is_zero(), "z y is nonzero");
        assert!(!chi.then(&chi).unwrap().is_zero(), "z^2 is nonzero");
        let (product, witness) = xi.then_with_witness(&chi).unwrap();
        assert!(witness.verify(&xi, &chi, &product));
    }
}

// Over k[x]/(x^2) the Ext algebra of the simple is the polynomial ring
// on the degree-1 class, so every Yoneda power is nonzero.
#[test]
fn dual_numbers_yoneda_powers_of_the_degree_one_class_are_nonzero() {
    let algebra = dual_numbers(f5());
    let s = Module::simple(&algebra, 0);
    let ext1 = ExtSpace::new(&s, &s, 1).unwrap();
    let xi = basis_class(&ext1, 0);
    let square = xi.then(&xi).unwrap();
    assert!(!square.is_zero(), "y^2 is nonzero over k[x]/(x^2)");
    assert!(!square.then(&xi).unwrap().is_zero(), "y^3 is nonzero");
}

// Ext^1(S_0, S_1) x Ext^1(S_1, S_2) -> Ext^2(S_0, S_2) over kA_3/(ab):
// both lifts are identities on the shared projective terms, so the
// product is the Ext^2 generator detected by the relation. On the
// commutative square the product Ext^1(S_0, S_1) x Ext^1(S_1, S_3) ->
// Ext^2(S_0, S_3) has rank 1 (QPA-verified).
#[test]
fn ext1_times_ext1_is_nonzero_on_relation_detected_pairs() {
    let field = f5();
    let a3 = an_with_relations(3, &[(0, 2)], field).unwrap();
    let s0 = Module::simple(&a3, 0);
    let s1 = Module::simple(&a3, 1);
    let s2 = Module::simple(&a3, 2);
    let alpha = basis_class(&ExtSpace::new(&s0, &s1, 1).unwrap(), 0);
    let beta = basis_class(&ExtSpace::new(&s1, &s2, 1).unwrap(), 0);
    let product = alpha.then(&beta).unwrap();
    assert_eq!(product.space().dim(), 1);
    assert!(!product.is_zero(), "Ext^1 . Ext^1 -> Ext^2 over kA_3/(ab)");
    let square = commutative_square(field);
    let t0 = Module::simple(&square, 0);
    let t1 = Module::simple(&square, 1);
    let t3 = Module::simple(&square, 3);
    let a = basis_class(&ExtSpace::new(&t0, &t1, 1).unwrap(), 0);
    let b = basis_class(&ExtSpace::new(&t1, &t3, 1).unwrap(), 0);
    let ab = a.then(&b).unwrap();
    assert_eq!(ab.space().dim(), 1);
    assert!(
        !ab.is_zero(),
        "the commutative square relation pairs 0 -> 3"
    );
}

#[test]
fn yoneda_products_are_bilinear_on_small_cases() {
    let field = f5();
    let a3 = an_with_relations(3, &[(0, 2)], field).unwrap();
    let dn = dual_numbers(field);
    let cases: Vec<(ExtClass, ExtClass)> = {
        let s0 = Module::simple(&a3, 0);
        let s1 = Module::simple(&a3, 1);
        let s2 = Module::simple(&a3, 2);
        let s = Module::simple(&dn, 0);
        vec![
            (
                basis_class(&ExtSpace::new(&s0, &s1, 1).unwrap(), 0),
                basis_class(&ExtSpace::new(&s1, &s2, 1).unwrap(), 0),
            ),
            (
                basis_class(&ExtSpace::new(&s, &s, 1).unwrap(), 0),
                basis_class(&ExtSpace::new(&s, &s, 1).unwrap(), 0),
            ),
        ]
    };
    for (alpha, beta) in cases {
        let two = field.elem(2);
        let three = field.elem(3);
        let product = alpha.then(&beta).unwrap();
        let doubled = alpha.scale(two);
        let sum = alpha.add(&doubled).unwrap();
        let left = sum.then(&beta).unwrap();
        let right = product.add(&doubled.then(&beta).unwrap()).unwrap();
        assert!(left.equals(&right).unwrap(), "additivity on the left");
        let scaled_left = alpha.scale(three).then(&beta).unwrap();
        assert!(scaled_left.equals(&product.scale(three)).unwrap());
        let scaled_right = alpha.then(&beta.scale(three)).unwrap();
        assert!(scaled_right.equals(&product.scale(three)).unwrap());
        let negated = alpha.neg().then(&beta).unwrap();
        assert!(negated.equals(&product.neg()).unwrap());
        let zero = alpha.space().zero_class().then(&beta).unwrap();
        assert!(zero.is_zero(), "the zero class annihilates products");
    }
}

#[test]
fn adding_a_coboundary_does_not_change_the_class() {
    let field = f5();
    let mut saw_nonzero_coboundary = false;
    for algebra in [
        truncated_poly(3, field).unwrap(),
        an_with_relations(3, &[(0, 2)], field).unwrap(),
        commutative_square(field),
    ] {
        let nv = algebra.quiver().num_vertices();
        for v in 0..nv {
            let s = Module::simple(&algebra, v);
            for w in 0..nv {
                for n in [
                    Module::projective(&algebra, w),
                    Module::injective(&algebra, w),
                ] {
                    for k in 1..=2 {
                        let space = ExtSpace::new(&s, &n, k).unwrap();
                        let cob = space.coboundary_basis();
                        if cob.rows() == 0 {
                            continue;
                        }
                        saw_nonzero_coboundary = true;
                        let lay = layout(space.cochain_term());
                        let mut classes = vec![space.zero_class()];
                        for i in 0..space.dim() {
                            classes.push(basis_class(&space, i));
                        }
                        for class in &classes {
                            let rep = class.representative();
                            for r in 0..cob.rows() {
                                let boundary = cochain_from_coordinates(
                                    space.cochain_term(),
                                    &lay,
                                    space.target(),
                                    cob.row(r),
                                );
                                let shifted = add_morphisms(&rep, &boundary);
                                let recovered = space.class_from_cocycle(&shifted).unwrap();
                                assert!(recovered.equals(class).unwrap());
                            }
                        }
                    }
                }
            }
        }
    }
    assert!(saw_nonzero_coboundary, "the fixtures exercise nonzero B^k");
}

#[test]
fn class_from_cocycle_rejects_wrong_endpoints_and_non_cocycles() {
    let field = f5();
    let algebra = truncated_poly(3, field).unwrap();
    let s = Module::simple(&algebra, 0);
    let p = Module::projective(&algebra, 0);
    let space = ExtSpace::new(&s, &p, 1).unwrap();
    let other = ExtSpace::new(&s, &p, 1).unwrap();
    let wrong_source = zero_morphism(other.cochain_term(), &p).unwrap();
    assert_eq!(
        space.class_from_cocycle(&wrong_source).unwrap_err(),
        ExtClassError::SourceMismatch
    );
    let p_copy = Module::projective(&algebra, 0);
    let wrong_target = zero_morphism(space.cochain_term(), &p_copy).unwrap();
    assert_eq!(
        space.class_from_cocycle(&wrong_target).unwrap_err(),
        ExtClassError::TargetMismatch
    );
    let lay = layout(space.cochain_term());
    let non_cocycle = yoneda_basis(space.cochain_term(), &lay, &p).remove(0);
    match space.class_from_cocycle(&non_cocycle).unwrap_err() {
        ExtClassError::NotCocycle { composite } => {
            assert!(composite.iter().any(|c| !c.is_zero()));
        }
        other => panic!("expected NotCocycle, got {other:?}"),
    }
}

#[test]
fn class_from_coordinates_rejects_wrong_length_and_non_canonical_entries() {
    let algebra = truncated_poly(3, f2()).unwrap();
    let s = Module::simple(&algebra, 0);
    let space = ExtSpace::new(&s, &s, 1).unwrap();
    assert_eq!(space.dim(), 1);
    assert_eq!(
        space.class_from_coordinates(&[]).unwrap_err(),
        ExtClassError::CoordinateCountMismatch {
            expected: 1,
            got: 0
        }
    );
    let one = f2().one();
    assert_eq!(
        space.class_from_coordinates(&[one, one]).unwrap_err(),
        ExtClassError::CoordinateCountMismatch {
            expected: 1,
            got: 2
        }
    );
    // The entry 3 comes from F_5; it is not a canonical F_2 representative.
    assert_eq!(
        space.class_from_coordinates(&[f5().elem(3)]).unwrap_err(),
        ExtClassError::NonCanonicalCoordinate { index: 0 }
    );
}

#[test]
fn arithmetic_rejects_incompatible_spaces_and_products_reject_bad_middles() {
    let field = f5();
    let algebra = truncated_poly(3, field).unwrap();
    let s = Module::simple(&algebra, 0);
    let s_copy = Module::simple(&algebra, 0);
    let deg1 = ExtSpace::new(&s, &s, 1).unwrap();
    let deg2 = ExtSpace::new(&s, &s, 2).unwrap();
    let copied = ExtSpace::new(&s_copy, &s_copy, 1).unwrap();
    let a = basis_class(&deg1, 0);
    let b = basis_class(&deg2, 0);
    let c = basis_class(&copied, 0);
    assert_eq!(a.add(&b).unwrap_err(), ExtClassError::IncompatibleSpaces);
    assert_eq!(a.equals(&b).unwrap_err(), ExtClassError::IncompatibleSpaces);
    assert_eq!(a.add(&c).unwrap_err(), ExtClassError::IncompatibleSpaces);
    assert_eq!(a.equals(&c).unwrap_err(), ExtClassError::IncompatibleSpaces);
    assert_eq!(a.then(&c).unwrap_err(), ExtClassError::MiddleMismatch);
}

#[test]
fn identity_class_needs_degree_zero_and_equal_endpoints() {
    let field = f5();
    let algebra = truncated_poly(3, field).unwrap();
    let s = Module::simple(&algebra, 0);
    let p = Module::projective(&algebra, 0);
    assert_eq!(
        ExtSpace::new(&s, &s, 1)
            .unwrap()
            .identity_class()
            .unwrap_err(),
        ExtClassError::NotDegreeZeroEndo
    );
    assert_eq!(
        ExtSpace::new(&s, &p, 0)
            .unwrap()
            .identity_class()
            .unwrap_err(),
        ExtClassError::NotDegreeZeroEndo
    );
}

#[test]
fn zero_modules_give_zero_spaces() {
    let field = f5();
    let algebra = truncated_poly(3, field).unwrap();
    let s = Module::simple(&algebra, 0);
    let z = Module::zero(&algebra);
    for k in 0..=2 {
        let left = ExtSpace::new(&z, &s, k).unwrap();
        let right = ExtSpace::new(&s, &z, k).unwrap();
        assert_eq!(left.dim(), 0);
        assert_eq!(right.dim(), 0);
        assert!(left.zero_class().is_zero());
        assert!(right.zero_class().representative().is_zero());
    }
}

#[test]
fn a_finite_resolution_ending_before_the_degree_gives_the_zero_space() {
    let field = f5();
    let algebra = linear_an(3, field);
    let s0 = Module::simple(&algebra, 0);
    let s1 = Module::simple(&algebra, 1);
    let space = ExtSpace::new(&s0, &s1, 3).unwrap();
    assert_eq!(space.dim(), 0);
    assert!(space.cochain_term().is_zero());
    assert!(space.zero_class().representative().is_zero());
    let empty = space.class_from_coordinates(&[]).unwrap();
    assert!(empty.is_zero());
    let zero = zero_morphism(space.cochain_term(), space.target()).unwrap();
    assert!(space.class_from_cocycle(&zero).unwrap().is_zero());
}

#[test]
fn product_witness_accepts_the_genuine_triple_and_rejects_tampering() {
    let field = f5();
    let algebra = an_with_relations(3, &[(0, 2)], field).unwrap();
    let s0 = Module::simple(&algebra, 0);
    let s1 = Module::simple(&algebra, 1);
    let s2 = Module::simple(&algebra, 2);
    let alpha = basis_class(&ExtSpace::new(&s0, &s1, 1).unwrap(), 0);
    let beta = basis_class(&ExtSpace::new(&s1, &s2, 1).unwrap(), 0);
    let (product, witness) = alpha.then_with_witness(&beta).unwrap();
    assert!(witness.verify(&alpha, &beta, &product));
    // A Morphism is checked at construction, so the tamper scales one
    // lift: every nonzero entry changes and one lift identity breaks.
    assert!(!witness.lifts()[0].is_zero());
    let scaled = scale_morphism(&witness.lifts()[0], field.elem(2));
    let mut tampered_lifts = witness.lifts().to_vec();
    tampered_lifts[0] = scaled;
    let tampered = ProductWitness {
        lifts: tampered_lifts,
    };
    assert!(!tampered.verify(&alpha, &beta, &product));
    let wrong_product = ExtClass {
        space: product.space().clone(),
        coords: vec![field.elem(2)],
    };
    assert!(!witness.verify(&alpha, &beta, &wrong_product));
    assert!(!witness.verify(&alpha.scale(field.elem(2)), &beta, &product));
}

#[test]
fn recomputed_spaces_carry_identical_bases_and_representatives() {
    let field = f5();
    let algebra = commutative_square(field);
    let s0 = Module::simple(&algebra, 0);
    let p0 = Module::projective(&algebra, 0);
    for (m, n, k) in [(&s0, &p0, 1), (&s0, &p0, 2), (&s0, &s0, 0)] {
        let first = ExtSpace::new(m, n, k).unwrap();
        let second = ExtSpace::new(m, n, k).unwrap();
        assert!(first.is_compatible(&second));
        assert_eq!(
            first.cocycle_basis().entries_u64(),
            second.cocycle_basis().entries_u64()
        );
        assert_eq!(
            first.coboundary_basis().entries_u64(),
            second.coboundary_basis().entries_u64()
        );
        assert_eq!(
            first.complement_basis().entries_u64(),
            second.complement_basis().entries_u64()
        );
        for (a, b) in first.representatives().iter().zip(second.representatives()) {
            for v in 0..algebra.quiver().num_vertices() {
                assert_eq!(a.map_at(v), b.map_at(v));
            }
        }
    }
}

#[test]
fn ext_space_new_rejects_modules_over_different_algebras() {
    let a = linear_an(3, f5());
    let b = linear_an(3, f5());
    let m = Module::simple(&a, 0);
    let n = Module::simple(&b, 0);
    assert_eq!(
        ExtSpace::new(&m, &n, 1).unwrap_err(),
        ExtError::DifferentAlgebras
    );
}

#[test]
fn an_unrepresentable_successor_degree_is_typed() {
    let algebra = linear_an(1, f5());
    let simple = Module::simple(&algebra, 0);
    let expected = ExtError::DegreeOverflow { degree: usize::MAX };
    assert_eq!(
        ext_table(&simple, &simple, usize::MAX),
        Err(expected.clone())
    );
    assert_eq!(ext_dim(&simple, &simple, usize::MAX), Err(expected.clone()));
    assert_eq!(
        ExtSpace::new(&simple, &simple, usize::MAX).unwrap_err(),
        expected
    );
}