Skip to content

fix: conjugate right operand in co-rep a0.u construction#289

Merged
lan496 merged 5 commits into
developfrom
fix/corep-xi-conjugation
Apr 24, 2026
Merged

fix: conjugate right operand in co-rep a0.u construction#289
lan496 merged 5 commits into
developfrom
fix/corep-xi-conjugation

Conversation

@lan496

@lan496 lan496 commented Apr 24, 2026

Copy link
Copy Markdown
Member

Summary

  • Fix a bug in all three ξ ∈ {+1, −1, 0} branches of _enumerate_small_corepresentations_with_factor_system: the right operand was applied without complex conjugation, violating the co-rep multiplication law Γ(a) · Γ(u)^* = ω(a, u) · Γ(a · u) whenever the unitary-subgroup irrep Γ(u) has non-real entries. Solving for Γ(a · u) with |ω| = 1 (unit-modulus for every factor system spgrep builds) gives conj(ω(a, u)) · U · conj(Γ(u)). enumerate_spinor_small_corepresentations reuses this helper, so the same bug affected the spinor path.
  • Sync docs/formulation/irreps/corep.md by adding ^* on Γ̃(u) in each Γ̃(a₀u) formula.
  • Add regression coverage: the existing corep tests never asserted the co-rep multiplication law on their outputs, and every pre-existing fixture happened to produce real Γ(u) matrices (so conj(Γ(u)) = Γ(u) masked the error). A dedicated test on SG 221 Pm-3m at k = (1/4, 1/4, 1/4) -- where the 2-dim E irrep of D₃ appears and is non-real -- reproduces the bug (72/144 pairs fail before the fix). The spinor co-rep test is also extended to assert the multiplication law on every co-irrep it produces.

Test plan

  • uv run pytest tests/test_corep.py -- new regression passes; extended spinor test still passes.
  • uv run pytest tests/ -- full suite (132 passed, 1 skipped).
  • prek run --files src/spgrep/corep.py tests/test_corep.py docs/formulation/irreps/corep.md -- ruff / mypy / format clean.
  • CI green (GitHub Actions).
  • Docs build (uv run sphinx-build docs docs_build) shows no new warnings.

[Claude Code] Generated with Claude Code

The co-rep multiplication law Gamma(a) . Gamma(u)^* = omega(a, u) . Gamma(a.u)
(a anti-linear, u in D) gives Gamma(a.u) = conj(omega(a, u)) . U . conj(Gamma(u))
once |omega| = 1 is used -- an assumption that holds for every factor system
spgrep builds (non-symmorphic exp(-2pi i g.w) is unit-modulus; spinor factor
takes values in {-1, +1}).

All three xi in {+1, -1, 0} branches of
`_enumerate_small_corepresentations_with_factor_system` applied the right
operand without the complex conjugation, violating the co-rep law whenever
the underlying unitary-subgroup irrep Gamma(u) has non-real entries. The
spinor path `enumerate_spinor_small_corepresentations` reuses this helper, so
the bug affected it too.

The bug was invisible to the existing tests because every fixture happened to
produce real Gamma(u) matrices; conj(Gamma(u)) = Gamma(u) masked the
error. SG 221 Pm-3m at k = (1/4, 1/4, 1/4) with the 2-dim E irrep of D_3
triggers it (72/144 pairs fail before the fix).

- `src/spgrep/corep.py`: add `np.conj(...)` on the right operand in all
  three xi branches.
- `docs/formulation/irreps/corep.md`: add `^*` on Gamma-tilde(u) in each
  Gamma-tilde(a_0 u) formula to match the corrected code.
- `tests/test_corep.py`: add `_assert_corep_composition_law` helper; add
  `test_corep_composition_law_pm3m_lambda` regression using the reproducer
  from the issue; extend spinor co-rep test to assert the composition law
  on every produced co-irrep.
Comment thread tests/test_corep.py Outdated
@lan496 lan496 added the bug Something isn't working label Apr 24, 2026
lan496 added 4 commits April 24, 2026 21:43
Address PR review: identify the group by ITA number rather than the
Hermann-Mauguin symbol in both the test name and docstring.
Add the standard Keep a Changelog preamble and restructure the Unreleased
section into the conventional categorized subsections (Added, Changed,
Fixed, ...). Historical version entries are left untouched.
Update the release-workflow note to mention the Unreleased-section pattern
introduced with the Keep a Changelog format. Add two conventions: changelog
format/policy, and the co-representation multiplication-law rule that
explains why the right operand is conjugated in `corep.py`.
@lan496
lan496 marked this pull request as ready for review April 24, 2026 12:47
Copilot AI review requested due to automatic review settings April 24, 2026 12:47
@lan496

lan496 commented Apr 24, 2026

Copy link
Copy Markdown
Member Author

@codex

Copilot AI 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.

Pull request overview

Fixes co-representation construction in spgrep.corep by correctly complex-conjugating the right operand in the anti-linear multiplication rule, and adds documentation + regression tests to prevent recurrence.

Changes:

  • Correct _enumerate_small_corepresentations_with_factor_system to use @ np.conj(...) when forming Γ(a₀u) across all Frobenius–Schur indicator branches.
  • Add/extend tests to assert the co-representation multiplication law (including a targeted non-real irrep regression for SG 221 at k = (1/4,1/4,1/4)).
  • Update theory docs and changelog/release guidance to reflect the correct Γ(u)^* convention and Keep-a-Changelog structure.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/spgrep/corep.py Fixes the co-rep extension formula by conjugating the right operand for anti-linear composition.
tests/test_corep.py Adds a reusable assertion for the co-rep law and introduces a regression test that fails without the fix.
docs/formulation/irreps/corep.md Updates formulas to include the required conjugation on \tilde{\Gamma}(u).
docs/changelog.md Adds an Unreleased/Fixed entry describing the bug fix under Keep a Changelog structure.
CLAUDE.md Updates release instructions and documents the co-representation multiplication convention used in the codebase.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lan496

lan496 commented Apr 24, 2026

Copy link
Copy Markdown
Member Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lan496
lan496 merged commit a46224f into develop Apr 24, 2026
11 checks passed
@lan496
lan496 deleted the fix/corep-xi-conjugation branch April 24, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants