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
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
use std::sync::Arc;

use crate::hom::HomError;
use crate::homotopy::{
    BoundedComplex, BoundedComplexError, ChainHomQuotient, ChainHomSpace, ChainMap, ChainMapError,
    DegreeRange,
};
use crate::homspace::{HomSpace, row_times};
use crate::linalg::DenseMat;
use crate::resolution::{ProjectiveResolution, ResolutionEnd, resolve};
use crate::target::VerifiedTargetPresentation;
use crate::tilting::ClassicalTiltingModule;

use super::transport::{StrictTransport, TransportError};

/// Rejected derived-equivalence certificate input or verification data.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum DerivedCertificateError {
    /// The tilting certificate does not verify.
    InvalidTilting,
    /// The target presentation does not verify.
    InvalidTarget,
    /// The target and tilting certificates use different source modules.
    DifferentSource,
    /// The projective resolution was not finite.
    ResolutionCut { at: usize },
    /// The named resolution term is not projective.
    ResolutionTermNotProjective { term: usize },
    /// The resolution does not form a bounded homological complex.
    ResolutionComplex(BoundedComplexError),
    /// A homotopy endomorphism space could not be constructed.
    Homotopy(ChainMapError),
    /// A nonzero self-Hom survives in the named degree.
    NonzeroSelfHom { degree: i32, dimension: usize },
    /// The degree-zero homotopy endomorphism space has the wrong dimension.
    DegreeZeroDimension {
        homotopy: usize,
        endomorphism: usize,
    },
    /// The degree-zero map to `End_A(T)` is not an algebra isomorphism.
    DegreeZeroIdentification { reason: String },
    /// The generation complex or one of its `add(T)` witnesses does not verify.
    Generation,
    /// Strict transport did not build from the target presentation.
    Transport(TransportError),
    /// A resolution width cannot be represented as a homological degree.
    DegreeOverflow { width: usize },
}

display_error! { DerivedCertificateError {
    Self::InvalidTilting => "tilting certificate does not verify";
    Self::InvalidTarget => "target presentation does not verify";
    Self::DifferentSource => "tilting and target certificates use different source modules";
    Self::ResolutionCut { at } => "tilting resolution was cut after {at} differentials";
    Self::ResolutionTermNotProjective { term } => "resolution term {term} is not projective";
    Self::ResolutionComplex(error) => "resolution complex rejected: {error}";
    Self::Homotopy(error) => "homotopy endomorphism space rejected: {error}";
    Self::NonzeroSelfHom { degree, dimension } => "homotopy self-Hom in degree {degree} has dimension {dimension}";
    Self::DegreeZeroDimension { homotopy, endomorphism } => "degree-zero homotopy dimension {homotopy} differs from End(T) dimension {endomorphism}";
    Self::DegreeZeroIdentification { reason } => "degree-zero End(T) identification failed: {reason}";
    Self::Generation => "generation complex or add(T) witnesses do not verify";
    Self::Transport(error) => "strict transport rejected: {error}";
    Self::DegreeOverflow { width } => "resolution width {width} does not fit in i32";
} }

error_source! { DerivedCertificateError {
    Self::ResolutionComplex(error) => Some(error),
    Self::Homotopy(error) => Some(error),
    Self::Transport(error) => Some(error),
    _ => None,
} }

/// One graded homotopy endomorphism space of the tilting resolution.
#[derive(Clone, Debug)]
pub struct GradedHomotopyEndomorphisms {
    pub(super) degree: i32,
    pub(super) quotient: ChainHomQuotient,
}

impl GradedHomotopyEndomorphisms {
    accessor_methods! {
        /// The target shift degree.
        pub degree() -> i32 = |this| this.degree;
        /// The deterministic homotopy quotient in this degree.
        pub quotient() -> &ChainHomQuotient = |this| &this.quotient;
    }

    /// Rechecks the stored quotient basis and null-homotopic subspace.
    pub fn verify(&self) -> bool {
        self.quotient.verify()
    }
}

