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
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
493
494
495
496
497
498
499
500
501
502
503
504
//! Checked derived invariants of one algebra, and witnesses that two algebras
//! are not derived equivalent.
//!
//! [`DerivedInvariants`] computes every [`DerivedInvariantKind`] of one
//! algebra. An invariant that does not finish ends in a typed
//! [`InvariantStop`]: an `i128` overflow, a bar limit, or cancellation. An
//! invariant whose hypothesis fails reads [`InvariantReading::NotApplicable`].
//! [`first_difference`] names the first kind whose values
//! both finished and differ, and [`DerivedInequivalenceWitness`] stores that
//! difference for recomputation.
//!
//! Every invariant here is a necessary condition. For two connected gentle
//! algebras, Amiot, Plamondon, and Schroll prove that the AAG function and
//! the winding class together are also sufficient. Equal values never merge
//! two algebras.
//!
//! # Cartan invariants
//!
//! Let `C` be [`Algebra::cartan_matrix`] of an algebra `A` with `n` vertices.
//! A derived equivalence `D(A) โ†’ D(B)` restricts to perfect complexes, which
//! are the compact objects of `D(A)`. It induces an isometry of `K_0(per A)`
//! and `K_0(per B)` for the Euler form `โŸจX, YโŸฉ = ฮฃ (-1)^i dim Hom(X, Y[i])`.
//! On the basis of indecomposable projectives `P_i = e_i A`, the Gram matrix
//! has entries `dim Hom(P_i, P_j) = dim e_j A e_i`, so it is `C^T`. Hence
//! `C_B = X C_A X^T` for some `X` in `GL_n(Z)`. Happel (1988) gives this
//! argument for algebras of finite global dimension.
//!
//! Integral congruence keeps `n` and `det C`, because `det(X)^2 = 1`. It maps
//! `C ยฑ C^T` to `X (C ยฑ C^T) X^T`, so the invariant factors of `C`,
//! `C + C^T`, and `C - C^T` agree. It multiplies `det(xC + C^T)` by
//! `det(X)^2 = 1`. None of this needs finite global dimension. When `det C`
//! is nonzero, the pencil divided by `det C` is the Coxeter polynomial.
//!
//! Every Cartan invariant is the same for `C` and `C^T`, so the Gram
//! convention does not matter: transposition keeps determinants and invariant
//! factors, negates `C - C^T`, and fixes the pencil, since
//! `det(xC^T + C) = det((xC + C^T)^T)`.
//!
//! The arithmetic is exact over `i128` and checked. An intermediate value
//! outside `i128` gives [`InvariantStop::Overflow`], never a wrong value.
//!
//! # Hochschild invariants
//!
//! Rickard (1991) proves that derived equivalent algebras over a field `k`
//! have isomorphic Hochschild cohomology. So `dim HH^i` agrees for every `i`,
//! and `dim HH^0`, the dimension of the center, agrees too. These dimensions
//! depend on the field. [`DerivedInequivalenceWitness`] requires both
//! algebras over the same `GF(p)`.
//!
//! [`crate::hochschild::bar_hochschild`] computes `HH^0` through `HH^d` under
//! [`InvariantLimits::bar`]. A bar cut keeps the finished degrees and records
//! the cut in [`HochschildDimensions::end`]. The center dimension reads
//! `HH^0` from the same computation.
//!
//! # Avella-Alaminos-Geiss function
//!
//! Avella-Alaminos and Geiss (2008, Theorem A) prove that derived equivalent
//! gentle algebras have equal functions. The reading is
//! [`crate::gentle::GentlePresentation::aag_function`] when
//! [`crate::gentle::GentlePresentation::new`] accepts the stored
//! presentation. Otherwise it is [`InvariantReading::NotApplicable`] with the
//! recognition error. A rejected presentation proves nothing about the
//! algebra, so that reading never separates. The kind sits after the Cartan
//! kinds and before the Hochschild kinds: recognition and the thread walk
//! cost time linear in the arrow count, far below the bar computation.
//!
//! # Winding class
//!
//! For a gentle presentation of genus at least 1, equal AAG functions do not
//! imply derived equivalence. [`crate::gentle::WindingClass`] adds the
//! winding-number data of Lekili and Polishchuk (2020, Theorem 1.2.4) and
//! Amiot, Plamondon, and Schroll (2023, Theorem 5.4): a gcd in genus 1, and
//! the parity or Arf invariant in higher genus. In genus 0 it is `Planar`.
//! A presentation that fails recognition reads
//! [`InvariantReading::NotApplicable`], as for the AAG function.
//! Derived equivalence over `GF(p)` extends to its algebraic closure, so a
//! difference over the closure also separates over `GF(p)`. The repository
//! document `docs/gentle-derived-invariant.md` records the construction.
//!
//! # References
//!
//! - D. Avella-Alaminos and C. Geiss, "Combinatorial derived invariants for
//!   gentle algebras", J. Pure Appl. Algebra 212 (2008), 228-243.
//! - C. Amiot, P.-G. Plamondon, and S. Schroll, "A complete derived invariant
//!   for gentle algebras via winding numbers and Arf invariants", Selecta
//!   Math. (N.S.) 29 (2023), no. 2, paper 30.
//! - D. Happel, "Triangulated categories in the representation theory of
//!   finite dimensional algebras", London Math. Soc. Lecture Note Ser. 119,
//!   Cambridge University Press, 1988.
//! - Y. Lekili and A. Polishchuk, "Derived equivalences of gentle algebras via
//!   Fukaya categories", Math. Ann. 376 (2020), 187-225.
//! - J. Rickard, "Derived equivalences as derived functors", J. London Math.
//!   Soc. (2) 43 (1991), 37-48.

