auslander 0.8.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
//! Split target presentations from exceptional tilting complexes.

use std::sync::{Arc, OnceLock};

use crate::algebra::Algebra;
use crate::certificate::Certificate;
use crate::field::{Fp, PrimeField};
use crate::homotopy::{ChainMap, ChainMapError, HomotopyHom, HomotopyHomQuotient};
use crate::linalg::DenseMat;
use crate::target::{
    CoordinateAlgebra, CoordinateTargetData, CoordinateTargetOutcome, TargetCutReason, TargetError,
    TargetLimits, TargetWork, recover_coordinate_target, verify_coordinate_target_data,
};
use crate::tilting_complex::CertifiedTiltingComplex;

#[derive(Clone, Debug)]
struct EndBlock {
    source: usize,
    target: usize,
    offset: usize,
    quotient: HomotopyHomQuotient,
}

/// The checked coordinate algebra `End_K(T)`.
#[derive(Clone)]
pub struct HomotopyEndomorphismAlgebra {
    tilting: CertifiedTiltingComplex,
    field: PrimeField,
    blocks: Vec<EndBlock>,
    basis_blocks: Vec<(usize, usize)>,
    ids: Vec<Vec<Fp>>,
    one: Vec<Fp>,
    radical: DenseMat,
    table: OnceLock<Vec<Vec<Fp>>>,
}

impl std::fmt::Debug for HomotopyEndomorphismAlgebra {
    fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        formatter
            .debug_struct("HomotopyEndomorphismAlgebra")
            .field("summands", &self.tilting.candidate().len())
            .field("dimension", &self.dim())
            .field("radical_dimension", &self.radical.rows())
            .finish()
    }
}

impl HomotopyEndomorphismAlgebra {
    /// Builds every degree-zero homotopy Hom block in summand order.
    pub fn new(
        tilting: &CertifiedTiltingComplex,
    ) -> Result<HomotopyEndomorphismAlgebra, ChainMapError> {
        let count = tilting.candidate().len();
        let field = tilting.candidate().algebra().field();
        let mut blocks = Vec::with_capacity(count * count);
        let mut basis_blocks = Vec::new();
        let mut offset = 0usize;
        for source in 0..count {
            for target in 0..count {
                let quotient = HomotopyHom::new(
                    tilting.candidate().summands()[source].complex(),
                    tilting.candidate().summands()[target].complex(),
                    0,
                )?
                .quotient()?;
                for local in 0..quotient.dim() {
                    basis_blocks.push((blocks.len(), local));
                }
                let dimension = quotient.dim();
                blocks.push(EndBlock {
                    source,
                    target,
                    offset,
                    quotient,
                });
                offset += dimension;
            }
        }
        let dim = offset;
        let mut ids = Vec::with_capacity(count);
        for index in 0..count {
            let block = &blocks[index * count + index];
            let identity = ChainMap::identity(tilting.candidate().summands()[index].complex());
            let (coordinates, _) = block.quotient.reduce(&identity)?;
            let mut row = vec![field.zero(); dim];
            row[block.offset..block.offset + coordinates.len()].copy_from_slice(&coordinates);
            ids.push(row);
        }
        let mut one = vec![field.zero(); dim];
        for id in &ids {
            for (value, coefficient) in one.iter_mut().zip(id) {
                *value = field.add(*value, *coefficient);
            }
        }
        let radical_rows: Vec<Vec<Fp>> = basis_blocks
            .iter()
            .enumerate()
            .filter(|(_, (block, _))| blocks[*block].source != blocks[*block].target)
            .map(|(basis, _)| {
                let mut row = vec![field.zero(); dim];
                row[basis] = field.one();
                row
            })
            .collect();
        let radical = DenseMat::from_rows_with_cols(&radical_rows, dim);
        Ok(HomotopyEndomorphismAlgebra {
            tilting: tilting.clone(),
            field,
            blocks,
            basis_blocks,
            ids,
            one,
            radical,
            table: OnceLock::new(),
        })
    }

    accessor_methods! {
        /// The certified tilting complex.
        pub tilting() -> &CertifiedTiltingComplex = |this| &this.tilting;
        /// The base prime field.
        pub field() -> PrimeField = |this| this.field;
        /// The dimension of `End_K(T)`.
        pub dim() -> usize = |this| this.basis_blocks.len();
        /// Coordinates of the identity.
        pub one() -> &[Fp] = |this| &this.one;
        /// One primitive idempotent row per ordered summand.
        pub idempotents() -> &[Vec<Fp>] = |this| &this.ids;
        /// The exact radical basis in the exceptional domain.
        pub radical_basis() -> &DenseMat = |this| &this.radical;
    }