/// The checked degree-zero map from homotopy endomorphisms to `End_A(T)`.
#[derive(Clone, Debug)]
pub struct DegreeZeroEndIdentification {
    pub(super) quotient: ChainHomQuotient,
    pub(super) coordinates: DenseMat,
}

impl DegreeZeroEndIdentification {
    accessor_methods! {
        /// The degree-zero homotopy endomorphism quotient.
        pub quotient() -> &ChainHomQuotient = |this| &this.quotient;
        /// Rows map quotient-basis coordinates to `End_A(T)` coordinates.
        pub coordinates() -> &DenseMat = |this| &this.coordinates;
    }
}

fn induced_endomorphism_coordinates(
    resolution: &ProjectiveResolution,
    map: &ChainMap,
    target: &VerifiedTargetPresentation,
) -> Result<Vec<crate::field::Fp>, DerivedCertificateError> {
    let endo = target.endo();
    let hom = HomSpace::new(&resolution.terms[0], target.source()).map_err(|error| {
        DerivedCertificateError::DegreeZeroIdentification {
            reason: format!("augmentation Hom space failed: {error}"),
        }
    })?;
    let rows: Vec<Vec<crate::field::Fp>> = endo
        .basis()
        .iter()
        .map(|basis| {
            resolution
                .augmentation
                .then(basis)
                .and_then(|map| hom.coords(&map).map_err(|_| HomError::EndpointMismatch))
        })
        .collect::<Result<_, _>>()
        .map_err(|error| DerivedCertificateError::DegreeZeroIdentification {
            reason: format!("End(T) action on the augmentation failed: {error}"),
        })?;
    let lift = DenseMat::from_rows_with_cols(&rows, hom.dim());
    let component = map
        .component(0)
        .map_err(DerivedCertificateError::Homotopy)?;
    let desired = component
        .then(&resolution.augmentation)
        .and_then(|map| hom.coords(&map).map_err(|_| HomError::EndpointMismatch))
        .map_err(|error| DerivedCertificateError::DegreeZeroIdentification {
            reason: format!("chain map did not descend along the augmentation: {error}"),
        })?;
    lift.transpose()
        .solve(&desired, &endo.field())
        .ok_or_else(|| DerivedCertificateError::DegreeZeroIdentification {
            reason: "chain map has no induced endomorphism of T".to_string(),
        })
}

fn basis_vector(
    field: &crate::field::PrimeField,
    dimension: usize,
    index: usize,
) -> Vec<crate::field::Fp> {
    let mut coordinates = vec![field.zero(); dimension];
    coordinates[index] = field.one();
    coordinates
}

fn degree_zero_basis_coordinates(
    resolution: &ProjectiveResolution,
    target: &VerifiedTargetPresentation,
    quotient: &ChainHomQuotient,
) -> Result<DenseMat, DerivedCertificateError> {
    let field = target.endo().field();
    let rows = (0..quotient.dim())
        .map(|index| {
            induced_endomorphism_coordinates(
                resolution,
                &quotient.representative(&basis_vector(&field, quotient.dim(), index)),
                target,
            )
        })
        .collect::<Result<Vec<_>, _>>()?;
    let coordinates = DenseMat::from_rows_with_cols(&rows, target.endo().dim());
    if coordinates.rank(&field) != target.endo().dim() {
        return Err(DerivedCertificateError::DegreeZeroIdentification {
            reason: "induced endomorphisms do not span End(T)".to_string(),
        });
    }
    Ok(coordinates)
}

