secondary/
secondary.rs

1//! This computes $d_2$ differentials in the Adams spectral sequence. This only works for fairly
2//! specific modules, but tends to cover most cases of interest.
3//!
4//! # Usage
5//! This asks for a module in the usual way, and verifies that the module satisfies the conditions
6//! necessary for the algorithm the work. It only works with the Milnor basis.
7//!
8//! # Output
9//! We omit differentials if the target bidegree is zero.
10//!
11//! # Sharding
12//! *This section applies to all of the secondary scripts, namely `secondary`,
13//! [`secondary_product`](../secondary_product/index.html)
14//! and [`secondary_massey`](../secondary_massey/index.html).*
15//!
16//! Most of the computation can be fully distributed. Rudimentary sharding over multiple machines
17//! is currently supported, where each machine works on a single `s`.
18//!
19//! These machines should share the same save directory (e.g. over a network-mounted drive), and
20//! all prerequisites for the computation must have been computed. This includes the "primary" data
21//! (resolutions, lifts, etc.) as well as the secondary prerequisites (the secondary resolution for
22//! secondary products, secondary products for secondary Massey product). Otherwise, conflicts may
23//! arise.
24//!
25//! To compute data for a single `s`, run the script with the environment variable
26//! `SECONDARY_JOB=s`. The minimum value of `s` is the cohomological degree shift of the secondary
27//! homotopy (i.e. the difference in degrees between the input class and the λ part of the answer;
28//! 2 in the case of `secondary`), and the maximum value of `s` is the `max_s` of the resolution.
29//!
30//! After running this script for all `s` in the range, run it as usual to produce the final
31//! output. An example script is as follows:
32//!
33//! ```shell
34//! #!/bin/sh
35//!
36//! cargo run --example resolve_through_stem S_2 /tmp/save 40 20;
37//!
38//! cargo build --example secondary
39//! for n in `seq 20 -1 2`; do
40//!     SECONDARY_JOB=$n target/debug/examples/secondary S_2 /tmp/save 40 20 &
41//! done
42//!
43//! wait
44//!
45//! target/debug/examples/secondary S_2 /tmp/save 40 20;
46//! ```
47
48use std::sync::Arc;
49
50use algebra::module::Module;
51use ext::{
52    chain_complex::{ChainComplex, FreeChainComplex},
53    secondary::*,
54    utils::query_module,
55};
56use sseq::coordinates::{Bidegree, BidegreeGenerator};
57
58fn main() -> anyhow::Result<()> {
59    ext::utils::init_logging()?;
60
61    let resolution = Arc::new(query_module(Some(algebra::AlgebraType::Milnor), true)?);
62
63    let lift = SecondaryResolution::new(Arc::clone(&resolution));
64    if let Some(s) = ext::utils::secondary_job() {
65        lift.compute_partial(s);
66        return Ok(());
67    }
68
69    lift.extend_all();
70
71    let d2_shift = Bidegree::n_s(-1, 2);
72
73    // Iterate through target of the d2
74    for b in lift.underlying().iter_nonzero_stem() {
75        if b.s() < 3 {
76            continue;
77        }
78
79        if b.t() - 1 > resolution.module(b.s() - 2).max_computed_degree() {
80            continue;
81        }
82        let homotopy = lift.homotopy(b.s());
83        let m = homotopy.homotopies.hom_k(b.t() - 1);
84
85        for (i, entry) in m.into_iter().enumerate() {
86            let source_gen = BidegreeGenerator::new(b - d2_shift, i);
87            println!("d_2 x_{source_gen} = {entry:?}");
88        }
89    }
90
91    Ok(())
92}