    /// The dimension of `Hom_K(T_source, T_target)`.
    pub fn block_dimension(&self, source: usize, target: usize) -> Option<usize> {
        let count = self.tilting.candidate().len();
        (source < count && target < count)
            .then(|| self.blocks[source * count + target].quotient.dim())
    }

    fn structure_table(&self) -> &Vec<Vec<Fp>> {
        self.table.get_or_init(|| {
            let dim = self.dim();
            let mut table = vec![vec![self.field.zero(); dim]; dim * dim];
            for (left, &(left_block, left_local)) in self.basis_blocks.iter().enumerate() {
                for (right, &(right_block, right_local)) in self.basis_blocks.iter().enumerate() {
                    let left_data = &self.blocks[left_block];
                    let right_data = &self.blocks[right_block];
                    if left_data.target != right_data.source {
                        continue;
                    }
                    let product = left_data
                        .quotient
                        .representative(&unit(self.field, left_data.quotient.dim(), left_local))
                        .then(&right_data.quotient.representative(&unit(
                            self.field,
                            right_data.quotient.dim(),
                            right_local,
                        )))
                        .expect("composable homotopy classes have matching middle terms");
                    let output = &self.blocks
                        [left_data.source * self.tilting.candidate().len() + right_data.target];
                    let coordinates = output
                        .quotient
                        .reduce(&product)
                        .expect("a composite reduces in its homotopy Hom block")
                        .0;
                    table[left * dim + right][output.offset..output.offset + coordinates.len()]
                        .copy_from_slice(&coordinates);
                }
            }
            table
        })
    }

    /// Multiplies coordinates in left-to-right chain-map order.
    pub fn multiply(&self, left: &[Fp], right: &[Fp]) -> Vec<Fp> {
        assert_eq!(left.len(), self.dim(), "left coordinate count");
        assert_eq!(right.len(), self.dim(), "right coordinate count");
        let mut output = vec![self.field.zero(); self.dim()];
        let table = self.structure_table();
        for (i, &a) in left.iter().enumerate() {
            if a.is_zero() {
                continue;
            }
            for (j, &b) in right.iter().enumerate() {
                if b.is_zero() {
                    continue;
                }
                let scale = self.field.mul(a, b);
                for (value, &coefficient) in output.iter_mut().zip(&table[i * self.dim() + j]) {
                    *value = self.field.add(*value, self.field.mul(scale, coefficient));
                }
            }
        }
        output
    }

    /// Recomputes every block, identity, radical row, and basis product.
    pub fn verify(&self) -> bool {
        if !self.tilting.verify() {
            return false;
        }
        let Ok(rebuilt) = HomotopyEndomorphismAlgebra::new(&self.tilting) else {
            return false;
        };
        self.dim() == rebuilt.dim()
            && self.ids == rebuilt.ids
            && self.radical == rebuilt.radical
            && (0..self.dim()).all(|left| {
                (0..self.dim()).all(|right| {
                    self.structure_table()[left * self.dim() + right]
                        == rebuilt.structure_table()[left * self.dim() + right]
                })
            })
    }
}

fn unit(field: PrimeField, length: usize, index: usize) -> Vec<Fp> {
    let mut row = vec![field.zero(); length];
    row[index] = field.one();
    row
}

impl CoordinateAlgebra for HomotopyEndomorphismAlgebra {
    fn field(&self) -> PrimeField {
        self.field
    }

    fn dim(&self) -> usize {
        self.dim()
    }

    fn radical_basis(&self) -> &DenseMat {
        &self.radical
    }

    fn radical_dim(&self) -> usize {
        self.radical.rows()
    }

    fn one(&self) -> &[Fp] {
        &self.one
    }

    fn multiply(&self, left: &[Fp], right: &[Fp]) -> Vec<Fp> {
        self.multiply(left, right)
    }
}

/// A checked target cut for one tilting complex.
#[derive(Clone, Debug)]
pub struct ComplexTargetCut {
    tilting: CertifiedTiltingComplex,
    limits: TargetLimits,
    reason: TargetCutReason,
}

impl ComplexTargetCut {
    accessor_methods! {
        /// The certified tilting complex.
        pub tilting() -> &CertifiedTiltingComplex = |this| &this.tilting;
        /// The effective target limits.
        pub limits() -> &TargetLimits = |this| &this.limits;
        /// The first rejected reservation.
        pub reason() -> &TargetCutReason = |this| &this.reason;
    }

    /// Repeats target recovery and requires the same cut.
    pub fn verify(&self) -> bool {
        matches!(
            present_complex_target(&self.tilting, &self.limits),
            Ok(ComplexTargetOutcome::Cut(cut)) if cut.reason == self.reason
        )
    }
}

/// A verified presentation of `End_K(T)^op`.
#[derive(Clone)]
pub struct VerifiedComplexTargetPresentation {
    tilting: CertifiedTiltingComplex,
    limits: TargetLimits,
    endo: HomotopyEndomorphismAlgebra,
    data: CoordinateTargetData,
}