fn degree_zero_product(
    resolution: &ProjectiveResolution,
    target: &VerifiedTargetPresentation,
    quotient: &ChainHomQuotient,
    coordinates: &DenseMat,
    left: usize,
    left_map: &ChainMap,
    right: usize,
) -> Result<(), DerivedCertificateError> {
    let right_map =
        quotient.representative(&basis_vector(&target.endo().field(), quotient.dim(), right));
    let product = left_map
        .then(&right_map)
        .map_err(DerivedCertificateError::Homotopy)?;
    let quotient_product = quotient
        .reduce(&product)
        .map_err(DerivedCertificateError::Homotopy)?
        .0;
    let expected = row_times(&quotient_product, coordinates, &target.endo().field());
    let actual = induced_endomorphism_coordinates(resolution, &product, target)?;
    let direct = target
        .endo()
        .multiply(coordinates.row(left), coordinates.row(right));
    if actual != expected || actual != direct {
        return Err(DerivedCertificateError::DegreeZeroIdentification {
            reason: format!("product mismatch at quotient basis pair ({left}, {right})"),
        });
    }
    Ok(())
}

fn verify_degree_zero_products(
    resolution: &ProjectiveResolution,
    target: &VerifiedTargetPresentation,
    quotient: &ChainHomQuotient,
    coordinates: &DenseMat,
) -> Result<(), DerivedCertificateError> {
    let field = target.endo().field();
    for left in 0..quotient.dim() {
        let left_map = quotient.representative(&basis_vector(&field, quotient.dim(), left));
        for right in 0..quotient.dim() {
            degree_zero_product(
                resolution,
                target,
                quotient,
                coordinates,
                left,
                &left_map,
                right,
            )?;
        }
    }
    Ok(())
}

fn degree_zero_identification(
    resolution_complex: &BoundedComplex,
    resolution: &ProjectiveResolution,
    target: &VerifiedTargetPresentation,
    quotient: &ChainHomQuotient,
) -> Result<DegreeZeroEndIdentification, DerivedCertificateError> {
    let endo = target.endo();
    if quotient.dim() != endo.dim() {
        return Err(DerivedCertificateError::DegreeZeroDimension {
            homotopy: quotient.dim(),
            endomorphism: endo.dim(),
        });
    }
    let coordinates = degree_zero_basis_coordinates(resolution, target, quotient)?;
    verify_degree_zero_products(resolution, target, quotient, &coordinates)?;
    if !resolution_complex.verify() {
        return Err(DerivedCertificateError::ResolutionComplex(
            BoundedComplexError::Empty,
        ));
    }
    Ok(DegreeZeroEndIdentification {
        quotient: quotient.clone(),
        coordinates,
    })
}

/// A certificate for the bounded derived equivalence from a split tilting target.
#[derive(Clone)]
pub struct DerivedEquivalenceCertificate {
    pub(super) tilting: ClassicalTiltingModule,
    pub(super) target: VerifiedTargetPresentation,
    pub(super) resolution_complex: BoundedComplex,
    pub(super) graded_homotopy: Vec<GradedHomotopyEndomorphisms>,
    pub(super) degree_zero: DegreeZeroEndIdentification,
    pub(super) transport: StrictTransport,
}

debug_fields!(DerivedEquivalenceCertificate |this| {
    "source_dim_vector" => this.tilting.module().dim_vector();
    "resolution_width" => this.tilting.projective_dimension();
    "graded_homotopy_spaces" => this.graded_homotopy.len();
});

fn certificate_resolution(
    tilting: &ClassicalTiltingModule,
) -> Result<(BoundedComplex, i32), DerivedCertificateError> {
    let resolution = tilting.resolution();
    if let ResolutionEnd::Cut { at } = resolution.end {
        return Err(DerivedCertificateError::ResolutionCut { at });
    }
    for (term, module) in resolution.terms.iter().enumerate() {
        if !matches!(resolve(module, 0).end, ResolutionEnd::Finite) {
            return Err(DerivedCertificateError::ResolutionTermNotProjective { term });
        }
    }
    let resolution_complex =
        BoundedComplex::new(0, resolution.terms.clone(), resolution.maps.clone())
            .map_err(DerivedCertificateError::ResolutionComplex)?;
    let width = i32::try_from(tilting.projective_dimension()).map_err(|_| {
        DerivedCertificateError::DegreeOverflow {
            width: tilting.projective_dimension(),
        }
    })?;
    Ok((resolution_complex, width))
}

