geometric_rep_theory 0.1.1

Algebraic and geometric structures arising in mathematical physics and mirror symmetry.
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
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
use std::{collections::HashMap, sync::Arc};

use nonempty::NonEmpty;
use num::Integer;

use crate::quiver_algebra::{
    BasisElt, DegreeLabel, HasHomologicalDegree, PathAlgebra, Quiver, Ring,
};

/// A differential graded path algebra `(kQ, d)`.
///
/// Wraps a graded quiver `Q` (with `DegreeLabel`-decorated edges) together with a degree-+1
/// derivation `d` satisfying `d² = 0` and the graded Leibniz rule. The differential is stored
/// as a map `arrow ↦ PathAlgebra element` for arrows that have non-trivial `d`.
pub struct GradedDifferentialQuiver<VertexLabel, EdgeLabel, Coeffs, const OP_ALG: bool>
where
    VertexLabel: std::hash::Hash + Eq + Clone,
    EdgeLabel: Eq + Clone + std::hash::Hash,
    Coeffs: Ring,
{
    quiver_arc: Arc<Quiver<VertexLabel, DegreeLabel<EdgeLabel>>>,
    differential:
        HashMap<EdgeLabel, PathAlgebra<VertexLabel, DegreeLabel<EdgeLabel>, Coeffs, OP_ALG>>,
}

impl<VertexLabel, EdgeLabel, Coeffs, const OP_ALG: bool>
    GradedDifferentialQuiver<VertexLabel, EdgeLabel, Coeffs, OP_ALG>