mod integer;
mod witness;

pub use witness::{DerivedInequivalenceWitness, WitnessError};

use std::sync::Arc;

use crate::algebra::Algebra;
use crate::control::ComputationControl;
use crate::gentle::{AagFunction, GentleError, GentlePresentation, WindingClass};
use crate::hochschild::{
    BarBudgetDiagnostics, BarLimits, HochschildDegree, HochschildError, HochschildOutcome,
    bar_hochschild,
};

use integer::{Checked, Overflow};

/// One derived invariant, in the table order of the classification contract.
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[non_exhaustive]
pub enum DerivedInvariantKind {
    /// The number of vertices, the rank of `K_0`.
    VertexCount,
    /// `det C` in `Z`.
    CartanDeterminant,
    /// The invariant factors of `C`.
    CartanFactors,
    /// The invariant factors of `C + C^T`.
    SymmetricFactors,
    /// The invariant factors of `C - C^T`.
    SkewFactors,
    /// `det(xC + C^T)` in `Z[x]`.
    CartanPencil,
    /// The Avella-Alaminos-Geiss function of a gentle presentation.
    AagFunction,
    /// The [`WindingClass`] of a gentle presentation.
    WindingClass,
    /// `dim HH^i` for each finished degree `i <= d`.
    HochschildDimensions,
    /// `dim HH^0`, the dimension of the center.
    CenterDimension,
}

impl DerivedInvariantKind {
    /// Every kind in table order. [`first_difference`] walks this list.
    pub const ALL: [DerivedInvariantKind; 10] = [
        DerivedInvariantKind::VertexCount,
        DerivedInvariantKind::CartanDeterminant,
        DerivedInvariantKind::CartanFactors,
        DerivedInvariantKind::SymmetricFactors,
        DerivedInvariantKind::SkewFactors,
        DerivedInvariantKind::CartanPencil,
        DerivedInvariantKind::AagFunction,
        DerivedInvariantKind::WindingClass,
        DerivedInvariantKind::HochschildDimensions,
        DerivedInvariantKind::CenterDimension,
    ];
}