fn graded_homotopy_at_degree(
    resolution: &BoundedComplex,
    degree: i32,
) -> Result<GradedHomotopyEndomorphisms, DerivedCertificateError> {
    let shifted = resolution
        .shift(degree)
        .map_err(DerivedCertificateError::ResolutionComplex)?;
    let quotient = ChainHomSpace::new(resolution, &shifted)
        .map_err(DerivedCertificateError::Homotopy)?
        .quotient()
        .map_err(DerivedCertificateError::Homotopy)?;
    if degree != 0 && quotient.dim() != 0 {
        return Err(DerivedCertificateError::NonzeroSelfHom {
            degree,
            dimension: quotient.dim(),
        });
    }
    Ok(GradedHomotopyEndomorphisms { degree, quotient })
}

fn graded_homotopy_spaces(
    resolution: &BoundedComplex,
    width: i32,
) -> Result<(Vec<GradedHomotopyEndomorphisms>, ChainHomQuotient), DerivedCertificateError> {
    let graded_homotopy = (-width..=width)
        .map(|degree| graded_homotopy_at_degree(resolution, degree))
        .collect::<Result<Vec<_>, _>>()?;
    let zero = graded_homotopy
        .iter()
        .find(|space| space.degree == 0)
        .expect("the degree range includes zero")
        .quotient
        .clone();
    Ok((graded_homotopy, zero))
}

fn generation_is_valid(tilting: &ClassicalTiltingModule) -> bool {
    let generation = tilting.generation_complex();
    let witnesses = tilting.add_witnesses();
    generation.verify()
        && witnesses.len() + 1 == generation.complex().len()
        && witnesses
            .iter()
            .all(|witness| witness.verify() && witness.target().ptr_eq(tilting.module()))
}

fn verify_certificate_base(certificate: &DerivedEquivalenceCertificate) -> bool {
    let tilting = &certificate.tilting;
    let resolution = tilting.resolution();
    tilting.verify()
        && certificate.target.verify()
        && tilting.module().ptr_eq(certificate.target.source())
        && certificate.resolution_complex.verify()
        && resolution.end == ResolutionEnd::Finite
        && resolution
            .terms
            .iter()
            .all(|term| matches!(resolve(term, 0).end, ResolutionEnd::Finite))
}

fn verify_graded_space(
    resolution: &BoundedComplex,
    width: i32,
    offset: usize,
    space: &GradedHomotopyEndomorphisms,
) -> bool {
    let degree = -width + offset as i32;
    if space.degree != degree || !space.verify() {
        return false;
    }
    let Some(shifted) = resolution.shift(degree).ok() else {
        return false;
    };
    let Some(range) = DegreeRange::new(
        resolution.lower().min(shifted.lower()),
        resolution.upper().max(shifted.upper()),
    )
    .ok() else {
        return false;
    };
    let (Some(source), Some(target)) = (
        resolution.padded_to(range).ok(),
        shifted.padded_to(range).ok(),
    ) else {
        return false;
    };
    space.quotient.source().agrees_with(&source)
        && space.quotient.target().agrees_with(&target)
        && (degree == 0 || space.quotient.dim() == 0)
}

fn verified_zero_homotopy(
    certificate: &DerivedEquivalenceCertificate,
) -> Option<&GradedHomotopyEndomorphisms> {
    if !verify_certificate_base(certificate) {
        return None;
    }
    let width = i32::try_from(certificate.tilting.projective_dimension()).ok()?;
    let count = usize::try_from(width)
        .ok()?
        .checked_mul(2)?
        .checked_add(1)?;
    if certificate.graded_homotopy.len() != count
        || !certificate
            .graded_homotopy
            .iter()
            .enumerate()
            .all(|(offset, space)| {
                verify_graded_space(&certificate.resolution_complex, width, offset, space)
            })
    {
        return None;
    }
    certificate
        .graded_homotopy
        .iter()
        .find(|space| space.degree == 0)
}