where
    VertexLabel: std::hash::Hash + Eq + Clone,
    EdgeLabel: Eq + Clone + std::hash::Hash,
    Coeffs: Ring,
{
    /// Construct a DGA from a graded quiver and a map of arrow differentials.
    ///
    /// Arrow labels not present in `quiver_arc` are silently dropped from `differential`.
    #[must_use = "You have endowed the path algebra with a differential. Not using this gets rid of that information"]
    pub fn new(
        quiver_arc: Arc<Quiver<VertexLabel, DegreeLabel<EdgeLabel>>>,
        mut differential: HashMap<
            EdgeLabel,
            PathAlgebra<VertexLabel, DegreeLabel<EdgeLabel>, Coeffs, OP_ALG>,
        >,
    ) -> Self {
        let edge_names = quiver_arc
            .edge_labels()
            .map(DegreeLabel::name)
            .collect::<Vec<_>>();
        differential.retain(|k, _| edge_names.contains(&k));
        for v in differential.values() {
            debug_assert!(
                v.all_parallel().is_ok(),
                "a = e_s a e_t so da = e_s da e_t so it better be all parallel summands or no summands"
            );
        }
        Self {
            quiver_arc,
            differential,
        }
    }

    /// The underlying graded quiver.
    #[must_use = "What do you want with the underlying quiver of it's differential graded path algebra?"]
    pub fn quiver(&self) -> &Arc<Quiver<VertexLabel, DegreeLabel<EdgeLabel>>> {
        &self.quiver_arc
    }

    pub(crate) fn apply_differential_letter(
        &self,
        letter: &DegreeLabel<EdgeLabel>,
    ) -> Option<PathAlgebra<VertexLabel, DegreeLabel<EdgeLabel>, Coeffs, OP_ALG>> {
        self.differential.get(letter.name()).cloned()
    }

    pub(crate) fn apply_differential_word(
        &self,
        word: &[DegreeLabel<EdgeLabel>],
    ) -> PathAlgebra<VertexLabel, DegreeLabel<EdgeLabel>, Coeffs, OP_ALG> {
        let mut result = PathAlgebra::zero(self.quiver_arc.clone());
        for idx in 0..word.len() {
            let removed_edge_src_tgt = self
                .quiver()
                .edge_endpoint_labels(&word[idx])
                .expect("This is an edge in the quiver");
            let before_part = BasisElt::create(&word[..idx])
                .unwrap_or_else(|| BasisElt::Idempotent(removed_edge_src_tgt.0.clone()));
            let after_part = BasisElt::create(&word[idx + 1..])
                .unwrap_or_else(|| BasisElt::Idempotent(removed_edge_src_tgt.1.clone()));
            if let Some(diff_part) = self.apply_differential_letter(&word[idx]) {
                let mut cur_contrib = diff_part;
                cur_contrib = before_part * cur_contrib;
                cur_contrib *= after_part;
                let sign: bool = word[..idx]
                    .iter()
                    .map(|e| e.homological_degree().expect("has homological degree"))
                    .sum::<i64>()
                    .is_odd();
                if sign {
                    result -= cur_contrib;
                } else {
                    result += cur_contrib;
                }
            }
        }
        result
    }

    pub(crate) fn apply_differential_path(
        &self,
        path: &NonEmpty<DegreeLabel<EdgeLabel>>,
    ) -> PathAlgebra<VertexLabel, DegreeLabel<EdgeLabel>, Coeffs, OP_ALG> {
        if path.len() == 1 {
            self.apply_differential_letter(path.first())
                .unwrap_or_else(|| PathAlgebra::zero(self.quiver_arc.clone()))
        } else {
            let tgt_of_first_edge = self
                .quiver()
                .edge_endpoint_labels(path.first())
                .expect("This is an edge in the quiver")
                .1;
            let just_rest_of_path = BasisElt::create(path.tail())
                .unwrap_or_else(|| BasisElt::Idempotent(tgt_of_first_edge.clone()));
            let sign_first = path
                .first()
                .homological_degree()
                .expect("has homological degree")
                .is_odd();
            // (-1)^|head| head * d(tail)
            let rest_contrib = if sign_first {
                -(BasisElt::Path(NonEmpty::singleton(path.first().clone()))
                    * self.apply_differential_word(&path.tail))
            } else {
                BasisElt::Path(NonEmpty::singleton(path.first().clone()))
                    * self.apply_differential_word(&path.tail)
            };
            if let Some(first_contrib) = self.apply_differential_letter(path.first()) {
                // d(head)*tail
                let mut returning = first_contrib * just_rest_of_path;
                returning += rest_contrib;
                returning
            } else {
                rest_contrib
            }
        }
    }

    /// Apply the differential `d` to an arbitrary algebra element, using the graded Leibniz rule
    /// with Koszul signs. Idempotents are sent to zero.
    pub fn apply_differential(
        &self,
        algebra_element: &PathAlgebra<VertexLabel, DegreeLabel<EdgeLabel>, Coeffs, OP_ALG>,
    ) -> PathAlgebra<VertexLabel, DegreeLabel<EdgeLabel>, Coeffs, OP_ALG> {
        debug_assert!(
            Arc::ptr_eq(algebra_element.quiver(), self.quiver()),
            "On same quiver"
        );
        let mut result = PathAlgebra::zero(self.quiver_arc.clone());
        for (basis_elt, coeff) in algebra_element.iter() {
            match basis_elt {
                crate::quiver_algebra::BasisElt::Idempotent(_) => {
                    // The differential of an idempotent is zero.
                }
                crate::quiver_algebra::BasisElt::Path(word) => {
                    let current = self.apply_differential_path(word);
                    result += current * coeff.clone();
                }
            }
        }
        result.simplify_default();
        result
    }

    /// Construct the Ginzburg DGA `Γ(Q, W)` from a quiver and superpotential.
    ///
    /// Builds the graded quiver by adding adjoint arrows `a* = label_dagger(a)` (degree −1)
    /// and self-loops `ω_v = self_loop(v)` (degree −2) at each vertex. Sets differentials
    /// `d(a*) = ∂W/∂a` and `d(ω_v) = ∂W_cubic/∂ω_v`, where `W_cubic` is the Ginzburg cubic.
    pub fn create_ginzburg_dga(
        ungraded_quiver: Quiver<VertexLabel, EdgeLabel>,
        original_potential: PathAlgebra<VertexLabel, EdgeLabel, Coeffs, OP_ALG>,
        label_dagger: fn(&EdgeLabel) -> EdgeLabel,
        self_loop: fn(&VertexLabel) -> EdgeLabel,
    ) -> Self {
        let ungraded_quiver = ungraded_quiver.map_labels(|z| z, DegreeLabel::new_deg_zero);
        let (ginzburg_arc, adjoint_pairs, self_loops, ginzburg_cubic) = ungraded_quiver
            .ginzburgify_and_cubic(DegreeLabel::dagger(label_dagger), |v| {
                DegreeLabel::new(self_loop(v), -2)
            });
        let mut differentials = HashMap::<
            EdgeLabel,
            PathAlgebra<VertexLabel, DegreeLabel<EdgeLabel>, Coeffs, OP_ALG>,
        >::with_capacity(ginzburg_arc.num_arrows());
        let original_potential_promoted = PathAlgebra::new(
            ginzburg_arc.clone(),
            original_potential.map_labels(|z| z, DegreeLabel::new_deg_zero),
        );
        for (a, a_dagger) in adjoint_pairs {
            let mut dw_da = original_potential_promoted.clone();
            dw_da.cyclic_derivative(&a);
            differentials.insert(a_dagger.name().clone(), dw_da);
        }
        for ti in self_loops {
            let mut dcubic_dt = ginzburg_cubic.clone();
            dcubic_dt.cyclic_derivative(&ti);
            differentials.insert(ti.name().clone(), dcubic_dt);
        }
        Self::new(ginzburg_arc, differentials)
    }

    /// Returns `true` if `d(algebra_element) = 0`, i.e. the element is closed in the
    /// homological sense (a cocycle).
    #[must_use = "This method checks if the given algebra element is closed (differential is zero).
    If you just want to check if it's closed, use is_definitely_closed instead to avoid the overhead of
    computing the full differential."]
    pub fn is_definitely_closed(
        &self,
        algebra_element: &PathAlgebra<VertexLabel, DegreeLabel<EdgeLabel>, Coeffs, OP_ALG>,
    ) -> bool {
        !self.apply_differential(algebra_element).might_be_nonzero()
    }
}