/// The finished value of one derived invariant.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum InvariantValue {
    /// The vertex count or the center dimension.
    Count(usize),
    /// The Cartan determinant.
    Integer(i128),
    /// Invariant factors `d_1 | ... | d_n`: nonnegative, zeros last.
    Factors(Vec<i128>),
    /// Coefficients in `Z[x]`, constant term first, with no trailing zero.
    Polynomial(Vec<i128>),
    /// The Avella-Alaminos-Geiss function.
    AagFunction(AagFunction),
    /// The winding class.
    WindingClass(WindingClass),
    /// `dim HH^0, ..., dim HH^k` for the finished degrees `0..=k`. The list
    /// is shorter than `d + 1` exactly when a bar cut stopped the computation
    /// after `HH^k`; [`HochschildDimensions::end`] records that cut.
    Dimensions(Vec<usize>),
}

impl InvariantValue {
    /// Whether the two values of one kind prove a difference.
    ///
    /// Two `Dimensions` prefixes differ only at a degree present in both. A
    /// longer prefix alone proves nothing.
    pub fn differs_from(&self, other: &InvariantValue) -> bool {
        match (self, other) {
            (InvariantValue::Dimensions(left), InvariantValue::Dimensions(right)) => {
                left.iter().zip(right).any(|(left, right)| left != right)
            }
            _ => self != other,
        }
    }
}

/// Why one derived invariant did not finish.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum InvariantStop {
    /// An intermediate integer left the `i128` range.
    Overflow,
    /// The bar computation hit a limit before the value finished.
    BarCut(Box<BarBudgetDiagnostics>),
    /// Cancellation was requested before the bar computation started.
    Cancelled,
}

/// The outcome of one derived invariant: a finished value, a typed stop, or
/// a failed hypothesis.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum InvariantReading {
    /// The exact value.
    Finished(InvariantValue),
    /// The computation stopped without a value.
    Stopped(InvariantStop),
    /// The invariant is not defined for this presentation. Only
    /// [`DerivedInvariantKind::AagFunction`] and
    /// [`DerivedInvariantKind::WindingClass`] read this, with the gentle
    /// recognition error. It is not a stop: more resources give the same
    /// reading.
    NotApplicable(GentleError),
}

impl InvariantReading {
    /// Whether both readings finished and their values differ.
    pub fn separates(&self, other: &InvariantReading) -> bool {
        matches!(
            (self, other),
            (InvariantReading::Finished(left), InvariantReading::Finished(right))
                if left.differs_from(right)
        )
    }
}

/// Resource ceilings for one invariant computation.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct InvariantLimits {
    /// The last Hochschild degree `d`.
    pub hochschild_degree: usize,
    /// The ceilings of the bar computation.
    pub bar: BarLimits,
}

/// How the Hochschild computation ended.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum HochschildEnd {
    /// Every degree through `d` finished.
    Complete,
    /// A bar cut or cancellation stopped the computation after the finished
    /// prefix.
    Stopped(InvariantStop),
}

/// `dim HH^i` for the finished degrees, with the typed end of the computation.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct HochschildDimensions {
    requested_degree: usize,
    dimensions: Vec<usize>,
    end: HochschildEnd,
}

impl HochschildDimensions {
    accessor_methods! {
        /// The requested last degree `d`.
        pub requested_degree() -> usize = |this| this.requested_degree;
        /// `dim HH^i` for the finished degrees `i`, starting at `0`.
        pub dimensions() -> &[usize] = |this| &this.dimensions;
        /// How the computation ended.
        pub end() -> &HochschildEnd = |this| &this.end;
    }

    fn compute(
        algebra: &Arc<Algebra>,
        limits: InvariantLimits,
        control: &ComputationControl,
    ) -> Result<HochschildDimensions, HochschildError> {
        let requested_degree = limits.hochschild_degree;
        let dimensions = |degrees: &[HochschildDegree]| degrees.iter().map(|d| d.dim()).collect();
        let (dimensions, end) = if control.is_cancelled() {
            (Vec::new(), HochschildEnd::Stopped(InvariantStop::Cancelled))
        } else {
            match bar_hochschild(algebra, requested_degree, limits.bar)? {
                HochschildOutcome::Complete(value) => {
                    (dimensions(value.degrees()), HochschildEnd::Complete)
                }
                HochschildOutcome::Cut(cut) => (
                    dimensions(cut.completed_degrees()),
                    HochschildEnd::Stopped(InvariantStop::BarCut(Box::new(
                        cut.diagnostics().clone(),
                    ))),
                ),
            }
        };
        Ok(HochschildDimensions {
            requested_degree,
            dimensions,
            end,
        })
    }

