auslander 0.10.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
use std::sync::Arc;

use crate::algebra::Algebra;
use crate::context::VerificationContext;
use crate::decompose::{inverse_morphism, mutually_inverse};
use crate::hom::{HomError, Morphism, hom_dim};
use crate::indec::IndecomposableModule;
use crate::iso::indecomposable_iso;
use crate::module::{Module, summand_sum};
use crate::profile::{Site, hit};
use crate::radical::{loewy_length, socle, top};

use super::decomposition::{BasicDecomposition, BasicError, defect_non_invertible};

/// The vertex set of a basic projective module, sorted and deduplicated.
///
/// Over a basic algebra `P = P_{v_1} + ... + P_{v_k}` with distinct vertices,
/// so the vertex set determines `P` up to isomorphism. Identity of the
/// projective half is therefore exact set equality of the vertex lists, which
/// is what [`PartialEq`] compares. The algebra is not part of that
/// comparison; [`ProjectiveSupport::is_compatible`] checks it separately.
pub struct ProjectiveSupport {
    algebra: Arc<Algebra>,
    vertices: Vec<u32>,
}

debug_fields!(ProjectiveSupport |this| {
    "vertices" => this.vertices;
});

/// Equality is exact set equality of the vertex lists, which are sorted and
/// deduplicated at construction. It ignores the algebra.
impl PartialEq for ProjectiveSupport {
    fn eq(&self, other: &ProjectiveSupport) -> bool {
        self.vertices == other.vertices
    }
}

impl Eq for ProjectiveSupport {}

impl ProjectiveSupport {
    /// Builds the support from a vertex list, sorting it and removing
    /// duplicates.
    ///
    /// A vertex outside `0..algebra.quiver().num_vertices()` is
    /// [`BasicError::VertexOutOfRange`]. An empty list is the zero projective.
    pub fn new(algebra: &Arc<Algebra>, vertices: &[u32]) -> Result<ProjectiveSupport, BasicError> {
        let num_vertices = algebra.quiver().num_vertices();
        for &vertex in vertices {
            if vertex >= num_vertices {
                return Err(BasicError::VertexOutOfRange {
                    vertex,
                    num_vertices,
                });
            }
        }
        let mut sorted = vertices.to_vec();
        sorted.sort_unstable();
        sorted.dedup();
        Ok(ProjectiveSupport {
            algebra: algebra.clone(),
            vertices: sorted,
        })
    }

    accessor_methods! {
        /// The algebra the projectives come from.
        pub algebra() -> &Arc<Algebra> = |this| &this.algebra;
        /// The support vertices, sorted and deduplicated.
        pub vertices() -> &[u32] = |this| &this.vertices;
        /// The number of support vertices, which is the number of indecomposable
        /// summands of the projective.
        pub len() -> usize = |this| this.vertices.len();
        /// Whether the support is empty, which means the projective is zero.
        pub is_empty() -> bool = |this| this.vertices.is_empty();
        /// Whether `v` lies in the support.
        pub contains(v: u32) -> bool = |this| this.vertices.binary_search(&v).is_ok();
        /// Whether both supports come from one algebra value (the same [`Arc`]).
        pub is_compatible(other: &ProjectiveSupport) -> bool = |this|
            Arc::ptr_eq(&this.algebra, &other.algebra);
        /// Rebuilds the canonical module `P_{v_1} + ... + P_{v_k}` in sorted
        /// vertex order; the zero module when the support is empty.
        ///
        /// Each call builds a fresh [`Module`] value, so results of two calls are
        /// isomorphic but never [`Module::ptr_eq`].
        pub module() -> Module = |this|
            summand_sum(&this.algebra, &this.vertices, Module::projective);
    }
}

/// A proof that two basic pairs are not isomorphic.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum SupportPairObstruction {
    /// The projective supports differ as sets, so the projective halves are
    /// not isomorphic.
    ProjectiveSupport {
        /// Support of the first pair.
        first: Vec<u32>,
        /// Support of the second pair.
        second: Vec<u32>,
    },
    /// The module halves have different summand counts, so by Krull-Schmidt
    /// they are not isomorphic.
    SummandCount {
        /// Summand count of the first module.
        first: usize,
        /// Summand count of the second module.
        second: usize,
    },
    /// Summand `index` of the first module is isomorphic to no summand of the
    /// second; by Krull-Schmidt the modules differ.
    UnmatchedSummand {
        /// Position of the unmatched summand in the first decomposition.
        index: usize,
        /// Dimension vector of the unmatched summand.
        dim_vector: Vec<usize>,
    },
}