impl<VertexLabel, EdgeLabel, Coeffs, const OP_ALG: bool> From<Quiver<VertexLabel, EdgeLabel>>
    for GradedDifferentialQuiver<VertexLabel, EdgeLabel, Coeffs, OP_ALG>
where
    VertexLabel: std::hash::Hash + Eq + Clone,
    EdgeLabel: Eq + Clone + std::hash::Hash,
    Coeffs: Ring,
{
    fn from(value: Quiver<VertexLabel, EdgeLabel>) -> Self {
        let value_zero_graded = value.map_labels(|z| z, DegreeLabel::new_deg_zero);
        Self {
            quiver_arc: Arc::new(value_zero_graded),
            differential: HashMap::new(),
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::quiver_algebra::homological_degree::DegreeLabel;
    use nonempty::nonempty;

    /// Build a GradedDifferentialQuiver on a 1-vertex quiver with self-loops
    ///   x  (degree  0)
    ///   y1 (degree -1)
    ///   y2 (degree -1)
    /// and differential d(y1) = x, d(y2) = x, d(x) = 0.
    ///
    /// Checks:
    ///  1. d(y1) = x  (basic lookup)
    ///  2. d²(y1) = 0
    ///  3. d(y1·y2) = x·y2 - y1·x  (Koszul sign from deg(y1) = -1, which is odd)
    ///  4. d²(y1·y2) = 0
    #[test]
    fn d_squared_zero_with_koszul_signs() {
        let x = DegreeLabel::new("x".to_string(), 0i64);
        let y1 = DegreeLabel::new("y1".to_string(), -1i64);
        let y2 = DegreeLabel::new("y2".to_string(), -1i64);

        let mut quiver: Quiver<&str, DegreeLabel<String>> = Quiver::new();
        quiver.add_edge("v", "v", x.clone());
        quiver.add_edge("v", "v", y1.clone());
        quiver.add_edge("v", "v", y2.clone());
        let quiver_arc = Arc::new(quiver);

        let x_elt = PathAlgebra::singleton(
            quiver_arc.clone(),
            BasisElt::Path(nonempty![x.clone()]),
            1i64,
        );

        let mut differential: HashMap<String, PathAlgebra<&str, DegreeLabel<String>, i64, true>> =
            HashMap::new();
        differential.insert("y1".to_string(), x_elt.clone());
        differential.insert("y2".to_string(), x_elt.clone());

        let dga = GradedDifferentialQuiver::new(quiver_arc.clone(), differential);

        let zero = PathAlgebra::zero(quiver_arc.clone());

        // 1. d(y1) = x
        let y1_elt = PathAlgebra::singleton(
            quiver_arc.clone(),
            BasisElt::Path(nonempty![y1.clone()]),
            1i64,
        );
        assert_eq!(dga.apply_differential(&y1_elt), x_elt);

        // 2. d²(y1) = d(x) = 0
        assert_eq!(dga.apply_differential(&x_elt), zero);

        // 3. d(y1·y2) = x·y2 - y1·x
        //    Koszul: the contribution at y2's position carries sign (-1)^{deg(y1)} = (-1)^{-1} = -1.
        let y1_y2 = PathAlgebra::singleton(
            quiver_arc.clone(),
            BasisElt::Path(nonempty![y1.clone(), y2.clone()]),
            1i64,
        );
        let x_y2 = PathAlgebra::singleton(
            quiver_arc.clone(),
            BasisElt::Path(nonempty![x.clone(), y2.clone()]),
            1i64,
        );
        let y1_x = PathAlgebra::singleton(
            quiver_arc.clone(),
            BasisElt::Path(nonempty![y1.clone(), x.clone()]),
            1i64,
        );
        let expected_d_y1y2 = x_y2 - y1_x;
        assert_eq!(
            dga.apply_differential_word(&[y1.clone(), y2.clone()]),
            expected_d_y1y2
        );

        // 4. d²(y1·y2) = 0
        let d_y1y2 = dga.apply_differential(&y1_y2);
        assert_eq!(dga.apply_differential(&d_y1y2), zero);

        // 5. d^2 (x y1 y2 + 5 y1^2 - 7 y2)
        let x_elt = PathAlgebra::singleton(quiver_arc.clone(), BasisElt::Path(nonempty![x]), 1i64);
        let y1_elt =
            PathAlgebra::singleton(quiver_arc.clone(), BasisElt::Path(nonempty![y1]), 1i64);
        let y2_elt =
            PathAlgebra::singleton(quiver_arc.clone(), BasisElt::Path(nonempty![y2]), 1i64);

        let expr = x_elt.clone() * y1_elt.clone() * y2_elt.clone() + y1_elt.clone() * y1_elt * 5i64
            - y2_elt * 7i64;
        let d_expr = dga.apply_differential(&expr);
        assert_eq!(dga.apply_differential(&d_expr), zero);
    }

    #[test]
    fn leibniz_rule() {
        let x = DegreeLabel::new("x".to_string(), 0i64);
        let y1 = DegreeLabel::new("y1".to_string(), -1i64);
        let y2 = DegreeLabel::new("y2".to_string(), -1i64);

        let mut quiver: Quiver<&str, DegreeLabel<String>> = Quiver::new();
        quiver.add_edge("v", "v", x.clone());
        quiver.add_edge("v", "v", y1.clone());
        quiver.add_edge("v", "v", y2.clone());
        let quiver_arc = Arc::new(quiver);

        let x_elt = PathAlgebra::singleton(quiver_arc.clone(), BasisElt::Path(nonempty![x]), 1i64);
        let y1_elt =
            PathAlgebra::singleton(quiver_arc.clone(), BasisElt::Path(nonempty![y1]), 1i64);
        let y2_elt =
            PathAlgebra::singleton(quiver_arc.clone(), BasisElt::Path(nonempty![y2]), 1i64);

        let mut differential: HashMap<String, PathAlgebra<&str, DegreeLabel<String>, i64, true>> =
            HashMap::new();
        differential.insert("y1".to_string(), x_elt.clone());
        differential.insert("y2".to_string(), x_elt.clone());

        let dga = GradedDifferentialQuiver::new(quiver_arc.clone(), differential);

        for a in [x_elt.clone(), y1_elt.clone(), y2_elt.clone()] {
            let sign = if a == x_elt { 1 } else { -1 };
            for b in [x_elt.clone(), y1_elt.clone(), y2_elt.clone()] {
                let a_b = a.clone() * b.clone();
                let d_ab = dga.apply_differential(&a_b);
                let da_b = dga.apply_differential(&a) * b.clone();
                let a_db = a.clone() * dga.apply_differential(&b);
                assert_eq!(d_ab, da_b + a_db * sign);
            }
        }
    }

    /// One-loop Ginzburg DGA with potential W = x^7.
    ///
    /// Quiver: single vertex "v", single loop "x" (degree 0).
    /// Ginzburg quiver adds x* (degree -1) and ω (degree -2).
    ///
    /// Differentials:
    ///   d(x)  = 0          (original arrow, absent from HashMap)
    ///   d(x*) = ∂W/∂x = 7·x^6
    ///   d(ω)  = ∂W_cubic/∂ω = x·x* - x*·x
    #[test]
    fn one_loop_x7_ginzburg_dga() {
        let mut original_quiver: Quiver<&str, String> = Quiver::new();
        original_quiver.add_edge("v", "v", "x".to_string());

        // W = x^7 built against a separate Arc so the quiver can be moved into create_ginzburg_dga
        let w = PathAlgebra::<_, _, _, true>::singleton(
            Arc::new({
                let mut q: Quiver<&str, String> = Quiver::new();
                q.add_edge("v", "v", "x".to_string());
                q
            }),
            BasisElt::Path(nonempty::nonempty![
                "x".to_string(),
                "x".to_string(),
                "x".to_string(),
                "x".to_string(),
                "x".to_string(),
                "x".to_string(),
                "x".to_string()
            ]),
            1.0f64,
        );

        let dga = GradedDifferentialQuiver::create_ginzburg_dga(
            original_quiver,
            w,
            |e| format!("{}*", e),
            |v| format!("omega_{}", v),
        );

        let x_label = DegreeLabel::new_deg_zero("x".to_string());
        let xstar_label = DegreeLabel::new("x*".to_string(), -1);
        let omega_label = DegreeLabel::new("omega_v".to_string(), -2);

        // d(x) is absent (degree 0 arrow, not in differential)
        assert_eq!(dga.apply_differential_letter(&x_label), None);

        // d(x*) = 7·x^6
        let x6 = PathAlgebra::singleton(
            dga.quiver().clone(),
            BasisElt::Path(nonempty::nonempty![
                x_label.clone(),
                x_label.clone(),
                x_label.clone(),
                x_label.clone(),
                x_label.clone(),
                x_label.clone()
            ]),
            7.0f64,
        );
        assert_eq!(dga.apply_differential_letter(&xstar_label), Some(x6));

        // d(ω) = x·x* - x*·x
        let x_xstar = PathAlgebra::singleton(
            dga.quiver().clone(),
            BasisElt::Path(nonempty::nonempty![x_label.clone(), xstar_label.clone()]),
            1.0f64,
        );
        let xstar_x = PathAlgebra::singleton(
            dga.quiver().clone(),
            BasisElt::Path(nonempty::nonempty![xstar_label.clone(), x_label.clone()]),
            1.0f64,
        );
        assert_eq!(
            dga.apply_differential_letter(&omega_label),
            Some(x_xstar - xstar_x)
        );
    }

    /// d(x*·x*) in the one-loop x^7 Ginzburg DGA.
    ///
    /// By Leibniz with |x*| = -1 (odd):
    ///   d(x*·x*) = d(x*)·x* + (-1)^{|x*|} x*·d(x*)
    ///            = 7x^6·x* - 7x*·x^6
    ///
    /// This exercises apply_differential on a compound path using the Koszul sign rule.
    #[test]
    fn one_loop_x7_leibniz_on_xstar_squared() {
        let mut original_quiver: Quiver<&str, String> = Quiver::new();
        original_quiver.add_edge("v", "v", "x".to_string());

        let w = PathAlgebra::<_, _, _, true>::singleton(
            Arc::new({
                let mut q: Quiver<&str, String> = Quiver::new();
                q.add_edge("v", "v", "x".to_string());
                q
            }),
            BasisElt::Path(nonempty::nonempty![
                "x".to_string(),
                "x".to_string(),
                "x".to_string(),
                "x".to_string(),
                "x".to_string(),
                "x".to_string(),
                "x".to_string()
            ]),
            1.0f64,
        );

        let dga = GradedDifferentialQuiver::create_ginzburg_dga(
            original_quiver,
            w,
            |e| format!("{}*", e),
            |v| format!("omega_{}", v),
        );

        let x_label = DegreeLabel::new_deg_zero("x".to_string());
        let xstar_label = DegreeLabel::new("x*".to_string(), -1);

        let xstar_sq = PathAlgebra::singleton(
            dga.quiver().clone(),
            BasisElt::Path(nonempty::nonempty![
                xstar_label.clone(),
                xstar_label.clone()
            ]),
            1.0f64,
        );

        // 7x^6·x*
        let x6_xstar = PathAlgebra::singleton(
            dga.quiver().clone(),
            BasisElt::Path(nonempty::nonempty![
                x_label.clone(),
                x_label.clone(),
                x_label.clone(),
                x_label.clone(),
                x_label.clone(),
                x_label.clone(),
                xstar_label.clone()
            ]),
            7.0f64,
        );
        // 7x*·x^6
        let xstar_x6 = PathAlgebra::singleton(
            dga.quiver().clone(),
            BasisElt::Path(nonempty::nonempty![
                xstar_label.clone(),
                x_label.clone(),
                x_label.clone(),
                x_label.clone(),
                x_label.clone(),
                x_label.clone(),
                x_label.clone()
            ]),
            7.0f64,
        );

        let expected = x6_xstar - xstar_x6;
        assert_eq!(dga.apply_differential(&xstar_sq), expected);
    }

    #[test]
    fn ginzburg_test() {
        let starting_quiver =
            crate::quiver_algebra::make_a2_quiver().map_labels(|v| v, |e| e.to_string());
        let dga = GradedDifferentialQuiver::<_, _, f64, true>::create_ginzburg_dga(
            starting_quiver,
            PathAlgebra::zero(Arc::new(Quiver::new())),
            |e| format!("{}*", e),
            |v| format!("omega_{}", v),
        );
        assert!(dga.quiver().contains_vertex(&"alpha"));
        assert!(dga.quiver().contains_vertex(&"beta"));
        assert!(
            dga.quiver()
                .contains_edge(&DegreeLabel::new_deg_zero("a".to_string()))
        );
        assert!(
            dga.quiver()
                .contains_edge(&DegreeLabel::new("a*".to_string(), -1))
        );
        assert!(
            dga.quiver()
                .contains_edge(&DegreeLabel::new("omega_alpha".to_string(), -2))
        );
        assert!(
            dga.quiver()
                .contains_edge(&DegreeLabel::new("omega_beta".to_string(), -2))
        );

        let da = dga.apply_differential_letter(&DegreeLabel::new("a".to_string(), 0));
        assert_eq!(da, None);

        let zero = PathAlgebra::zero(dga.quiver().clone());
        let a = PathAlgebra::singleton(
            dga.quiver().clone(),
            BasisElt::Path(nonempty::nonempty![DegreeLabel::new_deg_zero(
                "a".to_string()
            )]),
            1.0,
        );
        let a_dag = PathAlgebra::singleton(
            dga.quiver().clone(),
            BasisElt::Path(nonempty::nonempty![DegreeLabel::new("a*".to_string(), -1)]),
            1.0,
        );

        let dadag = dga.apply_differential_letter(&DegreeLabel::new("a*".to_string(), -1));
        assert_eq!(dadag, Some(zero));

        let domega =
            dga.apply_differential_letter(&DegreeLabel::new("omega_alpha".to_string(), -2));
        let expected = a.clone() * a_dag.clone();
        assert_eq!(domega, Some(expected));

        let domega = dga.apply_differential_letter(&DegreeLabel::new("omega_beta".to_string(), -2));
        let expected = -a_dag.clone() * a.clone();
        assert_eq!(domega, Some(expected));
    }
}