Skip to content

Add coordinate types to index SecondaryExtAlgebra as a Cλ²-module#250

Open
JoeyBF wants to merge 1 commit into
SpectralSequences:masterfrom
JoeyBF:secondary_element
Open

Add coordinate types to index SecondaryExtAlgebra as a Cλ²-module#250
JoeyBF wants to merge 1 commit into
SpectralSequences:masterfrom
JoeyBF:secondary_element

Conversation

@JoeyBF

@JoeyBF JoeyBF commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

ExtAlgebra is a first-class Cλ-module, indexed by the coordinate triple Bidegree / BidegreeGenerator / BidegreeElement. SecondaryExtAlgebra is the analogous Cλ²-module but lacked the matching coordinate types; this adds them so you can index into it the same way.

New secondary coordinate triple in ext/src/secondary.rs:

  • Weight: the λ-adic weight (Ext = 0, Lambda = 1; only two weights since λ² = 0), with an as_i32 synthetic coordinate.
  • SecondaryDegree: a base bidegree b — weight-0 part at b, weight-1 (λ) part at b + LAMBDA_BIDEGREE. Analog of Bidegree.
  • SecondaryGenerator: base + Weight + idx; into_element places the unit entry in the ext or λ part. Analog of BidegreeGenerator.
  • SecondaryElement: base + ext/λ FpVectors (promoted from the earlier SyntheticElement). A generic class is not weight-homogeneous, so both parts are stored. Analog of BidegreeElement.

Indexing methods on SecondaryExtAlgebra mirror ExtAlgebra (dimension/basis/element/generator, weight_dimension, and unit_* variants). They read ambient generator counts like ExtAlgebra::dimension, so the secondary d2/E3 structure stays a separate computation; undefined bidegrees panic rather than yielding a silent 0. SecondaryProduct.value and both examples use SecondaryElement.

The Weight enum is designed to feed a future 3-graded synthetic spectral sequence; the B/Z/E differential filtration is left for that later layer.

Claude-Session: https://claude.ai/code/session_0125sG5YPRQVfTs5eZ7hN7hA

Summary by CodeRabbit

  • New Features

    • Added support for displaying secondary algebra objects in a cleaner, more compact form.
    • Introduced new ways to inspect secondary degrees, generators, and elements, including basis and dimension lookups.
    • Expanded the public secondary algebra API for creating and working with secondary classes and unit-layer variants.
  • Bug Fixes

    • Simplified product and Massey-product output to show a single combined value instead of separate parts.

ExtAlgebra is a first-class Cλ-module, indexed by the coordinate triple
Bidegree / BidegreeGenerator / BidegreeElement. SecondaryExtAlgebra is the
analogous Cλ²-module but lacked the matching coordinate types; this adds them so
you can index into it the same way.

New secondary coordinate triple in ext/src/secondary.rs:
- Weight: the λ-adic weight (Ext = 0, Lambda = 1; only two weights since λ² = 0),
  with an as_i32 synthetic coordinate.
- SecondaryDegree: a base bidegree b — weight-0 part at b, weight-1 (λ) part at
  b + LAMBDA_BIDEGREE. Analog of Bidegree.
- SecondaryGenerator: base + Weight + idx; into_element places the unit entry in
  the ext or λ part. Analog of BidegreeGenerator.
- SecondaryElement: base + ext/λ FpVectors (promoted from the earlier
  SyntheticElement). A generic class is not weight-homogeneous, so both parts are
  stored. Analog of BidegreeElement.

Indexing methods on SecondaryExtAlgebra mirror ExtAlgebra
(dimension/basis/element/generator, weight_dimension, and unit_* variants). They
read ambient generator counts like ExtAlgebra::dimension, so the secondary
d2/E3 structure stays a separate computation; undefined bidegrees panic rather
than yielding a silent 0. SecondaryProduct.value and both examples use
SecondaryElement.

The Weight enum is designed to feed a future 3-graded synthetic spectral
sequence; the B/Z/E differential filtration is left for that later layer.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0125sG5YPRQVfTs5eZ7hN7hA
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Introduces Weight, SecondaryDegree, SecondaryGenerator, and SecondaryElement types in secondary.rs. Adds dimension, basis, element, and generator indexing methods (plus unit_* variants) to SecondaryExtAlgebra. Refactors SecondaryProduct from separate ext_part/lambda_part fields to a single value: SecondaryElement. Updates examples to use the new Display-based formatting.

Changes

Secondary Homotopy Types and API

Layer / File(s) Summary
Weight, SecondaryDegree, SecondaryGenerator, SecondaryElement types
ext/src/secondary.rs
Defines Weight enum (Ext/Lambda), SecondaryDegree (base bidegree + λ-part derivation), SecondaryGenerator (base, weight, idx, into_element), and SecondaryElement (ext + lambda FpVectors, from_concatenated, to_basis_string, Display).
SecondaryExtAlgebra indexing methods and SecondaryProduct refactor
ext/src/ext_algebra/secondary.rs
Refactors SecondaryProduct to use a single value: SecondaryElement field; adds weight_dimension, dimension, basis, element, generator, and unit_* variants to SecondaryExtAlgebra; updates secondary_multiply_into and rewrites test_secondary_indexing.
Re-exports and example output updates
ext/src/ext_algebra/mod.rs, ext/examples/secondary_massey.rs, ext/examples/secondary_product.rs
Re-exports SecondaryDegree, SecondaryElement, SecondaryGenerator, Weight from ext_algebra; updates both examples to construct and print SecondaryElement directly instead of manual Ext/λ decomposition.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • SpectralSequences/sseq#241: Introduced SecondaryProduct with ext_part/lambda_part fields and the secondary product/d2 machinery that this PR directly refactors into the unified value: SecondaryElement representation.