/// A verified isomorphism of two basic pairs.
///
/// Construction goes through [`pair_iso`]. The witness holds the summand
/// bijection and, for every summand of the first module, the isomorphism to
/// its partner and the isomorphism back.
#[derive(Clone)]
pub struct SupportPairIsoWitness {
    pub(super) bijection: Vec<usize>,
    pub(super) forward: Vec<Morphism>,
    pub(super) backward: Vec<Morphism>,
}

debug_fields!(SupportPairIsoWitness |this| {
    "bijection" => this.bijection;
});

impl SupportPairIsoWitness {
    accessor_methods! {
        /// `bijection()[i]` is the summand of the second module matched to
        /// summand `i` of the first.
        pub bijection() -> &[usize] = |this| &this.bijection;
        /// `forward()[i]` runs from summand `i` of the first module to summand
        /// `bijection()[i]` of the second.
        pub forward() -> &[Morphism] = |this| &this.forward;
        /// `backward()[i]` is the inverse of `forward()[i]`.
        pub backward() -> &[Morphism] = |this| &this.backward;
    }

    /// Rechecks the witness: the bijection is a permutation, and each pair of
    /// stored maps multiplies to the identity in both orders.
    pub fn verify(&self) -> bool {
        hit(Site::SupportPairIsoWitnessVerify);
        verify_guard!(
            self.forward.len() == self.bijection.len()
                && self.backward.len() == self.bijection.len()
        );
        let mut seen = vec![false; self.bijection.len()];
        for &j in &self.bijection {
            verify_guard!(j < seen.len() && !seen[j]);
            seen[j] = true;
        }
        for (f, g) in self.forward.iter().zip(&self.backward) {
            verify_guard!(mutually_inverse(f, g));
        }
        true
    }
}

/// The outcome of [`pair_iso`].
///
/// There is no undecided variant. Both inputs are certified basic pairs, and
/// the radical criterion between certified indecomposables is total.
#[derive(Clone, Debug)]
pub enum SupportPairIsoOutcome {
    /// The pairs are isomorphic, with a verified witness.
    Isomorphic(SupportPairIsoWitness),
    /// A proof that the pairs are not isomorphic.
    NotIsomorphic(SupportPairObstruction),
}

/// Whether the basic pairs `(a_mod, a_proj)` and `(b_mod, b_proj)` are
/// isomorphic.
///
/// The projective halves are compared as vertex sets. The module halves are
/// compared summand by summand with the radical criterion, which is exact
/// between certified indecomposables. Both modules are basic, so each summand
/// of the first is isomorphic to at most one summand of the second and the
/// greedy scan is exact.
///
/// Errors when the four inputs do not share one algebra value, and with
/// [`BasicError::Defect`] when the radical criterion returns a map that is
/// not invertible.
pub fn pair_iso(
    a_mod: &BasicDecomposition,
    a_proj: &ProjectiveSupport,
    b_mod: &BasicDecomposition,
    b_proj: &ProjectiveSupport,
) -> Result<SupportPairIsoOutcome, BasicError> {
    hit(Site::PairIso);
    if !a_proj.is_compatible(b_proj)
        || !Arc::ptr_eq(a_mod.module().algebra(), a_proj.algebra())
        || !Arc::ptr_eq(b_mod.module().algebra(), b_proj.algebra())
    {
        return Err(BasicError::DifferentAlgebras);
    }
    if a_proj.vertices() != b_proj.vertices() {
        return Ok(SupportPairIsoOutcome::NotIsomorphic(
            SupportPairObstruction::ProjectiveSupport {
                first: a_proj.vertices().to_vec(),
                second: b_proj.vertices().to_vec(),
            },
        ));
    }
    if a_mod.len() != b_mod.len() {
        return Ok(SupportPairIsoOutcome::NotIsomorphic(
            SupportPairObstruction::SummandCount {
                first: a_mod.len(),
                second: b_mod.len(),
            },
        ));
    }
    let mut bijection = Vec::with_capacity(a_mod.len());
    let mut forward = Vec::with_capacity(a_mod.len());
    let mut backward = Vec::with_capacity(a_mod.len());
    let mut used = vec![false; b_mod.len()];
    for (i, x) in a_mod.summands().iter().enumerate() {
        let Some(matched) = certified_match(
            x,
            b_mod
                .summands()
                .iter()
                .enumerate()
                .filter(|(j, _)| !used[*j]),
        )?
        else {
            return Ok(SupportPairIsoOutcome::NotIsomorphic(
                SupportPairObstruction::UnmatchedSummand {
                    index: i,
                    dim_vector: x.module().dim_vector().to_vec(),
                },
            ));
        };
        used[matched.target_index] = true;
        bijection.push(matched.target_index);
        forward.push(matched.forward);
        backward.push(matched.backward);
    }
    Ok(SupportPairIsoOutcome::Isomorphic(SupportPairIsoWitness {
        bijection,
        forward,
        backward,
    }))
}