fn verify_degree_zero(
    certificate: &DerivedEquivalenceCertificate,
    zero: &GradedHomotopyEndomorphisms,
) -> bool {
    let quotient = &certificate.degree_zero.quotient;
    let resolution = &certificate.resolution_complex;
    let Ok(rebuilt) = degree_zero_identification(
        resolution,
        certificate.tilting.resolution(),
        &certificate.target,
        quotient,
    ) else {
        return false;
    };
    let stored = &certificate.degree_zero;
    stored.quotient.verify()
        && stored.quotient.dim() == zero.quotient.dim()
        && rebuilt.coordinates == stored.coordinates
        && quotient.source().agrees_with(resolution)
        && quotient.target().agrees_with(resolution)
        && {
            let tilting = &certificate.tilting;
            let generation = tilting.generation_complex();
            generation.verify()
                && tilting.add_witnesses().len() + 1 == generation.complex().len()
                && tilting
                    .add_witnesses()
                    .iter()
                    .zip(&generation.complex().terms()[1..])
                    .all(|(witness, term)| {
                        witness.verify()
                            && witness.module().ptr_eq(term)
                            && witness.target().ptr_eq(tilting.module())
                    })
        }
}

impl DerivedEquivalenceCertificate {
    /// Builds the complete bounded derived-equivalence certificate.
    pub fn new(
        tilting: ClassicalTiltingModule,
        target: VerifiedTargetPresentation,
    ) -> Result<DerivedEquivalenceCertificate, DerivedCertificateError> {
        if !tilting.verify() {
            return Err(DerivedCertificateError::InvalidTilting);
        }
        if !target.verify() {
            return Err(DerivedCertificateError::InvalidTarget);
        }
        if !tilting.module().ptr_eq(target.source()) {
            return Err(DerivedCertificateError::DifferentSource);
        }
        let (resolution_complex, width) = certificate_resolution(&tilting)?;
        let (graded_homotopy, zero) = graded_homotopy_spaces(&resolution_complex, width)?;
        let degree_zero =
            degree_zero_identification(&resolution_complex, tilting.resolution(), &target, &zero)?;
        if !generation_is_valid(&tilting) {
            return Err(DerivedCertificateError::Generation);
        }
        let transport =
            StrictTransport::new(target.clone()).map_err(DerivedCertificateError::Transport)?;
        Ok(DerivedEquivalenceCertificate {
            tilting,
            target,
            resolution_complex,
            graded_homotopy,
            degree_zero,
            transport,
        })
    }

    accessor_methods! {
        /// The verified classical tilting data.
        pub tilting() -> &ClassicalTiltingModule = |this| &this.tilting;
        /// The verified split target presentation.
        pub target() -> &VerifiedTargetPresentation = |this| &this.target;
        /// The bounded projective resolution as a homological complex.
        pub resolution_complex() -> &BoundedComplex = |this| &this.resolution_complex;
        /// The homotopy endomorphism quotients through the resolution width.
        pub graded_homotopy() -> &[GradedHomotopyEndomorphisms] = |this| &this.graded_homotopy;
        /// The checked degree-zero algebra identification.
        pub degree_zero_identification() -> &DegreeZeroEndIdentification = |this| &this.degree_zero;
        /// The strict `add(T)` and projective transport data.
        pub transport() -> &StrictTransport = |this| &this.transport;
    }

    /// Rechecks tilting, generation, target recovery, homotopy spaces, and transport.
    pub fn verify(&self) -> bool {
        let Some(zero) = verified_zero_homotopy(self) else {
            return false;
        };
        if !verify_degree_zero(self, zero) {
            return false;
        }
        let transport = &self.transport;
        transport.verify()
            && transport.target().source().ptr_eq(self.target.source())
            && Arc::ptr_eq(transport.target().target(), self.target.target())
    }
}