    fn dimensions_reading(&self) -> InvariantReading {
        let finished = !self.dimensions.is_empty();
        self.reading(finished.then(|| InvariantValue::Dimensions(self.dimensions.clone())))
    }

    fn center_reading(&self) -> InvariantReading {
        self.reading(self.dimensions.first().copied().map(InvariantValue::Count))
    }

    /// Reads a value from the finished prefix, or the stop when it has none.
    fn reading(&self, value: Option<InvariantValue>) -> InvariantReading {
        match (value, &self.end) {
            (Some(value), _) => InvariantReading::Finished(value),
            (None, HochschildEnd::Stopped(stop)) => InvariantReading::Stopped(stop.clone()),
            (None, HochschildEnd::Complete) => unreachable!("a complete bar result has HH^0"),
        }
    }
}

/// Every derived invariant of one algebra under one set of limits.
#[derive(Clone, Debug)]
pub struct DerivedInvariants {
    algebra: Arc<Algebra>,
    limits: InvariantLimits,
    readings: Vec<InvariantReading>,
    hochschild: HochschildDimensions,
}

impl DerivedInvariants {
    /// Computes every invariant of `algebra` in table order.
    ///
    /// Cancellation is checked once, before the bar computation starts. The
    /// Cartan invariants always run. Errors only on an internal bar defect.
    pub fn compute(
        algebra: &Arc<Algebra>,
        limits: InvariantLimits,
        control: &ComputationControl,
    ) -> Result<DerivedInvariants, HochschildError> {
        let mut evaluator = Evaluator::new(algebra, limits, control);
        let readings = DerivedInvariantKind::ALL
            .iter()
            .map(|&kind| evaluator.reading(kind))
            .collect::<Result<Vec<_>, _>>()?;
        let hochschild = evaluator.hochschild()?.clone();
        Ok(DerivedInvariants {
            algebra: algebra.clone(),
            limits,
            readings,
            hochschild,
        })
    }

    accessor_methods! {
        /// The algebra these invariants describe.
        pub algebra() -> &Arc<Algebra> = |this| &this.algebra;
        /// The limits of the computation.
        pub limits() -> InvariantLimits = |this| this.limits;
        /// The Hochschild dimensions and how their computation ended.
        pub hochschild() -> &HochschildDimensions = |this| &this.hochschild;
        /// The reading of one invariant.
        pub reading(kind: DerivedInvariantKind) -> &InvariantReading = |this| &this.readings[kind as usize];
    }
}

/// Computes one derived invariant of `algebra` from scratch.
///
/// The bar computation runs only for [`DerivedInvariantKind::HochschildDimensions`]
/// and [`DerivedInvariantKind::CenterDimension`], with the same limits as
/// [`DerivedInvariants::compute`].
pub fn derived_invariant(
    algebra: &Arc<Algebra>,
    kind: DerivedInvariantKind,
    limits: InvariantLimits,
    control: &ComputationControl,
) -> Result<InvariantReading, HochschildError> {
    Evaluator::new(algebra, limits, control).reading(kind)
}

/// The first kind in table order whose readings both finished and differ.
///
/// `None` means that every pair of finished readings agrees. A reading that
/// stopped or is not applicable never separates. The comparison does not check the two fields;
/// [`DerivedInequivalenceWitness::new`] does.
pub fn first_difference(
    left: &DerivedInvariants,
    right: &DerivedInvariants,
) -> Option<DerivedInvariantKind> {
    DerivedInvariantKind::ALL
        .into_iter()
        .find(|&kind| left.reading(kind).separates(right.reading(kind)))
}

/// Computes readings on demand and runs the bar computation at most once.
struct Evaluator<'a> {
    algebra: &'a Arc<Algebra>,
    limits: InvariantLimits,
    control: &'a ComputationControl,
    cartan: Checked<Vec<Vec<i128>>>,
    hochschild: Option<HochschildDimensions>,
}