/// Isomorphism invariants of one indecomposable summand, used as part of a
/// [`PairFingerprint`].
///
/// Every field is an isomorphism invariant, so isomorphic summands agree in
/// all of them. The converse fails: see [`PairFingerprint`].
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SummandFingerprint {
    dim_vector: Vec<usize>,
    loewy_length: usize,
    top_dim_vector: Vec<usize>,
    socle_dim_vector: Vec<usize>,
    end_dim: usize,
    residue_degree: usize,
    hom_from_simples: Vec<usize>,
    hom_to_simples: Vec<usize>,
}

impl SummandFingerprint {
    accessor_methods! {
        /// The dimension vector.
        pub dim_vector() -> &[usize] = |this| &this.dim_vector;
        /// The Loewy length, from [`loewy_length`].
        pub loewy_length() -> usize = |this| this.loewy_length;
        /// The dimension vector of `top X`.
        pub top_dim_vector() -> &[usize] = |this| &this.top_dim_vector;
        /// The dimension vector of `soc X`.
        pub socle_dim_vector() -> &[usize] = |this| &this.socle_dim_vector;
        /// `dim_Fp End(X)`.
        pub end_dim() -> usize = |this| this.end_dim;
        /// The residue degree of `End(X)`, from
        /// [`IndecomposableModule::residue_degree`].
        pub residue_degree() -> usize = |this| this.residue_degree;
        /// `hom_dim(S_v, X)` for every vertex `v`, in vertex order.
        pub hom_from_simples() -> &[usize] = |this| &this.hom_from_simples;
        /// `hom_dim(X, S_v)` for every vertex `v`, in vertex order.
        pub hom_to_simples() -> &[usize] = |this| &this.hom_to_simples;
    }
}

/// A cheap sound prefilter for pair identity.
///
/// The fingerprint holds the projective support and, per module summand, a
/// [`SummandFingerprint`]; the summand list is sorted, so it does not depend
/// on decomposition order. Isomorphic pairs have equal fingerprints, so
/// unequal fingerprints prove the pairs different.
///
/// A fingerprint match is inconclusive and the certified test [`pair_iso`] is
/// mandatory. Dimension vectors are isomorphism invariants but not complete
/// identifiers: over `kronecker(2)` the three modules of dimension vector
/// `[1, 1]` given by the arrow pairs `(1, 0)`, `(0, 1)`, and `(1, 1)` are
/// pairwise non-isomorphic and share every field of this fingerprint.
///
/// The Hom-dimension profile runs against a fixed anchor family, the simple
/// modules in vertex order. Nothing here profiles against previously found
/// pairs, so a fingerprint depends on the pair alone and never on the order
/// in which pairs were discovered.
///
/// [`PartialEq`], [`Eq`], and [`Hash`] let a caller bucket pairs by
/// fingerprint before running [`pair_iso`] inside a bucket.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct PairFingerprint {
    projective_support: Vec<u32>,
    summands: Vec<SummandFingerprint>,
}

impl PairFingerprint {
    /// Computes the fingerprint of the pair `(module, projective)`.
    ///
    /// Errors when the two parts do not share one algebra value.
    pub fn new(
        module: &BasicDecomposition,
        projective: &ProjectiveSupport,
    ) -> Result<PairFingerprint, BasicError> {
        Self::new_with_hom(module, projective, hom_dim)
    }