impl std::fmt::Debug for VerifiedComplexTargetPresentation {
    fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        formatter
            .debug_struct("VerifiedComplexTargetPresentation")
            .field("endomorphism_dimension", &self.endo.dim())
            .field("target_dimension", &self.data.target.dim())
            .field("arrows", &self.data.target.quiver().num_arrows())
            .finish()
    }
}

impl VerifiedComplexTargetPresentation {
    accessor_methods! {
        /// The certified source tilting complex.
        pub tilting() -> &CertifiedTiltingComplex = |this| &this.tilting;
        /// The homotopy endomorphism algebra.
        pub endo() -> &HomotopyEndomorphismAlgebra = |this| &this.endo;
        /// The recovered algebra `End_K(T)^op`.
        pub target() -> &Arc<Algebra> = |this| &this.data.target;
        /// The target completion certificate.
        pub completion_certificate() -> &Certificate = |this| &this.data.completion;
        /// Primitive idempotent images in `End_K(T)`.
        pub idempotent_images() -> &DenseMat = |this| &this.data.idempotent_images;
        /// Target arrow images in `End_K(T)`.
        pub arrow_images() -> &DenseMat = |this| &this.data.arrow_images;
        /// Target normal-word images in `End_K(T)`.
        pub normal_word_images() -> &DenseMat = |this| &this.data.normal_word_images;
        /// The inverse normal-word coordinate map.
        pub normal_word_preimages() -> &DenseMat = |this| &this.data.normal_word_preimages;
        /// The radical nilpotency index.
        pub radical_nilpotency_index() -> usize = |this| this.data.radical_nilpotency_index;
        /// Exact target-recovery work.
        pub work() -> TargetWork = |this| this.data.work;
        /// The effective target limits.
        pub limits() -> &TargetLimits = |this| &this.limits;
    }

    /// Rebuilds the homotopy algebra and independently checks the target map.
    pub fn verify(&self) -> bool {
        let Ok(endo) = HomotopyEndomorphismAlgebra::new(&self.tilting) else {
            return false;
        };
        endo.verify()
            && verify_coordinate_target_data(&endo, endo.idempotents(), &self.limits, &self.data)
    }
}

/// Target recovery completed or stopped at a typed limit.
#[derive(Clone, Debug)]
pub enum ComplexTargetOutcome {
    /// A complete verified target presentation.
    Presented(Box<VerifiedComplexTargetPresentation>),
    /// A target budget stopped recovery.
    Cut(Box<ComplexTargetCut>),
}

/// Recovers `End_K(T)^op` from degree-zero homotopy Hom quotients.
pub fn present_complex_target(
    tilting: &CertifiedTiltingComplex,
    limits: &TargetLimits,
) -> Result<ComplexTargetOutcome, ComplexTargetError> {
    if !tilting.verify() {
        return Err(ComplexTargetError::InvalidTilting);
    }
    let endo = HomotopyEndomorphismAlgebra::new(tilting)?;
    match recover_coordinate_target(&endo, endo.idempotents(), limits)? {
        CoordinateTargetOutcome::Presented(data) => {
            let verified = VerifiedComplexTargetPresentation {
                tilting: tilting.clone(),
                limits: limits.clone(),
                endo,
                data: *data,
            };
            if !verified.verify() {
                return Err(ComplexTargetError::Defect {
                    reason: "the complex-target verifier rejected the presentation".to_string(),
                });
            }
            Ok(ComplexTargetOutcome::Presented(Box::new(verified)))
        }
        CoordinateTargetOutcome::Cut(reason) => {
            Ok(ComplexTargetOutcome::Cut(Box::new(ComplexTargetCut {
                tilting: tilting.clone(),
                limits: limits.clone(),
                reason,
            })))
        }
    }
}

/// A complex target failed construction or verification.
#[derive(Clone, Debug)]
pub enum ComplexTargetError {
    /// The supplied tilting certificate failed verification.
    InvalidTilting,
    /// A homotopy Hom block failed construction.
    Chain(ChainMapError),
    /// The shared target engine rejected the coordinate algebra.
    Target(TargetError),
    /// An internal cross-check failed.
    Defect { reason: String },
}

display_error! { ComplexTargetError {
    Self::InvalidTilting => "tilting-complex certificate does not verify";
    Self::Chain(error) => "homotopy endomorphism block failed: {error}";
    Self::Target(error) => "complex target failed: {error}";
    Self::Defect { reason } => "complex target cross-check failed: {reason}";
} }

error_source! { ComplexTargetError {
    Self::Chain(error) => Some(error),
    Self::Target(error) => Some(error),
    _ => None,
} }

from_variants! { ComplexTargetError {
    ChainMapError => Chain,
    TargetError => Target,
} }