impl<'a> Evaluator<'a> {
    fn new(
        algebra: &'a Arc<Algebra>,
        limits: InvariantLimits,
        control: &'a ComputationControl,
    ) -> Evaluator<'a> {
        let cartan = algebra
            .cartan_matrix()
            .into_iter()
            .map(|row| {
                row.into_iter()
                    .map(|e| i128::try_from(e).map_err(|_| Overflow))
                    .collect()
            })
            .collect();
        Evaluator {
            algebra,
            limits,
            control,
            cartan,
            hochschild: None,
        }
    }

    fn hochschild(&mut self) -> Result<&HochschildDimensions, HochschildError> {
        let value = match self.hochschild.take() {
            Some(value) => value,
            None => HochschildDimensions::compute(self.algebra, self.limits, self.control)?,
        };
        Ok(self.hochschild.insert(value))
    }

    fn integer(
        &self,
        value: impl FnOnce(&[Vec<i128>]) -> Checked<InvariantValue>,
    ) -> InvariantReading {
        match self
            .cartan
            .as_deref()
            .map_err(|&error| error)
            .and_then(value)
        {
            Ok(value) => InvariantReading::Finished(value),
            Err(Overflow) => InvariantReading::Stopped(InvariantStop::Overflow),
        }
    }

    fn reading(&mut self, kind: DerivedInvariantKind) -> Result<InvariantReading, HochschildError> {
        use DerivedInvariantKind as Kind;
        Ok(match kind {
            Kind::VertexCount => InvariantReading::Finished(InvariantValue::Count(
                self.algebra.quiver().num_vertices() as usize,
            )),
            Kind::CartanDeterminant
            | Kind::CartanFactors
            | Kind::SymmetricFactors
            | Kind::SkewFactors
            | Kind::CartanPencil => self.integer(|cartan| cartan_value(kind, cartan)),
            Kind::AagFunction => gentle_reading(self.algebra, |gentle| {
                InvariantValue::AagFunction(gentle.aag_function())
            }),
            Kind::WindingClass => gentle_reading(self.algebra, |gentle| {
                InvariantValue::WindingClass(gentle.complete_invariant().winding_class())
            }),
            Kind::HochschildDimensions => self.hochschild()?.dimensions_reading(),
            Kind::CenterDimension => self.hochschild()?.center_reading(),
        })
    }
}

/// The value of one Cartan kind, computed from `C`.
fn cartan_value(kind: DerivedInvariantKind, cartan: &[Vec<i128>]) -> Checked<InvariantValue> {
    use DerivedInvariantKind as Kind;
    match kind {
        Kind::CartanDeterminant => integer::determinant(cartan).map(InvariantValue::Integer),
        Kind::CartanFactors => integer::invariant_factors(cartan).map(InvariantValue::Factors),
        Kind::SymmetricFactors => transpose_factors(cartan, 1),
        Kind::SkewFactors => transpose_factors(cartan, -1),
        Kind::CartanPencil => integer::pencil(cartan).map(InvariantValue::Polynomial),
        Kind::VertexCount
        | Kind::AagFunction
        | Kind::WindingClass
        | Kind::HochschildDimensions
        | Kind::CenterDimension => {
            unreachable!("{kind:?} is not read from the Cartan matrix")
        }
    }
}

/// One value of the stored presentation when it is gentle.
fn gentle_reading(
    algebra: &Arc<Algebra>,
    value: impl FnOnce(&GentlePresentation) -> InvariantValue,
) -> InvariantReading {
    match GentlePresentation::new(algebra) {
        Ok(presentation) => InvariantReading::Finished(value(&presentation)),
        Err(error) => InvariantReading::NotApplicable(error),
    }
}

/// The invariant factors of `C + sign ยท C^T`.
fn transpose_factors(matrix: &[Vec<i128>], sign: i128) -> Checked<InvariantValue> {
    integer::invariant_factors(&integer::with_transpose(matrix, 1, sign)?)
        .map(InvariantValue::Factors)
}

#[cfg(test)]
mod tests;