    pub(crate) fn new_with_context(
        module: &BasicDecomposition,
        projective: &ProjectiveSupport,
        context: &VerificationContext,
    ) -> Result<PairFingerprint, BasicError> {
        Self::new_with_hom(module, projective, |source, target| {
            context.hom_dim_for(source, target)
        })
    }

    fn new_with_hom(
        module: &BasicDecomposition,
        projective: &ProjectiveSupport,
        hom: impl Fn(&Module, &Module) -> Result<usize, HomError>,
    ) -> Result<PairFingerprint, BasicError> {
        hit(Site::PairFingerprintNew);
        let algebra = module.module().algebra();
        if !Arc::ptr_eq(algebra, projective.algebra()) {
            return Err(BasicError::DifferentAlgebras);
        }
        let simples: Vec<Module> = (0..algebra.quiver().num_vertices())
            .map(|v| Module::simple(algebra, v))
            .collect();
        let mut summands = Vec::with_capacity(module.len());
        for x in module.summands() {
            let m = x.module();
            let (top_module, _) = top(m);
            let (socle_module, _) = socle(m);
            let mut hom_from_simples = Vec::with_capacity(simples.len());
            let mut hom_to_simples = Vec::with_capacity(simples.len());
            for simple in &simples {
                hom_from_simples.push(hom(simple, m)?);
                hom_to_simples.push(hom(m, simple)?);
            }
            summands.push(SummandFingerprint {
                dim_vector: m.dim_vector().to_vec(),
                loewy_length: loewy_length(m),
                top_dim_vector: top_module.dim_vector().to_vec(),
                socle_dim_vector: socle_module.dim_vector().to_vec(),
                end_dim: x.endo().dim(),
                residue_degree: x.residue_degree(),
                hom_from_simples,
                hom_to_simples,
            });
        }
        summands.sort();
        Ok(PairFingerprint {
            projective_support: projective.vertices().to_vec(),
            summands,
        })
    }

    accessor_methods! {
        /// The projective support the fingerprint was keyed on.
        pub projective_support() -> &[u32] = |this| &this.projective_support;
        /// The per-summand records, sorted.
        pub summands() -> &[SummandFingerprint] = |this| &this.summands;
    }
}

/// Fingerprints items, then certifies every fingerprint collision.
pub(crate) fn pairwise_distinct_by<T, F>(
    items: &[T],
    mut fingerprint: impl FnMut(&T) -> Option<F>,
    mut distinct: impl FnMut(&T, &T) -> bool,
) -> bool
where
    F: PartialEq,
{
    let_or_false!(
        Some(fingerprints) = items
            .iter()
            .map(&mut fingerprint)
            .collect::<Option<Vec<F>>>()
    );
    (0..items.len()).all(|i| {
        (i + 1..items.len())
            .all(|j| fingerprints[i] != fingerprints[j] || distinct(&items[i], &items[j]))
    })
}

/// One summand of a module together with the summand of `T` it matches.
#[derive(Clone)]
pub struct AddMatch {
    pub(super) target_index: usize,
    pub(super) forward: Morphism,
    pub(super) backward: Morphism,
}

debug_fields!(AddMatch |this| {
    "target_index" => this.target_index;
});

impl AddMatch {
    accessor_methods! {
        /// Index of the matched summand of `T`.
        pub target_index() -> usize = |this| this.target_index;
        /// The isomorphism from the module summand to the summand of `T`.
        pub forward() -> &Morphism = |this| &this.forward;
        /// The inverse of [`AddMatch::forward`].
        pub backward() -> &Morphism = |this| &this.backward;
    }
}

/// The first certified match for `x`, with its checked inverse.
pub(super) fn certified_match<'a>(
    x: &IndecomposableModule,
    candidates: impl IntoIterator<Item = (usize, &'a IndecomposableModule)>,
) -> Result<Option<AddMatch>, BasicError> {
    for (target_index, y) in candidates {
        if let Some(forward) = indecomposable_iso(x.module(), y.module(), x.endo()) {
            let backward = inverse_morphism(&forward).ok_or_else(defect_non_invertible)?;
            return Ok(Some(AddMatch {
                target_index,
                forward,
                backward,
            }));
        }
    }
    Ok(None)
}