Suggested reviewers

  • hoodmane

🐇 Hopping through the Ext and λ land,
I found two vectors, merged by hand!
SecondaryElement now holds them tight,
to_basis_string prints them right.
Weight is Ext or Lambda — pick your fate,
The secondary world just got more great! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding coordinate types and indexing support for SecondaryExtAlgebra as a Cλ²-module.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ext/src/ext_algebra/secondary.rs`:
- Around line 430-479: Extend the existing `test_secondary_indexing` fixture to
also exercise the new `SecondaryExtAlgebra` unit-side indexing API
(`unit_weight_dimension`, `unit_dimension`, `unit_basis`, `unit_element`, and
`unit_generator`) alongside the current `weight_dimension`, `dimension`,
`basis`, `element`, and `generator` checks. Reuse the same
`SecondaryDegree`/`Bidegree` cases and verify the unit methods return consistent
dimensions, basis ordering, round-tripping, and single-entry coordinates so both
coordinate paths are covered by the same test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 023db473-9591-4d01-a7ec-4c94e1eb7565

📥 Commits

Reviewing files that changed from the base of the PR and between faff1d6 and 264e1ce.

📒 Files selected for processing (5)
  • ext/examples/secondary_massey.rs
  • ext/examples/secondary_product.rs
  • ext/src/ext_algebra/mod.rs
  • ext/src/ext_algebra/secondary.rs
  • ext/src/secondary.rs

Comment on lines +430 to +479
fn test_secondary_indexing() {
let res = Arc::new(construct_standard::<false, _, _>("S_2", None).unwrap());
res.compute_through_stem(Bidegree::n_s(8, 8));
let e2 = Arc::new(ExtAlgebra::new(Arc::clone(&res), res));
let sec = SecondaryExtAlgebra::new(Arc::clone(&e2));

// (0,0): bottom class + λh0; (0,1): h0 + λh0²; (1,1): h1 + λ-part.
for (n, s) in [(0, 0), (0, 1), (1, 1)] {
let base = Bidegree::n_s(n, s);
let deg = SecondaryDegree::new(base);

let ext_dim = e2.resolution().number_of_gens_in_bidegree(base);
let lambda_dim = e2
.resolution()
.number_of_gens_in_bidegree(base + LAMBDA_BIDEGREE);

assert_eq!(sec.weight_dimension(deg, Weight::Ext), ext_dim);
assert_eq!(sec.weight_dimension(deg, Weight::Lambda), lambda_dim);
assert_eq!(sec.dimension(deg), ext_dim + lambda_dim);

let basis = sec.basis(deg);
assert_eq!(basis.len(), sec.dimension(deg));

for (i, g) in basis.iter().enumerate() {
// Weight-0 generators come first, then weight-1.
let (expected_weight, expected_idx) = if i < ext_dim {
(Weight::Ext, i)
} else {
(Weight::Lambda, i - ext_dim)
};
assert_eq!(g.weight(), expected_weight);
assert_eq!(g.idx(), expected_idx);
assert_eq!(g.base(), base);

// generator(g) round-trips to element(...) with a single 1 in the right part.
let elt = sec.generator(*g);
let mut ext_coords = vec![0u32; ext_dim];
let mut lambda_coords = vec![0u32; lambda_dim];
match g.weight() {
Weight::Ext => ext_coords[g.idx()] = 1,
Weight::Lambda => lambda_coords[g.idx()] = 1,
}
assert_eq!(elt, sec.element(deg, &ext_coords, &lambda_coords));
assert_eq!(
elt.ext().iter_nonzero().count() + elt.lambda().iter_nonzero().count(),
1
);
}
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the new unit_* indexing methods.

This test validates the module-side indexing API, but the PR also adds the parallel public unit_weight_dimension, unit_dimension, unit_basis, unit_element, and unit_generator methods. Extending this fixture to exercise those variants would catch drift between the two coordinate paths.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ext/src/ext_algebra/secondary.rs` around lines 430 - 479, Extend the existing
`test_secondary_indexing` fixture to also exercise the new `SecondaryExtAlgebra`
unit-side indexing API (`unit_weight_dimension`, `unit_dimension`, `unit_basis`,
`unit_element`, and `unit_generator`) alongside the current `weight_dimension`,
`dimension`, `basis`, `element`, and `generator` checks. Reuse the same
`SecondaryDegree`/`Bidegree` cases and verify the unit methods return consistent
dimensions, basis ordering, round-tripping, and single-entry coordinates so both
coordinate paths are covered by the same test.

JoeyBF pushed a commit to JoeyBF/sseq that referenced this pull request Jun 28, 2026
Use prod.value (SecondaryElement) instead of the removed ext_part/lambda_part
fields in lambda2.rs Table IV. Fix nightly rustfmt import grouping.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017kezHiWcYod7hYovRPczz9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants